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
from django.contrib.sessions.backends.base import SessionBase, CreateError from django.core.cache import cache class SessionStore(SessionBase): """ A cache-based session store. """ def __init__(self, session_key=None): self._cache = cache super(SessionStore, self).__init__(session_key) def load(self): session_data = self._cache.get(self.session_key) if session_data is not None: return session_data self.create() return {} def create(self): # Because a cache can fail silently (e.g. memcache), we don't know if # we are failing to create a new session because of a key collision or # because the cache is missing. So we try for a (large) number of times # and then raise an exception. That's the risk you shoulder if using # cache backing. for i in xrange(10000): self.session_key = self._get_new_session_key() try: self.save(must_create=True) except CreateError: continue self.modified = True return raise RuntimeError("Unable to create a new session key.") def save(self, must_create=False): if must_create: func = self._cache.add else: func = self._cache.set result = func(self.session_key, self._get_session(no_load=must_create), self.get_expiry_age()) if must_create and not result: raise CreateError def exists(self, session_key): if self._cache.has_key(session_key): return True return False def delete(self, session_key=None): if session_key is None: if self._session_key is None: return session_key = self._session_key self._cache.delete(session_key)
ajibawa-2023/Python-Code-Large/train/row_98798
36
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_98798:ImportFrom_L1_C0", "label": "from django.contrib.sessions.backends.base import SessionBase, CreateError", "type": "import", "loc": [1, 1], "level": 0, "parent": null, "vector": [1, 0, 0.0179, 0.0179, 0, 0.66, 0.0, 907, 0, 2, 0, 0, 907, 0, 0], "semantic": {"name": "django.contrib.sessions.backends.base", "arg_names": [], "import_names": ["SessionBase", "CreateError"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.contrib.sessions.backends.base import SessionBase, CreateError"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98798:ImportFrom_L2_C0", "label": "from django.core.cache import cache", "type": "import", "loc": [2, 2], "level": 0, "parent": null, "vector": [1, 0, 0.0357, 0.0179, 0, 0.66, 0.5, 734, 0, 1, 0, 0, 734, 0, 0], "semantic": {"name": "django.core.cache", "arg_names": [], "import_names": ["cache"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.core.cache import cache"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98798:ClassDef_L4_C0", "label": "SessionStore", "type": "class", "loc": [4, 55], "level": 0, "parent": null, "vector": [3, 0, 0.5268, 0.9286, 0, 0.66, 1.0, 951, 0, 6, 0, 0, 324, 0, 13], "semantic": {"name": "SessionStore", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class SessionStore(SessionBase):\n \"\"\"\n A cache-based session store.\n \"\"\"\n def __init__(self, session_key=None):\n self._cache = cache\n super(SessionStore, self).__init__(session_key)\n"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98798:Expr_L5_C4", "label": "expression", "type": "expression", "loc": [5, 7], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98798:ClassDef_L4_C0", "vector": [8, 1, 0.1071, 0.0536, 1, 0.92, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"\n A cache-based session store.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98798:FunctionDef_L8_C4", "label": "__init__", "type": "function", "loc": [8, 10], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98798:ClassDef_L4_C0", "vector": [2, 1, 0.1607, 0.0536, 1, 0.92, 0.1667, 555, 0, 2, 0, 0, 0, 0, 2], "semantic": {"name": "__init__", "arg_names": ["self", "session_key"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def __init__(self, session_key=None):\n self._cache = cache\n super(SessionStore, self).__init__(session_key)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98798:Assign_L9_C8", "label": "self._cache =", "type": "assigned_variable", "loc": [9, 9], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98798:FunctionDef_L8_C4", "vector": [14, 2, 0.1607, 0.0179, 2, 0.93, 0.0, 723, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "self._cache", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self._cache = cache"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98798:Expr_L10_C8", "label": "__init__()", "type": "expression", "loc": [10, 10], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98798:FunctionDef_L8_C4", "vector": [8, 2, 0.1786, 0.0179, 2, 0.93, 1.0, 555, 3, 1, 0, 0, 0, 0, 2], "semantic": {"name": "__init__", "arg_names": [], "import_names": [], "rhs_call_name": "__init__", "annotation": ""}, "snippet": " super(SessionStore, self).__init__(session_key)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98798:FunctionDef_L12_C4", "label": "load", "type": "function", "loc": [12, 17], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98798:ClassDef_L4_C0", "vector": [2, 1, 0.2589, 0.1071, 1, 0.92, 0.3333, 37, 0, 1, 1, 0, 0, 0, 2], "semantic": {"name": "load", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def load(self):\n session_data = self._cache.get(self.session_key)\n if session_data is not None:\n return session_data\n self.create()\n return {}"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98798:Assign_L13_C8", "label": "session_data = get()", "type": "assigned_variable", "loc": [13, 13], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98798:FunctionDef_L12_C4", "vector": [14, 2, 0.2321, 0.0179, 2, 0.32, 0.0, 19, 3, 1, 0, 0, 607, 10, 1], "semantic": {"name": "session_data", "arg_names": [], "import_names": [], "rhs_call_name": "get", "annotation": ""}, "snippet": " session_data = self._cache.get(self.session_key)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98798:If_L14_C8", "label": "if", "type": "if", "loc": [14, 15], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98798:FunctionDef_L12_C4", "vector": [4, 2, 0.2589, 0.0357, 2, 0.32, 0.3333, 0, 0, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if session_data is not None:\n return session_data"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98798:Return_L15_C12", "label": "return", "type": "return", "loc": [15, 15], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98798:If_L14_C8", "vector": [13, 3, 0.2679, 0.0179, 3, 0.55, 0.0, 0, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return session_data"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98798:Expr_L16_C8", "label": "create()", "type": "expression", "loc": [16, 16], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98798:FunctionDef_L12_C4", "vector": [8, 2, 0.2857, 0.0179, 2, 0.32, 0.6667, 316, 3, 0, 0, 0, 0, 0, 1], "semantic": {"name": "create", "arg_names": [], "import_names": [], "rhs_call_name": "create", "annotation": ""}, "snippet": " self.create()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98798:Return_L17_C8", "label": "return", "type": "return", "loc": [17, 17], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98798:FunctionDef_L12_C4", "vector": [13, 2, 0.3036, 0.0179, 2, 0.32, 1.0, 0, 0, 0, 0, 0, 0, 6, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return {}"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98798:FunctionDef_L19_C4", "label": "create", "type": "function", "loc": [19, 33], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98798:ClassDef_L4_C0", "vector": [2, 1, 0.4643, 0.2679, 1, 0.92, 0.5, 316, 0, 1, 0, 0, 0, 0, 4], "semantic": {"name": "create", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def create(self):\n # Because a cache can fail silently (e.g. memcache), we don't know if\n # we are failing to create a new session because of a key collision or\n # because the cache is missing. So we try for a (large) number of times\n # and then raise an exception. That's the risk you shoulder if using\n # cache backing.\n for i in xrange(10000):\n self.session_key = self._get_new_session_key()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98798:For_L25_C8", "label": "for i", "type": "for", "loc": [25, 32], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98798:FunctionDef_L19_C4", "vector": [6, 2, 0.5089, 0.1429, 2, 0.89, 0.0, 826, 3, 0, 0, 0, 0, 0, 3], "semantic": {"name": "i", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for i in xrange(10000):\n self.session_key = self._get_new_session_key()\n try:\n self.save(must_create=True)\n except CreateError:\n continue\n self.modified = True\n return"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98798:Assign_L26_C12", "label": "self.session_key = _get_new_session_key()", "type": "assigned_variable", "loc": [26, 26], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98798:For_L25_C8", "vector": [14, 3, 0.4643, 0.0179, 3, 0.35, 0.0, 113, 3, 0, 0, 0, 936, 10, 1], "semantic": {"name": "self.session_key", "arg_names": [], "import_names": [], "rhs_call_name": "_get_new_session_key", "annotation": ""}, "snippet": " self.session_key = self._get_new_session_key()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98798:Try_L27_C12", "label": "try", "type": "try", "loc": [27, 30], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98798:For_L25_C8", "vector": [7, 3, 0.5089, 0.0714, 3, 0.35, 0.3333, 0, 0, 1, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " try:\n self.save(must_create=True)\n except CreateError:\n continue"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98798:Expr_L28_C16", "label": "save()", "type": "expression", "loc": [28, 28], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98798:Try_L27_C12", "vector": [8, 4, 0.5, 0.0179, 4, 0.49, 0.0, 928, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "save", "arg_names": [], "import_names": [], "rhs_call_name": "save", "annotation": ""}, "snippet": " self.save(must_create=True)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98798:Assign_L31_C12", "label": "self.modified =", "type": "assigned_variable", "loc": [31, 31], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98798:For_L25_C8", "vector": [14, 3, 0.5536, 0.0179, 3, 0.35, 0.6667, 763, 1, 0, 0, 0, 0, 4, 0], "semantic": {"name": "self.modified", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.modified = True"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98798:Return_L32_C12", "label": "return", "type": "return", "loc": [32, 32], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98798:For_L25_C8", "vector": [13, 3, 0.5714, 0.0179, 3, 0.35, 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_98798:FunctionDef_L35_C4", "label": "save", "type": "function", "loc": [35, 43], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98798:ClassDef_L4_C0", "vector": [2, 1, 0.6964, 0.1607, 1, 0.92, 0.6667, 928, 0, 2, 0, 0, 0, 0, 3], "semantic": {"name": "save", "arg_names": ["self", "must_create"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def save(self, must_create=False):\n if must_create:\n func = self._cache.add\n else:\n func = self._cache.set\n result = func(self.session_key, self._get_session(no_load=must_create),\n self.get_expiry_age())\n if must_create and not result:"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98798:If_L36_C8", "label": "if", "type": "if", "loc": [36, 39], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98798:FunctionDef_L35_C4", "vector": [4, 2, 0.6696, 0.0714, 2, 0.42, 0.0, 0, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if must_create:\n func = self._cache.add\n else:\n func = self._cache.set"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98798:Assign_L37_C12", "label": "func =", "type": "assigned_variable", "loc": [37, 37], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98798:If_L36_C8", "vector": [14, 3, 0.6607, 0.0179, 3, 0.4, 0.0, 856, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "func", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " func = self._cache.add"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98798:Assign_L39_C12", "label": "func =", "type": "assigned_variable", "loc": [39, 39], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98798:If_L36_C8", "vector": [14, 3, 0.6964, 0.0179, 3, 0.4, 1.0, 856, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "func", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " func = self._cache.set"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98798:Assign_L40_C8", "label": "result = func()", "type": "assigned_variable", "loc": [40, 41], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98798:FunctionDef_L35_C4", "vector": [14, 2, 0.7232, 0.0357, 2, 0.42, 0.5, 51, 3, 3, 0, 0, 856, 10, 3], "semantic": {"name": "result", "arg_names": [], "import_names": [], "rhs_call_name": "func", "annotation": ""}, "snippet": " result = func(self.session_key, self._get_session(no_load=must_create),\n self.get_expiry_age())"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98798:If_L42_C8", "label": "if", "type": "if", "loc": [42, 43], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98798:FunctionDef_L35_C4", "vector": [4, 2, 0.7589, 0.0357, 2, 0.42, 1.0, 0, 0, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if must_create and not result:\n raise CreateError"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98798:FunctionDef_L45_C4", "label": "exists", "type": "function", "loc": [45, 48], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98798:ClassDef_L4_C0", "vector": [2, 1, 0.8304, 0.0714, 1, 0.92, 0.8333, 829, 0, 2, 1, 0, 0, 0, 1], "semantic": {"name": "exists", "arg_names": ["self", "session_key"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def exists(self, session_key):\n if self._cache.has_key(session_key):\n return True\n return False"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98798:If_L46_C8", "label": "if", "type": "if", "loc": [46, 47], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98798:FunctionDef_L45_C4", "vector": [4, 2, 0.8304, 0.0357, 2, 0.58, 0.0, 0, 3, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if self._cache.has_key(session_key):\n return True"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98798:Return_L47_C12", "label": "return", "type": "return", "loc": [47, 47], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98798:If_L46_C8", "vector": [13, 3, 0.8393, 0.0179, 3, 0.55, 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_98798:Return_L48_C8", "label": "return", "type": "return", "loc": [48, 48], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98798:FunctionDef_L45_C4", "vector": [13, 2, 0.8571, 0.0179, 2, 0.58, 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_98798:FunctionDef_L50_C4", "label": "delete", "type": "function", "loc": [50, 55], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98798:ClassDef_L4_C0", "vector": [2, 1, 0.9375, 0.1071, 1, 0.92, 1.0, 266, 0, 2, 0, 0, 0, 0, 1], "semantic": {"name": "delete", "arg_names": ["self", "session_key"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def delete(self, session_key=None):\n if session_key is None:\n if self._session_key is None:\n return\n session_key = self._session_key\n self._cache.delete(session_key)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98798:If_L51_C8", "label": "if", "type": "if", "loc": [51, 54], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98798:FunctionDef_L50_C4", "vector": [4, 2, 0.9375, 0.0714, 2, 0.72, 0.0, 0, 0, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if session_key is None:\n if self._session_key is None:\n return\n session_key = self._session_key"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98798:If_L52_C12", "label": "if", "type": "if", "loc": [52, 53], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98798:If_L51_C8", "vector": [4, 3, 0.9375, 0.0357, 3, 0.91, 0.0, 0, 0, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if self._session_key is None:\n return"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98798:Return_L53_C16", "label": "return", "type": "return", "loc": [53, 53], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98798:If_L52_C12", "vector": [13, 4, 0.9464, 0.0179, 4, 0.14, 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_98798:Assign_L54_C12", "label": "session_key =", "type": "assigned_variable", "loc": [54, 54], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98798:If_L51_C8", "vector": [14, 3, 0.9643, 0.0179, 3, 0.91, 1.0, 555, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "session_key", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " session_key = self._session_key"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98798:Expr_L55_C8", "label": "delete()", "type": "expression", "loc": [55, 55], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98798:FunctionDef_L50_C4", "vector": [8, 2, 0.9821, 0.0179, 2, 0.72, 1.0, 266, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "delete", "arg_names": [], "import_names": [], "rhs_call_name": "delete", "annotation": ""}, "snippet": " self._cache.delete(session_key)"}]
[{"f": "ajibawa-2023/Python-Code-Large/train/row_98798:ClassDef_L4_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98798:Expr_L5_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98798:ClassDef_L4_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98798:FunctionDef_L8_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98798:FunctionDef_L8_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98798:Assign_L9_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98798:FunctionDef_L8_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98798:Expr_L10_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98798:ClassDef_L4_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98798:FunctionDef_L12_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98798:FunctionDef_L12_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98798:Assign_L13_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98798:FunctionDef_L12_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98798:If_L14_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98798:If_L14_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98798:Return_L15_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98798:FunctionDef_L12_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98798:Expr_L16_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98798:FunctionDef_L12_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98798:Return_L17_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98798:ClassDef_L4_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98798:FunctionDef_L19_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98798:FunctionDef_L19_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98798:For_L25_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98798:For_L25_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98798:Assign_L26_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98798:For_L25_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98798:Try_L27_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98798:Try_L27_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98798:Expr_L28_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98798:For_L25_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98798:Assign_L31_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98798:For_L25_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98798:Return_L32_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98798:ClassDef_L4_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98798:FunctionDef_L35_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98798:FunctionDef_L35_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98798:If_L36_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98798:If_L36_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98798:Assign_L37_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98798:If_L36_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98798:Assign_L39_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98798:FunctionDef_L35_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98798:Assign_L40_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98798:FunctionDef_L35_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98798:If_L42_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98798:ClassDef_L4_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98798:FunctionDef_L45_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98798:FunctionDef_L45_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98798:If_L46_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98798:If_L46_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98798:Return_L47_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98798:FunctionDef_L45_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98798:Return_L48_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98798:ClassDef_L4_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98798:FunctionDef_L50_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98798:FunctionDef_L50_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98798:If_L51_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98798:If_L51_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98798:If_L52_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98798:If_L52_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98798:Return_L53_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98798:If_L51_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98798:Assign_L54_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98798:FunctionDef_L50_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98798:Expr_L55_C8"}]
from django.utils.translation import ungettext, ugettext as _ from django.utils.encoding import force_unicode from django import template from django.template import defaultfilters from datetime import date import re register = template.Library() def ordinal(value): """ Converts an integer to its ordinal as a string. 1 is '1st', 2 is '2nd', 3 is '3rd', etc. Works for any integer. """ try: value = int(value) except (TypeError, ValueError): return value t = (_('th'), _('st'), _('nd'), _('rd'), _('th'), _('th'), _('th'), _('th'), _('th'), _('th')) if value % 100 in (11, 12, 13): # special case return u"%d%s" % (value, t[0]) return u'%d%s' % (value, t[value % 10]) ordinal.is_safe = True register.filter(ordinal) def intcomma(value): """ Converts an integer to a string containing commas every three digits. For example, 3000 becomes '3,000' and 45000 becomes '45,000'. """ orig = force_unicode(value) new = re.sub("^(-?\d+)(\d{3})", '\g<1>,\g<2>', orig) if orig == new: return new else: return intcomma(new) intcomma.is_safe = True register.filter(intcomma) def intword(value): """ Converts a large integer to a friendly text representation. Works best for numbers over 1 million. For example, 1000000 becomes '1.0 million', 1200000 becomes '1.2 million' and '1200000000' becomes '1.2 billion'. """ value = int(value) if value < 1000000: return value if value < 1000000000: new_value = value / 1000000.0 return ungettext('%(value).1f million', '%(value).1f million', new_value) % {'value': new_value} if value < 1000000000000: new_value = value / 1000000000.0 return ungettext('%(value).1f billion', '%(value).1f billion', new_value) % {'value': new_value} if value < 1000000000000000: new_value = value / 1000000000000.0 return ungettext('%(value).1f trillion', '%(value).1f trillion', new_value) % {'value': new_value} return value intword.is_safe = False register.filter(intword) def apnumber(value): """ For numbers 1-9, returns the number spelled out. Otherwise, returns the number. This follows Associated Press style. """ try: value = int(value) except ValueError: return value if not 0 < value < 10: return value return (_('one'), _('two'), _('three'), _('four'), _('five'), _('six'), _('seven'), _('eight'), _('nine'))[value-1] apnumber.is_safe = True register.filter(apnumber) def naturalday(value, arg=None): """ For date values that are tomorrow, today or yesterday compared to present day returns representing string. Otherwise, returns a string formatted according to settings.DATE_FORMAT. """ try: value = date(value.year, value.month, value.day) except AttributeError: # Passed value wasn't a date object return value except ValueError: # Date arguments out of range return value delta = value - date.today() if delta.days == 0: return _(u'today') elif delta.days == 1: return _(u'tomorrow') elif delta.days == -1: return _(u'yesterday') return defaultfilters.date(value, arg) register.filter(naturalday)
ajibawa-2023/Python-Code-Large/train/row_98799
69
99
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_98799:ImportFrom_L1_C0", "label": "from django.utils.translation import ungettext, _", "type": "import", "loc": [1, 1], "level": 0, "parent": null, "vector": [1, 0, 0.0101, 0.0101, 0, 0.66, 0.0, 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 ungettext, ugettext as _"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98799:ImportFrom_L2_C0", "label": "from django.utils.encoding import force_unicode", "type": "import", "loc": [2, 2], "level": 0, "parent": null, "vector": [1, 0, 0.0202, 0.0101, 0, 0.66, 0.05, 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_98799:ImportFrom_L3_C0", "label": "from django import template", "type": "import", "loc": [3, 3], "level": 0, "parent": null, "vector": [1, 0, 0.0303, 0.0101, 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_98799:ImportFrom_L4_C0", "label": "from django.template import defaultfilters", "type": "import", "loc": [4, 4], "level": 0, "parent": null, "vector": [1, 0, 0.0404, 0.0101, 0, 0.66, 0.15, 213, 0, 1, 0, 0, 213, 0, 0], "semantic": {"name": "django.template", "arg_names": [], "import_names": ["defaultfilters"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.template import defaultfilters"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98799:ImportFrom_L5_C0", "label": "from datetime import date", "type": "import", "loc": [5, 5], "level": 0, "parent": null, "vector": [1, 0, 0.0505, 0.0101, 0, 0.66, 0.2, 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_98799:Import_L6_C0", "label": "re import re", "type": "import", "loc": [6, 6], "level": 0, "parent": null, "vector": [1, 0, 0.0606, 0.0101, 0, 0.66, 0.25, 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_98799:Assign_L8_C0", "label": "register = Library()", "type": "assigned_variable", "loc": [8, 8], "level": 0, "parent": null, "vector": [14, 0, 0.0808, 0.0101, 0, 0.66, 0.3, 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_98799:FunctionDef_L10_C0", "label": "ordinal", "type": "function", "loc": [10, 22], "level": 0, "parent": null, "vector": [2, 0, 0.1616, 0.1313, 0, 0.66, 0.35, 657, 0, 1, 1, 0, 0, 0, 11], "semantic": {"name": "ordinal", "arg_names": ["value"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "def ordinal(value):\n \"\"\"\n Converts an integer to its ordinal as a string. 1 is '1st', 2 is '2nd',\n 3 is '3rd', etc. Works for any integer.\n \"\"\"\n try:\n value = int(value)\n except (TypeError, ValueError):"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98799:Expr_L11_C4", "label": "expression", "type": "expression", "loc": [11, 14], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98799:FunctionDef_L10_C0", "vector": [8, 1, 0.1263, 0.0404, 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 Converts an integer to its ordinal as a string. 1 is '1st', 2 is '2nd',\n 3 is '3rd', etc. Works for any integer.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98799:Try_L15_C4", "label": "try", "type": "try", "loc": [15, 18], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98799:FunctionDef_L10_C0", "vector": [7, 1, 0.1667, 0.0404, 1, 0.41, 0.25, 0, 0, 1, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " try:\n value = int(value)\n except (TypeError, ValueError):\n return value"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98799:Assign_L16_C8", "label": "value = int()", "type": "assigned_variable", "loc": [16, 16], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98799:Try_L15_C4", "vector": [14, 2, 0.1616, 0.0101, 2, 0.78, 0.0, 441, 3, 1, 0, 0, 901, 10, 1], "semantic": {"name": "value", "arg_names": [], "import_names": [], "rhs_call_name": "int", "annotation": ""}, "snippet": " value = int(value)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98799:Return_L18_C8", "label": "return", "type": "return", "loc": [18, 18], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98799:Try_L15_C4", "vector": [13, 2, 0.1818, 0.0101, 2, 0.78, 0.0, 0, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return value"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98799:Assign_L19_C4", "label": "t =", "type": "assigned_variable", "loc": [19, 19], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98799:FunctionDef_L10_C0", "vector": [14, 1, 0.1919, 0.0101, 1, 0.41, 0.5, 15, 0, 0, 0, 0, 0, 8, 10], "semantic": {"name": "t", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " t = (_('th'), _('st'), _('nd'), _('rd'), _('th'), _('th'), _('th'), _('th'), _('th'), _('th'))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98799:If_L20_C4", "label": "if", "type": "if", "loc": [20, 21], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98799:FunctionDef_L10_C0", "vector": [4, 1, 0.2071, 0.0202, 1, 0.41, 0.75, 0, 0, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if value % 100 in (11, 12, 13): # special case\n return u\"%d%s\" % (value, t[0])"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98799:Return_L21_C8", "label": "return", "type": "return", "loc": [21, 21], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98799:If_L20_C4", "vector": [13, 2, 0.2121, 0.0101, 2, 0.13, 0.0, 0, 4, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return u\"%d%s\" % (value, t[0])"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98799:Return_L22_C4", "label": "return", "type": "return", "loc": [22, 22], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98799:FunctionDef_L10_C0", "vector": [13, 1, 0.2222, 0.0101, 1, 0.41, 1.0, 0, 4, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return u'%d%s' % (value, t[value % 10])"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98799:Assign_L23_C0", "label": "ordinal.is_safe =", "type": "assigned_variable", "loc": [23, 23], "level": 0, "parent": null, "vector": [14, 0, 0.2323, 0.0101, 0, 0.66, 0.4, 184, 1, 0, 0, 0, 0, 4, 0], "semantic": {"name": "ordinal.is_safe", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "ordinal.is_safe = True"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98799:Expr_L24_C0", "label": "filter()", "type": "expression", "loc": [24, 24], "level": 0, "parent": null, "vector": [8, 0, 0.2424, 0.0101, 0, 0.66, 0.45, 526, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "filter", "arg_names": [], "import_names": [], "rhs_call_name": "filter", "annotation": ""}, "snippet": "register.filter(ordinal)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98799:FunctionDef_L26_C0", "label": "intcomma", "type": "function", "loc": [26, 36], "level": 0, "parent": null, "vector": [2, 0, 0.3131, 0.1111, 0, 0.66, 0.5, 228, 0, 1, 1, 0, 0, 0, 3], "semantic": {"name": "intcomma", "arg_names": ["value"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "def intcomma(value):\n \"\"\"\n Converts an integer to a string containing commas every three digits.\n For example, 3000 becomes '3,000' and 45000 becomes '45,000'.\n \"\"\"\n orig = force_unicode(value)\n new = re.sub(\"^(-?\\d+)(\\d{3})\", '\\g<1>,\\g<2>', orig)\n if orig == new:"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98799:Expr_L27_C4", "label": "expression", "type": "expression", "loc": [27, 30], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98799:FunctionDef_L26_C0", "vector": [8, 1, 0.2879, 0.0404, 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 Converts an integer to a string containing commas every three digits.\n For example, 3000 becomes '3,000' and 45000 becomes '45,000'.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98799:Assign_L31_C4", "label": "orig = force_unicode()", "type": "assigned_variable", "loc": [31, 31], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98799:FunctionDef_L26_C0", "vector": [14, 1, 0.3131, 0.0101, 1, 0.35, 0.3333, 310, 3, 1, 0, 0, 870, 10, 1], "semantic": {"name": "orig", "arg_names": [], "import_names": [], "rhs_call_name": "force_unicode", "annotation": ""}, "snippet": " orig = force_unicode(value)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98799:Assign_L32_C4", "label": "new = sub()", "type": "assigned_variable", "loc": [32, 32], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98799:FunctionDef_L26_C0", "vector": [14, 1, 0.3232, 0.0101, 1, 0.35, 0.6667, 145, 3, 3, 0, 0, 819, 10, 1], "semantic": {"name": "new", "arg_names": [], "import_names": [], "rhs_call_name": "sub", "annotation": ""}, "snippet": " new = re.sub(\"^(-?\\d+)(\\d{3})\", '\\g<1>,\\g<2>', orig)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98799:If_L33_C4", "label": "if", "type": "if", "loc": [33, 36], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98799:FunctionDef_L26_C0", "vector": [4, 1, 0.3485, 0.0404, 1, 0.35, 1.0, 0, 0, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if orig == new:\n return new\n else:\n return intcomma(new)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98799:Return_L34_C8", "label": "return", "type": "return", "loc": [34, 34], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98799:If_L33_C4", "vector": [13, 2, 0.3434, 0.0101, 2, 0.4, 0.0, 0, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return new"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98799:Return_L36_C8", "label": "return", "type": "return", "loc": [36, 36], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98799:If_L33_C4", "vector": [13, 2, 0.3636, 0.0101, 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 intcomma(new)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98799:Assign_L37_C0", "label": "intcomma.is_safe =", "type": "assigned_variable", "loc": [37, 37], "level": 0, "parent": null, "vector": [14, 0, 0.3737, 0.0101, 0, 0.66, 0.55, 888, 1, 0, 0, 0, 0, 4, 0], "semantic": {"name": "intcomma.is_safe", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "intcomma.is_safe = True"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98799:Expr_L38_C0", "label": "filter()", "type": "expression", "loc": [38, 38], "level": 0, "parent": null, "vector": [8, 0, 0.3838, 0.0101, 0, 0.66, 0.6, 526, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "filter", "arg_names": [], "import_names": [], "rhs_call_name": "filter", "annotation": ""}, "snippet": "register.filter(intcomma)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98799:FunctionDef_L40_C0", "label": "intword", "type": "function", "loc": [40, 58], "level": 0, "parent": null, "vector": [2, 0, 0.4949, 0.1919, 0, 0.66, 0.65, 109, 0, 1, 1, 0, 0, 0, 4], "semantic": {"name": "intword", "arg_names": ["value"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "def intword(value):\n \"\"\"\n Converts a large integer to a friendly text representation. Works best for\n numbers over 1 million. For example, 1000000 becomes '1.0 million', 1200000\n becomes '1.2 million' and '1200000000' becomes '1.2 billion'.\n \"\"\"\n value = int(value)\n if value < 1000000:"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98799:Expr_L41_C4", "label": "expression", "type": "expression", "loc": [41, 45], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98799:FunctionDef_L40_C0", "vector": [8, 1, 0.4343, 0.0505, 1, 0.37, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"\n Converts a large integer to a friendly text representation. Works best for\n numbers over 1 million. For example, 1000000 becomes '1.0 million', 1200000\n becomes '1.2 million' and '1200000000' becomes '1.2 billion'.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98799:Assign_L46_C4", "label": "value = int()", "type": "assigned_variable", "loc": [46, 46], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98799:FunctionDef_L40_C0", "vector": [14, 1, 0.4646, 0.0101, 1, 0.37, 0.1667, 441, 3, 1, 0, 0, 901, 10, 1], "semantic": {"name": "value", "arg_names": [], "import_names": [], "rhs_call_name": "int", "annotation": ""}, "snippet": " value = int(value)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98799:If_L47_C4", "label": "if", "type": "if", "loc": [47, 48], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98799:FunctionDef_L40_C0", "vector": [4, 1, 0.4798, 0.0202, 1, 0.37, 0.3333, 0, 0, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if value < 1000000:\n return value"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98799:Return_L48_C8", "label": "return", "type": "return", "loc": [48, 48], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98799:If_L47_C4", "vector": [13, 2, 0.4848, 0.0101, 2, 0.84, 0.0, 0, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return value"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98799:If_L49_C4", "label": "if", "type": "if", "loc": [49, 51], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98799:FunctionDef_L40_C0", "vector": [4, 1, 0.5051, 0.0303, 1, 0.37, 0.5, 0, 0, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if value < 1000000000:\n new_value = value / 1000000.0\n return ungettext('%(value).1f million', '%(value).1f million', new_value) % {'value': new_value}"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98799:Assign_L50_C8", "label": "new_value =", "type": "assigned_variable", "loc": [50, 50], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98799:If_L49_C4", "vector": [14, 2, 0.5051, 0.0101, 2, 0.04, 0.0, 832, 4, 0, 0, 0, 0, 0, 0], "semantic": {"name": "new_value", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " new_value = value / 1000000.0"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98799:Return_L51_C8", "label": "return", "type": "return", "loc": [51, 51], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98799:If_L49_C4", "vector": [13, 2, 0.5152, 0.0101, 2, 0.04, 1.0, 0, 4, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return ungettext('%(value).1f million', '%(value).1f million', new_value) % {'value': new_value}"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98799:If_L52_C4", "label": "if", "type": "if", "loc": [52, 54], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98799:FunctionDef_L40_C0", "vector": [4, 1, 0.5354, 0.0303, 1, 0.37, 0.6667, 0, 0, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if value < 1000000000000:\n new_value = value / 1000000000.0\n return ungettext('%(value).1f billion', '%(value).1f billion', new_value) % {'value': new_value}"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98799:Assign_L53_C8", "label": "new_value =", "type": "assigned_variable", "loc": [53, 53], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98799:If_L52_C4", "vector": [14, 2, 0.5354, 0.0101, 2, 0.73, 0.0, 832, 4, 0, 0, 0, 0, 0, 0], "semantic": {"name": "new_value", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " new_value = value / 1000000000.0"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98799:Return_L54_C8", "label": "return", "type": "return", "loc": [54, 54], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98799:If_L52_C4", "vector": [13, 2, 0.5455, 0.0101, 2, 0.73, 1.0, 0, 4, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return ungettext('%(value).1f billion', '%(value).1f billion', new_value) % {'value': new_value}"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98799:If_L55_C4", "label": "if", "type": "if", "loc": [55, 57], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98799:FunctionDef_L40_C0", "vector": [4, 1, 0.5657, 0.0303, 1, 0.37, 0.8333, 0, 0, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if value < 1000000000000000:\n new_value = value / 1000000000000.0\n return ungettext('%(value).1f trillion', '%(value).1f trillion', new_value) % {'value': new_value}"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98799:Assign_L56_C8", "label": "new_value =", "type": "assigned_variable", "loc": [56, 56], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98799:If_L55_C4", "vector": [14, 2, 0.5657, 0.0101, 2, 0.54, 0.0, 832, 4, 0, 0, 0, 0, 0, 0], "semantic": {"name": "new_value", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " new_value = value / 1000000000000.0"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98799:Return_L57_C8", "label": "return", "type": "return", "loc": [57, 57], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98799:If_L55_C4", "vector": [13, 2, 0.5758, 0.0101, 2, 0.54, 1.0, 0, 4, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return ungettext('%(value).1f trillion', '%(value).1f trillion', new_value) % {'value': new_value}"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98799:Return_L58_C4", "label": "return", "type": "return", "loc": [58, 58], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98799:FunctionDef_L40_C0", "vector": [13, 1, 0.5859, 0.0101, 1, 0.37, 1.0, 0, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return value"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98799:Assign_L59_C0", "label": "intword.is_safe =", "type": "assigned_variable", "loc": [59, 59], "level": 0, "parent": null, "vector": [14, 0, 0.596, 0.0101, 0, 0.66, 0.7, 158, 1, 0, 0, 0, 0, 4, 0], "semantic": {"name": "intword.is_safe", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "intword.is_safe = False"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98799:Expr_L60_C0", "label": "filter()", "type": "expression", "loc": [60, 60], "level": 0, "parent": null, "vector": [8, 0, 0.6061, 0.0101, 0, 0.66, 0.75, 526, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "filter", "arg_names": [], "import_names": [], "rhs_call_name": "filter", "annotation": ""}, "snippet": "register.filter(intword)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98799:FunctionDef_L62_C0", "label": "apnumber", "type": "function", "loc": [62, 73], "level": 0, "parent": null, "vector": [2, 0, 0.6818, 0.1212, 0, 0.66, 0.8, 783, 0, 1, 1, 0, 0, 0, 10], "semantic": {"name": "apnumber", "arg_names": ["value"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "def apnumber(value):\n \"\"\"\n For numbers 1-9, returns the number spelled out. Otherwise, returns the\n number. This follows Associated Press style.\n \"\"\"\n try:\n value = int(value)\n except ValueError:"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98799:Expr_L63_C4", "label": "expression", "type": "expression", "loc": [63, 66], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98799:FunctionDef_L62_C0", "vector": [8, 1, 0.6515, 0.0404, 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 For numbers 1-9, returns the number spelled out. Otherwise, returns the\n number. This follows Associated Press style.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98799:Try_L67_C4", "label": "try", "type": "try", "loc": [67, 70], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98799:FunctionDef_L62_C0", "vector": [7, 1, 0.6919, 0.0404, 1, 0.28, 0.3333, 0, 0, 1, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " try:\n value = int(value)\n except ValueError:\n return value"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98799:Assign_L68_C8", "label": "value = int()", "type": "assigned_variable", "loc": [68, 68], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98799:Try_L67_C4", "vector": [14, 2, 0.6869, 0.0101, 2, 0.16, 0.0, 441, 3, 1, 0, 0, 901, 10, 1], "semantic": {"name": "value", "arg_names": [], "import_names": [], "rhs_call_name": "int", "annotation": ""}, "snippet": " value = int(value)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98799:Return_L70_C8", "label": "return", "type": "return", "loc": [70, 70], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98799:Try_L67_C4", "vector": [13, 2, 0.7071, 0.0101, 2, 0.16, 0.0, 0, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return value"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98799:If_L71_C4", "label": "if", "type": "if", "loc": [71, 72], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98799:FunctionDef_L62_C0", "vector": [4, 1, 0.7222, 0.0202, 1, 0.28, 0.6667, 0, 0, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if not 0 < value < 10:\n return value"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98799:Return_L72_C8", "label": "return", "type": "return", "loc": [72, 72], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98799:If_L71_C4", "vector": [13, 2, 0.7273, 0.0101, 2, 0.64, 0.0, 0, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return value"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98799:Return_L73_C4", "label": "return", "type": "return", "loc": [73, 73], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98799:FunctionDef_L62_C0", "vector": [13, 1, 0.7374, 0.0101, 1, 0.28, 1.0, 0, 6, 0, 0, 0, 0, 0, 9], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return (_('one'), _('two'), _('three'), _('four'), _('five'), _('six'), _('seven'), _('eight'), _('nine'))[value-1]"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98799:Assign_L74_C0", "label": "apnumber.is_safe =", "type": "assigned_variable", "loc": [74, 74], "level": 0, "parent": null, "vector": [14, 0, 0.7475, 0.0101, 0, 0.66, 0.85, 235, 1, 0, 0, 0, 0, 4, 0], "semantic": {"name": "apnumber.is_safe", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "apnumber.is_safe = True"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98799:Expr_L75_C0", "label": "filter()", "type": "expression", "loc": [75, 75], "level": 0, "parent": null, "vector": [8, 0, 0.7576, 0.0101, 0, 0.66, 0.9, 526, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "filter", "arg_names": [], "import_names": [], "rhs_call_name": "filter", "annotation": ""}, "snippet": "register.filter(apnumber)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98799:FunctionDef_L77_C0", "label": "naturalday", "type": "function", "loc": [77, 98], "level": 0, "parent": null, "vector": [2, 0, 0.8838, 0.2222, 0, 0.66, 0.95, 796, 0, 2, 1, 0, 0, 0, 6], "semantic": {"name": "naturalday", "arg_names": ["value", "arg"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "def naturalday(value, arg=None):\n \"\"\"\n For date values that are tomorrow, today or yesterday compared to\n present day returns representing string. Otherwise, returns a string\n formatted according to settings.DATE_FORMAT.\n \"\"\"\n try: \n value = date(value.year, value.month, value.day)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98799:Expr_L78_C4", "label": "expression", "type": "expression", "loc": [78, 82], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98799:FunctionDef_L77_C0", "vector": [8, 1, 0.8081, 0.0505, 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 For date values that are tomorrow, today or yesterday compared to\n present day returns representing string. Otherwise, returns a string\n formatted according to settings.DATE_FORMAT.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98799:Try_L83_C4", "label": "try", "type": "try", "loc": [83, 90], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98799:FunctionDef_L77_C0", "vector": [7, 1, 0.8737, 0.0808, 1, 0.28, 0.25, 0, 0, 2, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " try: \n value = date(value.year, value.month, value.day)\n except AttributeError:\n # Passed value wasn't a date object\n return value\n except ValueError:\n # Date arguments out of range\n return value"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98799:Assign_L84_C8", "label": "value = date()", "type": "assigned_variable", "loc": [84, 84], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98799:Try_L83_C4", "vector": [14, 2, 0.8485, 0.0101, 2, 0.57, 0.0, 441, 3, 3, 0, 0, 56, 10, 1], "semantic": {"name": "value", "arg_names": [], "import_names": [], "rhs_call_name": "date", "annotation": ""}, "snippet": " value = date(value.year, value.month, value.day)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98799:Return_L87_C8", "label": "return", "type": "return", "loc": [87, 87], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98799:Try_L83_C4", "vector": [13, 2, 0.8788, 0.0101, 2, 0.57, 0.0, 0, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return value"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98799:Return_L90_C8", "label": "return", "type": "return", "loc": [90, 90], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98799:Try_L83_C4", "vector": [13, 2, 0.9091, 0.0101, 2, 0.57, 0.0, 0, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return value"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98799:Assign_L91_C4", "label": "delta =", "type": "assigned_variable", "loc": [91, 91], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98799:FunctionDef_L77_C0", "vector": [14, 1, 0.9192, 0.0101, 1, 0.28, 0.5, 593, 4, 0, 0, 0, 0, 0, 1], "semantic": {"name": "delta", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " delta = value - date.today()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98799:If_L92_C4", "label": "if", "type": "if", "loc": [92, 97], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98799:FunctionDef_L77_C0", "vector": [4, 1, 0.9545, 0.0606, 1, 0.28, 0.75, 0, 0, 0, 0, 0, 0, 0, 3], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if delta.days == 0:\n return _(u'today')\n elif delta.days == 1:\n return _(u'tomorrow')\n elif delta.days == -1:\n return _(u'yesterday')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98799:Return_L93_C8", "label": "return", "type": "return", "loc": [93, 93], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98799:If_L92_C4", "vector": [13, 2, 0.9394, 0.0101, 2, 0.73, 0.0, 0, 3, 0, 0, 0, 0, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return _(u'today')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98799:If_L94_C4", "label": "if", "type": "if", "loc": [94, 97], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98799:If_L92_C4", "vector": [4, 2, 0.9646, 0.0404, 2, 0.73, 1.0, 0, 0, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " elif delta.days == 1:\n return _(u'tomorrow')\n elif delta.days == -1:\n return _(u'yesterday')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98799:Return_L95_C8", "label": "return", "type": "return", "loc": [95, 95], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98799:If_L94_C4", "vector": [13, 3, 0.9596, 0.0101, 3, 0.72, 0.0, 0, 3, 0, 0, 0, 0, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return _(u'tomorrow')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98799:If_L96_C4", "label": "if", "type": "if", "loc": [96, 97], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98799:If_L94_C4", "vector": [4, 3, 0.9747, 0.0202, 3, 0.72, 1.0, 0, 0, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " elif delta.days == -1:\n return _(u'yesterday')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98799:Return_L97_C8", "label": "return", "type": "return", "loc": [97, 97], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98799:If_L96_C4", "vector": [13, 4, 0.9798, 0.0101, 4, 0.67, 0.0, 0, 3, 0, 0, 0, 0, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return _(u'yesterday')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98799:Return_L98_C4", "label": "return", "type": "return", "loc": [98, 98], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98799:FunctionDef_L77_C0", "vector": [13, 1, 0.9899, 0.0101, 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 defaultfilters.date(value, arg)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98799:Expr_L99_C0", "label": "filter()", "type": "expression", "loc": [99, 99], "level": 0, "parent": null, "vector": [8, 0, 1.0, 0.0101, 0, 0.66, 1.0, 526, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "filter", "arg_names": [], "import_names": [], "rhs_call_name": "filter", "annotation": ""}, "snippet": "register.filter(naturalday)"}]
[{"f": "ajibawa-2023/Python-Code-Large/train/row_98799:FunctionDef_L10_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98799:Expr_L11_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98799:FunctionDef_L10_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98799:Try_L15_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98799:Try_L15_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98799:Assign_L16_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98799:Try_L15_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98799:Return_L18_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98799:FunctionDef_L10_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98799:Assign_L19_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98799:FunctionDef_L10_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98799:If_L20_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98799:If_L20_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98799:Return_L21_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98799:FunctionDef_L10_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98799:Return_L22_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98799:FunctionDef_L26_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98799:Expr_L27_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98799:FunctionDef_L26_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98799:Assign_L31_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98799:FunctionDef_L26_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98799:Assign_L32_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98799:FunctionDef_L26_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98799:If_L33_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98799:If_L33_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98799:Return_L34_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98799:If_L33_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98799:Return_L36_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98799:FunctionDef_L40_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98799:Expr_L41_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98799:FunctionDef_L40_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98799:Assign_L46_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98799:FunctionDef_L40_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98799:If_L47_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98799:If_L47_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98799:Return_L48_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98799:FunctionDef_L40_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98799:If_L49_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98799:If_L49_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98799:Assign_L50_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98799:If_L49_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98799:Return_L51_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98799:FunctionDef_L40_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98799:If_L52_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98799:If_L52_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98799:Assign_L53_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98799:If_L52_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98799:Return_L54_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98799:FunctionDef_L40_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98799:If_L55_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98799:If_L55_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98799:Assign_L56_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98799:If_L55_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98799:Return_L57_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98799:FunctionDef_L40_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98799:Return_L58_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98799:FunctionDef_L62_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98799:Expr_L63_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98799:FunctionDef_L62_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98799:Try_L67_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98799:Try_L67_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98799:Assign_L68_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98799:Try_L67_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98799:Return_L70_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98799:FunctionDef_L62_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98799:If_L71_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98799:If_L71_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98799:Return_L72_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98799:FunctionDef_L62_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98799:Return_L73_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98799:FunctionDef_L77_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98799:Expr_L78_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98799:FunctionDef_L77_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98799:Try_L83_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98799:Try_L83_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98799:Assign_L84_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98799:Try_L83_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98799:Return_L87_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98799:Try_L83_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98799:Return_L90_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98799:FunctionDef_L77_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98799:Assign_L91_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98799:FunctionDef_L77_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98799:If_L92_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98799:If_L92_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98799:Return_L93_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98799:If_L92_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98799:If_L94_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98799:If_L94_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98799:Return_L95_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98799:If_L94_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98799:If_L96_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98799:If_L96_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98799:Return_L97_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98799:FunctionDef_L77_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98799:Return_L98_C4"}]
from django.conf.urls.defaults import * from django.contrib.databrowse import views # Note: The views in this URLconf all require a 'models' argument, # which is a list of model classes (*not* instances). urlpatterns = patterns('', #(r'^$', views.homepage), #(r'^([^/]+)/([^/]+)/$', views.model_detail), (r'^([^/]+)/([^/]+)/fields/(\w+)/$', views.choice_list), (r'^([^/]+)/([^/]+)/fields/(\w+)/(.*)/$', views.choice_detail), #(r'^([^/]+)/([^/]+)/calendars/(\w+)/$', views.calendar_main), #(r'^([^/]+)/([^/]+)/calendars/(\w+)/(\d{4})/$', views.calendar_year), #(r'^([^/]+)/([^/]+)/calendars/(\w+)/(\d{4})/(\w{3})/$', views.calendar_month), #(r'^([^/]+)/([^/]+)/calendars/(\w+)/(\d{4})/(\w{3})/(\d{1,2})/$', views.calendar_day), #(r'^([^/]+)/([^/]+)/objects/(.*)/$', views.object_detail), )
ajibawa-2023/Python-Code-Large/train/row_98800
3
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_98800:ImportFrom_L1_C0", "label": "from django.conf.urls.defaults import *", "type": "import", "loc": [1, 1], "level": 0, "parent": null, "vector": [1, 0, 0.05, 0.05, 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_98800:ImportFrom_L2_C0", "label": "from django.contrib.databrowse import views", "type": "import", "loc": [2, 2], "level": 0, "parent": null, "vector": [1, 0, 0.1, 0.05, 0, 0.66, 0.5, 706, 0, 1, 0, 0, 706, 0, 0], "semantic": {"name": "django.contrib.databrowse", "arg_names": [], "import_names": ["views"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.contrib.databrowse import views"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98800:Assign_L7_C0", "label": "urlpatterns = patterns()", "type": "assigned_variable", "loc": [7, 20], "level": 0, "parent": null, "vector": [14, 0, 0.675, 0.7, 0, 0.66, 1.0, 990, 3, 3, 0, 0, 75, 10, 1], "semantic": {"name": "urlpatterns", "arg_names": [], "import_names": [], "rhs_call_name": "patterns", "annotation": ""}, "snippet": "urlpatterns = patterns('',\n #(r'^$', views.homepage),\n #(r'^([^/]+)/([^/]+)/$', views.model_detail),\n\n (r'^([^/]+)/([^/]+)/fields/(\\w+)/$', views.choice_list),\n (r'^([^/]+)/([^/]+)/fields/(\\w+)/(.*)/$', views.choice_detail),\n\n #(r'^([^/]+)/([^/]+)/calendars/(\\w+)/$', views.calendar_main),"}]
[]
from django import http from django.db import models from django.contrib.databrowse.datastructures import EasyModel from django.contrib.databrowse.sites import DatabrowsePlugin from django.shortcuts import render_to_response from django.utils.text import capfirst from django.utils.encoding import force_unicode from django.utils.safestring import mark_safe from django.views.generic import date_based from django.utils import datetime_safe class CalendarPlugin(DatabrowsePlugin): def __init__(self, field_names=None): self.field_names = field_names def field_dict(self, model): """ Helper function that returns a dictionary of all DateFields or DateTimeFields in the given model. If self.field_names is set, it takes take that into account when building the dictionary. """ if self.field_names is None: return dict([(f.name, f) for f in model._meta.fields if isinstance(f, models.DateField)]) else: return dict([(f.name, f) for f in model._meta.fields if isinstance(f, models.DateField) and f.name in self.field_names]) def model_index_html(self, request, model, site): fields = self.field_dict(model) if not fields: return u'' return mark_safe(u'<p class="filter"><strong>View calendar by:</strong> %s</p>' % \ u', '.join(['<a href="calendars/%s/">%s</a>' % (f.name, force_unicode(capfirst(f.verbose_name))) for f in fields.values()])) def urls(self, plugin_name, easy_instance_field): if isinstance(easy_instance_field.field, models.DateField): d = easy_instance_field.raw_value return [mark_safe(u'%s%s/%s/%s/%s/%s/' % ( easy_instance_field.model.url(), plugin_name, easy_instance_field.field.name, str(d.year), datetime_safe.new_date(d).strftime('%b').lower(), d.day))] def model_view(self, request, model_databrowse, url): self.model, self.site = model_databrowse.model, model_databrowse.site self.fields = self.field_dict(self.model) # If the model has no DateFields, there's no point in going further. if not self.fields: raise http.Http404('The requested model has no calendars.') if url is None: return self.homepage_view(request) url_bits = url.split('/') if self.fields.has_key(url_bits[0]): return self.calendar_view(request, self.fields[url_bits[0]], *url_bits[1:]) raise http.Http404('The requested page does not exist.') def homepage_view(self, request): easy_model = EasyModel(self.site, self.model) field_list = self.fields.values() field_list.sort(key=lambda k:k.verbose_name) return render_to_response('databrowse/calendar_homepage.html', {'root_url': self.site.root_url, 'model': easy_model, 'field_list': field_list}) def calendar_view(self, request, field, year=None, month=None, day=None): easy_model = EasyModel(self.site, self.model) queryset = easy_model.get_query_set() extra_context = {'root_url': self.site.root_url, 'model': easy_model, 'field': field} if day is not None: return date_based.archive_day(request, year, month, day, queryset, field.name, template_name='databrowse/calendar_day.html', allow_empty=False, allow_future=True, extra_context=extra_context) elif month is not None: return date_based.archive_month(request, year, month, queryset, field.name, template_name='databrowse/calendar_month.html', allow_empty=False, allow_future=True, extra_context=extra_context) elif year is not None: return date_based.archive_year(request, year, queryset, field.name, template_name='databrowse/calendar_year.html', allow_empty=False, allow_future=True, extra_context=extra_context) else: return date_based.archive_index(request, queryset, field.name, template_name='databrowse/calendar_main.html', allow_empty=True, allow_future=True, extra_context=extra_context) assert False, ('%s, %s, %s, %s' % (field, year, month, day))
ajibawa-2023/Python-Code-Large/train/row_98801
52
86
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_98801:ImportFrom_L1_C0", "label": "from django import http", "type": "import", "loc": [1, 1], "level": 0, "parent": null, "vector": [1, 0, 0.0116, 0.0116, 0, 0.66, 0.0, 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_98801:ImportFrom_L2_C0", "label": "from django.db import models", "type": "import", "loc": [2, 2], "level": 0, "parent": null, "vector": [1, 0, 0.0233, 0.0116, 0, 0.66, 0.1, 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_98801:ImportFrom_L3_C0", "label": "from django.contrib.databrowse.datastructures import EasyModel", "type": "import", "loc": [3, 3], "level": 0, "parent": null, "vector": [1, 0, 0.0349, 0.0116, 0, 0.66, 0.2, 235, 0, 1, 0, 0, 235, 0, 0], "semantic": {"name": "django.contrib.databrowse.datastructures", "arg_names": [], "import_names": ["EasyModel"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.contrib.databrowse.datastructures import EasyModel"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98801:ImportFrom_L4_C0", "label": "from django.contrib.databrowse.sites import DatabrowsePlugin", "type": "import", "loc": [4, 4], "level": 0, "parent": null, "vector": [1, 0, 0.0465, 0.0116, 0, 0.66, 0.3, 231, 0, 1, 0, 0, 231, 0, 0], "semantic": {"name": "django.contrib.databrowse.sites", "arg_names": [], "import_names": ["DatabrowsePlugin"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.contrib.databrowse.sites import DatabrowsePlugin"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98801:ImportFrom_L5_C0", "label": "from django.shortcuts import render_to_response", "type": "import", "loc": [5, 5], "level": 0, "parent": null, "vector": [1, 0, 0.0581, 0.0116, 0, 0.66, 0.4, 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_98801:ImportFrom_L6_C0", "label": "from django.utils.text import capfirst", "type": "import", "loc": [6, 6], "level": 0, "parent": null, "vector": [1, 0, 0.0698, 0.0116, 0, 0.66, 0.5, 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_98801:ImportFrom_L7_C0", "label": "from django.utils.encoding import force_unicode", "type": "import", "loc": [7, 7], "level": 0, "parent": null, "vector": [1, 0, 0.0814, 0.0116, 0, 0.66, 0.6, 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_98801:ImportFrom_L8_C0", "label": "from django.utils.safestring import mark_safe", "type": "import", "loc": [8, 8], "level": 0, "parent": null, "vector": [1, 0, 0.093, 0.0116, 0, 0.66, 0.7, 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_98801:ImportFrom_L9_C0", "label": "from django.views.generic import date_based", "type": "import", "loc": [9, 9], "level": 0, "parent": null, "vector": [1, 0, 0.1047, 0.0116, 0, 0.66, 0.8, 201, 0, 1, 0, 0, 201, 0, 0], "semantic": {"name": "django.views.generic", "arg_names": [], "import_names": ["date_based"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.views.generic import date_based"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98801:ImportFrom_L10_C0", "label": "from django.utils import datetime_safe", "type": "import", "loc": [10, 10], "level": 0, "parent": null, "vector": [1, 0, 0.1163, 0.0116, 0, 0.66, 0.9, 944, 0, 1, 0, 0, 944, 0, 0], "semantic": {"name": "django.utils", "arg_names": [], "import_names": ["datetime_safe"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.utils import datetime_safe"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98801:ClassDef_L12_C0", "label": "CalendarPlugin", "type": "class", "loc": [12, 86], "level": 0, "parent": null, "vector": [3, 0, 0.5698, 0.8721, 0, 0.66, 1.0, 318, 0, 7, 0, 0, 298, 0, 34], "semantic": {"name": "CalendarPlugin", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class CalendarPlugin(DatabrowsePlugin):\n def __init__(self, field_names=None):\n self.field_names = field_names\n\n def field_dict(self, model):\n \"\"\"\n Helper function that returns a dictionary of all DateFields or\n DateTimeFields in the given model. If self.field_names is set, it takes"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98801:FunctionDef_L13_C4", "label": "__init__", "type": "function", "loc": [13, 14], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98801:ClassDef_L12_C0", "vector": [2, 1, 0.157, 0.0233, 1, 0.31, 0.0, 555, 0, 2, 0, 0, 0, 0, 0], "semantic": {"name": "__init__", "arg_names": ["self", "field_names"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def __init__(self, field_names=None):\n self.field_names = field_names"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98801:Assign_L14_C8", "label": "self.field_names =", "type": "assigned_variable", "loc": [14, 14], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98801:FunctionDef_L13_C4", "vector": [14, 2, 0.1628, 0.0116, 2, 0.05, 0.0, 544, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "self.field_names", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.field_names = field_names"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98801:FunctionDef_L16_C4", "label": "field_dict", "type": "function", "loc": [16, 25], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98801:ClassDef_L12_C0", "vector": [2, 1, 0.2384, 0.1163, 1, 0.31, 0.1667, 459, 0, 2, 1, 0, 0, 0, 4], "semantic": {"name": "field_dict", "arg_names": ["self", "model"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def field_dict(self, model):\n \"\"\"\n Helper function that returns a dictionary of all DateFields or\n DateTimeFields in the given model. If self.field_names is set, it takes\n take that into account when building the dictionary.\n \"\"\"\n if self.field_names is None:\n return dict([(f.name, f) for f in model._meta.fields if isinstance(f, models.DateField)])"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98801:Expr_L17_C8", "label": "expression", "type": "expression", "loc": [17, 21], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98801:FunctionDef_L16_C4", "vector": [8, 2, 0.2209, 0.0581, 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 Helper function that returns a dictionary of all DateFields or\n DateTimeFields in the given model. If self.field_names is set, it takes\n take that into account when building the dictionary.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98801:If_L22_C8", "label": "if", "type": "if", "loc": [22, 25], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98801:FunctionDef_L16_C4", "vector": [4, 2, 0.2733, 0.0465, 2, 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.field_names is None:\n return dict([(f.name, f) for f in model._meta.fields if isinstance(f, models.DateField)])\n else:\n return dict([(f.name, f) for f in model._meta.fields if isinstance(f, models.DateField) and f.name in self.field_names])"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98801:Return_L23_C12", "label": "return", "type": "return", "loc": [23, 23], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98801:If_L22_C8", "vector": [13, 3, 0.2674, 0.0116, 3, 0.39, 0.0, 0, 3, 0, 0, 0, 0, 10, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return dict([(f.name, f) for f in model._meta.fields if isinstance(f, models.DateField)])"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98801:Return_L25_C12", "label": "return", "type": "return", "loc": [25, 25], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98801:If_L22_C8", "vector": [13, 3, 0.2907, 0.0116, 3, 0.39, 1.0, 0, 3, 0, 0, 0, 0, 10, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return dict([(f.name, f) for f in model._meta.fields if isinstance(f, models.DateField) and f.name in self.field_names])"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98801:FunctionDef_L27_C4", "label": "model_index_html", "type": "function", "loc": [27, 32], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98801:ClassDef_L12_C0", "vector": [2, 1, 0.343, 0.0698, 1, 0.31, 0.3333, 182, 0, 4, 1, 0, 0, 0, 6], "semantic": {"name": "model_index_html", "arg_names": ["self", "request", "model", "site"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def model_index_html(self, request, model, site):\n fields = self.field_dict(model)\n if not fields:\n return u''\n return mark_safe(u'<p class=\"filter\"><strong>View calendar by:</strong> %s</p>' % \\\n u', '.join(['<a href=\"calendars/%s/\">%s</a>' % (f.name, force_unicode(capfirst(f.verbose_name))) for f in fields.values()]))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98801:Assign_L28_C8", "label": "fields = field_dict()", "type": "assigned_variable", "loc": [28, 28], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98801:FunctionDef_L27_C4", "vector": [14, 2, 0.3256, 0.0116, 2, 0.49, 0.0, 358, 3, 1, 0, 0, 459, 10, 1], "semantic": {"name": "fields", "arg_names": [], "import_names": [], "rhs_call_name": "field_dict", "annotation": ""}, "snippet": " fields = self.field_dict(model)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98801:If_L29_C8", "label": "if", "type": "if", "loc": [29, 30], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98801:FunctionDef_L27_C4", "vector": [4, 2, 0.343, 0.0233, 2, 0.49, 0.5, 0, 0, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if not fields:\n return u''"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98801:Return_L30_C12", "label": "return", "type": "return", "loc": [30, 30], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98801:If_L29_C8", "vector": [13, 3, 0.3488, 0.0116, 3, 0.85, 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_98801:Return_L31_C8", "label": "return", "type": "return", "loc": [31, 32], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98801:FunctionDef_L27_C4", "vector": [13, 2, 0.3663, 0.0233, 2, 0.49, 1.0, 0, 3, 0, 0, 0, 0, 10, 5], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return mark_safe(u'<p class=\"filter\"><strong>View calendar by:</strong> %s</p>' % \\\n u', '.join(['<a href=\"calendars/%s/\">%s</a>' % (f.name, force_unicode(capfirst(f.verbose_name))) for f in fields.values()]))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98801:FunctionDef_L34_C4", "label": "urls", "type": "function", "loc": [34, 42], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98801:ClassDef_L12_C0", "vector": [2, 1, 0.4419, 0.1047, 1, 0.31, 0.5, 260, 0, 3, 1, 0, 0, 0, 7], "semantic": {"name": "urls", "arg_names": ["self", "plugin_name", "easy_instance_field"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def urls(self, plugin_name, easy_instance_field):\n if isinstance(easy_instance_field.field, models.DateField):\n d = easy_instance_field.raw_value\n return [mark_safe(u'%s%s/%s/%s/%s/%s/' % (\n easy_instance_field.model.url(),\n plugin_name, easy_instance_field.field.name,\n str(d.year),\n datetime_safe.new_date(d).strftime('%b').lower(),"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98801:If_L35_C8", "label": "if", "type": "if", "loc": [35, 42], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98801:FunctionDef_L34_C4", "vector": [4, 2, 0.4477, 0.093, 2, 0.58, 0.0, 0, 3, 0, 0, 0, 0, 0, 7], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if isinstance(easy_instance_field.field, models.DateField):\n d = easy_instance_field.raw_value\n return [mark_safe(u'%s%s/%s/%s/%s/%s/' % (\n easy_instance_field.model.url(),\n plugin_name, easy_instance_field.field.name,\n str(d.year),\n datetime_safe.new_date(d).strftime('%b').lower(),\n d.day))]"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98801:Assign_L36_C12", "label": "d =", "type": "assigned_variable", "loc": [36, 36], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98801:If_L35_C8", "vector": [14, 3, 0.4186, 0.0116, 3, 0.44, 0.0, 355, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "d", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " d = easy_instance_field.raw_value"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98801:Return_L37_C12", "label": "return", "type": "return", "loc": [37, 42], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98801:If_L35_C8", "vector": [13, 3, 0.4593, 0.0698, 3, 0.44, 1.0, 0, 0, 0, 0, 0, 0, 5, 6], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return [mark_safe(u'%s%s/%s/%s/%s/%s/' % (\n easy_instance_field.model.url(),\n plugin_name, easy_instance_field.field.name,\n str(d.year),\n datetime_safe.new_date(d).strftime('%b').lower(),\n d.day))]"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98801:FunctionDef_L44_C4", "label": "model_view", "type": "function", "loc": [44, 58], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98801:ClassDef_L12_C0", "vector": [2, 1, 0.593, 0.1744, 1, 0.31, 0.6667, 372, 0, 4, 1, 0, 0, 0, 7], "semantic": {"name": "model_view", "arg_names": ["self", "request", "model_databrowse", "url"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def model_view(self, request, model_databrowse, url):\n self.model, self.site = model_databrowse.model, model_databrowse.site\n self.fields = self.field_dict(self.model)\n\n # If the model has no DateFields, there's no point in going further.\n if not self.fields:\n raise http.Http404('The requested model has no calendars.')\n"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98801:Assign_L45_C8", "label": "assign", "type": "assigned_variable", "loc": [45, 45], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98801:FunctionDef_L44_C4", "vector": [14, 2, 0.5233, 0.0116, 2, 0.64, 0.0, 0, 0, 0, 0, 0, 0, 8, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.model, self.site = model_databrowse.model, model_databrowse.site"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98801:Assign_L46_C8", "label": "self.fields = field_dict()", "type": "assigned_variable", "loc": [46, 46], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98801:FunctionDef_L44_C4", "vector": [14, 2, 0.5349, 0.0116, 2, 0.64, 0.2, 318, 3, 1, 0, 0, 459, 10, 1], "semantic": {"name": "self.fields", "arg_names": [], "import_names": [], "rhs_call_name": "field_dict", "annotation": ""}, "snippet": " self.fields = self.field_dict(self.model)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98801:If_L49_C8", "label": "if", "type": "if", "loc": [49, 50], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98801:FunctionDef_L44_C4", "vector": [4, 2, 0.5756, 0.0233, 2, 0.64, 0.4, 0, 0, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if not self.fields:\n raise http.Http404('The requested model has no calendars.')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98801:If_L52_C8", "label": "if", "type": "if", "loc": [52, 53], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98801:FunctionDef_L44_C4", "vector": [4, 2, 0.6105, 0.0233, 2, 0.64, 0.6, 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.homepage_view(request)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98801:Return_L53_C12", "label": "return", "type": "return", "loc": [53, 53], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98801:If_L52_C8", "vector": [13, 3, 0.6163, 0.0116, 3, 0.2, 0.0, 0, 3, 0, 0, 0, 0, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return self.homepage_view(request)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98801:Assign_L54_C8", "label": "url_bits = split()", "type": "assigned_variable", "loc": [54, 54], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98801:FunctionDef_L44_C4", "vector": [14, 2, 0.6279, 0.0116, 2, 0.64, 0.8, 72, 3, 1, 0, 0, 908, 10, 1], "semantic": {"name": "url_bits", "arg_names": [], "import_names": [], "rhs_call_name": "split", "annotation": ""}, "snippet": " url_bits = url.split('/')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98801:If_L55_C8", "label": "if", "type": "if", "loc": [55, 56], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98801:FunctionDef_L44_C4", "vector": [4, 2, 0.6453, 0.0233, 2, 0.64, 1.0, 0, 3, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if self.fields.has_key(url_bits[0]):\n return self.calendar_view(request, self.fields[url_bits[0]], *url_bits[1:])"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98801:Return_L56_C12", "label": "return", "type": "return", "loc": [56, 56], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98801:If_L55_C8", "vector": [13, 3, 0.6512, 0.0116, 3, 0.11, 0.0, 0, 3, 0, 0, 0, 0, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return self.calendar_view(request, self.fields[url_bits[0]], *url_bits[1:])"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98801:FunctionDef_L60_C4", "label": "homepage_view", "type": "function", "loc": [60, 64], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98801:ClassDef_L12_C0", "vector": [2, 1, 0.7209, 0.0581, 1, 0.31, 0.8333, 450, 0, 2, 1, 0, 0, 0, 4], "semantic": {"name": "homepage_view", "arg_names": ["self", "request"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def homepage_view(self, request):\n easy_model = EasyModel(self.site, self.model)\n field_list = self.fields.values()\n field_list.sort(key=lambda k:k.verbose_name)\n return render_to_response('databrowse/calendar_homepage.html', {'root_url': self.site.root_url, 'model': easy_model, 'field_list': field_list})"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98801:Assign_L61_C8", "label": "easy_model = EasyModel()", "type": "assigned_variable", "loc": [61, 61], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98801:FunctionDef_L60_C4", "vector": [14, 2, 0.7093, 0.0116, 2, 0.03, 0.0, 363, 3, 2, 0, 0, 749, 10, 1], "semantic": {"name": "easy_model", "arg_names": [], "import_names": [], "rhs_call_name": "EasyModel", "annotation": ""}, "snippet": " easy_model = EasyModel(self.site, self.model)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98801:Assign_L62_C8", "label": "field_list = values()", "type": "assigned_variable", "loc": [62, 62], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98801:FunctionDef_L60_C4", "vector": [14, 2, 0.7209, 0.0116, 2, 0.03, 0.3333, 97, 3, 0, 0, 0, 721, 10, 1], "semantic": {"name": "field_list", "arg_names": [], "import_names": [], "rhs_call_name": "values", "annotation": ""}, "snippet": " field_list = self.fields.values()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98801:Expr_L63_C8", "label": "sort()", "type": "expression", "loc": [63, 63], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98801:FunctionDef_L60_C4", "vector": [8, 2, 0.7326, 0.0116, 2, 0.03, 0.6667, 489, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "sort", "arg_names": [], "import_names": [], "rhs_call_name": "sort", "annotation": ""}, "snippet": " field_list.sort(key=lambda k:k.verbose_name)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98801:Return_L64_C8", "label": "return", "type": "return", "loc": [64, 64], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98801:FunctionDef_L60_C4", "vector": [13, 2, 0.7442, 0.0116, 2, 0.03, 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('databrowse/calendar_homepage.html', {'root_url': self.site.root_url, 'model': easy_model, 'field_list': field_list})"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98801:FunctionDef_L66_C4", "label": "calendar_view", "type": "function", "loc": [66, 86], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98801:ClassDef_L12_C0", "vector": [2, 1, 0.8837, 0.2442, 1, 0.31, 1.0, 741, 0, 6, 1, 0, 0, 0, 6], "semantic": {"name": "calendar_view", "arg_names": ["self", "request", "field", "year", "month", "day"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def calendar_view(self, request, field, year=None, month=None, day=None):\n easy_model = EasyModel(self.site, self.model)\n queryset = easy_model.get_query_set()\n extra_context = {'root_url': self.site.root_url, 'model': easy_model, 'field': field}\n if day is not None:\n return date_based.archive_day(request, year, month, day, queryset, field.name,\n template_name='databrowse/calendar_day.html', allow_empty=False, allow_future=True,\n extra_context=extra_context)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98801:Assign_L67_C8", "label": "easy_model = EasyModel()", "type": "assigned_variable", "loc": [67, 67], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98801:FunctionDef_L66_C4", "vector": [14, 2, 0.7791, 0.0116, 2, 0.46, 0.0, 363, 3, 2, 0, 0, 749, 10, 1], "semantic": {"name": "easy_model", "arg_names": [], "import_names": [], "rhs_call_name": "EasyModel", "annotation": ""}, "snippet": " easy_model = EasyModel(self.site, self.model)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98801:Assign_L68_C8", "label": "queryset = get_query_set()", "type": "assigned_variable", "loc": [68, 68], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98801:FunctionDef_L66_C4", "vector": [14, 2, 0.7907, 0.0116, 2, 0.46, 0.3333, 38, 3, 0, 0, 0, 696, 10, 1], "semantic": {"name": "queryset", "arg_names": [], "import_names": [], "rhs_call_name": "get_query_set", "annotation": ""}, "snippet": " queryset = easy_model.get_query_set()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98801:Assign_L69_C8", "label": "extra_context =", "type": "assigned_variable", "loc": [69, 69], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98801:FunctionDef_L66_C4", "vector": [14, 2, 0.8023, 0.0116, 2, 0.46, 0.6667, 751, 0, 0, 0, 0, 0, 6, 0], "semantic": {"name": "extra_context", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " extra_context = {'root_url': self.site.root_url, 'model': easy_model, 'field': field}"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98801:If_L70_C8", "label": "if", "type": "if", "loc": [70, 85], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98801:FunctionDef_L66_C4", "vector": [4, 2, 0.9012, 0.186, 2, 0.46, 1.0, 0, 0, 0, 0, 0, 0, 0, 4], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if day is not None:\n return date_based.archive_day(request, year, month, day, queryset, field.name,\n template_name='databrowse/calendar_day.html', allow_empty=False, allow_future=True,\n extra_context=extra_context)\n elif month is not None:\n return date_based.archive_month(request, year, month, queryset, field.name,\n template_name='databrowse/calendar_month.html', allow_empty=False, allow_future=True,\n extra_context=extra_context)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98801:Return_L71_C12", "label": "return", "type": "return", "loc": [71, 73], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98801:If_L70_C8", "vector": [13, 3, 0.8372, 0.0349, 3, 0.19, 0.0, 0, 3, 0, 0, 0, 0, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return date_based.archive_day(request, year, month, day, queryset, field.name,\n template_name='databrowse/calendar_day.html', allow_empty=False, allow_future=True,\n extra_context=extra_context)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98801:If_L74_C8", "label": "if", "type": "if", "loc": [74, 85], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98801:If_L70_C8", "vector": [4, 3, 0.9244, 0.1395, 3, 0.19, 1.0, 0, 0, 0, 0, 0, 0, 0, 3], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " elif month is not None:\n return date_based.archive_month(request, year, month, queryset, field.name,\n template_name='databrowse/calendar_month.html', allow_empty=False, allow_future=True,\n extra_context=extra_context)\n elif year is not None:\n return date_based.archive_year(request, year, queryset, field.name,\n template_name='databrowse/calendar_year.html', allow_empty=False, allow_future=True,\n extra_context=extra_context)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98801:Return_L75_C12", "label": "return", "type": "return", "loc": [75, 77], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98801:If_L74_C8", "vector": [13, 4, 0.8837, 0.0349, 4, 0.08, 0.0, 0, 3, 0, 0, 0, 0, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return date_based.archive_month(request, year, month, queryset, field.name,\n template_name='databrowse/calendar_month.html', allow_empty=False, allow_future=True,\n extra_context=extra_context)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98801:If_L78_C8", "label": "if", "type": "if", "loc": [78, 85], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98801:If_L74_C8", "vector": [4, 4, 0.9477, 0.093, 4, 0.08, 1.0, 0, 0, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " elif year is not None:\n return date_based.archive_year(request, year, queryset, field.name,\n template_name='databrowse/calendar_year.html', allow_empty=False, allow_future=True,\n extra_context=extra_context)\n else:\n return date_based.archive_index(request, queryset, field.name,\n template_name='databrowse/calendar_main.html', allow_empty=True, allow_future=True,\n extra_context=extra_context)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98801:Return_L79_C12", "label": "return", "type": "return", "loc": [79, 81], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98801:If_L78_C8", "vector": [13, 5, 0.9302, 0.0349, 5, 0.13, 0.0, 0, 3, 0, 0, 0, 0, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return date_based.archive_year(request, year, queryset, field.name,\n template_name='databrowse/calendar_year.html', allow_empty=False, allow_future=True,\n extra_context=extra_context)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98801:Return_L83_C12", "label": "return", "type": "return", "loc": [83, 85], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98801:If_L78_C8", "vector": [13, 5, 0.9767, 0.0349, 5, 0.13, 1.0, 0, 3, 0, 0, 0, 0, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return date_based.archive_index(request, queryset, field.name,\n template_name='databrowse/calendar_main.html', allow_empty=True, allow_future=True,\n extra_context=extra_context)"}]
[{"f": "ajibawa-2023/Python-Code-Large/train/row_98801:ClassDef_L12_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98801:FunctionDef_L13_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98801:FunctionDef_L13_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98801:Assign_L14_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98801:ClassDef_L12_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98801:FunctionDef_L16_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98801:FunctionDef_L16_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98801:Expr_L17_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98801:FunctionDef_L16_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98801:If_L22_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98801:If_L22_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98801:Return_L23_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98801:If_L22_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98801:Return_L25_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98801:ClassDef_L12_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98801:FunctionDef_L27_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98801:FunctionDef_L27_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98801:Assign_L28_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98801:FunctionDef_L27_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98801:If_L29_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98801:If_L29_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98801:Return_L30_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98801:FunctionDef_L27_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98801:Return_L31_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98801:ClassDef_L12_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98801:FunctionDef_L34_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98801:FunctionDef_L34_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98801:If_L35_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98801:If_L35_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98801:Assign_L36_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98801:If_L35_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98801:Return_L37_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98801:ClassDef_L12_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98801:FunctionDef_L44_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98801:FunctionDef_L44_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98801:Assign_L45_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98801:FunctionDef_L44_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98801:Assign_L46_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98801:FunctionDef_L44_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98801:If_L49_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98801:FunctionDef_L44_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98801:If_L52_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98801:If_L52_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98801:Return_L53_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98801:FunctionDef_L44_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98801:Assign_L54_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98801:FunctionDef_L44_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98801:If_L55_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98801:If_L55_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98801:Return_L56_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98801:ClassDef_L12_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98801:FunctionDef_L60_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98801:FunctionDef_L60_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98801:Assign_L61_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98801:FunctionDef_L60_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98801:Assign_L62_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98801:FunctionDef_L60_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98801:Expr_L63_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98801:FunctionDef_L60_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98801:Return_L64_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98801:ClassDef_L12_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98801:FunctionDef_L66_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98801:FunctionDef_L66_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98801:Assign_L67_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98801:FunctionDef_L66_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98801:Assign_L68_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98801:FunctionDef_L66_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98801:Assign_L69_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98801:FunctionDef_L66_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98801:If_L70_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98801:If_L70_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98801:Return_L71_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98801:If_L70_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98801:If_L74_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98801:If_L74_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98801:Return_L75_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98801:If_L74_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98801:If_L78_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98801:If_L78_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98801:Return_L79_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98801:If_L78_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98801:Return_L83_C12"}]
from django import http from django.db import models from django.contrib.databrowse.datastructures import EasyModel from django.contrib.databrowse.sites import DatabrowsePlugin from django.shortcuts import render_to_response from django.utils.text import capfirst from django.utils.encoding import smart_str, force_unicode from django.utils.safestring import mark_safe import urllib class FieldChoicePlugin(DatabrowsePlugin): def __init__(self, field_filter=None): # If field_filter is given, it should be a callable that takes a # Django database Field instance and returns True if that field should # be included. If field_filter is None, that all fields will be used. self.field_filter = field_filter def field_dict(self, model): """ Helper function that returns a dictionary of all fields in the given model. If self.field_filter is set, it only includes the fields that match the filter. """ if self.field_filter: return dict([(f.name, f) for f in model._meta.fields if self.field_filter(f)]) else: return dict([(f.name, f) for f in model._meta.fields if not f.rel and not f.primary_key and not f.unique and not isinstance(f, (models.AutoField, models.TextField))]) def model_index_html(self, request, model, site): fields = self.field_dict(model) if not fields: return u'' return mark_safe(u'<p class="filter"><strong>View by:</strong> %s</p>' % \ u', '.join(['<a href="fields/%s/">%s</a>' % (f.name, force_unicode(capfirst(f.verbose_name))) for f in fields.values()])) def urls(self, plugin_name, easy_instance_field): if easy_instance_field.field in self.field_dict(easy_instance_field.model.model).values(): field_value = smart_str(easy_instance_field.raw_value) return [mark_safe(u'%s%s/%s/%s/' % ( easy_instance_field.model.url(), plugin_name, easy_instance_field.field.name, urllib.quote(field_value, safe='')))] def model_view(self, request, model_databrowse, url): self.model, self.site = model_databrowse.model, model_databrowse.site self.fields = self.field_dict(self.model) # If the model has no fields with choices, there's no point in going # further. if not self.fields: raise http.Http404('The requested model has no fields.') if url is None: return self.homepage_view(request) url_bits = url.split('/', 1) if self.fields.has_key(url_bits[0]): return self.field_view(request, self.fields[url_bits[0]], *url_bits[1:]) raise http.Http404('The requested page does not exist.') def homepage_view(self, request): easy_model = EasyModel(self.site, self.model) field_list = self.fields.values() field_list.sort(key=lambda k: k.verbose_name) return render_to_response('databrowse/fieldchoice_homepage.html', {'root_url': self.site.root_url, 'model': easy_model, 'field_list': field_list}) def field_view(self, request, field, value=None): easy_model = EasyModel(self.site, self.model) easy_field = easy_model.field(field.name) if value is not None: obj_list = easy_model.objects(**{field.name: value}) return render_to_response('databrowse/fieldchoice_detail.html', {'root_url': self.site.root_url, 'model': easy_model, 'field': easy_field, 'value': value, 'object_list': obj_list}) obj_list = [v[field.name] for v in self.model._default_manager.distinct().order_by(field.name).values(field.name)] return render_to_response('databrowse/fieldchoice_list.html', {'root_url': self.site.root_url, 'model': easy_model, 'field': easy_field, 'object_list': obj_list})
ajibawa-2023/Python-Code-Large/train/row_98802
48
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_98802:ImportFrom_L1_C0", "label": "from django import http", "type": "import", "loc": [1, 1], "level": 0, "parent": null, "vector": [1, 0, 0.0135, 0.0135, 0, 0.66, 0.0, 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_98802:ImportFrom_L2_C0", "label": "from django.db import models", "type": "import", "loc": [2, 2], "level": 0, "parent": null, "vector": [1, 0, 0.027, 0.0135, 0, 0.66, 0.1111, 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_98802:ImportFrom_L3_C0", "label": "from django.contrib.databrowse.datastructures import EasyModel", "type": "import", "loc": [3, 3], "level": 0, "parent": null, "vector": [1, 0, 0.0405, 0.0135, 0, 0.66, 0.2222, 235, 0, 1, 0, 0, 235, 0, 0], "semantic": {"name": "django.contrib.databrowse.datastructures", "arg_names": [], "import_names": ["EasyModel"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.contrib.databrowse.datastructures import EasyModel"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98802:ImportFrom_L4_C0", "label": "from django.contrib.databrowse.sites import DatabrowsePlugin", "type": "import", "loc": [4, 4], "level": 0, "parent": null, "vector": [1, 0, 0.0541, 0.0135, 0, 0.66, 0.3333, 231, 0, 1, 0, 0, 231, 0, 0], "semantic": {"name": "django.contrib.databrowse.sites", "arg_names": [], "import_names": ["DatabrowsePlugin"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.contrib.databrowse.sites import DatabrowsePlugin"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98802:ImportFrom_L5_C0", "label": "from django.shortcuts import render_to_response", "type": "import", "loc": [5, 5], "level": 0, "parent": null, "vector": [1, 0, 0.0676, 0.0135, 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_98802:ImportFrom_L6_C0", "label": "from django.utils.text import capfirst", "type": "import", "loc": [6, 6], "level": 0, "parent": null, "vector": [1, 0, 0.0811, 0.0135, 0, 0.66, 0.5556, 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_98802:ImportFrom_L7_C0", "label": "from django.utils.encoding import smart_str, force_unicode", "type": "import", "loc": [7, 7], "level": 0, "parent": null, "vector": [1, 0, 0.0946, 0.0135, 0, 0.66, 0.6667, 96, 0, 2, 0, 0, 96, 0, 0], "semantic": {"name": "django.utils.encoding", "arg_names": [], "import_names": ["smart_str", "force_unicode"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.utils.encoding import smart_str, force_unicode"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98802:ImportFrom_L8_C0", "label": "from django.utils.safestring import mark_safe", "type": "import", "loc": [8, 8], "level": 0, "parent": null, "vector": [1, 0, 0.1081, 0.0135, 0, 0.66, 0.7778, 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_98802:Import_L9_C0", "label": "urllib import urllib", "type": "import", "loc": [9, 9], "level": 0, "parent": null, "vector": [1, 0, 0.1216, 0.0135, 0, 0.66, 0.8889, 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_98802:ClassDef_L11_C0", "label": "FieldChoicePlugin", "type": "class", "loc": [11, 74], "level": 0, "parent": null, "vector": [3, 0, 0.5743, 0.8649, 0, 0.66, 1.0, 724, 0, 7, 0, 0, 298, 0, 35], "semantic": {"name": "FieldChoicePlugin", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class FieldChoicePlugin(DatabrowsePlugin):\n def __init__(self, field_filter=None):\n # If field_filter is given, it should be a callable that takes a\n # Django database Field instance and returns True if that field should\n # be included. If field_filter is None, that all fields will be used.\n self.field_filter = field_filter\n\n def field_dict(self, model):"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98802:FunctionDef_L12_C4", "label": "__init__", "type": "function", "loc": [12, 16], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98802:ClassDef_L11_C0", "vector": [2, 1, 0.1892, 0.0676, 1, 0.85, 0.0, 555, 0, 2, 0, 0, 0, 0, 0], "semantic": {"name": "__init__", "arg_names": ["self", "field_filter"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def __init__(self, field_filter=None):\n # If field_filter is given, it should be a callable that takes a\n # Django database Field instance and returns True if that field should\n # be included. If field_filter is None, that all fields will be used.\n self.field_filter = field_filter"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98802:Assign_L16_C8", "label": "self.field_filter =", "type": "assigned_variable", "loc": [16, 16], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98802:FunctionDef_L12_C4", "vector": [14, 2, 0.2162, 0.0135, 2, 0.16, 0.0, 60, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "self.field_filter", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.field_filter = field_filter"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98802:FunctionDef_L18_C4", "label": "field_dict", "type": "function", "loc": [18, 27], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98802:ClassDef_L11_C0", "vector": [2, 1, 0.3041, 0.1351, 1, 0.85, 0.1667, 459, 0, 2, 1, 0, 0, 0, 4], "semantic": {"name": "field_dict", "arg_names": ["self", "model"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def field_dict(self, model):\n \"\"\"\n Helper function that returns a dictionary of all fields in the given\n model. If self.field_filter is set, it only includes the fields that\n match the filter.\n \"\"\"\n if self.field_filter:\n return dict([(f.name, f) for f in model._meta.fields if self.field_filter(f)])"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98802:Expr_L19_C8", "label": "expression", "type": "expression", "loc": [19, 23], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98802:FunctionDef_L18_C4", "vector": [8, 2, 0.2838, 0.0676, 2, 0.34, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"\n Helper function that returns a dictionary of all fields in the given\n model. If self.field_filter is set, it only includes the fields that\n match the filter.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98802:If_L24_C8", "label": "if", "type": "if", "loc": [24, 27], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98802:FunctionDef_L18_C4", "vector": [4, 2, 0.3446, 0.0541, 2, 0.34, 1.0, 0, 7, 0, 0, 0, 0, 0, 4], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if self.field_filter:\n return dict([(f.name, f) for f in model._meta.fields if self.field_filter(f)])\n else:\n return dict([(f.name, f) for f in model._meta.fields if not f.rel and not f.primary_key and not f.unique and not isinstance(f, (models.AutoField, models.TextField))])"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98802:Return_L25_C12", "label": "return", "type": "return", "loc": [25, 25], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98802:If_L24_C8", "vector": [13, 3, 0.3378, 0.0135, 3, 0.76, 0.0, 0, 3, 0, 0, 0, 0, 10, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return dict([(f.name, f) for f in model._meta.fields if self.field_filter(f)])"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98802:Return_L27_C12", "label": "return", "type": "return", "loc": [27, 27], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98802:If_L24_C8", "vector": [13, 3, 0.3649, 0.0135, 3, 0.76, 1.0, 0, 3, 0, 0, 0, 0, 10, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return dict([(f.name, f) for f in model._meta.fields if not f.rel and not f.primary_key and not f.unique and not isinstance(f, (models.AutoField, models.TextField))])"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98802:FunctionDef_L29_C4", "label": "model_index_html", "type": "function", "loc": [29, 34], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98802:ClassDef_L11_C0", "vector": [2, 1, 0.4257, 0.0811, 1, 0.85, 0.3333, 182, 0, 4, 1, 0, 0, 0, 6], "semantic": {"name": "model_index_html", "arg_names": ["self", "request", "model", "site"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def model_index_html(self, request, model, site):\n fields = self.field_dict(model)\n if not fields:\n return u''\n return mark_safe(u'<p class=\"filter\"><strong>View by:</strong> %s</p>' % \\\n u', '.join(['<a href=\"fields/%s/\">%s</a>' % (f.name, force_unicode(capfirst(f.verbose_name))) for f in fields.values()]))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98802:Assign_L30_C8", "label": "fields = field_dict()", "type": "assigned_variable", "loc": [30, 30], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98802:FunctionDef_L29_C4", "vector": [14, 2, 0.4054, 0.0135, 2, 0.88, 0.0, 358, 3, 1, 0, 0, 459, 10, 1], "semantic": {"name": "fields", "arg_names": [], "import_names": [], "rhs_call_name": "field_dict", "annotation": ""}, "snippet": " fields = self.field_dict(model)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98802:If_L31_C8", "label": "if", "type": "if", "loc": [31, 32], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98802:FunctionDef_L29_C4", "vector": [4, 2, 0.4257, 0.027, 2, 0.88, 0.5, 0, 0, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if not fields:\n return u''"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98802:Return_L32_C12", "label": "return", "type": "return", "loc": [32, 32], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98802:If_L31_C8", "vector": [13, 3, 0.4324, 0.0135, 3, 0.36, 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_98802:Return_L33_C8", "label": "return", "type": "return", "loc": [33, 34], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98802:FunctionDef_L29_C4", "vector": [13, 2, 0.4527, 0.027, 2, 0.88, 1.0, 0, 3, 0, 0, 0, 0, 10, 5], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return mark_safe(u'<p class=\"filter\"><strong>View by:</strong> %s</p>' % \\\n u', '.join(['<a href=\"fields/%s/\">%s</a>' % (f.name, force_unicode(capfirst(f.verbose_name))) for f in fields.values()]))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98802:FunctionDef_L36_C4", "label": "urls", "type": "function", "loc": [36, 42], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98802:ClassDef_L11_C0", "vector": [2, 1, 0.527, 0.0946, 1, 0.85, 0.5, 260, 0, 3, 1, 0, 0, 0, 6], "semantic": {"name": "urls", "arg_names": ["self", "plugin_name", "easy_instance_field"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def urls(self, plugin_name, easy_instance_field):\n if easy_instance_field.field in self.field_dict(easy_instance_field.model.model).values():\n field_value = smart_str(easy_instance_field.raw_value)\n return [mark_safe(u'%s%s/%s/%s/' % (\n easy_instance_field.model.url(),\n plugin_name, easy_instance_field.field.name,\n urllib.quote(field_value, safe='')))]"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98802:If_L37_C8", "label": "if", "type": "if", "loc": [37, 42], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98802:FunctionDef_L36_C4", "vector": [4, 2, 0.5338, 0.0811, 2, 0.55, 0.0, 0, 0, 0, 0, 0, 0, 0, 6], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if easy_instance_field.field in self.field_dict(easy_instance_field.model.model).values():\n field_value = smart_str(easy_instance_field.raw_value)\n return [mark_safe(u'%s%s/%s/%s/' % (\n easy_instance_field.model.url(),\n plugin_name, easy_instance_field.field.name,\n urllib.quote(field_value, safe='')))]"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98802:Assign_L38_C12", "label": "field_value = smart_str()", "type": "assigned_variable", "loc": [38, 38], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98802:If_L37_C8", "vector": [14, 3, 0.5135, 0.0135, 3, 0.32, 0.0, 900, 3, 1, 0, 0, 820, 10, 1], "semantic": {"name": "field_value", "arg_names": [], "import_names": [], "rhs_call_name": "smart_str", "annotation": ""}, "snippet": " field_value = smart_str(easy_instance_field.raw_value)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98802:Return_L39_C12", "label": "return", "type": "return", "loc": [39, 42], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98802:If_L37_C8", "vector": [13, 3, 0.5473, 0.0541, 3, 0.32, 1.0, 0, 0, 0, 0, 0, 0, 5, 3], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return [mark_safe(u'%s%s/%s/%s/' % (\n easy_instance_field.model.url(),\n plugin_name, easy_instance_field.field.name,\n urllib.quote(field_value, safe='')))]"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98802:FunctionDef_L44_C4", "label": "model_view", "type": "function", "loc": [44, 59], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98802:ClassDef_L11_C0", "vector": [2, 1, 0.6959, 0.2162, 1, 0.85, 0.6667, 372, 0, 4, 1, 0, 0, 0, 7], "semantic": {"name": "model_view", "arg_names": ["self", "request", "model_databrowse", "url"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def model_view(self, request, model_databrowse, url):\n self.model, self.site = model_databrowse.model, model_databrowse.site\n self.fields = self.field_dict(self.model)\n\n # If the model has no fields with choices, there's no point in going\n # further.\n if not self.fields:\n raise http.Http404('The requested model has no fields.')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98802:Assign_L45_C8", "label": "assign", "type": "assigned_variable", "loc": [45, 45], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98802:FunctionDef_L44_C4", "vector": [14, 2, 0.6081, 0.0135, 2, 0.43, 0.0, 0, 0, 0, 0, 0, 0, 8, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.model, self.site = model_databrowse.model, model_databrowse.site"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98802:Assign_L46_C8", "label": "self.fields = field_dict()", "type": "assigned_variable", "loc": [46, 46], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98802:FunctionDef_L44_C4", "vector": [14, 2, 0.6216, 0.0135, 2, 0.43, 0.2, 318, 3, 1, 0, 0, 459, 10, 1], "semantic": {"name": "self.fields", "arg_names": [], "import_names": [], "rhs_call_name": "field_dict", "annotation": ""}, "snippet": " self.fields = self.field_dict(self.model)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98802:If_L50_C8", "label": "if", "type": "if", "loc": [50, 51], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98802:FunctionDef_L44_C4", "vector": [4, 2, 0.6824, 0.027, 2, 0.43, 0.4, 0, 0, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if not self.fields:\n raise http.Http404('The requested model has no fields.')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98802:If_L53_C8", "label": "if", "type": "if", "loc": [53, 54], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98802:FunctionDef_L44_C4", "vector": [4, 2, 0.723, 0.027, 2, 0.43, 0.6, 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.homepage_view(request)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98802:Return_L54_C12", "label": "return", "type": "return", "loc": [54, 54], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98802:If_L53_C8", "vector": [13, 3, 0.7297, 0.0135, 3, 0.82, 0.0, 0, 3, 0, 0, 0, 0, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return self.homepage_view(request)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98802:Assign_L55_C8", "label": "url_bits = split()", "type": "assigned_variable", "loc": [55, 55], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98802:FunctionDef_L44_C4", "vector": [14, 2, 0.7432, 0.0135, 2, 0.43, 0.8, 72, 3, 2, 0, 0, 908, 10, 1], "semantic": {"name": "url_bits", "arg_names": [], "import_names": [], "rhs_call_name": "split", "annotation": ""}, "snippet": " url_bits = url.split('/', 1)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98802:If_L56_C8", "label": "if", "type": "if", "loc": [56, 57], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98802:FunctionDef_L44_C4", "vector": [4, 2, 0.7635, 0.027, 2, 0.43, 1.0, 0, 3, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if self.fields.has_key(url_bits[0]):\n return self.field_view(request, self.fields[url_bits[0]], *url_bits[1:])"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98802:Return_L57_C12", "label": "return", "type": "return", "loc": [57, 57], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98802:If_L56_C8", "vector": [13, 3, 0.7703, 0.0135, 3, 0.56, 0.0, 0, 3, 0, 0, 0, 0, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return self.field_view(request, self.fields[url_bits[0]], *url_bits[1:])"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98802:FunctionDef_L61_C4", "label": "homepage_view", "type": "function", "loc": [61, 65], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98802:ClassDef_L11_C0", "vector": [2, 1, 0.8514, 0.0676, 1, 0.85, 0.8333, 450, 0, 2, 1, 0, 0, 0, 4], "semantic": {"name": "homepage_view", "arg_names": ["self", "request"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def homepage_view(self, request):\n easy_model = EasyModel(self.site, self.model)\n field_list = self.fields.values()\n field_list.sort(key=lambda k: k.verbose_name)\n return render_to_response('databrowse/fieldchoice_homepage.html', {'root_url': self.site.root_url, 'model': easy_model, 'field_list': field_list})"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98802:Assign_L62_C8", "label": "easy_model = EasyModel()", "type": "assigned_variable", "loc": [62, 62], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98802:FunctionDef_L61_C4", "vector": [14, 2, 0.8378, 0.0135, 2, 0.95, 0.0, 363, 3, 2, 0, 0, 749, 10, 1], "semantic": {"name": "easy_model", "arg_names": [], "import_names": [], "rhs_call_name": "EasyModel", "annotation": ""}, "snippet": " easy_model = EasyModel(self.site, self.model)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98802:Assign_L63_C8", "label": "field_list = values()", "type": "assigned_variable", "loc": [63, 63], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98802:FunctionDef_L61_C4", "vector": [14, 2, 0.8514, 0.0135, 2, 0.95, 0.3333, 97, 3, 0, 0, 0, 721, 10, 1], "semantic": {"name": "field_list", "arg_names": [], "import_names": [], "rhs_call_name": "values", "annotation": ""}, "snippet": " field_list = self.fields.values()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98802:Expr_L64_C8", "label": "sort()", "type": "expression", "loc": [64, 64], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98802:FunctionDef_L61_C4", "vector": [8, 2, 0.8649, 0.0135, 2, 0.95, 0.6667, 489, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "sort", "arg_names": [], "import_names": [], "rhs_call_name": "sort", "annotation": ""}, "snippet": " field_list.sort(key=lambda k: k.verbose_name)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98802:Return_L65_C8", "label": "return", "type": "return", "loc": [65, 65], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98802:FunctionDef_L61_C4", "vector": [13, 2, 0.8784, 0.0135, 2, 0.95, 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('databrowse/fieldchoice_homepage.html', {'root_url': self.site.root_url, 'model': easy_model, 'field_list': field_list})"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98802:FunctionDef_L67_C4", "label": "field_view", "type": "function", "loc": [67, 74], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98802:ClassDef_L11_C0", "vector": [2, 1, 0.9527, 0.1081, 1, 0.85, 1.0, 767, 0, 4, 1, 0, 0, 0, 8], "semantic": {"name": "field_view", "arg_names": ["self", "request", "field", "value"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def field_view(self, request, field, value=None):\n easy_model = EasyModel(self.site, self.model)\n easy_field = easy_model.field(field.name)\n if value is not None:\n obj_list = easy_model.objects(**{field.name: value})\n return render_to_response('databrowse/fieldchoice_detail.html', {'root_url': self.site.root_url, 'model': easy_model, 'field': easy_field, 'value': value, 'object_list': obj_list})\n obj_list = [v[field.name] for v in self.model._default_manager.distinct().order_by(field.name).values(field.name)]\n return render_to_response('databrowse/fieldchoice_list.html', {'root_url': self.site.root_url, 'model': easy_model, 'field': easy_field, 'object_list': obj_list})"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98802:Assign_L68_C8", "label": "easy_model = EasyModel()", "type": "assigned_variable", "loc": [68, 68], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98802:FunctionDef_L67_C4", "vector": [14, 2, 0.9189, 0.0135, 2, 0.12, 0.0, 363, 3, 2, 0, 0, 749, 10, 1], "semantic": {"name": "easy_model", "arg_names": [], "import_names": [], "rhs_call_name": "EasyModel", "annotation": ""}, "snippet": " easy_model = EasyModel(self.site, self.model)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98802:Assign_L69_C8", "label": "easy_field = field()", "type": "assigned_variable", "loc": [69, 69], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98802:FunctionDef_L67_C4", "vector": [14, 2, 0.9324, 0.0135, 2, 0.12, 0.25, 862, 3, 1, 0, 0, 480, 10, 1], "semantic": {"name": "easy_field", "arg_names": [], "import_names": [], "rhs_call_name": "field", "annotation": ""}, "snippet": " easy_field = easy_model.field(field.name)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98802:If_L70_C8", "label": "if", "type": "if", "loc": [70, 72], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98802:FunctionDef_L67_C4", "vector": [4, 2, 0.9595, 0.0405, 2, 0.12, 0.5, 0, 0, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if value is not None:\n obj_list = easy_model.objects(**{field.name: value})\n return render_to_response('databrowse/fieldchoice_detail.html', {'root_url': self.site.root_url, 'model': easy_model, 'field': easy_field, 'value': value, 'object_list': obj_list})"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98802:Assign_L71_C12", "label": "obj_list = objects()", "type": "assigned_variable", "loc": [71, 71], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98802:If_L70_C8", "vector": [14, 3, 0.9595, 0.0135, 3, 0.99, 0.0, 342, 3, 1, 0, 0, 550, 10, 1], "semantic": {"name": "obj_list", "arg_names": [], "import_names": [], "rhs_call_name": "objects", "annotation": ""}, "snippet": " obj_list = easy_model.objects(**{field.name: value})"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98802:Return_L72_C12", "label": "return", "type": "return", "loc": [72, 72], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98802:If_L70_C8", "vector": [13, 3, 0.973, 0.0135, 3, 0.99, 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('databrowse/fieldchoice_detail.html', {'root_url': self.site.root_url, 'model': easy_model, 'field': easy_field, 'value': value, 'object_list': obj_list})"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98802:Assign_L73_C8", "label": "obj_list =", "type": "assigned_variable", "loc": [73, 73], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98802:FunctionDef_L67_C4", "vector": [14, 2, 0.9865, 0.0135, 2, 0.12, 0.75, 342, 5, 0, 0, 0, 0, 0, 3], "semantic": {"name": "obj_list", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " obj_list = [v[field.name] for v in self.model._default_manager.distinct().order_by(field.name).values(field.name)]"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98802:Return_L74_C8", "label": "return", "type": "return", "loc": [74, 74], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98802:FunctionDef_L67_C4", "vector": [13, 2, 1.0, 0.0135, 2, 0.12, 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('databrowse/fieldchoice_list.html', {'root_url': self.site.root_url, 'model': easy_model, 'field': easy_field, 'object_list': obj_list})"}]
[{"f": "ajibawa-2023/Python-Code-Large/train/row_98802:ClassDef_L11_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98802:FunctionDef_L12_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98802:FunctionDef_L12_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98802:Assign_L16_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98802:ClassDef_L11_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98802:FunctionDef_L18_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98802:FunctionDef_L18_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98802:Expr_L19_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98802:FunctionDef_L18_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98802:If_L24_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98802:If_L24_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98802:Return_L25_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98802:If_L24_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98802:Return_L27_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98802:ClassDef_L11_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98802:FunctionDef_L29_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98802:FunctionDef_L29_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98802:Assign_L30_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98802:FunctionDef_L29_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98802:If_L31_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98802:If_L31_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98802:Return_L32_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98802:FunctionDef_L29_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98802:Return_L33_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98802:ClassDef_L11_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98802:FunctionDef_L36_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98802:FunctionDef_L36_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98802:If_L37_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98802:If_L37_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98802:Assign_L38_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98802:If_L37_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98802:Return_L39_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98802:ClassDef_L11_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98802:FunctionDef_L44_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98802:FunctionDef_L44_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98802:Assign_L45_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98802:FunctionDef_L44_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98802:Assign_L46_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98802:FunctionDef_L44_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98802:If_L50_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98802:FunctionDef_L44_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98802:If_L53_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98802:If_L53_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98802:Return_L54_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98802:FunctionDef_L44_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98802:Assign_L55_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98802:FunctionDef_L44_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98802:If_L56_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98802:If_L56_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98802:Return_L57_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98802:ClassDef_L11_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98802:FunctionDef_L61_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98802:FunctionDef_L61_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98802:Assign_L62_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98802:FunctionDef_L61_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98802:Assign_L63_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98802:FunctionDef_L61_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98802:Expr_L64_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98802:FunctionDef_L61_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98802:Return_L65_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98802:ClassDef_L11_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98802:FunctionDef_L67_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98802:FunctionDef_L67_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98802:Assign_L68_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98802:FunctionDef_L67_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98802:Assign_L69_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98802:FunctionDef_L67_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98802:If_L70_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98802:If_L70_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98802:Assign_L71_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98802:If_L70_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98802:Return_L72_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98802:FunctionDef_L67_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98802:Assign_L73_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98802:FunctionDef_L67_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98802:Return_L74_C8"}]
from django import http from django.contrib.databrowse.datastructures import EasyModel from django.contrib.databrowse.sites import DatabrowsePlugin from django.shortcuts import render_to_response import urlparse class ObjectDetailPlugin(DatabrowsePlugin): def model_view(self, request, model_databrowse, url): # If the object ID wasn't provided, redirect to the model page, which is one level up. if url is None: return http.HttpResponseRedirect(urlparse.urljoin(request.path, '../')) easy_model = EasyModel(model_databrowse.site, model_databrowse.model) obj = easy_model.object_by_pk(url) return render_to_response('databrowse/object_detail.html', {'object': obj, 'root_url': model_databrowse.site.root_url})
ajibawa-2023/Python-Code-Large/train/row_98803
12
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_98803:ImportFrom_L1_C0", "label": "from django import http", "type": "import", "loc": [1, 1], "level": 0, "parent": null, "vector": [1, 0, 0.0714, 0.0714, 0, 0.66, 0.0, 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_98803:ImportFrom_L2_C0", "label": "from django.contrib.databrowse.datastructures import EasyModel", "type": "import", "loc": [2, 2], "level": 0, "parent": null, "vector": [1, 0, 0.1429, 0.0714, 0, 0.66, 0.2, 235, 0, 1, 0, 0, 235, 0, 0], "semantic": {"name": "django.contrib.databrowse.datastructures", "arg_names": [], "import_names": ["EasyModel"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.contrib.databrowse.datastructures import EasyModel"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98803:ImportFrom_L3_C0", "label": "from django.contrib.databrowse.sites import DatabrowsePlugin", "type": "import", "loc": [3, 3], "level": 0, "parent": null, "vector": [1, 0, 0.2143, 0.0714, 0, 0.66, 0.4, 231, 0, 1, 0, 0, 231, 0, 0], "semantic": {"name": "django.contrib.databrowse.sites", "arg_names": [], "import_names": ["DatabrowsePlugin"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.contrib.databrowse.sites import DatabrowsePlugin"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98803:ImportFrom_L4_C0", "label": "from django.shortcuts import render_to_response", "type": "import", "loc": [4, 4], "level": 0, "parent": null, "vector": [1, 0, 0.2857, 0.0714, 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_98803:Import_L5_C0", "label": "urlparse import urlparse", "type": "import", "loc": [5, 5], "level": 0, "parent": null, "vector": [1, 0, 0.3571, 0.0714, 0, 0.66, 0.8, 857, 0, 1, 0, 0, 857, 0, 0], "semantic": {"name": "urlparse", "arg_names": [], "import_names": ["urlparse"], "rhs_call_name": "", "annotation": ""}, "snippet": "import urlparse"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98803:ClassDef_L7_C0", "label": "ObjectDetailPlugin", "type": "class", "loc": [7, 14], "level": 0, "parent": null, "vector": [3, 0, 0.75, 0.5714, 0, 0.66, 1.0, 121, 0, 1, 0, 0, 298, 0, 5], "semantic": {"name": "ObjectDetailPlugin", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class ObjectDetailPlugin(DatabrowsePlugin):\n def model_view(self, request, model_databrowse, url):\n # If the object ID wasn't provided, redirect to the model page, which is one level up.\n if url is None:\n return http.HttpResponseRedirect(urlparse.urljoin(request.path, '../'))\n easy_model = EasyModel(model_databrowse.site, model_databrowse.model)\n obj = easy_model.object_by_pk(url)\n return render_to_response('databrowse/object_detail.html', {'object': obj, 'root_url': model_databrowse.site.root_url})"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98803:FunctionDef_L8_C4", "label": "model_view", "type": "function", "loc": [8, 14], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98803:ClassDef_L7_C0", "vector": [2, 1, 0.7857, 0.5, 1, 0.69, 0.0, 372, 0, 4, 1, 0, 0, 0, 5], "semantic": {"name": "model_view", "arg_names": ["self", "request", "model_databrowse", "url"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def model_view(self, request, model_databrowse, url):\n # If the object ID wasn't provided, redirect to the model page, which is one level up.\n if url is None:\n return http.HttpResponseRedirect(urlparse.urljoin(request.path, '../'))\n easy_model = EasyModel(model_databrowse.site, model_databrowse.model)\n obj = easy_model.object_by_pk(url)\n return render_to_response('databrowse/object_detail.html', {'object': obj, 'root_url': model_databrowse.site.root_url})"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98803:If_L10_C8", "label": "if", "type": "if", "loc": [10, 11], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98803:FunctionDef_L8_C4", "vector": [4, 2, 0.75, 0.1429, 2, 0.93, 0.0, 0, 0, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if url is None:\n return http.HttpResponseRedirect(urlparse.urljoin(request.path, '../'))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98803:Return_L11_C12", "label": "return", "type": "return", "loc": [11, 11], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98803:If_L10_C8", "vector": [13, 3, 0.7857, 0.0714, 3, 0.89, 0.0, 0, 3, 0, 0, 0, 0, 10, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return http.HttpResponseRedirect(urlparse.urljoin(request.path, '../'))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98803:Assign_L12_C8", "label": "easy_model = EasyModel()", "type": "assigned_variable", "loc": [12, 12], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98803:FunctionDef_L8_C4", "vector": [14, 2, 0.8571, 0.0714, 2, 0.93, 0.3333, 363, 3, 2, 0, 0, 749, 10, 1], "semantic": {"name": "easy_model", "arg_names": [], "import_names": [], "rhs_call_name": "EasyModel", "annotation": ""}, "snippet": " easy_model = EasyModel(model_databrowse.site, model_databrowse.model)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98803:Assign_L13_C8", "label": "obj = object_by_pk()", "type": "assigned_variable", "loc": [13, 13], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98803:FunctionDef_L8_C4", "vector": [14, 2, 0.9286, 0.0714, 2, 0.93, 0.6667, 505, 3, 1, 0, 0, 601, 10, 1], "semantic": {"name": "obj", "arg_names": [], "import_names": [], "rhs_call_name": "object_by_pk", "annotation": ""}, "snippet": " obj = easy_model.object_by_pk(url)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98803:Return_L14_C8", "label": "return", "type": "return", "loc": [14, 14], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98803:FunctionDef_L8_C4", "vector": [13, 2, 1.0, 0.0714, 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 render_to_response('databrowse/object_detail.html', {'object': obj, 'root_url': model_databrowse.site.root_url})"}]
[{"f": "ajibawa-2023/Python-Code-Large/train/row_98803:ClassDef_L7_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98803:FunctionDef_L8_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98803:FunctionDef_L8_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98803:If_L10_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98803:If_L10_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98803:Return_L11_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98803:FunctionDef_L8_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98803:Assign_L12_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98803:FunctionDef_L8_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98803:Assign_L13_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98803:FunctionDef_L8_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98803:Return_L14_C8"}]
from django import http from django.db import models from django.contrib.databrowse.datastructures import EasyModel from django.shortcuts import render_to_response from django.utils.safestring import mark_safe class AlreadyRegistered(Exception): pass class NotRegistered(Exception): pass class DatabrowsePlugin(object): def urls(self, plugin_name, easy_instance_field): """ Given an EasyInstanceField object, returns a list of URLs for this plugin's views of this object. These URLs should be absolute. Returns None if the EasyInstanceField object doesn't get a list of plugin-specific URLs. """ return None def model_index_html(self, request, model, site): """ Returns a snippet of HTML to include on the model index page. """ return '' def model_view(self, request, model_databrowse, url): """ Handles main URL routing for a plugin's model-specific pages. """ raise NotImplementedError class ModelDatabrowse(object): plugins = {} def __init__(self, model, site): self.model = model self.site = site def root(self, request, url): """ Handles main URL routing for the databrowse app. `url` is the remainder of the URL -- e.g. 'objects/3'. """ # Delegate to the appropriate method, based on the URL. if url is None: return self.main_view(request) try: plugin_name, rest_of_url = url.split('/', 1) except ValueError: # need more than 1 value to unpack plugin_name, rest_of_url = url, None try: plugin = self.plugins[plugin_name] except KeyError: raise http.Http404('A plugin with the requested name does not exist.') return plugin.model_view(request, self, rest_of_url) def main_view(self, request): easy_model = EasyModel(self.site, self.model) html_snippets = mark_safe(u'\n'.join([p.model_index_html(request, self.model, self.site) for p in self.plugins.values()])) return render_to_response('databrowse/model_detail.html', { 'model': easy_model, 'root_url': self.site.root_url, 'plugin_html': html_snippets, }) class DatabrowseSite(object): def __init__(self): self.registry = {} # model_class -> databrowse_class self.root_url = None def register(self, model_or_iterable, databrowse_class=None, **options): """ Registers the given model(s) with the given databrowse site. The model(s) should be Model classes, not instances. If a databrowse class isn't given, it will use DefaultModelDatabrowse (the default databrowse options). If a model is already registered, this will raise AlreadyRegistered. """ databrowse_class = databrowse_class or DefaultModelDatabrowse if issubclass(model_or_iterable, models.Model): 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__) self.registry[model] = databrowse_class def unregister(self, model_or_iterable): """ Unregisters the given model(s). If a model isn't already registered, this will raise NotRegistered. """ if issubclass(model_or_iterable, models.Model): 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 root(self, request, url): """ Handles main URL routing for the databrowse app. `url` is the remainder of the URL -- e.g. 'comments/comment/'. """ self.root_url = request.path[:len(request.path) - len(url)] url = url.rstrip('/') # Trim trailing slash, if it exists. if url == '': return self.index(request) elif '/' in url: return self.model_page(request, *url.split('/', 2)) raise http.Http404('The requested databrowse page does not exist.') def index(self, request): m_list = [EasyModel(self, m) for m in self.registry.keys()] return render_to_response('databrowse/homepage.html', {'model_list': m_list, 'root_url': self.root_url}) def model_page(self, request, app_label, model_name, rest_of_url=None): """ Handles the model-specific functionality of the databrowse site, delegating to the appropriate ModelDatabrowse class. """ model = models.get_model(app_label, model_name) if model is None: raise http.Http404("App %r, model %r, not found." % (app_label, model_name)) try: databrowse_class = self.registry[model] except KeyError: raise http.Http404("This model exists but has not been registered with databrowse.") return databrowse_class(model, self).root(request, rest_of_url) site = DatabrowseSite() from django.contrib.databrowse.plugins.calendars import CalendarPlugin from django.contrib.databrowse.plugins.objects import ObjectDetailPlugin from django.contrib.databrowse.plugins.fieldchoices import FieldChoicePlugin class DefaultModelDatabrowse(ModelDatabrowse): plugins = {'objects': ObjectDetailPlugin(), 'calendars': CalendarPlugin(), 'fields': FieldChoicePlugin()}
ajibawa-2023/Python-Code-Large/train/row_98804
77
149
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_98804:ImportFrom_L1_C0", "label": "from django import http", "type": "import", "loc": [1, 1], "level": 0, "parent": null, "vector": [1, 0, 0.0067, 0.0067, 0, 0.66, 0.0, 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_98804:ImportFrom_L2_C0", "label": "from django.db import models", "type": "import", "loc": [2, 2], "level": 0, "parent": null, "vector": [1, 0, 0.0134, 0.0067, 0, 0.66, 0.0714, 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_98804:ImportFrom_L3_C0", "label": "from django.contrib.databrowse.datastructures import EasyModel", "type": "import", "loc": [3, 3], "level": 0, "parent": null, "vector": [1, 0, 0.0201, 0.0067, 0, 0.66, 0.1429, 235, 0, 1, 0, 0, 235, 0, 0], "semantic": {"name": "django.contrib.databrowse.datastructures", "arg_names": [], "import_names": ["EasyModel"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.contrib.databrowse.datastructures import EasyModel"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98804:ImportFrom_L4_C0", "label": "from django.shortcuts import render_to_response", "type": "import", "loc": [4, 4], "level": 0, "parent": null, "vector": [1, 0, 0.0268, 0.0067, 0, 0.66, 0.2143, 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_98804:ImportFrom_L5_C0", "label": "from django.utils.safestring import mark_safe", "type": "import", "loc": [5, 5], "level": 0, "parent": null, "vector": [1, 0, 0.0336, 0.0067, 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_98804:ClassDef_L7_C0", "label": "AlreadyRegistered", "type": "class", "loc": [7, 8], "level": 0, "parent": null, "vector": [3, 0, 0.0503, 0.0134, 0, 0.66, 0.3571, 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_98804:ClassDef_L10_C0", "label": "NotRegistered", "type": "class", "loc": [10, 11], "level": 0, "parent": null, "vector": [3, 0, 0.0705, 0.0134, 0, 0.66, 0.4286, 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_98804:ClassDef_L13_C0", "label": "DatabrowsePlugin", "type": "class", "loc": [13, 34], "level": 0, "parent": null, "vector": [3, 0, 0.1577, 0.1477, 0, 0.66, 0.5, 298, 0, 3, 0, 0, 186, 0, 0], "semantic": {"name": "DatabrowsePlugin", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class DatabrowsePlugin(object):\n def urls(self, plugin_name, easy_instance_field):\n \"\"\"\n Given an EasyInstanceField object, returns a list of URLs for this\n plugin's views of this object. These URLs should be absolute.\n\n Returns None if the EasyInstanceField object doesn't get a\n list of plugin-specific URLs."}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98804:FunctionDef_L14_C4", "label": "urls", "type": "function", "loc": [14, 22], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98804:ClassDef_L13_C0", "vector": [2, 1, 0.1208, 0.0604, 1, 0.76, 0.0, 260, 0, 3, 1, 0, 0, 0, 0], "semantic": {"name": "urls", "arg_names": ["self", "plugin_name", "easy_instance_field"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def urls(self, plugin_name, easy_instance_field):\n \"\"\"\n Given an EasyInstanceField object, returns a list of URLs for this\n plugin's views of this object. These URLs should be absolute.\n\n Returns None if the EasyInstanceField object doesn't get a\n list of plugin-specific URLs.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98804:Expr_L15_C8", "label": "expression", "type": "expression", "loc": [15, 21], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98804:FunctionDef_L14_C4", "vector": [8, 2, 0.1208, 0.047, 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 Given an EasyInstanceField object, returns a list of URLs for this\n plugin's views of this object. These URLs should be absolute.\n\n Returns None if the EasyInstanceField object doesn't get a\n list of plugin-specific URLs.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98804:Return_L22_C8", "label": "return", "type": "return", "loc": [22, 22], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98804:FunctionDef_L14_C4", "vector": [13, 2, 0.1477, 0.0067, 2, 0.04, 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_98804:FunctionDef_L24_C4", "label": "model_index_html", "type": "function", "loc": [24, 28], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98804:ClassDef_L13_C0", "vector": [2, 1, 0.1745, 0.0336, 1, 0.76, 0.5, 182, 0, 4, 1, 0, 0, 0, 0], "semantic": {"name": "model_index_html", "arg_names": ["self", "request", "model", "site"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def model_index_html(self, request, model, site):\n \"\"\"\n Returns a snippet of HTML to include on the model index page.\n \"\"\"\n return ''"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98804:Expr_L25_C8", "label": "expression", "type": "expression", "loc": [25, 27], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98804:FunctionDef_L24_C4", "vector": [8, 2, 0.1745, 0.0201, 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 a snippet of HTML to include on the model index page.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98804:Return_L28_C8", "label": "return", "type": "return", "loc": [28, 28], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98804:FunctionDef_L24_C4", "vector": [13, 2, 0.1879, 0.0067, 2, 0.4, 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_98804:FunctionDef_L30_C4", "label": "model_view", "type": "function", "loc": [30, 34], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98804:ClassDef_L13_C0", "vector": [2, 1, 0.2148, 0.0336, 1, 0.76, 1.0, 372, 0, 4, 0, 0, 0, 0, 0], "semantic": {"name": "model_view", "arg_names": ["self", "request", "model_databrowse", "url"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def model_view(self, request, model_databrowse, url):\n \"\"\"\n Handles main URL routing for a plugin's model-specific pages.\n \"\"\"\n raise NotImplementedError"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98804:Expr_L31_C8", "label": "expression", "type": "expression", "loc": [31, 33], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98804:FunctionDef_L30_C4", "vector": [8, 2, 0.2148, 0.0201, 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 Handles main URL routing for a plugin's model-specific pages.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98804:ClassDef_L36_C0", "label": "ModelDatabrowse", "type": "class", "loc": [36, 69], "level": 0, "parent": null, "vector": [3, 0, 0.3523, 0.2282, 0, 0.66, 0.5714, 353, 0, 3, 0, 0, 186, 0, 10], "semantic": {"name": "ModelDatabrowse", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class ModelDatabrowse(object):\n plugins = {}\n\n def __init__(self, model, site):\n self.model = model\n self.site = site\n\n def root(self, request, url):"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98804:Assign_L37_C4", "label": "plugins =", "type": "assigned_variable", "loc": [37, 37], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98804:ClassDef_L36_C0", "vector": [14, 1, 0.2483, 0.0067, 1, 0.83, 0.0, 913, 0, 0, 0, 0, 0, 6, 0], "semantic": {"name": "plugins", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " plugins = {}"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98804:FunctionDef_L39_C4", "label": "__init__", "type": "function", "loc": [39, 41], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98804:ClassDef_L36_C0", "vector": [2, 1, 0.2685, 0.0201, 1, 0.83, 0.3333, 555, 0, 3, 0, 0, 0, 0, 0], "semantic": {"name": "__init__", "arg_names": ["self", "model", "site"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def __init__(self, model, site):\n self.model = model\n self.site = site"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98804:Assign_L40_C8", "label": "self.model =", "type": "assigned_variable", "loc": [40, 40], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98804:FunctionDef_L39_C4", "vector": [14, 2, 0.2685, 0.0067, 2, 0.73, 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_98804:Assign_L41_C8", "label": "self.site =", "type": "assigned_variable", "loc": [41, 41], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98804:FunctionDef_L39_C4", "vector": [14, 2, 0.2752, 0.0067, 2, 0.73, 1.0, 728, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "self.site", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.site = site"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98804:FunctionDef_L43_C4", "label": "root", "type": "function", "loc": [43, 60], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98804:ClassDef_L36_C0", "vector": [2, 1, 0.3456, 0.1208, 1, 0.83, 0.6667, 696, 0, 3, 1, 0, 0, 0, 4], "semantic": {"name": "root", "arg_names": ["self", "request", "url"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def root(self, request, url):\n \"\"\"\n Handles main URL routing for the databrowse app.\n\n `url` is the remainder of the URL -- e.g. 'objects/3'.\n \"\"\"\n # Delegate to the appropriate method, based on the URL.\n if url is None:"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98804:Expr_L44_C8", "label": "expression", "type": "expression", "loc": [44, 48], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98804:FunctionDef_L43_C4", "vector": [8, 2, 0.3087, 0.0336, 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 Handles main URL routing for the databrowse app.\n\n `url` is the remainder of the URL -- e.g. 'objects/3'.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98804:If_L50_C8", "label": "if", "type": "if", "loc": [50, 51], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98804:FunctionDef_L43_C4", "vector": [4, 2, 0.3389, 0.0134, 2, 0.28, 0.25, 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.main_view(request)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98804:Return_L51_C12", "label": "return", "type": "return", "loc": [51, 51], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98804:If_L50_C8", "vector": [13, 3, 0.3423, 0.0067, 3, 0.96, 0.0, 0, 3, 0, 0, 0, 0, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return self.main_view(request)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98804:Try_L52_C8", "label": "try", "type": "try", "loc": [52, 55], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98804:FunctionDef_L43_C4", "vector": [7, 2, 0.3591, 0.0268, 2, 0.28, 0.5, 0, 0, 1, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " try:\n plugin_name, rest_of_url = url.split('/', 1)\n except ValueError: # need more than 1 value to unpack\n plugin_name, rest_of_url = url, None"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98804:Assign_L53_C12", "label": "plugin_name, rest_of_url = split()", "type": "assigned_variable", "loc": [53, 53], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98804:Try_L52_C8", "vector": [14, 3, 0.3557, 0.0067, 3, 0.44, 0.0, 534, 3, 2, 0, 0, 908, 10, 1], "semantic": {"name": "plugin_name, rest_of_url", "arg_names": [], "import_names": [], "rhs_call_name": "split", "annotation": ""}, "snippet": " plugin_name, rest_of_url = url.split('/', 1)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98804:Assign_L55_C12", "label": "plugin_name, rest_of_url =", "type": "assigned_variable", "loc": [55, 55], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98804:Try_L52_C8", "vector": [14, 3, 0.3691, 0.0067, 3, 0.44, 0.0, 534, 0, 0, 0, 0, 0, 8, 0], "semantic": {"name": "plugin_name, rest_of_url", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " plugin_name, rest_of_url = url, None"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98804:Try_L56_C8", "label": "try", "type": "try", "loc": [56, 59], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98804:FunctionDef_L43_C4", "vector": [7, 2, 0.3859, 0.0268, 2, 0.28, 0.75, 0, 0, 1, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " try:\n plugin = self.plugins[plugin_name]\n except KeyError:\n raise http.Http404('A plugin with the requested name does not exist.')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98804:Assign_L57_C12", "label": "plugin =", "type": "assigned_variable", "loc": [57, 57], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98804:Try_L56_C8", "vector": [14, 3, 0.3826, 0.0067, 3, 0.36, 0.0, 437, 6, 0, 0, 0, 0, 0, 0], "semantic": {"name": "plugin", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " plugin = self.plugins[plugin_name]"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98804:Return_L60_C8", "label": "return", "type": "return", "loc": [60, 60], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98804:FunctionDef_L43_C4", "vector": [13, 2, 0.4027, 0.0067, 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 plugin.model_view(request, self, rest_of_url)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98804:FunctionDef_L62_C4", "label": "main_view", "type": "function", "loc": [62, 69], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98804:ClassDef_L36_C0", "vector": [2, 1, 0.4396, 0.0537, 1, 0.83, 1.0, 617, 0, 2, 1, 0, 0, 0, 6], "semantic": {"name": "main_view", "arg_names": ["self", "request"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def main_view(self, request):\n easy_model = EasyModel(self.site, self.model)\n html_snippets = mark_safe(u'\\n'.join([p.model_index_html(request, self.model, self.site) for p in self.plugins.values()]))\n return render_to_response('databrowse/model_detail.html', {\n 'model': easy_model,\n 'root_url': self.site.root_url,\n 'plugin_html': html_snippets,\n })"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98804:Assign_L63_C8", "label": "easy_model = EasyModel()", "type": "assigned_variable", "loc": [63, 63], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98804:FunctionDef_L62_C4", "vector": [14, 2, 0.4228, 0.0067, 2, 0.06, 0.0, 363, 3, 2, 0, 0, 749, 10, 1], "semantic": {"name": "easy_model", "arg_names": [], "import_names": [], "rhs_call_name": "EasyModel", "annotation": ""}, "snippet": " easy_model = EasyModel(self.site, self.model)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98804:Assign_L64_C8", "label": "html_snippets = mark_safe()", "type": "assigned_variable", "loc": [64, 64], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98804:FunctionDef_L62_C4", "vector": [14, 2, 0.4295, 0.0067, 2, 0.06, 0.5, 634, 3, 1, 0, 0, 159, 10, 4], "semantic": {"name": "html_snippets", "arg_names": [], "import_names": [], "rhs_call_name": "mark_safe", "annotation": ""}, "snippet": " html_snippets = mark_safe(u'\\n'.join([p.model_index_html(request, self.model, self.site) for p in self.plugins.values()]))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98804:Return_L65_C8", "label": "return", "type": "return", "loc": [65, 69], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98804:FunctionDef_L62_C4", "vector": [13, 2, 0.4497, 0.0336, 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 render_to_response('databrowse/model_detail.html', {\n 'model': easy_model,\n 'root_url': self.site.root_url,\n 'plugin_html': html_snippets,\n })"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98804:ClassDef_L71_C0", "label": "DatabrowseSite", "type": "class", "loc": [71, 140], "level": 0, "parent": null, "vector": [3, 0, 0.7081, 0.4698, 0, 0.66, 0.6429, 976, 0, 6, 0, 0, 186, 0, 19], "semantic": {"name": "DatabrowseSite", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class DatabrowseSite(object):\n def __init__(self):\n self.registry = {} # model_class -> databrowse_class\n self.root_url = None\n\n def register(self, model_or_iterable, databrowse_class=None, **options):\n \"\"\"\n Registers the given model(s) with the given databrowse site."}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98804:FunctionDef_L72_C4", "label": "__init__", "type": "function", "loc": [72, 74], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98804:ClassDef_L71_C0", "vector": [2, 1, 0.4899, 0.0201, 1, 0.77, 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.registry = {} # model_class -> databrowse_class\n self.root_url = None"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98804:Assign_L73_C8", "label": "self.registry =", "type": "assigned_variable", "loc": [73, 73], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98804:FunctionDef_L72_C4", "vector": [14, 2, 0.4899, 0.0067, 2, 0.7, 0.0, 648, 0, 0, 0, 0, 0, 6, 0], "semantic": {"name": "self.registry", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.registry = {} # model_class -> databrowse_class"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98804:Assign_L74_C8", "label": "self.root_url =", "type": "assigned_variable", "loc": [74, 74], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98804:FunctionDef_L72_C4", "vector": [14, 2, 0.4966, 0.0067, 2, 0.7, 1.0, 407, 1, 0, 0, 0, 0, 9, 0], "semantic": {"name": "self.root_url", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.root_url = None"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98804:FunctionDef_L76_C4", "label": "register", "type": "function", "loc": [76, 93], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98804:ClassDef_L71_C0", "vector": [2, 1, 0.5671, 0.1208, 1, 0.77, 0.2, 276, 0, 4, 0, 0, 0, 0, 2], "semantic": {"name": "register", "arg_names": ["self", "model_or_iterable", "databrowse_class", "options"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def register(self, model_or_iterable, databrowse_class=None, **options):\n \"\"\"\n Registers the given model(s) with the given databrowse site.\n\n The model(s) should be Model classes, not instances.\n\n If a databrowse class isn't given, it will use DefaultModelDatabrowse\n (the default databrowse options)."}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98804:Expr_L77_C8", "label": "expression", "type": "expression", "loc": [77, 86], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98804:FunctionDef_L76_C4", "vector": [8, 2, 0.547, 0.0671, 2, 0.52, 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 databrowse site.\n\n The model(s) should be Model classes, not instances.\n\n If a databrowse class isn't given, it will use DefaultModelDatabrowse\n (the default databrowse options).\n"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98804:Assign_L87_C8", "label": "databrowse_class =", "type": "assigned_variable", "loc": [87, 87], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98804:FunctionDef_L76_C4", "vector": [14, 2, 0.5839, 0.0067, 2, 0.52, 0.3333, 352, 0, 0, 0, 0, 0, 0, 0], "semantic": {"name": "databrowse_class", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " databrowse_class = databrowse_class or DefaultModelDatabrowse"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98804:If_L88_C8", "label": "if", "type": "if", "loc": [88, 89], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98804:FunctionDef_L76_C4", "vector": [4, 2, 0.594, 0.0134, 2, 0.52, 0.6667, 0, 3, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if issubclass(model_or_iterable, models.Model):\n model_or_iterable = [model_or_iterable]"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98804:Assign_L89_C12", "label": "model_or_iterable =", "type": "assigned_variable", "loc": [89, 89], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98804:If_L88_C8", "vector": [14, 3, 0.5973, 0.0067, 3, 0.07, 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_98804:For_L90_C8", "label": "for model", "type": "for", "loc": [90, 93], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98804:FunctionDef_L76_C4", "vector": [6, 2, 0.6141, 0.0268, 2, 0.52, 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 in self.registry:\n raise AlreadyRegistered('The model %s is already registered' % model.__name__)\n self.registry[model] = databrowse_class"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98804:If_L91_C12", "label": "if", "type": "if", "loc": [91, 92], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98804:For_L90_C8", "vector": [4, 3, 0.6141, 0.0134, 3, 0.7, 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_98804:Assign_L93_C12", "label": "assign", "type": "assigned_variable", "loc": [93, 93], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98804:For_L90_C8", "vector": [14, 3, 0.6242, 0.0067, 3, 0.7, 1.0, 0, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.registry[model] = databrowse_class"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98804:FunctionDef_L95_C4", "label": "unregister", "type": "function", "loc": [95, 106], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98804:ClassDef_L71_C0", "vector": [2, 1, 0.6745, 0.0805, 1, 0.77, 0.4, 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 issubclass(model_or_iterable, models.Model):\n model_or_iterable = [model_or_iterable]"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98804:Expr_L96_C8", "label": "expression", "type": "expression", "loc": [96, 100], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98804:FunctionDef_L95_C4", "vector": [8, 2, 0.6577, 0.0336, 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 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_98804:If_L101_C8", "label": "if", "type": "if", "loc": [101, 102], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98804:FunctionDef_L95_C4", "vector": [4, 2, 0.6812, 0.0134, 2, 0.67, 0.5, 0, 3, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if issubclass(model_or_iterable, models.Model):\n model_or_iterable = [model_or_iterable]"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98804:Assign_L102_C12", "label": "model_or_iterable =", "type": "assigned_variable", "loc": [102, 102], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98804:If_L101_C8", "vector": [14, 3, 0.6846, 0.0067, 3, 0.4, 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_98804:For_L103_C8", "label": "for model", "type": "for", "loc": [103, 106], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98804:FunctionDef_L95_C4", "vector": [6, 2, 0.7013, 0.0268, 2, 0.67, 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_98804:If_L104_C12", "label": "if", "type": "if", "loc": [104, 105], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98804:For_L103_C8", "vector": [4, 3, 0.7013, 0.0134, 3, 0.66, 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_98804:FunctionDef_L108_C4", "label": "root", "type": "function", "loc": [108, 122], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98804:ClassDef_L71_C0", "vector": [2, 1, 0.7718, 0.1007, 1, 0.77, 0.6, 696, 0, 3, 1, 0, 0, 0, 7], "semantic": {"name": "root", "arg_names": ["self", "request", "url"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def root(self, request, url):\n \"\"\"\n Handles main URL routing for the databrowse app.\n\n `url` is the remainder of the URL -- e.g. 'comments/comment/'.\n \"\"\"\n self.root_url = request.path[:len(request.path) - len(url)]\n url = url.rstrip('/') # Trim trailing slash, if it exists."}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98804:Expr_L109_C8", "label": "expression", "type": "expression", "loc": [109, 113], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98804:FunctionDef_L108_C4", "vector": [8, 2, 0.745, 0.0336, 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 Handles main URL routing for the databrowse app.\n\n `url` is the remainder of the URL -- e.g. 'comments/comment/'.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98804:Assign_L114_C8", "label": "self.root_url =", "type": "assigned_variable", "loc": [114, 114], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98804:FunctionDef_L108_C4", "vector": [14, 2, 0.7651, 0.0067, 2, 0.08, 0.3333, 407, 6, 0, 0, 0, 0, 0, 2], "semantic": {"name": "self.root_url", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.root_url = request.path[:len(request.path) - len(url)]"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98804:Assign_L115_C8", "label": "url = rstrip()", "type": "assigned_variable", "loc": [115, 115], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98804:FunctionDef_L108_C4", "vector": [14, 2, 0.7718, 0.0067, 2, 0.08, 0.6667, 789, 3, 1, 0, 0, 807, 10, 1], "semantic": {"name": "url", "arg_names": [], "import_names": [], "rhs_call_name": "rstrip", "annotation": ""}, "snippet": " url = url.rstrip('/') # Trim trailing slash, if it exists."}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98804:If_L117_C8", "label": "if", "type": "if", "loc": [117, 120], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98804:FunctionDef_L108_C4", "vector": [4, 2, 0.7953, 0.0268, 2, 0.08, 1.0, 0, 0, 0, 0, 0, 0, 0, 3], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if url == '':\n return self.index(request)\n elif '/' in url:\n return self.model_page(request, *url.split('/', 2))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98804:Return_L118_C12", "label": "return", "type": "return", "loc": [118, 118], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98804:If_L117_C8", "vector": [13, 3, 0.7919, 0.0067, 3, 0.06, 0.0, 0, 3, 0, 0, 0, 0, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return self.index(request)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98804:If_L119_C8", "label": "if", "type": "if", "loc": [119, 120], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98804:If_L117_C8", "vector": [4, 3, 0.802, 0.0134, 3, 0.06, 1.0, 0, 0, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " elif '/' in url:\n return self.model_page(request, *url.split('/', 2))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98804:Return_L120_C12", "label": "return", "type": "return", "loc": [120, 120], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98804:If_L119_C8", "vector": [13, 4, 0.8054, 0.0067, 4, 0.31, 0.0, 0, 3, 0, 0, 0, 0, 10, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return self.model_page(request, *url.split('/', 2))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98804:FunctionDef_L124_C4", "label": "index", "type": "function", "loc": [124, 126], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98804:ClassDef_L71_C0", "vector": [2, 1, 0.8389, 0.0201, 1, 0.77, 0.8, 780, 0, 2, 1, 0, 0, 0, 3], "semantic": {"name": "index", "arg_names": ["self", "request"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def index(self, request):\n m_list = [EasyModel(self, m) for m in self.registry.keys()]\n return render_to_response('databrowse/homepage.html', {'model_list': m_list, 'root_url': self.root_url})"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98804:Assign_L125_C8", "label": "m_list =", "type": "assigned_variable", "loc": [125, 125], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98804:FunctionDef_L124_C4", "vector": [14, 2, 0.8389, 0.0067, 2, 0.68, 0.0, 828, 5, 0, 0, 0, 0, 0, 2], "semantic": {"name": "m_list", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " m_list = [EasyModel(self, m) for m in self.registry.keys()]"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98804:Return_L126_C8", "label": "return", "type": "return", "loc": [126, 126], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98804:FunctionDef_L124_C4", "vector": [13, 2, 0.8456, 0.0067, 2, 0.68, 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('databrowse/homepage.html', {'model_list': m_list, 'root_url': self.root_url})"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98804:FunctionDef_L128_C4", "label": "model_page", "type": "function", "loc": [128, 140], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98804:ClassDef_L71_C0", "vector": [2, 1, 0.8993, 0.0872, 1, 0.77, 1.0, 62, 0, 5, 1, 0, 0, 0, 5], "semantic": {"name": "model_page", "arg_names": ["self", "request", "app_label", "model_name", "rest_of_url"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def model_page(self, request, app_label, model_name, rest_of_url=None):\n \"\"\"\n Handles the model-specific functionality of the databrowse site, delegating\n to the appropriate ModelDatabrowse class.\n \"\"\"\n model = models.get_model(app_label, model_name)\n if model is None:\n raise http.Http404(\"App %r, model %r, not found.\" % (app_label, model_name))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98804:Expr_L129_C8", "label": "expression", "type": "expression", "loc": [129, 132], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98804:FunctionDef_L128_C4", "vector": [8, 2, 0.8758, 0.0268, 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 Handles the model-specific functionality of the databrowse site, delegating\n to the appropriate ModelDatabrowse class.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98804:Assign_L133_C8", "label": "model = get_model()", "type": "assigned_variable", "loc": [133, 133], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98804:FunctionDef_L128_C4", "vector": [14, 2, 0.8926, 0.0067, 2, 0.19, 0.25, 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_98804:If_L134_C8", "label": "if", "type": "if", "loc": [134, 135], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98804:FunctionDef_L128_C4", "vector": [4, 2, 0.9027, 0.0134, 2, 0.19, 0.5, 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 http.Http404(\"App %r, model %r, not found.\" % (app_label, model_name))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98804:Try_L136_C8", "label": "try", "type": "try", "loc": [136, 139], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98804:FunctionDef_L128_C4", "vector": [7, 2, 0.9228, 0.0268, 2, 0.19, 0.75, 0, 0, 1, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " try:\n databrowse_class = self.registry[model]\n except KeyError:\n raise http.Http404(\"This model exists but has not been registered with databrowse.\")"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98804:Assign_L137_C12", "label": "databrowse_class =", "type": "assigned_variable", "loc": [137, 137], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98804:Try_L136_C8", "vector": [14, 3, 0.9195, 0.0067, 3, 0.85, 0.0, 352, 6, 0, 0, 0, 0, 0, 0], "semantic": {"name": "databrowse_class", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " databrowse_class = self.registry[model]"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98804:Return_L140_C8", "label": "return", "type": "return", "loc": [140, 140], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98804:FunctionDef_L128_C4", "vector": [13, 2, 0.9396, 0.0067, 2, 0.19, 1.0, 0, 3, 0, 0, 0, 0, 10, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return databrowse_class(model, self).root(request, rest_of_url)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98804:Assign_L142_C0", "label": "site = DatabrowseSite()", "type": "assigned_variable", "loc": [142, 142], "level": 0, "parent": null, "vector": [14, 0, 0.953, 0.0067, 0, 0.66, 0.7143, 681, 3, 0, 0, 0, 976, 10, 1], "semantic": {"name": "site", "arg_names": [], "import_names": [], "rhs_call_name": "DatabrowseSite", "annotation": ""}, "snippet": "site = DatabrowseSite()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98804:ImportFrom_L144_C0", "label": "from django.contrib.databrowse.plugins.calendars import CalendarPlugin", "type": "import", "loc": [144, 144], "level": 0, "parent": null, "vector": [1, 0, 0.9664, 0.0067, 0, 0.66, 0.7857, 923, 0, 1, 0, 0, 923, 0, 0], "semantic": {"name": "django.contrib.databrowse.plugins.calendars", "arg_names": [], "import_names": ["CalendarPlugin"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.contrib.databrowse.plugins.calendars import CalendarPlugin"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98804:ImportFrom_L145_C0", "label": "from django.contrib.databrowse.plugins.objects import ObjectDetailPlugin", "type": "import", "loc": [145, 145], "level": 0, "parent": null, "vector": [1, 0, 0.9732, 0.0067, 0, 0.66, 0.8571, 431, 0, 1, 0, 0, 431, 0, 0], "semantic": {"name": "django.contrib.databrowse.plugins.objects", "arg_names": [], "import_names": ["ObjectDetailPlugin"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.contrib.databrowse.plugins.objects import ObjectDetailPlugin"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98804:ImportFrom_L146_C0", "label": "from django.contrib.databrowse.plugins.fieldchoices import FieldChoicePlugin", "type": "import", "loc": [146, 146], "level": 0, "parent": null, "vector": [1, 0, 0.9799, 0.0067, 0, 0.66, 0.9286, 560, 0, 1, 0, 0, 560, 0, 0], "semantic": {"name": "django.contrib.databrowse.plugins.fieldchoices", "arg_names": [], "import_names": ["FieldChoicePlugin"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.contrib.databrowse.plugins.fieldchoices import FieldChoicePlugin"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98804:ClassDef_L148_C0", "label": "DefaultModelDatabrowse", "type": "class", "loc": [148, 149], "level": 0, "parent": null, "vector": [3, 0, 0.9966, 0.0134, 0, 0.66, 1.0, 836, 0, 0, 0, 0, 353, 0, 3], "semantic": {"name": "DefaultModelDatabrowse", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class DefaultModelDatabrowse(ModelDatabrowse):\n plugins = {'objects': ObjectDetailPlugin(), 'calendars': CalendarPlugin(), 'fields': FieldChoicePlugin()}"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98804:Assign_L149_C4", "label": "plugins =", "type": "assigned_variable", "loc": [149, 149], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98804:ClassDef_L148_C0", "vector": [14, 1, 1.0, 0.0067, 1, 0.36, 0.0, 913, 0, 0, 0, 0, 0, 6, 3], "semantic": {"name": "plugins", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " plugins = {'objects': ObjectDetailPlugin(), 'calendars': CalendarPlugin(), 'fields': FieldChoicePlugin()}"}]
[{"f": "ajibawa-2023/Python-Code-Large/train/row_98804:ClassDef_L13_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98804:FunctionDef_L14_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98804:FunctionDef_L14_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98804:Expr_L15_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98804:FunctionDef_L14_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98804:Return_L22_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98804:ClassDef_L13_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98804:FunctionDef_L24_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98804:FunctionDef_L24_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98804:Expr_L25_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98804:FunctionDef_L24_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98804:Return_L28_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98804:ClassDef_L13_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98804:FunctionDef_L30_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98804:FunctionDef_L30_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98804:Expr_L31_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98804:ClassDef_L36_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98804:Assign_L37_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98804:ClassDef_L36_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98804:FunctionDef_L39_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98804:FunctionDef_L39_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98804:Assign_L40_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98804:FunctionDef_L39_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98804:Assign_L41_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98804:ClassDef_L36_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98804:FunctionDef_L43_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98804:FunctionDef_L43_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98804:Expr_L44_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98804:FunctionDef_L43_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98804:If_L50_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98804:If_L50_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98804:Return_L51_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98804:FunctionDef_L43_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98804:Try_L52_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98804:Try_L52_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98804:Assign_L53_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98804:Try_L52_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98804:Assign_L55_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98804:FunctionDef_L43_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98804:Try_L56_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98804:Try_L56_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98804:Assign_L57_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98804:FunctionDef_L43_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98804:Return_L60_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98804:ClassDef_L36_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98804:FunctionDef_L62_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98804:FunctionDef_L62_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98804:Assign_L63_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98804:FunctionDef_L62_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98804:Assign_L64_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98804:FunctionDef_L62_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98804:Return_L65_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98804:ClassDef_L71_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98804:FunctionDef_L72_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98804:FunctionDef_L72_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98804:Assign_L73_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98804:FunctionDef_L72_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98804:Assign_L74_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98804:ClassDef_L71_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98804:FunctionDef_L76_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98804:FunctionDef_L76_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98804:Expr_L77_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98804:FunctionDef_L76_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98804:Assign_L87_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98804:FunctionDef_L76_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98804:If_L88_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98804:If_L88_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98804:Assign_L89_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98804:FunctionDef_L76_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98804:For_L90_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98804:For_L90_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98804:If_L91_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98804:For_L90_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98804:Assign_L93_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98804:ClassDef_L71_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98804:FunctionDef_L95_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98804:FunctionDef_L95_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98804:Expr_L96_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98804:FunctionDef_L95_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98804:If_L101_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98804:If_L101_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98804:Assign_L102_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98804:FunctionDef_L95_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98804:For_L103_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98804:For_L103_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98804:If_L104_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98804:ClassDef_L71_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98804:FunctionDef_L108_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98804:FunctionDef_L108_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98804:Expr_L109_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98804:FunctionDef_L108_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98804:Assign_L114_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98804:FunctionDef_L108_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98804:Assign_L115_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98804:FunctionDef_L108_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98804:If_L117_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98804:If_L117_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98804:Return_L118_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98804:If_L117_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98804:If_L119_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98804:If_L119_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98804:Return_L120_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98804:ClassDef_L71_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98804:FunctionDef_L124_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98804:FunctionDef_L124_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98804:Assign_L125_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98804:FunctionDef_L124_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98804:Return_L126_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98804:ClassDef_L71_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98804:FunctionDef_L128_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98804:FunctionDef_L128_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98804:Expr_L129_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98804:FunctionDef_L128_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98804:Assign_L133_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98804:FunctionDef_L128_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98804:If_L134_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98804:FunctionDef_L128_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98804:Try_L136_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98804:Try_L136_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98804:Assign_L137_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98804:FunctionDef_L128_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98804:Return_L140_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98804:ClassDef_L148_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98804:Assign_L149_C4"}]
from django.http import Http404 from django.shortcuts import render_to_response ########### # CHOICES # ########### def choice_list(request, app_label, module_name, field_name, models): m, f = lookup_field(app_label, module_name, field_name, models) return render_to_response('databrowse/choice_list.html', {'model': m, 'field': f}) def choice_detail(request, app_label, module_name, field_name, field_val, models): m, f = lookup_field(app_label, module_name, field_name, models) try: label = dict(f.field.choices)[field_val] except KeyError: raise Http404('Invalid choice value given') obj_list = m.objects(**{f.field.name: field_val}) return render_to_response('databrowse/choice_detail.html', {'model': m, 'field': f, 'value': label, 'object_list': obj_list})
ajibawa-2023/Python-Code-Large/train/row_98805
11
19
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_98805:ImportFrom_L1_C0", "label": "from django.http import Http404", "type": "import", "loc": [1, 1], "level": 0, "parent": null, "vector": [1, 0, 0.0526, 0.0526, 0, 0.66, 0.0, 779, 0, 1, 0, 0, 779, 0, 0], "semantic": {"name": "django.http", "arg_names": [], "import_names": ["Http404"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.http import Http404"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98805:ImportFrom_L2_C0", "label": "from django.shortcuts import render_to_response", "type": "import", "loc": [2, 2], "level": 0, "parent": null, "vector": [1, 0, 0.1053, 0.0526, 0, 0.66, 0.3333, 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_98805:FunctionDef_L8_C0", "label": "choice_list", "type": "function", "loc": [8, 10], "level": 0, "parent": null, "vector": [2, 0, 0.4737, 0.1579, 0, 0.66, 0.6667, 576, 0, 5, 1, 0, 0, 0, 2], "semantic": {"name": "choice_list", "arg_names": ["request", "app_label", "module_name", "field_name", "models"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "def choice_list(request, app_label, module_name, field_name, models):\n m, f = lookup_field(app_label, module_name, field_name, models)\n return render_to_response('databrowse/choice_list.html', {'model': m, 'field': f})"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98805:Assign_L9_C4", "label": "m, f = lookup_field()", "type": "assigned_variable", "loc": [9, 9], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98805:FunctionDef_L8_C0", "vector": [14, 1, 0.4737, 0.0526, 1, 0.61, 0.0, 524, 3, 4, 0, 0, 514, 10, 1], "semantic": {"name": "m, f", "arg_names": [], "import_names": [], "rhs_call_name": "lookup_field", "annotation": ""}, "snippet": " m, f = lookup_field(app_label, module_name, field_name, models)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98805:Return_L10_C4", "label": "return", "type": "return", "loc": [10, 10], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98805:FunctionDef_L8_C0", "vector": [13, 1, 0.5263, 0.0526, 1, 0.61, 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('databrowse/choice_list.html', {'model': m, 'field': f})"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98805:FunctionDef_L12_C0", "label": "choice_detail", "type": "function", "loc": [12, 19], "level": 0, "parent": null, "vector": [2, 0, 0.8158, 0.4211, 0, 0.66, 1.0, 560, 0, 6, 1, 0, 0, 0, 5], "semantic": {"name": "choice_detail", "arg_names": ["request", "app_label", "module_name", "field_name", "field_val", "models"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "def choice_detail(request, app_label, module_name, field_name, field_val, models):\n m, f = lookup_field(app_label, module_name, field_name, models)\n try:\n label = dict(f.field.choices)[field_val]\n except KeyError:\n raise Http404('Invalid choice value given')\n obj_list = m.objects(**{f.field.name: field_val})\n return render_to_response('databrowse/choice_detail.html', {'model': m, 'field': f, 'value': label, 'object_list': obj_list})"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98805:Assign_L13_C4", "label": "m, f = lookup_field()", "type": "assigned_variable", "loc": [13, 13], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98805:FunctionDef_L12_C0", "vector": [14, 1, 0.6842, 0.0526, 1, 0.81, 0.0, 524, 3, 4, 0, 0, 514, 10, 1], "semantic": {"name": "m, f", "arg_names": [], "import_names": [], "rhs_call_name": "lookup_field", "annotation": ""}, "snippet": " m, f = lookup_field(app_label, module_name, field_name, models)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98805:Try_L14_C4", "label": "try", "type": "try", "loc": [14, 17], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98805:FunctionDef_L12_C0", "vector": [7, 1, 0.8158, 0.2105, 1, 0.81, 0.3333, 0, 0, 1, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " try:\n label = dict(f.field.choices)[field_val]\n except KeyError:\n raise Http404('Invalid choice value given')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98805:Assign_L15_C8", "label": "label =", "type": "assigned_variable", "loc": [15, 15], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98805:Try_L14_C4", "vector": [14, 2, 0.7895, 0.0526, 2, 0.23, 0.0, 811, 6, 0, 0, 0, 0, 0, 1], "semantic": {"name": "label", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " label = dict(f.field.choices)[field_val]"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98805:Assign_L18_C4", "label": "obj_list = objects()", "type": "assigned_variable", "loc": [18, 18], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98805:FunctionDef_L12_C0", "vector": [14, 1, 0.9474, 0.0526, 1, 0.81, 0.6667, 342, 3, 1, 0, 0, 550, 10, 1], "semantic": {"name": "obj_list", "arg_names": [], "import_names": [], "rhs_call_name": "objects", "annotation": ""}, "snippet": " obj_list = m.objects(**{f.field.name: field_val})"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98805:Return_L19_C4", "label": "return", "type": "return", "loc": [19, 19], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98805:FunctionDef_L12_C0", "vector": [13, 1, 1.0, 0.0526, 1, 0.81, 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('databrowse/choice_detail.html', {'model': m, 'field': f, 'value': label, 'object_list': obj_list})"}]
[{"f": "ajibawa-2023/Python-Code-Large/train/row_98805:FunctionDef_L8_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98805:Assign_L9_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98805:FunctionDef_L8_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98805:Return_L10_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98805:FunctionDef_L12_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98805:Assign_L13_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98805:FunctionDef_L12_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98805:Try_L14_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98805:Try_L14_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98805:Assign_L15_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98805:FunctionDef_L12_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98805:Assign_L18_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98805:FunctionDef_L12_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98805:Return_L19_C4"}]
from django.contrib.databrowse.sites import DatabrowsePlugin, ModelDatabrowse, DatabrowseSite, site
ajibawa-2023/Python-Code-Large/train/row_98806
1
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"]
[{"id": "ajibawa-2023/Python-Code-Large/train/row_98806:ImportFrom_L1_C0", "label": "from django.contrib.databrowse.sites import DatabrowsePlugin, ModelDatabrowse, DatabrowseSite\u2026", "type": "import", "loc": [1, 1], "level": 0, "parent": null, "vector": [1, 0, 1.0, 1.0, 0, 0.66, 0.0, 231, 0, 4, 0, 0, 231, 0, 0], "semantic": {"name": "django.contrib.databrowse.sites", "arg_names": [], "import_names": ["DatabrowsePlugin", "ModelDatabrowse", "DatabrowseSite", "site"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.contrib.databrowse.sites import DatabrowsePlugin, ModelDatabrowse, DatabrowseSite, site"}]
[]
""" These classes are light wrappers around Django's database API that provide convenience functionality and permalink functions for the databrowse app. """ from django.db import models from django.utils import formats from django.utils.text import capfirst from django.utils.encoding import smart_unicode, smart_str, iri_to_uri from django.utils.safestring import mark_safe from django.db.models.query import QuerySet EMPTY_VALUE = '(None)' DISPLAY_SIZE = 100 class EasyModel(object): def __init__(self, site, model): self.site = site self.model = model self.model_list = site.registry.keys() self.verbose_name = model._meta.verbose_name self.verbose_name_plural = model._meta.verbose_name_plural def __repr__(self): return '<EasyModel for %s>' % smart_str(self.model._meta.object_name) def model_databrowse(self): "Returns the ModelDatabrowse class for this model." return self.site.registry[self.model] def url(self): return mark_safe('%s%s/%s/' % (self.site.root_url, self.model._meta.app_label, self.model._meta.module_name)) def objects(self, **kwargs): return self.get_query_set().filter(**kwargs) def get_query_set(self): easy_qs = self.model._default_manager.get_query_set()._clone(klass=EasyQuerySet) easy_qs._easymodel = self return easy_qs def object_by_pk(self, pk): return EasyInstance(self, self.model._default_manager.get(pk=pk)) def sample_objects(self): for obj in self.model._default_manager.all()[:3]: yield EasyInstance(self, obj) def field(self, name): try: f = self.model._meta.get_field(name) except models.FieldDoesNotExist: return None return EasyField(self, f) def fields(self): return [EasyField(self, f) for f in (self.model._meta.fields + self.model._meta.many_to_many)] class EasyField(object): def __init__(self, easy_model, field): self.model, self.field = easy_model, field def __repr__(self): return smart_str(u'<EasyField for %s.%s>' % (self.model.model._meta.object_name, self.field.name)) def choices(self): for value, label in self.field.choices: yield EasyChoice(self.model, self, value, label) def url(self): if self.field.choices: return mark_safe('%s%s/%s/%s/' % (self.model.site.root_url, self.model.model._meta.app_label, self.model.model._meta.module_name, self.field.name)) elif self.field.rel: return mark_safe('%s%s/%s/' % (self.model.site.root_url, self.model.model._meta.app_label, self.model.model._meta.module_name)) class EasyChoice(object): def __init__(self, easy_model, field, value, label): self.model, self.field = easy_model, field self.value, self.label = value, label def __repr__(self): return smart_str(u'<EasyChoice for %s.%s>' % (self.model.model._meta.object_name, self.field.name)) def url(self): return mark_safe('%s%s/%s/%s/%s/' % (self.model.site.root_url, self.model.model._meta.app_label, self.model.model._meta.module_name, self.field.field.name, iri_to_uri(self.value))) class EasyInstance(object): def __init__(self, easy_model, instance): self.model, self.instance = easy_model, instance def __repr__(self): return smart_str(u'<EasyInstance for %s (%s)>' % (self.model.model._meta.object_name, self.instance._get_pk_val())) def __unicode__(self): val = smart_unicode(self.instance) if len(val) > DISPLAY_SIZE: return val[:DISPLAY_SIZE] + u'...' return val def __str__(self): return self.__unicode__().encode('utf-8') def pk(self): return self.instance._get_pk_val() def url(self): return mark_safe('%s%s/%s/objects/%s/' % (self.model.site.root_url, self.model.model._meta.app_label, self.model.model._meta.module_name, iri_to_uri(self.pk()))) def fields(self): """ Generator that yields EasyInstanceFields for each field in this EasyInstance's model. """ for f in self.model.model._meta.fields + self.model.model._meta.many_to_many: yield EasyInstanceField(self.model, self, f) def related_objects(self): """ Generator that yields dictionaries of all models that have this EasyInstance's model as a ForeignKey or ManyToManyField, along with lists of related objects. """ for rel_object in self.model.model._meta.get_all_related_objects() + self.model.model._meta.get_all_related_many_to_many_objects(): if rel_object.model not in self.model.model_list: continue # Skip models that aren't in the model_list em = EasyModel(self.model.site, rel_object.model) yield { 'model': em, 'related_field': rel_object.field.verbose_name, 'object_list': [EasyInstance(em, i) for i in getattr(self.instance, rel_object.get_accessor_name()).all()], } class EasyInstanceField(object): def __init__(self, easy_model, instance, field): self.model, self.field, self.instance = easy_model, field, instance self.raw_value = getattr(instance.instance, field.name) def __repr__(self): return smart_str(u'<EasyInstanceField for %s.%s>' % (self.model.model._meta.object_name, self.field.name)) def values(self): """ Returns a list of values for this field for this instance. It's a list so we can accomodate many-to-many fields. """ # This import is deliberately inside the function because it causes # some settings to be imported, and we don't want to do that at the # module level. if self.field.rel: if isinstance(self.field.rel, models.ManyToOneRel): objs = getattr(self.instance.instance, self.field.name) elif isinstance(self.field.rel, models.ManyToManyRel): # ManyToManyRel return list(getattr(self.instance.instance, self.field.name).all()) elif self.field.choices: objs = dict(self.field.choices).get(self.raw_value, EMPTY_VALUE) elif isinstance(self.field, models.DateField) or isinstance(self.field, models.TimeField): if self.raw_value: if isinstance(self.field, models.DateTimeField): objs = capfirst(formats.date_format(self.raw_value, 'DATETIME_FORMAT')) elif isinstance(self.field, models.TimeField): objs = capfirst(formats.time_format(self.raw_value, 'TIME_FORMAT')) else: objs = capfirst(formats.date_format(self.raw_value, 'DATE_FORMAT')) else: objs = EMPTY_VALUE elif isinstance(self.field, models.BooleanField) or isinstance(self.field, models.NullBooleanField): objs = {True: 'Yes', False: 'No', None: 'Unknown'}[self.raw_value] else: objs = self.raw_value return [objs] def urls(self): "Returns a list of (value, URL) tuples." # First, check the urls() method for each plugin. plugin_urls = [] for plugin_name, plugin in self.model.model_databrowse().plugins.items(): urls = plugin.urls(plugin_name, self) if urls is not None: #plugin_urls.append(urls) values = self.values() return zip(self.values(), urls) if self.field.rel: m = EasyModel(self.model.site, self.field.rel.to) if self.field.rel.to in self.model.model_list: lst = [] for value in self.values(): url = mark_safe('%s%s/%s/objects/%s/' % (self.model.site.root_url, m.model._meta.app_label, m.model._meta.module_name, iri_to_uri(value._get_pk_val()))) lst.append((smart_unicode(value), url)) else: lst = [(value, None) for value in self.values()] elif self.field.choices: lst = [] for value in self.values(): url = mark_safe('%s%s/%s/fields/%s/%s/' % (self.model.site.root_url, self.model.model._meta.app_label, self.model.model._meta.module_name, self.field.name, iri_to_uri(self.raw_value))) lst.append((value, url)) elif isinstance(self.field, models.URLField): val = self.values()[0] lst = [(val, iri_to_uri(val))] else: lst = [(self.values()[0], None)] return lst class EasyQuerySet(QuerySet): """ When creating (or cloning to) an `EasyQuerySet`, make sure to set the `_easymodel` variable to the related `EasyModel`. """ def iterator(self, *args, **kwargs): for obj in super(EasyQuerySet, self).iterator(*args, **kwargs): yield EasyInstance(self._easymodel, obj) def _clone(self, *args, **kwargs): c = super(EasyQuerySet, self)._clone(*args, **kwargs) c._easymodel = self._easymodel return c
ajibawa-2023/Python-Code-Large/train/row_98807
150
215
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_98807:Expr_L1_C0", "label": "expression", "type": "expression", "loc": [1, 4], "level": 0, "parent": null, "vector": [8, 0, 0.0116, 0.0186, 0, 0.66, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "\"\"\"\nThese classes are light wrappers around Django's database API that provide\nconvenience functionality and permalink functions for the databrowse app.\n\"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98807:ImportFrom_L6_C0", "label": "from django.db import models", "type": "import", "loc": [6, 6], "level": 0, "parent": null, "vector": [1, 0, 0.0279, 0.0047, 0, 0.66, 0.0714, 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_98807:ImportFrom_L7_C0", "label": "from django.utils import formats", "type": "import", "loc": [7, 7], "level": 0, "parent": null, "vector": [1, 0, 0.0326, 0.0047, 0, 0.66, 0.1429, 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_98807:ImportFrom_L8_C0", "label": "from django.utils.text import capfirst", "type": "import", "loc": [8, 8], "level": 0, "parent": null, "vector": [1, 0, 0.0372, 0.0047, 0, 0.66, 0.2143, 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_98807:ImportFrom_L9_C0", "label": "from django.utils.encoding import smart_unicode, smart_str, iri_to_uri", "type": "import", "loc": [9, 9], "level": 0, "parent": null, "vector": [1, 0, 0.0419, 0.0047, 0, 0.66, 0.2857, 96, 0, 3, 0, 0, 96, 0, 0], "semantic": {"name": "django.utils.encoding", "arg_names": [], "import_names": ["smart_unicode", "smart_str", "iri_to_uri"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.utils.encoding import smart_unicode, smart_str, iri_to_uri"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98807:ImportFrom_L10_C0", "label": "from django.utils.safestring import mark_safe", "type": "import", "loc": [10, 10], "level": 0, "parent": null, "vector": [1, 0, 0.0465, 0.0047, 0, 0.66, 0.3571, 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_98807:ImportFrom_L11_C0", "label": "from django.db.models.query import QuerySet", "type": "import", "loc": [11, 11], "level": 0, "parent": null, "vector": [1, 0, 0.0512, 0.0047, 0, 0.66, 0.4286, 793, 0, 1, 0, 0, 793, 0, 0], "semantic": {"name": "django.db.models.query", "arg_names": [], "import_names": ["QuerySet"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.db.models.query import QuerySet"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98807:Assign_L13_C0", "label": "EMPTY_VALUE =", "type": "assigned_variable", "loc": [13, 13], "level": 0, "parent": null, "vector": [14, 0, 0.0605, 0.0047, 0, 0.66, 0.5, 334, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "EMPTY_VALUE", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "EMPTY_VALUE = '(None)'"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98807:Assign_L14_C0", "label": "DISPLAY_SIZE =", "type": "assigned_variable", "loc": [14, 14], "level": 0, "parent": null, "vector": [14, 0, 0.0651, 0.0047, 0, 0.66, 0.5714, 323, 1, 0, 0, 0, 0, 1, 0], "semantic": {"name": "DISPLAY_SIZE", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "DISPLAY_SIZE = 100"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98807:ClassDef_L16_C0", "label": "EasyModel", "type": "class", "loc": [16, 57], "level": 0, "parent": null, "vector": [3, 0, 0.1698, 0.1953, 0, 0.66, 0.6429, 749, 0, 10, 0, 0, 186, 0, 14], "semantic": {"name": "EasyModel", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class EasyModel(object):\n def __init__(self, site, model):\n self.site = site\n self.model = model\n self.model_list = site.registry.keys()\n self.verbose_name = model._meta.verbose_name\n self.verbose_name_plural = model._meta.verbose_name_plural\n"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98807:FunctionDef_L17_C4", "label": "__init__", "type": "function", "loc": [17, 22], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98807:ClassDef_L16_C0", "vector": [2, 1, 0.0907, 0.0279, 1, 0.18, 0.0, 555, 0, 3, 0, 0, 0, 0, 1], "semantic": {"name": "__init__", "arg_names": ["self", "site", "model"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def __init__(self, site, model):\n self.site = site\n self.model = model\n self.model_list = site.registry.keys()\n self.verbose_name = model._meta.verbose_name\n self.verbose_name_plural = model._meta.verbose_name_plural"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98807:Assign_L18_C8", "label": "self.site =", "type": "assigned_variable", "loc": [18, 18], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98807:FunctionDef_L17_C4", "vector": [14, 2, 0.0837, 0.0047, 2, 0.33, 0.0, 728, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "self.site", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.site = site"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98807:Assign_L19_C8", "label": "self.model =", "type": "assigned_variable", "loc": [19, 19], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98807:FunctionDef_L17_C4", "vector": [14, 2, 0.0884, 0.0047, 2, 0.33, 0.25, 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_98807:Assign_L20_C8", "label": "self.model_list = keys()", "type": "assigned_variable", "loc": [20, 20], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98807:FunctionDef_L17_C4", "vector": [14, 2, 0.093, 0.0047, 2, 0.33, 0.5, 972, 3, 0, 0, 0, 204, 10, 1], "semantic": {"name": "self.model_list", "arg_names": [], "import_names": [], "rhs_call_name": "keys", "annotation": ""}, "snippet": " self.model_list = site.registry.keys()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98807:Assign_L21_C8", "label": "self.verbose_name =", "type": "assigned_variable", "loc": [21, 21], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98807:FunctionDef_L17_C4", "vector": [14, 2, 0.0977, 0.0047, 2, 0.33, 0.75, 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 = model._meta.verbose_name"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98807:Assign_L22_C8", "label": "self.verbose_name_plural =", "type": "assigned_variable", "loc": [22, 22], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98807:FunctionDef_L17_C4", "vector": [14, 2, 0.1023, 0.0047, 2, 0.33, 1.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 = model._meta.verbose_name_plural"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98807:FunctionDef_L24_C4", "label": "__repr__", "type": "function", "loc": [24, 25], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98807:ClassDef_L16_C0", "vector": [2, 1, 0.114, 0.0093, 1, 0.18, 0.1111, 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 '<EasyModel for %s>' % smart_str(self.model._meta.object_name)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98807:Return_L25_C8", "label": "return", "type": "return", "loc": [25, 25], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98807:FunctionDef_L24_C4", "vector": [13, 2, 0.1163, 0.0047, 2, 0.51, 0.0, 0, 4, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return '<EasyModel for %s>' % smart_str(self.model._meta.object_name)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98807:FunctionDef_L27_C4", "label": "model_databrowse", "type": "function", "loc": [27, 29], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98807:ClassDef_L16_C0", "vector": [2, 1, 0.1302, 0.014, 1, 0.18, 0.2222, 977, 0, 1, 1, 0, 0, 0, 0], "semantic": {"name": "model_databrowse", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def model_databrowse(self):\n \"Returns the ModelDatabrowse class for this model.\"\n return self.site.registry[self.model]"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98807:Expr_L28_C8", "label": "expression", "type": "expression", "loc": [28, 28], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98807:FunctionDef_L27_C4", "vector": [8, 2, 0.1302, 0.0047, 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 ModelDatabrowse class for this model.\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98807:Return_L29_C8", "label": "return", "type": "return", "loc": [29, 29], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98807:FunctionDef_L27_C4", "vector": [13, 2, 0.1349, 0.0047, 2, 0.66, 1.0, 0, 6, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return self.site.registry[self.model]"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98807:FunctionDef_L31_C4", "label": "url", "type": "function", "loc": [31, 32], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98807:ClassDef_L16_C0", "vector": [2, 1, 0.1465, 0.0093, 1, 0.18, 0.3333, 789, 0, 1, 1, 0, 0, 0, 1], "semantic": {"name": "url", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def url(self):\n return mark_safe('%s%s/%s/' % (self.site.root_url, self.model._meta.app_label, self.model._meta.module_name))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98807:Return_L32_C8", "label": "return", "type": "return", "loc": [32, 32], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98807:FunctionDef_L31_C4", "vector": [13, 2, 0.1488, 0.0047, 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 mark_safe('%s%s/%s/' % (self.site.root_url, self.model._meta.app_label, self.model._meta.module_name))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98807:FunctionDef_L34_C4", "label": "objects", "type": "function", "loc": [34, 35], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98807:ClassDef_L16_C0", "vector": [2, 1, 0.1605, 0.0093, 1, 0.18, 0.4444, 550, 0, 2, 1, 0, 0, 0, 2], "semantic": {"name": "objects", "arg_names": ["self", "kwargs"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def objects(self, **kwargs):\n return self.get_query_set().filter(**kwargs)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98807:Return_L35_C8", "label": "return", "type": "return", "loc": [35, 35], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98807:FunctionDef_L34_C4", "vector": [13, 2, 0.1628, 0.0047, 2, 0.77, 0.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(**kwargs)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98807:FunctionDef_L37_C4", "label": "get_query_set", "type": "function", "loc": [37, 40], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98807:ClassDef_L16_C0", "vector": [2, 1, 0.1791, 0.0186, 1, 0.18, 0.5556, 696, 0, 1, 1, 0, 0, 0, 2], "semantic": {"name": "get_query_set", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def get_query_set(self):\n easy_qs = self.model._default_manager.get_query_set()._clone(klass=EasyQuerySet)\n easy_qs._easymodel = self\n return easy_qs"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98807:Assign_L38_C8", "label": "easy_qs = _clone()", "type": "assigned_variable", "loc": [38, 38], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98807:FunctionDef_L37_C4", "vector": [14, 2, 0.1767, 0.0047, 2, 0.5, 0.0, 513, 3, 1, 0, 0, 617, 10, 2], "semantic": {"name": "easy_qs", "arg_names": [], "import_names": [], "rhs_call_name": "_clone", "annotation": ""}, "snippet": " easy_qs = self.model._default_manager.get_query_set()._clone(klass=EasyQuerySet)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98807:Assign_L39_C8", "label": "easy_qs._easymodel =", "type": "assigned_variable", "loc": [39, 39], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98807:FunctionDef_L37_C4", "vector": [14, 2, 0.1814, 0.0047, 2, 0.5, 0.5, 361, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "easy_qs._easymodel", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " easy_qs._easymodel = self"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98807:Return_L40_C8", "label": "return", "type": "return", "loc": [40, 40], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98807:FunctionDef_L37_C4", "vector": [13, 2, 0.186, 0.0047, 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 easy_qs"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98807:FunctionDef_L42_C4", "label": "object_by_pk", "type": "function", "loc": [42, 43], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98807:ClassDef_L16_C0", "vector": [2, 1, 0.1977, 0.0093, 1, 0.18, 0.6667, 601, 0, 2, 1, 0, 0, 0, 2], "semantic": {"name": "object_by_pk", "arg_names": ["self", "pk"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def object_by_pk(self, pk):\n return EasyInstance(self, self.model._default_manager.get(pk=pk))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98807:Return_L43_C8", "label": "return", "type": "return", "loc": [43, 43], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98807:FunctionDef_L42_C4", "vector": [13, 2, 0.2, 0.0047, 2, 0.41, 0.0, 0, 3, 0, 0, 0, 0, 10, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return EasyInstance(self, self.model._default_manager.get(pk=pk))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98807:FunctionDef_L45_C4", "label": "sample_objects", "type": "function", "loc": [45, 47], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98807:ClassDef_L16_C0", "vector": [2, 1, 0.214, 0.014, 1, 0.18, 0.7778, 284, 0, 1, 0, 0, 0, 0, 2], "semantic": {"name": "sample_objects", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def sample_objects(self):\n for obj in self.model._default_manager.all()[:3]:\n yield EasyInstance(self, obj)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98807:For_L46_C8", "label": "for obj", "type": "for", "loc": [46, 47], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98807:FunctionDef_L45_C4", "vector": [6, 2, 0.2163, 0.0093, 2, 0.43, 0.0, 505, 6, 0, 0, 0, 0, 0, 2], "semantic": {"name": "obj", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for obj in self.model._default_manager.all()[:3]:\n yield EasyInstance(self, obj)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98807:Expr_L47_C12", "label": "expression", "type": "expression", "loc": [47, 47], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98807:For_L46_C8", "vector": [8, 3, 0.2186, 0.0047, 3, 0.15, 0.0, 0, 0, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " yield EasyInstance(self, obj)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98807:FunctionDef_L49_C4", "label": "field", "type": "function", "loc": [49, 54], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98807:ClassDef_L16_C0", "vector": [2, 1, 0.2395, 0.0279, 1, 0.18, 0.8889, 480, 0, 2, 1, 0, 0, 0, 2], "semantic": {"name": "field", "arg_names": ["self", "name"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def field(self, name):\n try:\n f = self.model._meta.get_field(name)\n except models.FieldDoesNotExist:\n return None\n return EasyField(self, f)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98807:Try_L50_C8", "label": "try", "type": "try", "loc": [50, 53], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98807:FunctionDef_L49_C4", "vector": [7, 2, 0.2395, 0.0186, 2, 0.35, 0.0, 0, 0, 1, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " try:\n f = self.model._meta.get_field(name)\n except models.FieldDoesNotExist:\n return None"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98807:Assign_L51_C12", "label": "f = get_field()", "type": "assigned_variable", "loc": [51, 51], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98807:Try_L50_C8", "vector": [14, 3, 0.2372, 0.0047, 3, 0.73, 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.model._meta.get_field(name)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98807:Return_L53_C12", "label": "return", "type": "return", "loc": [53, 53], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98807:Try_L50_C8", "vector": [13, 3, 0.2465, 0.0047, 3, 0.73, 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_98807:Return_L54_C8", "label": "return", "type": "return", "loc": [54, 54], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98807:FunctionDef_L49_C4", "vector": [13, 2, 0.2512, 0.0047, 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 EasyField(self, f)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98807:FunctionDef_L56_C4", "label": "fields", "type": "function", "loc": [56, 57], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98807:ClassDef_L16_C0", "vector": [2, 1, 0.2628, 0.0093, 1, 0.18, 1.0, 358, 0, 1, 1, 0, 0, 0, 1], "semantic": {"name": "fields", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def fields(self):\n return [EasyField(self, f) for f in (self.model._meta.fields + self.model._meta.many_to_many)]"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98807:Return_L57_C8", "label": "return", "type": "return", "loc": [57, 57], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98807:FunctionDef_L56_C4", "vector": [13, 2, 0.2651, 0.0047, 2, 0.84, 0.0, 0, 5, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return [EasyField(self, f) for f in (self.model._meta.fields + self.model._meta.many_to_many)]"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98807:ClassDef_L59_C0", "label": "EasyField", "type": "class", "loc": [59, 74], "level": 0, "parent": null, "vector": [3, 0, 0.3093, 0.0744, 0, 0.66, 0.7143, 981, 0, 4, 0, 0, 186, 0, 4], "semantic": {"name": "EasyField", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class EasyField(object):\n def __init__(self, easy_model, field):\n self.model, self.field = easy_model, field\n\n def __repr__(self):\n return smart_str(u'<EasyField for %s.%s>' % (self.model.model._meta.object_name, self.field.name))\n\n def choices(self):"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98807:FunctionDef_L60_C4", "label": "__init__", "type": "function", "loc": [60, 61], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98807:ClassDef_L59_C0", "vector": [2, 1, 0.2814, 0.0093, 1, 0.08, 0.0, 555, 0, 3, 0, 0, 0, 0, 0], "semantic": {"name": "__init__", "arg_names": ["self", "easy_model", "field"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def __init__(self, easy_model, field):\n self.model, self.field = easy_model, field"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98807:Assign_L61_C8", "label": "assign", "type": "assigned_variable", "loc": [61, 61], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98807:FunctionDef_L60_C4", "vector": [14, 2, 0.2837, 0.0047, 2, 0.52, 0.0, 0, 0, 0, 0, 0, 0, 8, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.model, self.field = easy_model, field"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98807:FunctionDef_L63_C4", "label": "__repr__", "type": "function", "loc": [63, 64], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98807:ClassDef_L59_C0", "vector": [2, 1, 0.2953, 0.0093, 1, 0.08, 0.3333, 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_str(u'<EasyField for %s.%s>' % (self.model.model._meta.object_name, self.field.name))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98807:Return_L64_C8", "label": "return", "type": "return", "loc": [64, 64], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98807:FunctionDef_L63_C4", "vector": [13, 2, 0.2977, 0.0047, 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 smart_str(u'<EasyField for %s.%s>' % (self.model.model._meta.object_name, self.field.name))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98807:FunctionDef_L66_C4", "label": "choices", "type": "function", "loc": [66, 68], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98807:ClassDef_L59_C0", "vector": [2, 1, 0.3116, 0.014, 1, 0.08, 0.6667, 405, 0, 1, 0, 0, 0, 0, 1], "semantic": {"name": "choices", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def choices(self):\n for value, label in self.field.choices:\n yield EasyChoice(self.model, self, value, label)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98807:For_L67_C8", "label": "for value, label", "type": "for", "loc": [67, 68], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98807:FunctionDef_L66_C4", "vector": [6, 2, 0.314, 0.0093, 2, 0.71, 0.0, 342, 7, 0, 0, 0, 0, 0, 1], "semantic": {"name": "value, label", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for value, label in self.field.choices:\n yield EasyChoice(self.model, self, value, label)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98807:Expr_L68_C12", "label": "expression", "type": "expression", "loc": [68, 68], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98807:For_L67_C8", "vector": [8, 3, 0.3163, 0.0047, 3, 0.25, 0.0, 0, 0, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " yield EasyChoice(self.model, self, value, label)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98807:FunctionDef_L70_C4", "label": "url", "type": "function", "loc": [70, 74], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98807:ClassDef_L59_C0", "vector": [2, 1, 0.3349, 0.0233, 1, 0.08, 1.0, 789, 0, 1, 1, 0, 0, 0, 2], "semantic": {"name": "url", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def url(self):\n if self.field.choices:\n return mark_safe('%s%s/%s/%s/' % (self.model.site.root_url, self.model.model._meta.app_label, self.model.model._meta.module_name, self.field.name))\n elif self.field.rel:\n return mark_safe('%s%s/%s/' % (self.model.site.root_url, self.model.model._meta.app_label, self.model.model._meta.module_name))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98807:If_L71_C8", "label": "if", "type": "if", "loc": [71, 74], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98807:FunctionDef_L70_C4", "vector": [4, 2, 0.3372, 0.0186, 2, 0.5, 0.0, 0, 7, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if self.field.choices:\n return mark_safe('%s%s/%s/%s/' % (self.model.site.root_url, self.model.model._meta.app_label, self.model.model._meta.module_name, self.field.name))\n elif self.field.rel:\n return mark_safe('%s%s/%s/' % (self.model.site.root_url, self.model.model._meta.app_label, self.model.model._meta.module_name))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98807:Return_L72_C12", "label": "return", "type": "return", "loc": [72, 72], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98807:If_L71_C8", "vector": [13, 3, 0.3349, 0.0047, 3, 0.96, 0.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/%s/%s/' % (self.model.site.root_url, self.model.model._meta.app_label, self.model.model._meta.module_name, self.field.name))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98807:If_L73_C8", "label": "if", "type": "if", "loc": [73, 74], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98807:If_L71_C8", "vector": [4, 3, 0.3419, 0.0093, 3, 0.96, 1.0, 0, 7, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " elif self.field.rel:\n return mark_safe('%s%s/%s/' % (self.model.site.root_url, self.model.model._meta.app_label, self.model.model._meta.module_name))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98807:Return_L74_C12", "label": "return", "type": "return", "loc": [74, 74], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98807:If_L73_C8", "vector": [13, 4, 0.3442, 0.0047, 4, 0.41, 0.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/%s/' % (self.model.site.root_url, self.model.model._meta.app_label, self.model.model._meta.module_name))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98807:ClassDef_L76_C0", "label": "EasyChoice", "type": "class", "loc": [76, 85], "level": 0, "parent": null, "vector": [3, 0, 0.3744, 0.0465, 0, 0.66, 0.7857, 390, 0, 3, 0, 0, 186, 0, 3], "semantic": {"name": "EasyChoice", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class EasyChoice(object):\n def __init__(self, easy_model, field, value, label):\n self.model, self.field = easy_model, field\n self.value, self.label = value, label\n\n def __repr__(self):\n return smart_str(u'<EasyChoice for %s.%s>' % (self.model.model._meta.object_name, self.field.name))\n"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98807:FunctionDef_L77_C4", "label": "__init__", "type": "function", "loc": [77, 79], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98807:ClassDef_L76_C0", "vector": [2, 1, 0.3628, 0.014, 1, 0.15, 0.0, 555, 0, 5, 0, 0, 0, 0, 0], "semantic": {"name": "__init__", "arg_names": ["self", "easy_model", "field", "value", "label"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def __init__(self, easy_model, field, value, label):\n self.model, self.field = easy_model, field\n self.value, self.label = value, label"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98807:Assign_L78_C8", "label": "assign", "type": "assigned_variable", "loc": [78, 78], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98807:FunctionDef_L77_C4", "vector": [14, 2, 0.3628, 0.0047, 2, 0.86, 0.0, 0, 0, 0, 0, 0, 0, 8, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.model, self.field = easy_model, field"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98807:Assign_L79_C8", "label": "assign", "type": "assigned_variable", "loc": [79, 79], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98807:FunctionDef_L77_C4", "vector": [14, 2, 0.3674, 0.0047, 2, 0.86, 1.0, 0, 0, 0, 0, 0, 0, 8, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.value, self.label = value, label"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98807:FunctionDef_L81_C4", "label": "__repr__", "type": "function", "loc": [81, 82], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98807:ClassDef_L76_C0", "vector": [2, 1, 0.3791, 0.0093, 1, 0.15, 0.5, 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_str(u'<EasyChoice for %s.%s>' % (self.model.model._meta.object_name, self.field.name))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98807:Return_L82_C8", "label": "return", "type": "return", "loc": [82, 82], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98807:FunctionDef_L81_C4", "vector": [13, 2, 0.3814, 0.0047, 2, 0.28, 0.0, 0, 3, 0, 0, 0, 0, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return smart_str(u'<EasyChoice for %s.%s>' % (self.model.model._meta.object_name, self.field.name))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98807:FunctionDef_L84_C4", "label": "url", "type": "function", "loc": [84, 85], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98807:ClassDef_L76_C0", "vector": [2, 1, 0.393, 0.0093, 1, 0.15, 1.0, 789, 0, 1, 1, 0, 0, 0, 2], "semantic": {"name": "url", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def url(self):\n return mark_safe('%s%s/%s/%s/%s/' % (self.model.site.root_url, self.model.model._meta.app_label, self.model.model._meta.module_name, self.field.field.name, iri_to_uri(self.value)))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98807:Return_L85_C8", "label": "return", "type": "return", "loc": [85, 85], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98807:FunctionDef_L84_C4", "vector": [13, 2, 0.3953, 0.0047, 2, 0.87, 0.0, 0, 3, 0, 0, 0, 0, 10, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return mark_safe('%s%s/%s/%s/%s/' % (self.model.site.root_url, self.model.model._meta.app_label, self.model.model._meta.module_name, self.field.field.name, iri_to_uri(self.value)))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98807:ClassDef_L87_C0", "label": "EasyInstance", "type": "class", "loc": [87, 131], "level": 0, "parent": null, "vector": [3, 0, 0.507, 0.2093, 0, 0.66, 0.8571, 857, 0, 8, 0, 0, 186, 0, 18], "semantic": {"name": "EasyInstance", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class EasyInstance(object):\n def __init__(self, easy_model, instance):\n self.model, self.instance = easy_model, instance\n\n def __repr__(self):\n return smart_str(u'<EasyInstance for %s (%s)>' % (self.model.model._meta.object_name, self.instance._get_pk_val()))\n\n def __unicode__(self):"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98807:FunctionDef_L88_C4", "label": "__init__", "type": "function", "loc": [88, 89], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98807:ClassDef_L87_C0", "vector": [2, 1, 0.4116, 0.0093, 1, 0.81, 0.0, 555, 0, 3, 0, 0, 0, 0, 0], "semantic": {"name": "__init__", "arg_names": ["self", "easy_model", "instance"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def __init__(self, easy_model, instance):\n self.model, self.instance = easy_model, instance"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98807:Assign_L89_C8", "label": "assign", "type": "assigned_variable", "loc": [89, 89], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98807:FunctionDef_L88_C4", "vector": [14, 2, 0.414, 0.0047, 2, 0.03, 0.0, 0, 0, 0, 0, 0, 0, 8, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.model, self.instance = easy_model, instance"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98807:FunctionDef_L91_C4", "label": "__repr__", "type": "function", "loc": [91, 92], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98807:ClassDef_L87_C0", "vector": [2, 1, 0.4256, 0.0093, 1, 0.81, 0.1429, 204, 0, 1, 1, 0, 0, 0, 2], "semantic": {"name": "__repr__", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def __repr__(self):\n return smart_str(u'<EasyInstance for %s (%s)>' % (self.model.model._meta.object_name, self.instance._get_pk_val()))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98807:Return_L92_C8", "label": "return", "type": "return", "loc": [92, 92], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98807:FunctionDef_L91_C4", "vector": [13, 2, 0.4279, 0.0047, 2, 0.71, 0.0, 0, 3, 0, 0, 0, 0, 10, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return smart_str(u'<EasyInstance for %s (%s)>' % (self.model.model._meta.object_name, self.instance._get_pk_val()))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98807:FunctionDef_L94_C4", "label": "__unicode__", "type": "function", "loc": [94, 98], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98807:ClassDef_L87_C0", "vector": [2, 1, 0.4465, 0.0233, 1, 0.81, 0.2857, 318, 0, 1, 1, 0, 0, 0, 2], "semantic": {"name": "__unicode__", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def __unicode__(self):\n val = smart_unicode(self.instance)\n if len(val) > DISPLAY_SIZE:\n return val[:DISPLAY_SIZE] + u'...'\n return val"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98807:Assign_L95_C8", "label": "val = smart_unicode()", "type": "assigned_variable", "loc": [95, 95], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98807:FunctionDef_L94_C4", "vector": [14, 2, 0.4419, 0.0047, 2, 0.66, 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(self.instance)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98807:If_L96_C8", "label": "if", "type": "if", "loc": [96, 97], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98807:FunctionDef_L94_C4", "vector": [4, 2, 0.4488, 0.0093, 2, 0.66, 0.5, 0, 0, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if len(val) > DISPLAY_SIZE:\n return val[:DISPLAY_SIZE] + u'...'"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98807:Return_L97_C12", "label": "return", "type": "return", "loc": [97, 97], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98807:If_L96_C8", "vector": [13, 3, 0.4512, 0.0047, 3, 0.06, 0.0, 0, 4, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return val[:DISPLAY_SIZE] + u'...'"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98807:Return_L98_C8", "label": "return", "type": "return", "loc": [98, 98], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98807:FunctionDef_L94_C4", "vector": [13, 2, 0.4558, 0.0047, 2, 0.66, 1.0, 0, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return val"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98807:FunctionDef_L100_C4", "label": "__str__", "type": "function", "loc": [100, 101], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98807:ClassDef_L87_C0", "vector": [2, 1, 0.4674, 0.0093, 1, 0.81, 0.4286, 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 self.__unicode__().encode('utf-8')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98807:Return_L101_C8", "label": "return", "type": "return", "loc": [101, 101], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98807:FunctionDef_L100_C4", "vector": [13, 2, 0.4698, 0.0047, 2, 0.67, 0.0, 0, 3, 0, 0, 0, 0, 10, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return self.__unicode__().encode('utf-8')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98807:FunctionDef_L103_C4", "label": "pk", "type": "function", "loc": [103, 104], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98807:ClassDef_L87_C0", "vector": [2, 1, 0.4814, 0.0093, 1, 0.81, 0.5714, 164, 0, 1, 1, 0, 0, 0, 1], "semantic": {"name": "pk", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def pk(self):\n return self.instance._get_pk_val()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98807:Return_L104_C8", "label": "return", "type": "return", "loc": [104, 104], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98807:FunctionDef_L103_C4", "vector": [13, 2, 0.4837, 0.0047, 2, 0.57, 0.0, 0, 3, 0, 0, 0, 0, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return self.instance._get_pk_val()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98807:FunctionDef_L106_C4", "label": "url", "type": "function", "loc": [106, 107], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98807:ClassDef_L87_C0", "vector": [2, 1, 0.4953, 0.0093, 1, 0.81, 0.7143, 789, 0, 1, 1, 0, 0, 0, 3], "semantic": {"name": "url", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def url(self):\n return mark_safe('%s%s/%s/objects/%s/' % (self.model.site.root_url, self.model.model._meta.app_label, self.model.model._meta.module_name, iri_to_uri(self.pk())))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98807:Return_L107_C8", "label": "return", "type": "return", "loc": [107, 107], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98807:FunctionDef_L106_C4", "vector": [13, 2, 0.4977, 0.0047, 2, 0.39, 0.0, 0, 3, 0, 0, 0, 0, 10, 3], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return mark_safe('%s%s/%s/objects/%s/' % (self.model.site.root_url, self.model.model._meta.app_label, self.model.model._meta.module_name, iri_to_uri(self.pk())))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98807:FunctionDef_L109_C4", "label": "fields", "type": "function", "loc": [109, 115], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98807:ClassDef_L87_C0", "vector": [2, 1, 0.5209, 0.0326, 1, 0.81, 0.8571, 358, 0, 1, 0, 0, 0, 0, 1], "semantic": {"name": "fields", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def fields(self):\n \"\"\"\n Generator that yields EasyInstanceFields for each field in this\n EasyInstance's model.\n \"\"\"\n for f in self.model.model._meta.fields + self.model.model._meta.many_to_many:\n yield EasyInstanceField(self.model, self, f)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98807:Expr_L110_C8", "label": "expression", "type": "expression", "loc": [110, 113], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98807:FunctionDef_L109_C4", "vector": [8, 2, 0.5186, 0.0186, 2, 0.9, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"\n Generator that yields EasyInstanceFields for each field in this\n EasyInstance's model.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98807:For_L114_C8", "label": "for f", "type": "for", "loc": [114, 115], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98807:FunctionDef_L109_C4", "vector": [6, 2, 0.5326, 0.0093, 2, 0.9, 1.0, 899, 4, 0, 0, 0, 0, 0, 1], "semantic": {"name": "f", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for f in self.model.model._meta.fields + self.model.model._meta.many_to_many:\n yield EasyInstanceField(self.model, self, f)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98807:Expr_L115_C12", "label": "expression", "type": "expression", "loc": [115, 115], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98807:For_L114_C8", "vector": [8, 3, 0.5349, 0.0047, 3, 0.51, 0.0, 0, 0, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " yield EasyInstanceField(self.model, self, f)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98807:FunctionDef_L117_C4", "label": "related_objects", "type": "function", "loc": [117, 131], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98807:ClassDef_L87_C0", "vector": [2, 1, 0.5767, 0.0698, 1, 0.81, 1.0, 768, 0, 1, 0, 0, 0, 0, 7], "semantic": {"name": "related_objects", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def related_objects(self):\n \"\"\"\n Generator that yields dictionaries of all models that have this\n EasyInstance's model as a ForeignKey or ManyToManyField, along with\n lists of related objects.\n \"\"\"\n for rel_object in self.model.model._meta.get_all_related_objects() + self.model.model._meta.get_all_related_many_to_many_objects():\n if rel_object.model not in self.model.model_list:"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98807:Expr_L118_C8", "label": "expression", "type": "expression", "loc": [118, 122], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98807:FunctionDef_L117_C4", "vector": [8, 2, 0.5581, 0.0233, 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 Generator that yields dictionaries of all models that have this\n EasyInstance's model as a ForeignKey or ManyToManyField, along with\n lists of related objects.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98807:For_L123_C8", "label": "for rel_object", "type": "for", "loc": [123, 131], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98807:FunctionDef_L117_C4", "vector": [6, 2, 0.5907, 0.0419, 2, 0.71, 1.0, 582, 4, 0, 0, 0, 0, 0, 7], "semantic": {"name": "rel_object", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for rel_object in self.model.model._meta.get_all_related_objects() + self.model.model._meta.get_all_related_many_to_many_objects():\n if rel_object.model not in self.model.model_list:\n continue # Skip models that aren't in the model_list\n em = EasyModel(self.model.site, rel_object.model)\n yield {\n 'model': em,\n 'related_field': rel_object.field.verbose_name,\n 'object_list': [EasyInstance(em, i) for i in getattr(self.instance, rel_object.get_accessor_name()).all()],"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98807:If_L124_C12", "label": "if", "type": "if", "loc": [124, 125], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98807:For_L123_C8", "vector": [4, 3, 0.5791, 0.0093, 3, 0.82, 0.0, 0, 0, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if rel_object.model not in self.model.model_list:\n continue # Skip models that aren't in the model_list"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98807:Assign_L126_C12", "label": "em = EasyModel()", "type": "assigned_variable", "loc": [126, 126], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98807:For_L123_C8", "vector": [14, 3, 0.586, 0.0047, 3, 0.82, 0.5, 832, 3, 2, 0, 0, 749, 10, 1], "semantic": {"name": "em", "arg_names": [], "import_names": [], "rhs_call_name": "EasyModel", "annotation": ""}, "snippet": " em = EasyModel(self.model.site, rel_object.model)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98807:Expr_L127_C12", "label": "expression", "type": "expression", "loc": [127, 131], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98807:For_L123_C8", "vector": [8, 3, 0.6, 0.0233, 3, 0.82, 1.0, 0, 0, 0, 0, 0, 0, 0, 4], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " yield {\n 'model': em,\n 'related_field': rel_object.field.verbose_name,\n 'object_list': [EasyInstance(em, i) for i in getattr(self.instance, rel_object.get_accessor_name()).all()],\n }"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98807:ClassDef_L133_C0", "label": "EasyInstanceField", "type": "class", "loc": [133, 201], "level": 0, "parent": null, "vector": [3, 0, 0.7767, 0.3209, 0, 0.66, 0.9286, 675, 0, 4, 0, 0, 186, 0, 44], "semantic": {"name": "EasyInstanceField", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class EasyInstanceField(object):\n def __init__(self, easy_model, instance, field):\n self.model, self.field, self.instance = easy_model, field, instance\n self.raw_value = getattr(instance.instance, field.name)\n\n def __repr__(self):\n return smart_str(u'<EasyInstanceField for %s.%s>' % (self.model.model._meta.object_name, self.field.name))\n"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98807:FunctionDef_L134_C4", "label": "__init__", "type": "function", "loc": [134, 136], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98807:ClassDef_L133_C0", "vector": [2, 1, 0.6279, 0.014, 1, 0.96, 0.0, 555, 0, 4, 0, 0, 0, 0, 1], "semantic": {"name": "__init__", "arg_names": ["self", "easy_model", "instance", "field"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def __init__(self, easy_model, instance, field):\n self.model, self.field, self.instance = easy_model, field, instance\n self.raw_value = getattr(instance.instance, field.name)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98807:Assign_L135_C8", "label": "assign", "type": "assigned_variable", "loc": [135, 135], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98807:FunctionDef_L134_C4", "vector": [14, 2, 0.6279, 0.0047, 2, 0.33, 0.0, 0, 0, 0, 0, 0, 0, 8, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.model, self.field, self.instance = easy_model, field, instance"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98807:Assign_L136_C8", "label": "self.raw_value = getattr()", "type": "assigned_variable", "loc": [136, 136], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98807:FunctionDef_L134_C4", "vector": [14, 2, 0.6326, 0.0047, 2, 0.33, 1.0, 390, 3, 2, 0, 0, 121, 10, 1], "semantic": {"name": "self.raw_value", "arg_names": [], "import_names": [], "rhs_call_name": "getattr", "annotation": ""}, "snippet": " self.raw_value = getattr(instance.instance, field.name)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98807:FunctionDef_L138_C4", "label": "__repr__", "type": "function", "loc": [138, 139], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98807:ClassDef_L133_C0", "vector": [2, 1, 0.6442, 0.0093, 1, 0.96, 0.3333, 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_str(u'<EasyInstanceField for %s.%s>' % (self.model.model._meta.object_name, self.field.name))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98807:Return_L139_C8", "label": "return", "type": "return", "loc": [139, 139], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98807:FunctionDef_L138_C4", "vector": [13, 2, 0.6465, 0.0047, 2, 0.05, 0.0, 0, 3, 0, 0, 0, 0, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return smart_str(u'<EasyInstanceField for %s.%s>' % (self.model.model._meta.object_name, self.field.name))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98807:FunctionDef_L141_C4", "label": "values", "type": "function", "loc": [141, 170], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98807:ClassDef_L133_C0", "vector": [2, 1, 0.7233, 0.1395, 1, 0.96, 0.6667, 721, 0, 1, 1, 0, 0, 0, 20], "semantic": {"name": "values", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def values(self):\n \"\"\"\n Returns a list of values for this field for this instance. It's a list\n so we can accomodate many-to-many fields.\n \"\"\"\n # This import is deliberately inside the function because it causes\n # some settings to be imported, and we don't want to do that at the\n # module level."}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98807:Expr_L142_C8", "label": "expression", "type": "expression", "loc": [142, 145], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98807:FunctionDef_L141_C4", "vector": [8, 2, 0.6674, 0.0186, 2, 0.61, 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 values for this field for this instance. It's a list\n so we can accomodate many-to-many fields.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98807:If_L149_C8", "label": "if", "type": "if", "loc": [149, 169], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98807:FunctionDef_L141_C4", "vector": [4, 2, 0.7395, 0.0977, 2, 0.61, 0.5, 0, 7, 0, 0, 0, 0, 0, 20], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if self.field.rel:\n if isinstance(self.field.rel, models.ManyToOneRel):\n objs = getattr(self.instance.instance, self.field.name)\n elif isinstance(self.field.rel, models.ManyToManyRel): # ManyToManyRel\n return list(getattr(self.instance.instance, self.field.name).all())\n elif self.field.choices:\n objs = dict(self.field.choices).get(self.raw_value, EMPTY_VALUE)\n elif isinstance(self.field, models.DateField) or isinstance(self.field, models.TimeField):"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98807:If_L150_C12", "label": "if", "type": "if", "loc": [150, 153], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98807:If_L149_C8", "vector": [4, 3, 0.7047, 0.0186, 3, 0.3, 0.0, 0, 3, 0, 0, 0, 0, 0, 6], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if isinstance(self.field.rel, models.ManyToOneRel):\n objs = getattr(self.instance.instance, self.field.name)\n elif isinstance(self.field.rel, models.ManyToManyRel): # ManyToManyRel\n return list(getattr(self.instance.instance, self.field.name).all())"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98807:Assign_L151_C16", "label": "objs = getattr()", "type": "assigned_variable", "loc": [151, 151], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98807:If_L150_C12", "vector": [14, 4, 0.7023, 0.0047, 4, 0.85, 0.0, 794, 3, 2, 0, 0, 121, 10, 1], "semantic": {"name": "objs", "arg_names": [], "import_names": [], "rhs_call_name": "getattr", "annotation": ""}, "snippet": " objs = getattr(self.instance.instance, self.field.name)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98807:If_L152_C12", "label": "if", "type": "if", "loc": [152, 153], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98807:If_L150_C12", "vector": [4, 4, 0.7093, 0.0093, 4, 0.85, 1.0, 0, 3, 0, 0, 0, 0, 0, 4], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " elif isinstance(self.field.rel, models.ManyToManyRel): # ManyToManyRel\n return list(getattr(self.instance.instance, self.field.name).all())"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98807:Return_L153_C16", "label": "return", "type": "return", "loc": [153, 153], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98807:If_L152_C12", "vector": [13, 5, 0.7116, 0.0047, 5, 0.24, 0.0, 0, 3, 0, 0, 0, 0, 10, 3], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return list(getattr(self.instance.instance, self.field.name).all())"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98807:If_L154_C8", "label": "if", "type": "if", "loc": [154, 169], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98807:If_L149_C8", "vector": [4, 3, 0.7512, 0.0744, 3, 0.3, 1.0, 0, 7, 0, 0, 0, 0, 0, 14], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " elif self.field.choices:\n objs = dict(self.field.choices).get(self.raw_value, EMPTY_VALUE)\n elif isinstance(self.field, models.DateField) or isinstance(self.field, models.TimeField):\n if self.raw_value:\n if isinstance(self.field, models.DateTimeField):\n objs = capfirst(formats.date_format(self.raw_value, 'DATETIME_FORMAT'))\n elif isinstance(self.field, models.TimeField):\n objs = capfirst(formats.time_format(self.raw_value, 'TIME_FORMAT'))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98807:Assign_L155_C12", "label": "objs = get()", "type": "assigned_variable", "loc": [155, 155], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98807:If_L154_C8", "vector": [14, 4, 0.7209, 0.0047, 4, 0.51, 0.0, 794, 3, 2, 0, 0, 607, 10, 2], "semantic": {"name": "objs", "arg_names": [], "import_names": [], "rhs_call_name": "get", "annotation": ""}, "snippet": " objs = dict(self.field.choices).get(self.raw_value, EMPTY_VALUE)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98807:If_L156_C8", "label": "if", "type": "if", "loc": [156, 169], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98807:If_L154_C8", "vector": [4, 4, 0.7558, 0.0651, 4, 0.51, 1.0, 0, 0, 0, 0, 0, 0, 0, 12], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " elif isinstance(self.field, models.DateField) or isinstance(self.field, models.TimeField):\n if self.raw_value:\n if isinstance(self.field, models.DateTimeField):\n objs = capfirst(formats.date_format(self.raw_value, 'DATETIME_FORMAT'))\n elif isinstance(self.field, models.TimeField):\n objs = capfirst(formats.time_format(self.raw_value, 'TIME_FORMAT'))\n else:\n objs = capfirst(formats.date_format(self.raw_value, 'DATE_FORMAT'))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98807:If_L157_C12", "label": "if", "type": "if", "loc": [157, 165], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98807:If_L156_C8", "vector": [4, 5, 0.7488, 0.0419, 5, 0.2, 0.0, 0, 7, 0, 0, 0, 0, 0, 8], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if self.raw_value:\n if isinstance(self.field, models.DateTimeField):\n objs = capfirst(formats.date_format(self.raw_value, 'DATETIME_FORMAT'))\n elif isinstance(self.field, models.TimeField):\n objs = capfirst(formats.time_format(self.raw_value, 'TIME_FORMAT'))\n else:\n objs = capfirst(formats.date_format(self.raw_value, 'DATE_FORMAT'))\n else:"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98807:If_L158_C16", "label": "if", "type": "if", "loc": [158, 163], "level": 6, "parent": "ajibawa-2023/Python-Code-Large/train/row_98807:If_L157_C12", "vector": [4, 6, 0.7465, 0.0279, 6, 0.31, 0.0, 0, 3, 0, 0, 0, 0, 0, 8], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if isinstance(self.field, models.DateTimeField):\n objs = capfirst(formats.date_format(self.raw_value, 'DATETIME_FORMAT'))\n elif isinstance(self.field, models.TimeField):\n objs = capfirst(formats.time_format(self.raw_value, 'TIME_FORMAT'))\n else:\n objs = capfirst(formats.date_format(self.raw_value, 'DATE_FORMAT'))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98807:Assign_L159_C20", "label": "objs = capfirst()", "type": "assigned_variable", "loc": [159, 159], "level": 7, "parent": "ajibawa-2023/Python-Code-Large/train/row_98807:If_L158_C16", "vector": [14, 7, 0.7395, 0.0047, 7, 0.93, 0.0, 794, 3, 1, 0, 0, 561, 10, 2], "semantic": {"name": "objs", "arg_names": [], "import_names": [], "rhs_call_name": "capfirst", "annotation": ""}, "snippet": " objs = capfirst(formats.date_format(self.raw_value, 'DATETIME_FORMAT'))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98807:If_L160_C16", "label": "if", "type": "if", "loc": [160, 163], "level": 7, "parent": "ajibawa-2023/Python-Code-Large/train/row_98807:If_L158_C16", "vector": [4, 7, 0.7512, 0.0186, 7, 0.93, 1.0, 0, 3, 0, 0, 0, 0, 0, 5], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " elif isinstance(self.field, models.TimeField):\n objs = capfirst(formats.time_format(self.raw_value, 'TIME_FORMAT'))\n else:\n objs = capfirst(formats.date_format(self.raw_value, 'DATE_FORMAT'))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98807:Assign_L161_C20", "label": "objs = capfirst()", "type": "assigned_variable", "loc": [161, 161], "level": 8, "parent": "ajibawa-2023/Python-Code-Large/train/row_98807:If_L160_C16", "vector": [14, 8, 0.7488, 0.0047, 8, 0.39, 0.0, 794, 3, 1, 0, 0, 561, 10, 2], "semantic": {"name": "objs", "arg_names": [], "import_names": [], "rhs_call_name": "capfirst", "annotation": ""}, "snippet": " objs = capfirst(formats.time_format(self.raw_value, 'TIME_FORMAT'))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98807:Assign_L163_C20", "label": "objs = capfirst()", "type": "assigned_variable", "loc": [163, 163], "level": 8, "parent": "ajibawa-2023/Python-Code-Large/train/row_98807:If_L160_C16", "vector": [14, 8, 0.7581, 0.0047, 8, 0.39, 1.0, 794, 3, 1, 0, 0, 561, 10, 2], "semantic": {"name": "objs", "arg_names": [], "import_names": [], "rhs_call_name": "capfirst", "annotation": ""}, "snippet": " objs = capfirst(formats.date_format(self.raw_value, 'DATE_FORMAT'))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98807:Assign_L165_C16", "label": "objs =", "type": "assigned_variable", "loc": [165, 165], "level": 6, "parent": "ajibawa-2023/Python-Code-Large/train/row_98807:If_L157_C12", "vector": [14, 6, 0.7674, 0.0047, 6, 0.31, 1.0, 794, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "objs", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " objs = EMPTY_VALUE"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98807:If_L166_C8", "label": "if", "type": "if", "loc": [166, 169], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98807:If_L156_C8", "vector": [4, 5, 0.7791, 0.0186, 5, 0.2, 1.0, 0, 0, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " elif isinstance(self.field, models.BooleanField) or isinstance(self.field, models.NullBooleanField):\n objs = {True: 'Yes', False: 'No', None: 'Unknown'}[self.raw_value]\n else:\n objs = self.raw_value"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98807:Assign_L167_C12", "label": "objs =", "type": "assigned_variable", "loc": [167, 167], "level": 6, "parent": "ajibawa-2023/Python-Code-Large/train/row_98807:If_L166_C8", "vector": [14, 6, 0.7767, 0.0047, 6, 0.25, 0.0, 794, 6, 0, 0, 0, 0, 0, 0], "semantic": {"name": "objs", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " objs = {True: 'Yes', False: 'No', None: 'Unknown'}[self.raw_value]"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98807:Assign_L169_C12", "label": "objs =", "type": "assigned_variable", "loc": [169, 169], "level": 6, "parent": "ajibawa-2023/Python-Code-Large/train/row_98807:If_L166_C8", "vector": [14, 6, 0.786, 0.0047, 6, 0.25, 1.0, 794, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "objs", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " objs = self.raw_value"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98807:Return_L170_C8", "label": "return", "type": "return", "loc": [170, 170], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98807:FunctionDef_L141_C4", "vector": [13, 2, 0.7907, 0.0047, 2, 0.61, 1.0, 0, 0, 0, 0, 0, 0, 5, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return [objs]"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98807:FunctionDef_L172_C4", "label": "urls", "type": "function", "loc": [172, 201], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98807:ClassDef_L133_C0", "vector": [2, 1, 0.8674, 0.1395, 1, 0.96, 1.0, 260, 0, 1, 1, 0, 0, 0, 22], "semantic": {"name": "urls", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def urls(self):\n \"Returns a list of (value, URL) tuples.\"\n # First, check the urls() method for each plugin.\n plugin_urls = []\n for plugin_name, plugin in self.model.model_databrowse().plugins.items():\n urls = plugin.urls(plugin_name, self)\n if urls is not None:\n #plugin_urls.append(urls)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98807:Expr_L173_C8", "label": "expression", "type": "expression", "loc": [173, 173], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98807:FunctionDef_L172_C4", "vector": [8, 2, 0.8047, 0.0047, 2, 0.87, 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 (value, URL) tuples.\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98807:Assign_L175_C8", "label": "plugin_urls =", "type": "assigned_variable", "loc": [175, 175], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98807:FunctionDef_L172_C4", "vector": [14, 2, 0.814, 0.0047, 2, 0.87, 0.25, 114, 0, 0, 0, 0, 0, 5, 0], "semantic": {"name": "plugin_urls", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " plugin_urls = []"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98807:For_L176_C8", "label": "for plugin_name, plugin", "type": "for", "loc": [176, 181], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98807:FunctionDef_L172_C4", "vector": [6, 2, 0.8302, 0.0279, 2, 0.87, 0.5, 965, 3, 0, 0, 0, 0, 0, 6], "semantic": {"name": "plugin_name, plugin", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for plugin_name, plugin in self.model.model_databrowse().plugins.items():\n urls = plugin.urls(plugin_name, self)\n if urls is not None:\n #plugin_urls.append(urls)\n values = self.values()\n return zip(self.values(), urls)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98807:Assign_L177_C12", "label": "urls = urls()", "type": "assigned_variable", "loc": [177, 177], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98807:For_L176_C8", "vector": [14, 3, 0.8233, 0.0047, 3, 0.94, 0.0, 260, 3, 2, 0, 0, 260, 10, 1], "semantic": {"name": "urls", "arg_names": [], "import_names": [], "rhs_call_name": "urls", "annotation": ""}, "snippet": " urls = plugin.urls(plugin_name, self)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98807:If_L178_C12", "label": "if", "type": "if", "loc": [178, 181], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98807:For_L176_C8", "vector": [4, 3, 0.8349, 0.0186, 3, 0.94, 1.0, 0, 0, 0, 0, 0, 0, 0, 3], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if urls is not None:\n #plugin_urls.append(urls)\n values = self.values()\n return zip(self.values(), urls)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98807:Assign_L180_C16", "label": "values = values()", "type": "assigned_variable", "loc": [180, 180], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98807:If_L178_C12", "vector": [14, 4, 0.8372, 0.0047, 4, 0.1, 0.0, 721, 3, 0, 0, 0, 721, 10, 1], "semantic": {"name": "values", "arg_names": [], "import_names": [], "rhs_call_name": "values", "annotation": ""}, "snippet": " values = self.values()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98807:Return_L181_C16", "label": "return", "type": "return", "loc": [181, 181], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98807:If_L178_C12", "vector": [13, 4, 0.8419, 0.0047, 4, 0.1, 1.0, 0, 3, 0, 0, 0, 0, 10, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return zip(self.values(), urls)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98807:If_L182_C8", "label": "if", "type": "if", "loc": [182, 200], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98807:FunctionDef_L172_C4", "vector": [4, 2, 0.8884, 0.0884, 2, 0.87, 0.75, 0, 7, 0, 0, 0, 0, 0, 16], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if self.field.rel:\n m = EasyModel(self.model.site, self.field.rel.to)\n if self.field.rel.to in self.model.model_list:\n lst = []\n for value in self.values():\n url = mark_safe('%s%s/%s/objects/%s/' % (self.model.site.root_url, m.model._meta.app_label, m.model._meta.module_name, iri_to_uri(value._get_pk_val())))\n lst.append((smart_unicode(value), url))\n else:"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98807:Assign_L183_C12", "label": "m = EasyModel()", "type": "assigned_variable", "loc": [183, 183], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98807:If_L182_C8", "vector": [14, 3, 0.8512, 0.0047, 3, 0.1, 0.0, 711, 3, 2, 0, 0, 749, 10, 1], "semantic": {"name": "m", "arg_names": [], "import_names": [], "rhs_call_name": "EasyModel", "annotation": ""}, "snippet": " m = EasyModel(self.model.site, self.field.rel.to)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98807:If_L184_C12", "label": "if", "type": "if", "loc": [184, 190], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98807:If_L182_C8", "vector": [4, 3, 0.8698, 0.0326, 3, 0.1, 0.5, 0, 0, 0, 0, 0, 0, 0, 7], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if self.field.rel.to in self.model.model_list:\n lst = []\n for value in self.values():\n url = mark_safe('%s%s/%s/objects/%s/' % (self.model.site.root_url, m.model._meta.app_label, m.model._meta.module_name, iri_to_uri(value._get_pk_val())))\n lst.append((smart_unicode(value), url))\n else:\n lst = [(value, None) for value in self.values()]"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98807:Assign_L185_C16", "label": "lst =", "type": "assigned_variable", "loc": [185, 185], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98807:If_L184_C12", "vector": [14, 4, 0.8605, 0.0047, 4, 0.52, 0.0, 564, 0, 0, 0, 0, 0, 5, 0], "semantic": {"name": "lst", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " lst = []"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98807:For_L186_C16", "label": "for value", "type": "for", "loc": [186, 188], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98807:If_L184_C12", "vector": [6, 4, 0.8698, 0.014, 4, 0.52, 0.5, 441, 3, 0, 0, 0, 0, 0, 6], "semantic": {"name": "value", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for value in self.values():\n url = mark_safe('%s%s/%s/objects/%s/' % (self.model.site.root_url, m.model._meta.app_label, m.model._meta.module_name, iri_to_uri(value._get_pk_val())))\n lst.append((smart_unicode(value), url))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98807:Assign_L187_C20", "label": "url = mark_safe()", "type": "assigned_variable", "loc": [187, 187], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98807:For_L186_C16", "vector": [14, 5, 0.8698, 0.0047, 5, 0.5, 0.0, 789, 3, 1, 0, 0, 159, 10, 3], "semantic": {"name": "url", "arg_names": [], "import_names": [], "rhs_call_name": "mark_safe", "annotation": ""}, "snippet": " url = mark_safe('%s%s/%s/objects/%s/' % (self.model.site.root_url, m.model._meta.app_label, m.model._meta.module_name, iri_to_uri(value._get_pk_val())))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98807:Expr_L188_C20", "label": "append()", "type": "expression", "loc": [188, 188], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98807:For_L186_C16", "vector": [8, 5, 0.8744, 0.0047, 5, 0.5, 1.0, 243, 3, 1, 0, 0, 0, 0, 2], "semantic": {"name": "append", "arg_names": [], "import_names": [], "rhs_call_name": "append", "annotation": ""}, "snippet": " lst.append((smart_unicode(value), url))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98807:Assign_L190_C16", "label": "lst =", "type": "assigned_variable", "loc": [190, 190], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98807:If_L184_C12", "vector": [14, 4, 0.8837, 0.0047, 4, 0.52, 1.0, 564, 5, 0, 0, 0, 0, 0, 1], "semantic": {"name": "lst", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " lst = [(value, None) for value in self.values()]"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98807:If_L191_C8", "label": "if", "type": "if", "loc": [191, 200], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98807:If_L182_C8", "vector": [4, 3, 0.9093, 0.0465, 3, 0.1, 1.0, 0, 7, 0, 0, 0, 0, 0, 8], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " elif self.field.choices:\n lst = []\n for value in self.values():\n url = mark_safe('%s%s/%s/fields/%s/%s/' % (self.model.site.root_url, self.model.model._meta.app_label, self.model.model._meta.module_name, self.field.name, iri_to_uri(self.raw_value)))\n lst.append((value, url))\n elif isinstance(self.field, models.URLField):\n val = self.values()[0]\n lst = [(val, iri_to_uri(val))]"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98807:Assign_L192_C12", "label": "lst =", "type": "assigned_variable", "loc": [192, 192], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98807:If_L191_C8", "vector": [14, 4, 0.893, 0.0047, 4, 0.9, 0.0, 564, 0, 0, 0, 0, 0, 5, 0], "semantic": {"name": "lst", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " lst = []"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98807:For_L193_C12", "label": "for value", "type": "for", "loc": [193, 195], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98807:If_L191_C8", "vector": [6, 4, 0.9023, 0.014, 4, 0.9, 0.5, 441, 3, 0, 0, 0, 0, 0, 4], "semantic": {"name": "value", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for value in self.values():\n url = mark_safe('%s%s/%s/fields/%s/%s/' % (self.model.site.root_url, self.model.model._meta.app_label, self.model.model._meta.module_name, self.field.name, iri_to_uri(self.raw_value)))\n lst.append((value, url))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98807:Assign_L194_C16", "label": "url = mark_safe()", "type": "assigned_variable", "loc": [194, 194], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98807:For_L193_C12", "vector": [14, 5, 0.9023, 0.0047, 5, 0.12, 0.0, 789, 3, 1, 0, 0, 159, 10, 2], "semantic": {"name": "url", "arg_names": [], "import_names": [], "rhs_call_name": "mark_safe", "annotation": ""}, "snippet": " url = mark_safe('%s%s/%s/fields/%s/%s/' % (self.model.site.root_url, self.model.model._meta.app_label, self.model.model._meta.module_name, self.field.name, iri_to_uri(self.raw_value)))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98807:Expr_L195_C16", "label": "append()", "type": "expression", "loc": [195, 195], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98807:For_L193_C12", "vector": [8, 5, 0.907, 0.0047, 5, 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": " lst.append((value, url))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98807:If_L196_C8", "label": "if", "type": "if", "loc": [196, 200], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98807:If_L191_C8", "vector": [4, 4, 0.9209, 0.0233, 4, 0.9, 1.0, 0, 3, 0, 0, 0, 0, 0, 4], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " elif isinstance(self.field, models.URLField):\n val = self.values()[0]\n lst = [(val, iri_to_uri(val))]\n else:\n lst = [(self.values()[0], None)]"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98807:Assign_L197_C12", "label": "val =", "type": "assigned_variable", "loc": [197, 197], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98807:If_L196_C8", "vector": [14, 5, 0.9163, 0.0047, 5, 0.01, 0.0, 618, 6, 0, 0, 0, 0, 0, 1], "semantic": {"name": "val", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " val = self.values()[0]"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98807:Assign_L198_C12", "label": "lst =", "type": "assigned_variable", "loc": [198, 198], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98807:If_L196_C8", "vector": [14, 5, 0.9209, 0.0047, 5, 0.01, 0.5, 564, 0, 0, 0, 0, 0, 5, 1], "semantic": {"name": "lst", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " lst = [(val, iri_to_uri(val))]"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98807:Assign_L200_C12", "label": "lst =", "type": "assigned_variable", "loc": [200, 200], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98807:If_L196_C8", "vector": [14, 5, 0.9302, 0.0047, 5, 0.01, 1.0, 564, 0, 0, 0, 0, 0, 5, 1], "semantic": {"name": "lst", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " lst = [(self.values()[0], None)]"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98807:Return_L201_C8", "label": "return", "type": "return", "loc": [201, 201], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98807:FunctionDef_L172_C4", "vector": [13, 2, 0.9349, 0.0047, 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 lst"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98807:ClassDef_L203_C0", "label": "EasyQuerySet", "type": "class", "loc": [203, 215], "level": 0, "parent": null, "vector": [3, 0, 0.9721, 0.0605, 0, 0.66, 1.0, 315, 0, 2, 0, 0, 78, 0, 5], "semantic": {"name": "EasyQuerySet", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class EasyQuerySet(QuerySet):\n \"\"\"\n When creating (or cloning to) an `EasyQuerySet`, make sure to set the\n `_easymodel` variable to the related `EasyModel`.\n \"\"\"\n def iterator(self, *args, **kwargs):\n for obj in super(EasyQuerySet, self).iterator(*args, **kwargs):\n yield EasyInstance(self._easymodel, obj)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98807:Expr_L204_C4", "label": "expression", "type": "expression", "loc": [204, 207], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98807:ClassDef_L203_C0", "vector": [8, 1, 0.9558, 0.0186, 1, 0.21, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"\n When creating (or cloning to) an `EasyQuerySet`, make sure to set the\n `_easymodel` variable to the related `EasyModel`.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98807:FunctionDef_L208_C4", "label": "iterator", "type": "function", "loc": [208, 210], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98807:ClassDef_L203_C0", "vector": [2, 1, 0.9721, 0.014, 1, 0.21, 0.5, 829, 0, 3, 0, 0, 0, 0, 3], "semantic": {"name": "iterator", "arg_names": ["self", "args", "kwargs"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def iterator(self, *args, **kwargs):\n for obj in super(EasyQuerySet, self).iterator(*args, **kwargs):\n yield EasyInstance(self._easymodel, obj)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98807:For_L209_C8", "label": "for obj", "type": "for", "loc": [209, 210], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98807:FunctionDef_L208_C4", "vector": [6, 2, 0.9744, 0.0093, 2, 0.45, 0.0, 505, 3, 0, 0, 0, 0, 0, 3], "semantic": {"name": "obj", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for obj in super(EasyQuerySet, self).iterator(*args, **kwargs):\n yield EasyInstance(self._easymodel, obj)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98807:Expr_L210_C12", "label": "expression", "type": "expression", "loc": [210, 210], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98807:For_L209_C8", "vector": [8, 3, 0.9767, 0.0047, 3, 0.97, 0.0, 0, 0, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " yield EasyInstance(self._easymodel, obj)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98807:FunctionDef_L212_C4", "label": "_clone", "type": "function", "loc": [212, 215], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98807:ClassDef_L203_C0", "vector": [2, 1, 0.993, 0.0186, 1, 0.21, 1.0, 617, 0, 3, 1, 0, 0, 0, 2], "semantic": {"name": "_clone", "arg_names": ["self", "args", "kwargs"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def _clone(self, *args, **kwargs):\n c = super(EasyQuerySet, self)._clone(*args, **kwargs)\n c._easymodel = self._easymodel\n return c"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98807:Assign_L213_C8", "label": "c = _clone()", "type": "assigned_variable", "loc": [213, 213], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98807:FunctionDef_L212_C4", "vector": [14, 2, 0.9907, 0.0047, 2, 0.06, 0.0, 411, 3, 2, 0, 0, 617, 10, 2], "semantic": {"name": "c", "arg_names": [], "import_names": [], "rhs_call_name": "_clone", "annotation": ""}, "snippet": " c = super(EasyQuerySet, self)._clone(*args, **kwargs)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98807:Assign_L214_C8", "label": "c._easymodel =", "type": "assigned_variable", "loc": [214, 214], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98807:FunctionDef_L212_C4", "vector": [14, 2, 0.9953, 0.0047, 2, 0.06, 0.5, 435, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "c._easymodel", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " c._easymodel = self._easymodel"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98807:Return_L215_C8", "label": "return", "type": "return", "loc": [215, 215], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98807:FunctionDef_L212_C4", "vector": [13, 2, 1.0, 0.0047, 2, 0.06, 1.0, 0, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return c"}]
[{"f": "ajibawa-2023/Python-Code-Large/train/row_98807:ClassDef_L16_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98807:FunctionDef_L17_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98807:FunctionDef_L17_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98807:Assign_L18_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98807:FunctionDef_L17_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98807:Assign_L19_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98807:FunctionDef_L17_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98807:Assign_L20_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98807:FunctionDef_L17_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98807:Assign_L21_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98807:FunctionDef_L17_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98807:Assign_L22_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98807:ClassDef_L16_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98807:FunctionDef_L24_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98807:FunctionDef_L24_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98807:Return_L25_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98807:ClassDef_L16_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98807:FunctionDef_L27_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98807:FunctionDef_L27_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98807:Expr_L28_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98807:FunctionDef_L27_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98807:Return_L29_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98807:ClassDef_L16_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98807:FunctionDef_L31_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98807:FunctionDef_L31_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98807:Return_L32_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98807:ClassDef_L16_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98807:FunctionDef_L34_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98807:FunctionDef_L34_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98807:Return_L35_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98807:ClassDef_L16_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98807:FunctionDef_L37_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98807:FunctionDef_L37_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98807:Assign_L38_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98807:FunctionDef_L37_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98807:Assign_L39_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98807:FunctionDef_L37_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98807:Return_L40_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98807:ClassDef_L16_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98807:FunctionDef_L42_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98807:FunctionDef_L42_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98807:Return_L43_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98807:ClassDef_L16_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98807:FunctionDef_L45_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98807:FunctionDef_L45_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98807:For_L46_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98807:For_L46_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98807:Expr_L47_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98807:ClassDef_L16_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98807:FunctionDef_L49_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98807:FunctionDef_L49_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98807:Try_L50_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98807:Try_L50_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98807:Assign_L51_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98807:Try_L50_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98807:Return_L53_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98807:FunctionDef_L49_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98807:Return_L54_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98807:ClassDef_L16_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98807:FunctionDef_L56_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98807:FunctionDef_L56_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98807:Return_L57_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98807:ClassDef_L59_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98807:FunctionDef_L60_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98807:FunctionDef_L60_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98807:Assign_L61_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98807:ClassDef_L59_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98807:FunctionDef_L63_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98807:FunctionDef_L63_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98807:Return_L64_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98807:ClassDef_L59_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98807:FunctionDef_L66_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98807:FunctionDef_L66_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98807:For_L67_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98807:For_L67_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98807:Expr_L68_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98807:ClassDef_L59_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98807:FunctionDef_L70_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98807:FunctionDef_L70_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98807:If_L71_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98807:If_L71_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98807:Return_L72_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98807:If_L71_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98807:If_L73_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98807:If_L73_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98807:Return_L74_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98807:ClassDef_L76_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98807:FunctionDef_L77_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98807:FunctionDef_L77_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98807:Assign_L78_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98807:FunctionDef_L77_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98807:Assign_L79_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98807:ClassDef_L76_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98807:FunctionDef_L81_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98807:FunctionDef_L81_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98807:Return_L82_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98807:ClassDef_L76_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98807:FunctionDef_L84_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98807:FunctionDef_L84_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98807:Return_L85_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98807:ClassDef_L87_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98807:FunctionDef_L88_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98807:FunctionDef_L88_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98807:Assign_L89_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98807:ClassDef_L87_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98807:FunctionDef_L91_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98807:FunctionDef_L91_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98807:Return_L92_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98807:ClassDef_L87_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98807:FunctionDef_L94_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98807:FunctionDef_L94_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98807:Assign_L95_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98807:FunctionDef_L94_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98807:If_L96_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98807:If_L96_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98807:Return_L97_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98807:FunctionDef_L94_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98807:Return_L98_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98807:ClassDef_L87_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98807:FunctionDef_L100_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98807:FunctionDef_L100_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98807:Return_L101_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98807:ClassDef_L87_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98807:FunctionDef_L103_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98807:FunctionDef_L103_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98807:Return_L104_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98807:ClassDef_L87_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98807:FunctionDef_L106_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98807:FunctionDef_L106_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98807:Return_L107_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98807:ClassDef_L87_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98807:FunctionDef_L109_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98807:FunctionDef_L109_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98807:Expr_L110_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98807:FunctionDef_L109_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98807:For_L114_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98807:For_L114_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98807:Expr_L115_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98807:ClassDef_L87_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98807:FunctionDef_L117_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98807:FunctionDef_L117_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98807:Expr_L118_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98807:FunctionDef_L117_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98807:For_L123_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98807:For_L123_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98807:If_L124_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98807:For_L123_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98807:Assign_L126_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98807:For_L123_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98807:Expr_L127_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98807:ClassDef_L133_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98807:FunctionDef_L134_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98807:FunctionDef_L134_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98807:Assign_L135_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98807:FunctionDef_L134_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98807:Assign_L136_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98807:ClassDef_L133_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98807:FunctionDef_L138_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98807:FunctionDef_L138_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98807:Return_L139_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98807:ClassDef_L133_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98807:FunctionDef_L141_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98807:FunctionDef_L141_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98807:Expr_L142_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98807:FunctionDef_L141_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98807:If_L149_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98807:If_L149_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98807:If_L150_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98807:If_L150_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98807:Assign_L151_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98807:If_L150_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98807:If_L152_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98807:If_L152_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98807:Return_L153_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98807:If_L149_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98807:If_L154_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98807:If_L154_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98807:Assign_L155_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98807:If_L154_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98807:If_L156_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98807:If_L156_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98807:If_L157_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98807:If_L157_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98807:If_L158_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98807:If_L158_C16", "t": "ajibawa-2023/Python-Code-Large/train/row_98807:Assign_L159_C20"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98807:If_L158_C16", "t": "ajibawa-2023/Python-Code-Large/train/row_98807:If_L160_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98807:If_L160_C16", "t": "ajibawa-2023/Python-Code-Large/train/row_98807:Assign_L161_C20"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98807:If_L160_C16", "t": "ajibawa-2023/Python-Code-Large/train/row_98807:Assign_L163_C20"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98807:If_L157_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98807:Assign_L165_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98807:If_L156_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98807:If_L166_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98807:If_L166_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98807:Assign_L167_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98807:If_L166_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98807:Assign_L169_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98807:FunctionDef_L141_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98807:Return_L170_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98807:ClassDef_L133_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98807:FunctionDef_L172_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98807:FunctionDef_L172_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98807:Expr_L173_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98807:FunctionDef_L172_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98807:Assign_L175_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98807:FunctionDef_L172_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98807:For_L176_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98807:For_L176_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98807:Assign_L177_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98807:For_L176_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98807:If_L178_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98807:If_L178_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98807:Assign_L180_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98807:If_L178_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98807:Return_L181_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98807:FunctionDef_L172_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98807:If_L182_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98807:If_L182_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98807:Assign_L183_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98807:If_L182_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98807:If_L184_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98807:If_L184_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98807:Assign_L185_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98807:If_L184_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98807:For_L186_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98807:For_L186_C16", "t": "ajibawa-2023/Python-Code-Large/train/row_98807:Assign_L187_C20"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98807:For_L186_C16", "t": "ajibawa-2023/Python-Code-Large/train/row_98807:Expr_L188_C20"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98807:If_L184_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98807:Assign_L190_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98807:If_L182_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98807:If_L191_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98807:If_L191_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98807:Assign_L192_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98807:If_L191_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98807:For_L193_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98807:For_L193_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98807:Assign_L194_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98807:For_L193_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98807:Expr_L195_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98807:If_L191_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98807:If_L196_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98807:If_L196_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98807:Assign_L197_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98807:If_L196_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98807:Assign_L198_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98807:If_L196_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98807:Assign_L200_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98807:FunctionDef_L172_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98807:Return_L201_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98807:ClassDef_L203_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98807:Expr_L204_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98807:ClassDef_L203_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98807:FunctionDef_L208_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98807:FunctionDef_L208_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98807:For_L209_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98807:For_L209_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98807:Expr_L210_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98807:ClassDef_L203_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98807:FunctionDef_L212_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98807:FunctionDef_L212_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98807:Assign_L213_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98807:FunctionDef_L212_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98807:Assign_L214_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98807:FunctionDef_L212_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98807:Return_L215_C8"}]
# -*- coding: utf-8 -*- import unittest from django.contrib.webdesign.lorem_ipsum import * from django.template import loader, Context class WebdesignTest(unittest.TestCase): def test_words(self): self.assertEqual(words(7), u'lorem ipsum dolor sit amet consectetur adipisicing') def test_paragraphs(self): self.assertEqual(paragraphs(1), ['Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.']) def test_lorem_tag(self): t = loader.get_template_from_string("{% load webdesign %}{% lorem 3 w %}") self.assertEqual(t.render(Context({})), u'lorem ipsum dolor')
ajibawa-2023/Python-Code-Large/train/row_98808
11
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_98808:Import_L3_C0", "label": "unittest import unittest", "type": "import", "loc": [3, 3], "level": 0, "parent": null, "vector": [1, 0, 0.1429, 0.0476, 0, 0.66, 0.0, 88, 0, 1, 0, 0, 88, 0, 0], "semantic": {"name": "unittest", "arg_names": [], "import_names": ["unittest"], "rhs_call_name": "", "annotation": ""}, "snippet": "import unittest"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98808:ImportFrom_L5_C0", "label": "from django.contrib.webdesign.lorem_ipsum import *", "type": "import", "loc": [5, 5], "level": 0, "parent": null, "vector": [1, 0, 0.2381, 0.0476, 0, 0.66, 0.3333, 74, 0, 1, 0, 0, 74, 0, 0], "semantic": {"name": "django.contrib.webdesign.lorem_ipsum", "arg_names": [], "import_names": ["*"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.contrib.webdesign.lorem_ipsum import *"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98808:ImportFrom_L6_C0", "label": "from django.template import loader, Context", "type": "import", "loc": [6, 6], "level": 0, "parent": null, "vector": [1, 0, 0.2857, 0.0476, 0, 0.66, 0.6667, 213, 0, 2, 0, 0, 213, 0, 0], "semantic": {"name": "django.template", "arg_names": [], "import_names": ["loader", "Context"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.template import loader, Context"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98808:ClassDef_L9_C0", "label": "WebdesignTest", "type": "class", "loc": [9, 21], "level": 0, "parent": null, "vector": [3, 0, 0.7143, 0.619, 0, 0.66, 1.0, 125, 0, 3, 0, 0, 878, 0, 8], "semantic": {"name": "WebdesignTest", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class WebdesignTest(unittest.TestCase):\n\n def test_words(self):\n self.assertEqual(words(7), u'lorem ipsum dolor sit amet consectetur adipisicing')\n\n def test_paragraphs(self):\n self.assertEqual(paragraphs(1),\n ['Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.'])"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98808:FunctionDef_L11_C4", "label": "test_words", "type": "function", "loc": [11, 12], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98808:ClassDef_L9_C0", "vector": [2, 1, 0.5476, 0.0952, 1, 0.67, 0.0, 567, 0, 1, 0, 0, 0, 0, 2], "semantic": {"name": "test_words", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def test_words(self):\n self.assertEqual(words(7), u'lorem ipsum dolor sit amet consectetur adipisicing')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98808:Expr_L12_C8", "label": "assertEqual()", "type": "expression", "loc": [12, 12], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98808:FunctionDef_L11_C4", "vector": [8, 2, 0.5714, 0.0476, 2, 0.9, 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(words(7), u'lorem ipsum dolor sit amet consectetur adipisicing')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98808:FunctionDef_L14_C4", "label": "test_paragraphs", "type": "function", "loc": [14, 16], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98808:ClassDef_L9_C0", "vector": [2, 1, 0.7143, 0.1429, 1, 0.67, 0.5, 147, 0, 1, 0, 0, 0, 0, 2], "semantic": {"name": "test_paragraphs", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def test_paragraphs(self):\n self.assertEqual(paragraphs(1),\n ['Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.'])"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98808:Expr_L15_C8", "label": "assertEqual()", "type": "expression", "loc": [15, 16], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98808:FunctionDef_L14_C4", "vector": [8, 2, 0.7381, 0.0952, 2, 0.09, 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(paragraphs(1),\n ['Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.'])"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98808:FunctionDef_L18_C4", "label": "test_lorem_tag", "type": "function", "loc": [18, 21], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98808:ClassDef_L9_C0", "vector": [2, 1, 0.9286, 0.1905, 1, 0.67, 1.0, 207, 0, 1, 0, 0, 0, 0, 4], "semantic": {"name": "test_lorem_tag", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def test_lorem_tag(self):\n t = loader.get_template_from_string(\"{% load webdesign %}{% lorem 3 w %}\")\n self.assertEqual(t.render(Context({})),\n u'lorem ipsum dolor')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98808:Assign_L19_C8", "label": "t = get_template_from_string()", "type": "assigned_variable", "loc": [19, 19], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98808:FunctionDef_L18_C4", "vector": [14, 2, 0.9048, 0.0476, 2, 0.65, 0.0, 15, 3, 1, 0, 0, 813, 10, 1], "semantic": {"name": "t", "arg_names": [], "import_names": [], "rhs_call_name": "get_template_from_string", "annotation": ""}, "snippet": " t = loader.get_template_from_string(\"{% load webdesign %}{% lorem 3 w %}\")"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98808:Expr_L20_C8", "label": "assertEqual()", "type": "expression", "loc": [20, 21], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98808:FunctionDef_L18_C4", "vector": [8, 2, 0.9762, 0.0952, 2, 0.65, 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(t.render(Context({})),\n u'lorem ipsum dolor')"}]
[{"f": "ajibawa-2023/Python-Code-Large/train/row_98808:ClassDef_L9_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98808:FunctionDef_L11_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98808:FunctionDef_L11_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98808:Expr_L12_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98808:ClassDef_L9_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98808:FunctionDef_L14_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98808:FunctionDef_L14_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98808:Expr_L15_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98808:ClassDef_L9_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98808:FunctionDef_L18_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98808:FunctionDef_L18_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98808:Assign_L19_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98808:FunctionDef_L18_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98808:Expr_L20_C8"}]
""" Utility functions for generating "lorem ipsum" Latin text. """ import random COMMON_P = 'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.' WORDS = ('exercitationem', 'perferendis', 'perspiciatis', 'laborum', 'eveniet', 'sunt', 'iure', 'nam', 'nobis', 'eum', 'cum', 'officiis', 'excepturi', 'odio', 'consectetur', 'quasi', 'aut', 'quisquam', 'vel', 'eligendi', 'itaque', 'non', 'odit', 'tempore', 'quaerat', 'dignissimos', 'facilis', 'neque', 'nihil', 'expedita', 'vitae', 'vero', 'ipsum', 'nisi', 'animi', 'cumque', 'pariatur', 'velit', 'modi', 'natus', 'iusto', 'eaque', 'sequi', 'illo', 'sed', 'ex', 'et', 'voluptatibus', 'tempora', 'veritatis', 'ratione', 'assumenda', 'incidunt', 'nostrum', 'placeat', 'aliquid', 'fuga', 'provident', 'praesentium', 'rem', 'necessitatibus', 'suscipit', 'adipisci', 'quidem', 'possimus', 'voluptas', 'debitis', 'sint', 'accusantium', 'unde', 'sapiente', 'voluptate', 'qui', 'aspernatur', 'laudantium', 'soluta', 'amet', 'quo', 'aliquam', 'saepe', 'culpa', 'libero', 'ipsa', 'dicta', 'reiciendis', 'nesciunt', 'doloribus', 'autem', 'impedit', 'minima', 'maiores', 'repudiandae', 'ipsam', 'obcaecati', 'ullam', 'enim', 'totam', 'delectus', 'ducimus', 'quis', 'voluptates', 'dolores', 'molestiae', 'harum', 'dolorem', 'quia', 'voluptatem', 'molestias', 'magni', 'distinctio', 'omnis', 'illum', 'dolorum', 'voluptatum', 'ea', 'quas', 'quam', 'corporis', 'quae', 'blanditiis', 'atque', 'deserunt', 'laboriosam', 'earum', 'consequuntur', 'hic', 'cupiditate', 'quibusdam', 'accusamus', 'ut', 'rerum', 'error', 'minus', 'eius', 'ab', 'ad', 'nemo', 'fugit', 'officia', 'at', 'in', 'id', 'quos', 'reprehenderit', 'numquam', 'iste', 'fugiat', 'sit', 'inventore', 'beatae', 'repellendus', 'magnam', 'recusandae', 'quod', 'explicabo', 'doloremque', 'aperiam', 'consequatur', 'asperiores', 'commodi', 'optio', 'dolor', 'labore', 'temporibus', 'repellat', 'veniam', 'architecto', 'est', 'esse', 'mollitia', 'nulla', 'a', 'similique', 'eos', 'alias', 'dolore', 'tenetur', 'deleniti', 'porro', 'facere', 'maxime', 'corrupti') COMMON_WORDS = ('lorem', 'ipsum', 'dolor', 'sit', 'amet', 'consectetur', 'adipisicing', 'elit', 'sed', 'do', 'eiusmod', 'tempor', 'incididunt', 'ut', 'labore', 'et', 'dolore', 'magna', 'aliqua') def sentence(): """ Returns a randomly generated sentence of lorem ipsum text. The first word is capitalized, and the sentence ends in either a period or question mark. Commas are added at random. """ # Determine the number of comma-separated sections and number of words in # each section for this sentence. sections = [u' '.join(random.sample(WORDS, random.randint(3, 12))) for i in range(random.randint(1, 5))] s = u', '.join(sections) # Convert to sentence case and add end punctuation. return u'%s%s%s' % (s[0].upper(), s[1:], random.choice('?.')) def paragraph(): """ Returns a randomly generated paragraph of lorem ipsum text. The paragraph consists of between 1 and 4 sentences, inclusive. """ return u' '.join([sentence() for i in range(random.randint(1, 4))]) def paragraphs(count, common=True): """ Returns a list of paragraphs as returned by paragraph(). If `common` is True, then the first paragraph will be the standard 'lorem ipsum' paragraph. Otherwise, the first paragraph will be random Latin text. Either way, subsequent paragraphs will be random Latin text. """ paras = [] for i in range(count): if common and i == 0: paras.append(COMMON_P) else: paras.append(paragraph()) return paras def words(count, common=True): """ Returns a string of `count` lorem ipsum words separated by a single space. If `common` is True, then the first 19 words will be the standard 'lorem ipsum' words. Otherwise, all words will be selected randomly. """ if common: word_list = list(COMMON_WORDS) else: word_list = [] c = len(word_list) if count > c: count -= c while count > 0: c = min(count, len(WORDS)) count -= c word_list += random.sample(WORDS, c) else: word_list = word_list[:count] return u' '.join(word_list)
ajibawa-2023/Python-Code-Large/train/row_98809
32
101
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_98809:Expr_L1_C0", "label": "expression", "type": "expression", "loc": [1, 3], "level": 0, "parent": null, "vector": [8, 0, 0.0198, 0.0297, 0, 0.66, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "\"\"\"\nUtility functions for generating \"lorem ipsum\" Latin text.\n\"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98809:Import_L5_C0", "label": "random import random", "type": "import", "loc": [5, 5], "level": 0, "parent": null, "vector": [1, 0, 0.0495, 0.0099, 0, 0.66, 0.125, 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_98809:Assign_L7_C0", "label": "COMMON_P =", "type": "assigned_variable", "loc": [7, 7], "level": 0, "parent": null, "vector": [14, 0, 0.0693, 0.0099, 0, 0.66, 0.25, 117, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "COMMON_P", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "COMMON_P = 'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.'"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98809:Assign_L9_C0", "label": "WORDS =", "type": "assigned_variable", "loc": [9, 37], "level": 0, "parent": null, "vector": [14, 0, 0.2277, 0.2871, 0, 0.66, 0.375, 851, 0, 0, 0, 0, 0, 8, 0], "semantic": {"name": "WORDS", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "WORDS = ('exercitationem', 'perferendis', 'perspiciatis', 'laborum', 'eveniet',\n 'sunt', 'iure', 'nam', 'nobis', 'eum', 'cum', 'officiis', 'excepturi',\n 'odio', 'consectetur', 'quasi', 'aut', 'quisquam', 'vel', 'eligendi',\n 'itaque', 'non', 'odit', 'tempore', 'quaerat', 'dignissimos',\n 'facilis', 'neque', 'nihil', 'expedita', 'vitae', 'vero', 'ipsum',\n 'nisi', 'animi', 'cumque', 'pariatur', 'velit', 'modi', 'natus',\n 'iusto', 'eaque', 'sequi', 'illo', 'sed', 'ex', 'et', 'voluptatibus',\n 'tempora', 'veritatis', 'ratione', 'assumenda', 'incidunt', 'nostrum',"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98809:Assign_L39_C0", "label": "COMMON_WORDS =", "type": "assigned_variable", "loc": [39, 41], "level": 0, "parent": null, "vector": [14, 0, 0.396, 0.0297, 0, 0.66, 0.5, 520, 0, 0, 0, 0, 0, 8, 0], "semantic": {"name": "COMMON_WORDS", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "COMMON_WORDS = ('lorem', 'ipsum', 'dolor', 'sit', 'amet', 'consectetur',\n 'adipisicing', 'elit', 'sed', 'do', 'eiusmod', 'tempor', 'incididunt',\n 'ut', 'labore', 'et', 'dolore', 'magna', 'aliqua')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98809:FunctionDef_L43_C0", "label": "sentence", "type": "function", "loc": [43, 55], "level": 0, "parent": null, "vector": [2, 0, 0.4851, 0.1287, 0, 0.66, 0.625, 42, 0, 0, 1, 0, 0, 0, 8], "semantic": {"name": "sentence", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "def sentence():\n \"\"\"\n Returns a randomly generated sentence of lorem ipsum text.\n\n The first word is capitalized, and the sentence ends in either a period or\n question mark. Commas are added at random.\n \"\"\"\n # Determine the number of comma-separated sections and number of words in"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98809:Expr_L44_C4", "label": "expression", "type": "expression", "loc": [44, 49], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98809:FunctionDef_L43_C0", "vector": [8, 1, 0.4604, 0.0594, 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 Returns a randomly generated sentence of lorem ipsum text.\n\n The first word is capitalized, and the sentence ends in either a period or\n question mark. Commas are added at random.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98809:Assign_L52_C4", "label": "sections =", "type": "assigned_variable", "loc": [52, 52], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98809:FunctionDef_L43_C0", "vector": [14, 1, 0.5149, 0.0099, 1, 0.16, 0.3333, 190, 5, 0, 0, 0, 0, 0, 5], "semantic": {"name": "sections", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " sections = [u' '.join(random.sample(WORDS, random.randint(3, 12))) for i in range(random.randint(1, 5))]"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98809:Assign_L53_C4", "label": "s = join()", "type": "assigned_variable", "loc": [53, 53], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98809:FunctionDef_L43_C0", "vector": [14, 1, 0.5248, 0.0099, 1, 0.16, 0.6667, 553, 3, 1, 0, 0, 933, 10, 1], "semantic": {"name": "s", "arg_names": [], "import_names": [], "rhs_call_name": "join", "annotation": ""}, "snippet": " s = u', '.join(sections)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98809:Return_L55_C4", "label": "return", "type": "return", "loc": [55, 55], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98809:FunctionDef_L43_C0", "vector": [13, 1, 0.5446, 0.0099, 1, 0.16, 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%s' % (s[0].upper(), s[1:], random.choice('?.'))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98809:FunctionDef_L57_C0", "label": "paragraph", "type": "function", "loc": [57, 63], "level": 0, "parent": null, "vector": [2, 0, 0.5941, 0.0693, 0, 0.66, 0.75, 446, 0, 0, 1, 0, 0, 0, 4], "semantic": {"name": "paragraph", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "def paragraph():\n \"\"\"\n Returns a randomly generated paragraph of lorem ipsum text.\n\n The paragraph consists of between 1 and 4 sentences, inclusive.\n \"\"\"\n return u' '.join([sentence() for i in range(random.randint(1, 4))])"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98809:Expr_L58_C4", "label": "expression", "type": "expression", "loc": [58, 62], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98809:FunctionDef_L57_C0", "vector": [8, 1, 0.5941, 0.0495, 1, 0.75, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"\n Returns a randomly generated paragraph of lorem ipsum text.\n\n The paragraph consists of between 1 and 4 sentences, inclusive.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98809:Return_L63_C4", "label": "return", "type": "return", "loc": [63, 63], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98809:FunctionDef_L57_C0", "vector": [13, 1, 0.6238, 0.0099, 1, 0.75, 1.0, 0, 3, 0, 0, 0, 0, 10, 4], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return u' '.join([sentence() for i in range(random.randint(1, 4))])"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98809:FunctionDef_L65_C0", "label": "paragraphs", "type": "function", "loc": [65, 79], "level": 0, "parent": null, "vector": [2, 0, 0.7129, 0.1485, 0, 0.66, 0.875, 140, 0, 2, 1, 0, 0, 0, 4], "semantic": {"name": "paragraphs", "arg_names": ["count", "common"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "def paragraphs(count, common=True):\n \"\"\"\n Returns a list of paragraphs as returned by paragraph().\n\n If `common` is True, then the first paragraph will be the standard\n 'lorem ipsum' paragraph. Otherwise, the first paragraph will be random\n Latin text. Either way, subsequent paragraphs will be random Latin text.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98809:Expr_L66_C4", "label": "expression", "type": "expression", "loc": [66, 72], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98809:FunctionDef_L65_C0", "vector": [8, 1, 0.6832, 0.0693, 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 list of paragraphs as returned by paragraph().\n\n If `common` is True, then the first paragraph will be the standard\n 'lorem ipsum' paragraph. Otherwise, the first paragraph will be random\n Latin text. Either way, subsequent paragraphs will be random Latin text.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98809:Assign_L73_C4", "label": "paras =", "type": "assigned_variable", "loc": [73, 73], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98809:FunctionDef_L65_C0", "vector": [14, 1, 0.7228, 0.0099, 1, 0.4, 0.3333, 76, 0, 0, 0, 0, 0, 5, 0], "semantic": {"name": "paras", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " paras = []"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98809:For_L74_C4", "label": "for i", "type": "for", "loc": [74, 78], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98809:FunctionDef_L65_C0", "vector": [6, 1, 0.7525, 0.0495, 1, 0.4, 0.6667, 826, 3, 0, 0, 0, 0, 0, 4], "semantic": {"name": "i", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for i in range(count):\n if common and i == 0:\n paras.append(COMMON_P)\n else:\n paras.append(paragraph())"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98809:If_L75_C8", "label": "if", "type": "if", "loc": [75, 78], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98809:For_L74_C4", "vector": [4, 2, 0.7574, 0.0396, 2, 0.76, 0.0, 0, 0, 0, 0, 0, 0, 0, 3], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if common and i == 0:\n paras.append(COMMON_P)\n else:\n paras.append(paragraph())"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98809:Expr_L76_C12", "label": "append()", "type": "expression", "loc": [76, 76], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98809:If_L75_C8", "vector": [8, 3, 0.7525, 0.0099, 3, 0.08, 0.0, 243, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "append", "arg_names": [], "import_names": [], "rhs_call_name": "append", "annotation": ""}, "snippet": " paras.append(COMMON_P)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98809:Expr_L78_C12", "label": "append()", "type": "expression", "loc": [78, 78], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98809:If_L75_C8", "vector": [8, 3, 0.7723, 0.0099, 3, 0.08, 1.0, 243, 3, 1, 0, 0, 0, 0, 2], "semantic": {"name": "append", "arg_names": [], "import_names": [], "rhs_call_name": "append", "annotation": ""}, "snippet": " paras.append(paragraph())"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98809:Return_L79_C4", "label": "return", "type": "return", "loc": [79, 79], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98809:FunctionDef_L65_C0", "vector": [13, 1, 0.7822, 0.0099, 1, 0.4, 1.0, 0, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return paras"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98809:FunctionDef_L81_C0", "label": "words", "type": "function", "loc": [81, 101], "level": 0, "parent": null, "vector": [2, 0, 0.901, 0.2079, 0, 0.66, 1.0, 376, 0, 2, 1, 0, 0, 0, 6], "semantic": {"name": "words", "arg_names": ["count", "common"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "def words(count, common=True):\n \"\"\"\n Returns a string of `count` lorem ipsum words separated by a single space.\n\n If `common` is True, then the first 19 words will be the standard\n 'lorem ipsum' words. Otherwise, all words will be selected randomly.\n \"\"\"\n if common:"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98809:Expr_L82_C4", "label": "expression", "type": "expression", "loc": [82, 87], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98809:FunctionDef_L81_C0", "vector": [8, 1, 0.8366, 0.0594, 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 Returns a string of `count` lorem ipsum words separated by a single space.\n\n If `common` is True, then the first 19 words will be the standard\n 'lorem ipsum' words. Otherwise, all words will be selected randomly.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98809:If_L88_C4", "label": "if", "type": "if", "loc": [88, 91], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98809:FunctionDef_L81_C0", "vector": [4, 1, 0.8861, 0.0396, 1, 0.66, 0.25, 0, 2, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if common:\n word_list = list(COMMON_WORDS)\n else:\n word_list = []"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98809:Assign_L89_C8", "label": "word_list = list()", "type": "assigned_variable", "loc": [89, 89], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98809:If_L88_C4", "vector": [14, 2, 0.8812, 0.0099, 2, 0.64, 0.0, 434, 3, 1, 0, 0, 430, 10, 1], "semantic": {"name": "word_list", "arg_names": [], "import_names": [], "rhs_call_name": "list", "annotation": ""}, "snippet": " word_list = list(COMMON_WORDS)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98809:Assign_L91_C8", "label": "word_list =", "type": "assigned_variable", "loc": [91, 91], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98809:If_L88_C4", "vector": [14, 2, 0.901, 0.0099, 2, 0.64, 1.0, 434, 0, 0, 0, 0, 0, 5, 0], "semantic": {"name": "word_list", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " word_list = []"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98809:Assign_L92_C4", "label": "c = len()", "type": "assigned_variable", "loc": [92, 92], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98809:FunctionDef_L81_C0", "vector": [14, 1, 0.9109, 0.0099, 1, 0.66, 0.5, 411, 3, 1, 0, 0, 890, 10, 1], "semantic": {"name": "c", "arg_names": [], "import_names": [], "rhs_call_name": "len", "annotation": ""}, "snippet": " c = len(word_list)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98809:If_L93_C4", "label": "if", "type": "if", "loc": [93, 100], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98809:FunctionDef_L81_C0", "vector": [4, 1, 0.9554, 0.0792, 1, 0.66, 0.75, 0, 0, 0, 0, 0, 0, 0, 3], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if count > c:\n count -= c\n while count > 0:\n c = min(count, len(WORDS))\n count -= c\n word_list += random.sample(WORDS, c)\n else:\n word_list = word_list[:count]"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98809:While_L95_C8", "label": "while", "type": "while", "loc": [95, 98], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98809:If_L93_C4", "vector": [5, 2, 0.9554, 0.0396, 2, 0.4, 0.0, 0, 0, 0, 0, 0, 0, 0, 3], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " while count > 0:\n c = min(count, len(WORDS))\n count -= c\n word_list += random.sample(WORDS, c)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98809:Assign_L96_C12", "label": "c = min()", "type": "assigned_variable", "loc": [96, 96], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98809:While_L95_C8", "vector": [14, 3, 0.9505, 0.0099, 3, 0.66, 0.0, 411, 3, 2, 0, 0, 867, 10, 2], "semantic": {"name": "c", "arg_names": [], "import_names": [], "rhs_call_name": "min", "annotation": ""}, "snippet": " c = min(count, len(WORDS))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98809:Assign_L100_C8", "label": "word_list =", "type": "assigned_variable", "loc": [100, 100], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98809:If_L93_C4", "vector": [14, 2, 0.9901, 0.0099, 2, 0.4, 1.0, 434, 6, 0, 0, 0, 0, 0, 0], "semantic": {"name": "word_list", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " word_list = word_list[:count]"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98809:Return_L101_C4", "label": "return", "type": "return", "loc": [101, 101], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98809:FunctionDef_L81_C0", "vector": [13, 1, 1.0, 0.0099, 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 u' '.join(word_list)"}]
[{"f": "ajibawa-2023/Python-Code-Large/train/row_98809:FunctionDef_L43_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98809:Expr_L44_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98809:FunctionDef_L43_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98809:Assign_L52_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98809:FunctionDef_L43_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98809:Assign_L53_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98809:FunctionDef_L43_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98809:Return_L55_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98809:FunctionDef_L57_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98809:Expr_L58_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98809:FunctionDef_L57_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98809:Return_L63_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98809:FunctionDef_L65_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98809:Expr_L66_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98809:FunctionDef_L65_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98809:Assign_L73_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98809:FunctionDef_L65_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98809:For_L74_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98809:For_L74_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98809:If_L75_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98809:If_L75_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98809:Expr_L76_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98809:If_L75_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98809:Expr_L78_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98809:FunctionDef_L65_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98809:Return_L79_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98809:FunctionDef_L81_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98809:Expr_L82_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98809:FunctionDef_L81_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98809:If_L88_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98809:If_L88_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98809:Assign_L89_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98809:If_L88_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98809:Assign_L91_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98809:FunctionDef_L81_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98809:Assign_L92_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98809:FunctionDef_L81_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98809:If_L93_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98809:If_L93_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98809:While_L95_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98809:While_L95_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98809:Assign_L96_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98809:If_L93_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98809:Assign_L100_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98809:FunctionDef_L81_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98809:Return_L101_C4"}]
from django.contrib.webdesign.lorem_ipsum import words, paragraphs from django import template register = template.Library() class LoremNode(template.Node): def __init__(self, count, method, common): self.count, self.method, self.common = count, method, common def render(self, context): try: count = int(self.count.resolve(context)) except (ValueError, TypeError): count = 1 if self.method == 'w': return words(count, common=self.common) else: paras = paragraphs(count, common=self.common) if self.method == 'p': paras = ['<p>%s</p>' % p for p in paras] return u'\n\n'.join(paras) #@register.tag def lorem(parser, token): """ Creates random Latin text useful for providing test data in templates. Usage format:: {% lorem [count] [method] [random] %} ``count`` is a number (or variable) containing the number of paragraphs or words to generate (default is 1). ``method`` is either ``w`` for words, ``p`` for HTML paragraphs, ``b`` for plain-text paragraph blocks (default is ``b``). ``random`` is the word ``random``, which if given, does not use the common paragraph (starting "Lorem ipsum dolor sit amet, consectetuer..."). Examples: * ``{% lorem %}`` will output the common "lorem ipsum" paragraph * ``{% lorem 3 p %}`` will output the common "lorem ipsum" paragraph and two random paragraphs each wrapped in HTML ``<p>`` tags * ``{% lorem 2 w random %}`` will output two random latin words """ bits = list(token.split_contents()) tagname = bits[0] # Random bit common = bits[-1] != 'random' if not common: bits.pop() # Method bit if bits[-1] in ('w', 'p', 'b'): method = bits.pop() else: method = 'b' # Count bit if len(bits) > 1: count = bits.pop() else: count = '1' count = parser.compile_filter(count) if len(bits) != 1: raise template.TemplateSyntaxError("Incorrect format for %r tag" % tagname) return LoremNode(count, method, common) lorem = register.tag(lorem)
ajibawa-2023/Python-Code-Large/train/row_98810
33
67
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_98810:ImportFrom_L1_C0", "label": "from django.contrib.webdesign.lorem_ipsum import words, paragraphs", "type": "import", "loc": [1, 1], "level": 0, "parent": null, "vector": [1, 0, 0.0149, 0.0149, 0, 0.66, 0.0, 74, 0, 2, 0, 0, 74, 0, 0], "semantic": {"name": "django.contrib.webdesign.lorem_ipsum", "arg_names": [], "import_names": ["words", "paragraphs"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.contrib.webdesign.lorem_ipsum import words, paragraphs"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98810:ImportFrom_L2_C0", "label": "from django import template", "type": "import", "loc": [2, 2], "level": 0, "parent": null, "vector": [1, 0, 0.0299, 0.0149, 0, 0.66, 0.2, 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_98810:Assign_L4_C0", "label": "register = Library()", "type": "assigned_variable", "loc": [4, 4], "level": 0, "parent": null, "vector": [14, 0, 0.0597, 0.0149, 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_98810:ClassDef_L6_C0", "label": "LoremNode", "type": "class", "loc": [6, 21], "level": 0, "parent": null, "vector": [3, 0, 0.2015, 0.2388, 0, 0.66, 0.6, 87, 0, 2, 0, 0, 586, 0, 5], "semantic": {"name": "LoremNode", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class LoremNode(template.Node):\n def __init__(self, count, method, common):\n self.count, self.method, self.common = count, method, common\n\n def render(self, context):\n try:\n count = int(self.count.resolve(context))\n except (ValueError, TypeError):"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98810:FunctionDef_L7_C4", "label": "__init__", "type": "function", "loc": [7, 8], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98810:ClassDef_L6_C0", "vector": [2, 1, 0.1119, 0.0299, 1, 0.74, 0.0, 555, 0, 4, 0, 0, 0, 0, 0], "semantic": {"name": "__init__", "arg_names": ["self", "count", "method", "common"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def __init__(self, count, method, common):\n self.count, self.method, self.common = count, method, common"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98810:Assign_L8_C8", "label": "assign", "type": "assigned_variable", "loc": [8, 8], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98810:FunctionDef_L7_C4", "vector": [14, 2, 0.1194, 0.0149, 2, 0.88, 0.0, 0, 0, 0, 0, 0, 0, 8, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.count, self.method, self.common = count, method, common"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98810:FunctionDef_L10_C4", "label": "render", "type": "function", "loc": [10, 21], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98810:ClassDef_L6_C0", "vector": [2, 1, 0.2313, 0.1791, 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 try:\n count = int(self.count.resolve(context))\n except (ValueError, TypeError):\n count = 1\n if self.method == 'w':\n return words(count, common=self.common)\n else:"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98810:Try_L11_C8", "label": "try", "type": "try", "loc": [11, 14], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98810:FunctionDef_L10_C4", "vector": [7, 2, 0.1866, 0.0597, 2, 0.67, 0.0, 0, 0, 1, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " try:\n count = int(self.count.resolve(context))\n except (ValueError, TypeError):\n count = 1"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98810:Assign_L12_C12", "label": "count = int()", "type": "assigned_variable", "loc": [12, 12], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98810:Try_L11_C8", "vector": [14, 3, 0.1791, 0.0149, 3, 0.67, 0.0, 778, 3, 1, 0, 0, 901, 10, 2], "semantic": {"name": "count", "arg_names": [], "import_names": [], "rhs_call_name": "int", "annotation": ""}, "snippet": " count = int(self.count.resolve(context))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98810:Assign_L14_C12", "label": "count =", "type": "assigned_variable", "loc": [14, 14], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98810:Try_L11_C8", "vector": [14, 3, 0.209, 0.0149, 3, 0.67, 0.0, 778, 1, 0, 0, 0, 0, 1, 0], "semantic": {"name": "count", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " count = 1"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98810:If_L15_C8", "label": "if", "type": "if", "loc": [15, 18], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98810:FunctionDef_L10_C4", "vector": [4, 2, 0.2463, 0.0597, 2, 0.67, 0.3333, 0, 0, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if self.method == 'w':\n return words(count, common=self.common)\n else:\n paras = paragraphs(count, common=self.common)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98810:Return_L16_C12", "label": "return", "type": "return", "loc": [16, 16], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98810:If_L15_C8", "vector": [13, 3, 0.2388, 0.0149, 3, 0.04, 0.0, 0, 3, 0, 0, 0, 0, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return words(count, common=self.common)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98810:Assign_L18_C12", "label": "paras = paragraphs()", "type": "assigned_variable", "loc": [18, 18], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98810:If_L15_C8", "vector": [14, 3, 0.2687, 0.0149, 3, 0.04, 1.0, 76, 3, 2, 0, 0, 140, 10, 1], "semantic": {"name": "paras", "arg_names": [], "import_names": [], "rhs_call_name": "paragraphs", "annotation": ""}, "snippet": " paras = paragraphs(count, common=self.common)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98810:If_L19_C8", "label": "if", "type": "if", "loc": [19, 20], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98810:FunctionDef_L10_C4", "vector": [4, 2, 0.291, 0.0299, 2, 0.67, 0.6667, 0, 0, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if self.method == 'p':\n paras = ['<p>%s</p>' % p for p in paras]"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98810:Assign_L20_C12", "label": "paras =", "type": "assigned_variable", "loc": [20, 20], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98810:If_L19_C8", "vector": [14, 3, 0.2985, 0.0149, 3, 0.05, 0.0, 76, 5, 0, 0, 0, 0, 0, 0], "semantic": {"name": "paras", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " paras = ['<p>%s</p>' % p for p in paras]"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98810:Return_L21_C8", "label": "return", "type": "return", "loc": [21, 21], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98810:FunctionDef_L10_C4", "vector": [13, 2, 0.3134, 0.0149, 2, 0.67, 1.0, 0, 3, 0, 0, 0, 0, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return u'\\n\\n'.join(paras)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98810:FunctionDef_L24_C0", "label": "lorem", "type": "function", "loc": [24, 66], "level": 0, "parent": null, "vector": [2, 0, 0.6716, 0.6418, 0, 0.66, 0.8, 450, 0, 2, 1, 0, 0, 0, 10], "semantic": {"name": "lorem", "arg_names": ["parser", "token"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "def lorem(parser, token):\n \"\"\"\n Creates random Latin text useful for providing test data in templates.\n\n Usage format::\n\n {% lorem [count] [method] [random] %}\n"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98810:Expr_L25_C4", "label": "expression", "type": "expression", "loc": [25, 46], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98810:FunctionDef_L24_C0", "vector": [8, 1, 0.5299, 0.3284, 1, 0.87, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"\n Creates random Latin text useful for providing test data in templates.\n\n Usage format::\n\n {% lorem [count] [method] [random] %}\n\n ``count`` is a number (or variable) containing the number of paragraphs or"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98810:Assign_L47_C4", "label": "bits = list()", "type": "assigned_variable", "loc": [47, 47], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98810:FunctionDef_L24_C0", "vector": [14, 1, 0.7015, 0.0149, 1, 0.87, 0.1111, 593, 3, 1, 0, 0, 430, 10, 2], "semantic": {"name": "bits", "arg_names": [], "import_names": [], "rhs_call_name": "list", "annotation": ""}, "snippet": " bits = list(token.split_contents())"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98810:Assign_L48_C4", "label": "tagname =", "type": "assigned_variable", "loc": [48, 48], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98810:FunctionDef_L24_C0", "vector": [14, 1, 0.7164, 0.0149, 1, 0.87, 0.2222, 781, 6, 0, 0, 0, 0, 0, 0], "semantic": {"name": "tagname", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " tagname = bits[0]"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98810:Assign_L50_C4", "label": "common =", "type": "assigned_variable", "loc": [50, 50], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98810:FunctionDef_L24_C0", "vector": [14, 1, 0.7463, 0.0149, 1, 0.87, 0.3333, 718, 0, 0, 0, 0, 0, 0, 0], "semantic": {"name": "common", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " common = bits[-1] != 'random'"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98810:If_L51_C4", "label": "if", "type": "if", "loc": [51, 52], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98810:FunctionDef_L24_C0", "vector": [4, 1, 0.7687, 0.0299, 1, 0.87, 0.4444, 0, 0, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if not common:\n bits.pop()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98810:Expr_L52_C8", "label": "pop()", "type": "expression", "loc": [52, 52], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98810:If_L51_C4", "vector": [8, 2, 0.7761, 0.0149, 2, 0.97, 0.0, 969, 3, 0, 0, 0, 0, 0, 1], "semantic": {"name": "pop", "arg_names": [], "import_names": [], "rhs_call_name": "pop", "annotation": ""}, "snippet": " bits.pop()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98810:If_L54_C4", "label": "if", "type": "if", "loc": [54, 57], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98810:FunctionDef_L24_C0", "vector": [4, 1, 0.8284, 0.0597, 1, 0.87, 0.5556, 0, 0, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if bits[-1] in ('w', 'p', 'b'):\n method = bits.pop()\n else:\n method = 'b'"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98810:Assign_L55_C8", "label": "method = pop()", "type": "assigned_variable", "loc": [55, 55], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98810:If_L54_C4", "vector": [14, 2, 0.8209, 0.0149, 2, 0.08, 0.0, 445, 3, 0, 0, 0, 969, 10, 1], "semantic": {"name": "method", "arg_names": [], "import_names": [], "rhs_call_name": "pop", "annotation": ""}, "snippet": " method = bits.pop()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98810:Assign_L57_C8", "label": "method =", "type": "assigned_variable", "loc": [57, 57], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98810:If_L54_C4", "vector": [14, 2, 0.8507, 0.0149, 2, 0.08, 1.0, 445, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "method", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " method = 'b'"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98810:If_L59_C4", "label": "if", "type": "if", "loc": [59, 62], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98810:FunctionDef_L24_C0", "vector": [4, 1, 0.903, 0.0597, 1, 0.87, 0.6667, 0, 0, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if len(bits) > 1:\n count = bits.pop()\n else:\n count = '1'"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98810:Assign_L60_C8", "label": "count = pop()", "type": "assigned_variable", "loc": [60, 60], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98810:If_L59_C4", "vector": [14, 2, 0.8955, 0.0149, 2, 0.81, 0.0, 778, 3, 0, 0, 0, 969, 10, 1], "semantic": {"name": "count", "arg_names": [], "import_names": [], "rhs_call_name": "pop", "annotation": ""}, "snippet": " count = bits.pop()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98810:Assign_L62_C8", "label": "count =", "type": "assigned_variable", "loc": [62, 62], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98810:If_L59_C4", "vector": [14, 2, 0.9254, 0.0149, 2, 0.81, 1.0, 778, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "count", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " count = '1'"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98810:Assign_L63_C4", "label": "count = compile_filter()", "type": "assigned_variable", "loc": [63, 63], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98810:FunctionDef_L24_C0", "vector": [14, 1, 0.9403, 0.0149, 1, 0.87, 0.7778, 778, 3, 1, 0, 0, 511, 10, 1], "semantic": {"name": "count", "arg_names": [], "import_names": [], "rhs_call_name": "compile_filter", "annotation": ""}, "snippet": " count = parser.compile_filter(count)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98810:If_L64_C4", "label": "if", "type": "if", "loc": [64, 65], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98810:FunctionDef_L24_C0", "vector": [4, 1, 0.9627, 0.0299, 1, 0.87, 0.8889, 0, 0, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if len(bits) != 1:\n raise template.TemplateSyntaxError(\"Incorrect format for %r tag\" % tagname)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98810:Return_L66_C4", "label": "return", "type": "return", "loc": [66, 66], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98810:FunctionDef_L24_C0", "vector": [13, 1, 0.9851, 0.0149, 1, 0.87, 1.0, 0, 3, 0, 0, 0, 0, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return LoremNode(count, method, common)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98810:Assign_L67_C0", "label": "lorem = tag()", "type": "assigned_variable", "loc": [67, 67], "level": 0, "parent": null, "vector": [14, 0, 1.0, 0.0149, 0, 0.66, 1.0, 450, 3, 1, 0, 0, 732, 10, 1], "semantic": {"name": "lorem", "arg_names": [], "import_names": [], "rhs_call_name": "tag", "annotation": ""}, "snippet": "lorem = register.tag(lorem)"}]
[{"f": "ajibawa-2023/Python-Code-Large/train/row_98810:ClassDef_L6_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98810:FunctionDef_L7_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98810:FunctionDef_L7_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98810:Assign_L8_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98810:ClassDef_L6_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98810:FunctionDef_L10_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98810:FunctionDef_L10_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98810:Try_L11_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98810:Try_L11_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98810:Assign_L12_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98810:Try_L11_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98810:Assign_L14_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98810:FunctionDef_L10_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98810:If_L15_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98810:If_L15_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98810:Return_L16_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98810:If_L15_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98810:Assign_L18_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98810:FunctionDef_L10_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98810:If_L19_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98810:If_L19_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98810:Assign_L20_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98810:FunctionDef_L10_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98810:Return_L21_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98810:FunctionDef_L24_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98810:Expr_L25_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98810:FunctionDef_L24_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98810:Assign_L47_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98810:FunctionDef_L24_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98810:Assign_L48_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98810:FunctionDef_L24_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98810:Assign_L50_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98810:FunctionDef_L24_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98810:If_L51_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98810:If_L51_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98810:Expr_L52_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98810:FunctionDef_L24_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98810:If_L54_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98810:If_L54_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98810:Assign_L55_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98810:If_L54_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98810:Assign_L57_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98810:FunctionDef_L24_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98810:If_L59_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98810:If_L59_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98810:Assign_L60_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98810:If_L59_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98810:Assign_L62_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98810:FunctionDef_L24_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98810:Assign_L63_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98810:FunctionDef_L24_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98810:If_L64_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98810:FunctionDef_L24_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98810:Return_L66_C4"}]
from django.db import models from django.utils.translation import ugettext_lazy as _ from django.utils.encoding import smart_unicode class ContentTypeManager(models.Manager): # Cache to avoid re-looking up ContentType objects all over the place. # This cache is shared by all the get_for_* methods. _cache = {} def get_by_natural_key(self, app_label, model): try: ct = self.__class__._cache[self.db][(app_label, model)] except KeyError: ct = self.get(app_label=app_label, model=model) return ct def get_for_model(self, model): """ Returns the ContentType object for a given model, creating the ContentType if necessary. Lookups are cached so that subsequent lookups for the same model don't hit the database. """ opts = model._meta while opts.proxy: model = opts.proxy_for_model opts = model._meta key = (opts.app_label, opts.object_name.lower()) try: ct = self.__class__._cache[self.db][key] except KeyError: # Load or create the ContentType entry. The smart_unicode() is # needed around opts.verbose_name_raw because name_raw might be a # django.utils.functional.__proxy__ object. ct, created = self.get_or_create( app_label = opts.app_label, model = opts.object_name.lower(), defaults = {'name': smart_unicode(opts.verbose_name_raw)}, ) self._add_to_cache(self.db, ct) return ct def get_for_id(self, id): """ Lookup a ContentType by ID. Uses the same shared cache as get_for_model (though ContentTypes are obviously not created on-the-fly by get_by_id). """ try: ct = self.__class__._cache[self.db][id] except KeyError: # This could raise a DoesNotExist; that's correct behavior and will # make sure that only correct ctypes get stored in the cache dict. ct = self.get(pk=id) self._add_to_cache(self.db, ct) return ct def clear_cache(self): """ Clear out the content-type cache. This needs to happen during database flushes to prevent caching of "stale" content type IDs (see django.contrib.contenttypes.management.update_contenttypes for where this gets called). """ self.__class__._cache.clear() def _add_to_cache(self, using, ct): """Insert a ContentType into the cache.""" model = ct.model_class() key = (model._meta.app_label, model._meta.object_name.lower()) self.__class__._cache.setdefault(using, {})[key] = ct self.__class__._cache.setdefault(using, {})[ct.id] = ct class ContentType(models.Model): name = models.CharField(max_length=100) app_label = models.CharField(max_length=100) model = models.CharField(_('python model class name'), max_length=100) objects = ContentTypeManager() class Meta: verbose_name = _('content type') verbose_name_plural = _('content types') db_table = 'django_content_type' ordering = ('name',) unique_together = (('app_label', 'model'),) def __unicode__(self): return self.name def model_class(self): "Returns the Python model class for this type of content." from django.db import models return models.get_model(self.app_label, self.model) def get_object_for_this_type(self, **kwargs): """ Returns an object of this type for the keyword arguments given. Basically, this is a proxy around this object_type's get_object() model method. The ObjectNotExist exception, if thrown, will not be caught, so code that calls this method should catch it. """ return self.model_class()._default_manager.using(self._state.db).get(**kwargs) def natural_key(self): return (self.app_label, self.model)
ajibawa-2023/Python-Code-Large/train/row_98811
60
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_98811:ImportFrom_L1_C0", "label": "from django.db import models", "type": "import", "loc": [1, 1], "level": 0, "parent": null, "vector": [1, 0, 0.0095, 0.0095, 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_98811:ImportFrom_L2_C0", "label": "from django.utils.translation import _", "type": "import", "loc": [2, 2], "level": 0, "parent": null, "vector": [1, 0, 0.019, 0.0095, 0, 0.66, 0.25, 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_98811:ImportFrom_L3_C0", "label": "from django.utils.encoding import smart_unicode", "type": "import", "loc": [3, 3], "level": 0, "parent": null, "vector": [1, 0, 0.0286, 0.0095, 0, 0.66, 0.5, 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_98811:ClassDef_L5_C0", "label": "ContentTypeManager", "type": "class", "loc": [5, 72], "level": 0, "parent": null, "vector": [3, 0, 0.3667, 0.6476, 0, 0.66, 0.75, 343, 0, 5, 0, 0, 948, 0, 13], "semantic": {"name": "ContentTypeManager", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class ContentTypeManager(models.Manager):\n\n # Cache to avoid re-looking up ContentType objects all over the place.\n # This cache is shared by all the get_for_* methods.\n _cache = {}\n\n def get_by_natural_key(self, app_label, model):\n try:"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98811:Assign_L9_C4", "label": "_cache =", "type": "assigned_variable", "loc": [9, 9], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98811:ClassDef_L5_C0", "vector": [14, 1, 0.0857, 0.0095, 1, 0.04, 0.0, 123, 0, 0, 0, 0, 0, 6, 0], "semantic": {"name": "_cache", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " _cache = {}"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98811:FunctionDef_L11_C4", "label": "get_by_natural_key", "type": "function", "loc": [11, 16], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98811:ClassDef_L5_C0", "vector": [2, 1, 0.1286, 0.0571, 1, 0.04, 0.2, 668, 0, 3, 1, 0, 0, 0, 1], "semantic": {"name": "get_by_natural_key", "arg_names": ["self", "app_label", "model"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def get_by_natural_key(self, app_label, model):\n try:\n ct = self.__class__._cache[self.db][(app_label, model)]\n except KeyError:\n ct = self.get(app_label=app_label, model=model)\n return ct"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98811:Try_L12_C8", "label": "try", "type": "try", "loc": [12, 15], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98811:FunctionDef_L11_C4", "vector": [7, 2, 0.1286, 0.0381, 2, 0.04, 0.0, 0, 0, 1, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " try:\n ct = self.__class__._cache[self.db][(app_label, model)]\n except KeyError:\n ct = self.get(app_label=app_label, model=model)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98811:Assign_L13_C12", "label": "ct =", "type": "assigned_variable", "loc": [13, 13], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98811:Try_L12_C8", "vector": [14, 3, 0.1238, 0.0095, 3, 0.27, 0.0, 147, 6, 0, 0, 0, 0, 0, 0], "semantic": {"name": "ct", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " ct = self.__class__._cache[self.db][(app_label, model)]"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98811:Assign_L15_C12", "label": "ct = get()", "type": "assigned_variable", "loc": [15, 15], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98811:Try_L12_C8", "vector": [14, 3, 0.1429, 0.0095, 3, 0.27, 0.0, 147, 3, 2, 0, 0, 607, 10, 1], "semantic": {"name": "ct", "arg_names": [], "import_names": [], "rhs_call_name": "get", "annotation": ""}, "snippet": " ct = self.get(app_label=app_label, model=model)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98811:Return_L16_C8", "label": "return", "type": "return", "loc": [16, 16], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98811:FunctionDef_L11_C4", "vector": [13, 2, 0.1524, 0.0095, 2, 0.04, 1.0, 0, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return ct"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98811:FunctionDef_L18_C4", "label": "get_for_model", "type": "function", "loc": [18, 42], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98811:ClassDef_L5_C0", "vector": [2, 1, 0.2857, 0.2381, 1, 0.04, 0.4, 752, 0, 2, 1, 0, 0, 0, 5], "semantic": {"name": "get_for_model", "arg_names": ["self", "model"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def get_for_model(self, model):\n \"\"\"\n Returns the ContentType object for a given model, creating the\n ContentType if necessary. Lookups are cached so that subsequent lookups\n for the same model don't hit the database.\n \"\"\"\n opts = model._meta\n while opts.proxy:"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98811:Expr_L19_C8", "label": "expression", "type": "expression", "loc": [19, 23], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98811:FunctionDef_L18_C4", "vector": [8, 2, 0.2, 0.0476, 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 Returns the ContentType object for a given model, creating the\n ContentType if necessary. Lookups are cached so that subsequent lookups\n for the same model don't hit the database.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98811:Assign_L24_C8", "label": "opts =", "type": "assigned_variable", "loc": [24, 24], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98811:FunctionDef_L18_C4", "vector": [14, 2, 0.2286, 0.0095, 2, 0.3, 0.2, 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_98811:While_L25_C8", "label": "while", "type": "while", "loc": [25, 27], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98811:FunctionDef_L18_C4", "vector": [5, 2, 0.2476, 0.0286, 2, 0.3, 0.4, 0, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " while opts.proxy:\n model = opts.proxy_for_model\n opts = model._meta"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98811:Assign_L26_C12", "label": "model =", "type": "assigned_variable", "loc": [26, 26], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98811:While_L25_C8", "vector": [14, 3, 0.2476, 0.0095, 3, 0.45, 0.0, 722, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "model", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " model = opts.proxy_for_model"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98811:Assign_L27_C12", "label": "opts =", "type": "assigned_variable", "loc": [27, 27], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98811:While_L25_C8", "vector": [14, 3, 0.2571, 0.0095, 3, 0.45, 1.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_98811:Assign_L28_C8", "label": "key =", "type": "assigned_variable", "loc": [28, 28], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98811:FunctionDef_L18_C4", "vector": [14, 2, 0.2667, 0.0095, 2, 0.3, 0.6, 230, 0, 0, 0, 0, 0, 8, 1], "semantic": {"name": "key", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " key = (opts.app_label, opts.object_name.lower())"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98811:Try_L29_C8", "label": "try", "type": "try", "loc": [29, 40], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98811:FunctionDef_L18_C4", "vector": [7, 2, 0.3286, 0.1143, 2, 0.3, 0.8, 0, 0, 1, 0, 0, 0, 0, 4], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " try:\n ct = self.__class__._cache[self.db][key]\n except KeyError:\n # Load or create the ContentType entry. The smart_unicode() is\n # needed around opts.verbose_name_raw because name_raw might be a\n # django.utils.functional.__proxy__ object.\n ct, created = self.get_or_create(\n app_label = opts.app_label,"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98811:Assign_L30_C12", "label": "ct =", "type": "assigned_variable", "loc": [30, 30], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98811:Try_L29_C8", "vector": [14, 3, 0.2857, 0.0095, 3, 0.69, 0.0, 147, 6, 0, 0, 0, 0, 0, 0], "semantic": {"name": "ct", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " ct = self.__class__._cache[self.db][key]"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98811:Assign_L35_C12", "label": "ct, created = get_or_create()", "type": "assigned_variable", "loc": [35, 39], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98811:Try_L29_C8", "vector": [14, 3, 0.3524, 0.0476, 3, 0.69, 0.0, 265, 3, 3, 0, 0, 204, 10, 3], "semantic": {"name": "ct, created", "arg_names": [], "import_names": [], "rhs_call_name": "get_or_create", "annotation": ""}, "snippet": " ct, created = self.get_or_create(\n app_label = opts.app_label,\n model = opts.object_name.lower(),\n defaults = {'name': smart_unicode(opts.verbose_name_raw)},\n )"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98811:Expr_L40_C12", "label": "_add_to_cache()", "type": "expression", "loc": [40, 40], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98811:Try_L29_C8", "vector": [8, 3, 0.381, 0.0095, 3, 0.69, 1.0, 250, 3, 2, 0, 0, 0, 0, 1], "semantic": {"name": "_add_to_cache", "arg_names": [], "import_names": [], "rhs_call_name": "_add_to_cache", "annotation": ""}, "snippet": " self._add_to_cache(self.db, ct)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98811:Return_L42_C8", "label": "return", "type": "return", "loc": [42, 42], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98811:FunctionDef_L18_C4", "vector": [13, 2, 0.4, 0.0095, 2, 0.3, 1.0, 0, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return ct"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98811:FunctionDef_L44_C4", "label": "get_for_id", "type": "function", "loc": [44, 56], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98811:ClassDef_L5_C0", "vector": [2, 1, 0.4762, 0.1238, 1, 0.04, 0.6, 934, 0, 2, 1, 0, 0, 0, 2], "semantic": {"name": "get_for_id", "arg_names": ["self", "id"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def get_for_id(self, id):\n \"\"\"\n Lookup a ContentType by ID. Uses the same shared cache as get_for_model\n (though ContentTypes are obviously not created on-the-fly by get_by_id).\n \"\"\"\n try:\n ct = self.__class__._cache[self.db][id]\n except KeyError:"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98811:Expr_L45_C8", "label": "expression", "type": "expression", "loc": [45, 48], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98811:FunctionDef_L44_C4", "vector": [8, 2, 0.4429, 0.0381, 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 Lookup a ContentType by ID. Uses the same shared cache as get_for_model\n (though ContentTypes are obviously not created on-the-fly by get_by_id).\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98811:Try_L49_C8", "label": "try", "type": "try", "loc": [49, 55], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98811:FunctionDef_L44_C4", "vector": [7, 2, 0.4952, 0.0667, 2, 0.59, 0.5, 0, 0, 1, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " try:\n ct = self.__class__._cache[self.db][id]\n except KeyError:\n # This could raise a DoesNotExist; that's correct behavior and will\n # make sure that only correct ctypes get stored in the cache dict.\n ct = self.get(pk=id)\n self._add_to_cache(self.db, ct)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98811:Assign_L50_C12", "label": "ct =", "type": "assigned_variable", "loc": [50, 50], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98811:Try_L49_C8", "vector": [14, 3, 0.4762, 0.0095, 3, 0.08, 0.0, 147, 6, 0, 0, 0, 0, 0, 0], "semantic": {"name": "ct", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " ct = self.__class__._cache[self.db][id]"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98811:Assign_L54_C12", "label": "ct = get()", "type": "assigned_variable", "loc": [54, 54], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98811:Try_L49_C8", "vector": [14, 3, 0.5143, 0.0095, 3, 0.08, 0.0, 147, 3, 1, 0, 0, 607, 10, 1], "semantic": {"name": "ct", "arg_names": [], "import_names": [], "rhs_call_name": "get", "annotation": ""}, "snippet": " ct = self.get(pk=id)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98811:Expr_L55_C12", "label": "_add_to_cache()", "type": "expression", "loc": [55, 55], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98811:Try_L49_C8", "vector": [8, 3, 0.5238, 0.0095, 3, 0.08, 1.0, 250, 3, 2, 0, 0, 0, 0, 1], "semantic": {"name": "_add_to_cache", "arg_names": [], "import_names": [], "rhs_call_name": "_add_to_cache", "annotation": ""}, "snippet": " self._add_to_cache(self.db, ct)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98811:Return_L56_C8", "label": "return", "type": "return", "loc": [56, 56], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98811:FunctionDef_L44_C4", "vector": [13, 2, 0.5333, 0.0095, 2, 0.59, 1.0, 0, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return ct"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98811:FunctionDef_L58_C4", "label": "clear_cache", "type": "function", "loc": [58, 65], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98811:ClassDef_L5_C0", "vector": [2, 1, 0.5857, 0.0762, 1, 0.04, 0.8, 808, 0, 1, 0, 0, 0, 0, 1], "semantic": {"name": "clear_cache", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def clear_cache(self):\n \"\"\"\n Clear out the content-type cache. This needs to happen during database\n flushes to prevent caching of \"stale\" content type IDs (see\n django.contrib.contenttypes.management.update_contenttypes for where\n this gets called).\n \"\"\"\n self.__class__._cache.clear()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98811:Expr_L59_C8", "label": "expression", "type": "expression", "loc": [59, 64], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98811:FunctionDef_L58_C4", "vector": [8, 2, 0.5857, 0.0571, 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 Clear out the content-type cache. This needs to happen during database\n flushes to prevent caching of \"stale\" content type IDs (see\n django.contrib.contenttypes.management.update_contenttypes for where\n this gets called).\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98811:Expr_L65_C8", "label": "clear()", "type": "expression", "loc": [65, 65], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98811:FunctionDef_L58_C4", "vector": [8, 2, 0.619, 0.0095, 2, 0.8, 1.0, 712, 3, 0, 0, 0, 0, 0, 1], "semantic": {"name": "clear", "arg_names": [], "import_names": [], "rhs_call_name": "clear", "annotation": ""}, "snippet": " self.__class__._cache.clear()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98811:FunctionDef_L67_C4", "label": "_add_to_cache", "type": "function", "loc": [67, 72], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98811:ClassDef_L5_C0", "vector": [2, 1, 0.6619, 0.0571, 1, 0.04, 1.0, 250, 0, 3, 0, 0, 0, 0, 4], "semantic": {"name": "_add_to_cache", "arg_names": ["self", "using", "ct"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def _add_to_cache(self, using, ct):\n \"\"\"Insert a ContentType into the cache.\"\"\"\n model = ct.model_class()\n key = (model._meta.app_label, model._meta.object_name.lower())\n self.__class__._cache.setdefault(using, {})[key] = ct\n self.__class__._cache.setdefault(using, {})[ct.id] = ct"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98811:Expr_L68_C8", "label": "expression", "type": "expression", "loc": [68, 68], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98811:FunctionDef_L67_C4", "vector": [8, 2, 0.6476, 0.0095, 2, 0.05, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"Insert a ContentType into the cache.\"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98811:Assign_L69_C8", "label": "model = model_class()", "type": "assigned_variable", "loc": [69, 69], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98811:FunctionDef_L67_C4", "vector": [14, 2, 0.6571, 0.0095, 2, 0.05, 0.25, 722, 3, 0, 0, 0, 826, 10, 1], "semantic": {"name": "model", "arg_names": [], "import_names": [], "rhs_call_name": "model_class", "annotation": ""}, "snippet": " model = ct.model_class()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98811:Assign_L70_C8", "label": "key =", "type": "assigned_variable", "loc": [70, 70], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98811:FunctionDef_L67_C4", "vector": [14, 2, 0.6667, 0.0095, 2, 0.05, 0.5, 230, 0, 0, 0, 0, 0, 8, 1], "semantic": {"name": "key", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " key = (model._meta.app_label, model._meta.object_name.lower())"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98811:Assign_L71_C8", "label": "assign", "type": "assigned_variable", "loc": [71, 71], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98811:FunctionDef_L67_C4", "vector": [14, 2, 0.6762, 0.0095, 2, 0.05, 0.75, 0, 2, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.__class__._cache.setdefault(using, {})[key] = ct"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98811:Assign_L72_C8", "label": "assign", "type": "assigned_variable", "loc": [72, 72], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98811:FunctionDef_L67_C4", "vector": [14, 2, 0.6857, 0.0095, 2, 0.05, 1.0, 0, 2, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.__class__._cache.setdefault(using, {})[ct.id] = ct"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98811:ClassDef_L74_C0", "label": "ContentType", "type": "class", "loc": [74, 105], "level": 0, "parent": null, "vector": [3, 0, 0.8524, 0.3048, 0, 0.66, 1.0, 313, 0, 4, 0, 0, 996, 0, 11], "semantic": {"name": "ContentType", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class ContentType(models.Model):\n name = models.CharField(max_length=100)\n app_label = models.CharField(max_length=100)\n model = models.CharField(_('python model class name'), max_length=100)\n objects = ContentTypeManager()\n\n class Meta:\n verbose_name = _('content type')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98811:Assign_L75_C4", "label": "name = CharField()", "type": "assigned_variable", "loc": [75, 75], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98811:ClassDef_L74_C0", "vector": [14, 1, 0.7143, 0.0095, 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=100)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98811:Assign_L76_C4", "label": "app_label = CharField()", "type": "assigned_variable", "loc": [76, 76], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98811:ClassDef_L74_C0", "vector": [14, 1, 0.7238, 0.0095, 1, 0.68, 0.125, 187, 3, 1, 0, 0, 952, 10, 1], "semantic": {"name": "app_label", "arg_names": [], "import_names": [], "rhs_call_name": "CharField", "annotation": ""}, "snippet": " app_label = models.CharField(max_length=100)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98811:Assign_L77_C4", "label": "model = CharField()", "type": "assigned_variable", "loc": [77, 77], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98811:ClassDef_L74_C0", "vector": [14, 1, 0.7333, 0.0095, 1, 0.68, 0.25, 722, 3, 2, 0, 0, 952, 10, 2], "semantic": {"name": "model", "arg_names": [], "import_names": [], "rhs_call_name": "CharField", "annotation": ""}, "snippet": " model = models.CharField(_('python model class name'), max_length=100)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98811:Assign_L78_C4", "label": "objects = ContentTypeManager()", "type": "assigned_variable", "loc": [78, 78], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98811:ClassDef_L74_C0", "vector": [14, 1, 0.7429, 0.0095, 1, 0.68, 0.375, 550, 3, 0, 0, 0, 343, 10, 1], "semantic": {"name": "objects", "arg_names": [], "import_names": [], "rhs_call_name": "ContentTypeManager", "annotation": ""}, "snippet": " objects = ContentTypeManager()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98811:ClassDef_L80_C4", "label": "Meta", "type": "class", "loc": [80, 85], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98811:ClassDef_L74_C0", "vector": [3, 1, 0.7857, 0.0571, 1, 0.68, 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 verbose_name = _('content type')\n verbose_name_plural = _('content types')\n db_table = 'django_content_type'\n ordering = ('name',)\n unique_together = (('app_label', 'model'),)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98811:Assign_L81_C8", "label": "verbose_name = _()", "type": "assigned_variable", "loc": [81, 81], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98811:ClassDef_L80_C4", "vector": [14, 2, 0.7714, 0.0095, 2, 0.61, 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 = _('content type')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98811:Assign_L82_C8", "label": "verbose_name_plural = _()", "type": "assigned_variable", "loc": [82, 82], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98811:ClassDef_L80_C4", "vector": [14, 2, 0.781, 0.0095, 2, 0.61, 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 = _('content types')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98811:Assign_L83_C8", "label": "db_table =", "type": "assigned_variable", "loc": [83, 83], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98811:ClassDef_L80_C4", "vector": [14, 2, 0.7905, 0.0095, 2, 0.61, 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_content_type'"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98811:Assign_L84_C8", "label": "ordering =", "type": "assigned_variable", "loc": [84, 84], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98811:ClassDef_L80_C4", "vector": [14, 2, 0.8, 0.0095, 2, 0.61, 0.75, 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_98811:Assign_L85_C8", "label": "unique_together =", "type": "assigned_variable", "loc": [85, 85], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98811:ClassDef_L80_C4", "vector": [14, 2, 0.8095, 0.0095, 2, 0.61, 1.0, 846, 0, 0, 0, 0, 0, 8, 0], "semantic": {"name": "unique_together", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " unique_together = (('app_label', 'model'),)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98811:FunctionDef_L87_C4", "label": "__unicode__", "type": "function", "loc": [87, 88], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98811:ClassDef_L74_C0", "vector": [2, 1, 0.8333, 0.019, 1, 0.68, 0.625, 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_98811:Return_L88_C8", "label": "return", "type": "return", "loc": [88, 88], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98811:FunctionDef_L87_C4", "vector": [13, 2, 0.8381, 0.0095, 2, 0.31, 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_98811:FunctionDef_L90_C4", "label": "model_class", "type": "function", "loc": [90, 93], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98811:ClassDef_L74_C0", "vector": [2, 1, 0.8714, 0.0381, 1, 0.68, 0.75, 826, 0, 1, 1, 0, 0, 0, 1], "semantic": {"name": "model_class", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def model_class(self):\n \"Returns the Python model class for this type of content.\"\n from django.db import models\n return models.get_model(self.app_label, self.model)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98811:Expr_L91_C8", "label": "expression", "type": "expression", "loc": [91, 91], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98811:FunctionDef_L90_C4", "vector": [8, 2, 0.8667, 0.0095, 2, 0.6, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"Returns the Python model class for this type of content.\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98811:ImportFrom_L92_C8", "label": "from django.db import models", "type": "import", "loc": [92, 92], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98811:FunctionDef_L90_C4", "vector": [1, 2, 0.8762, 0.0095, 2, 0.6, 0.5, 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_98811:Return_L93_C8", "label": "return", "type": "return", "loc": [93, 93], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98811:FunctionDef_L90_C4", "vector": [13, 2, 0.8857, 0.0095, 2, 0.6, 1.0, 0, 3, 0, 0, 0, 0, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return models.get_model(self.app_label, self.model)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98811:FunctionDef_L95_C4", "label": "get_object_for_this_type", "type": "function", "loc": [95, 102], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98811:ClassDef_L74_C0", "vector": [2, 1, 0.9381, 0.0762, 1, 0.68, 0.875, 753, 0, 2, 1, 0, 0, 0, 3], "semantic": {"name": "get_object_for_this_type", "arg_names": ["self", "kwargs"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def get_object_for_this_type(self, **kwargs):\n \"\"\"\n Returns an object of this type for the keyword arguments given.\n Basically, this is a proxy around this object_type's get_object() model\n method. The ObjectNotExist exception, if thrown, will not be caught,\n so code that calls this method should catch it.\n \"\"\"\n return self.model_class()._default_manager.using(self._state.db).get(**kwargs)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98811:Expr_L96_C8", "label": "expression", "type": "expression", "loc": [96, 101], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98811:FunctionDef_L95_C4", "vector": [8, 2, 0.9381, 0.0571, 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 Returns an object of this type for the keyword arguments given.\n Basically, this is a proxy around this object_type's get_object() model\n method. The ObjectNotExist exception, if thrown, will not be caught,\n so code that calls this method should catch it.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98811:Return_L102_C8", "label": "return", "type": "return", "loc": [102, 102], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98811:FunctionDef_L95_C4", "vector": [13, 2, 0.9714, 0.0095, 2, 0.93, 1.0, 0, 3, 0, 0, 0, 0, 10, 3], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return self.model_class()._default_manager.using(self._state.db).get(**kwargs)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98811:FunctionDef_L104_C4", "label": "natural_key", "type": "function", "loc": [104, 105], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98811:ClassDef_L74_C0", "vector": [2, 1, 0.9952, 0.019, 1, 0.68, 1.0, 449, 0, 1, 1, 0, 0, 0, 0], "semantic": {"name": "natural_key", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def natural_key(self):\n return (self.app_label, self.model)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98811:Return_L105_C8", "label": "return", "type": "return", "loc": [105, 105], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98811:FunctionDef_L104_C4", "vector": [13, 2, 1.0, 0.0095, 2, 0.32, 0.0, 0, 0, 0, 0, 0, 0, 8, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return (self.app_label, self.model)"}]
[{"f": "ajibawa-2023/Python-Code-Large/train/row_98811:ClassDef_L5_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98811:Assign_L9_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98811:ClassDef_L5_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98811:FunctionDef_L11_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98811:FunctionDef_L11_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98811:Try_L12_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98811:Try_L12_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98811:Assign_L13_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98811:Try_L12_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98811:Assign_L15_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98811:FunctionDef_L11_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98811:Return_L16_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98811:ClassDef_L5_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98811:FunctionDef_L18_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98811:FunctionDef_L18_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98811:Expr_L19_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98811:FunctionDef_L18_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98811:Assign_L24_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98811:FunctionDef_L18_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98811:While_L25_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98811:While_L25_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98811:Assign_L26_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98811:While_L25_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98811:Assign_L27_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98811:FunctionDef_L18_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98811:Assign_L28_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98811:FunctionDef_L18_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98811:Try_L29_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98811:Try_L29_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98811:Assign_L30_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98811:Try_L29_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98811:Assign_L35_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98811:Try_L29_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98811:Expr_L40_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98811:FunctionDef_L18_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98811:Return_L42_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98811:ClassDef_L5_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98811:FunctionDef_L44_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98811:FunctionDef_L44_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98811:Expr_L45_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98811:FunctionDef_L44_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98811:Try_L49_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98811:Try_L49_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98811:Assign_L50_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98811:Try_L49_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98811:Assign_L54_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98811:Try_L49_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98811:Expr_L55_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98811:FunctionDef_L44_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98811:Return_L56_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98811:ClassDef_L5_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98811:FunctionDef_L58_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98811:FunctionDef_L58_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98811:Expr_L59_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98811:FunctionDef_L58_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98811:Expr_L65_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98811:ClassDef_L5_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98811:FunctionDef_L67_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98811:FunctionDef_L67_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98811:Expr_L68_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98811:FunctionDef_L67_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98811:Assign_L69_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98811:FunctionDef_L67_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98811:Assign_L70_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98811:FunctionDef_L67_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98811:Assign_L71_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98811:FunctionDef_L67_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98811:Assign_L72_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98811:ClassDef_L74_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98811:Assign_L75_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98811:ClassDef_L74_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98811:Assign_L76_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98811:ClassDef_L74_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98811:Assign_L77_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98811:ClassDef_L74_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98811:Assign_L78_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98811:ClassDef_L74_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98811:ClassDef_L80_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98811:ClassDef_L80_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98811:Assign_L81_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98811:ClassDef_L80_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98811:Assign_L82_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98811:ClassDef_L80_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98811:Assign_L83_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98811:ClassDef_L80_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98811:Assign_L84_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98811:ClassDef_L80_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98811:Assign_L85_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98811:ClassDef_L74_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98811:FunctionDef_L87_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98811:FunctionDef_L87_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98811:Return_L88_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98811:ClassDef_L74_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98811:FunctionDef_L90_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98811:FunctionDef_L90_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98811:Expr_L91_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98811:FunctionDef_L90_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98811:ImportFrom_L92_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98811:FunctionDef_L90_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98811:Return_L93_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98811:ClassDef_L74_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98811:FunctionDef_L95_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98811:FunctionDef_L95_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98811:Expr_L96_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98811:FunctionDef_L95_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98811:Return_L102_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98811:ClassDef_L74_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98811:FunctionDef_L104_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98811:FunctionDef_L104_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98811:Return_L105_C8"}]
from django import db from django.conf import settings from django.contrib.contenttypes.models import ContentType from django.contrib.sites.models import Site from django.contrib.contenttypes.views import shortcut from django.core.exceptions import ObjectDoesNotExist from django.http import HttpRequest from django.test import TestCase class ContentTypesTests(TestCase): def setUp(self): # First, let's make sure we're dealing with a blank slate (and that # DEBUG is on so that queries get logged) self.old_DEBUG = settings.DEBUG self.old_Site_meta_installed = Site._meta.installed settings.DEBUG = True ContentType.objects.clear_cache() db.reset_queries() def tearDown(self): settings.DEBUG = self.old_DEBUG Site._meta.installed = self.old_Site_meta_installed def test_lookup_cache(self): """ Make sure that the content type cache (see ContentTypeManager) works correctly. Lookups for a particular content type -- by model or by ID -- should hit the database only on the first lookup. """ # At this point, a lookup for a ContentType should hit the DB ContentType.objects.get_for_model(ContentType) self.assertEqual(1, len(db.connection.queries)) # A second hit, though, won't hit the DB, nor will a lookup by ID ct = ContentType.objects.get_for_model(ContentType) self.assertEqual(1, len(db.connection.queries)) ContentType.objects.get_for_id(ct.id) self.assertEqual(1, len(db.connection.queries)) # Once we clear the cache, another lookup will again hit the DB ContentType.objects.clear_cache() ContentType.objects.get_for_model(ContentType) len(db.connection.queries) self.assertEqual(2, len(db.connection.queries)) def test_shortcut_view(self): """ Check that the shortcut view (used for the admin "view on site" functionality) returns a complete URL regardless of whether the sites framework is installed """ request = HttpRequest() request.META = { "SERVER_NAME": "Example.com", "SERVER_PORT": "80", } from django.contrib.auth.models import User user_ct = ContentType.objects.get_for_model(User) obj = User.objects.create(username="john") Site._meta.installed = True response = shortcut(request, user_ct.id, obj.id) self.assertEqual("http://example.com/users/john/", response._headers.get("location")[1]) Site._meta.installed = False response = shortcut(request, user_ct.id, obj.id) self.assertEqual("http://Example.com/users/john/", response._headers.get("location")[1])
ajibawa-2023/Python-Code-Large/train/row_98812
43
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_98812:ImportFrom_L1_C0", "label": "from django import db", "type": "import", "loc": [1, 1], "level": 0, "parent": null, "vector": [1, 0, 0.0145, 0.0145, 0, 0.66, 0.0, 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_98812:ImportFrom_L2_C0", "label": "from django.conf import settings", "type": "import", "loc": [2, 2], "level": 0, "parent": null, "vector": [1, 0, 0.029, 0.0145, 0, 0.66, 0.125, 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_98812:ImportFrom_L3_C0", "label": "from django.contrib.contenttypes.models import ContentType", "type": "import", "loc": [3, 3], "level": 0, "parent": null, "vector": [1, 0, 0.0435, 0.0145, 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_98812:ImportFrom_L4_C0", "label": "from django.contrib.sites.models import Site", "type": "import", "loc": [4, 4], "level": 0, "parent": null, "vector": [1, 0, 0.058, 0.0145, 0, 0.66, 0.375, 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_98812:ImportFrom_L5_C0", "label": "from django.contrib.contenttypes.views import shortcut", "type": "import", "loc": [5, 5], "level": 0, "parent": null, "vector": [1, 0, 0.0725, 0.0145, 0, 0.66, 0.5, 913, 0, 1, 0, 0, 913, 0, 0], "semantic": {"name": "django.contrib.contenttypes.views", "arg_names": [], "import_names": ["shortcut"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.contrib.contenttypes.views import shortcut"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98812:ImportFrom_L6_C0", "label": "from django.core.exceptions import ObjectDoesNotExist", "type": "import", "loc": [6, 6], "level": 0, "parent": null, "vector": [1, 0, 0.087, 0.0145, 0, 0.66, 0.625, 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_98812:ImportFrom_L7_C0", "label": "from django.http import HttpRequest", "type": "import", "loc": [7, 7], "level": 0, "parent": null, "vector": [1, 0, 0.1014, 0.0145, 0, 0.66, 0.75, 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_98812:ImportFrom_L8_C0", "label": "from django.test import TestCase", "type": "import", "loc": [8, 8], "level": 0, "parent": null, "vector": [1, 0, 0.1159, 0.0145, 0, 0.66, 0.875, 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_98812:ClassDef_L11_C0", "label": "ContentTypesTests", "type": "class", "loc": [11, 69], "level": 0, "parent": null, "vector": [3, 0, 0.5797, 0.8551, 0, 0.66, 1.0, 887, 0, 4, 0, 0, 3, 0, 25], "semantic": {"name": "ContentTypesTests", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class ContentTypesTests(TestCase):\n\n def setUp(self):\n # First, let's make sure we're dealing with a blank slate (and that\n # DEBUG is on so that queries get logged)\n self.old_DEBUG = settings.DEBUG\n self.old_Site_meta_installed = Site._meta.installed\n settings.DEBUG = True"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98812:FunctionDef_L13_C4", "label": "setUp", "type": "function", "loc": [13, 20], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98812:ClassDef_L11_C0", "vector": [2, 1, 0.2391, 0.1159, 1, 0.06, 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 # First, let's make sure we're dealing with a blank slate (and that\n # DEBUG is on so that queries get logged)\n self.old_DEBUG = settings.DEBUG\n self.old_Site_meta_installed = Site._meta.installed\n settings.DEBUG = True\n ContentType.objects.clear_cache()\n db.reset_queries()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98812:Assign_L16_C8", "label": "self.old_DEBUG =", "type": "assigned_variable", "loc": [16, 16], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98812:FunctionDef_L13_C4", "vector": [14, 2, 0.2319, 0.0145, 2, 0.69, 0.0, 605, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "self.old_DEBUG", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.old_DEBUG = settings.DEBUG"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98812:Assign_L17_C8", "label": "self.old_Site_meta_installed =", "type": "assigned_variable", "loc": [17, 17], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98812:FunctionDef_L13_C4", "vector": [14, 2, 0.2464, 0.0145, 2, 0.69, 0.25, 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_98812:Assign_L18_C8", "label": "settings.DEBUG =", "type": "assigned_variable", "loc": [18, 18], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98812:FunctionDef_L13_C4", "vector": [14, 2, 0.2609, 0.0145, 2, 0.69, 0.5, 754, 1, 0, 0, 0, 0, 4, 0], "semantic": {"name": "settings.DEBUG", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " settings.DEBUG = True"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98812:Expr_L19_C8", "label": "clear_cache()", "type": "expression", "loc": [19, 19], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98812:FunctionDef_L13_C4", "vector": [8, 2, 0.2754, 0.0145, 2, 0.69, 0.75, 808, 3, 0, 0, 0, 0, 0, 1], "semantic": {"name": "clear_cache", "arg_names": [], "import_names": [], "rhs_call_name": "clear_cache", "annotation": ""}, "snippet": " ContentType.objects.clear_cache()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98812:Expr_L20_C8", "label": "reset_queries()", "type": "expression", "loc": [20, 20], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98812:FunctionDef_L13_C4", "vector": [8, 2, 0.2899, 0.0145, 2, 0.69, 1.0, 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_98812:FunctionDef_L22_C4", "label": "tearDown", "type": "function", "loc": [22, 24], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98812:ClassDef_L11_C0", "vector": [2, 1, 0.3333, 0.0435, 1, 0.06, 0.3333, 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.DEBUG = self.old_DEBUG\n Site._meta.installed = self.old_Site_meta_installed"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98812:Assign_L23_C8", "label": "settings.DEBUG =", "type": "assigned_variable", "loc": [23, 23], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98812:FunctionDef_L22_C4", "vector": [14, 2, 0.3333, 0.0145, 2, 0.91, 0.0, 754, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "settings.DEBUG", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " settings.DEBUG = self.old_DEBUG"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98812:Assign_L24_C8", "label": "Site._meta.installed =", "type": "assigned_variable", "loc": [24, 24], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98812:FunctionDef_L22_C4", "vector": [14, 2, 0.3478, 0.0145, 2, 0.91, 1.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_98812:FunctionDef_L26_C4", "label": "test_lookup_cache", "type": "function", "loc": [26, 47], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98812:ClassDef_L11_C0", "vector": [2, 1, 0.529, 0.3188, 1, 0.06, 0.6667, 790, 0, 1, 0, 0, 0, 0, 14], "semantic": {"name": "test_lookup_cache", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def test_lookup_cache(self):\n \"\"\"\n Make sure that the content type cache (see ContentTypeManager)\n works correctly. Lookups for a particular content type -- by model or\n by ID -- should hit the database only on the first lookup.\n \"\"\"\n\n # At this point, a lookup for a ContentType should hit the DB"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98812:Expr_L27_C8", "label": "expression", "type": "expression", "loc": [27, 31], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98812:FunctionDef_L26_C4", "vector": [8, 2, 0.4203, 0.0725, 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 Make sure that the content type cache (see ContentTypeManager)\n works correctly. Lookups for a particular content type -- by model or\n by ID -- should hit the database only on the first lookup.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98812:Expr_L34_C8", "label": "get_for_model()", "type": "expression", "loc": [34, 34], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98812:FunctionDef_L26_C4", "vector": [8, 2, 0.4928, 0.0145, 2, 0.01, 0.1, 752, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "get_for_model", "arg_names": [], "import_names": [], "rhs_call_name": "get_for_model", "annotation": ""}, "snippet": " ContentType.objects.get_for_model(ContentType)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98812:Expr_L35_C8", "label": "assertEqual()", "type": "expression", "loc": [35, 35], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98812:FunctionDef_L26_C4", "vector": [8, 2, 0.5072, 0.0145, 2, 0.01, 0.2, 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(db.connection.queries))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98812:Assign_L38_C8", "label": "ct = get_for_model()", "type": "assigned_variable", "loc": [38, 38], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98812:FunctionDef_L26_C4", "vector": [14, 2, 0.5507, 0.0145, 2, 0.01, 0.3, 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(ContentType)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98812:Expr_L39_C8", "label": "assertEqual()", "type": "expression", "loc": [39, 39], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98812:FunctionDef_L26_C4", "vector": [8, 2, 0.5652, 0.0145, 2, 0.01, 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(1, len(db.connection.queries))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98812:Expr_L40_C8", "label": "get_for_id()", "type": "expression", "loc": [40, 40], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98812:FunctionDef_L26_C4", "vector": [8, 2, 0.5797, 0.0145, 2, 0.01, 0.5, 934, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "get_for_id", "arg_names": [], "import_names": [], "rhs_call_name": "get_for_id", "annotation": ""}, "snippet": " ContentType.objects.get_for_id(ct.id)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98812:Expr_L41_C8", "label": "assertEqual()", "type": "expression", "loc": [41, 41], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98812:FunctionDef_L26_C4", "vector": [8, 2, 0.5942, 0.0145, 2, 0.01, 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(1, len(db.connection.queries))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98812:Expr_L44_C8", "label": "clear_cache()", "type": "expression", "loc": [44, 44], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98812:FunctionDef_L26_C4", "vector": [8, 2, 0.6377, 0.0145, 2, 0.01, 0.7, 808, 3, 0, 0, 0, 0, 0, 1], "semantic": {"name": "clear_cache", "arg_names": [], "import_names": [], "rhs_call_name": "clear_cache", "annotation": ""}, "snippet": " ContentType.objects.clear_cache()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98812:Expr_L45_C8", "label": "get_for_model()", "type": "expression", "loc": [45, 45], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98812:FunctionDef_L26_C4", "vector": [8, 2, 0.6522, 0.0145, 2, 0.01, 0.8, 752, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "get_for_model", "arg_names": [], "import_names": [], "rhs_call_name": "get_for_model", "annotation": ""}, "snippet": " ContentType.objects.get_for_model(ContentType)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98812:Expr_L46_C8", "label": "len()", "type": "expression", "loc": [46, 46], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98812:FunctionDef_L26_C4", "vector": [8, 2, 0.6667, 0.0145, 2, 0.01, 0.9, 890, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "len", "arg_names": [], "import_names": [], "rhs_call_name": "len", "annotation": ""}, "snippet": " len(db.connection.queries)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98812:Expr_L47_C8", "label": "assertEqual()", "type": "expression", "loc": [47, 47], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98812:FunctionDef_L26_C4", "vector": [8, 2, 0.6812, 0.0145, 2, 0.01, 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, len(db.connection.queries))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98812:FunctionDef_L49_C4", "label": "test_shortcut_view", "type": "function", "loc": [49, 69], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98812:ClassDef_L11_C0", "vector": [2, 1, 0.8551, 0.3043, 1, 0.06, 1.0, 875, 0, 1, 0, 0, 0, 0, 9], "semantic": {"name": "test_shortcut_view", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def test_shortcut_view(self):\n \"\"\"\n Check that the shortcut view (used for the admin \"view on site\"\n functionality) returns a complete URL regardless of whether the sites\n framework is installed\n \"\"\"\n\n request = HttpRequest()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98812:Expr_L50_C8", "label": "expression", "type": "expression", "loc": [50, 54], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98812:FunctionDef_L49_C4", "vector": [8, 2, 0.7536, 0.0725, 2, 0.18, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"\n Check that the shortcut view (used for the admin \"view on site\"\n functionality) returns a complete URL regardless of whether the sites\n framework is installed\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98812:Assign_L56_C8", "label": "request = HttpRequest()", "type": "assigned_variable", "loc": [56, 56], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98812:FunctionDef_L49_C4", "vector": [14, 2, 0.8116, 0.0145, 2, 0.18, 0.0909, 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_98812:Assign_L57_C8", "label": "request.META =", "type": "assigned_variable", "loc": [57, 60], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98812:FunctionDef_L49_C4", "vector": [14, 2, 0.8478, 0.058, 2, 0.18, 0.1818, 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_98812:ImportFrom_L61_C8", "label": "from django.contrib.auth.models import User", "type": "import", "loc": [61, 61], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98812:FunctionDef_L49_C4", "vector": [1, 2, 0.8841, 0.0145, 2, 0.18, 0.2727, 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_98812:Assign_L62_C8", "label": "user_ct = get_for_model()", "type": "assigned_variable", "loc": [62, 62], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98812:FunctionDef_L49_C4", "vector": [14, 2, 0.8986, 0.0145, 2, 0.18, 0.3636, 413, 3, 1, 0, 0, 752, 10, 1], "semantic": {"name": "user_ct", "arg_names": [], "import_names": [], "rhs_call_name": "get_for_model", "annotation": ""}, "snippet": " user_ct = ContentType.objects.get_for_model(User)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98812:Assign_L63_C8", "label": "obj = create()", "type": "assigned_variable", "loc": [63, 63], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98812:FunctionDef_L49_C4", "vector": [14, 2, 0.913, 0.0145, 2, 0.18, 0.4545, 505, 3, 1, 0, 0, 316, 10, 1], "semantic": {"name": "obj", "arg_names": [], "import_names": [], "rhs_call_name": "create", "annotation": ""}, "snippet": " obj = User.objects.create(username=\"john\")"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98812:Assign_L64_C8", "label": "Site._meta.installed =", "type": "assigned_variable", "loc": [64, 64], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98812:FunctionDef_L49_C4", "vector": [14, 2, 0.9275, 0.0145, 2, 0.18, 0.5455, 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_98812:Assign_L65_C8", "label": "response = shortcut()", "type": "assigned_variable", "loc": [65, 65], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98812:FunctionDef_L49_C4", "vector": [14, 2, 0.942, 0.0145, 2, 0.18, 0.6364, 511, 3, 3, 0, 0, 63, 10, 1], "semantic": {"name": "response", "arg_names": [], "import_names": [], "rhs_call_name": "shortcut", "annotation": ""}, "snippet": " response = shortcut(request, user_ct.id, obj.id)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98812:Expr_L66_C8", "label": "assertEqual()", "type": "expression", "loc": [66, 66], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98812:FunctionDef_L49_C4", "vector": [8, 2, 0.9565, 0.0145, 2, 0.18, 0.7273, 299, 3, 2, 0, 0, 0, 0, 2], "semantic": {"name": "assertEqual", "arg_names": [], "import_names": [], "rhs_call_name": "assertEqual", "annotation": ""}, "snippet": " self.assertEqual(\"http://example.com/users/john/\", response._headers.get(\"location\")[1])"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98812:Assign_L67_C8", "label": "Site._meta.installed =", "type": "assigned_variable", "loc": [67, 67], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98812:FunctionDef_L49_C4", "vector": [14, 2, 0.971, 0.0145, 2, 0.18, 0.8182, 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_98812:Assign_L68_C8", "label": "response = shortcut()", "type": "assigned_variable", "loc": [68, 68], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98812:FunctionDef_L49_C4", "vector": [14, 2, 0.9855, 0.0145, 2, 0.18, 0.9091, 511, 3, 3, 0, 0, 63, 10, 1], "semantic": {"name": "response", "arg_names": [], "import_names": [], "rhs_call_name": "shortcut", "annotation": ""}, "snippet": " response = shortcut(request, user_ct.id, obj.id)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98812:Expr_L69_C8", "label": "assertEqual()", "type": "expression", "loc": [69, 69], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98812:FunctionDef_L49_C4", "vector": [8, 2, 1.0, 0.0145, 2, 0.18, 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(\"http://Example.com/users/john/\", response._headers.get(\"location\")[1])"}]
[{"f": "ajibawa-2023/Python-Code-Large/train/row_98812:ClassDef_L11_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98812:FunctionDef_L13_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98812:FunctionDef_L13_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98812:Assign_L16_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98812:FunctionDef_L13_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98812:Assign_L17_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98812:FunctionDef_L13_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98812:Assign_L18_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98812:FunctionDef_L13_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98812:Expr_L19_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98812:FunctionDef_L13_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98812:Expr_L20_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98812:ClassDef_L11_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98812:FunctionDef_L22_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98812:FunctionDef_L22_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98812:Assign_L23_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98812:FunctionDef_L22_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98812:Assign_L24_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98812:ClassDef_L11_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98812:FunctionDef_L26_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98812:FunctionDef_L26_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98812:Expr_L27_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98812:FunctionDef_L26_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98812:Expr_L34_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98812:FunctionDef_L26_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98812:Expr_L35_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98812:FunctionDef_L26_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98812:Assign_L38_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98812:FunctionDef_L26_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98812:Expr_L39_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98812:FunctionDef_L26_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98812:Expr_L40_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98812:FunctionDef_L26_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98812:Expr_L41_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98812:FunctionDef_L26_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98812:Expr_L44_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98812:FunctionDef_L26_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98812:Expr_L45_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98812:FunctionDef_L26_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98812:Expr_L46_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98812:FunctionDef_L26_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98812:Expr_L47_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98812:ClassDef_L11_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98812:FunctionDef_L49_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98812:FunctionDef_L49_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98812:Expr_L50_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98812:FunctionDef_L49_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98812:Assign_L56_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98812:FunctionDef_L49_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98812:Assign_L57_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98812:FunctionDef_L49_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98812:ImportFrom_L61_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98812:FunctionDef_L49_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98812:Assign_L62_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98812:FunctionDef_L49_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98812:Assign_L63_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98812:FunctionDef_L49_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98812:Assign_L64_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98812:FunctionDef_L49_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98812:Assign_L65_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98812:FunctionDef_L49_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98812:Expr_L66_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98812:FunctionDef_L49_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98812:Assign_L67_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98812:FunctionDef_L49_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98812:Assign_L68_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98812:FunctionDef_L49_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98812:Expr_L69_C8"}]
""" Classes allowing "generic" relations through ContentType and object-id fields. """ from django.core.exceptions import ObjectDoesNotExist from django.db import connection from django.db.models import signals from django.db import models, router, DEFAULT_DB_ALIAS from django.db.models.fields.related import RelatedField, Field, ManyToManyRel from django.db.models.loading import get_model from django.forms import ModelForm from django.forms.models import BaseModelFormSet, modelformset_factory, save_instance from django.contrib.admin.options import InlineModelAdmin, flatten_fieldsets from django.utils.encoding import smart_unicode from django.utils.functional import curry from django.contrib.contenttypes.models import ContentType class GenericForeignKey(object): """ Provides a generic relation to any object through content-type/object-id fields. """ def __init__(self, ct_field="content_type", fk_field="object_id"): self.ct_field = ct_field self.fk_field = fk_field def contribute_to_class(self, cls, name): self.name = name self.model = cls self.cache_attr = "_%s_cache" % name cls._meta.add_virtual_field(self) # For some reason I don't totally understand, using weakrefs here doesn't work. signals.pre_init.connect(self.instance_pre_init, sender=cls, weak=False) # Connect myself as the descriptor for this field setattr(cls, name, self) def instance_pre_init(self, signal, sender, args, kwargs, **_kwargs): """ Handles initializing an object with the generic FK instaed of content-type/object-id fields. """ if self.name in kwargs: value = kwargs.pop(self.name) kwargs[self.ct_field] = self.get_content_type(obj=value) kwargs[self.fk_field] = value._get_pk_val() def get_content_type(self, obj=None, id=None, using=None): # Convenience function using get_model avoids a circular import when # using this model ContentType = get_model("contenttypes", "contenttype") if obj: return ContentType.objects.db_manager(obj._state.db).get_for_model(obj) elif id: return ContentType.objects.db_manager(using).get_for_id(id) else: # This should never happen. I love comments like this, don't you? raise Exception("Impossible arguments to GFK.get_content_type!") def __get__(self, instance, instance_type=None): if instance is None: return self try: return getattr(instance, self.cache_attr) except AttributeError: rel_obj = None # Make sure to use ContentType.objects.get_for_id() to ensure that # lookups are cached (see ticket #5570). This takes more code than # the naive ``getattr(instance, self.ct_field)``, but has better # performance when dealing with GFKs in loops and such. f = self.model._meta.get_field(self.ct_field) ct_id = getattr(instance, f.get_attname(), None) if ct_id: ct = self.get_content_type(id=ct_id, using=instance._state.db) try: rel_obj = ct.get_object_for_this_type(pk=getattr(instance, self.fk_field)) except ObjectDoesNotExist: pass setattr(instance, self.cache_attr, rel_obj) return rel_obj def __set__(self, instance, value): if instance is None: raise AttributeError(u"%s must be accessed via instance" % self.related.opts.object_name) ct = None fk = None if value is not None: ct = self.get_content_type(obj=value) fk = value._get_pk_val() setattr(instance, self.ct_field, ct) setattr(instance, self.fk_field, fk) setattr(instance, self.cache_attr, value) class GenericRelation(RelatedField, Field): """Provides an accessor to generic related objects (e.g. comments)""" def __init__(self, to, **kwargs): kwargs['verbose_name'] = kwargs.get('verbose_name', None) kwargs['rel'] = GenericRel(to, related_name=kwargs.pop('related_name', None), limit_choices_to=kwargs.pop('limit_choices_to', None), symmetrical=kwargs.pop('symmetrical', True)) # Override content-type/object-id field names on the related class self.object_id_field_name = kwargs.pop("object_id_field", "object_id") self.content_type_field_name = kwargs.pop("content_type_field", "content_type") kwargs['blank'] = True kwargs['editable'] = False kwargs['serialize'] = False Field.__init__(self, **kwargs) def get_choices_default(self): return Field.get_choices(self, include_blank=False) def value_to_string(self, obj): qs = getattr(obj, self.name).all() return smart_unicode([instance._get_pk_val() for instance in qs]) def m2m_db_table(self): return self.rel.to._meta.db_table def m2m_column_name(self): return self.object_id_field_name def m2m_reverse_name(self): return self.rel.to._meta.pk.column def contribute_to_class(self, cls, name): super(GenericRelation, self).contribute_to_class(cls, name) # Save a reference to which model this class is on for future use self.model = cls # Add the descriptor for the m2m relation setattr(cls, self.name, ReverseGenericRelatedObjectsDescriptor(self)) def contribute_to_related_class(self, cls, related): pass def set_attributes_from_rel(self): pass def get_internal_type(self): return "ManyToManyField" def db_type(self, connection): # Since we're simulating a ManyToManyField, in effect, best return the # same db_type as well. return None def extra_filters(self, pieces, pos, negate): """ Return an extra filter to the queryset so that the results are filtered on the appropriate content type. """ if negate: return [] ContentType = get_model("contenttypes", "contenttype") content_type = ContentType.objects.get_for_model(self.model) prefix = "__".join(pieces[:pos + 1]) return [("%s__%s" % (prefix, self.content_type_field_name), content_type)] def bulk_related_objects(self, objs, using=DEFAULT_DB_ALIAS): """ Return all objects related to ``objs`` via this ``GenericRelation``. """ return self.rel.to._base_manager.db_manager(using).filter(**{ "%s__pk" % self.content_type_field_name: ContentType.objects.db_manager(using).get_for_model(self.model).pk, "%s__in" % self.object_id_field_name: [obj.pk for obj in objs] }) class ReverseGenericRelatedObjectsDescriptor(object): """ This class provides the functionality that makes the related-object managers available as attributes on a model class, for fields that have multiple "remote" values and have a GenericRelation defined in their model (rather than having another model pointed *at* them). In the example "article.publications", the publications attribute is a ReverseGenericRelatedObjectsDescriptor instance. """ def __init__(self, field): self.field = field def __get__(self, instance, instance_type=None): if instance is None: return self # This import is done here to avoid circular import importing this module from django.contrib.contenttypes.models import ContentType # Dynamically create a class that subclasses the related model's # default manager. rel_model = self.field.rel.to superclass = rel_model._default_manager.__class__ RelatedManager = create_generic_related_manager(superclass) qn = connection.ops.quote_name manager = RelatedManager( model = rel_model, instance = instance, symmetrical = (self.field.rel.symmetrical and instance.__class__ == rel_model), join_table = qn(self.field.m2m_db_table()), source_col_name = qn(self.field.m2m_column_name()), target_col_name = qn(self.field.m2m_reverse_name()), content_type = ContentType.objects.db_manager(instance._state.db).get_for_model(instance), content_type_field_name = self.field.content_type_field_name, object_id_field_name = self.field.object_id_field_name ) return manager def __set__(self, instance, value): if instance is None: raise AttributeError("Manager must be accessed via instance") manager = self.__get__(instance) manager.clear() for obj in value: manager.add(obj) def create_generic_related_manager(superclass): """ Factory function for a manager that subclasses 'superclass' (which is a Manager) and adds behavior for generic related objects. """ class GenericRelatedObjectManager(superclass): def __init__(self, model=None, core_filters=None, instance=None, symmetrical=None, join_table=None, source_col_name=None, target_col_name=None, content_type=None, content_type_field_name=None, object_id_field_name=None): super(GenericRelatedObjectManager, self).__init__() self.core_filters = core_filters or {} self.model = model self.content_type = content_type self.symmetrical = symmetrical self.instance = instance self.join_table = join_table self.join_table = model._meta.db_table self.source_col_name = source_col_name self.target_col_name = target_col_name self.content_type_field_name = content_type_field_name self.object_id_field_name = object_id_field_name self.pk_val = self.instance._get_pk_val() def get_query_set(self): db = self._db or router.db_for_read(self.model, instance=self.instance) query = { '%s__pk' % self.content_type_field_name : self.content_type.id, '%s__exact' % self.object_id_field_name : self.pk_val, } return superclass.get_query_set(self).using(db).filter(**query) def add(self, *objs): for obj in objs: if not isinstance(obj, self.model): raise TypeError("'%s' instance expected" % self.model._meta.object_name) setattr(obj, self.content_type_field_name, self.content_type) setattr(obj, self.object_id_field_name, self.pk_val) obj.save() add.alters_data = True def remove(self, *objs): db = router.db_for_write(self.model, instance=self.instance) for obj in objs: obj.delete(using=db) remove.alters_data = True def clear(self): db = router.db_for_write(self.model, instance=self.instance) for obj in self.all(): obj.delete(using=db) clear.alters_data = True def create(self, **kwargs): kwargs[self.content_type_field_name] = self.content_type kwargs[self.object_id_field_name] = self.pk_val db = router.db_for_write(self.model, instance=self.instance) return super(GenericRelatedObjectManager, self).using(db).create(**kwargs) create.alters_data = True return GenericRelatedObjectManager class GenericRel(ManyToManyRel): def __init__(self, to, related_name=None, limit_choices_to=None, symmetrical=True): self.to = to self.related_name = related_name self.limit_choices_to = limit_choices_to or {} self.symmetrical = symmetrical self.multiple = True self.through = None class BaseGenericInlineFormSet(BaseModelFormSet): """ A formset for generic inline objects to a parent. """ def __init__(self, data=None, files=None, instance=None, save_as_new=None, prefix=None, queryset=None): # Avoid a circular import. from django.contrib.contenttypes.models import ContentType opts = self.model._meta self.instance = instance self.rel_name = '-'.join(( opts.app_label, opts.object_name.lower(), self.ct_field.name, self.ct_fk_field.name, )) if self.instance is None or self.instance.pk is None: qs = self.model._default_manager.none() else: if queryset is None: queryset = self.model._default_manager qs = queryset.filter(**{ self.ct_field.name: ContentType.objects.get_for_model(self.instance), self.ct_fk_field.name: self.instance.pk, }) super(BaseGenericInlineFormSet, self).__init__( queryset=qs, data=data, files=files, prefix=prefix ) #@classmethod def get_default_prefix(cls): opts = cls.model._meta return '-'.join((opts.app_label, opts.object_name.lower(), cls.ct_field.name, cls.ct_fk_field.name, )) get_default_prefix = classmethod(get_default_prefix) def save_new(self, form, commit=True): # Avoid a circular import. from django.contrib.contenttypes.models import ContentType kwargs = { self.ct_field.get_attname(): ContentType.objects.get_for_model(self.instance).pk, self.ct_fk_field.get_attname(): self.instance.pk, } new_obj = self.model(**kwargs) return save_instance(form, new_obj, commit=commit) def generic_inlineformset_factory(model, form=ModelForm, formset=BaseGenericInlineFormSet, ct_field="content_type", fk_field="object_id", fields=None, exclude=None, extra=3, can_order=False, can_delete=True, max_num=None, formfield_callback=lambda f: f.formfield()): """ Returns an ``GenericInlineFormSet`` for the given kwargs. You must provide ``ct_field`` and ``object_id`` if they different from the defaults ``content_type`` and ``object_id`` respectively. """ opts = model._meta # Avoid a circular import. from django.contrib.contenttypes.models import ContentType # if there is no field called `ct_field` let the exception propagate ct_field = opts.get_field(ct_field) if not isinstance(ct_field, models.ForeignKey) or ct_field.rel.to != ContentType: raise Exception("fk_name '%s' is not a ForeignKey to ContentType" % ct_field) fk_field = opts.get_field(fk_field) # let the exception propagate if exclude is not None: exclude = list(exclude) exclude.extend([ct_field.name, fk_field.name]) else: exclude = [ct_field.name, fk_field.name] FormSet = modelformset_factory(model, form=form, formfield_callback=formfield_callback, formset=formset, extra=extra, can_delete=can_delete, can_order=can_order, fields=fields, exclude=exclude, max_num=max_num) FormSet.ct_field = ct_field FormSet.ct_fk_field = fk_field return FormSet class GenericInlineModelAdmin(InlineModelAdmin): ct_field = "content_type" ct_fk_field = "object_id" formset = BaseGenericInlineFormSet def get_formset(self, request, obj=None): 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(self.get_readonly_fields(request, obj)) exclude = exclude or None defaults = { "ct_field": self.ct_field, "fk_field": self.ct_fk_field, "form": self.form, "formfield_callback": curry(self.formfield_for_dbfield, request=request), "formset": self.formset, "extra": self.extra, "can_delete": self.can_delete, "can_order": False, "fields": fields, "max_num": self.max_num, "exclude": exclude } return generic_inlineformset_factory(self.model, **defaults) class GenericStackedInline(GenericInlineModelAdmin): template = 'admin/edit_inline/stacked.html' class GenericTabularInline(GenericInlineModelAdmin): template = 'admin/edit_inline/tabular.html'
ajibawa-2023/Python-Code-Large/train/row_98813
233
426
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_98813:Expr_L1_C0", "label": "expression", "type": "expression", "loc": [1, 3], "level": 0, "parent": null, "vector": [8, 0, 0.0047, 0.007, 0, 0.66, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "\"\"\"\nClasses allowing \"generic\" relations through ContentType and object-id fields.\n\"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98813:ImportFrom_L5_C0", "label": "from django.core.exceptions import ObjectDoesNotExist", "type": "import", "loc": [5, 5], "level": 0, "parent": null, "vector": [1, 0, 0.0117, 0.0023, 0, 0.66, 0.0455, 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_98813:ImportFrom_L6_C0", "label": "from django.db import connection", "type": "import", "loc": [6, 6], "level": 0, "parent": null, "vector": [1, 0, 0.0141, 0.0023, 0, 0.66, 0.0909, 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_98813:ImportFrom_L7_C0", "label": "from django.db.models import signals", "type": "import", "loc": [7, 7], "level": 0, "parent": null, "vector": [1, 0, 0.0164, 0.0023, 0, 0.66, 0.1364, 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_98813:ImportFrom_L8_C0", "label": "from django.db import models, router, DEFAULT_DB_ALIAS", "type": "import", "loc": [8, 8], "level": 0, "parent": null, "vector": [1, 0, 0.0188, 0.0023, 0, 0.66, 0.1818, 40, 0, 3, 0, 0, 40, 0, 0], "semantic": {"name": "django.db", "arg_names": [], "import_names": ["models", "router", "DEFAULT_DB_ALIAS"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.db import models, router, DEFAULT_DB_ALIAS"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98813:ImportFrom_L9_C0", "label": "from django.db.models.fields.related import RelatedField, Field, ManyToManyRel", "type": "import", "loc": [9, 9], "level": 0, "parent": null, "vector": [1, 0, 0.0211, 0.0023, 0, 0.66, 0.2273, 410, 0, 3, 0, 0, 410, 0, 0], "semantic": {"name": "django.db.models.fields.related", "arg_names": [], "import_names": ["RelatedField", "Field", "ManyToManyRel"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.db.models.fields.related import RelatedField, Field, ManyToManyRel"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98813:ImportFrom_L10_C0", "label": "from django.db.models.loading import get_model", "type": "import", "loc": [10, 10], "level": 0, "parent": null, "vector": [1, 0, 0.0235, 0.0023, 0, 0.66, 0.2727, 343, 0, 1, 0, 0, 343, 0, 0], "semantic": {"name": "django.db.models.loading", "arg_names": [], "import_names": ["get_model"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.db.models.loading import get_model"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98813:ImportFrom_L11_C0", "label": "from django.forms import ModelForm", "type": "import", "loc": [11, 11], "level": 0, "parent": null, "vector": [1, 0, 0.0258, 0.0023, 0, 0.66, 0.3182, 666, 0, 1, 0, 0, 666, 0, 0], "semantic": {"name": "django.forms", "arg_names": [], "import_names": ["ModelForm"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.forms import ModelForm"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98813:ImportFrom_L12_C0", "label": "from django.forms.models import BaseModelFormSet, modelformset_factory, save_instance", "type": "import", "loc": [12, 12], "level": 0, "parent": null, "vector": [1, 0, 0.0282, 0.0023, 0, 0.66, 0.3636, 625, 0, 3, 0, 0, 625, 0, 0], "semantic": {"name": "django.forms.models", "arg_names": [], "import_names": ["BaseModelFormSet", "modelformset_factory", "save_instance"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.forms.models import BaseModelFormSet, modelformset_factory, save_instance"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98813:ImportFrom_L13_C0", "label": "from django.contrib.admin.options import InlineModelAdmin, flatten_fieldsets", "type": "import", "loc": [13, 13], "level": 0, "parent": null, "vector": [1, 0, 0.0305, 0.0023, 0, 0.66, 0.4091, 84, 0, 2, 0, 0, 84, 0, 0], "semantic": {"name": "django.contrib.admin.options", "arg_names": [], "import_names": ["InlineModelAdmin", "flatten_fieldsets"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.contrib.admin.options import InlineModelAdmin, flatten_fieldsets"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98813:ImportFrom_L14_C0", "label": "from django.utils.encoding import smart_unicode", "type": "import", "loc": [14, 14], "level": 0, "parent": null, "vector": [1, 0, 0.0329, 0.0023, 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_98813:ImportFrom_L15_C0", "label": "from django.utils.functional import curry", "type": "import", "loc": [15, 15], "level": 0, "parent": null, "vector": [1, 0, 0.0352, 0.0023, 0, 0.66, 0.5, 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_98813:ImportFrom_L17_C0", "label": "from django.contrib.contenttypes.models import ContentType", "type": "import", "loc": [17, 17], "level": 0, "parent": null, "vector": [1, 0, 0.0399, 0.0023, 0, 0.66, 0.5455, 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_98813:ClassDef_L20_C0", "label": "GenericForeignKey", "type": "class", "loc": [20, 100], "level": 0, "parent": null, "vector": [3, 0, 0.1408, 0.1901, 0, 0.66, 0.5909, 60, 0, 6, 0, 0, 186, 0, 26], "semantic": {"name": "GenericForeignKey", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class GenericForeignKey(object):\n \"\"\"\n Provides a generic relation to any object through content-type/object-id\n fields.\n \"\"\"\n\n def __init__(self, ct_field=\"content_type\", fk_field=\"object_id\"):\n self.ct_field = ct_field"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98813:Expr_L21_C4", "label": "expression", "type": "expression", "loc": [21, 24], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98813:ClassDef_L20_C0", "vector": [8, 1, 0.0528, 0.0094, 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 Provides a generic relation to any object through content-type/object-id\n fields.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L26_C4", "label": "__init__", "type": "function", "loc": [26, 28], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98813:ClassDef_L20_C0", "vector": [2, 1, 0.0634, 0.007, 1, 0.01, 0.1667, 555, 0, 3, 0, 0, 0, 0, 0], "semantic": {"name": "__init__", "arg_names": ["self", "ct_field", "fk_field"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def __init__(self, ct_field=\"content_type\", fk_field=\"object_id\"):\n self.ct_field = ct_field\n self.fk_field = fk_field"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98813:Assign_L27_C8", "label": "self.ct_field =", "type": "assigned_variable", "loc": [27, 27], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L26_C4", "vector": [14, 2, 0.0634, 0.0023, 2, 0.75, 0.0, 276, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "self.ct_field", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.ct_field = ct_field"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98813:Assign_L28_C8", "label": "self.fk_field =", "type": "assigned_variable", "loc": [28, 28], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L26_C4", "vector": [14, 2, 0.0657, 0.0023, 2, 0.75, 1.0, 941, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "self.fk_field", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.fk_field = fk_field"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L30_C4", "label": "contribute_to_class", "type": "function", "loc": [30, 40], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98813:ClassDef_L20_C0", "vector": [2, 1, 0.0822, 0.0258, 1, 0.01, 0.3333, 973, 0, 3, 0, 0, 0, 0, 3], "semantic": {"name": "contribute_to_class", "arg_names": ["self", "cls", "name"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def contribute_to_class(self, cls, name):\n self.name = name\n self.model = cls\n self.cache_attr = \"_%s_cache\" % name\n cls._meta.add_virtual_field(self)\n\n # For some reason I don't totally understand, using weakrefs here doesn't work.\n signals.pre_init.connect(self.instance_pre_init, sender=cls, weak=False)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98813:Assign_L31_C8", "label": "self.name =", "type": "assigned_variable", "loc": [31, 31], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L30_C4", "vector": [14, 2, 0.0728, 0.0023, 2, 0.95, 0.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_98813:Assign_L32_C8", "label": "self.model =", "type": "assigned_variable", "loc": [32, 32], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L30_C4", "vector": [14, 2, 0.0751, 0.0023, 2, 0.95, 0.2, 81, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "self.model", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.model = cls"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98813:Assign_L33_C8", "label": "self.cache_attr =", "type": "assigned_variable", "loc": [33, 33], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L30_C4", "vector": [14, 2, 0.0775, 0.0023, 2, 0.95, 0.4, 324, 4, 0, 0, 0, 0, 0, 0], "semantic": {"name": "self.cache_attr", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.cache_attr = \"_%s_cache\" % name"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98813:Expr_L34_C8", "label": "add_virtual_field()", "type": "expression", "loc": [34, 34], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L30_C4", "vector": [8, 2, 0.0798, 0.0023, 2, 0.95, 0.6, 366, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "add_virtual_field", "arg_names": [], "import_names": [], "rhs_call_name": "add_virtual_field", "annotation": ""}, "snippet": " cls._meta.add_virtual_field(self)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98813:Expr_L37_C8", "label": "connect()", "type": "expression", "loc": [37, 37], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L30_C4", "vector": [8, 2, 0.0869, 0.0023, 2, 0.95, 0.8, 242, 3, 3, 0, 0, 0, 0, 1], "semantic": {"name": "connect", "arg_names": [], "import_names": [], "rhs_call_name": "connect", "annotation": ""}, "snippet": " signals.pre_init.connect(self.instance_pre_init, sender=cls, weak=False)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98813:Expr_L40_C8", "label": "setattr()", "type": "expression", "loc": [40, 40], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L30_C4", "vector": [8, 2, 0.0939, 0.0023, 2, 0.95, 1.0, 501, 3, 3, 0, 0, 0, 0, 1], "semantic": {"name": "setattr", "arg_names": [], "import_names": [], "rhs_call_name": "setattr", "annotation": ""}, "snippet": " setattr(cls, name, self)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L42_C4", "label": "instance_pre_init", "type": "function", "loc": [42, 50], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98813:ClassDef_L20_C0", "vector": [2, 1, 0.108, 0.0211, 1, 0.01, 0.5, 393, 0, 6, 0, 0, 0, 0, 3], "semantic": {"name": "instance_pre_init", "arg_names": ["self", "signal", "sender", "args", "kwargs", "_kwargs"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def instance_pre_init(self, signal, sender, args, kwargs, **_kwargs):\n \"\"\"\n Handles initializing an object with the generic FK instaed of\n content-type/object-id fields.\n \"\"\"\n if self.name in kwargs:\n value = kwargs.pop(self.name)\n kwargs[self.ct_field] = self.get_content_type(obj=value)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98813:Expr_L43_C8", "label": "expression", "type": "expression", "loc": [43, 46], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L42_C4", "vector": [8, 2, 0.1045, 0.0094, 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 Handles initializing an object with the generic FK instaed of\n content-type/object-id fields.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98813:If_L47_C8", "label": "if", "type": "if", "loc": [47, 50], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L42_C4", "vector": [4, 2, 0.1138, 0.0094, 2, 0.12, 1.0, 0, 0, 0, 0, 0, 0, 0, 3], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if self.name in kwargs:\n value = kwargs.pop(self.name)\n kwargs[self.ct_field] = self.get_content_type(obj=value)\n kwargs[self.fk_field] = value._get_pk_val()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98813:Assign_L48_C12", "label": "value = pop()", "type": "assigned_variable", "loc": [48, 48], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98813:If_L47_C8", "vector": [14, 3, 0.1127, 0.0023, 3, 0.11, 0.0, 441, 3, 1, 0, 0, 969, 10, 1], "semantic": {"name": "value", "arg_names": [], "import_names": [], "rhs_call_name": "pop", "annotation": ""}, "snippet": " value = kwargs.pop(self.name)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98813:Assign_L49_C12", "label": " = get_content_type()", "type": "assigned_variable", "loc": [49, 49], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98813:If_L47_C8", "vector": [14, 3, 0.115, 0.0023, 3, 0.11, 0.5, 0, 3, 1, 0, 0, 367, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "get_content_type", "annotation": ""}, "snippet": " kwargs[self.ct_field] = self.get_content_type(obj=value)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98813:Assign_L50_C12", "label": " = _get_pk_val()", "type": "assigned_variable", "loc": [50, 50], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98813:If_L47_C8", "vector": [14, 3, 0.1174, 0.0023, 3, 0.11, 1.0, 0, 3, 0, 0, 0, 743, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "_get_pk_val", "annotation": ""}, "snippet": " kwargs[self.fk_field] = value._get_pk_val()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L52_C4", "label": "get_content_type", "type": "function", "loc": [52, 62], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98813:ClassDef_L20_C0", "vector": [2, 1, 0.1338, 0.0258, 1, 0.01, 0.6667, 367, 0, 4, 1, 0, 0, 0, 6], "semantic": {"name": "get_content_type", "arg_names": ["self", "obj", "id", "using"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def get_content_type(self, obj=None, id=None, using=None):\n # Convenience function using get_model avoids a circular import when\n # using this model\n ContentType = get_model(\"contenttypes\", \"contenttype\")\n if obj:\n return ContentType.objects.db_manager(obj._state.db).get_for_model(obj)\n elif id:\n return ContentType.objects.db_manager(using).get_for_id(id)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98813:Assign_L55_C8", "label": "ContentType = get_model()", "type": "assigned_variable", "loc": [55, 55], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L52_C4", "vector": [14, 2, 0.1291, 0.0023, 2, 0.56, 0.0, 313, 3, 2, 0, 0, 115, 10, 1], "semantic": {"name": "ContentType", "arg_names": [], "import_names": [], "rhs_call_name": "get_model", "annotation": ""}, "snippet": " ContentType = get_model(\"contenttypes\", \"contenttype\")"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98813:If_L56_C8", "label": "if", "type": "if", "loc": [56, 62], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L52_C4", "vector": [4, 2, 0.1385, 0.0164, 2, 0.56, 1.0, 0, 2, 0, 0, 0, 0, 0, 5], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if obj:\n return ContentType.objects.db_manager(obj._state.db).get_for_model(obj)\n elif id:\n return ContentType.objects.db_manager(using).get_for_id(id)\n else:\n # This should never happen. I love comments like this, don't you?\n raise Exception(\"Impossible arguments to GFK.get_content_type!\")"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98813:Return_L57_C13", "label": "return", "type": "return", "loc": [57, 57], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98813:If_L56_C8", "vector": [13, 3, 0.1338, 0.0023, 3, 0.07, 0.0, 0, 3, 0, 0, 0, 0, 10, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return ContentType.objects.db_manager(obj._state.db).get_for_model(obj)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98813:If_L58_C8", "label": "if", "type": "if", "loc": [58, 62], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98813:If_L56_C8", "vector": [4, 3, 0.1408, 0.0117, 3, 0.07, 1.0, 0, 2, 0, 0, 0, 0, 0, 3], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " elif id:\n return ContentType.objects.db_manager(using).get_for_id(id)\n else:\n # This should never happen. I love comments like this, don't you?\n raise Exception(\"Impossible arguments to GFK.get_content_type!\")"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98813:Return_L59_C13", "label": "return", "type": "return", "loc": [59, 59], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98813:If_L58_C8", "vector": [13, 4, 0.1385, 0.0023, 4, 0.58, 0.0, 0, 3, 0, 0, 0, 0, 10, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return ContentType.objects.db_manager(using).get_for_id(id)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L64_C4", "label": "__get__", "type": "function", "loc": [64, 86], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98813:ClassDef_L20_C0", "vector": [2, 1, 0.1761, 0.054, 1, 0.01, 0.8333, 93, 0, 3, 1, 0, 0, 0, 8], "semantic": {"name": "__get__", "arg_names": ["self", "instance", "instance_type"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def __get__(self, instance, instance_type=None):\n if instance is None:\n return self\n\n try:\n return getattr(instance, self.cache_attr)\n except AttributeError:\n rel_obj = None"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98813:If_L65_C8", "label": "if", "type": "if", "loc": [65, 66], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L64_C4", "vector": [4, 2, 0.1538, 0.0047, 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 instance is None:\n return self"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98813:Return_L66_C12", "label": "return", "type": "return", "loc": [66, 66], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98813:If_L65_C8", "vector": [13, 3, 0.1549, 0.0023, 3, 0.75, 0.0, 0, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return self"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98813:Try_L68_C8", "label": "try", "type": "try", "loc": [68, 86], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L64_C4", "vector": [7, 2, 0.1808, 0.0446, 2, 0.33, 1.0, 0, 0, 1, 0, 0, 0, 0, 8], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " try:\n return getattr(instance, self.cache_attr)\n except AttributeError:\n rel_obj = None\n\n # Make sure to use ContentType.objects.get_for_id() to ensure that\n # lookups are cached (see ticket #5570). This takes more code than\n # the naive ``getattr(instance, self.ct_field)``, but has better"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98813:Return_L69_C12", "label": "return", "type": "return", "loc": [69, 69], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98813:Try_L68_C8", "vector": [13, 3, 0.162, 0.0023, 3, 0.43, 0.0, 0, 3, 0, 0, 0, 0, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return getattr(instance, self.cache_attr)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98813:Assign_L71_C12", "label": "rel_obj =", "type": "assigned_variable", "loc": [71, 71], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98813:Try_L68_C8", "vector": [14, 3, 0.1667, 0.0023, 3, 0.43, 0.0, 711, 1, 0, 0, 0, 0, 9, 0], "semantic": {"name": "rel_obj", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " rel_obj = None"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98813:Assign_L77_C12", "label": "f = get_field()", "type": "assigned_variable", "loc": [77, 77], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98813:Try_L68_C8", "vector": [14, 3, 0.1808, 0.0023, 3, 0.43, 0.2, 899, 3, 1, 0, 0, 389, 10, 1], "semantic": {"name": "f", "arg_names": [], "import_names": [], "rhs_call_name": "get_field", "annotation": ""}, "snippet": " f = self.model._meta.get_field(self.ct_field)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98813:Assign_L78_C12", "label": "ct_id = getattr()", "type": "assigned_variable", "loc": [78, 78], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98813:Try_L68_C8", "vector": [14, 3, 0.1831, 0.0023, 3, 0.43, 0.4, 996, 3, 3, 0, 0, 121, 10, 2], "semantic": {"name": "ct_id", "arg_names": [], "import_names": [], "rhs_call_name": "getattr", "annotation": ""}, "snippet": " ct_id = getattr(instance, f.get_attname(), None)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98813:If_L79_C12", "label": "if", "type": "if", "loc": [79, 84], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98813:Try_L68_C8", "vector": [4, 3, 0.1913, 0.0141, 3, 0.43, 0.6, 0, 2, 0, 0, 0, 0, 0, 3], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if ct_id:\n ct = self.get_content_type(id=ct_id, using=instance._state.db)\n try:\n rel_obj = ct.get_object_for_this_type(pk=getattr(instance, self.fk_field))\n except ObjectDoesNotExist:\n pass"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98813:Assign_L80_C16", "label": "ct = get_content_type()", "type": "assigned_variable", "loc": [80, 80], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98813:If_L79_C12", "vector": [14, 4, 0.1878, 0.0023, 4, 0.34, 0.0, 147, 3, 2, 0, 0, 367, 10, 1], "semantic": {"name": "ct", "arg_names": [], "import_names": [], "rhs_call_name": "get_content_type", "annotation": ""}, "snippet": " ct = self.get_content_type(id=ct_id, using=instance._state.db)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98813:Try_L81_C16", "label": "try", "type": "try", "loc": [81, 84], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98813:If_L79_C12", "vector": [7, 4, 0.1937, 0.0094, 4, 0.34, 1.0, 0, 0, 1, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " try:\n rel_obj = ct.get_object_for_this_type(pk=getattr(instance, self.fk_field))\n except ObjectDoesNotExist:\n pass"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98813:Assign_L82_C20", "label": "rel_obj = get_object_for_this_type()", "type": "assigned_variable", "loc": [82, 82], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98813:Try_L81_C16", "vector": [14, 5, 0.1925, 0.0023, 5, 0.09, 0.0, 711, 3, 1, 0, 0, 753, 10, 2], "semantic": {"name": "rel_obj", "arg_names": [], "import_names": [], "rhs_call_name": "get_object_for_this_type", "annotation": ""}, "snippet": " rel_obj = ct.get_object_for_this_type(pk=getattr(instance, self.fk_field))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98813:Expr_L85_C12", "label": "setattr()", "type": "expression", "loc": [85, 85], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98813:Try_L68_C8", "vector": [8, 3, 0.1995, 0.0023, 3, 0.43, 0.8, 501, 3, 3, 0, 0, 0, 0, 1], "semantic": {"name": "setattr", "arg_names": [], "import_names": [], "rhs_call_name": "setattr", "annotation": ""}, "snippet": " setattr(instance, self.cache_attr, rel_obj)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98813:Return_L86_C12", "label": "return", "type": "return", "loc": [86, 86], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98813:Try_L68_C8", "vector": [13, 3, 0.2019, 0.0023, 3, 0.43, 1.0, 0, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return rel_obj"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L88_C4", "label": "__set__", "type": "function", "loc": [88, 100], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98813:ClassDef_L20_C0", "vector": [2, 1, 0.2207, 0.0305, 1, 0.01, 1.0, 145, 0, 3, 0, 0, 0, 0, 6], "semantic": {"name": "__set__", "arg_names": ["self", "instance", "value"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def __set__(self, instance, value):\n if instance is None:\n raise AttributeError(u\"%s must be accessed via instance\" % self.related.opts.object_name)\n\n ct = None\n fk = None\n if value is not None:\n ct = self.get_content_type(obj=value)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98813:If_L89_C8", "label": "if", "type": "if", "loc": [89, 90], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L88_C4", "vector": [4, 2, 0.2101, 0.0047, 2, 0.38, 0.0, 0, 0, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if instance is None:\n raise AttributeError(u\"%s must be accessed via instance\" % self.related.opts.object_name)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98813:Assign_L92_C8", "label": "ct =", "type": "assigned_variable", "loc": [92, 92], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L88_C4", "vector": [14, 2, 0.216, 0.0023, 2, 0.38, 0.1667, 147, 1, 0, 0, 0, 0, 9, 0], "semantic": {"name": "ct", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " ct = None"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98813:Assign_L93_C8", "label": "fk =", "type": "assigned_variable", "loc": [93, 93], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L88_C4", "vector": [14, 2, 0.2183, 0.0023, 2, 0.38, 0.3333, 714, 1, 0, 0, 0, 0, 9, 0], "semantic": {"name": "fk", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " fk = None"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98813:If_L94_C8", "label": "if", "type": "if", "loc": [94, 96], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L88_C4", "vector": [4, 2, 0.223, 0.007, 2, 0.38, 0.5, 0, 0, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if value is not None:\n ct = self.get_content_type(obj=value)\n fk = value._get_pk_val()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98813:Assign_L95_C12", "label": "ct = get_content_type()", "type": "assigned_variable", "loc": [95, 95], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98813:If_L94_C8", "vector": [14, 3, 0.223, 0.0023, 3, 0.55, 0.0, 147, 3, 1, 0, 0, 367, 10, 1], "semantic": {"name": "ct", "arg_names": [], "import_names": [], "rhs_call_name": "get_content_type", "annotation": ""}, "snippet": " ct = self.get_content_type(obj=value)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98813:Assign_L96_C12", "label": "fk = _get_pk_val()", "type": "assigned_variable", "loc": [96, 96], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98813:If_L94_C8", "vector": [14, 3, 0.2254, 0.0023, 3, 0.55, 1.0, 714, 3, 0, 0, 0, 743, 10, 1], "semantic": {"name": "fk", "arg_names": [], "import_names": [], "rhs_call_name": "_get_pk_val", "annotation": ""}, "snippet": " fk = value._get_pk_val()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98813:Expr_L98_C8", "label": "setattr()", "type": "expression", "loc": [98, 98], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L88_C4", "vector": [8, 2, 0.23, 0.0023, 2, 0.38, 0.6667, 501, 3, 3, 0, 0, 0, 0, 1], "semantic": {"name": "setattr", "arg_names": [], "import_names": [], "rhs_call_name": "setattr", "annotation": ""}, "snippet": " setattr(instance, self.ct_field, ct)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98813:Expr_L99_C8", "label": "setattr()", "type": "expression", "loc": [99, 99], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L88_C4", "vector": [8, 2, 0.2324, 0.0023, 2, 0.38, 0.8333, 501, 3, 3, 0, 0, 0, 0, 1], "semantic": {"name": "setattr", "arg_names": [], "import_names": [], "rhs_call_name": "setattr", "annotation": ""}, "snippet": " setattr(instance, self.fk_field, fk)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98813:Expr_L100_C8", "label": "setattr()", "type": "expression", "loc": [100, 100], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L88_C4", "vector": [8, 2, 0.2347, 0.0023, 2, 0.38, 1.0, 501, 3, 3, 0, 0, 0, 0, 1], "semantic": {"name": "setattr", "arg_names": [], "import_names": [], "rhs_call_name": "setattr", "annotation": ""}, "snippet": " setattr(instance, self.cache_attr, value)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98813:ClassDef_L102_C0", "label": "GenericRelation", "type": "class", "loc": [102, 184], "level": 0, "parent": null, "vector": [3, 0, 0.3357, 0.1948, 0, 0.66, 0.6364, 949, 0, 13, 0, 0, 878, 0, 24], "semantic": {"name": "GenericRelation", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class GenericRelation(RelatedField, Field):\n \"\"\"Provides an accessor to generic related objects (e.g. comments)\"\"\"\n\n def __init__(self, to, **kwargs):\n kwargs['verbose_name'] = kwargs.get('verbose_name', None)\n kwargs['rel'] = GenericRel(to,\n related_name=kwargs.pop('related_name', None),\n limit_choices_to=kwargs.pop('limit_choices_to', None),"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98813:Expr_L103_C4", "label": "expression", "type": "expression", "loc": [103, 103], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98813:ClassDef_L102_C0", "vector": [8, 1, 0.2418, 0.0023, 1, 0.85, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"Provides an accessor to generic related objects (e.g. comments)\"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L105_C4", "label": "__init__", "type": "function", "loc": [105, 120], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98813:ClassDef_L102_C0", "vector": [2, 1, 0.2641, 0.0376, 1, 0.85, 0.0769, 555, 0, 3, 0, 0, 0, 0, 8], "semantic": {"name": "__init__", "arg_names": ["self", "to", "kwargs"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def __init__(self, to, **kwargs):\n kwargs['verbose_name'] = kwargs.get('verbose_name', None)\n kwargs['rel'] = GenericRel(to,\n related_name=kwargs.pop('related_name', None),\n limit_choices_to=kwargs.pop('limit_choices_to', None),\n symmetrical=kwargs.pop('symmetrical', True))\n\n"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98813:Assign_L106_C8", "label": " = get()", "type": "assigned_variable", "loc": [106, 106], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L105_C4", "vector": [14, 2, 0.2488, 0.0023, 2, 0.35, 0.0, 0, 3, 2, 0, 0, 607, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "get", "annotation": ""}, "snippet": " kwargs['verbose_name'] = kwargs.get('verbose_name', None)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98813:Assign_L107_C8", "label": " = GenericRel()", "type": "assigned_variable", "loc": [107, 110], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L105_C4", "vector": [14, 2, 0.2547, 0.0094, 2, 0.35, 0.1429, 0, 3, 4, 0, 0, 683, 10, 4], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "GenericRel", "annotation": ""}, "snippet": " kwargs['rel'] = GenericRel(to,\n related_name=kwargs.pop('related_name', None),\n limit_choices_to=kwargs.pop('limit_choices_to', None),\n symmetrical=kwargs.pop('symmetrical', True))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98813:Assign_L114_C8", "label": "self.object_id_field_name = pop()", "type": "assigned_variable", "loc": [114, 114], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L105_C4", "vector": [14, 2, 0.2676, 0.0023, 2, 0.35, 0.2857, 841, 3, 2, 0, 0, 969, 10, 1], "semantic": {"name": "self.object_id_field_name", "arg_names": [], "import_names": [], "rhs_call_name": "pop", "annotation": ""}, "snippet": " self.object_id_field_name = kwargs.pop(\"object_id_field\", \"object_id\")"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98813:Assign_L115_C8", "label": "self.content_type_field_name = pop()", "type": "assigned_variable", "loc": [115, 115], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L105_C4", "vector": [14, 2, 0.27, 0.0023, 2, 0.35, 0.4286, 526, 3, 2, 0, 0, 969, 10, 1], "semantic": {"name": "self.content_type_field_name", "arg_names": [], "import_names": [], "rhs_call_name": "pop", "annotation": ""}, "snippet": " self.content_type_field_name = kwargs.pop(\"content_type_field\", \"content_type\")"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98813:Assign_L117_C8", "label": "assign", "type": "assigned_variable", "loc": [117, 117], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L105_C4", "vector": [14, 2, 0.2746, 0.0023, 2, 0.35, 0.5714, 0, 1, 0, 0, 0, 0, 4, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " kwargs['blank'] = True"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98813:Assign_L118_C8", "label": "assign", "type": "assigned_variable", "loc": [118, 118], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L105_C4", "vector": [14, 2, 0.277, 0.0023, 2, 0.35, 0.7143, 0, 1, 0, 0, 0, 0, 4, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " kwargs['editable'] = False"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98813:Assign_L119_C8", "label": "assign", "type": "assigned_variable", "loc": [119, 119], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L105_C4", "vector": [14, 2, 0.2793, 0.0023, 2, 0.35, 0.8571, 0, 1, 0, 0, 0, 0, 4, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " kwargs['serialize'] = False"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98813:Expr_L120_C8", "label": "__init__()", "type": "expression", "loc": [120, 120], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L105_C4", "vector": [8, 2, 0.2817, 0.0023, 2, 0.35, 1.0, 555, 3, 2, 0, 0, 0, 0, 1], "semantic": {"name": "__init__", "arg_names": [], "import_names": [], "rhs_call_name": "__init__", "annotation": ""}, "snippet": " Field.__init__(self, **kwargs)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L122_C4", "label": "get_choices_default", "type": "function", "loc": [122, 123], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98813:ClassDef_L102_C0", "vector": [2, 1, 0.2876, 0.0047, 1, 0.85, 0.1538, 314, 0, 1, 1, 0, 0, 0, 1], "semantic": {"name": "get_choices_default", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def get_choices_default(self):\n return Field.get_choices(self, include_blank=False)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98813:Return_L123_C8", "label": "return", "type": "return", "loc": [123, 123], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L122_C4", "vector": [13, 2, 0.2887, 0.0023, 2, 0.44, 0.0, 0, 3, 0, 0, 0, 0, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return Field.get_choices(self, include_blank=False)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L125_C4", "label": "value_to_string", "type": "function", "loc": [125, 127], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98813:ClassDef_L102_C0", "vector": [2, 1, 0.2958, 0.007, 1, 0.85, 0.2308, 303, 0, 2, 1, 0, 0, 0, 4], "semantic": {"name": "value_to_string", "arg_names": ["self", "obj"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def value_to_string(self, obj):\n qs = getattr(obj, self.name).all()\n return smart_unicode([instance._get_pk_val() for instance in qs])"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98813:Assign_L126_C8", "label": "qs = all()", "type": "assigned_variable", "loc": [126, 126], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L125_C4", "vector": [14, 2, 0.2958, 0.0023, 2, 0.88, 0.0, 251, 3, 0, 0, 0, 895, 10, 2], "semantic": {"name": "qs", "arg_names": [], "import_names": [], "rhs_call_name": "all", "annotation": ""}, "snippet": " qs = getattr(obj, self.name).all()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98813:Return_L127_C8", "label": "return", "type": "return", "loc": [127, 127], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L125_C4", "vector": [13, 2, 0.2981, 0.0023, 2, 0.88, 1.0, 0, 3, 0, 0, 0, 0, 10, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return smart_unicode([instance._get_pk_val() for instance in qs])"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L129_C4", "label": "m2m_db_table", "type": "function", "loc": [129, 130], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98813:ClassDef_L102_C0", "vector": [2, 1, 0.304, 0.0047, 1, 0.85, 0.3077, 359, 0, 1, 1, 0, 0, 0, 0], "semantic": {"name": "m2m_db_table", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def m2m_db_table(self):\n return self.rel.to._meta.db_table"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98813:Return_L130_C8", "label": "return", "type": "return", "loc": [130, 130], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L129_C4", "vector": [13, 2, 0.3052, 0.0023, 2, 0.53, 0.0, 0, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return self.rel.to._meta.db_table"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L132_C4", "label": "m2m_column_name", "type": "function", "loc": [132, 133], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98813:ClassDef_L102_C0", "vector": [2, 1, 0.311, 0.0047, 1, 0.85, 0.3846, 937, 0, 1, 1, 0, 0, 0, 0], "semantic": {"name": "m2m_column_name", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def m2m_column_name(self):\n return self.object_id_field_name"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98813:Return_L133_C8", "label": "return", "type": "return", "loc": [133, 133], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L132_C4", "vector": [13, 2, 0.3122, 0.0023, 2, 0.33, 0.0, 0, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return self.object_id_field_name"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L135_C4", "label": "m2m_reverse_name", "type": "function", "loc": [135, 136], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98813:ClassDef_L102_C0", "vector": [2, 1, 0.3181, 0.0047, 1, 0.85, 0.4615, 990, 0, 1, 1, 0, 0, 0, 0], "semantic": {"name": "m2m_reverse_name", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def m2m_reverse_name(self):\n return self.rel.to._meta.pk.column"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98813:Return_L136_C8", "label": "return", "type": "return", "loc": [136, 136], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L135_C4", "vector": [13, 2, 0.3192, 0.0023, 2, 0.57, 0.0, 0, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return self.rel.to._meta.pk.column"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L138_C4", "label": "contribute_to_class", "type": "function", "loc": [138, 145], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98813:ClassDef_L102_C0", "vector": [2, 1, 0.3322, 0.0188, 1, 0.85, 0.5385, 973, 0, 3, 0, 0, 0, 0, 4], "semantic": {"name": "contribute_to_class", "arg_names": ["self", "cls", "name"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def contribute_to_class(self, cls, name):\n super(GenericRelation, self).contribute_to_class(cls, name)\n\n # Save a reference to which model this class is on for future use\n self.model = cls\n\n # Add the descriptor for the m2m relation\n setattr(cls, self.name, ReverseGenericRelatedObjectsDescriptor(self))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98813:Expr_L139_C8", "label": "contribute_to_class()", "type": "expression", "loc": [139, 139], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L138_C4", "vector": [8, 2, 0.3263, 0.0023, 2, 0.24, 0.0, 973, 3, 2, 0, 0, 0, 0, 2], "semantic": {"name": "contribute_to_class", "arg_names": [], "import_names": [], "rhs_call_name": "contribute_to_class", "annotation": ""}, "snippet": " super(GenericRelation, self).contribute_to_class(cls, name)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98813:Assign_L142_C8", "label": "self.model =", "type": "assigned_variable", "loc": [142, 142], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L138_C4", "vector": [14, 2, 0.3333, 0.0023, 2, 0.24, 0.5, 81, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "self.model", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.model = cls"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98813:Expr_L145_C8", "label": "setattr()", "type": "expression", "loc": [145, 145], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L138_C4", "vector": [8, 2, 0.3404, 0.0023, 2, 0.24, 1.0, 501, 3, 3, 0, 0, 0, 0, 2], "semantic": {"name": "setattr", "arg_names": [], "import_names": [], "rhs_call_name": "setattr", "annotation": ""}, "snippet": " setattr(cls, self.name, ReverseGenericRelatedObjectsDescriptor(self))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L147_C4", "label": "contribute_to_related_class", "type": "function", "loc": [147, 148], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98813:ClassDef_L102_C0", "vector": [2, 1, 0.3462, 0.0047, 1, 0.85, 0.6154, 722, 0, 3, 0, 0, 0, 0, 0], "semantic": {"name": "contribute_to_related_class", "arg_names": ["self", "cls", "related"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def contribute_to_related_class(self, cls, related):\n pass"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L150_C4", "label": "set_attributes_from_rel", "type": "function", "loc": [150, 151], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98813:ClassDef_L102_C0", "vector": [2, 1, 0.3533, 0.0047, 1, 0.85, 0.6923, 796, 0, 1, 0, 0, 0, 0, 0], "semantic": {"name": "set_attributes_from_rel", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def set_attributes_from_rel(self):\n pass"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L153_C4", "label": "get_internal_type", "type": "function", "loc": [153, 154], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98813:ClassDef_L102_C0", "vector": [2, 1, 0.3603, 0.0047, 1, 0.85, 0.7692, 291, 0, 1, 1, 0, 0, 0, 0], "semantic": {"name": "get_internal_type", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def get_internal_type(self):\n return \"ManyToManyField\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98813:Return_L154_C8", "label": "return", "type": "return", "loc": [154, 154], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L153_C4", "vector": [13, 2, 0.3615, 0.0023, 2, 0.0, 0.0, 0, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return \"ManyToManyField\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L156_C4", "label": "db_type", "type": "function", "loc": [156, 159], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98813:ClassDef_L102_C0", "vector": [2, 1, 0.3697, 0.0094, 1, 0.85, 0.8462, 976, 0, 2, 1, 0, 0, 0, 0], "semantic": {"name": "db_type", "arg_names": ["self", "connection"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def db_type(self, connection):\n # Since we're simulating a ManyToManyField, in effect, best return the\n # same db_type as well.\n return None"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98813:Return_L159_C8", "label": "return", "type": "return", "loc": [159, 159], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L156_C4", "vector": [13, 2, 0.3732, 0.0023, 2, 0.62, 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_98813:FunctionDef_L161_C4", "label": "extra_filters", "type": "function", "loc": [161, 172], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98813:ClassDef_L102_C0", "vector": [2, 1, 0.3908, 0.0282, 1, 0.85, 0.9231, 75, 0, 4, 1, 0, 0, 0, 3], "semantic": {"name": "extra_filters", "arg_names": ["self", "pieces", "pos", "negate"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def extra_filters(self, pieces, pos, negate):\n \"\"\"\n Return an extra filter to the queryset so that the results are filtered\n on the appropriate content type.\n \"\"\"\n if negate:\n return []\n ContentType = get_model(\"contenttypes\", \"contenttype\")"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98813:Expr_L162_C8", "label": "expression", "type": "expression", "loc": [162, 165], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L161_C4", "vector": [8, 2, 0.3838, 0.0094, 2, 0.46, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"\n Return an extra filter to the queryset so that the results are filtered\n on the appropriate content type.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98813:If_L166_C8", "label": "if", "type": "if", "loc": [166, 167], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L161_C4", "vector": [4, 2, 0.3908, 0.0047, 2, 0.46, 0.2, 0, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if negate:\n return []"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98813:Return_L167_C12", "label": "return", "type": "return", "loc": [167, 167], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98813:If_L166_C8", "vector": [13, 3, 0.392, 0.0023, 3, 0.6, 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_98813:Assign_L168_C8", "label": "ContentType = get_model()", "type": "assigned_variable", "loc": [168, 168], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L161_C4", "vector": [14, 2, 0.3944, 0.0023, 2, 0.46, 0.4, 313, 3, 2, 0, 0, 115, 10, 1], "semantic": {"name": "ContentType", "arg_names": [], "import_names": [], "rhs_call_name": "get_model", "annotation": ""}, "snippet": " ContentType = get_model(\"contenttypes\", \"contenttype\")"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98813:Assign_L169_C8", "label": "content_type = get_for_model()", "type": "assigned_variable", "loc": [169, 169], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L161_C4", "vector": [14, 2, 0.3967, 0.0023, 2, 0.46, 0.6, 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(self.model)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98813:Assign_L170_C8", "label": "prefix = join()", "type": "assigned_variable", "loc": [170, 170], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L161_C4", "vector": [14, 2, 0.3991, 0.0023, 2, 0.46, 0.8, 284, 3, 1, 0, 0, 933, 10, 1], "semantic": {"name": "prefix", "arg_names": [], "import_names": [], "rhs_call_name": "join", "annotation": ""}, "snippet": " prefix = \"__\".join(pieces[:pos + 1])"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98813:Return_L171_C8", "label": "return", "type": "return", "loc": [171, 172], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L161_C4", "vector": [13, 2, 0.4026, 0.0047, 2, 0.46, 1.0, 0, 0, 0, 0, 0, 0, 5, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return [(\"%s__%s\" % (prefix, self.content_type_field_name),\n content_type)]"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L174_C4", "label": "bulk_related_objects", "type": "function", "loc": [174, 184], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98813:ClassDef_L102_C0", "vector": [2, 1, 0.4202, 0.0258, 1, 0.85, 1.0, 85, 0, 3, 1, 0, 0, 0, 4], "semantic": {"name": "bulk_related_objects", "arg_names": ["self", "objs", "using"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def bulk_related_objects(self, objs, using=DEFAULT_DB_ALIAS):\n \"\"\"\n Return all objects related to ``objs`` via this ``GenericRelation``.\n\n \"\"\"\n return self.rel.to._base_manager.db_manager(using).filter(**{\n \"%s__pk\" % self.content_type_field_name:\n ContentType.objects.db_manager(using).get_for_model(self.model).pk,"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98813:Expr_L175_C8", "label": "expression", "type": "expression", "loc": [175, 178], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L174_C4", "vector": [8, 2, 0.4143, 0.0094, 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 Return all objects related to ``objs`` via this ``GenericRelation``.\n\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98813:Return_L179_C8", "label": "return", "type": "return", "loc": [179, 184], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L174_C4", "vector": [13, 2, 0.4261, 0.0141, 2, 0.21, 1.0, 0, 3, 0, 0, 0, 0, 10, 4], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return self.rel.to._base_manager.db_manager(using).filter(**{\n \"%s__pk\" % self.content_type_field_name:\n ContentType.objects.db_manager(using).get_for_model(self.model).pk,\n \"%s__in\" % self.object_id_field_name:\n [obj.pk for obj in objs]\n })"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98813:ClassDef_L187_C0", "label": "ReverseGenericRelatedObjectsDescriptor", "type": "class", "loc": [187, 235], "level": 0, "parent": null, "vector": [3, 0, 0.4953, 0.115, 0, 0.66, 0.6818, 496, 0, 3, 0, 0, 186, 0, 14], "semantic": {"name": "ReverseGenericRelatedObjectsDescriptor", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class ReverseGenericRelatedObjectsDescriptor(object):\n \"\"\"\n This class provides the functionality that makes the related-object\n managers available as attributes on a model class, for fields that have\n multiple \"remote\" values and have a GenericRelation defined in their model\n (rather than having another model pointed *at* them). In the example\n \"article.publications\", the publications attribute is a\n ReverseGenericRelatedObjectsDescriptor instance."}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98813:Expr_L188_C4", "label": "expression", "type": "expression", "loc": [188, 195], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98813:ClassDef_L187_C0", "vector": [8, 1, 0.4495, 0.0188, 1, 0.92, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"\n This class provides the functionality that makes the related-object\n managers available as attributes on a model class, for fields that have\n multiple \"remote\" values and have a GenericRelation defined in their model\n (rather than having another model pointed *at* them). In the example\n \"article.publications\", the publications attribute is a\n ReverseGenericRelatedObjectsDescriptor instance.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L196_C4", "label": "__init__", "type": "function", "loc": [196, 197], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98813:ClassDef_L187_C0", "vector": [2, 1, 0.4613, 0.0047, 1, 0.92, 0.3333, 555, 0, 2, 0, 0, 0, 0, 0], "semantic": {"name": "__init__", "arg_names": ["self", "field"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def __init__(self, field):\n self.field = field"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98813:Assign_L197_C8", "label": "self.field =", "type": "assigned_variable", "loc": [197, 197], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L196_C4", "vector": [14, 2, 0.4624, 0.0023, 2, 0.21, 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 = field"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L199_C4", "label": "__get__", "type": "function", "loc": [199, 226], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98813:ClassDef_L187_C0", "vector": [2, 1, 0.4988, 0.0657, 1, 0.92, 0.6667, 93, 0, 3, 1, 0, 0, 0, 10], "semantic": {"name": "__get__", "arg_names": ["self", "instance", "instance_type"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def __get__(self, instance, instance_type=None):\n if instance is None:\n return self\n\n # This import is done here to avoid circular import importing this module\n from django.contrib.contenttypes.models import ContentType\n\n # Dynamically create a class that subclasses the related model's"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98813:If_L200_C8", "label": "if", "type": "if", "loc": [200, 201], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L199_C4", "vector": [4, 2, 0.4707, 0.0047, 2, 0.14, 0.0, 0, 0, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if instance is None:\n return self"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98813:Return_L201_C12", "label": "return", "type": "return", "loc": [201, 201], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98813:If_L200_C8", "vector": [13, 3, 0.4718, 0.0023, 3, 0.87, 0.0, 0, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return self"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98813:ImportFrom_L204_C8", "label": "from django.contrib.contenttypes.models import ContentType", "type": "import", "loc": [204, 204], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L199_C4", "vector": [1, 2, 0.4789, 0.0023, 2, 0.14, 0.1429, 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_98813:Assign_L208_C8", "label": "rel_model =", "type": "assigned_variable", "loc": [208, 208], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L199_C4", "vector": [14, 2, 0.4883, 0.0023, 2, 0.14, 0.2857, 510, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "rel_model", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " rel_model = self.field.rel.to"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98813:Assign_L209_C8", "label": "superclass =", "type": "assigned_variable", "loc": [209, 209], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L199_C4", "vector": [14, 2, 0.4906, 0.0023, 2, 0.14, 0.4286, 770, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "superclass", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " superclass = rel_model._default_manager.__class__"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98813:Assign_L210_C8", "label": "RelatedManager = create_generic_related_manager()", "type": "assigned_variable", "loc": [210, 210], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L199_C4", "vector": [14, 2, 0.493, 0.0023, 2, 0.14, 0.5714, 865, 3, 1, 0, 0, 716, 10, 1], "semantic": {"name": "RelatedManager", "arg_names": [], "import_names": [], "rhs_call_name": "create_generic_related_manager", "annotation": ""}, "snippet": " RelatedManager = create_generic_related_manager(superclass)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98813:Assign_L212_C8", "label": "qn =", "type": "assigned_variable", "loc": [212, 212], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L199_C4", "vector": [14, 2, 0.4977, 0.0023, 2, 0.14, 0.7143, 514, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "qn", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " qn = connection.ops.quote_name"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98813:Assign_L214_C8", "label": "manager = RelatedManager()", "type": "assigned_variable", "loc": [214, 224], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L199_C4", "vector": [14, 2, 0.5141, 0.0258, 2, 0.14, 0.8571, 748, 3, 9, 0, 0, 865, 10, 9], "semantic": {"name": "manager", "arg_names": [], "import_names": [], "rhs_call_name": "RelatedManager", "annotation": ""}, "snippet": " manager = RelatedManager(\n model = rel_model,\n instance = instance,\n symmetrical = (self.field.rel.symmetrical and instance.__class__ == rel_model),\n join_table = qn(self.field.m2m_db_table()),\n source_col_name = qn(self.field.m2m_column_name()),\n target_col_name = qn(self.field.m2m_reverse_name()),\n content_type = ContentType.objects.db_manager(instance._state.db).get_for_model(instance),"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98813:Return_L226_C8", "label": "return", "type": "return", "loc": [226, 226], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L199_C4", "vector": [13, 2, 0.5305, 0.0023, 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 manager"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L228_C4", "label": "__set__", "type": "function", "loc": [228, 235], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98813:ClassDef_L187_C0", "vector": [2, 1, 0.5434, 0.0188, 1, 0.92, 1.0, 145, 0, 3, 0, 0, 0, 0, 4], "semantic": {"name": "__set__", "arg_names": ["self", "instance", "value"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def __set__(self, instance, value):\n if instance is None:\n raise AttributeError(\"Manager must be accessed via instance\")\n\n manager = self.__get__(instance)\n manager.clear()\n for obj in value:\n manager.add(obj)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98813:If_L229_C8", "label": "if", "type": "if", "loc": [229, 230], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L228_C4", "vector": [4, 2, 0.5387, 0.0047, 2, 0.4, 0.0, 0, 0, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if instance is None:\n raise AttributeError(\"Manager must be accessed via instance\")"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98813:Assign_L232_C8", "label": "manager = __get__()", "type": "assigned_variable", "loc": [232, 232], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L228_C4", "vector": [14, 2, 0.5446, 0.0023, 2, 0.4, 0.3333, 748, 3, 1, 0, 0, 93, 10, 1], "semantic": {"name": "manager", "arg_names": [], "import_names": [], "rhs_call_name": "__get__", "annotation": ""}, "snippet": " manager = self.__get__(instance)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98813:Expr_L233_C8", "label": "clear()", "type": "expression", "loc": [233, 233], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L228_C4", "vector": [8, 2, 0.5469, 0.0023, 2, 0.4, 0.6667, 712, 3, 0, 0, 0, 0, 0, 1], "semantic": {"name": "clear", "arg_names": [], "import_names": [], "rhs_call_name": "clear", "annotation": ""}, "snippet": " manager.clear()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98813:For_L234_C8", "label": "for obj", "type": "for", "loc": [234, 235], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L228_C4", "vector": [6, 2, 0.5505, 0.0047, 2, 0.4, 1.0, 505, 2, 0, 0, 0, 0, 0, 1], "semantic": {"name": "obj", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for obj in value:\n manager.add(obj)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98813:Expr_L235_C12", "label": "add()", "type": "expression", "loc": [235, 235], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98813:For_L234_C8", "vector": [8, 3, 0.5516, 0.0023, 3, 0.25, 0.0, 241, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "add", "arg_names": [], "import_names": [], "rhs_call_name": "add", "annotation": ""}, "snippet": " manager.add(obj)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L237_C0", "label": "create_generic_related_manager", "type": "function", "loc": [237, 298], "level": 0, "parent": null, "vector": [2, 0, 0.6279, 0.1455, 0, 0.66, 0.7273, 716, 0, 1, 1, 0, 0, 0, 21], "semantic": {"name": "create_generic_related_manager", "arg_names": ["superclass"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "def create_generic_related_manager(superclass):\n \"\"\"\n Factory function for a manager that subclasses 'superclass' (which is a\n Manager) and adds behavior for generic related objects.\n \"\"\"\n\n class GenericRelatedObjectManager(superclass):\n def __init__(self, model=None, core_filters=None, instance=None, symmetrical=None,"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98813:Expr_L238_C4", "label": "expression", "type": "expression", "loc": [238, 241], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L237_C0", "vector": [8, 1, 0.5622, 0.0094, 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 Factory function for a manager that subclasses 'superclass' (which is a\n Manager) and adds behavior for generic related objects.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98813:ClassDef_L243_C4", "label": "GenericRelatedObjectManager", "type": "class", "loc": [243, 296], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L237_C0", "vector": [3, 1, 0.6326, 0.1268, 1, 0.59, 0.5, 360, 0, 6, 0, 0, 770, 0, 21], "semantic": {"name": "GenericRelatedObjectManager", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " class GenericRelatedObjectManager(superclass):\n def __init__(self, model=None, core_filters=None, instance=None, symmetrical=None,\n join_table=None, source_col_name=None, target_col_name=None, content_type=None,\n content_type_field_name=None, object_id_field_name=None):\n\n super(GenericRelatedObjectManager, self).__init__()\n self.core_filters = core_filters or {}\n self.model = model"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L244_C8", "label": "__init__", "type": "function", "loc": [244, 260], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98813:ClassDef_L243_C4", "vector": [2, 2, 0.5915, 0.0399, 2, 0.27, 0.0, 555, 0, 11, 0, 0, 0, 0, 3], "semantic": {"name": "__init__", "arg_names": ["self", "model", "core_filters", "instance", "symmetrical", "join_table", "source_col_name", "target_col_name", "content_type", "content_type_field_name", "object_id_field_name"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def __init__(self, model=None, core_filters=None, instance=None, symmetrical=None,\n join_table=None, source_col_name=None, target_col_name=None, content_type=None,\n content_type_field_name=None, object_id_field_name=None):\n\n super(GenericRelatedObjectManager, self).__init__()\n self.core_filters = core_filters or {}\n self.model = model\n self.content_type = content_type"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98813:Expr_L248_C12", "label": "__init__()", "type": "expression", "loc": [248, 248], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L244_C8", "vector": [8, 3, 0.5822, 0.0023, 3, 0.16, 0.0, 555, 3, 0, 0, 0, 0, 0, 2], "semantic": {"name": "__init__", "arg_names": [], "import_names": [], "rhs_call_name": "__init__", "annotation": ""}, "snippet": " super(GenericRelatedObjectManager, self).__init__()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98813:Assign_L249_C12", "label": "self.core_filters =", "type": "assigned_variable", "loc": [249, 249], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L244_C8", "vector": [14, 3, 0.5845, 0.0023, 3, 0.16, 0.0833, 605, 0, 0, 0, 0, 0, 0, 0], "semantic": {"name": "self.core_filters", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.core_filters = core_filters or {}"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98813:Assign_L250_C12", "label": "self.model =", "type": "assigned_variable", "loc": [250, 250], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L244_C8", "vector": [14, 3, 0.5869, 0.0023, 3, 0.16, 0.1667, 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_98813:Assign_L251_C12", "label": "self.content_type =", "type": "assigned_variable", "loc": [251, 251], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L244_C8", "vector": [14, 3, 0.5892, 0.0023, 3, 0.16, 0.25, 886, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "self.content_type", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.content_type = content_type"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98813:Assign_L252_C12", "label": "self.symmetrical =", "type": "assigned_variable", "loc": [252, 252], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L244_C8", "vector": [14, 3, 0.5915, 0.0023, 3, 0.16, 0.3333, 77, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "self.symmetrical", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.symmetrical = symmetrical"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98813:Assign_L253_C12", "label": "self.instance =", "type": "assigned_variable", "loc": [253, 253], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L244_C8", "vector": [14, 3, 0.5939, 0.0023, 3, 0.16, 0.4167, 330, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "self.instance", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.instance = instance"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98813:Assign_L254_C12", "label": "self.join_table =", "type": "assigned_variable", "loc": [254, 254], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L244_C8", "vector": [14, 3, 0.5962, 0.0023, 3, 0.16, 0.5, 785, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "self.join_table", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.join_table = join_table"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98813:Assign_L255_C12", "label": "self.join_table =", "type": "assigned_variable", "loc": [255, 255], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L244_C8", "vector": [14, 3, 0.5986, 0.0023, 3, 0.16, 0.5833, 785, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "self.join_table", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.join_table = model._meta.db_table"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98813:Assign_L256_C12", "label": "self.source_col_name =", "type": "assigned_variable", "loc": [256, 256], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L244_C8", "vector": [14, 3, 0.6009, 0.0023, 3, 0.16, 0.6667, 537, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "self.source_col_name", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.source_col_name = source_col_name"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98813:Assign_L257_C12", "label": "self.target_col_name =", "type": "assigned_variable", "loc": [257, 257], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L244_C8", "vector": [14, 3, 0.6033, 0.0023, 3, 0.16, 0.75, 208, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "self.target_col_name", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.target_col_name = target_col_name"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98813:Assign_L258_C12", "label": "self.content_type_field_name =", "type": "assigned_variable", "loc": [258, 258], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L244_C8", "vector": [14, 3, 0.6056, 0.0023, 3, 0.16, 0.8333, 526, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "self.content_type_field_name", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.content_type_field_name = content_type_field_name"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98813:Assign_L259_C12", "label": "self.object_id_field_name =", "type": "assigned_variable", "loc": [259, 259], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L244_C8", "vector": [14, 3, 0.608, 0.0023, 3, 0.16, 0.9167, 841, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "self.object_id_field_name", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.object_id_field_name = object_id_field_name"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98813:Assign_L260_C12", "label": "self.pk_val = _get_pk_val()", "type": "assigned_variable", "loc": [260, 260], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L244_C8", "vector": [14, 3, 0.6103, 0.0023, 3, 0.16, 1.0, 473, 3, 0, 0, 0, 743, 10, 1], "semantic": {"name": "self.pk_val", "arg_names": [], "import_names": [], "rhs_call_name": "_get_pk_val", "annotation": ""}, "snippet": " self.pk_val = self.instance._get_pk_val()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L262_C8", "label": "get_query_set", "type": "function", "loc": [262, 268], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98813:ClassDef_L243_C4", "vector": [2, 2, 0.6221, 0.0164, 2, 0.27, 0.1111, 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 db = self._db or router.db_for_read(self.model, instance=self.instance)\n query = {\n '%s__pk' % self.content_type_field_name : self.content_type.id,\n '%s__exact' % self.object_id_field_name : self.pk_val,\n }\n return superclass.get_query_set(self).using(db).filter(**query)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98813:Assign_L263_C12", "label": "db =", "type": "assigned_variable", "loc": [263, 263], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L262_C8", "vector": [14, 3, 0.6174, 0.0023, 3, 0.7, 0.0, 761, 0, 0, 0, 0, 0, 0, 1], "semantic": {"name": "db", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " db = self._db or router.db_for_read(self.model, instance=self.instance)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98813:Assign_L264_C12", "label": "query =", "type": "assigned_variable", "loc": [264, 267], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L262_C8", "vector": [14, 3, 0.6232, 0.0094, 3, 0.7, 0.5, 546, 0, 0, 0, 0, 0, 6, 0], "semantic": {"name": "query", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " query = {\n '%s__pk' % self.content_type_field_name : self.content_type.id,\n '%s__exact' % self.object_id_field_name : self.pk_val,\n }"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98813:Return_L268_C12", "label": "return", "type": "return", "loc": [268, 268], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L262_C8", "vector": [13, 3, 0.6291, 0.0023, 3, 0.7, 1.0, 0, 3, 0, 0, 0, 0, 10, 3], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return superclass.get_query_set(self).using(db).filter(**query)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L270_C8", "label": "add", "type": "function", "loc": [270, 276], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98813:ClassDef_L243_C4", "vector": [2, 2, 0.6408, 0.0164, 2, 0.27, 0.2222, 241, 0, 2, 0, 0, 0, 0, 5], "semantic": {"name": "add", "arg_names": ["self", "objs"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def add(self, *objs):\n for obj in objs:\n if not isinstance(obj, self.model):\n raise TypeError(\"'%s' instance expected\" % self.model._meta.object_name)\n setattr(obj, self.content_type_field_name, self.content_type)\n setattr(obj, self.object_id_field_name, self.pk_val)\n obj.save()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98813:For_L271_C12", "label": "for obj", "type": "for", "loc": [271, 276], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L270_C8", "vector": [6, 3, 0.642, 0.0141, 3, 0.11, 0.0, 505, 2, 0, 0, 0, 0, 0, 5], "semantic": {"name": "obj", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for obj in objs:\n if not isinstance(obj, self.model):\n raise TypeError(\"'%s' instance expected\" % self.model._meta.object_name)\n setattr(obj, self.content_type_field_name, self.content_type)\n setattr(obj, self.object_id_field_name, self.pk_val)\n obj.save()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98813:If_L272_C16", "label": "if", "type": "if", "loc": [272, 273], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98813:For_L271_C12", "vector": [4, 4, 0.6397, 0.0047, 4, 0.52, 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, self.model):\n raise TypeError(\"'%s' instance expected\" % self.model._meta.object_name)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98813:Expr_L274_C16", "label": "setattr()", "type": "expression", "loc": [274, 274], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98813:For_L271_C12", "vector": [8, 4, 0.6432, 0.0023, 4, 0.52, 0.3333, 501, 3, 3, 0, 0, 0, 0, 1], "semantic": {"name": "setattr", "arg_names": [], "import_names": [], "rhs_call_name": "setattr", "annotation": ""}, "snippet": " setattr(obj, self.content_type_field_name, self.content_type)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98813:Expr_L275_C16", "label": "setattr()", "type": "expression", "loc": [275, 275], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98813:For_L271_C12", "vector": [8, 4, 0.6455, 0.0023, 4, 0.52, 0.6667, 501, 3, 3, 0, 0, 0, 0, 1], "semantic": {"name": "setattr", "arg_names": [], "import_names": [], "rhs_call_name": "setattr", "annotation": ""}, "snippet": " setattr(obj, self.object_id_field_name, self.pk_val)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98813:Expr_L276_C16", "label": "save()", "type": "expression", "loc": [276, 276], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98813:For_L271_C12", "vector": [8, 4, 0.6479, 0.0023, 4, 0.52, 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_98813:Assign_L277_C8", "label": "add.alters_data =", "type": "assigned_variable", "loc": [277, 277], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98813:ClassDef_L243_C4", "vector": [14, 2, 0.6502, 0.0023, 2, 0.27, 0.3333, 3, 1, 0, 0, 0, 0, 4, 0], "semantic": {"name": "add.alters_data", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " add.alters_data = True"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L279_C8", "label": "remove", "type": "function", "loc": [279, 282], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98813:ClassDef_L243_C4", "vector": [2, 2, 0.6585, 0.0094, 2, 0.27, 0.4444, 185, 0, 2, 0, 0, 0, 0, 2], "semantic": {"name": "remove", "arg_names": ["self", "objs"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def remove(self, *objs):\n db = router.db_for_write(self.model, instance=self.instance)\n for obj in objs:\n obj.delete(using=db)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98813:Assign_L280_C12", "label": "db = db_for_write()", "type": "assigned_variable", "loc": [280, 280], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L279_C8", "vector": [14, 3, 0.6573, 0.0023, 3, 0.48, 0.0, 761, 3, 2, 0, 0, 395, 10, 1], "semantic": {"name": "db", "arg_names": [], "import_names": [], "rhs_call_name": "db_for_write", "annotation": ""}, "snippet": " db = router.db_for_write(self.model, instance=self.instance)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98813:For_L281_C12", "label": "for obj", "type": "for", "loc": [281, 282], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L279_C8", "vector": [6, 3, 0.6608, 0.0047, 3, 0.48, 1.0, 505, 2, 0, 0, 0, 0, 0, 1], "semantic": {"name": "obj", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for obj in objs:\n obj.delete(using=db)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98813:Expr_L282_C16", "label": "delete()", "type": "expression", "loc": [282, 282], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98813:For_L281_C12", "vector": [8, 4, 0.662, 0.0023, 4, 0.44, 0.0, 266, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "delete", "arg_names": [], "import_names": [], "rhs_call_name": "delete", "annotation": ""}, "snippet": " obj.delete(using=db)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98813:Assign_L283_C8", "label": "remove.alters_data =", "type": "assigned_variable", "loc": [283, 283], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98813:ClassDef_L243_C4", "vector": [14, 2, 0.6643, 0.0023, 2, 0.27, 0.5556, 434, 1, 0, 0, 0, 0, 4, 0], "semantic": {"name": "remove.alters_data", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " remove.alters_data = True"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L285_C8", "label": "clear", "type": "function", "loc": [285, 288], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98813:ClassDef_L243_C4", "vector": [2, 2, 0.6725, 0.0094, 2, 0.27, 0.6667, 712, 0, 1, 0, 0, 0, 0, 3], "semantic": {"name": "clear", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def clear(self):\n db = router.db_for_write(self.model, instance=self.instance)\n for obj in self.all():\n obj.delete(using=db)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98813:Assign_L286_C12", "label": "db = db_for_write()", "type": "assigned_variable", "loc": [286, 286], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L285_C8", "vector": [14, 3, 0.6714, 0.0023, 3, 0.67, 0.0, 761, 3, 2, 0, 0, 395, 10, 1], "semantic": {"name": "db", "arg_names": [], "import_names": [], "rhs_call_name": "db_for_write", "annotation": ""}, "snippet": " db = router.db_for_write(self.model, instance=self.instance)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98813:For_L287_C12", "label": "for obj", "type": "for", "loc": [287, 288], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L285_C8", "vector": [6, 3, 0.6749, 0.0047, 3, 0.67, 1.0, 505, 3, 0, 0, 0, 0, 0, 2], "semantic": {"name": "obj", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for obj in self.all():\n obj.delete(using=db)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98813:Expr_L288_C16", "label": "delete()", "type": "expression", "loc": [288, 288], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98813:For_L287_C12", "vector": [8, 4, 0.6761, 0.0023, 4, 0.57, 0.0, 266, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "delete", "arg_names": [], "import_names": [], "rhs_call_name": "delete", "annotation": ""}, "snippet": " obj.delete(using=db)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98813:Assign_L289_C8", "label": "clear.alters_data =", "type": "assigned_variable", "loc": [289, 289], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98813:ClassDef_L243_C4", "vector": [14, 2, 0.6784, 0.0023, 2, 0.27, 0.7778, 56, 1, 0, 0, 0, 0, 4, 0], "semantic": {"name": "clear.alters_data", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " clear.alters_data = True"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L291_C8", "label": "create", "type": "function", "loc": [291, 295], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98813:ClassDef_L243_C4", "vector": [2, 2, 0.6878, 0.0117, 2, 0.27, 0.8889, 316, 0, 2, 1, 0, 0, 0, 4], "semantic": {"name": "create", "arg_names": ["self", "kwargs"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def create(self, **kwargs):\n kwargs[self.content_type_field_name] = self.content_type\n kwargs[self.object_id_field_name] = self.pk_val\n db = router.db_for_write(self.model, instance=self.instance)\n return super(GenericRelatedObjectManager, self).using(db).create(**kwargs)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98813:Assign_L292_C12", "label": "assign", "type": "assigned_variable", "loc": [292, 292], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L291_C8", "vector": [14, 3, 0.6854, 0.0023, 3, 0.26, 0.0, 0, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " kwargs[self.content_type_field_name] = self.content_type"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98813:Assign_L293_C12", "label": "assign", "type": "assigned_variable", "loc": [293, 293], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L291_C8", "vector": [14, 3, 0.6878, 0.0023, 3, 0.26, 0.3333, 0, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " kwargs[self.object_id_field_name] = self.pk_val"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98813:Assign_L294_C12", "label": "db = db_for_write()", "type": "assigned_variable", "loc": [294, 294], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L291_C8", "vector": [14, 3, 0.6901, 0.0023, 3, 0.26, 0.6667, 761, 3, 2, 0, 0, 395, 10, 1], "semantic": {"name": "db", "arg_names": [], "import_names": [], "rhs_call_name": "db_for_write", "annotation": ""}, "snippet": " db = router.db_for_write(self.model, instance=self.instance)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98813:Return_L295_C12", "label": "return", "type": "return", "loc": [295, 295], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L291_C8", "vector": [13, 3, 0.6925, 0.0023, 3, 0.26, 1.0, 0, 3, 0, 0, 0, 0, 10, 3], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return super(GenericRelatedObjectManager, self).using(db).create(**kwargs)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98813:Assign_L296_C8", "label": "create.alters_data =", "type": "assigned_variable", "loc": [296, 296], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98813:ClassDef_L243_C4", "vector": [14, 2, 0.6948, 0.0023, 2, 0.27, 1.0, 770, 1, 0, 0, 0, 0, 4, 0], "semantic": {"name": "create.alters_data", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " create.alters_data = True"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98813:Return_L298_C4", "label": "return", "type": "return", "loc": [298, 298], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L237_C0", "vector": [13, 1, 0.6995, 0.0023, 1, 0.59, 1.0, 0, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return GenericRelatedObjectManager"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98813:ClassDef_L300_C0", "label": "GenericRel", "type": "class", "loc": [300, 307], "level": 0, "parent": null, "vector": [3, 0, 0.7124, 0.0188, 0, 0.66, 0.7727, 683, 0, 1, 0, 0, 767, 0, 0], "semantic": {"name": "GenericRel", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class GenericRel(ManyToManyRel):\n def __init__(self, to, related_name=None, limit_choices_to=None, symmetrical=True):\n self.to = to\n self.related_name = related_name\n self.limit_choices_to = limit_choices_to or {}\n self.symmetrical = symmetrical\n self.multiple = True\n self.through = None"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L301_C4", "label": "__init__", "type": "function", "loc": [301, 307], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98813:ClassDef_L300_C0", "vector": [2, 1, 0.7136, 0.0164, 1, 0.87, 0.0, 555, 0, 5, 0, 0, 0, 0, 0], "semantic": {"name": "__init__", "arg_names": ["self", "to", "related_name", "limit_choices_to", "symmetrical"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def __init__(self, to, related_name=None, limit_choices_to=None, symmetrical=True):\n self.to = to\n self.related_name = related_name\n self.limit_choices_to = limit_choices_to or {}\n self.symmetrical = symmetrical\n self.multiple = True\n self.through = None"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98813:Assign_L302_C8", "label": "self.to =", "type": "assigned_variable", "loc": [302, 302], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L301_C4", "vector": [14, 2, 0.7089, 0.0023, 2, 0.58, 0.0, 807, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "self.to", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.to = to"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98813:Assign_L303_C8", "label": "self.related_name =", "type": "assigned_variable", "loc": [303, 303], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L301_C4", "vector": [14, 2, 0.7113, 0.0023, 2, 0.58, 0.2, 929, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "self.related_name", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.related_name = related_name"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98813:Assign_L304_C8", "label": "self.limit_choices_to =", "type": "assigned_variable", "loc": [304, 304], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L301_C4", "vector": [14, 2, 0.7136, 0.0023, 2, 0.58, 0.4, 991, 0, 0, 0, 0, 0, 0, 0], "semantic": {"name": "self.limit_choices_to", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.limit_choices_to = limit_choices_to or {}"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98813:Assign_L305_C8", "label": "self.symmetrical =", "type": "assigned_variable", "loc": [305, 305], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L301_C4", "vector": [14, 2, 0.716, 0.0023, 2, 0.58, 0.6, 77, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "self.symmetrical", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.symmetrical = symmetrical"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98813:Assign_L306_C8", "label": "self.multiple =", "type": "assigned_variable", "loc": [306, 306], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L301_C4", "vector": [14, 2, 0.7183, 0.0023, 2, 0.58, 0.8, 731, 1, 0, 0, 0, 0, 4, 0], "semantic": {"name": "self.multiple", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.multiple = True"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98813:Assign_L307_C8", "label": "self.through =", "type": "assigned_variable", "loc": [307, 307], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L301_C4", "vector": [14, 2, 0.7207, 0.0023, 2, 0.58, 1.0, 654, 1, 0, 0, 0, 0, 9, 0], "semantic": {"name": "self.through", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.through = None"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98813:ClassDef_L309_C0", "label": "BaseGenericInlineFormSet", "type": "class", "loc": [309, 354], "level": 0, "parent": null, "vector": [3, 0, 0.7782, 0.108, 0, 0.66, 0.8182, 53, 0, 3, 0, 0, 937, 0, 15], "semantic": {"name": "BaseGenericInlineFormSet", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class BaseGenericInlineFormSet(BaseModelFormSet):\n \"\"\"\n A formset for generic inline objects to a parent.\n \"\"\"\n\n def __init__(self, data=None, files=None, instance=None, save_as_new=None,\n prefix=None, queryset=None):\n # Avoid a circular import."}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98813:Expr_L310_C4", "label": "expression", "type": "expression", "loc": [310, 312], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98813:ClassDef_L309_C0", "vector": [8, 1, 0.73, 0.007, 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 A formset for generic inline objects to a parent.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L314_C4", "label": "__init__", "type": "function", "loc": [314, 336], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98813:ClassDef_L309_C0", "vector": [2, 1, 0.7629, 0.054, 1, 0.74, 0.25, 555, 0, 7, 0, 0, 0, 0, 7], "semantic": {"name": "__init__", "arg_names": ["self", "data", "files", "instance", "save_as_new", "prefix", "queryset"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def __init__(self, data=None, files=None, instance=None, save_as_new=None,\n prefix=None, queryset=None):\n # Avoid a circular import.\n from django.contrib.contenttypes.models import ContentType\n opts = self.model._meta\n self.instance = instance\n self.rel_name = '-'.join((\n opts.app_label, opts.object_name.lower(),"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98813:ImportFrom_L317_C8", "label": "from django.contrib.contenttypes.models import ContentType", "type": "import", "loc": [317, 317], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L314_C4", "vector": [1, 2, 0.7441, 0.0023, 2, 0.5, 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_98813:Assign_L318_C8", "label": "opts =", "type": "assigned_variable", "loc": [318, 318], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L314_C4", "vector": [14, 2, 0.7465, 0.0023, 2, 0.5, 0.2, 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_98813:Assign_L319_C8", "label": "self.instance =", "type": "assigned_variable", "loc": [319, 319], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L314_C4", "vector": [14, 2, 0.7488, 0.0023, 2, 0.5, 0.4, 330, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "self.instance", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.instance = instance"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98813:Assign_L320_C8", "label": "self.rel_name = join()", "type": "assigned_variable", "loc": [320, 323], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L314_C4", "vector": [14, 2, 0.7547, 0.0094, 2, 0.5, 0.6, 396, 3, 1, 0, 0, 933, 10, 2], "semantic": {"name": "self.rel_name", "arg_names": [], "import_names": [], "rhs_call_name": "join", "annotation": ""}, "snippet": " self.rel_name = '-'.join((\n opts.app_label, opts.object_name.lower(),\n self.ct_field.name, self.ct_fk_field.name,\n ))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98813:If_L324_C8", "label": "if", "type": "if", "loc": [324, 332], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L314_C4", "vector": [4, 2, 0.77, 0.0211, 2, 0.5, 0.8, 0, 0, 0, 0, 0, 0, 0, 3], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if self.instance is None or self.instance.pk is None:\n qs = self.model._default_manager.none()\n else:\n if queryset is None:\n queryset = self.model._default_manager\n qs = queryset.filter(**{\n self.ct_field.name: ContentType.objects.get_for_model(self.instance),\n self.ct_fk_field.name: self.instance.pk,"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98813:Assign_L325_C12", "label": "qs = none()", "type": "assigned_variable", "loc": [325, 325], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98813:If_L324_C8", "vector": [14, 3, 0.7629, 0.0023, 3, 0.33, 0.0, 251, 3, 0, 0, 0, 615, 10, 1], "semantic": {"name": "qs", "arg_names": [], "import_names": [], "rhs_call_name": "none", "annotation": ""}, "snippet": " qs = self.model._default_manager.none()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98813:If_L327_C12", "label": "if", "type": "if", "loc": [327, 328], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98813:If_L324_C8", "vector": [4, 3, 0.7688, 0.0047, 3, 0.33, 0.5, 0, 0, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if queryset is None:\n queryset = self.model._default_manager"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98813:Assign_L328_C16", "label": "queryset =", "type": "assigned_variable", "loc": [328, 328], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98813:If_L327_C12", "vector": [14, 4, 0.77, 0.0023, 4, 0.58, 0.0, 38, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "queryset", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " queryset = self.model._default_manager"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98813:Assign_L329_C12", "label": "qs = filter()", "type": "assigned_variable", "loc": [329, 332], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98813:If_L324_C8", "vector": [14, 3, 0.7758, 0.0094, 3, 0.33, 1.0, 251, 3, 1, 0, 0, 526, 10, 2], "semantic": {"name": "qs", "arg_names": [], "import_names": [], "rhs_call_name": "filter", "annotation": ""}, "snippet": " qs = queryset.filter(**{\n self.ct_field.name: ContentType.objects.get_for_model(self.instance),\n self.ct_fk_field.name: self.instance.pk,\n })"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98813:Expr_L333_C8", "label": "__init__()", "type": "expression", "loc": [333, 336], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L314_C4", "vector": [8, 2, 0.7852, 0.0094, 2, 0.5, 1.0, 555, 3, 4, 0, 0, 0, 0, 2], "semantic": {"name": "__init__", "arg_names": [], "import_names": [], "rhs_call_name": "__init__", "annotation": ""}, "snippet": " super(BaseGenericInlineFormSet, self).__init__(\n queryset=qs, data=data, files=files,\n prefix=prefix\n )"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L339_C4", "label": "get_default_prefix", "type": "function", "loc": [339, 343], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98813:ClassDef_L309_C0", "vector": [2, 1, 0.8005, 0.0117, 1, 0.74, 0.5, 80, 0, 1, 1, 0, 0, 0, 2], "semantic": {"name": "get_default_prefix", "arg_names": ["cls"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def get_default_prefix(cls):\n opts = cls.model._meta\n return '-'.join((opts.app_label, opts.object_name.lower(),\n cls.ct_field.name, cls.ct_fk_field.name,\n ))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98813:Assign_L340_C8", "label": "opts =", "type": "assigned_variable", "loc": [340, 340], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L339_C4", "vector": [14, 2, 0.7981, 0.0023, 2, 0.57, 0.0, 631, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "opts", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " opts = cls.model._meta"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98813:Return_L341_C8", "label": "return", "type": "return", "loc": [341, 343], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L339_C4", "vector": [13, 2, 0.8028, 0.007, 2, 0.57, 1.0, 0, 3, 0, 0, 0, 0, 10, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return '-'.join((opts.app_label, opts.object_name.lower(),\n cls.ct_field.name, cls.ct_fk_field.name,\n ))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98813:Assign_L344_C4", "label": "get_default_prefix = classmethod()", "type": "assigned_variable", "loc": [344, 344], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98813:ClassDef_L309_C0", "vector": [14, 1, 0.8075, 0.0023, 1, 0.74, 0.75, 80, 3, 1, 0, 0, 76, 10, 1], "semantic": {"name": "get_default_prefix", "arg_names": [], "import_names": [], "rhs_call_name": "classmethod", "annotation": ""}, "snippet": " get_default_prefix = classmethod(get_default_prefix)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L346_C4", "label": "save_new", "type": "function", "loc": [346, 354], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98813:ClassDef_L309_C0", "vector": [2, 1, 0.8216, 0.0211, 1, 0.74, 1.0, 300, 0, 3, 1, 0, 0, 0, 5], "semantic": {"name": "save_new", "arg_names": ["self", "form", "commit"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def save_new(self, form, commit=True):\n # Avoid a circular import.\n from django.contrib.contenttypes.models import ContentType\n kwargs = {\n self.ct_field.get_attname(): ContentType.objects.get_for_model(self.instance).pk,\n self.ct_fk_field.get_attname(): self.instance.pk,\n }\n new_obj = self.model(**kwargs)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98813:ImportFrom_L348_C8", "label": "from django.contrib.contenttypes.models import ContentType", "type": "import", "loc": [348, 348], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L346_C4", "vector": [1, 2, 0.8169, 0.0023, 2, 0.39, 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_98813:Assign_L349_C8", "label": "kwargs =", "type": "assigned_variable", "loc": [349, 352], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L346_C4", "vector": [14, 2, 0.8228, 0.0094, 2, 0.39, 0.3333, 987, 0, 0, 0, 0, 0, 6, 3], "semantic": {"name": "kwargs", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " kwargs = {\n self.ct_field.get_attname(): ContentType.objects.get_for_model(self.instance).pk,\n self.ct_fk_field.get_attname(): self.instance.pk,\n }"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98813:Assign_L353_C8", "label": "new_obj = model()", "type": "assigned_variable", "loc": [353, 353], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L346_C4", "vector": [14, 2, 0.8286, 0.0023, 2, 0.39, 0.6667, 237, 3, 1, 0, 0, 722, 10, 1], "semantic": {"name": "new_obj", "arg_names": [], "import_names": [], "rhs_call_name": "model", "annotation": ""}, "snippet": " new_obj = self.model(**kwargs)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98813:Return_L354_C8", "label": "return", "type": "return", "loc": [354, 354], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L346_C4", "vector": [13, 2, 0.831, 0.0023, 2, 0.39, 1.0, 0, 3, 0, 0, 0, 0, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return save_instance(form, new_obj, commit=commit)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L356_C0", "label": "generic_inlineformset_factory", "type": "function", "loc": [356, 389], "level": 0, "parent": null, "vector": [2, 0, 0.8744, 0.0798, 0, 0.66, 0.8636, 709, 0, 12, 1, 0, 0, 0, 8], "semantic": {"name": "generic_inlineformset_factory", "arg_names": ["model", "form", "formset", "ct_field", "fk_field", "fields", "exclude", "extra", "can_order", "can_delete", "max_num", "formfield_callback"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "def generic_inlineformset_factory(model, form=ModelForm,\n formset=BaseGenericInlineFormSet,\n ct_field=\"content_type\", fk_field=\"object_id\",\n fields=None, exclude=None,\n extra=3, can_order=False, can_delete=True,\n max_num=None,\n formfield_callback=lambda f: f.formfield()):\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98813:Expr_L363_C4", "label": "expression", "type": "expression", "loc": [363, 368], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L356_C0", "vector": [8, 1, 0.858, 0.0141, 1, 0.31, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"\n Returns an ``GenericInlineFormSet`` for the given kwargs.\n\n You must provide ``ct_field`` and ``object_id`` if they different from the\n defaults ``content_type`` and ``object_id`` respectively.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98813:Assign_L369_C4", "label": "opts =", "type": "assigned_variable", "loc": [369, 369], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L356_C0", "vector": [14, 1, 0.8662, 0.0023, 1, 0.31, 0.1, 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_98813:ImportFrom_L371_C4", "label": "from django.contrib.contenttypes.models import ContentType", "type": "import", "loc": [371, 371], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L356_C0", "vector": [1, 1, 0.8709, 0.0023, 1, 0.31, 0.2, 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_98813:Assign_L373_C4", "label": "ct_field = get_field()", "type": "assigned_variable", "loc": [373, 373], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L356_C0", "vector": [14, 1, 0.8756, 0.0023, 1, 0.31, 0.3, 883, 3, 1, 0, 0, 389, 10, 1], "semantic": {"name": "ct_field", "arg_names": [], "import_names": [], "rhs_call_name": "get_field", "annotation": ""}, "snippet": " ct_field = opts.get_field(ct_field)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98813:If_L374_C4", "label": "if", "type": "if", "loc": [374, 375], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L356_C0", "vector": [4, 1, 0.8791, 0.0047, 1, 0.31, 0.4, 0, 0, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if not isinstance(ct_field, models.ForeignKey) or ct_field.rel.to != ContentType:\n raise Exception(\"fk_name '%s' is not a ForeignKey to ContentType\" % ct_field)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98813:Assign_L376_C4", "label": "fk_field = get_field()", "type": "assigned_variable", "loc": [376, 376], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L356_C0", "vector": [14, 1, 0.8826, 0.0023, 1, 0.31, 0.5, 45, 3, 1, 0, 0, 389, 10, 1], "semantic": {"name": "fk_field", "arg_names": [], "import_names": [], "rhs_call_name": "get_field", "annotation": ""}, "snippet": " fk_field = opts.get_field(fk_field) # let the exception propagate"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98813:If_L377_C4", "label": "if", "type": "if", "loc": [377, 381], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L356_C0", "vector": [4, 1, 0.8897, 0.0117, 1, 0.31, 0.6, 0, 0, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if exclude is not None:\n exclude = list(exclude)\n exclude.extend([ct_field.name, fk_field.name])\n else:\n exclude = [ct_field.name, fk_field.name]"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98813:Assign_L378_C8", "label": "exclude = list()", "type": "assigned_variable", "loc": [378, 378], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98813:If_L377_C4", "vector": [14, 2, 0.8873, 0.0023, 2, 0.1, 0.0, 739, 3, 1, 0, 0, 430, 10, 1], "semantic": {"name": "exclude", "arg_names": [], "import_names": [], "rhs_call_name": "list", "annotation": ""}, "snippet": " exclude = list(exclude)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98813:Expr_L379_C8", "label": "extend()", "type": "expression", "loc": [379, 379], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98813:If_L377_C4", "vector": [8, 2, 0.8897, 0.0023, 2, 0.1, 0.5, 660, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "extend", "arg_names": [], "import_names": [], "rhs_call_name": "extend", "annotation": ""}, "snippet": " exclude.extend([ct_field.name, fk_field.name])"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98813:Assign_L381_C8", "label": "exclude =", "type": "assigned_variable", "loc": [381, 381], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98813:If_L377_C4", "vector": [14, 2, 0.8944, 0.0023, 2, 0.1, 1.0, 739, 0, 0, 0, 0, 0, 5, 0], "semantic": {"name": "exclude", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " exclude = [ct_field.name, fk_field.name]"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98813:Assign_L382_C4", "label": "FormSet = modelformset_factory()", "type": "assigned_variable", "loc": [382, 386], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L356_C0", "vector": [14, 1, 0.9014, 0.0117, 1, 0.31, 0.7, 477, 3, 10, 0, 0, 345, 10, 1], "semantic": {"name": "FormSet", "arg_names": [], "import_names": [], "rhs_call_name": "modelformset_factory", "annotation": ""}, "snippet": " FormSet = modelformset_factory(model, form=form,\n formfield_callback=formfield_callback,\n formset=formset,\n extra=extra, can_delete=can_delete, can_order=can_order,\n fields=fields, exclude=exclude, max_num=max_num)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98813:Assign_L387_C4", "label": "FormSet.ct_field =", "type": "assigned_variable", "loc": [387, 387], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L356_C0", "vector": [14, 1, 0.9085, 0.0023, 1, 0.31, 0.8, 609, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "FormSet.ct_field", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " FormSet.ct_field = ct_field"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98813:Assign_L388_C4", "label": "FormSet.ct_fk_field =", "type": "assigned_variable", "loc": [388, 388], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L356_C0", "vector": [14, 1, 0.9108, 0.0023, 1, 0.31, 0.9, 203, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "FormSet.ct_fk_field", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " FormSet.ct_fk_field = fk_field"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98813:Return_L389_C4", "label": "return", "type": "return", "loc": [389, 389], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L356_C0", "vector": [13, 1, 0.9131, 0.0023, 1, 0.31, 1.0, 0, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return FormSet"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98813:ClassDef_L391_C0", "label": "GenericInlineModelAdmin", "type": "class", "loc": [391, 420], "level": 0, "parent": null, "vector": [3, 0, 0.9519, 0.0704, 0, 0.66, 0.9091, 723, 0, 1, 0, 0, 289, 0, 6], "semantic": {"name": "GenericInlineModelAdmin", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class GenericInlineModelAdmin(InlineModelAdmin):\n ct_field = \"content_type\"\n ct_fk_field = \"object_id\"\n formset = BaseGenericInlineFormSet\n\n def get_formset(self, request, obj=None):\n if self.declared_fieldsets:\n fields = flatten_fieldsets(self.declared_fieldsets)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98813:Assign_L392_C4", "label": "ct_field =", "type": "assigned_variable", "loc": [392, 392], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98813:ClassDef_L391_C0", "vector": [14, 1, 0.9202, 0.0023, 1, 0.57, 0.0, 883, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "ct_field", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " ct_field = \"content_type\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98813:Assign_L393_C4", "label": "ct_fk_field =", "type": "assigned_variable", "loc": [393, 393], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98813:ClassDef_L391_C0", "vector": [14, 1, 0.9225, 0.0023, 1, 0.57, 0.3333, 984, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "ct_fk_field", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " ct_fk_field = \"object_id\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98813:Assign_L394_C4", "label": "formset =", "type": "assigned_variable", "loc": [394, 394], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98813:ClassDef_L391_C0", "vector": [14, 1, 0.9249, 0.0023, 1, 0.57, 0.6667, 613, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "formset", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " formset = BaseGenericInlineFormSet"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L396_C4", "label": "get_formset", "type": "function", "loc": [396, 420], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98813:ClassDef_L391_C0", "vector": [2, 1, 0.9577, 0.0587, 1, 0.57, 1.0, 405, 0, 3, 1, 0, 0, 0, 6], "semantic": {"name": "get_formset", "arg_names": ["self", "request", "obj"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def get_formset(self, request, obj=None):\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 = []\n else:"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98813:If_L397_C8", "label": "if", "type": "if", "loc": [397, 400], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L396_C4", "vector": [4, 2, 0.9354, 0.0094, 2, 0.18, 0.0, 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_98813:Assign_L398_C12", "label": "fields = flatten_fieldsets()", "type": "assigned_variable", "loc": [398, 398], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98813:If_L397_C8", "vector": [14, 3, 0.9343, 0.0023, 3, 0.37, 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_98813:Assign_L400_C12", "label": "fields =", "type": "assigned_variable", "loc": [400, 400], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98813:If_L397_C8", "vector": [14, 3, 0.939, 0.0023, 3, 0.37, 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_98813:If_L401_C8", "label": "if", "type": "if", "loc": [401, 404], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L396_C4", "vector": [4, 2, 0.9448, 0.0094, 2, 0.18, 0.2, 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_98813:Assign_L402_C12", "label": "exclude =", "type": "assigned_variable", "loc": [402, 402], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98813:If_L401_C8", "vector": [14, 3, 0.9437, 0.0023, 3, 0.81, 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_98813:Assign_L404_C12", "label": "exclude = list()", "type": "assigned_variable", "loc": [404, 404], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98813:If_L401_C8", "vector": [14, 3, 0.9484, 0.0023, 3, 0.81, 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_98813:Expr_L405_C8", "label": "extend()", "type": "expression", "loc": [405, 405], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L396_C4", "vector": [8, 2, 0.9507, 0.0023, 2, 0.18, 0.4, 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_98813:Assign_L406_C8", "label": "exclude =", "type": "assigned_variable", "loc": [406, 406], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L396_C4", "vector": [14, 2, 0.9531, 0.0023, 2, 0.18, 0.6, 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_98813:Assign_L407_C8", "label": "defaults =", "type": "assigned_variable", "loc": [407, 419], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L396_C4", "vector": [14, 2, 0.9695, 0.0305, 2, 0.18, 0.8, 233, 0, 0, 0, 0, 0, 6, 1], "semantic": {"name": "defaults", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " defaults = {\n \"ct_field\": self.ct_field,\n \"fk_field\": self.ct_fk_field,\n \"form\": self.form,\n \"formfield_callback\": curry(self.formfield_for_dbfield, request=request),\n \"formset\": self.formset,\n \"extra\": self.extra,\n \"can_delete\": self.can_delete,"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98813:Return_L420_C8", "label": "return", "type": "return", "loc": [420, 420], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L396_C4", "vector": [13, 2, 0.9859, 0.0023, 2, 0.18, 1.0, 0, 3, 0, 0, 0, 0, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return generic_inlineformset_factory(self.model, **defaults)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98813:ClassDef_L422_C0", "label": "GenericStackedInline", "type": "class", "loc": [422, 423], "level": 0, "parent": null, "vector": [3, 0, 0.9918, 0.0047, 0, 0.66, 0.9545, 957, 0, 0, 0, 0, 723, 0, 0], "semantic": {"name": "GenericStackedInline", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class GenericStackedInline(GenericInlineModelAdmin):\n template = 'admin/edit_inline/stacked.html'"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98813:Assign_L423_C4", "label": "template =", "type": "assigned_variable", "loc": [423, 423], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98813:ClassDef_L422_C0", "vector": [14, 1, 0.993, 0.0023, 1, 0.07, 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_98813:ClassDef_L425_C0", "label": "GenericTabularInline", "type": "class", "loc": [425, 426], "level": 0, "parent": null, "vector": [3, 0, 0.9988, 0.0047, 0, 0.66, 1.0, 725, 0, 0, 0, 0, 723, 0, 0], "semantic": {"name": "GenericTabularInline", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class GenericTabularInline(GenericInlineModelAdmin):\n template = 'admin/edit_inline/tabular.html'"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98813:Assign_L426_C4", "label": "template =", "type": "assigned_variable", "loc": [426, 426], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98813:ClassDef_L425_C0", "vector": [14, 1, 1.0, 0.0023, 1, 0.69, 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_98813:ClassDef_L20_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98813:Expr_L21_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98813:ClassDef_L20_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L26_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L26_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98813:Assign_L27_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L26_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98813:Assign_L28_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98813:ClassDef_L20_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L30_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L30_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98813:Assign_L31_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L30_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98813:Assign_L32_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L30_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98813:Assign_L33_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L30_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98813:Expr_L34_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L30_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98813:Expr_L37_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L30_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98813:Expr_L40_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98813:ClassDef_L20_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L42_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L42_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98813:Expr_L43_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L42_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98813:If_L47_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98813:If_L47_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98813:Assign_L48_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98813:If_L47_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98813:Assign_L49_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98813:If_L47_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98813:Assign_L50_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98813:ClassDef_L20_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L52_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L52_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98813:Assign_L55_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L52_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98813:If_L56_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98813:If_L56_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98813:Return_L57_C13"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98813:If_L56_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98813:If_L58_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98813:If_L58_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98813:Return_L59_C13"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98813:ClassDef_L20_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L64_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L64_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98813:If_L65_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98813:If_L65_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98813:Return_L66_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L64_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98813:Try_L68_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98813:Try_L68_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98813:Return_L69_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98813:Try_L68_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98813:Assign_L71_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98813:Try_L68_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98813:Assign_L77_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98813:Try_L68_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98813:Assign_L78_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98813:Try_L68_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98813:If_L79_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98813:If_L79_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98813:Assign_L80_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98813:If_L79_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98813:Try_L81_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98813:Try_L81_C16", "t": "ajibawa-2023/Python-Code-Large/train/row_98813:Assign_L82_C20"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98813:Try_L68_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98813:Expr_L85_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98813:Try_L68_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98813:Return_L86_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98813:ClassDef_L20_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L88_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L88_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98813:If_L89_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L88_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98813:Assign_L92_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L88_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98813:Assign_L93_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L88_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98813:If_L94_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98813:If_L94_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98813:Assign_L95_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98813:If_L94_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98813:Assign_L96_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L88_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98813:Expr_L98_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L88_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98813:Expr_L99_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L88_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98813:Expr_L100_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98813:ClassDef_L102_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98813:Expr_L103_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98813:ClassDef_L102_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L105_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L105_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98813:Assign_L106_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L105_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98813:Assign_L107_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L105_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98813:Assign_L114_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L105_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98813:Assign_L115_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L105_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98813:Assign_L117_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L105_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98813:Assign_L118_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L105_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98813:Assign_L119_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L105_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98813:Expr_L120_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98813:ClassDef_L102_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L122_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L122_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98813:Return_L123_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98813:ClassDef_L102_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L125_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L125_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98813:Assign_L126_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L125_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98813:Return_L127_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98813:ClassDef_L102_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L129_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L129_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98813:Return_L130_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98813:ClassDef_L102_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L132_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L132_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98813:Return_L133_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98813:ClassDef_L102_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L135_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L135_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98813:Return_L136_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98813:ClassDef_L102_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L138_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L138_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98813:Expr_L139_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L138_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98813:Assign_L142_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L138_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98813:Expr_L145_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98813:ClassDef_L102_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L147_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98813:ClassDef_L102_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L150_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98813:ClassDef_L102_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L153_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L153_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98813:Return_L154_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98813:ClassDef_L102_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L156_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L156_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98813:Return_L159_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98813:ClassDef_L102_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L161_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L161_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98813:Expr_L162_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L161_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98813:If_L166_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98813:If_L166_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98813:Return_L167_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L161_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98813:Assign_L168_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L161_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98813:Assign_L169_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L161_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98813:Assign_L170_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L161_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98813:Return_L171_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98813:ClassDef_L102_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L174_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L174_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98813:Expr_L175_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L174_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98813:Return_L179_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98813:ClassDef_L187_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98813:Expr_L188_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98813:ClassDef_L187_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L196_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L196_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98813:Assign_L197_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98813:ClassDef_L187_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L199_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L199_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98813:If_L200_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98813:If_L200_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98813:Return_L201_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L199_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98813:ImportFrom_L204_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L199_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98813:Assign_L208_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L199_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98813:Assign_L209_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L199_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98813:Assign_L210_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L199_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98813:Assign_L212_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L199_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98813:Assign_L214_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L199_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98813:Return_L226_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98813:ClassDef_L187_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L228_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L228_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98813:If_L229_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L228_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98813:Assign_L232_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L228_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98813:Expr_L233_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L228_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98813:For_L234_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98813:For_L234_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98813:Expr_L235_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L237_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98813:Expr_L238_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L237_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98813:ClassDef_L243_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98813:ClassDef_L243_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L244_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L244_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98813:Expr_L248_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L244_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98813:Assign_L249_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L244_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98813:Assign_L250_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L244_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98813:Assign_L251_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L244_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98813:Assign_L252_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L244_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98813:Assign_L253_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L244_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98813:Assign_L254_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L244_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98813:Assign_L255_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L244_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98813:Assign_L256_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L244_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98813:Assign_L257_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L244_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98813:Assign_L258_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L244_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98813:Assign_L259_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L244_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98813:Assign_L260_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98813:ClassDef_L243_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L262_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L262_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98813:Assign_L263_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L262_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98813:Assign_L264_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L262_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98813:Return_L268_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98813:ClassDef_L243_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L270_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L270_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98813:For_L271_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98813:For_L271_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98813:If_L272_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98813:For_L271_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98813:Expr_L274_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98813:For_L271_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98813:Expr_L275_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98813:For_L271_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98813:Expr_L276_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98813:ClassDef_L243_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98813:Assign_L277_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98813:ClassDef_L243_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L279_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L279_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98813:Assign_L280_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L279_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98813:For_L281_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98813:For_L281_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98813:Expr_L282_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98813:ClassDef_L243_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98813:Assign_L283_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98813:ClassDef_L243_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L285_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L285_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98813:Assign_L286_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L285_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98813:For_L287_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98813:For_L287_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98813:Expr_L288_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98813:ClassDef_L243_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98813:Assign_L289_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98813:ClassDef_L243_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L291_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L291_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98813:Assign_L292_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L291_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98813:Assign_L293_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L291_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98813:Assign_L294_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L291_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98813:Return_L295_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98813:ClassDef_L243_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98813:Assign_L296_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L237_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98813:Return_L298_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98813:ClassDef_L300_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L301_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L301_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98813:Assign_L302_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L301_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98813:Assign_L303_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L301_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98813:Assign_L304_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L301_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98813:Assign_L305_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L301_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98813:Assign_L306_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L301_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98813:Assign_L307_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98813:ClassDef_L309_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98813:Expr_L310_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98813:ClassDef_L309_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L314_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L314_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98813:ImportFrom_L317_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L314_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98813:Assign_L318_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L314_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98813:Assign_L319_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L314_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98813:Assign_L320_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L314_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98813:If_L324_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98813:If_L324_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98813:Assign_L325_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98813:If_L324_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98813:If_L327_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98813:If_L327_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98813:Assign_L328_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98813:If_L324_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98813:Assign_L329_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L314_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98813:Expr_L333_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98813:ClassDef_L309_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L339_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L339_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98813:Assign_L340_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L339_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98813:Return_L341_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98813:ClassDef_L309_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98813:Assign_L344_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98813:ClassDef_L309_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L346_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L346_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98813:ImportFrom_L348_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L346_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98813:Assign_L349_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L346_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98813:Assign_L353_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L346_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98813:Return_L354_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L356_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98813:Expr_L363_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L356_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98813:Assign_L369_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L356_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98813:ImportFrom_L371_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L356_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98813:Assign_L373_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L356_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98813:If_L374_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L356_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98813:Assign_L376_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L356_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98813:If_L377_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98813:If_L377_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98813:Assign_L378_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98813:If_L377_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98813:Expr_L379_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98813:If_L377_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98813:Assign_L381_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L356_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98813:Assign_L382_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L356_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98813:Assign_L387_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L356_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98813:Assign_L388_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L356_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98813:Return_L389_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98813:ClassDef_L391_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98813:Assign_L392_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98813:ClassDef_L391_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98813:Assign_L393_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98813:ClassDef_L391_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98813:Assign_L394_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98813:ClassDef_L391_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L396_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L396_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98813:If_L397_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98813:If_L397_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98813:Assign_L398_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98813:If_L397_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98813:Assign_L400_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L396_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98813:If_L401_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98813:If_L401_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98813:Assign_L402_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98813:If_L401_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98813:Assign_L404_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L396_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98813:Expr_L405_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L396_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98813:Assign_L406_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L396_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98813:Assign_L407_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98813:FunctionDef_L396_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98813:Return_L420_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98813:ClassDef_L422_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98813:Assign_L423_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98813:ClassDef_L425_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98813:Assign_L426_C4"}]
from django import http from django.contrib.contenttypes.models import ContentType from django.contrib.sites.models import Site, get_current_site from django.core.exceptions import ObjectDoesNotExist def shortcut(request, content_type_id, object_id): "Redirect to an object's page based on a content-type ID and an object ID." # Look up the object, making sure it's got a get_absolute_url() function. try: content_type = ContentType.objects.get(pk=content_type_id) if not content_type.model_class(): raise http.Http404("Content type %s object has no associated model" % content_type_id) obj = content_type.get_object_for_this_type(pk=object_id) except (ObjectDoesNotExist, ValueError): raise http.Http404("Content type %s object %s doesn't exist" % (content_type_id, object_id)) try: absurl = obj.get_absolute_url() except AttributeError: raise http.Http404("%s objects don't have get_absolute_url() methods" % content_type.name) # Try to figure out the object's domain, so we can do a cross-site redirect # if necessary. # If the object actually defines a domain, we're done. if absurl.startswith('http://') or absurl.startswith('https://'): return http.HttpResponseRedirect(absurl) # Otherwise, we need to introspect the object's relationships for a # relation to the Site object object_domain = None if Site._meta.installed: opts = obj._meta # First, look for an many-to-many relationship to Site. for field in opts.many_to_many: if field.rel.to is Site: try: # Caveat: In the case of multiple related Sites, this just # selects the *first* one, which is arbitrary. object_domain = getattr(obj, field.name).all()[0].domain except IndexError: pass if object_domain is not None: break # Next, look for a many-to-one relationship to Site. if object_domain is None: for field in obj._meta.fields: if field.rel and field.rel.to is Site: try: object_domain = getattr(obj, field.name).domain except Site.DoesNotExist: pass if object_domain is not None: break # Fall back to the current site (if possible). if object_domain is None: try: object_domain = get_current_site(request).domain except Site.DoesNotExist: pass # If all that malarkey found an object domain, use it. Otherwise, fall back # to whatever get_absolute_url() returned. if object_domain is not None: protocol = request.is_secure() and 'https' or 'http' return http.HttpResponseRedirect('%s://%s%s' % (protocol, object_domain, absurl)) else: return http.HttpResponseRedirect(absurl)
ajibawa-2023/Python-Code-Large/train/row_98814
35
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_98814:ImportFrom_L1_C0", "label": "from django import http", "type": "import", "loc": [1, 1], "level": 0, "parent": null, "vector": [1, 0, 0.0141, 0.0141, 0, 0.66, 0.0, 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_98814:ImportFrom_L2_C0", "label": "from django.contrib.contenttypes.models import ContentType", "type": "import", "loc": [2, 2], "level": 0, "parent": null, "vector": [1, 0, 0.0282, 0.0141, 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_98814:ImportFrom_L3_C0", "label": "from django.contrib.sites.models import Site, get_current_site", "type": "import", "loc": [3, 3], "level": 0, "parent": null, "vector": [1, 0, 0.0423, 0.0141, 0, 0.66, 0.5, 890, 0, 2, 0, 0, 890, 0, 0], "semantic": {"name": "django.contrib.sites.models", "arg_names": [], "import_names": ["Site", "get_current_site"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.contrib.sites.models import Site, get_current_site"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98814:ImportFrom_L4_C0", "label": "from django.core.exceptions import ObjectDoesNotExist", "type": "import", "loc": [4, 4], "level": 0, "parent": null, "vector": [1, 0, 0.0563, 0.0141, 0, 0.66, 0.75, 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_98814:FunctionDef_L6_C0", "label": "shortcut", "type": "function", "loc": [6, 71], "level": 0, "parent": null, "vector": [2, 0, 0.5423, 0.9296, 0, 0.66, 1.0, 63, 0, 3, 1, 0, 0, 0, 17], "semantic": {"name": "shortcut", "arg_names": ["request", "content_type_id", "object_id"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "def shortcut(request, content_type_id, object_id):\n \"Redirect to an object's page based on a content-type ID and an object ID.\"\n # Look up the object, making sure it's got a get_absolute_url() function.\n try:\n content_type = ContentType.objects.get(pk=content_type_id)\n if not content_type.model_class():\n raise http.Http404(\"Content type %s object has no associated model\" % content_type_id)\n obj = content_type.get_object_for_this_type(pk=object_id)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98814:Expr_L7_C4", "label": "expression", "type": "expression", "loc": [7, 7], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98814:FunctionDef_L6_C0", "vector": [8, 1, 0.0986, 0.0141, 1, 0.54, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"Redirect to an object's page based on a content-type ID and an object ID.\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98814:Try_L9_C4", "label": "try", "type": "try", "loc": [9, 15], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98814:FunctionDef_L6_C0", "vector": [7, 1, 0.169, 0.0986, 1, 0.54, 0.1429, 0, 0, 1, 0, 0, 0, 0, 5], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " try:\n content_type = ContentType.objects.get(pk=content_type_id)\n if not content_type.model_class():\n raise http.Http404(\"Content type %s object has no associated model\" % content_type_id)\n obj = content_type.get_object_for_this_type(pk=object_id)\n except (ObjectDoesNotExist, ValueError):\n raise http.Http404(\"Content type %s object %s doesn't exist\" % (content_type_id, object_id))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98814:Assign_L10_C8", "label": "content_type = get()", "type": "assigned_variable", "loc": [10, 10], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98814:Try_L9_C4", "vector": [14, 2, 0.1408, 0.0141, 2, 0.63, 0.0, 610, 3, 1, 0, 0, 607, 10, 1], "semantic": {"name": "content_type", "arg_names": [], "import_names": [], "rhs_call_name": "get", "annotation": ""}, "snippet": " content_type = ContentType.objects.get(pk=content_type_id)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98814:If_L11_C8", "label": "if", "type": "if", "loc": [11, 12], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98814:Try_L9_C4", "vector": [4, 2, 0.162, 0.0282, 2, 0.63, 0.5, 0, 0, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if not content_type.model_class():\n raise http.Http404(\"Content type %s object has no associated model\" % content_type_id)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98814:Assign_L13_C8", "label": "obj = get_object_for_this_type()", "type": "assigned_variable", "loc": [13, 13], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98814:Try_L9_C4", "vector": [14, 2, 0.1831, 0.0141, 2, 0.63, 1.0, 505, 3, 1, 0, 0, 753, 10, 1], "semantic": {"name": "obj", "arg_names": [], "import_names": [], "rhs_call_name": "get_object_for_this_type", "annotation": ""}, "snippet": " obj = content_type.get_object_for_this_type(pk=object_id)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98814:Try_L16_C4", "label": "try", "type": "try", "loc": [16, 19], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98814:FunctionDef_L6_C0", "vector": [7, 1, 0.2465, 0.0563, 1, 0.54, 0.2857, 0, 0, 1, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " try:\n absurl = obj.get_absolute_url()\n except AttributeError:\n raise http.Http404(\"%s objects don't have get_absolute_url() methods\" % content_type.name)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98814:Assign_L17_C8", "label": "absurl = get_absolute_url()", "type": "assigned_variable", "loc": [17, 17], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98814:Try_L16_C4", "vector": [14, 2, 0.2394, 0.0141, 2, 0.27, 0.0, 133, 3, 0, 0, 0, 276, 10, 1], "semantic": {"name": "absurl", "arg_names": [], "import_names": [], "rhs_call_name": "get_absolute_url", "annotation": ""}, "snippet": " absurl = obj.get_absolute_url()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98814:If_L25_C4", "label": "if", "type": "if", "loc": [25, 26], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98814:FunctionDef_L6_C0", "vector": [4, 1, 0.3592, 0.0282, 1, 0.54, 0.4286, 0, 0, 0, 0, 0, 0, 0, 3], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if absurl.startswith('http://') or absurl.startswith('https://'):\n return http.HttpResponseRedirect(absurl)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98814:Return_L26_C8", "label": "return", "type": "return", "loc": [26, 26], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98814:If_L25_C4", "vector": [13, 2, 0.3662, 0.0141, 2, 0.69, 0.0, 0, 3, 0, 0, 0, 0, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return http.HttpResponseRedirect(absurl)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98814:Assign_L30_C4", "label": "object_domain =", "type": "assigned_variable", "loc": [30, 30], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98814:FunctionDef_L6_C0", "vector": [14, 1, 0.4225, 0.0141, 1, 0.54, 0.5714, 83, 1, 0, 0, 0, 0, 9, 0], "semantic": {"name": "object_domain", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " object_domain = None"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98814:If_L32_C4", "label": "if", "type": "if", "loc": [32, 56], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98814:FunctionDef_L6_C0", "vector": [4, 1, 0.6197, 0.3521, 1, 0.54, 0.7143, 0, 7, 0, 0, 0, 0, 0, 3], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if Site._meta.installed:\n opts = obj._meta\n\n # First, look for an many-to-many relationship to Site.\n for field in opts.many_to_many:\n if field.rel.to is Site:\n try:\n # Caveat: In the case of multiple related Sites, this just"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98814:Assign_L33_C8", "label": "opts =", "type": "assigned_variable", "loc": [33, 33], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98814:If_L32_C4", "vector": [14, 2, 0.4648, 0.0141, 2, 0.04, 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_98814:For_L36_C8", "label": "for field", "type": "for", "loc": [36, 45], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98814:If_L32_C4", "vector": [6, 2, 0.5704, 0.1408, 2, 0.04, 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 opts.many_to_many:\n if field.rel.to is Site:\n try:\n # Caveat: In the case of multiple related Sites, this just\n # selects the *first* one, which is arbitrary.\n object_domain = getattr(obj, field.name).all()[0].domain\n except IndexError:\n pass"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98814:If_L37_C12", "label": "if", "type": "if", "loc": [37, 45], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98814:For_L36_C8", "vector": [4, 3, 0.5775, 0.1268, 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 field.rel.to is Site:\n try:\n # Caveat: In the case of multiple related Sites, this just\n # selects the *first* one, which is arbitrary.\n object_domain = getattr(obj, field.name).all()[0].domain\n except IndexError:\n pass\n if object_domain is not None:"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98814:Try_L38_C16", "label": "try", "type": "try", "loc": [38, 43], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98814:If_L37_C12", "vector": [7, 4, 0.5704, 0.0845, 4, 0.49, 0.0, 0, 0, 1, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " try:\n # Caveat: In the case of multiple related Sites, this just\n # selects the *first* one, which is arbitrary.\n object_domain = getattr(obj, field.name).all()[0].domain\n except IndexError:\n pass"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98814:Assign_L41_C20", "label": "object_domain =", "type": "assigned_variable", "loc": [41, 41], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98814:Try_L38_C16", "vector": [14, 5, 0.5775, 0.0141, 5, 0.27, 0.0, 83, 7, 0, 0, 0, 0, 0, 2], "semantic": {"name": "object_domain", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " object_domain = getattr(obj, field.name).all()[0].domain"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98814:If_L44_C16", "label": "if", "type": "if", "loc": [44, 45], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98814:If_L37_C12", "vector": [4, 4, 0.6268, 0.0282, 4, 0.49, 1.0, 0, 0, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if object_domain is not None:\n break"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98814:If_L48_C8", "label": "if", "type": "if", "loc": [48, 56], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98814:If_L32_C4", "vector": [4, 2, 0.7324, 0.1268, 2, 0.04, 1.0, 0, 0, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if object_domain is None:\n for field in obj._meta.fields:\n if field.rel and field.rel.to is Site:\n try:\n object_domain = getattr(obj, field.name).domain\n except Site.DoesNotExist:\n pass\n if object_domain is not None:"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98814:For_L49_C12", "label": "for field", "type": "for", "loc": [49, 56], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98814:If_L48_C8", "vector": [6, 3, 0.7394, 0.1127, 3, 0.11, 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 obj._meta.fields:\n if field.rel and field.rel.to is Site:\n try:\n object_domain = getattr(obj, field.name).domain\n except Site.DoesNotExist:\n pass\n if object_domain is not None:\n break"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98814:If_L50_C16", "label": "if", "type": "if", "loc": [50, 56], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98814:For_L49_C12", "vector": [4, 4, 0.7465, 0.0986, 4, 0.97, 0.0, 0, 0, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if field.rel and field.rel.to is Site:\n try:\n object_domain = getattr(obj, field.name).domain\n except Site.DoesNotExist:\n pass\n if object_domain is not None:\n break"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98814:Try_L51_C20", "label": "try", "type": "try", "loc": [51, 54], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98814:If_L50_C16", "vector": [7, 5, 0.7394, 0.0563, 5, 0.42, 0.0, 0, 0, 1, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " try:\n object_domain = getattr(obj, field.name).domain\n except Site.DoesNotExist:\n pass"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98814:Assign_L52_C24", "label": "object_domain =", "type": "assigned_variable", "loc": [52, 52], "level": 6, "parent": "ajibawa-2023/Python-Code-Large/train/row_98814:Try_L51_C20", "vector": [14, 6, 0.7324, 0.0141, 6, 0.88, 0.0, 83, 7, 0, 0, 0, 0, 0, 1], "semantic": {"name": "object_domain", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " object_domain = getattr(obj, field.name).domain"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98814:If_L55_C20", "label": "if", "type": "if", "loc": [55, 56], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98814:If_L50_C16", "vector": [4, 5, 0.7817, 0.0282, 5, 0.42, 1.0, 0, 0, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if object_domain is not None:\n break"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98814:If_L59_C4", "label": "if", "type": "if", "loc": [59, 63], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98814:FunctionDef_L6_C0", "vector": [4, 1, 0.8592, 0.0704, 1, 0.54, 0.8571, 0, 0, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if object_domain is None:\n try:\n object_domain = get_current_site(request).domain\n except Site.DoesNotExist:\n pass"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98814:Try_L60_C8", "label": "try", "type": "try", "loc": [60, 63], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98814:If_L59_C4", "vector": [7, 2, 0.8662, 0.0563, 2, 0.05, 0.0, 0, 0, 1, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " try:\n object_domain = get_current_site(request).domain\n except Site.DoesNotExist:\n pass"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98814:Assign_L61_C12", "label": "object_domain =", "type": "assigned_variable", "loc": [61, 61], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98814:Try_L60_C8", "vector": [14, 3, 0.8592, 0.0141, 3, 0.52, 0.0, 83, 7, 0, 0, 0, 0, 0, 1], "semantic": {"name": "object_domain", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " object_domain = get_current_site(request).domain"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98814:If_L67_C4", "label": "if", "type": "if", "loc": [67, 71], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98814:FunctionDef_L6_C0", "vector": [4, 1, 0.9718, 0.0704, 1, 0.54, 1.0, 0, 0, 0, 0, 0, 0, 0, 3], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if object_domain is not None:\n protocol = request.is_secure() and 'https' or 'http'\n return http.HttpResponseRedirect('%s://%s%s' % (protocol, object_domain, absurl))\n else:\n return http.HttpResponseRedirect(absurl)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98814:Assign_L68_C8", "label": "protocol =", "type": "assigned_variable", "loc": [68, 68], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98814:If_L67_C4", "vector": [14, 2, 0.9577, 0.0141, 2, 0.03, 0.0, 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_98814:Return_L69_C8", "label": "return", "type": "return", "loc": [69, 69], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98814:If_L67_C4", "vector": [13, 2, 0.9718, 0.0141, 2, 0.03, 0.5, 0, 3, 0, 0, 0, 0, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return http.HttpResponseRedirect('%s://%s%s' % (protocol, object_domain, absurl))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98814:Return_L71_C8", "label": "return", "type": "return", "loc": [71, 71], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98814:If_L67_C4", "vector": [13, 2, 1.0, 0.0141, 2, 0.03, 1.0, 0, 3, 0, 0, 0, 0, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return http.HttpResponseRedirect(absurl)"}]
[{"f": "ajibawa-2023/Python-Code-Large/train/row_98814:FunctionDef_L6_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98814:Expr_L7_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98814:FunctionDef_L6_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98814:Try_L9_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98814:Try_L9_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98814:Assign_L10_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98814:Try_L9_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98814:If_L11_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98814:Try_L9_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98814:Assign_L13_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98814:FunctionDef_L6_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98814:Try_L16_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98814:Try_L16_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98814:Assign_L17_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98814:FunctionDef_L6_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98814:If_L25_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98814:If_L25_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98814:Return_L26_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98814:FunctionDef_L6_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98814:Assign_L30_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98814:FunctionDef_L6_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98814:If_L32_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98814:If_L32_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98814:Assign_L33_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98814:If_L32_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98814:For_L36_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98814:For_L36_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98814:If_L37_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98814:If_L37_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98814:Try_L38_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98814:Try_L38_C16", "t": "ajibawa-2023/Python-Code-Large/train/row_98814:Assign_L41_C20"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98814:If_L37_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98814:If_L44_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98814:If_L32_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98814:If_L48_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98814:If_L48_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98814:For_L49_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98814:For_L49_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98814:If_L50_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98814:If_L50_C16", "t": "ajibawa-2023/Python-Code-Large/train/row_98814:Try_L51_C20"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98814:Try_L51_C20", "t": "ajibawa-2023/Python-Code-Large/train/row_98814:Assign_L52_C24"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98814:If_L50_C16", "t": "ajibawa-2023/Python-Code-Large/train/row_98814:If_L55_C20"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98814:FunctionDef_L6_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98814:If_L59_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98814:If_L59_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98814:Try_L60_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98814:Try_L60_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98814:Assign_L61_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98814:FunctionDef_L6_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98814:If_L67_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98814:If_L67_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98814:Assign_L68_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98814:If_L67_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98814:Return_L69_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98814:If_L67_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98814:Return_L71_C8"}]
from django.contrib.contenttypes.models import ContentType from django.db.models import get_apps, get_models, signals from django.utils.encoding import smart_unicode def update_contenttypes(app, created_models, verbosity=2, **kwargs): """ Creates content types for models in the given app, removing any model entries that no longer have a matching model class. """ ContentType.objects.clear_cache() content_types = list(ContentType.objects.filter(app_label=app.__name__.split('.')[-2])) app_models = get_models(app) if not app_models: return for klass in app_models: opts = klass._meta try: ct = ContentType.objects.get(app_label=opts.app_label, model=opts.object_name.lower()) content_types.remove(ct) except ContentType.DoesNotExist: ct = ContentType(name=smart_unicode(opts.verbose_name_raw), app_label=opts.app_label, model=opts.object_name.lower()) ct.save() if verbosity >= 2: print "Adding content type '%s | %s'" % (ct.app_label, ct.model) # The presence of any remaining content types means the supplied app has an # undefined model. Confirm that the content type is stale before deletion. if content_types: if kwargs.get('interactive', False): content_type_display = '\n'.join([' %s | %s' % (ct.app_label, ct.model) for ct in content_types]) ok_to_delete = raw_input("""The following content types are stale and need to be deleted: %s Any objects related to these content types by a foreign key will also be deleted. Are you sure you want to delete these content types? If you're unsure, answer 'no'. Type 'yes' to continue, or 'no' to cancel: """ % content_type_display) else: ok_to_delete = False if ok_to_delete == 'yes': for ct in content_types: if verbosity >= 2: print "Deleting stale content type '%s | %s'" % (ct.app_label, ct.model) ct.delete() else: if verbosity >= 2: print "Stale content types remain." def update_all_contenttypes(verbosity=2, **kwargs): for app in get_apps(): update_contenttypes(app, None, verbosity, **kwargs) signals.post_syncdb.connect(update_contenttypes) if __name__ == "__main__": update_all_contenttypes()
ajibawa-2023/Python-Code-Large/train/row_98815
37
60
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_98815:ImportFrom_L1_C0", "label": "from django.contrib.contenttypes.models import ContentType", "type": "import", "loc": [1, 1], "level": 0, "parent": null, "vector": [1, 0, 0.0167, 0.0167, 0, 0.66, 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_98815:ImportFrom_L2_C0", "label": "from django.db.models import get_apps, get_models, signals", "type": "import", "loc": [2, 2], "level": 0, "parent": null, "vector": [1, 0, 0.0333, 0.0167, 0, 0.66, 0.1667, 680, 0, 3, 0, 0, 680, 0, 0], "semantic": {"name": "django.db.models", "arg_names": [], "import_names": ["get_apps", "get_models", "signals"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.db.models import get_apps, get_models, signals"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98815:ImportFrom_L3_C0", "label": "from django.utils.encoding import smart_unicode", "type": "import", "loc": [3, 3], "level": 0, "parent": null, "vector": [1, 0, 0.05, 0.0167, 0, 0.66, 0.3333, 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_98815:FunctionDef_L5_C0", "label": "update_contenttypes", "type": "function", "loc": [5, 51], "level": 0, "parent": null, "vector": [2, 0, 0.4667, 0.7833, 0, 0.66, 0.5, 391, 0, 4, 0, 0, 0, 0, 19], "semantic": {"name": "update_contenttypes", "arg_names": ["app", "created_models", "verbosity", "kwargs"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "def update_contenttypes(app, created_models, verbosity=2, **kwargs):\n \"\"\"\n Creates content types for models in the given app, removing any model\n entries that no longer have a matching model class.\n \"\"\"\n ContentType.objects.clear_cache()\n content_types = list(ContentType.objects.filter(app_label=app.__name__.split('.')[-2]))\n app_models = get_models(app)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98815:Expr_L6_C4", "label": "expression", "type": "expression", "loc": [6, 9], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98815:FunctionDef_L5_C0", "vector": [8, 1, 0.125, 0.0667, 1, 0.26, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"\n Creates content types for models in the given app, removing any model\n entries that no longer have a matching model class.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98815:Expr_L10_C4", "label": "clear_cache()", "type": "expression", "loc": [10, 10], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98815:FunctionDef_L5_C0", "vector": [8, 1, 0.1667, 0.0167, 1, 0.26, 0.1667, 808, 3, 0, 0, 0, 0, 0, 1], "semantic": {"name": "clear_cache", "arg_names": [], "import_names": [], "rhs_call_name": "clear_cache", "annotation": ""}, "snippet": " ContentType.objects.clear_cache()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98815:Assign_L11_C4", "label": "content_types = list()", "type": "assigned_variable", "loc": [11, 11], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98815:FunctionDef_L5_C0", "vector": [14, 1, 0.1833, 0.0167, 1, 0.26, 0.3333, 403, 3, 1, 0, 0, 430, 10, 3], "semantic": {"name": "content_types", "arg_names": [], "import_names": [], "rhs_call_name": "list", "annotation": ""}, "snippet": " content_types = list(ContentType.objects.filter(app_label=app.__name__.split('.')[-2]))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98815:Assign_L12_C4", "label": "app_models = get_models()", "type": "assigned_variable", "loc": [12, 12], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98815:FunctionDef_L5_C0", "vector": [14, 1, 0.2, 0.0167, 1, 0.26, 0.5, 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_98815:If_L13_C4", "label": "if", "type": "if", "loc": [13, 14], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98815:FunctionDef_L5_C0", "vector": [4, 1, 0.225, 0.0333, 1, 0.26, 0.6667, 0, 0, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if not app_models:\n return"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98815:Return_L14_C8", "label": "return", "type": "return", "loc": [14, 14], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98815:If_L13_C4", "vector": [13, 2, 0.2333, 0.0167, 2, 0.98, 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_98815:For_L15_C4", "label": "for klass", "type": "for", "loc": [15, 26], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98815:FunctionDef_L5_C0", "vector": [6, 1, 0.3417, 0.2, 1, 0.26, 0.8333, 35, 2, 0, 0, 0, 0, 0, 8], "semantic": {"name": "klass", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for klass in app_models:\n opts = klass._meta\n try:\n ct = ContentType.objects.get(app_label=opts.app_label,\n model=opts.object_name.lower())\n content_types.remove(ct)\n except ContentType.DoesNotExist:\n ct = ContentType(name=smart_unicode(opts.verbose_name_raw),"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98815:Assign_L16_C8", "label": "opts =", "type": "assigned_variable", "loc": [16, 16], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98815:For_L15_C4", "vector": [14, 2, 0.2667, 0.0167, 2, 0.7, 0.0, 631, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "opts", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " opts = klass._meta"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98815:Try_L17_C8", "label": "try", "type": "try", "loc": [17, 26], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98815:For_L15_C4", "vector": [7, 2, 0.3583, 0.1667, 2, 0.7, 1.0, 0, 0, 1, 0, 0, 0, 0, 8], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " try:\n ct = ContentType.objects.get(app_label=opts.app_label,\n model=opts.object_name.lower())\n content_types.remove(ct)\n except ContentType.DoesNotExist:\n ct = ContentType(name=smart_unicode(opts.verbose_name_raw),\n app_label=opts.app_label, model=opts.object_name.lower())\n ct.save()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98815:Assign_L18_C12", "label": "ct = get()", "type": "assigned_variable", "loc": [18, 19], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98815:Try_L17_C8", "vector": [14, 3, 0.3083, 0.0333, 3, 0.67, 0.0, 147, 3, 2, 0, 0, 607, 10, 2], "semantic": {"name": "ct", "arg_names": [], "import_names": [], "rhs_call_name": "get", "annotation": ""}, "snippet": " ct = ContentType.objects.get(app_label=opts.app_label,\n model=opts.object_name.lower())"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98815:Expr_L20_C12", "label": "remove()", "type": "expression", "loc": [20, 20], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98815:Try_L17_C8", "vector": [8, 3, 0.3333, 0.0167, 3, 0.67, 1.0, 185, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "remove", "arg_names": [], "import_names": [], "rhs_call_name": "remove", "annotation": ""}, "snippet": " content_types.remove(ct)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98815:Assign_L22_C12", "label": "ct = ContentType()", "type": "assigned_variable", "loc": [22, 23], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98815:Try_L17_C8", "vector": [14, 3, 0.375, 0.0333, 3, 0.67, 0.0, 147, 3, 3, 0, 0, 313, 10, 3], "semantic": {"name": "ct", "arg_names": [], "import_names": [], "rhs_call_name": "ContentType", "annotation": ""}, "snippet": " ct = ContentType(name=smart_unicode(opts.verbose_name_raw),\n app_label=opts.app_label, model=opts.object_name.lower())"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98815:Expr_L24_C12", "label": "save()", "type": "expression", "loc": [24, 24], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98815:Try_L17_C8", "vector": [8, 3, 0.4, 0.0167, 3, 0.67, 0.5, 928, 3, 0, 0, 0, 0, 0, 1], "semantic": {"name": "save", "arg_names": [], "import_names": [], "rhs_call_name": "save", "annotation": ""}, "snippet": " ct.save()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98815:If_L25_C12", "label": "if", "type": "if", "loc": [25, 26], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98815:Try_L17_C8", "vector": [4, 3, 0.425, 0.0333, 3, 0.67, 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 content type '%s | %s'\" % (ct.app_label, ct.model))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98815:Expr_L26_C16", "label": "print()", "type": "expression", "loc": [26, 26], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98815:If_L25_C12", "vector": [8, 4, 0.4333, 0.0167, 4, 0.7, 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 content type '%s | %s'\" % (ct.app_label, ct.model))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98815:If_L29_C4", "label": "if", "type": "if", "loc": [29, 51], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98815:FunctionDef_L5_C0", "vector": [4, 1, 0.6667, 0.3833, 1, 0.26, 1.0, 0, 2, 0, 0, 0, 0, 0, 6], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if content_types:\n if kwargs.get('interactive', False):\n content_type_display = '\\n'.join([' %s | %s' % (ct.app_label, ct.model) for ct in content_types])\n ok_to_delete = raw_input(\"\"\"The following content types are stale and need to be deleted:\n\n%s\n\nAny objects related to these content types by a foreign key will also"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98815:If_L30_C8", "label": "if", "type": "if", "loc": [30, 42], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98815:If_L29_C4", "vector": [4, 2, 0.6, 0.2167, 2, 0.03, 0.0, 0, 3, 0, 0, 0, 0, 0, 3], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if kwargs.get('interactive', False):\n content_type_display = '\\n'.join([' %s | %s' % (ct.app_label, ct.model) for ct in content_types])\n ok_to_delete = raw_input(\"\"\"The following content types are stale and need to be deleted:\n\n%s\n\nAny objects related to these content types by a foreign key will also\nbe deleted. Are you sure you want to delete these content types?"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98815:Assign_L31_C12", "label": "content_type_display = join()", "type": "assigned_variable", "loc": [31, 31], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98815:If_L30_C8", "vector": [14, 3, 0.5167, 0.0167, 3, 0.47, 0.0, 185, 3, 1, 0, 0, 933, 10, 1], "semantic": {"name": "content_type_display", "arg_names": [], "import_names": [], "rhs_call_name": "join", "annotation": ""}, "snippet": " content_type_display = '\\n'.join([' %s | %s' % (ct.app_label, ct.model) for ct in content_types])"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98815:Assign_L32_C12", "label": "ok_to_delete = raw_input()", "type": "assigned_variable", "loc": [32, 40], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98815:If_L30_C8", "vector": [14, 3, 0.6, 0.15, 3, 0.47, 0.5, 958, 3, 1, 0, 0, 821, 10, 1], "semantic": {"name": "ok_to_delete", "arg_names": [], "import_names": [], "rhs_call_name": "raw_input", "annotation": ""}, "snippet": " ok_to_delete = raw_input(\"\"\"The following content types are stale and need to be deleted:\n\n%s\n\nAny objects related to these content types by a foreign key will also\nbe deleted. Are you sure you want to delete these content types?\nIf you're unsure, answer 'no'.\n"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98815:Assign_L42_C12", "label": "ok_to_delete =", "type": "assigned_variable", "loc": [42, 42], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98815:If_L30_C8", "vector": [14, 3, 0.7, 0.0167, 3, 0.47, 1.0, 958, 1, 0, 0, 0, 0, 4, 0], "semantic": {"name": "ok_to_delete", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " ok_to_delete = False"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98815:If_L44_C8", "label": "if", "type": "if", "loc": [44, 51], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98815:If_L29_C4", "vector": [4, 2, 0.7917, 0.1333, 2, 0.03, 1.0, 0, 0, 0, 0, 0, 0, 0, 3], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if ok_to_delete == 'yes':\n for ct in content_types:\n if verbosity >= 2:\n print(\"Deleting stale content type '%s | %s'\" % (ct.app_label, ct.model))\n ct.delete()\n else:\n if verbosity >= 2:\n print(\"Stale content types remain.\")"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98815:For_L45_C12", "label": "for ct", "type": "for", "loc": [45, 48], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98815:If_L44_C8", "vector": [6, 3, 0.775, 0.0667, 3, 0.19, 0.0, 147, 2, 0, 0, 0, 0, 0, 2], "semantic": {"name": "ct", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for ct in content_types:\n if verbosity >= 2:\n print(\"Deleting stale content type '%s | %s'\" % (ct.app_label, ct.model))\n ct.delete()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98815:If_L46_C16", "label": "if", "type": "if", "loc": [46, 47], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98815:For_L45_C12", "vector": [4, 4, 0.775, 0.0333, 4, 0.82, 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(\"Deleting stale content type '%s | %s'\" % (ct.app_label, ct.model))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98815:Expr_L47_C20", "label": "print()", "type": "expression", "loc": [47, 47], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98815:If_L46_C16", "vector": [8, 5, 0.7833, 0.0167, 5, 0.66, 0.0, 535, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "print", "arg_names": [], "import_names": [], "rhs_call_name": "print", "annotation": ""}, "snippet": " print(\"Deleting stale content type '%s | %s'\" % (ct.app_label, ct.model))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98815:Expr_L48_C16", "label": "delete()", "type": "expression", "loc": [48, 48], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98815:For_L45_C12", "vector": [8, 4, 0.8, 0.0167, 4, 0.82, 1.0, 266, 3, 0, 0, 0, 0, 0, 1], "semantic": {"name": "delete", "arg_names": [], "import_names": [], "rhs_call_name": "delete", "annotation": ""}, "snippet": " ct.delete()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98815:If_L50_C12", "label": "if", "type": "if", "loc": [50, 51], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98815:If_L44_C8", "vector": [4, 3, 0.8417, 0.0333, 3, 0.19, 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(\"Stale content types remain.\")"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98815:Expr_L51_C16", "label": "print()", "type": "expression", "loc": [51, 51], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98815:If_L50_C12", "vector": [8, 4, 0.85, 0.0167, 4, 0.23, 0.0, 535, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "print", "arg_names": [], "import_names": [], "rhs_call_name": "print", "annotation": ""}, "snippet": " print(\"Stale content types remain.\")"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98815:FunctionDef_L53_C0", "label": "update_all_contenttypes", "type": "function", "loc": [53, 55], "level": 0, "parent": null, "vector": [2, 0, 0.9, 0.05, 0, 0.66, 0.6667, 68, 0, 2, 0, 0, 0, 0, 2], "semantic": {"name": "update_all_contenttypes", "arg_names": ["verbosity", "kwargs"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "def update_all_contenttypes(verbosity=2, **kwargs):\n for app in get_apps():\n update_contenttypes(app, None, verbosity, **kwargs)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98815:For_L54_C4", "label": "for app", "type": "for", "loc": [54, 55], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98815:FunctionDef_L53_C0", "vector": [6, 1, 0.9083, 0.0333, 1, 0.57, 0.0, 494, 3, 0, 0, 0, 0, 0, 2], "semantic": {"name": "app", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for app in get_apps():\n update_contenttypes(app, None, verbosity, **kwargs)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98815:Expr_L55_C8", "label": "update_contenttypes()", "type": "expression", "loc": [55, 55], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98815:For_L54_C4", "vector": [8, 2, 0.9167, 0.0167, 2, 0.85, 0.0, 391, 3, 4, 0, 0, 0, 0, 1], "semantic": {"name": "update_contenttypes", "arg_names": [], "import_names": [], "rhs_call_name": "update_contenttypes", "annotation": ""}, "snippet": " update_contenttypes(app, None, verbosity, **kwargs)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98815:Expr_L57_C0", "label": "connect()", "type": "expression", "loc": [57, 57], "level": 0, "parent": null, "vector": [8, 0, 0.95, 0.0167, 0, 0.66, 0.8333, 242, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "connect", "arg_names": [], "import_names": [], "rhs_call_name": "connect", "annotation": ""}, "snippet": "signals.post_syncdb.connect(update_contenttypes)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98815:If_L59_C0", "label": "if", "type": "if", "loc": [59, 60], "level": 0, "parent": null, "vector": [4, 0, 0.9917, 0.0333, 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 update_all_contenttypes()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98815:Expr_L60_C4", "label": "update_all_contenttypes()", "type": "expression", "loc": [60, 60], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98815:If_L59_C0", "vector": [8, 1, 1.0, 0.0167, 1, 0.78, 0.0, 68, 3, 0, 0, 0, 0, 0, 1], "semantic": {"name": "update_all_contenttypes", "arg_names": [], "import_names": [], "rhs_call_name": "update_all_contenttypes", "annotation": ""}, "snippet": " update_all_contenttypes()"}]
[{"f": "ajibawa-2023/Python-Code-Large/train/row_98815:FunctionDef_L5_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98815:Expr_L6_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98815:FunctionDef_L5_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98815:Expr_L10_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98815:FunctionDef_L5_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98815:Assign_L11_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98815:FunctionDef_L5_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98815:Assign_L12_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98815:FunctionDef_L5_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98815:If_L13_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98815:If_L13_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98815:Return_L14_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98815:FunctionDef_L5_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98815:For_L15_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98815:For_L15_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98815:Assign_L16_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98815:For_L15_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98815:Try_L17_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98815:Try_L17_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98815:Assign_L18_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98815:Try_L17_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98815:Expr_L20_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98815:Try_L17_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98815:Assign_L22_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98815:Try_L17_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98815:Expr_L24_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98815:Try_L17_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98815:If_L25_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98815:If_L25_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98815:Expr_L26_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98815:FunctionDef_L5_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98815:If_L29_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98815:If_L29_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98815:If_L30_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98815:If_L30_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98815:Assign_L31_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98815:If_L30_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98815:Assign_L32_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98815:If_L30_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98815:Assign_L42_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98815:If_L29_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98815:If_L44_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98815:If_L44_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98815:For_L45_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98815:For_L45_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98815:If_L46_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98815:If_L46_C16", "t": "ajibawa-2023/Python-Code-Large/train/row_98815:Expr_L47_C20"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98815:For_L45_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98815:Expr_L48_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98815:If_L44_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98815:If_L50_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98815:If_L50_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98815:Expr_L51_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98815:FunctionDef_L53_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98815:For_L54_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98815:For_L54_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98815:Expr_L55_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98815:If_L59_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98815:Expr_L60_C4"}]
""" models.py (even empty) currently required by the runtests.py to enable unit tests """
ajibawa-2023/Python-Code-Large/train/row_98816
1
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"]
[{"id": "ajibawa-2023/Python-Code-Large/train/row_98816:Expr_L1_C0", "label": "expression", "type": "expression", "loc": [1, 1], "level": 0, "parent": null, "vector": [8, 0, 1.0, 1.0, 0, 0.66, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "\"\"\" models.py (even empty) currently required by the runtests.py to enable unit tests \"\"\""}]
[]
""" This is a URLconf to be loaded by tests.py. Add any URLs needed for tests only. """ from django.conf.urls.defaults import * from django.contrib.formtools.tests import * urlpatterns = patterns('', (r'^test1/', TestFormPreview(TestForm)), (r'^test2/', UserSecuredFormPreview(TestForm)), (r'^wizard/$', WizardClass([WizardPageOneForm, WizardPageTwoForm, WizardPageThreeForm])), (r'^wizard2/$', UserSecuredWizardClass([WizardPageOneForm, WizardPageTwoForm, WizardPageThreeForm])) )
ajibawa-2023/Python-Code-Large/train/row_98817
4
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_98817: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": "\"\"\"\nThis is a URLconf to be loaded by tests.py. Add any URLs needed for tests only.\n\"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98817: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.3333, 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_98817:ImportFrom_L6_C0", "label": "from django.contrib.formtools.tests import *", "type": "import", "loc": [6, 6], "level": 0, "parent": null, "vector": [1, 0, 0.3529, 0.0588, 0, 0.66, 0.6667, 50, 0, 1, 0, 0, 50, 0, 0], "semantic": {"name": "django.contrib.formtools.tests", "arg_names": [], "import_names": ["*"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.contrib.formtools.tests import *"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98817:Assign_L8_C0", "label": "urlpatterns = patterns()", "type": "assigned_variable", "loc": [8, 17], "level": 0, "parent": null, "vector": [14, 0, 0.7353, 0.5882, 0, 0.66, 1.0, 990, 3, 5, 0, 0, 75, 10, 5], "semantic": {"name": "urlpatterns", "arg_names": [], "import_names": [], "rhs_call_name": "patterns", "annotation": ""}, "snippet": "urlpatterns = patterns('',\n (r'^test1/', TestFormPreview(TestForm)),\n (r'^test2/', UserSecuredFormPreview(TestForm)),\n (r'^wizard/$', WizardClass([WizardPageOneForm,\n WizardPageTwoForm,\n WizardPageThreeForm])),\n (r'^wizard2/$', UserSecuredWizardClass([WizardPageOneForm,\n WizardPageTwoForm,"}]
[]
import os from django import forms from django import http from django.conf import settings from django.contrib.formtools import preview, wizard, utils from django.test import TestCase from django.utils import unittest success_string = "Done was called!" class TestFormPreview(preview.FormPreview): def done(self, request, cleaned_data): return http.HttpResponse(success_string) class TestForm(forms.Form): field1 = forms.CharField() field1_ = forms.CharField() bool1 = forms.BooleanField(required=False) class UserSecuredFormPreview(TestFormPreview): """ FormPreview with a custum security_hash method """ def security_hash(self, request, form): return "123" class PreviewTests(TestCase): urls = 'django.contrib.formtools.tests.urls' def setUp(self): # Create a FormPreview instance to share between tests self.preview = preview.FormPreview(TestForm) input_template = '<input type="hidden" name="%s" value="%s" />' self.input = input_template % (self.preview.unused_name('stage'), "%d") self.test_data = {'field1':u'foo', 'field1_':u'asdf'} def test_unused_name(self): """ Verifies name mangling to get uniue field name. """ self.assertEqual(self.preview.unused_name('field1'), 'field1__') def test_form_get(self): """ Test contrib.formtools.preview form retrieval. Use the client library to see if we can sucessfully retrieve the form (mostly testing the setup ROOT_URLCONF process). Verify that an additional hidden input field is created to manage the stage. """ response = self.client.get('/test1/') stage = self.input % 1 self.assertContains(response, stage, 1) def test_form_preview(self): """ Test contrib.formtools.preview form preview rendering. Use the client library to POST to the form to see if a preview is returned. If we do get a form back check that the hidden value is correctly managing the state of the form. """ # Pass strings for form submittal and add stage variable to # show we previously saw first stage of the form. self.test_data.update({'stage': 1}) response = self.client.post('/test1/', self.test_data) # Check to confirm stage is set to 2 in output form. stage = self.input % 2 self.assertContains(response, stage, 1) def test_form_submit(self): """ Test contrib.formtools.preview form submittal. Use the client library to POST to the form with stage set to 3 to see if our forms done() method is called. Check first without the security hash, verify failure, retry with security hash and verify sucess. """ # Pass strings for form submittal and add stage variable to # show we previously saw first stage of the form. self.test_data.update({'stage':2}) response = self.client.post('/test1/', self.test_data) self.failIfEqual(response.content, success_string) hash = self.preview.security_hash(None, TestForm(self.test_data)) self.test_data.update({'hash': hash}) response = self.client.post('/test1/', self.test_data) self.assertEqual(response.content, success_string) def test_bool_submit(self): """ Test contrib.formtools.preview form submittal when form contains: BooleanField(required=False) Ticket: #6209 - When an unchecked BooleanField is previewed, the preview form's hash would be computed with no value for ``bool1``. However, when the preview form is rendered, the unchecked hidden BooleanField would be rendered with the string value 'False'. So when the preview form is resubmitted, the hash would be computed with the value 'False' for ``bool1``. We need to make sure the hashes are the same in both cases. """ self.test_data.update({'stage':2}) hash = self.preview.security_hash(None, TestForm(self.test_data)) self.test_data.update({'hash':hash, 'bool1':u'False'}) response = self.client.post('/test1/', self.test_data) self.assertEqual(response.content, success_string) def test_form_submit_django12_hash(self): """ Test contrib.formtools.preview form submittal, using the hash function used in Django 1.2 """ # Pass strings for form submittal and add stage variable to # show we previously saw first stage of the form. self.test_data.update({'stage':2}) response = self.client.post('/test1/', self.test_data) self.failIfEqual(response.content, success_string) hash = utils.security_hash(None, TestForm(self.test_data)) self.test_data.update({'hash': hash}) response = self.client.post('/test1/', self.test_data) self.assertEqual(response.content, success_string) def test_form_submit_django12_hash_custom_hash(self): """ Test contrib.formtools.preview form submittal, using the hash function used in Django 1.2 and a custom security_hash method. """ # Pass strings for form submittal and add stage variable to # show we previously saw first stage of the form. self.test_data.update({'stage':2}) response = self.client.post('/test2/', self.test_data) self.assertEqual(response.status_code, 200) self.failIfEqual(response.content, success_string) hash = utils.security_hash(None, TestForm(self.test_data)) self.test_data.update({'hash': hash}) response = self.client.post('/test2/', self.test_data) self.failIfEqual(response.content, success_string) class SecurityHashTests(unittest.TestCase): def test_textfield_hash(self): """ Regression test for #10034: the hash generation function should ignore leading/trailing whitespace so as to be friendly to broken browsers that submit it (usually in textareas). """ f1 = HashTestForm({'name': 'joe', 'bio': 'Nothing notable.'}) f2 = HashTestForm({'name': ' joe', 'bio': 'Nothing notable. '}) hash1 = utils.security_hash(None, f1) hash2 = utils.security_hash(None, f2) self.assertEqual(hash1, hash2) def test_empty_permitted(self): """ Regression test for #10643: the security hash should allow forms with empty_permitted = True, or forms where data has not changed. """ f1 = HashTestBlankForm({}) f2 = HashTestForm({}, empty_permitted=True) hash1 = utils.security_hash(None, f1) hash2 = utils.security_hash(None, f2) self.assertEqual(hash1, hash2) class FormHmacTests(unittest.TestCase): """ Same as SecurityHashTests, but with form_hmac """ def test_textfield_hash(self): """ Regression test for #10034: the hash generation function should ignore leading/trailing whitespace so as to be friendly to broken browsers that submit it (usually in textareas). """ f1 = HashTestForm({'name': 'joe', 'bio': 'Nothing notable.'}) f2 = HashTestForm({'name': ' joe', 'bio': 'Nothing notable. '}) hash1 = utils.form_hmac(f1) hash2 = utils.form_hmac(f2) self.assertEqual(hash1, hash2) def test_empty_permitted(self): """ Regression test for #10643: the security hash should allow forms with empty_permitted = True, or forms where data has not changed. """ f1 = HashTestBlankForm({}) f2 = HashTestForm({}, empty_permitted=True) hash1 = utils.form_hmac(f1) hash2 = utils.form_hmac(f2) self.assertEqual(hash1, hash2) class HashTestForm(forms.Form): name = forms.CharField() bio = forms.CharField() class HashTestBlankForm(forms.Form): name = forms.CharField(required=False) bio = forms.CharField(required=False) # # FormWizard tests # class WizardPageOneForm(forms.Form): field = forms.CharField() class WizardPageTwoForm(forms.Form): field = forms.CharField() class WizardPageThreeForm(forms.Form): field = forms.CharField() class WizardClass(wizard.FormWizard): def get_template(self, step): return 'formwizard/wizard.html' def done(self, request, cleaned_data): return http.HttpResponse(success_string) class UserSecuredWizardClass(WizardClass): """ Wizard with a custum security_hash method """ def security_hash(self, request, form): return "123" class DummyRequest(http.HttpRequest): def __init__(self, POST=None): super(DummyRequest, self).__init__() self.method = POST and "POST" or "GET" if POST is not None: self.POST.update(POST) self._dont_enforce_csrf_checks = True class WizardTests(TestCase): urls = 'django.contrib.formtools.tests.urls' def setUp(self): self.old_TEMPLATE_DIRS = settings.TEMPLATE_DIRS settings.TEMPLATE_DIRS = ( os.path.join( os.path.dirname(__file__), 'templates' ), ) # Use a known SECRET_KEY to make security_hash tests deterministic self.old_SECRET_KEY = settings.SECRET_KEY settings.SECRET_KEY = "123" def tearDown(self): settings.TEMPLATE_DIRS = self.old_TEMPLATE_DIRS settings.SECRET_KEY = self.old_SECRET_KEY def test_step_starts_at_zero(self): """ step should be zero for the first form """ response = self.client.get('/wizard/') self.assertEquals(0, response.context['step0']) def test_step_increments(self): """ step should be incremented when we go to the next page """ response = self.client.post('/wizard/', {"0-field":"test", "wizard_step":"0"}) self.assertEquals(1, response.context['step0']) def test_bad_hash(self): """ Form should not advance if the hash is missing or bad """ response = self.client.post('/wizard/', {"0-field":"test", "1-field":"test2", "wizard_step": "1"}) self.assertEquals(0, response.context['step0']) def test_good_hash_django12(self): """ Form should advance if the hash is present and good, as calculated using django 1.2 method. """ # We are hard-coding a hash value here, but that is OK, since we want to # ensure that we don't accidentally change the algorithm. data = {"0-field": "test", "1-field": "test2", "hash_0": "2fdbefd4c0cad51509478fbacddf8b13", "wizard_step": "1"} response = self.client.post('/wizard/', data) self.assertEquals(2, response.context['step0']) def test_good_hash_django12_subclass(self): """ The Django 1.2 method of calulating hashes should *not* be used as a fallback if the FormWizard subclass has provided their own method of calculating a hash. """ # We are hard-coding a hash value here, but that is OK, since we want to # ensure that we don't accidentally change the algorithm. data = {"0-field": "test", "1-field": "test2", "hash_0": "2fdbefd4c0cad51509478fbacddf8b13", "wizard_step": "1"} response = self.client.post('/wizard2/', data) self.assertEquals(0, response.context['step0']) def test_good_hash_current(self): """ Form should advance if the hash is present and good, as calculated using current method. """ data = {"0-field": "test", "1-field": "test2", "hash_0": "7e9cea465f6a10a6fb47fcea65cb9a76350c9a5c", "wizard_step": "1"} response = self.client.post('/wizard/', data) self.assertEquals(2, response.context['step0']) def test_14498(self): """ Regression test for ticket #14498. """ that = self class WizardWithProcessStep(WizardClass): def process_step(self, request, form, step): that.assertTrue(hasattr(form, 'cleaned_data')) wizard = WizardWithProcessStep([WizardPageOneForm, WizardPageTwoForm, WizardPageThreeForm]) data = {"0-field": "test", "1-field": "test2", "hash_0": "7e9cea465f6a10a6fb47fcea65cb9a76350c9a5c", "wizard_step": "1"} wizard(DummyRequest(POST=data))
ajibawa-2023/Python-Code-Large/train/row_98818
180
362
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_98818:Import_L1_C0", "label": "os import os", "type": "import", "loc": [1, 1], "level": 0, "parent": null, "vector": [1, 0, 0.0028, 0.0028, 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_98818:ImportFrom_L3_C0", "label": "from django import forms", "type": "import", "loc": [3, 3], "level": 0, "parent": null, "vector": [1, 0, 0.0083, 0.0028, 0, 0.66, 0.0455, 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_98818:ImportFrom_L4_C0", "label": "from django import http", "type": "import", "loc": [4, 4], "level": 0, "parent": null, "vector": [1, 0, 0.011, 0.0028, 0, 0.66, 0.0909, 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_98818:ImportFrom_L5_C0", "label": "from django.conf import settings", "type": "import", "loc": [5, 5], "level": 0, "parent": null, "vector": [1, 0, 0.0138, 0.0028, 0, 0.66, 0.1364, 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_98818:ImportFrom_L6_C0", "label": "from django.contrib.formtools import preview, wizard, utils", "type": "import", "loc": [6, 6], "level": 0, "parent": null, "vector": [1, 0, 0.0166, 0.0028, 0, 0.66, 0.1818, 8, 0, 3, 0, 0, 8, 0, 0], "semantic": {"name": "django.contrib.formtools", "arg_names": [], "import_names": ["preview", "wizard", "utils"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.contrib.formtools import preview, wizard, utils"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98818:ImportFrom_L7_C0", "label": "from django.test import TestCase", "type": "import", "loc": [7, 7], "level": 0, "parent": null, "vector": [1, 0, 0.0193, 0.0028, 0, 0.66, 0.2273, 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_98818:ImportFrom_L8_C0", "label": "from django.utils import unittest", "type": "import", "loc": [8, 8], "level": 0, "parent": null, "vector": [1, 0, 0.0221, 0.0028, 0, 0.66, 0.2727, 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_98818:Assign_L10_C0", "label": "success_string =", "type": "assigned_variable", "loc": [10, 10], "level": 0, "parent": null, "vector": [14, 0, 0.0276, 0.0028, 0, 0.66, 0.3182, 548, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "success_string", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "success_string = \"Done was called!\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98818:ClassDef_L13_C0", "label": "TestFormPreview", "type": "class", "loc": [13, 16], "level": 0, "parent": null, "vector": [3, 0, 0.0401, 0.011, 0, 0.66, 0.3636, 609, 0, 1, 0, 0, 451, 0, 1], "semantic": {"name": "TestFormPreview", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class TestFormPreview(preview.FormPreview):\n\n def done(self, request, cleaned_data):\n return http.HttpResponse(success_string)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98818:FunctionDef_L15_C4", "label": "done", "type": "function", "loc": [15, 16], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98818:ClassDef_L13_C0", "vector": [2, 1, 0.0428, 0.0055, 1, 0.72, 0.0, 151, 0, 3, 1, 0, 0, 0, 1], "semantic": {"name": "done", "arg_names": ["self", "request", "cleaned_data"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def done(self, request, cleaned_data):\n return http.HttpResponse(success_string)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98818:Return_L16_C8", "label": "return", "type": "return", "loc": [16, 16], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98818:FunctionDef_L15_C4", "vector": [13, 2, 0.0442, 0.0028, 2, 0.09, 0.0, 0, 3, 0, 0, 0, 0, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return http.HttpResponse(success_string)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98818:ClassDef_L19_C0", "label": "TestForm", "type": "class", "loc": [19, 22], "level": 0, "parent": null, "vector": [3, 0, 0.0566, 0.011, 0, 0.66, 0.4091, 153, 0, 0, 0, 0, 953, 0, 3], "semantic": {"name": "TestForm", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class TestForm(forms.Form):\n field1 = forms.CharField()\n field1_ = forms.CharField()\n bool1 = forms.BooleanField(required=False)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98818:Assign_L20_C4", "label": "field1 = CharField()", "type": "assigned_variable", "loc": [20, 20], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98818:ClassDef_L19_C0", "vector": [14, 1, 0.0552, 0.0028, 1, 0.46, 0.0, 424, 3, 0, 0, 0, 952, 10, 1], "semantic": {"name": "field1", "arg_names": [], "import_names": [], "rhs_call_name": "CharField", "annotation": ""}, "snippet": " field1 = forms.CharField()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98818:Assign_L21_C4", "label": "field1_ = CharField()", "type": "assigned_variable", "loc": [21, 21], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98818:ClassDef_L19_C0", "vector": [14, 1, 0.058, 0.0028, 1, 0.46, 0.5, 891, 3, 0, 0, 0, 952, 10, 1], "semantic": {"name": "field1_", "arg_names": [], "import_names": [], "rhs_call_name": "CharField", "annotation": ""}, "snippet": " field1_ = forms.CharField()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98818:Assign_L22_C4", "label": "bool1 = BooleanField()", "type": "assigned_variable", "loc": [22, 22], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98818:ClassDef_L19_C0", "vector": [14, 1, 0.0608, 0.0028, 1, 0.46, 1.0, 913, 3, 1, 0, 0, 498, 10, 1], "semantic": {"name": "bool1", "arg_names": [], "import_names": [], "rhs_call_name": "BooleanField", "annotation": ""}, "snippet": " bool1 = forms.BooleanField(required=False)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98818:ClassDef_L25_C0", "label": "UserSecuredFormPreview", "type": "class", "loc": [25, 30], "level": 0, "parent": null, "vector": [3, 0, 0.076, 0.0166, 0, 0.66, 0.4545, 346, 0, 1, 0, 0, 609, 0, 0], "semantic": {"name": "UserSecuredFormPreview", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class UserSecuredFormPreview(TestFormPreview):\n \"\"\"\n FormPreview with a custum security_hash method\n \"\"\"\n def security_hash(self, request, form):\n return \"123\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98818:Expr_L26_C4", "label": "expression", "type": "expression", "loc": [26, 28], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98818:ClassDef_L25_C0", "vector": [8, 1, 0.0746, 0.0083, 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 FormPreview with a custum security_hash method\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98818:FunctionDef_L29_C4", "label": "security_hash", "type": "function", "loc": [29, 30], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98818:ClassDef_L25_C0", "vector": [2, 1, 0.0815, 0.0055, 1, 0.99, 1.0, 234, 0, 3, 1, 0, 0, 0, 0], "semantic": {"name": "security_hash", "arg_names": ["self", "request", "form"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def security_hash(self, request, form):\n return \"123\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98818:Return_L30_C8", "label": "return", "type": "return", "loc": [30, 30], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98818:FunctionDef_L29_C4", "vector": [13, 2, 0.0829, 0.0028, 2, 0.38, 0.0, 0, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return \"123\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98818:ClassDef_L33_C0", "label": "PreviewTests", "type": "class", "loc": [33, 149], "level": 0, "parent": null, "vector": [3, 0, 0.2514, 0.3232, 0, 0.66, 0.5, 200, 0, 8, 0, 0, 3, 0, 40], "semantic": {"name": "PreviewTests", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class PreviewTests(TestCase):\n urls = 'django.contrib.formtools.tests.urls'\n\n def setUp(self):\n # Create a FormPreview instance to share between tests\n self.preview = preview.FormPreview(TestForm)\n input_template = '<input type=\"hidden\" name=\"%s\" value=\"%s\" />'\n self.input = input_template % (self.preview.unused_name('stage'), \"%d\")"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98818:Assign_L34_C4", "label": "urls =", "type": "assigned_variable", "loc": [34, 34], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98818:ClassDef_L33_C0", "vector": [14, 1, 0.0939, 0.0028, 1, 0.42, 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.formtools.tests.urls'"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98818:FunctionDef_L36_C4", "label": "setUp", "type": "function", "loc": [36, 41], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98818:ClassDef_L33_C0", "vector": [2, 1, 0.1064, 0.0166, 1, 0.42, 0.125, 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 # Create a FormPreview instance to share between tests\n self.preview = preview.FormPreview(TestForm)\n input_template = '<input type=\"hidden\" name=\"%s\" value=\"%s\" />'\n self.input = input_template % (self.preview.unused_name('stage'), \"%d\")\n self.test_data = {'field1':u'foo', 'field1_':u'asdf'}"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98818:Assign_L38_C8", "label": "self.preview = FormPreview()", "type": "assigned_variable", "loc": [38, 38], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98818:FunctionDef_L36_C4", "vector": [14, 2, 0.105, 0.0028, 2, 0.71, 0.0, 42, 3, 1, 0, 0, 804, 10, 1], "semantic": {"name": "self.preview", "arg_names": [], "import_names": [], "rhs_call_name": "FormPreview", "annotation": ""}, "snippet": " self.preview = preview.FormPreview(TestForm)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98818:Assign_L39_C8", "label": "input_template =", "type": "assigned_variable", "loc": [39, 39], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98818:FunctionDef_L36_C4", "vector": [14, 2, 0.1077, 0.0028, 2, 0.71, 0.3333, 500, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "input_template", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " input_template = '<input type=\"hidden\" name=\"%s\" value=\"%s\" />'"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98818:Assign_L40_C8", "label": "self.input =", "type": "assigned_variable", "loc": [40, 40], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98818:FunctionDef_L36_C4", "vector": [14, 2, 0.1105, 0.0028, 2, 0.71, 0.6667, 805, 4, 0, 0, 0, 0, 0, 1], "semantic": {"name": "self.input", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.input = input_template % (self.preview.unused_name('stage'), \"%d\")"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98818:Assign_L41_C8", "label": "self.test_data =", "type": "assigned_variable", "loc": [41, 41], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98818:FunctionDef_L36_C4", "vector": [14, 2, 0.1133, 0.0028, 2, 0.71, 1.0, 178, 0, 0, 0, 0, 0, 6, 0], "semantic": {"name": "self.test_data", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.test_data = {'field1':u'foo', 'field1_':u'asdf'}"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98818:FunctionDef_L43_C4", "label": "test_unused_name", "type": "function", "loc": [43, 47], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98818:ClassDef_L33_C0", "vector": [2, 1, 0.1243, 0.0138, 1, 0.42, 0.25, 716, 0, 1, 0, 0, 0, 0, 2], "semantic": {"name": "test_unused_name", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def test_unused_name(self):\n \"\"\"\n Verifies name mangling to get uniue field name.\n \"\"\"\n self.assertEqual(self.preview.unused_name('field1'), 'field1__')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98818:Expr_L44_C8", "label": "expression", "type": "expression", "loc": [44, 46], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98818:FunctionDef_L43_C4", "vector": [8, 2, 0.1243, 0.0083, 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 Verifies name mangling to get uniue field name.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98818:Expr_L47_C8", "label": "assertEqual()", "type": "expression", "loc": [47, 47], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98818:FunctionDef_L43_C4", "vector": [8, 2, 0.1298, 0.0028, 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(self.preview.unused_name('field1'), 'field1__')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98818:FunctionDef_L49_C4", "label": "test_form_get", "type": "function", "loc": [49, 61], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98818:ClassDef_L33_C0", "vector": [2, 1, 0.1519, 0.0359, 1, 0.42, 0.375, 743, 0, 1, 0, 0, 0, 0, 2], "semantic": {"name": "test_form_get", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def test_form_get(self):\n \"\"\"\n Test contrib.formtools.preview form retrieval.\n\n Use the client library to see if we can sucessfully retrieve\n the form (mostly testing the setup ROOT_URLCONF\n process). Verify that an additional hidden input field\n is created to manage the stage."}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98818:Expr_L50_C8", "label": "expression", "type": "expression", "loc": [50, 58], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98818:FunctionDef_L49_C4", "vector": [8, 2, 0.1492, 0.0249, 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 Test contrib.formtools.preview form retrieval.\n\n Use the client library to see if we can sucessfully retrieve\n the form (mostly testing the setup ROOT_URLCONF\n process). Verify that an additional hidden input field\n is created to manage the stage.\n"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98818:Assign_L59_C8", "label": "response = get()", "type": "assigned_variable", "loc": [59, 59], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98818:FunctionDef_L49_C4", "vector": [14, 2, 0.163, 0.0028, 2, 0.88, 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('/test1/')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98818:Assign_L60_C8", "label": "stage =", "type": "assigned_variable", "loc": [60, 60], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98818:FunctionDef_L49_C4", "vector": [14, 2, 0.1657, 0.0028, 2, 0.88, 0.6667, 612, 4, 0, 0, 0, 0, 0, 0], "semantic": {"name": "stage", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " stage = self.input % 1"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98818:Expr_L61_C8", "label": "assertContains()", "type": "expression", "loc": [61, 61], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98818:FunctionDef_L49_C4", "vector": [8, 2, 0.1685, 0.0028, 2, 0.88, 1.0, 335, 3, 3, 0, 0, 0, 0, 1], "semantic": {"name": "assertContains", "arg_names": [], "import_names": [], "rhs_call_name": "assertContains", "annotation": ""}, "snippet": " self.assertContains(response, stage, 1)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98818:FunctionDef_L63_C4", "label": "test_form_preview", "type": "function", "loc": [63, 78], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98818:ClassDef_L33_C0", "vector": [2, 1, 0.1948, 0.0442, 1, 0.42, 0.5, 85, 0, 1, 0, 0, 0, 0, 3], "semantic": {"name": "test_form_preview", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def test_form_preview(self):\n \"\"\"\n Test contrib.formtools.preview form preview rendering.\n\n Use the client library to POST to the form to see if a preview\n is returned. If we do get a form back check that the hidden\n value is correctly managing the state of the form.\n"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98818:Expr_L64_C8", "label": "expression", "type": "expression", "loc": [64, 71], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98818:FunctionDef_L63_C4", "vector": [8, 2, 0.1865, 0.0221, 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 Test contrib.formtools.preview form preview rendering.\n\n Use the client library to POST to the form to see if a preview\n is returned. If we do get a form back check that the hidden\n value is correctly managing the state of the form.\n\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98818:Expr_L74_C8", "label": "update()", "type": "expression", "loc": [74, 74], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98818:FunctionDef_L63_C4", "vector": [8, 2, 0.2044, 0.0028, 2, 0.44, 0.25, 637, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "update", "arg_names": [], "import_names": [], "rhs_call_name": "update", "annotation": ""}, "snippet": " self.test_data.update({'stage': 1})"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98818:Assign_L75_C8", "label": "response = post()", "type": "assigned_variable", "loc": [75, 75], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98818:FunctionDef_L63_C4", "vector": [14, 2, 0.2072, 0.0028, 2, 0.44, 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('/test1/', self.test_data)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98818:Assign_L77_C8", "label": "stage =", "type": "assigned_variable", "loc": [77, 77], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98818:FunctionDef_L63_C4", "vector": [14, 2, 0.2127, 0.0028, 2, 0.44, 0.75, 612, 4, 0, 0, 0, 0, 0, 0], "semantic": {"name": "stage", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " stage = self.input % 2"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98818:Expr_L78_C8", "label": "assertContains()", "type": "expression", "loc": [78, 78], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98818:FunctionDef_L63_C4", "vector": [8, 2, 0.2155, 0.0028, 2, 0.44, 1.0, 335, 3, 3, 0, 0, 0, 0, 1], "semantic": {"name": "assertContains", "arg_names": [], "import_names": [], "rhs_call_name": "assertContains", "annotation": ""}, "snippet": " self.assertContains(response, stage, 1)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98818:FunctionDef_L80_C4", "label": "test_form_submit", "type": "function", "loc": [80, 98], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98818:ClassDef_L33_C0", "vector": [2, 1, 0.2459, 0.0525, 1, 0.42, 0.625, 730, 0, 1, 0, 0, 0, 0, 8], "semantic": {"name": "test_form_submit", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def test_form_submit(self):\n \"\"\"\n Test contrib.formtools.preview form submittal.\n\n Use the client library to POST to the form with stage set to 3\n to see if our forms done() method is called. Check first\n without the security hash, verify failure, retry with security\n hash and verify sucess."}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98818:Expr_L81_C8", "label": "expression", "type": "expression", "loc": [81, 89], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98818:FunctionDef_L80_C4", "vector": [8, 2, 0.2348, 0.0249, 2, 0.37, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"\n Test contrib.formtools.preview form submittal.\n\n Use the client library to POST to the form with stage set to 3\n to see if our forms done() method is called. Check first\n without the security hash, verify failure, retry with security\n hash and verify sucess.\n"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98818:Expr_L92_C8", "label": "update()", "type": "expression", "loc": [92, 92], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98818:FunctionDef_L80_C4", "vector": [8, 2, 0.2541, 0.0028, 2, 0.37, 0.1429, 637, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "update", "arg_names": [], "import_names": [], "rhs_call_name": "update", "annotation": ""}, "snippet": " self.test_data.update({'stage':2})"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98818:Assign_L93_C8", "label": "response = post()", "type": "assigned_variable", "loc": [93, 93], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98818:FunctionDef_L80_C4", "vector": [14, 2, 0.2569, 0.0028, 2, 0.37, 0.2857, 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('/test1/', self.test_data)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98818:Expr_L94_C8", "label": "failIfEqual()", "type": "expression", "loc": [94, 94], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98818:FunctionDef_L80_C4", "vector": [8, 2, 0.2597, 0.0028, 2, 0.37, 0.4286, 443, 3, 2, 0, 0, 0, 0, 1], "semantic": {"name": "failIfEqual", "arg_names": [], "import_names": [], "rhs_call_name": "failIfEqual", "annotation": ""}, "snippet": " self.failIfEqual(response.content, success_string)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98818:Assign_L95_C8", "label": "hash = security_hash()", "type": "assigned_variable", "loc": [95, 95], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98818:FunctionDef_L80_C4", "vector": [14, 2, 0.2624, 0.0028, 2, 0.37, 0.5714, 58, 3, 2, 0, 0, 234, 10, 2], "semantic": {"name": "hash", "arg_names": [], "import_names": [], "rhs_call_name": "security_hash", "annotation": ""}, "snippet": " hash = self.preview.security_hash(None, TestForm(self.test_data))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98818:Expr_L96_C8", "label": "update()", "type": "expression", "loc": [96, 96], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98818:FunctionDef_L80_C4", "vector": [8, 2, 0.2652, 0.0028, 2, 0.37, 0.7143, 637, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "update", "arg_names": [], "import_names": [], "rhs_call_name": "update", "annotation": ""}, "snippet": " self.test_data.update({'hash': hash})"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98818:Assign_L97_C8", "label": "response = post()", "type": "assigned_variable", "loc": [97, 97], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98818:FunctionDef_L80_C4", "vector": [14, 2, 0.268, 0.0028, 2, 0.37, 0.8571, 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('/test1/', self.test_data)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98818:Expr_L98_C8", "label": "assertEqual()", "type": "expression", "loc": [98, 98], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98818:FunctionDef_L80_C4", "vector": [8, 2, 0.2707, 0.0028, 2, 0.37, 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.content, success_string)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98818:FunctionDef_L100_C4", "label": "test_bool_submit", "type": "function", "loc": [100, 117], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98818:ClassDef_L33_C0", "vector": [2, 1, 0.2997, 0.0497, 1, 0.42, 0.75, 248, 0, 1, 0, 0, 0, 0, 6], "semantic": {"name": "test_bool_submit", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def test_bool_submit(self):\n \"\"\"\n Test contrib.formtools.preview form submittal when form contains:\n BooleanField(required=False)\n\n Ticket: #6209 - When an unchecked BooleanField is previewed, the preview\n form's hash would be computed with no value for ``bool1``. However, when\n the preview form is rendered, the unchecked hidden BooleanField would be"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98818:Expr_L101_C8", "label": "expression", "type": "expression", "loc": [101, 112], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98818:FunctionDef_L100_C4", "vector": [8, 2, 0.2942, 0.0331, 2, 0.98, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"\n Test contrib.formtools.preview form submittal when form contains:\n BooleanField(required=False)\n\n Ticket: #6209 - When an unchecked BooleanField is previewed, the preview\n form's hash would be computed with no value for ``bool1``. However, when\n the preview form is rendered, the unchecked hidden BooleanField would be\n rendered with the string value 'False'. So when the preview form is"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98818:Expr_L113_C8", "label": "update()", "type": "expression", "loc": [113, 113], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98818:FunctionDef_L100_C4", "vector": [8, 2, 0.3122, 0.0028, 2, 0.98, 0.2, 637, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "update", "arg_names": [], "import_names": [], "rhs_call_name": "update", "annotation": ""}, "snippet": " self.test_data.update({'stage':2})"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98818:Assign_L114_C8", "label": "hash = security_hash()", "type": "assigned_variable", "loc": [114, 114], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98818:FunctionDef_L100_C4", "vector": [14, 2, 0.3149, 0.0028, 2, 0.98, 0.4, 58, 3, 2, 0, 0, 234, 10, 2], "semantic": {"name": "hash", "arg_names": [], "import_names": [], "rhs_call_name": "security_hash", "annotation": ""}, "snippet": " hash = self.preview.security_hash(None, TestForm(self.test_data))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98818:Expr_L115_C8", "label": "update()", "type": "expression", "loc": [115, 115], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98818:FunctionDef_L100_C4", "vector": [8, 2, 0.3177, 0.0028, 2, 0.98, 0.6, 637, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "update", "arg_names": [], "import_names": [], "rhs_call_name": "update", "annotation": ""}, "snippet": " self.test_data.update({'hash':hash, 'bool1':u'False'})"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98818:Assign_L116_C8", "label": "response = post()", "type": "assigned_variable", "loc": [116, 116], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98818:FunctionDef_L100_C4", "vector": [14, 2, 0.3204, 0.0028, 2, 0.98, 0.8, 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('/test1/', self.test_data)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98818:Expr_L117_C8", "label": "assertEqual()", "type": "expression", "loc": [117, 117], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98818:FunctionDef_L100_C4", "vector": [8, 2, 0.3232, 0.0028, 2, 0.98, 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.content, success_string)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98818:FunctionDef_L119_C4", "label": "test_form_submit_django12_hash", "type": "function", "loc": [119, 132], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98818:ClassDef_L33_C0", "vector": [2, 1, 0.3467, 0.0387, 1, 0.42, 0.875, 851, 0, 1, 0, 0, 0, 0, 8], "semantic": {"name": "test_form_submit_django12_hash", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def test_form_submit_django12_hash(self):\n \"\"\"\n Test contrib.formtools.preview form submittal, using the hash function\n used in Django 1.2\n \"\"\"\n # Pass strings for form submittal and add stage variable to\n # show we previously saw first stage of the form.\n self.test_data.update({'stage':2})"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98818:Expr_L120_C8", "label": "expression", "type": "expression", "loc": [120, 123], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98818:FunctionDef_L119_C4", "vector": [8, 2, 0.3356, 0.011, 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 Test contrib.formtools.preview form submittal, using the hash function\n used in Django 1.2\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98818:Expr_L126_C8", "label": "update()", "type": "expression", "loc": [126, 126], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98818:FunctionDef_L119_C4", "vector": [8, 2, 0.3481, 0.0028, 2, 0.95, 0.1429, 637, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "update", "arg_names": [], "import_names": [], "rhs_call_name": "update", "annotation": ""}, "snippet": " self.test_data.update({'stage':2})"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98818:Assign_L127_C8", "label": "response = post()", "type": "assigned_variable", "loc": [127, 127], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98818:FunctionDef_L119_C4", "vector": [14, 2, 0.3508, 0.0028, 2, 0.95, 0.2857, 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('/test1/', self.test_data)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98818:Expr_L128_C8", "label": "failIfEqual()", "type": "expression", "loc": [128, 128], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98818:FunctionDef_L119_C4", "vector": [8, 2, 0.3536, 0.0028, 2, 0.95, 0.4286, 443, 3, 2, 0, 0, 0, 0, 1], "semantic": {"name": "failIfEqual", "arg_names": [], "import_names": [], "rhs_call_name": "failIfEqual", "annotation": ""}, "snippet": " self.failIfEqual(response.content, success_string)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98818:Assign_L129_C8", "label": "hash = security_hash()", "type": "assigned_variable", "loc": [129, 129], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98818:FunctionDef_L119_C4", "vector": [14, 2, 0.3564, 0.0028, 2, 0.95, 0.5714, 58, 3, 2, 0, 0, 234, 10, 2], "semantic": {"name": "hash", "arg_names": [], "import_names": [], "rhs_call_name": "security_hash", "annotation": ""}, "snippet": " hash = utils.security_hash(None, TestForm(self.test_data))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98818:Expr_L130_C8", "label": "update()", "type": "expression", "loc": [130, 130], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98818:FunctionDef_L119_C4", "vector": [8, 2, 0.3591, 0.0028, 2, 0.95, 0.7143, 637, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "update", "arg_names": [], "import_names": [], "rhs_call_name": "update", "annotation": ""}, "snippet": " self.test_data.update({'hash': hash})"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98818:Assign_L131_C8", "label": "response = post()", "type": "assigned_variable", "loc": [131, 131], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98818:FunctionDef_L119_C4", "vector": [14, 2, 0.3619, 0.0028, 2, 0.95, 0.8571, 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('/test1/', self.test_data)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98818:Expr_L132_C8", "label": "assertEqual()", "type": "expression", "loc": [132, 132], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98818:FunctionDef_L119_C4", "vector": [8, 2, 0.3646, 0.0028, 2, 0.95, 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.content, success_string)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98818:FunctionDef_L135_C4", "label": "test_form_submit_django12_hash_custom_hash", "type": "function", "loc": [135, 149], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98818:ClassDef_L33_C0", "vector": [2, 1, 0.3923, 0.0414, 1, 0.42, 1.0, 927, 0, 1, 0, 0, 0, 0, 9], "semantic": {"name": "test_form_submit_django12_hash_custom_hash", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def test_form_submit_django12_hash_custom_hash(self):\n \"\"\"\n Test contrib.formtools.preview form submittal, using the hash function\n used in Django 1.2 and a custom security_hash method.\n \"\"\"\n # Pass strings for form submittal and add stage variable to\n # show we previously saw first stage of the form.\n self.test_data.update({'stage':2})"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98818:Expr_L136_C8", "label": "expression", "type": "expression", "loc": [136, 139], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98818:FunctionDef_L135_C4", "vector": [8, 2, 0.3798, 0.011, 2, 0.14, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"\n Test contrib.formtools.preview form submittal, using the hash function\n used in Django 1.2 and a custom security_hash method.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98818:Expr_L142_C8", "label": "update()", "type": "expression", "loc": [142, 142], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98818:FunctionDef_L135_C4", "vector": [8, 2, 0.3923, 0.0028, 2, 0.14, 0.125, 637, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "update", "arg_names": [], "import_names": [], "rhs_call_name": "update", "annotation": ""}, "snippet": " self.test_data.update({'stage':2})"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98818:Assign_L143_C8", "label": "response = post()", "type": "assigned_variable", "loc": [143, 143], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98818:FunctionDef_L135_C4", "vector": [14, 2, 0.395, 0.0028, 2, 0.14, 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('/test2/', self.test_data)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98818:Expr_L144_C8", "label": "assertEqual()", "type": "expression", "loc": [144, 144], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98818:FunctionDef_L135_C4", "vector": [8, 2, 0.3978, 0.0028, 2, 0.14, 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(response.status_code, 200)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98818:Expr_L145_C8", "label": "failIfEqual()", "type": "expression", "loc": [145, 145], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98818:FunctionDef_L135_C4", "vector": [8, 2, 0.4006, 0.0028, 2, 0.14, 0.5, 443, 3, 2, 0, 0, 0, 0, 1], "semantic": {"name": "failIfEqual", "arg_names": [], "import_names": [], "rhs_call_name": "failIfEqual", "annotation": ""}, "snippet": " self.failIfEqual(response.content, success_string)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98818:Assign_L146_C8", "label": "hash = security_hash()", "type": "assigned_variable", "loc": [146, 146], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98818:FunctionDef_L135_C4", "vector": [14, 2, 0.4033, 0.0028, 2, 0.14, 0.625, 58, 3, 2, 0, 0, 234, 10, 2], "semantic": {"name": "hash", "arg_names": [], "import_names": [], "rhs_call_name": "security_hash", "annotation": ""}, "snippet": " hash = utils.security_hash(None, TestForm(self.test_data))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98818:Expr_L147_C8", "label": "update()", "type": "expression", "loc": [147, 147], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98818:FunctionDef_L135_C4", "vector": [8, 2, 0.4061, 0.0028, 2, 0.14, 0.75, 637, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "update", "arg_names": [], "import_names": [], "rhs_call_name": "update", "annotation": ""}, "snippet": " self.test_data.update({'hash': hash})"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98818:Assign_L148_C8", "label": "response = post()", "type": "assigned_variable", "loc": [148, 148], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98818:FunctionDef_L135_C4", "vector": [14, 2, 0.4088, 0.0028, 2, 0.14, 0.875, 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('/test2/', self.test_data)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98818:Expr_L149_C8", "label": "failIfEqual()", "type": "expression", "loc": [149, 149], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98818:FunctionDef_L135_C4", "vector": [8, 2, 0.4116, 0.0028, 2, 0.14, 1.0, 443, 3, 2, 0, 0, 0, 0, 1], "semantic": {"name": "failIfEqual", "arg_names": [], "import_names": [], "rhs_call_name": "failIfEqual", "annotation": ""}, "snippet": " self.failIfEqual(response.content, success_string)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98818:ClassDef_L152_C0", "label": "SecurityHashTests", "type": "class", "loc": [152, 175], "level": 0, "parent": null, "vector": [3, 0, 0.4517, 0.0663, 0, 0.66, 0.5455, 619, 0, 2, 0, 0, 878, 0, 10], "semantic": {"name": "SecurityHashTests", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class SecurityHashTests(unittest.TestCase):\n\n def test_textfield_hash(self):\n \"\"\"\n Regression test for #10034: the hash generation function should ignore\n leading/trailing whitespace so as to be friendly to broken browsers that\n submit it (usually in textareas).\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98818:FunctionDef_L154_C4", "label": "test_textfield_hash", "type": "function", "loc": [154, 164], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98818:ClassDef_L152_C0", "vector": [2, 1, 0.4392, 0.0304, 1, 0.08, 0.0, 493, 0, 1, 0, 0, 0, 0, 5], "semantic": {"name": "test_textfield_hash", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def test_textfield_hash(self):\n \"\"\"\n Regression test for #10034: the hash generation function should ignore\n leading/trailing whitespace so as to be friendly to broken browsers that\n submit it (usually in textareas).\n \"\"\"\n f1 = HashTestForm({'name': 'joe', 'bio': 'Nothing notable.'})\n f2 = HashTestForm({'name': ' joe', 'bio': 'Nothing notable. '})"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98818:Expr_L155_C8", "label": "expression", "type": "expression", "loc": [155, 159], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98818:FunctionDef_L154_C4", "vector": [8, 2, 0.4337, 0.0138, 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 Regression test for #10034: the hash generation function should ignore\n leading/trailing whitespace so as to be friendly to broken browsers that\n submit it (usually in textareas).\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98818:Assign_L160_C8", "label": "f1 = HashTestForm()", "type": "assigned_variable", "loc": [160, 160], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98818:FunctionDef_L154_C4", "vector": [14, 2, 0.442, 0.0028, 2, 0.31, 0.2, 282, 3, 1, 0, 0, 585, 10, 1], "semantic": {"name": "f1", "arg_names": [], "import_names": [], "rhs_call_name": "HashTestForm", "annotation": ""}, "snippet": " f1 = HashTestForm({'name': 'joe', 'bio': 'Nothing notable.'})"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98818:Assign_L161_C8", "label": "f2 = HashTestForm()", "type": "assigned_variable", "loc": [161, 161], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98818:FunctionDef_L154_C4", "vector": [14, 2, 0.4448, 0.0028, 2, 0.31, 0.4, 833, 3, 1, 0, 0, 585, 10, 1], "semantic": {"name": "f2", "arg_names": [], "import_names": [], "rhs_call_name": "HashTestForm", "annotation": ""}, "snippet": " f2 = HashTestForm({'name': ' joe', 'bio': 'Nothing notable. '})"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98818:Assign_L162_C8", "label": "hash1 = security_hash()", "type": "assigned_variable", "loc": [162, 162], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98818:FunctionDef_L154_C4", "vector": [14, 2, 0.4475, 0.0028, 2, 0.31, 0.6, 858, 3, 2, 0, 0, 234, 10, 1], "semantic": {"name": "hash1", "arg_names": [], "import_names": [], "rhs_call_name": "security_hash", "annotation": ""}, "snippet": " hash1 = utils.security_hash(None, f1)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98818:Assign_L163_C8", "label": "hash2 = security_hash()", "type": "assigned_variable", "loc": [163, 163], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98818:FunctionDef_L154_C4", "vector": [14, 2, 0.4503, 0.0028, 2, 0.31, 0.8, 307, 3, 2, 0, 0, 234, 10, 1], "semantic": {"name": "hash2", "arg_names": [], "import_names": [], "rhs_call_name": "security_hash", "annotation": ""}, "snippet": " hash2 = utils.security_hash(None, f2)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98818:Expr_L164_C8", "label": "assertEqual()", "type": "expression", "loc": [164, 164], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98818:FunctionDef_L154_C4", "vector": [8, 2, 0.453, 0.0028, 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(hash1, hash2)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98818:FunctionDef_L166_C4", "label": "test_empty_permitted", "type": "function", "loc": [166, 175], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98818:ClassDef_L152_C0", "vector": [2, 1, 0.471, 0.0276, 1, 0.08, 1.0, 451, 0, 1, 0, 0, 0, 0, 5], "semantic": {"name": "test_empty_permitted", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def test_empty_permitted(self):\n \"\"\"\n Regression test for #10643: the security hash should allow forms with\n empty_permitted = True, or forms where data has not changed.\n \"\"\"\n f1 = HashTestBlankForm({})\n f2 = HashTestForm({}, empty_permitted=True)\n hash1 = utils.security_hash(None, f1)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98818:Expr_L167_C8", "label": "expression", "type": "expression", "loc": [167, 170], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98818:FunctionDef_L166_C4", "vector": [8, 2, 0.4655, 0.011, 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 Regression test for #10643: the security hash should allow forms with\n empty_permitted = True, or forms where data has not changed.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98818:Assign_L171_C8", "label": "f1 = HashTestBlankForm()", "type": "assigned_variable", "loc": [171, 171], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98818:FunctionDef_L166_C4", "vector": [14, 2, 0.4724, 0.0028, 2, 0.77, 0.2, 282, 3, 1, 0, 0, 679, 10, 1], "semantic": {"name": "f1", "arg_names": [], "import_names": [], "rhs_call_name": "HashTestBlankForm", "annotation": ""}, "snippet": " f1 = HashTestBlankForm({})"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98818:Assign_L172_C8", "label": "f2 = HashTestForm()", "type": "assigned_variable", "loc": [172, 172], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98818:FunctionDef_L166_C4", "vector": [14, 2, 0.4751, 0.0028, 2, 0.77, 0.4, 833, 3, 2, 0, 0, 585, 10, 1], "semantic": {"name": "f2", "arg_names": [], "import_names": [], "rhs_call_name": "HashTestForm", "annotation": ""}, "snippet": " f2 = HashTestForm({}, empty_permitted=True)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98818:Assign_L173_C8", "label": "hash1 = security_hash()", "type": "assigned_variable", "loc": [173, 173], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98818:FunctionDef_L166_C4", "vector": [14, 2, 0.4779, 0.0028, 2, 0.77, 0.6, 858, 3, 2, 0, 0, 234, 10, 1], "semantic": {"name": "hash1", "arg_names": [], "import_names": [], "rhs_call_name": "security_hash", "annotation": ""}, "snippet": " hash1 = utils.security_hash(None, f1)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98818:Assign_L174_C8", "label": "hash2 = security_hash()", "type": "assigned_variable", "loc": [174, 174], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98818:FunctionDef_L166_C4", "vector": [14, 2, 0.4807, 0.0028, 2, 0.77, 0.8, 307, 3, 2, 0, 0, 234, 10, 1], "semantic": {"name": "hash2", "arg_names": [], "import_names": [], "rhs_call_name": "security_hash", "annotation": ""}, "snippet": " hash2 = utils.security_hash(None, f2)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98818:Expr_L175_C8", "label": "assertEqual()", "type": "expression", "loc": [175, 175], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98818:FunctionDef_L166_C4", "vector": [8, 2, 0.4834, 0.0028, 2, 0.77, 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(hash1, hash2)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98818:ClassDef_L178_C0", "label": "FormHmacTests", "type": "class", "loc": [178, 204], "level": 0, "parent": null, "vector": [3, 0, 0.5276, 0.0746, 0, 0.66, 0.5909, 331, 0, 2, 0, 0, 878, 0, 10], "semantic": {"name": "FormHmacTests", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class FormHmacTests(unittest.TestCase):\n \"\"\"\n Same as SecurityHashTests, but with form_hmac\n \"\"\"\n\n def test_textfield_hash(self):\n \"\"\"\n Regression test for #10034: the hash generation function should ignore"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98818:Expr_L179_C4", "label": "expression", "type": "expression", "loc": [179, 181], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98818:ClassDef_L178_C0", "vector": [8, 1, 0.4972, 0.0083, 1, 0.21, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"\n Same as SecurityHashTests, but with form_hmac\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98818:FunctionDef_L183_C4", "label": "test_textfield_hash", "type": "function", "loc": [183, 193], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98818:ClassDef_L178_C0", "vector": [2, 1, 0.5193, 0.0304, 1, 0.21, 0.5, 493, 0, 1, 0, 0, 0, 0, 5], "semantic": {"name": "test_textfield_hash", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def test_textfield_hash(self):\n \"\"\"\n Regression test for #10034: the hash generation function should ignore\n leading/trailing whitespace so as to be friendly to broken browsers that\n submit it (usually in textareas).\n \"\"\"\n f1 = HashTestForm({'name': 'joe', 'bio': 'Nothing notable.'})\n f2 = HashTestForm({'name': ' joe', 'bio': 'Nothing notable. '})"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98818:Expr_L184_C8", "label": "expression", "type": "expression", "loc": [184, 188], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98818:FunctionDef_L183_C4", "vector": [8, 2, 0.5138, 0.0138, 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 Regression test for #10034: the hash generation function should ignore\n leading/trailing whitespace so as to be friendly to broken browsers that\n submit it (usually in textareas).\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98818:Assign_L189_C8", "label": "f1 = HashTestForm()", "type": "assigned_variable", "loc": [189, 189], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98818:FunctionDef_L183_C4", "vector": [14, 2, 0.5221, 0.0028, 2, 0.84, 0.2, 282, 3, 1, 0, 0, 585, 10, 1], "semantic": {"name": "f1", "arg_names": [], "import_names": [], "rhs_call_name": "HashTestForm", "annotation": ""}, "snippet": " f1 = HashTestForm({'name': 'joe', 'bio': 'Nothing notable.'})"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98818:Assign_L190_C8", "label": "f2 = HashTestForm()", "type": "assigned_variable", "loc": [190, 190], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98818:FunctionDef_L183_C4", "vector": [14, 2, 0.5249, 0.0028, 2, 0.84, 0.4, 833, 3, 1, 0, 0, 585, 10, 1], "semantic": {"name": "f2", "arg_names": [], "import_names": [], "rhs_call_name": "HashTestForm", "annotation": ""}, "snippet": " f2 = HashTestForm({'name': ' joe', 'bio': 'Nothing notable. '})"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98818:Assign_L191_C8", "label": "hash1 = form_hmac()", "type": "assigned_variable", "loc": [191, 191], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98818:FunctionDef_L183_C4", "vector": [14, 2, 0.5276, 0.0028, 2, 0.84, 0.6, 858, 3, 1, 0, 0, 352, 10, 1], "semantic": {"name": "hash1", "arg_names": [], "import_names": [], "rhs_call_name": "form_hmac", "annotation": ""}, "snippet": " hash1 = utils.form_hmac(f1)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98818:Assign_L192_C8", "label": "hash2 = form_hmac()", "type": "assigned_variable", "loc": [192, 192], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98818:FunctionDef_L183_C4", "vector": [14, 2, 0.5304, 0.0028, 2, 0.84, 0.8, 307, 3, 1, 0, 0, 352, 10, 1], "semantic": {"name": "hash2", "arg_names": [], "import_names": [], "rhs_call_name": "form_hmac", "annotation": ""}, "snippet": " hash2 = utils.form_hmac(f2)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98818:Expr_L193_C8", "label": "assertEqual()", "type": "expression", "loc": [193, 193], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98818:FunctionDef_L183_C4", "vector": [8, 2, 0.5331, 0.0028, 2, 0.84, 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(hash1, hash2)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98818:FunctionDef_L195_C4", "label": "test_empty_permitted", "type": "function", "loc": [195, 204], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98818:ClassDef_L178_C0", "vector": [2, 1, 0.5511, 0.0276, 1, 0.21, 1.0, 451, 0, 1, 0, 0, 0, 0, 5], "semantic": {"name": "test_empty_permitted", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def test_empty_permitted(self):\n \"\"\"\n Regression test for #10643: the security hash should allow forms with\n empty_permitted = True, or forms where data has not changed.\n \"\"\"\n f1 = HashTestBlankForm({})\n f2 = HashTestForm({}, empty_permitted=True)\n hash1 = utils.form_hmac(f1)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98818:Expr_L196_C8", "label": "expression", "type": "expression", "loc": [196, 199], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98818:FunctionDef_L195_C4", "vector": [8, 2, 0.5456, 0.011, 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 Regression test for #10643: the security hash should allow forms with\n empty_permitted = True, or forms where data has not changed.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98818:Assign_L200_C8", "label": "f1 = HashTestBlankForm()", "type": "assigned_variable", "loc": [200, 200], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98818:FunctionDef_L195_C4", "vector": [14, 2, 0.5525, 0.0028, 2, 0.3, 0.2, 282, 3, 1, 0, 0, 679, 10, 1], "semantic": {"name": "f1", "arg_names": [], "import_names": [], "rhs_call_name": "HashTestBlankForm", "annotation": ""}, "snippet": " f1 = HashTestBlankForm({})"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98818:Assign_L201_C8", "label": "f2 = HashTestForm()", "type": "assigned_variable", "loc": [201, 201], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98818:FunctionDef_L195_C4", "vector": [14, 2, 0.5552, 0.0028, 2, 0.3, 0.4, 833, 3, 2, 0, 0, 585, 10, 1], "semantic": {"name": "f2", "arg_names": [], "import_names": [], "rhs_call_name": "HashTestForm", "annotation": ""}, "snippet": " f2 = HashTestForm({}, empty_permitted=True)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98818:Assign_L202_C8", "label": "hash1 = form_hmac()", "type": "assigned_variable", "loc": [202, 202], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98818:FunctionDef_L195_C4", "vector": [14, 2, 0.558, 0.0028, 2, 0.3, 0.6, 858, 3, 1, 0, 0, 352, 10, 1], "semantic": {"name": "hash1", "arg_names": [], "import_names": [], "rhs_call_name": "form_hmac", "annotation": ""}, "snippet": " hash1 = utils.form_hmac(f1)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98818:Assign_L203_C8", "label": "hash2 = form_hmac()", "type": "assigned_variable", "loc": [203, 203], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98818:FunctionDef_L195_C4", "vector": [14, 2, 0.5608, 0.0028, 2, 0.3, 0.8, 307, 3, 1, 0, 0, 352, 10, 1], "semantic": {"name": "hash2", "arg_names": [], "import_names": [], "rhs_call_name": "form_hmac", "annotation": ""}, "snippet": " hash2 = utils.form_hmac(f2)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98818:Expr_L204_C8", "label": "assertEqual()", "type": "expression", "loc": [204, 204], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98818:FunctionDef_L195_C4", "vector": [8, 2, 0.5635, 0.0028, 2, 0.3, 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(hash1, hash2)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98818:ClassDef_L207_C0", "label": "HashTestForm", "type": "class", "loc": [207, 209], "level": 0, "parent": null, "vector": [3, 0, 0.5746, 0.0083, 0, 0.66, 0.6364, 585, 0, 0, 0, 0, 953, 0, 2], "semantic": {"name": "HashTestForm", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class HashTestForm(forms.Form):\n name = forms.CharField()\n bio = forms.CharField()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98818:Assign_L208_C4", "label": "name = CharField()", "type": "assigned_variable", "loc": [208, 208], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98818:ClassDef_L207_C0", "vector": [14, 1, 0.5746, 0.0028, 1, 0.2, 0.0, 57, 3, 0, 0, 0, 952, 10, 1], "semantic": {"name": "name", "arg_names": [], "import_names": [], "rhs_call_name": "CharField", "annotation": ""}, "snippet": " name = forms.CharField()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98818:Assign_L209_C4", "label": "bio = CharField()", "type": "assigned_variable", "loc": [209, 209], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98818:ClassDef_L207_C0", "vector": [14, 1, 0.5773, 0.0028, 1, 0.2, 1.0, 577, 3, 0, 0, 0, 952, 10, 1], "semantic": {"name": "bio", "arg_names": [], "import_names": [], "rhs_call_name": "CharField", "annotation": ""}, "snippet": " bio = forms.CharField()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98818:ClassDef_L212_C0", "label": "HashTestBlankForm", "type": "class", "loc": [212, 214], "level": 0, "parent": null, "vector": [3, 0, 0.5884, 0.0083, 0, 0.66, 0.6818, 679, 0, 0, 0, 0, 953, 0, 2], "semantic": {"name": "HashTestBlankForm", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class HashTestBlankForm(forms.Form):\n name = forms.CharField(required=False)\n bio = forms.CharField(required=False)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98818:Assign_L213_C4", "label": "name = CharField()", "type": "assigned_variable", "loc": [213, 213], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98818:ClassDef_L212_C0", "vector": [14, 1, 0.5884, 0.0028, 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 = forms.CharField(required=False)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98818:Assign_L214_C4", "label": "bio = CharField()", "type": "assigned_variable", "loc": [214, 214], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98818:ClassDef_L212_C0", "vector": [14, 1, 0.5912, 0.0028, 1, 0.52, 1.0, 577, 3, 1, 0, 0, 952, 10, 1], "semantic": {"name": "bio", "arg_names": [], "import_names": [], "rhs_call_name": "CharField", "annotation": ""}, "snippet": " bio = forms.CharField(required=False)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98818:ClassDef_L221_C0", "label": "WizardPageOneForm", "type": "class", "loc": [221, 222], "level": 0, "parent": null, "vector": [3, 0, 0.6119, 0.0055, 0, 0.66, 0.7273, 34, 0, 0, 0, 0, 953, 0, 1], "semantic": {"name": "WizardPageOneForm", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class WizardPageOneForm(forms.Form):\n field = forms.CharField()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98818:Assign_L222_C4", "label": "field = CharField()", "type": "assigned_variable", "loc": [222, 222], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98818:ClassDef_L221_C0", "vector": [14, 1, 0.6133, 0.0028, 1, 0.92, 0.0, 480, 3, 0, 0, 0, 952, 10, 1], "semantic": {"name": "field", "arg_names": [], "import_names": [], "rhs_call_name": "CharField", "annotation": ""}, "snippet": " field = forms.CharField()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98818:ClassDef_L225_C0", "label": "WizardPageTwoForm", "type": "class", "loc": [225, 226], "level": 0, "parent": null, "vector": [3, 0, 0.6229, 0.0055, 0, 0.66, 0.7727, 580, 0, 0, 0, 0, 953, 0, 1], "semantic": {"name": "WizardPageTwoForm", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class WizardPageTwoForm(forms.Form):\n field = forms.CharField()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98818:Assign_L226_C4", "label": "field = CharField()", "type": "assigned_variable", "loc": [226, 226], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98818:ClassDef_L225_C0", "vector": [14, 1, 0.6243, 0.0028, 1, 0.46, 0.0, 480, 3, 0, 0, 0, 952, 10, 1], "semantic": {"name": "field", "arg_names": [], "import_names": [], "rhs_call_name": "CharField", "annotation": ""}, "snippet": " field = forms.CharField()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98818:ClassDef_L229_C0", "label": "WizardPageThreeForm", "type": "class", "loc": [229, 230], "level": 0, "parent": null, "vector": [3, 0, 0.634, 0.0055, 0, 0.66, 0.8182, 792, 0, 0, 0, 0, 953, 0, 1], "semantic": {"name": "WizardPageThreeForm", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class WizardPageThreeForm(forms.Form):\n field = forms.CharField()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98818:Assign_L230_C4", "label": "field = CharField()", "type": "assigned_variable", "loc": [230, 230], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98818:ClassDef_L229_C0", "vector": [14, 1, 0.6354, 0.0028, 1, 0.59, 0.0, 480, 3, 0, 0, 0, 952, 10, 1], "semantic": {"name": "field", "arg_names": [], "import_names": [], "rhs_call_name": "CharField", "annotation": ""}, "snippet": " field = forms.CharField()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98818:ClassDef_L233_C0", "label": "WizardClass", "type": "class", "loc": [233, 239], "level": 0, "parent": null, "vector": [3, 0, 0.6519, 0.0193, 0, 0.66, 0.8636, 354, 0, 2, 0, 0, 382, 0, 1], "semantic": {"name": "WizardClass", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class WizardClass(wizard.FormWizard):\n\n def get_template(self, step):\n return 'formwizard/wizard.html'\n\n def done(self, request, cleaned_data):\n return http.HttpResponse(success_string)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98818:FunctionDef_L235_C4", "label": "get_template", "type": "function", "loc": [235, 236], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98818:ClassDef_L233_C0", "vector": [2, 1, 0.6506, 0.0055, 1, 0.27, 0.0, 27, 0, 2, 1, 0, 0, 0, 0], "semantic": {"name": "get_template", "arg_names": ["self", "step"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def get_template(self, step):\n return 'formwizard/wizard.html'"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98818:Return_L236_C8", "label": "return", "type": "return", "loc": [236, 236], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98818:FunctionDef_L235_C4", "vector": [13, 2, 0.6519, 0.0028, 2, 0.94, 0.0, 0, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return 'formwizard/wizard.html'"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98818:FunctionDef_L238_C4", "label": "done", "type": "function", "loc": [238, 239], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98818:ClassDef_L233_C0", "vector": [2, 1, 0.6588, 0.0055, 1, 0.27, 1.0, 151, 0, 3, 1, 0, 0, 0, 1], "semantic": {"name": "done", "arg_names": ["self", "request", "cleaned_data"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def done(self, request, cleaned_data):\n return http.HttpResponse(success_string)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98818:Return_L239_C8", "label": "return", "type": "return", "loc": [239, 239], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98818:FunctionDef_L238_C4", "vector": [13, 2, 0.6602, 0.0028, 2, 0.55, 0.0, 0, 3, 0, 0, 0, 0, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return http.HttpResponse(success_string)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98818:ClassDef_L242_C0", "label": "UserSecuredWizardClass", "type": "class", "loc": [242, 247], "level": 0, "parent": null, "vector": [3, 0, 0.6754, 0.0166, 0, 0.66, 0.9091, 191, 0, 1, 0, 0, 354, 0, 0], "semantic": {"name": "UserSecuredWizardClass", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class UserSecuredWizardClass(WizardClass):\n \"\"\"\n Wizard with a custum security_hash method\n \"\"\"\n def security_hash(self, request, form):\n return \"123\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98818:Expr_L243_C4", "label": "expression", "type": "expression", "loc": [243, 245], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98818:ClassDef_L242_C0", "vector": [8, 1, 0.674, 0.0083, 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 Wizard with a custum security_hash method\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98818:FunctionDef_L246_C4", "label": "security_hash", "type": "function", "loc": [246, 247], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98818:ClassDef_L242_C0", "vector": [2, 1, 0.6809, 0.0055, 1, 0.24, 1.0, 234, 0, 3, 1, 0, 0, 0, 0], "semantic": {"name": "security_hash", "arg_names": ["self", "request", "form"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def security_hash(self, request, form):\n return \"123\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98818:Return_L247_C8", "label": "return", "type": "return", "loc": [247, 247], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98818:FunctionDef_L246_C4", "vector": [13, 2, 0.6823, 0.0028, 2, 0.65, 0.0, 0, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return \"123\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98818:ClassDef_L250_C0", "label": "DummyRequest", "type": "class", "loc": [250, 257], "level": 0, "parent": null, "vector": [3, 0, 0.7003, 0.0221, 0, 0.66, 0.9545, 278, 0, 1, 0, 0, 764, 0, 3], "semantic": {"name": "DummyRequest", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class DummyRequest(http.HttpRequest):\n\n def __init__(self, POST=None):\n super(DummyRequest, self).__init__()\n self.method = POST and \"POST\" or \"GET\"\n if POST is not None:\n self.POST.update(POST)\n self._dont_enforce_csrf_checks = True"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98818:FunctionDef_L252_C4", "label": "__init__", "type": "function", "loc": [252, 257], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98818:ClassDef_L250_C0", "vector": [2, 1, 0.703, 0.0166, 1, 0.08, 0.0, 555, 0, 2, 0, 0, 0, 0, 3], "semantic": {"name": "__init__", "arg_names": ["self", "POST"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def __init__(self, POST=None):\n super(DummyRequest, self).__init__()\n self.method = POST and \"POST\" or \"GET\"\n if POST is not None:\n self.POST.update(POST)\n self._dont_enforce_csrf_checks = True"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98818:Expr_L253_C8", "label": "__init__()", "type": "expression", "loc": [253, 253], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98818:FunctionDef_L252_C4", "vector": [8, 2, 0.6989, 0.0028, 2, 0.57, 0.0, 555, 3, 0, 0, 0, 0, 0, 2], "semantic": {"name": "__init__", "arg_names": [], "import_names": [], "rhs_call_name": "__init__", "annotation": ""}, "snippet": " super(DummyRequest, self).__init__()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98818:Assign_L254_C8", "label": "self.method =", "type": "assigned_variable", "loc": [254, 254], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98818:FunctionDef_L252_C4", "vector": [14, 2, 0.7017, 0.0028, 2, 0.57, 0.3333, 432, 0, 0, 0, 0, 0, 0, 0], "semantic": {"name": "self.method", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.method = POST and \"POST\" or \"GET\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98818:If_L255_C8", "label": "if", "type": "if", "loc": [255, 256], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98818:FunctionDef_L252_C4", "vector": [4, 2, 0.7058, 0.0055, 2, 0.57, 0.6667, 0, 0, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if POST is not None:\n self.POST.update(POST)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98818:Expr_L256_C12", "label": "update()", "type": "expression", "loc": [256, 256], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98818:If_L255_C8", "vector": [8, 3, 0.7072, 0.0028, 3, 0.97, 0.0, 637, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "update", "arg_names": [], "import_names": [], "rhs_call_name": "update", "annotation": ""}, "snippet": " self.POST.update(POST)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98818:Assign_L257_C8", "label": "self._dont_enforce_csrf_checks =", "type": "assigned_variable", "loc": [257, 257], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98818:FunctionDef_L252_C4", "vector": [14, 2, 0.7099, 0.0028, 2, 0.57, 1.0, 522, 1, 0, 0, 0, 0, 4, 0], "semantic": {"name": "self._dont_enforce_csrf_checks", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self._dont_enforce_csrf_checks = True"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98818:ClassDef_L260_C0", "label": "WizardTests", "type": "class", "loc": [260, 361], "level": 0, "parent": null, "vector": [3, 0, 0.8577, 0.2818, 0, 0.66, 1.0, 94, 0, 10, 0, 0, 3, 0, 19], "semantic": {"name": "WizardTests", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class WizardTests(TestCase):\n urls = 'django.contrib.formtools.tests.urls'\n\n def setUp(self):\n self.old_TEMPLATE_DIRS = settings.TEMPLATE_DIRS\n settings.TEMPLATE_DIRS = (\n os.path.join(\n os.path.dirname(__file__),"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98818:Assign_L261_C4", "label": "urls =", "type": "assigned_variable", "loc": [261, 261], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98818:ClassDef_L260_C0", "vector": [14, 1, 0.721, 0.0028, 1, 0.56, 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.formtools.tests.urls'"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98818:FunctionDef_L263_C4", "label": "setUp", "type": "function", "loc": [263, 273], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98818:ClassDef_L260_C0", "vector": [2, 1, 0.7403, 0.0304, 1, 0.56, 0.1111, 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_TEMPLATE_DIRS = settings.TEMPLATE_DIRS\n settings.TEMPLATE_DIRS = (\n os.path.join(\n os.path.dirname(__file__),\n 'templates'\n ),\n )"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98818:Assign_L264_C8", "label": "self.old_TEMPLATE_DIRS =", "type": "assigned_variable", "loc": [264, 264], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98818:FunctionDef_L263_C4", "vector": [14, 2, 0.7293, 0.0028, 2, 0.45, 0.0, 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_98818:Assign_L265_C8", "label": "settings.TEMPLATE_DIRS =", "type": "assigned_variable", "loc": [265, 270], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98818:FunctionDef_L263_C4", "vector": [14, 2, 0.739, 0.0166, 2, 0.45, 0.3333, 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_98818:Assign_L272_C8", "label": "self.old_SECRET_KEY =", "type": "assigned_variable", "loc": [272, 272], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98818:FunctionDef_L263_C4", "vector": [14, 2, 0.7514, 0.0028, 2, 0.45, 0.6667, 428, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "self.old_SECRET_KEY", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.old_SECRET_KEY = settings.SECRET_KEY"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98818:Assign_L273_C8", "label": "settings.SECRET_KEY =", "type": "assigned_variable", "loc": [273, 273], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98818:FunctionDef_L263_C4", "vector": [14, 2, 0.7541, 0.0028, 2, 0.45, 1.0, 596, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "settings.SECRET_KEY", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " settings.SECRET_KEY = \"123\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98818:FunctionDef_L275_C4", "label": "tearDown", "type": "function", "loc": [275, 277], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98818:ClassDef_L260_C0", "vector": [2, 1, 0.7624, 0.0083, 1, 0.56, 0.2222, 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.TEMPLATE_DIRS = self.old_TEMPLATE_DIRS\n settings.SECRET_KEY = self.old_SECRET_KEY"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98818:Assign_L276_C8", "label": "settings.TEMPLATE_DIRS =", "type": "assigned_variable", "loc": [276, 276], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98818:FunctionDef_L275_C4", "vector": [14, 2, 0.7624, 0.0028, 2, 0.02, 0.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_98818:Assign_L277_C8", "label": "settings.SECRET_KEY =", "type": "assigned_variable", "loc": [277, 277], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98818:FunctionDef_L275_C4", "vector": [14, 2, 0.7652, 0.0028, 2, 0.02, 1.0, 596, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "settings.SECRET_KEY", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " settings.SECRET_KEY = self.old_SECRET_KEY"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98818:FunctionDef_L279_C4", "label": "test_step_starts_at_zero", "type": "function", "loc": [279, 284], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98818:ClassDef_L260_C0", "vector": [2, 1, 0.7776, 0.0166, 1, 0.56, 0.3333, 358, 0, 1, 0, 0, 0, 0, 2], "semantic": {"name": "test_step_starts_at_zero", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def test_step_starts_at_zero(self):\n \"\"\"\n step should be zero for the first form\n \"\"\"\n response = self.client.get('/wizard/')\n self.assertEquals(0, response.context['step0'])"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98818:Expr_L280_C8", "label": "expression", "type": "expression", "loc": [280, 282], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98818:FunctionDef_L279_C4", "vector": [8, 2, 0.7762, 0.0083, 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 step should be zero for the first form\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98818:Assign_L283_C8", "label": "response = get()", "type": "assigned_variable", "loc": [283, 283], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98818:FunctionDef_L279_C4", "vector": [14, 2, 0.7818, 0.0028, 2, 0.92, 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('/wizard/')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98818:Expr_L284_C8", "label": "assertEquals()", "type": "expression", "loc": [284, 284], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98818:FunctionDef_L279_C4", "vector": [8, 2, 0.7845, 0.0028, 2, 0.92, 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(0, response.context['step0'])"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98818:FunctionDef_L286_C4", "label": "test_step_increments", "type": "function", "loc": [286, 291], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98818:ClassDef_L260_C0", "vector": [2, 1, 0.797, 0.0166, 1, 0.56, 0.4444, 932, 0, 1, 0, 0, 0, 0, 2], "semantic": {"name": "test_step_increments", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def test_step_increments(self):\n \"\"\"\n step should be incremented when we go to the next page\n \"\"\"\n response = self.client.post('/wizard/', {\"0-field\":\"test\", \"wizard_step\":\"0\"})\n self.assertEquals(1, response.context['step0'])"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98818:Expr_L287_C8", "label": "expression", "type": "expression", "loc": [287, 289], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98818:FunctionDef_L286_C4", "vector": [8, 2, 0.7956, 0.0083, 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 step should be incremented when we go to the next page\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98818:Assign_L290_C8", "label": "response = post()", "type": "assigned_variable", "loc": [290, 290], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98818:FunctionDef_L286_C4", "vector": [14, 2, 0.8011, 0.0028, 2, 0.36, 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('/wizard/', {\"0-field\":\"test\", \"wizard_step\":\"0\"})"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98818:Expr_L291_C8", "label": "assertEquals()", "type": "expression", "loc": [291, 291], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98818:FunctionDef_L286_C4", "vector": [8, 2, 0.8039, 0.0028, 2, 0.36, 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(1, response.context['step0'])"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98818:FunctionDef_L293_C4", "label": "test_bad_hash", "type": "function", "loc": [293, 301], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98818:ClassDef_L260_C0", "vector": [2, 1, 0.8204, 0.0249, 1, 0.56, 0.5556, 117, 0, 1, 0, 0, 0, 0, 2], "semantic": {"name": "test_bad_hash", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def test_bad_hash(self):\n \"\"\"\n Form should not advance if the hash is missing or bad\n \"\"\"\n response = self.client.post('/wizard/',\n {\"0-field\":\"test\",\n \"1-field\":\"test2\",\n \"wizard_step\": \"1\"})"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98818:Expr_L294_C8", "label": "expression", "type": "expression", "loc": [294, 296], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98818:FunctionDef_L293_C4", "vector": [8, 2, 0.8149, 0.0083, 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 Form should not advance if the hash is missing or bad\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98818:Assign_L297_C8", "label": "response = post()", "type": "assigned_variable", "loc": [297, 300], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98818:FunctionDef_L293_C4", "vector": [14, 2, 0.8246, 0.011, 2, 0.86, 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('/wizard/',\n {\"0-field\":\"test\",\n \"1-field\":\"test2\",\n \"wizard_step\": \"1\"})"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98818:Expr_L301_C8", "label": "assertEquals()", "type": "expression", "loc": [301, 301], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98818:FunctionDef_L293_C4", "vector": [8, 2, 0.8315, 0.0028, 2, 0.86, 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(0, response.context['step0'])"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98818:FunctionDef_L303_C4", "label": "test_good_hash_django12", "type": "function", "loc": [303, 315], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98818:ClassDef_L260_C0", "vector": [2, 1, 0.8536, 0.0359, 1, 0.56, 0.6667, 491, 0, 1, 0, 0, 0, 0, 2], "semantic": {"name": "test_good_hash_django12", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def test_good_hash_django12(self):\n \"\"\"\n Form should advance if the hash is present and good, as calculated using\n django 1.2 method.\n \"\"\"\n # We are hard-coding a hash value here, but that is OK, since we want to\n # ensure that we don't accidentally change the algorithm.\n data = {\"0-field\": \"test\","}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98818:Expr_L304_C8", "label": "expression", "type": "expression", "loc": [304, 307], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98818:FunctionDef_L303_C4", "vector": [8, 2, 0.8439, 0.011, 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 Form should advance if the hash is present and good, as calculated using\n django 1.2 method.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98818:Assign_L310_C8", "label": "data =", "type": "assigned_variable", "loc": [310, 313], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98818:FunctionDef_L303_C4", "vector": [14, 2, 0.8605, 0.011, 2, 0.28, 0.3333, 929, 0, 0, 0, 0, 0, 6, 0], "semantic": {"name": "data", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " data = {\"0-field\": \"test\",\n \"1-field\": \"test2\",\n \"hash_0\": \"2fdbefd4c0cad51509478fbacddf8b13\",\n \"wizard_step\": \"1\"}"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98818:Assign_L314_C8", "label": "response = post()", "type": "assigned_variable", "loc": [314, 314], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98818:FunctionDef_L303_C4", "vector": [14, 2, 0.8674, 0.0028, 2, 0.28, 0.6667, 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('/wizard/', data)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98818:Expr_L315_C8", "label": "assertEquals()", "type": "expression", "loc": [315, 315], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98818:FunctionDef_L303_C4", "vector": [8, 2, 0.8702, 0.0028, 2, 0.28, 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(2, response.context['step0'])"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98818:FunctionDef_L317_C4", "label": "test_good_hash_django12_subclass", "type": "function", "loc": [317, 330], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98818:ClassDef_L260_C0", "vector": [2, 1, 0.8936, 0.0387, 1, 0.56, 0.7778, 976, 0, 1, 0, 0, 0, 0, 2], "semantic": {"name": "test_good_hash_django12_subclass", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def test_good_hash_django12_subclass(self):\n \"\"\"\n The Django 1.2 method of calulating hashes should *not* be used as a\n fallback if the FormWizard subclass has provided their own method\n of calculating a hash.\n \"\"\"\n # We are hard-coding a hash value here, but that is OK, since we want to\n # ensure that we don't accidentally change the algorithm."}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98818:Expr_L318_C8", "label": "expression", "type": "expression", "loc": [318, 322], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98818:FunctionDef_L317_C4", "vector": [8, 2, 0.884, 0.0138, 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 The Django 1.2 method of calulating hashes should *not* be used as a\n fallback if the FormWizard subclass has provided their own method\n of calculating a hash.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98818:Assign_L325_C8", "label": "data =", "type": "assigned_variable", "loc": [325, 328], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98818:FunctionDef_L317_C4", "vector": [14, 2, 0.9019, 0.011, 2, 0.53, 0.3333, 929, 0, 0, 0, 0, 0, 6, 0], "semantic": {"name": "data", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " data = {\"0-field\": \"test\",\n \"1-field\": \"test2\",\n \"hash_0\": \"2fdbefd4c0cad51509478fbacddf8b13\",\n \"wizard_step\": \"1\"}"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98818:Assign_L329_C8", "label": "response = post()", "type": "assigned_variable", "loc": [329, 329], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98818:FunctionDef_L317_C4", "vector": [14, 2, 0.9088, 0.0028, 2, 0.53, 0.6667, 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('/wizard2/', data)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98818:Expr_L330_C8", "label": "assertEquals()", "type": "expression", "loc": [330, 330], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98818:FunctionDef_L317_C4", "vector": [8, 2, 0.9116, 0.0028, 2, 0.53, 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(0, response.context['step0'])"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98818:FunctionDef_L332_C4", "label": "test_good_hash_current", "type": "function", "loc": [332, 342], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98818:ClassDef_L260_C0", "vector": [2, 1, 0.9309, 0.0304, 1, 0.56, 0.8889, 11, 0, 1, 0, 0, 0, 0, 2], "semantic": {"name": "test_good_hash_current", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def test_good_hash_current(self):\n \"\"\"\n Form should advance if the hash is present and good, as calculated using\n current method.\n \"\"\"\n data = {\"0-field\": \"test\",\n \"1-field\": \"test2\",\n \"hash_0\": \"7e9cea465f6a10a6fb47fcea65cb9a76350c9a5c\","}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98818:Expr_L333_C8", "label": "expression", "type": "expression", "loc": [333, 336], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98818:FunctionDef_L332_C4", "vector": [8, 2, 0.924, 0.011, 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 Form should advance if the hash is present and good, as calculated using\n current method.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98818:Assign_L337_C8", "label": "data =", "type": "assigned_variable", "loc": [337, 340], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98818:FunctionDef_L332_C4", "vector": [14, 2, 0.9351, 0.011, 2, 0.93, 0.3333, 929, 0, 0, 0, 0, 0, 6, 0], "semantic": {"name": "data", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " data = {\"0-field\": \"test\",\n \"1-field\": \"test2\",\n \"hash_0\": \"7e9cea465f6a10a6fb47fcea65cb9a76350c9a5c\",\n \"wizard_step\": \"1\"}"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98818:Assign_L341_C8", "label": "response = post()", "type": "assigned_variable", "loc": [341, 341], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98818:FunctionDef_L332_C4", "vector": [14, 2, 0.942, 0.0028, 2, 0.93, 0.6667, 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('/wizard/', data)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98818:Expr_L342_C8", "label": "assertEquals()", "type": "expression", "loc": [342, 342], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98818:FunctionDef_L332_C4", "vector": [8, 2, 0.9448, 0.0028, 2, 0.93, 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(2, response.context['step0'])"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98818:FunctionDef_L344_C4", "label": "test_14498", "type": "function", "loc": [344, 361], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98818:ClassDef_L260_C0", "vector": [2, 1, 0.9738, 0.0497, 1, 0.56, 1.0, 47, 0, 1, 0, 0, 0, 0, 5], "semantic": {"name": "test_14498", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def test_14498(self):\n \"\"\"\n Regression test for ticket #14498.\n \"\"\"\n that = self\n\n class WizardWithProcessStep(WizardClass):\n def process_step(self, request, form, step):"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98818:Expr_L345_C8", "label": "expression", "type": "expression", "loc": [345, 347], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98818:FunctionDef_L344_C4", "vector": [8, 2, 0.9558, 0.0083, 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 Regression test for ticket #14498.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98818:Assign_L348_C8", "label": "that =", "type": "assigned_variable", "loc": [348, 348], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98818:FunctionDef_L344_C4", "vector": [14, 2, 0.9613, 0.0028, 2, 0.84, 0.2, 418, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "that", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " that = self"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98818:ClassDef_L350_C8", "label": "WizardWithProcessStep", "type": "class", "loc": [350, 352], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98818:FunctionDef_L344_C4", "vector": [3, 2, 0.9696, 0.0083, 2, 0.84, 0.4, 169, 0, 1, 0, 0, 354, 0, 2], "semantic": {"name": "WizardWithProcessStep", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " class WizardWithProcessStep(WizardClass):\n def process_step(self, request, form, step):\n that.assertTrue(hasattr(form, 'cleaned_data'))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98818:FunctionDef_L351_C12", "label": "process_step", "type": "function", "loc": [351, 352], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98818:ClassDef_L350_C8", "vector": [2, 3, 0.971, 0.0055, 3, 0.0, 0.0, 470, 0, 4, 0, 0, 0, 0, 2], "semantic": {"name": "process_step", "arg_names": ["self", "request", "form", "step"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def process_step(self, request, form, step):\n that.assertTrue(hasattr(form, 'cleaned_data'))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98818:Expr_L352_C16", "label": "assertTrue()", "type": "expression", "loc": [352, 352], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98818:FunctionDef_L351_C12", "vector": [8, 4, 0.9724, 0.0028, 4, 0.49, 0.0, 170, 3, 1, 0, 0, 0, 0, 2], "semantic": {"name": "assertTrue", "arg_names": [], "import_names": [], "rhs_call_name": "assertTrue", "annotation": ""}, "snippet": " that.assertTrue(hasattr(form, 'cleaned_data'))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98818:Assign_L354_C8", "label": "wizard = WizardWithProcessStep()", "type": "assigned_variable", "loc": [354, 356], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98818:FunctionDef_L344_C4", "vector": [14, 2, 0.9807, 0.0083, 2, 0.84, 0.6, 569, 3, 1, 0, 0, 169, 10, 1], "semantic": {"name": "wizard", "arg_names": [], "import_names": [], "rhs_call_name": "WizardWithProcessStep", "annotation": ""}, "snippet": " wizard = WizardWithProcessStep([WizardPageOneForm,\n WizardPageTwoForm,\n WizardPageThreeForm])"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98818:Assign_L357_C8", "label": "data =", "type": "assigned_variable", "loc": [357, 360], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98818:FunctionDef_L344_C4", "vector": [14, 2, 0.9903, 0.011, 2, 0.84, 0.8, 929, 0, 0, 0, 0, 0, 6, 0], "semantic": {"name": "data", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " data = {\"0-field\": \"test\",\n \"1-field\": \"test2\",\n \"hash_0\": \"7e9cea465f6a10a6fb47fcea65cb9a76350c9a5c\",\n \"wizard_step\": \"1\"}"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98818:Expr_L361_C8", "label": "wizard()", "type": "expression", "loc": [361, 361], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98818:FunctionDef_L344_C4", "vector": [8, 2, 0.9972, 0.0028, 2, 0.84, 1.0, 569, 3, 1, 0, 0, 0, 0, 2], "semantic": {"name": "wizard", "arg_names": [], "import_names": [], "rhs_call_name": "wizard", "annotation": ""}, "snippet": " wizard(DummyRequest(POST=data))"}]
[{"f": "ajibawa-2023/Python-Code-Large/train/row_98818:ClassDef_L13_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98818:FunctionDef_L15_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98818:FunctionDef_L15_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98818:Return_L16_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98818:ClassDef_L19_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98818:Assign_L20_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98818:ClassDef_L19_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98818:Assign_L21_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98818:ClassDef_L19_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98818:Assign_L22_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98818:ClassDef_L25_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98818:Expr_L26_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98818:ClassDef_L25_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98818:FunctionDef_L29_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98818:FunctionDef_L29_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98818:Return_L30_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98818:ClassDef_L33_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98818:Assign_L34_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98818:ClassDef_L33_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98818:FunctionDef_L36_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98818:FunctionDef_L36_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98818:Assign_L38_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98818:FunctionDef_L36_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98818:Assign_L39_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98818:FunctionDef_L36_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98818:Assign_L40_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98818:FunctionDef_L36_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98818:Assign_L41_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98818:ClassDef_L33_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98818:FunctionDef_L43_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98818:FunctionDef_L43_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98818:Expr_L44_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98818:FunctionDef_L43_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98818:Expr_L47_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98818:ClassDef_L33_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98818:FunctionDef_L49_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98818:FunctionDef_L49_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98818:Expr_L50_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98818:FunctionDef_L49_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98818:Assign_L59_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98818:FunctionDef_L49_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98818:Assign_L60_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98818:FunctionDef_L49_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98818:Expr_L61_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98818:ClassDef_L33_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98818:FunctionDef_L63_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98818:FunctionDef_L63_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98818:Expr_L64_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98818:FunctionDef_L63_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98818:Expr_L74_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98818:FunctionDef_L63_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98818:Assign_L75_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98818:FunctionDef_L63_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98818:Assign_L77_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98818:FunctionDef_L63_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98818:Expr_L78_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98818:ClassDef_L33_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98818:FunctionDef_L80_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98818:FunctionDef_L80_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98818:Expr_L81_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98818:FunctionDef_L80_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98818:Expr_L92_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98818:FunctionDef_L80_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98818:Assign_L93_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98818:FunctionDef_L80_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98818:Expr_L94_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98818:FunctionDef_L80_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98818:Assign_L95_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98818:FunctionDef_L80_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98818:Expr_L96_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98818:FunctionDef_L80_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98818:Assign_L97_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98818:FunctionDef_L80_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98818:Expr_L98_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98818:ClassDef_L33_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98818:FunctionDef_L100_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98818:FunctionDef_L100_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98818:Expr_L101_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98818:FunctionDef_L100_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98818:Expr_L113_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98818:FunctionDef_L100_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98818:Assign_L114_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98818:FunctionDef_L100_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98818:Expr_L115_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98818:FunctionDef_L100_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98818:Assign_L116_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98818:FunctionDef_L100_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98818:Expr_L117_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98818:ClassDef_L33_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98818:FunctionDef_L119_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98818:FunctionDef_L119_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98818:Expr_L120_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98818:FunctionDef_L119_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98818:Expr_L126_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98818:FunctionDef_L119_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98818:Assign_L127_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98818:FunctionDef_L119_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98818:Expr_L128_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98818:FunctionDef_L119_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98818:Assign_L129_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98818:FunctionDef_L119_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98818:Expr_L130_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98818:FunctionDef_L119_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98818:Assign_L131_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98818:FunctionDef_L119_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98818:Expr_L132_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98818:ClassDef_L33_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98818:FunctionDef_L135_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98818:FunctionDef_L135_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98818:Expr_L136_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98818:FunctionDef_L135_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98818:Expr_L142_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98818:FunctionDef_L135_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98818:Assign_L143_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98818:FunctionDef_L135_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98818:Expr_L144_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98818:FunctionDef_L135_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98818:Expr_L145_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98818:FunctionDef_L135_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98818:Assign_L146_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98818:FunctionDef_L135_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98818:Expr_L147_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98818:FunctionDef_L135_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98818:Assign_L148_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98818:FunctionDef_L135_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98818:Expr_L149_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98818:ClassDef_L152_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98818:FunctionDef_L154_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98818:FunctionDef_L154_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98818:Expr_L155_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98818:FunctionDef_L154_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98818:Assign_L160_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98818:FunctionDef_L154_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98818:Assign_L161_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98818:FunctionDef_L154_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98818:Assign_L162_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98818:FunctionDef_L154_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98818:Assign_L163_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98818:FunctionDef_L154_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98818:Expr_L164_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98818:ClassDef_L152_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98818:FunctionDef_L166_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98818:FunctionDef_L166_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98818:Expr_L167_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98818:FunctionDef_L166_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98818:Assign_L171_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98818:FunctionDef_L166_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98818:Assign_L172_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98818:FunctionDef_L166_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98818:Assign_L173_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98818:FunctionDef_L166_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98818:Assign_L174_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98818:FunctionDef_L166_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98818:Expr_L175_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98818:ClassDef_L178_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98818:Expr_L179_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98818:ClassDef_L178_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98818:FunctionDef_L183_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98818:FunctionDef_L183_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98818:Expr_L184_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98818:FunctionDef_L183_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98818:Assign_L189_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98818:FunctionDef_L183_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98818:Assign_L190_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98818:FunctionDef_L183_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98818:Assign_L191_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98818:FunctionDef_L183_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98818:Assign_L192_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98818:FunctionDef_L183_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98818:Expr_L193_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98818:ClassDef_L178_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98818:FunctionDef_L195_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98818:FunctionDef_L195_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98818:Expr_L196_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98818:FunctionDef_L195_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98818:Assign_L200_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98818:FunctionDef_L195_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98818:Assign_L201_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98818:FunctionDef_L195_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98818:Assign_L202_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98818:FunctionDef_L195_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98818:Assign_L203_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98818:FunctionDef_L195_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98818:Expr_L204_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98818:ClassDef_L207_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98818:Assign_L208_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98818:ClassDef_L207_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98818:Assign_L209_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98818:ClassDef_L212_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98818:Assign_L213_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98818:ClassDef_L212_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98818:Assign_L214_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98818:ClassDef_L221_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98818:Assign_L222_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98818:ClassDef_L225_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98818:Assign_L226_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98818:ClassDef_L229_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98818:Assign_L230_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98818:ClassDef_L233_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98818:FunctionDef_L235_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98818:FunctionDef_L235_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98818:Return_L236_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98818:ClassDef_L233_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98818:FunctionDef_L238_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98818:FunctionDef_L238_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98818:Return_L239_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98818:ClassDef_L242_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98818:Expr_L243_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98818:ClassDef_L242_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98818:FunctionDef_L246_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98818:FunctionDef_L246_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98818:Return_L247_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98818:ClassDef_L250_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98818:FunctionDef_L252_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98818:FunctionDef_L252_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98818:Expr_L253_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98818:FunctionDef_L252_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98818:Assign_L254_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98818:FunctionDef_L252_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98818:If_L255_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98818:If_L255_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98818:Expr_L256_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98818:FunctionDef_L252_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98818:Assign_L257_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98818:ClassDef_L260_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98818:Assign_L261_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98818:ClassDef_L260_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98818:FunctionDef_L263_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98818:FunctionDef_L263_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98818:Assign_L264_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98818:FunctionDef_L263_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98818:Assign_L265_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98818:FunctionDef_L263_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98818:Assign_L272_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98818:FunctionDef_L263_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98818:Assign_L273_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98818:ClassDef_L260_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98818:FunctionDef_L275_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98818:FunctionDef_L275_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98818:Assign_L276_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98818:FunctionDef_L275_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98818:Assign_L277_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98818:ClassDef_L260_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98818:FunctionDef_L279_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98818:FunctionDef_L279_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98818:Expr_L280_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98818:FunctionDef_L279_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98818:Assign_L283_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98818:FunctionDef_L279_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98818:Expr_L284_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98818:ClassDef_L260_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98818:FunctionDef_L286_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98818:FunctionDef_L286_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98818:Expr_L287_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98818:FunctionDef_L286_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98818:Assign_L290_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98818:FunctionDef_L286_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98818:Expr_L291_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98818:ClassDef_L260_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98818:FunctionDef_L293_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98818:FunctionDef_L293_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98818:Expr_L294_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98818:FunctionDef_L293_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98818:Assign_L297_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98818:FunctionDef_L293_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98818:Expr_L301_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98818:ClassDef_L260_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98818:FunctionDef_L303_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98818:FunctionDef_L303_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98818:Expr_L304_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98818:FunctionDef_L303_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98818:Assign_L310_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98818:FunctionDef_L303_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98818:Assign_L314_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98818:FunctionDef_L303_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98818:Expr_L315_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98818:ClassDef_L260_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98818:FunctionDef_L317_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98818:FunctionDef_L317_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98818:Expr_L318_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98818:FunctionDef_L317_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98818:Assign_L325_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98818:FunctionDef_L317_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98818:Assign_L329_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98818:FunctionDef_L317_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98818:Expr_L330_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98818:ClassDef_L260_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98818:FunctionDef_L332_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98818:FunctionDef_L332_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98818:Expr_L333_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98818:FunctionDef_L332_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98818:Assign_L337_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98818:FunctionDef_L332_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98818:Assign_L341_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98818:FunctionDef_L332_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98818:Expr_L342_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98818:ClassDef_L260_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98818:FunctionDef_L344_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98818:FunctionDef_L344_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98818:Expr_L345_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98818:FunctionDef_L344_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98818:Assign_L348_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98818:FunctionDef_L344_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98818:ClassDef_L350_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98818:ClassDef_L350_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98818:FunctionDef_L351_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98818:FunctionDef_L351_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98818:Expr_L352_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98818:FunctionDef_L344_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98818:Assign_L354_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98818:FunctionDef_L344_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98818:Assign_L357_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98818:FunctionDef_L344_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98818:Expr_L361_C8"}]
""" Formtools Preview application. """ import cPickle as pickle from django.conf import settings from django.http import Http404 from django.shortcuts import render_to_response from django.template.context import RequestContext from django.utils.hashcompat import md5_constructor from django.utils.crypto import constant_time_compare from django.contrib.formtools.utils import security_hash AUTO_ID = 'formtools_%s' # Each form here uses this as its auto_id parameter. class FormPreview(object): preview_template = 'formtools/preview.html' form_template = 'formtools/form.html' # METHODS SUBCLASSES SHOULDN'T OVERRIDE ################################### def __init__(self, form): # form should be a Form class, not an instance. self.form, self.state = form, {} def __call__(self, request, *args, **kwargs): stage = {'1': 'preview', '2': 'post'}.get(request.POST.get(self.unused_name('stage')), 'preview') self.parse_params(*args, **kwargs) try: method = getattr(self, stage + '_' + request.method.lower()) except AttributeError: raise Http404 return method(request) def unused_name(self, name): """ Given a first-choice name, adds an underscore to the name until it reaches a name that isn't claimed by any field in the form. This is calculated rather than being hard-coded so that no field names are off-limits for use in the form. """ while 1: try: f = self.form.base_fields[name] except KeyError: break # This field name isn't being used by the form. name += '_' return name def preview_get(self, request): "Displays the form" f = self.form(auto_id=AUTO_ID) return render_to_response(self.form_template, {'form': f, 'stage_field': self.unused_name('stage'), 'state': self.state}, context_instance=RequestContext(request)) def preview_post(self, request): "Validates the POST data. If valid, displays the preview page. Else, redisplays form." f = self.form(request.POST, auto_id=AUTO_ID) context = {'form': f, 'stage_field': self.unused_name('stage'), 'state': self.state} if f.is_valid(): self.process_preview(request, f, context) context['hash_field'] = self.unused_name('hash') context['hash_value'] = self.security_hash(request, f) return render_to_response(self.preview_template, context, context_instance=RequestContext(request)) else: return render_to_response(self.form_template, context, context_instance=RequestContext(request)) def _check_security_hash(self, token, request, form): expected = self.security_hash(request, form) if constant_time_compare(token, expected): return True else: # Fall back to Django 1.2 method, for compatibility with forms that # are in the middle of being used when the upgrade occurs. However, # we don't want to do this fallback if a subclass has provided their # own security_hash method - because they might have implemented a # more secure method, and this would punch a hole in that. # PendingDeprecationWarning <- left here to remind us that this # compatibility fallback should be removed in Django 1.5 FormPreview_expected = FormPreview.security_hash(self, request, form) if expected == FormPreview_expected: # They didn't override security_hash, do the fallback: old_expected = security_hash(request, form) return constant_time_compare(token, old_expected) else: return False def post_post(self, request): "Validates the POST data. If valid, calls done(). Else, redisplays form." f = self.form(request.POST, auto_id=AUTO_ID) if f.is_valid(): if not self._check_security_hash(request.POST.get(self.unused_name('hash'), ''), request, f): return self.failed_hash(request) # Security hash failed. return self.done(request, f.cleaned_data) else: return render_to_response(self.form_template, {'form': f, 'stage_field': self.unused_name('stage'), 'state': self.state}, context_instance=RequestContext(request)) # METHODS SUBCLASSES MIGHT OVERRIDE IF APPROPRIATE ######################## def parse_params(self, *args, **kwargs): """ Given captured args and kwargs from the URLconf, saves something in self.state and/or raises Http404 if necessary. For example, this URLconf captures a user_id variable: (r'^contact/(?P<user_id>\d{1,6})/$', MyFormPreview(MyForm)), In this case, the kwargs variable in parse_params would be {'user_id': 32} for a request to '/contact/32/'. You can use that user_id to make sure it's a valid user and/or save it for later, for use in done(). """ pass def process_preview(self, request, form, context): """ Given a validated form, performs any extra processing before displaying the preview page, and saves any extra data in context. """ pass def security_hash(self, request, form): """ Calculates the security hash for the given HttpRequest and Form instances. Subclasses may want to take into account request-specific information, such as the IP address. """ return security_hash(request, form) def failed_hash(self, request): "Returns an HttpResponse in the case of an invalid security hash." return self.preview_post(request) # METHODS SUBCLASSES MUST OVERRIDE ######################################## def done(self, request, cleaned_data): """ Does something with the cleaned_data and returns an HttpResponseRedirect. """ raise NotImplementedError('You must define a done() method on your %s subclass.' % self.__class__.__name__)
ajibawa-2023/Python-Code-Large/train/row_98819
70
150
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_98819:Expr_L1_C0", "label": "expression", "type": "expression", "loc": [1, 3], "level": 0, "parent": null, "vector": [8, 0, 0.0133, 0.02, 0, 0.66, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "\"\"\"\nFormtools Preview application.\n\"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98819:Import_L5_C0", "label": "cPickle import pickle", "type": "import", "loc": [5, 5], "level": 0, "parent": null, "vector": [1, 0, 0.0333, 0.0067, 0, 0.66, 0.1, 279, 0, 1, 0, 0, 279, 0, 0], "semantic": {"name": "cPickle", "arg_names": [], "import_names": ["pickle"], "rhs_call_name": "", "annotation": ""}, "snippet": "import cPickle as pickle"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98819:ImportFrom_L7_C0", "label": "from django.conf import settings", "type": "import", "loc": [7, 7], "level": 0, "parent": null, "vector": [1, 0, 0.0467, 0.0067, 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_98819:ImportFrom_L8_C0", "label": "from django.http import Http404", "type": "import", "loc": [8, 8], "level": 0, "parent": null, "vector": [1, 0, 0.0533, 0.0067, 0, 0.66, 0.3, 779, 0, 1, 0, 0, 779, 0, 0], "semantic": {"name": "django.http", "arg_names": [], "import_names": ["Http404"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.http import Http404"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98819:ImportFrom_L9_C0", "label": "from django.shortcuts import render_to_response", "type": "import", "loc": [9, 9], "level": 0, "parent": null, "vector": [1, 0, 0.06, 0.0067, 0, 0.66, 0.4, 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_98819:ImportFrom_L10_C0", "label": "from django.template.context import RequestContext", "type": "import", "loc": [10, 10], "level": 0, "parent": null, "vector": [1, 0, 0.0667, 0.0067, 0, 0.66, 0.5, 925, 0, 1, 0, 0, 925, 0, 0], "semantic": {"name": "django.template.context", "arg_names": [], "import_names": ["RequestContext"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.template.context import RequestContext"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98819:ImportFrom_L11_C0", "label": "from django.utils.hashcompat import md5_constructor", "type": "import", "loc": [11, 11], "level": 0, "parent": null, "vector": [1, 0, 0.0733, 0.0067, 0, 0.66, 0.6, 474, 0, 1, 0, 0, 474, 0, 0], "semantic": {"name": "django.utils.hashcompat", "arg_names": [], "import_names": ["md5_constructor"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.utils.hashcompat import md5_constructor"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98819:ImportFrom_L12_C0", "label": "from django.utils.crypto import constant_time_compare", "type": "import", "loc": [12, 12], "level": 0, "parent": null, "vector": [1, 0, 0.08, 0.0067, 0, 0.66, 0.7, 657, 0, 1, 0, 0, 657, 0, 0], "semantic": {"name": "django.utils.crypto", "arg_names": [], "import_names": ["constant_time_compare"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.utils.crypto import constant_time_compare"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98819:ImportFrom_L13_C0", "label": "from django.contrib.formtools.utils import security_hash", "type": "import", "loc": [13, 13], "level": 0, "parent": null, "vector": [1, 0, 0.0867, 0.0067, 0, 0.66, 0.8, 839, 0, 1, 0, 0, 839, 0, 0], "semantic": {"name": "django.contrib.formtools.utils", "arg_names": [], "import_names": ["security_hash"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.contrib.formtools.utils import security_hash"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98819:Assign_L15_C0", "label": "AUTO_ID =", "type": "assigned_variable", "loc": [15, 15], "level": 0, "parent": null, "vector": [14, 0, 0.1, 0.0067, 0, 0.66, 0.9, 611, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "AUTO_ID", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "AUTO_ID = 'formtools_%s' # Each form here uses this as its auto_id parameter."}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98819:ClassDef_L17_C0", "label": "FormPreview", "type": "class", "loc": [17, 150], "level": 0, "parent": null, "vector": [3, 0, 0.5567, 0.8933, 0, 0.66, 1.0, 804, 0, 12, 0, 0, 186, 0, 39], "semantic": {"name": "FormPreview", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class FormPreview(object):\n preview_template = 'formtools/preview.html'\n form_template = 'formtools/form.html'\n\n # METHODS SUBCLASSES SHOULDN'T OVERRIDE ###################################\n\n def __init__(self, form):\n # form should be a Form class, not an instance."}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98819:Assign_L18_C4", "label": "preview_template =", "type": "assigned_variable", "loc": [18, 18], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98819:ClassDef_L17_C0", "vector": [14, 1, 0.12, 0.0067, 1, 0.02, 0.0, 4, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "preview_template", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " preview_template = 'formtools/preview.html'"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98819:Assign_L19_C4", "label": "form_template =", "type": "assigned_variable", "loc": [19, 19], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98819:ClassDef_L17_C0", "vector": [14, 1, 0.1267, 0.0067, 1, 0.02, 0.0769, 34, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "form_template", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " form_template = 'formtools/form.html'"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98819:FunctionDef_L23_C4", "label": "__init__", "type": "function", "loc": [23, 25], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98819:ClassDef_L17_C0", "vector": [2, 1, 0.16, 0.02, 1, 0.02, 0.1538, 555, 0, 2, 0, 0, 0, 0, 0], "semantic": {"name": "__init__", "arg_names": ["self", "form"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def __init__(self, form):\n # form should be a Form class, not an instance.\n self.form, self.state = form, {}"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98819:Assign_L25_C8", "label": "assign", "type": "assigned_variable", "loc": [25, 25], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98819:FunctionDef_L23_C4", "vector": [14, 2, 0.1667, 0.0067, 2, 0.23, 0.0, 0, 0, 0, 0, 0, 0, 8, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.form, self.state = form, {}"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98819:FunctionDef_L27_C4", "label": "__call__", "type": "function", "loc": [27, 34], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98819:ClassDef_L17_C0", "vector": [2, 1, 0.2033, 0.0533, 1, 0.02, 0.2308, 319, 0, 4, 1, 0, 0, 0, 7], "semantic": {"name": "__call__", "arg_names": ["self", "request", "args", "kwargs"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def __call__(self, request, *args, **kwargs):\n stage = {'1': 'preview', '2': 'post'}.get(request.POST.get(self.unused_name('stage')), 'preview')\n self.parse_params(*args, **kwargs)\n try:\n method = getattr(self, stage + '_' + request.method.lower())\n except AttributeError:\n raise Http404\n return method(request)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98819:Assign_L28_C8", "label": "stage = get()", "type": "assigned_variable", "loc": [28, 28], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98819:FunctionDef_L27_C4", "vector": [14, 2, 0.1867, 0.0067, 2, 0.29, 0.0, 612, 3, 2, 0, 0, 607, 10, 3], "semantic": {"name": "stage", "arg_names": [], "import_names": [], "rhs_call_name": "get", "annotation": ""}, "snippet": " stage = {'1': 'preview', '2': 'post'}.get(request.POST.get(self.unused_name('stage')), 'preview')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98819:Expr_L29_C8", "label": "parse_params()", "type": "expression", "loc": [29, 29], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98819:FunctionDef_L27_C4", "vector": [8, 2, 0.1933, 0.0067, 2, 0.29, 0.3333, 26, 3, 2, 0, 0, 0, 0, 1], "semantic": {"name": "parse_params", "arg_names": [], "import_names": [], "rhs_call_name": "parse_params", "annotation": ""}, "snippet": " self.parse_params(*args, **kwargs)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98819:Try_L30_C8", "label": "try", "type": "try", "loc": [30, 33], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98819:FunctionDef_L27_C4", "vector": [7, 2, 0.21, 0.0267, 2, 0.29, 0.6667, 0, 0, 1, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " try:\n method = getattr(self, stage + '_' + request.method.lower())\n except AttributeError:\n raise Http404"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98819:Assign_L31_C12", "label": "method = getattr()", "type": "assigned_variable", "loc": [31, 31], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98819:Try_L30_C8", "vector": [14, 3, 0.2067, 0.0067, 3, 0.33, 0.0, 445, 3, 2, 0, 0, 121, 10, 2], "semantic": {"name": "method", "arg_names": [], "import_names": [], "rhs_call_name": "getattr", "annotation": ""}, "snippet": " method = getattr(self, stage + '_' + request.method.lower())"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98819:Return_L34_C8", "label": "return", "type": "return", "loc": [34, 34], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98819:FunctionDef_L27_C4", "vector": [13, 2, 0.2267, 0.0067, 2, 0.29, 1.0, 0, 3, 0, 0, 0, 0, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return method(request)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98819:FunctionDef_L36_C4", "label": "unused_name", "type": "function", "loc": [36, 50], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98819:ClassDef_L17_C0", "vector": [2, 1, 0.2867, 0.1, 1, 0.02, 0.3077, 103, 0, 2, 1, 0, 0, 0, 0], "semantic": {"name": "unused_name", "arg_names": ["self", "name"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def unused_name(self, name):\n \"\"\"\n Given a first-choice name, adds an underscore to the name until it\n reaches a name that isn't claimed by any field in the form.\n\n This is calculated rather than being hard-coded so that no field names\n are off-limits for use in the form.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98819:Expr_L37_C8", "label": "expression", "type": "expression", "loc": [37, 43], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98819:FunctionDef_L36_C4", "vector": [8, 2, 0.2667, 0.0467, 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 Given a first-choice name, adds an underscore to the name until it\n reaches a name that isn't claimed by any field in the form.\n\n This is calculated rather than being hard-coded so that no field names\n are off-limits for use in the form.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98819:While_L44_C8", "label": "while", "type": "while", "loc": [44, 49], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98819:FunctionDef_L36_C4", "vector": [5, 2, 0.31, 0.04, 2, 0.89, 0.5, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " while 1:\n try:\n f = self.form.base_fields[name]\n except KeyError:\n break # This field name isn't being used by the form.\n name += '_'"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98819:Try_L45_C12", "label": "try", "type": "try", "loc": [45, 48], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98819:While_L44_C8", "vector": [7, 3, 0.31, 0.0267, 3, 0.24, 0.0, 0, 0, 1, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " try:\n f = self.form.base_fields[name]\n except KeyError:\n break # This field name isn't being used by the form."}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98819:Assign_L46_C16", "label": "f =", "type": "assigned_variable", "loc": [46, 46], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98819:Try_L45_C12", "vector": [14, 4, 0.3067, 0.0067, 4, 0.76, 0.0, 899, 6, 0, 0, 0, 0, 0, 0], "semantic": {"name": "f", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " f = self.form.base_fields[name]"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98819:Return_L50_C8", "label": "return", "type": "return", "loc": [50, 50], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98819:FunctionDef_L36_C4", "vector": [13, 2, 0.3333, 0.0067, 2, 0.89, 1.0, 0, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return name"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98819:FunctionDef_L52_C4", "label": "preview_get", "type": "function", "loc": [52, 57], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98819:ClassDef_L17_C0", "vector": [2, 1, 0.3633, 0.04, 1, 0.02, 0.3846, 332, 0, 2, 1, 0, 0, 0, 4], "semantic": {"name": "preview_get", "arg_names": ["self", "request"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def preview_get(self, request):\n \"Displays the form\"\n f = self.form(auto_id=AUTO_ID)\n return render_to_response(self.form_template,\n {'form': f, 'stage_field': self.unused_name('stage'), 'state': self.state},\n context_instance=RequestContext(request))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98819:Expr_L53_C8", "label": "expression", "type": "expression", "loc": [53, 53], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98819:FunctionDef_L52_C4", "vector": [8, 2, 0.3533, 0.0067, 2, 0.14, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"Displays the form\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98819:Assign_L54_C8", "label": "f = form()", "type": "assigned_variable", "loc": [54, 54], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98819:FunctionDef_L52_C4", "vector": [14, 2, 0.36, 0.0067, 2, 0.14, 0.5, 899, 3, 1, 0, 0, 761, 10, 1], "semantic": {"name": "f", "arg_names": [], "import_names": [], "rhs_call_name": "form", "annotation": ""}, "snippet": " f = self.form(auto_id=AUTO_ID)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98819:Return_L55_C8", "label": "return", "type": "return", "loc": [55, 57], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98819:FunctionDef_L52_C4", "vector": [13, 2, 0.3733, 0.02, 2, 0.14, 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(self.form_template,\n {'form': f, 'stage_field': self.unused_name('stage'), 'state': self.state},\n context_instance=RequestContext(request))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98819:FunctionDef_L59_C4", "label": "preview_post", "type": "function", "loc": [59, 69], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98819:ClassDef_L17_C0", "vector": [2, 1, 0.4267, 0.0733, 1, 0.02, 0.4615, 587, 0, 2, 1, 0, 0, 0, 10], "semantic": {"name": "preview_post", "arg_names": ["self", "request"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def preview_post(self, request):\n \"Validates the POST data. If valid, displays the preview page. Else, redisplays form.\"\n f = self.form(request.POST, auto_id=AUTO_ID)\n context = {'form': f, 'stage_field': self.unused_name('stage'), 'state': self.state}\n if f.is_valid():\n self.process_preview(request, f, context) \n context['hash_field'] = self.unused_name('hash')\n context['hash_value'] = self.security_hash(request, f)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98819:Expr_L60_C8", "label": "expression", "type": "expression", "loc": [60, 60], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98819:FunctionDef_L59_C4", "vector": [8, 2, 0.4, 0.0067, 2, 0.56, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"Validates the POST data. If valid, displays the preview page. Else, redisplays form.\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98819:Assign_L61_C8", "label": "f = form()", "type": "assigned_variable", "loc": [61, 61], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98819:FunctionDef_L59_C4", "vector": [14, 2, 0.4067, 0.0067, 2, 0.56, 0.3333, 899, 3, 2, 0, 0, 761, 10, 1], "semantic": {"name": "f", "arg_names": [], "import_names": [], "rhs_call_name": "form", "annotation": ""}, "snippet": " f = self.form(request.POST, auto_id=AUTO_ID)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98819:Assign_L62_C8", "label": "context =", "type": "assigned_variable", "loc": [62, 62], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98819:FunctionDef_L59_C4", "vector": [14, 2, 0.4133, 0.0067, 2, 0.56, 0.6667, 954, 0, 0, 0, 0, 0, 6, 1], "semantic": {"name": "context", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " context = {'form': f, 'stage_field': self.unused_name('stage'), 'state': self.state}"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98819:If_L63_C8", "label": "if", "type": "if", "loc": [63, 69], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98819:FunctionDef_L59_C4", "vector": [4, 2, 0.44, 0.0467, 2, 0.56, 1.0, 0, 3, 0, 0, 0, 0, 0, 8], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if f.is_valid():\n self.process_preview(request, f, context) \n context['hash_field'] = self.unused_name('hash')\n context['hash_value'] = self.security_hash(request, f)\n return render_to_response(self.preview_template, context, context_instance=RequestContext(request))\n else:\n return render_to_response(self.form_template, context, context_instance=RequestContext(request))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98819:Expr_L64_C12", "label": "process_preview()", "type": "expression", "loc": [64, 64], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98819:If_L63_C8", "vector": [8, 3, 0.4267, 0.0067, 3, 0.36, 0.0, 679, 3, 3, 0, 0, 0, 0, 1], "semantic": {"name": "process_preview", "arg_names": [], "import_names": [], "rhs_call_name": "process_preview", "annotation": ""}, "snippet": " self.process_preview(request, f, context) "}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98819:Assign_L65_C12", "label": " = unused_name()", "type": "assigned_variable", "loc": [65, 65], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98819:If_L63_C8", "vector": [14, 3, 0.4333, 0.0067, 3, 0.36, 0.25, 0, 3, 1, 0, 0, 103, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "unused_name", "annotation": ""}, "snippet": " context['hash_field'] = self.unused_name('hash')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98819:Assign_L66_C12", "label": " = security_hash()", "type": "assigned_variable", "loc": [66, 66], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98819:If_L63_C8", "vector": [14, 3, 0.44, 0.0067, 3, 0.36, 0.5, 0, 3, 2, 0, 0, 234, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "security_hash", "annotation": ""}, "snippet": " context['hash_value'] = self.security_hash(request, f)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98819:Return_L67_C12", "label": "return", "type": "return", "loc": [67, 67], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98819:If_L63_C8", "vector": [13, 3, 0.4467, 0.0067, 3, 0.36, 0.75, 0, 3, 0, 0, 0, 0, 10, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return render_to_response(self.preview_template, context, context_instance=RequestContext(request))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98819:Return_L69_C12", "label": "return", "type": "return", "loc": [69, 69], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98819:If_L63_C8", "vector": [13, 3, 0.46, 0.0067, 3, 0.36, 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.form_template, context, context_instance=RequestContext(request))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98819:FunctionDef_L71_C4", "label": "_check_security_hash", "type": "function", "loc": [71, 90], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98819:ClassDef_L17_C0", "vector": [2, 1, 0.5367, 0.1333, 1, 0.02, 0.5385, 266, 0, 4, 1, 0, 0, 0, 5], "semantic": {"name": "_check_security_hash", "arg_names": ["self", "token", "request", "form"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def _check_security_hash(self, token, request, form):\n expected = self.security_hash(request, form)\n if constant_time_compare(token, expected):\n return True\n else:\n # Fall back to Django 1.2 method, for compatibility with forms that\n # are in the middle of being used when the upgrade occurs. However,\n # we don't want to do this fallback if a subclass has provided their"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98819:Assign_L72_C8", "label": "expected = security_hash()", "type": "assigned_variable", "loc": [72, 72], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98819:FunctionDef_L71_C4", "vector": [14, 2, 0.48, 0.0067, 2, 0.82, 0.0, 361, 3, 2, 0, 0, 234, 10, 1], "semantic": {"name": "expected", "arg_names": [], "import_names": [], "rhs_call_name": "security_hash", "annotation": ""}, "snippet": " expected = self.security_hash(request, form)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98819:If_L73_C8", "label": "if", "type": "if", "loc": [73, 90], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98819:FunctionDef_L71_C4", "vector": [4, 2, 0.5433, 0.12, 2, 0.82, 1.0, 0, 3, 0, 0, 0, 0, 0, 4], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if constant_time_compare(token, expected):\n return True\n else:\n # Fall back to Django 1.2 method, for compatibility with forms that\n # are in the middle of being used when the upgrade occurs. However,\n # we don't want to do this fallback if a subclass has provided their\n # own security_hash method - because they might have implemented a\n # more secure method, and this would punch a hole in that."}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98819:Return_L74_C12", "label": "return", "type": "return", "loc": [74, 74], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98819:If_L73_C8", "vector": [13, 3, 0.4933, 0.0067, 3, 0.15, 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_98819:Assign_L84_C12", "label": "FormPreview_expected = security_hash()", "type": "assigned_variable", "loc": [84, 84], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98819:If_L73_C8", "vector": [14, 3, 0.56, 0.0067, 3, 0.15, 0.5, 702, 3, 3, 0, 0, 234, 10, 1], "semantic": {"name": "FormPreview_expected", "arg_names": [], "import_names": [], "rhs_call_name": "security_hash", "annotation": ""}, "snippet": " FormPreview_expected = FormPreview.security_hash(self, request, form)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98819:If_L85_C12", "label": "if", "type": "if", "loc": [85, 90], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98819:If_L73_C8", "vector": [4, 3, 0.5833, 0.04, 3, 0.15, 1.0, 0, 0, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if expected == FormPreview_expected:\n # They didn't override security_hash, do the fallback:\n old_expected = security_hash(request, form)\n return constant_time_compare(token, old_expected)\n else:\n return False"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98819:Assign_L87_C16", "label": "old_expected = security_hash()", "type": "assigned_variable", "loc": [87, 87], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98819:If_L85_C12", "vector": [14, 4, 0.58, 0.0067, 4, 0.05, 0.0, 644, 3, 2, 0, 0, 234, 10, 1], "semantic": {"name": "old_expected", "arg_names": [], "import_names": [], "rhs_call_name": "security_hash", "annotation": ""}, "snippet": " old_expected = security_hash(request, form)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98819:Return_L88_C16", "label": "return", "type": "return", "loc": [88, 88], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98819:If_L85_C12", "vector": [13, 4, 0.5867, 0.0067, 4, 0.05, 0.5, 0, 3, 0, 0, 0, 0, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return constant_time_compare(token, old_expected)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98819:Return_L90_C16", "label": "return", "type": "return", "loc": [90, 90], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98819:If_L85_C12", "vector": [13, 4, 0.6, 0.0067, 4, 0.05, 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_98819:FunctionDef_L92_C4", "label": "post_post", "type": "function", "loc": [92, 103], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98819:ClassDef_L17_C0", "vector": [2, 1, 0.65, 0.08, 1, 0.02, 0.6154, 511, 0, 2, 1, 0, 0, 0, 10], "semantic": {"name": "post_post", "arg_names": ["self", "request"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def post_post(self, request):\n \"Validates the POST data. If valid, calls done(). Else, redisplays form.\"\n f = self.form(request.POST, auto_id=AUTO_ID)\n if f.is_valid():\n if not self._check_security_hash(request.POST.get(self.unused_name('hash'), ''),\n request, f):\n return self.failed_hash(request) # Security hash failed.\n return self.done(request, f.cleaned_data)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98819:Expr_L93_C8", "label": "expression", "type": "expression", "loc": [93, 93], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98819:FunctionDef_L92_C4", "vector": [8, 2, 0.62, 0.0067, 2, 0.08, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"Validates the POST data. If valid, calls done(). Else, redisplays form.\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98819:Assign_L94_C8", "label": "f = form()", "type": "assigned_variable", "loc": [94, 94], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98819:FunctionDef_L92_C4", "vector": [14, 2, 0.6267, 0.0067, 2, 0.08, 0.5, 899, 3, 2, 0, 0, 761, 10, 1], "semantic": {"name": "f", "arg_names": [], "import_names": [], "rhs_call_name": "form", "annotation": ""}, "snippet": " f = self.form(request.POST, auto_id=AUTO_ID)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98819:If_L95_C8", "label": "if", "type": "if", "loc": [95, 103], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98819:FunctionDef_L92_C4", "vector": [4, 2, 0.66, 0.06, 2, 0.08, 1.0, 0, 3, 0, 0, 0, 0, 0, 9], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if f.is_valid():\n if not self._check_security_hash(request.POST.get(self.unused_name('hash'), ''),\n request, f):\n return self.failed_hash(request) # Security hash failed.\n return self.done(request, f.cleaned_data)\n else:\n return render_to_response(self.form_template,\n {'form': f, 'stage_field': self.unused_name('stage'), 'state': self.state},"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98819:If_L96_C12", "label": "if", "type": "if", "loc": [96, 98], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98819:If_L95_C8", "vector": [4, 3, 0.6467, 0.02, 3, 0.08, 0.0, 0, 0, 0, 0, 0, 0, 0, 4], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if not self._check_security_hash(request.POST.get(self.unused_name('hash'), ''),\n request, f):\n return self.failed_hash(request) # Security hash failed."}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98819:Return_L98_C16", "label": "return", "type": "return", "loc": [98, 98], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98819:If_L96_C12", "vector": [13, 4, 0.6533, 0.0067, 4, 0.01, 0.0, 0, 3, 0, 0, 0, 0, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return self.failed_hash(request) # Security hash failed."}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98819:Return_L99_C12", "label": "return", "type": "return", "loc": [99, 99], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98819:If_L95_C8", "vector": [13, 3, 0.66, 0.0067, 3, 0.08, 0.5, 0, 3, 0, 0, 0, 0, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return self.done(request, f.cleaned_data)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98819:Return_L101_C12", "label": "return", "type": "return", "loc": [101, 103], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98819:If_L95_C8", "vector": [13, 3, 0.68, 0.02, 3, 0.08, 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(self.form_template,\n {'form': f, 'stage_field': self.unused_name('stage'), 'state': self.state},\n context_instance=RequestContext(request))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98819:FunctionDef_L107_C4", "label": "parse_params", "type": "function", "loc": [107, 121], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98819:ClassDef_L17_C0", "vector": [2, 1, 0.76, 0.1, 1, 0.02, 0.6923, 26, 0, 3, 0, 0, 0, 0, 0], "semantic": {"name": "parse_params", "arg_names": ["self", "args", "kwargs"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def parse_params(self, *args, **kwargs):\n \"\"\"\n Given captured args and kwargs from the URLconf, saves something in\n self.state and/or raises Http404 if necessary.\n\n For example, this URLconf captures a user_id variable:\n\n (r'^contact/(?P<user_id>\\d{1,6})/$', MyFormPreview(MyForm)),"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98819:Expr_L108_C8", "label": "expression", "type": "expression", "loc": [108, 120], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98819:FunctionDef_L107_C4", "vector": [8, 2, 0.76, 0.0867, 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 Given captured args and kwargs from the URLconf, saves something in\n self.state and/or raises Http404 if necessary.\n\n For example, this URLconf captures a user_id variable:\n\n (r'^contact/(?P<user_id>\\d{1,6})/$', MyFormPreview(MyForm)),\n"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98819:FunctionDef_L123_C4", "label": "process_preview", "type": "function", "loc": [123, 128], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98819:ClassDef_L17_C0", "vector": [2, 1, 0.8367, 0.04, 1, 0.02, 0.7692, 679, 0, 4, 0, 0, 0, 0, 0], "semantic": {"name": "process_preview", "arg_names": ["self", "request", "form", "context"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def process_preview(self, request, form, context):\n \"\"\"\n Given a validated form, performs any extra processing before displaying\n the preview page, and saves any extra data in context.\n \"\"\"\n pass"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98819:Expr_L124_C8", "label": "expression", "type": "expression", "loc": [124, 127], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98819:FunctionDef_L123_C4", "vector": [8, 2, 0.8367, 0.0267, 2, 0.98, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"\n Given a validated form, performs any extra processing before displaying\n the preview page, and saves any extra data in context.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98819:FunctionDef_L130_C4", "label": "security_hash", "type": "function", "loc": [130, 137], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98819:ClassDef_L17_C0", "vector": [2, 1, 0.89, 0.0533, 1, 0.02, 0.8462, 234, 0, 3, 1, 0, 0, 0, 1], "semantic": {"name": "security_hash", "arg_names": ["self", "request", "form"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def security_hash(self, request, form):\n \"\"\"\n Calculates the security hash for the given HttpRequest and Form instances.\n\n Subclasses may want to take into account request-specific information,\n such as the IP address.\n \"\"\"\n return security_hash(request, form)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98819:Expr_L131_C8", "label": "expression", "type": "expression", "loc": [131, 136], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98819:FunctionDef_L130_C4", "vector": [8, 2, 0.89, 0.04, 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 Calculates the security hash for the given HttpRequest and Form instances.\n\n Subclasses may want to take into account request-specific information,\n such as the IP address.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98819:Return_L137_C8", "label": "return", "type": "return", "loc": [137, 137], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98819:FunctionDef_L130_C4", "vector": [13, 2, 0.9133, 0.0067, 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 security_hash(request, form)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98819:FunctionDef_L139_C4", "label": "failed_hash", "type": "function", "loc": [139, 141], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98819:ClassDef_L17_C0", "vector": [2, 1, 0.9333, 0.02, 1, 0.02, 0.9231, 940, 0, 2, 1, 0, 0, 0, 1], "semantic": {"name": "failed_hash", "arg_names": ["self", "request"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def failed_hash(self, request):\n \"Returns an HttpResponse in the case of an invalid security hash.\"\n return self.preview_post(request)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98819:Expr_L140_C8", "label": "expression", "type": "expression", "loc": [140, 140], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98819:FunctionDef_L139_C4", "vector": [8, 2, 0.9333, 0.0067, 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 an HttpResponse in the case of an invalid security hash.\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98819:Return_L141_C8", "label": "return", "type": "return", "loc": [141, 141], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98819:FunctionDef_L139_C4", "vector": [13, 2, 0.94, 0.0067, 2, 0.72, 1.0, 0, 3, 0, 0, 0, 0, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return self.preview_post(request)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98819:FunctionDef_L145_C4", "label": "done", "type": "function", "loc": [145, 150], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98819:ClassDef_L17_C0", "vector": [2, 1, 0.9833, 0.04, 1, 0.02, 1.0, 151, 0, 3, 0, 0, 0, 0, 1], "semantic": {"name": "done", "arg_names": ["self", "request", "cleaned_data"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def done(self, request, cleaned_data):\n \"\"\"\n Does something with the cleaned_data and returns an\n HttpResponseRedirect.\n \"\"\"\n raise NotImplementedError('You must define a done() method on your %s subclass.' % self.__class__.__name__)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98819:Expr_L146_C8", "label": "expression", "type": "expression", "loc": [146, 149], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98819:FunctionDef_L145_C4", "vector": [8, 2, 0.9833, 0.0267, 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 Does something with the cleaned_data and returns an\n HttpResponseRedirect.\n \"\"\""}]
[{"f": "ajibawa-2023/Python-Code-Large/train/row_98819:ClassDef_L17_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98819:Assign_L18_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98819:ClassDef_L17_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98819:Assign_L19_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98819:ClassDef_L17_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98819:FunctionDef_L23_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98819:FunctionDef_L23_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98819:Assign_L25_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98819:ClassDef_L17_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98819:FunctionDef_L27_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98819:FunctionDef_L27_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98819:Assign_L28_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98819:FunctionDef_L27_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98819:Expr_L29_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98819:FunctionDef_L27_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98819:Try_L30_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98819:Try_L30_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98819:Assign_L31_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98819:FunctionDef_L27_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98819:Return_L34_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98819:ClassDef_L17_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98819:FunctionDef_L36_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98819:FunctionDef_L36_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98819:Expr_L37_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98819:FunctionDef_L36_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98819:While_L44_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98819:While_L44_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98819:Try_L45_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98819:Try_L45_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98819:Assign_L46_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98819:FunctionDef_L36_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98819:Return_L50_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98819:ClassDef_L17_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98819:FunctionDef_L52_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98819:FunctionDef_L52_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98819:Expr_L53_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98819:FunctionDef_L52_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98819:Assign_L54_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98819:FunctionDef_L52_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98819:Return_L55_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98819:ClassDef_L17_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98819:FunctionDef_L59_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98819:FunctionDef_L59_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98819:Expr_L60_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98819:FunctionDef_L59_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98819:Assign_L61_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98819:FunctionDef_L59_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98819:Assign_L62_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98819:FunctionDef_L59_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98819:If_L63_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98819:If_L63_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98819:Expr_L64_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98819:If_L63_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98819:Assign_L65_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98819:If_L63_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98819:Assign_L66_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98819:If_L63_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98819:Return_L67_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98819:If_L63_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98819:Return_L69_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98819:ClassDef_L17_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98819:FunctionDef_L71_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98819:FunctionDef_L71_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98819:Assign_L72_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98819:FunctionDef_L71_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98819:If_L73_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98819:If_L73_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98819:Return_L74_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98819:If_L73_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98819:Assign_L84_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98819:If_L73_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98819:If_L85_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98819:If_L85_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98819:Assign_L87_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98819:If_L85_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98819:Return_L88_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98819:If_L85_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98819:Return_L90_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98819:ClassDef_L17_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98819:FunctionDef_L92_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98819:FunctionDef_L92_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98819:Expr_L93_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98819:FunctionDef_L92_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98819:Assign_L94_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98819:FunctionDef_L92_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98819:If_L95_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98819:If_L95_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98819:If_L96_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98819:If_L96_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98819:Return_L98_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98819:If_L95_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98819:Return_L99_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98819:If_L95_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98819:Return_L101_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98819:ClassDef_L17_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98819:FunctionDef_L107_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98819:FunctionDef_L107_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98819:Expr_L108_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98819:ClassDef_L17_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98819:FunctionDef_L123_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98819:FunctionDef_L123_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98819:Expr_L124_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98819:ClassDef_L17_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98819:FunctionDef_L130_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98819:FunctionDef_L130_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98819:Expr_L131_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98819:FunctionDef_L130_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98819:Return_L137_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98819:ClassDef_L17_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98819:FunctionDef_L139_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98819:FunctionDef_L139_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98819:Expr_L140_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98819:FunctionDef_L139_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98819:Return_L141_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98819:ClassDef_L17_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98819:FunctionDef_L145_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98819:FunctionDef_L145_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98819:Expr_L146_C8"}]
try: import cPickle as pickle except ImportError: import pickle from django.conf import settings from django.forms import BooleanField from django.utils.crypto import salted_hmac from django.utils.hashcompat import md5_constructor def security_hash(request, form, *args): """ Calculates a security hash for the given Form instance. This creates a list of the form field names/values in a deterministic order, pickles the result with the SECRET_KEY setting, then takes an md5 hash of that. """ import warnings warnings.warn("security_hash is deprecated; use form_hmac instead", PendingDeprecationWarning) data = [] for bf in form: # Get the value from the form data. If the form allows empty or hasn't # changed then don't call clean() to avoid trigger validation errors. if form.empty_permitted and not form.has_changed(): value = bf.data or '' else: value = bf.field.clean(bf.data) or '' if isinstance(value, basestring): value = value.strip() data.append((bf.name, value)) data.extend(args) data.append(settings.SECRET_KEY) # Use HIGHEST_PROTOCOL because it's the most efficient. It requires # Python 2.3, but Django requires 2.4 anyway, so that's OK. pickled = pickle.dumps(data, pickle.HIGHEST_PROTOCOL) return md5_constructor(pickled).hexdigest() def form_hmac(form): """ Calculates a security hash for the given Form instance. """ data = [] for bf in form: # Get the value from the form data. If the form allows empty or hasn't # changed then don't call clean() to avoid trigger validation errors. if form.empty_permitted and not form.has_changed(): value = bf.data or '' else: value = bf.field.clean(bf.data) or '' if isinstance(value, basestring): value = value.strip() data.append((bf.name, value)) pickled = pickle.dumps(data, pickle.HIGHEST_PROTOCOL) key_salt = 'django.contrib.formtools' return salted_hmac(key_salt, pickled).hexdigest()
ajibawa-2023/Python-Code-Large/train/row_98820
36
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_98820:Try_L1_C0", "label": "try", "type": "try", "loc": [1, 4], "level": 0, "parent": null, "vector": [7, 0, 0.0397, 0.0635, 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 import cPickle as pickle\nexcept ImportError:\n import pickle"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98820:Import_L2_C4", "label": "cPickle import pickle", "type": "import", "loc": [2, 2], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98820:Try_L1_C0", "vector": [1, 1, 0.0317, 0.0159, 1, 0.06, 0.0, 279, 0, 1, 0, 0, 279, 0, 0], "semantic": {"name": "cPickle", "arg_names": [], "import_names": ["pickle"], "rhs_call_name": "", "annotation": ""}, "snippet": " import cPickle as pickle"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98820:Import_L4_C4", "label": "pickle import pickle", "type": "import", "loc": [4, 4], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98820:Try_L1_C0", "vector": [1, 1, 0.0635, 0.0159, 1, 0.06, 0.0, 848, 0, 1, 0, 0, 848, 0, 0], "semantic": {"name": "pickle", "arg_names": [], "import_names": ["pickle"], "rhs_call_name": "", "annotation": ""}, "snippet": " import pickle"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98820:ImportFrom_L6_C0", "label": "from django.conf import settings", "type": "import", "loc": [6, 6], "level": 0, "parent": null, "vector": [1, 0, 0.0952, 0.0159, 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_98820:ImportFrom_L7_C0", "label": "from django.forms import BooleanField", "type": "import", "loc": [7, 7], "level": 0, "parent": null, "vector": [1, 0, 0.1111, 0.0159, 0, 0.66, 0.3333, 666, 0, 1, 0, 0, 666, 0, 0], "semantic": {"name": "django.forms", "arg_names": [], "import_names": ["BooleanField"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.forms import BooleanField"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98820:ImportFrom_L8_C0", "label": "from django.utils.crypto import salted_hmac", "type": "import", "loc": [8, 8], "level": 0, "parent": null, "vector": [1, 0, 0.127, 0.0159, 0, 0.66, 0.5, 657, 0, 1, 0, 0, 657, 0, 0], "semantic": {"name": "django.utils.crypto", "arg_names": [], "import_names": ["salted_hmac"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.utils.crypto import salted_hmac"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98820:ImportFrom_L9_C0", "label": "from django.utils.hashcompat import md5_constructor", "type": "import", "loc": [9, 9], "level": 0, "parent": null, "vector": [1, 0, 0.1429, 0.0159, 0, 0.66, 0.6667, 474, 0, 1, 0, 0, 474, 0, 0], "semantic": {"name": "django.utils.hashcompat", "arg_names": [], "import_names": ["md5_constructor"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.utils.hashcompat import md5_constructor"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98820:FunctionDef_L12_C0", "label": "security_hash", "type": "function", "loc": [12, 42], "level": 0, "parent": null, "vector": [2, 0, 0.4286, 0.4921, 0, 0.66, 0.8333, 234, 0, 3, 1, 0, 0, 0, 11], "semantic": {"name": "security_hash", "arg_names": ["request", "form", "args"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "def security_hash(request, form, *args):\n \"\"\"\n Calculates a security hash for the given Form instance.\n\n This creates a list of the form field names/values in a deterministic\n order, pickles the result with the SECRET_KEY setting, then takes an md5\n hash of that.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98820:Expr_L13_C4", "label": "expression", "type": "expression", "loc": [13, 19], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98820:FunctionDef_L12_C0", "vector": [8, 1, 0.254, 0.1111, 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 Calculates a security hash for the given Form instance.\n\n This creates a list of the form field names/values in a deterministic\n order, pickles the result with the SECRET_KEY setting, then takes an md5\n hash of that.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98820:Import_L20_C4", "label": "warnings import warnings", "type": "import", "loc": [20, 20], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98820:FunctionDef_L12_C0", "vector": [1, 1, 0.3175, 0.0159, 1, 0.4, 0.125, 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_98820:Expr_L21_C4", "label": "warn()", "type": "expression", "loc": [21, 22], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98820:FunctionDef_L12_C0", "vector": [8, 1, 0.3413, 0.0317, 1, 0.4, 0.25, 960, 3, 2, 0, 0, 0, 0, 1], "semantic": {"name": "warn", "arg_names": [], "import_names": [], "rhs_call_name": "warn", "annotation": ""}, "snippet": " warnings.warn(\"security_hash is deprecated; use form_hmac instead\",\n PendingDeprecationWarning)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98820:Assign_L23_C4", "label": "data =", "type": "assigned_variable", "loc": [23, 23], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98820:FunctionDef_L12_C0", "vector": [14, 1, 0.3651, 0.0159, 1, 0.4, 0.375, 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_98820:For_L24_C4", "label": "for bf", "type": "for", "loc": [24, 33], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98820:FunctionDef_L12_C0", "vector": [6, 1, 0.4524, 0.1587, 1, 0.4, 0.5, 635, 2, 0, 0, 0, 0, 0, 5], "semantic": {"name": "bf", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for bf in form:\n # Get the value from the form data. If the form allows empty or hasn't\n # changed then don't call clean() to avoid trigger validation errors.\n if form.empty_permitted and not form.has_changed():\n value = bf.data or ''\n else:\n value = bf.field.clean(bf.data) or ''\n if isinstance(value, basestring):"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98820:If_L27_C8", "label": "if", "type": "if", "loc": [27, 30], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98820:For_L24_C4", "vector": [4, 2, 0.4524, 0.0635, 2, 0.86, 0.0, 0, 0, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if form.empty_permitted and not form.has_changed():\n value = bf.data or ''\n else:\n value = bf.field.clean(bf.data) or ''"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98820:Assign_L28_C12", "label": "value =", "type": "assigned_variable", "loc": [28, 28], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98820:If_L27_C8", "vector": [14, 3, 0.4444, 0.0159, 3, 0.56, 0.0, 441, 0, 0, 0, 0, 0, 0, 0], "semantic": {"name": "value", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " value = bf.data or ''"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98820:Assign_L30_C12", "label": "value =", "type": "assigned_variable", "loc": [30, 30], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98820:If_L27_C8", "vector": [14, 3, 0.4762, 0.0159, 3, 0.56, 1.0, 441, 0, 0, 0, 0, 0, 0, 1], "semantic": {"name": "value", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " value = bf.field.clean(bf.data) or ''"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98820:If_L31_C8", "label": "if", "type": "if", "loc": [31, 32], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98820:For_L24_C4", "vector": [4, 2, 0.5, 0.0317, 2, 0.86, 0.5, 0, 3, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if isinstance(value, basestring):\n value = value.strip()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98820:Assign_L32_C12", "label": "value = strip()", "type": "assigned_variable", "loc": [32, 32], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98820:If_L31_C8", "vector": [14, 3, 0.5079, 0.0159, 3, 0.71, 0.0, 441, 3, 0, 0, 0, 973, 10, 1], "semantic": {"name": "value", "arg_names": [], "import_names": [], "rhs_call_name": "strip", "annotation": ""}, "snippet": " value = value.strip()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98820:Expr_L33_C8", "label": "append()", "type": "expression", "loc": [33, 33], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98820:For_L24_C4", "vector": [8, 2, 0.5238, 0.0159, 2, 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": " data.append((bf.name, value))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98820:Expr_L35_C4", "label": "extend()", "type": "expression", "loc": [35, 35], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98820:FunctionDef_L12_C0", "vector": [8, 1, 0.5556, 0.0159, 1, 0.4, 0.625, 660, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "extend", "arg_names": [], "import_names": [], "rhs_call_name": "extend", "annotation": ""}, "snippet": " data.extend(args)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98820:Expr_L36_C4", "label": "append()", "type": "expression", "loc": [36, 36], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98820:FunctionDef_L12_C0", "vector": [8, 1, 0.5714, 0.0159, 1, 0.4, 0.75, 243, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "append", "arg_names": [], "import_names": [], "rhs_call_name": "append", "annotation": ""}, "snippet": " data.append(settings.SECRET_KEY)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98820:Assign_L40_C4", "label": "pickled = dumps()", "type": "assigned_variable", "loc": [40, 40], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98820:FunctionDef_L12_C0", "vector": [14, 1, 0.6349, 0.0159, 1, 0.4, 0.875, 271, 3, 2, 0, 0, 160, 10, 1], "semantic": {"name": "pickled", "arg_names": [], "import_names": [], "rhs_call_name": "dumps", "annotation": ""}, "snippet": " pickled = pickle.dumps(data, pickle.HIGHEST_PROTOCOL)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98820:Return_L42_C4", "label": "return", "type": "return", "loc": [42, 42], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98820:FunctionDef_L12_C0", "vector": [13, 1, 0.6667, 0.0159, 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 md5_constructor(pickled).hexdigest()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98820:FunctionDef_L45_C0", "label": "form_hmac", "type": "function", "loc": [45, 63], "level": 0, "parent": null, "vector": [2, 0, 0.8571, 0.3016, 0, 0.66, 1.0, 352, 0, 1, 1, 0, 0, 0, 8], "semantic": {"name": "form_hmac", "arg_names": ["form"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "def form_hmac(form):\n \"\"\"\n Calculates a security hash for the given Form instance.\n \"\"\"\n data = []\n for bf in form:\n # Get the value from the form data. If the form allows empty or hasn't\n # changed then don't call clean() to avoid trigger validation errors."}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98820:Expr_L46_C4", "label": "expression", "type": "expression", "loc": [46, 48], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98820:FunctionDef_L45_C0", "vector": [8, 1, 0.746, 0.0476, 1, 0.96, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"\n Calculates a security hash for the given Form instance.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98820:Assign_L49_C4", "label": "data =", "type": "assigned_variable", "loc": [49, 49], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98820:FunctionDef_L45_C0", "vector": [14, 1, 0.7778, 0.0159, 1, 0.96, 0.2, 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_98820:For_L50_C4", "label": "for bf", "type": "for", "loc": [50, 59], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98820:FunctionDef_L45_C0", "vector": [6, 1, 0.8651, 0.1587, 1, 0.96, 0.4, 635, 2, 0, 0, 0, 0, 0, 5], "semantic": {"name": "bf", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for bf in form:\n # Get the value from the form data. If the form allows empty or hasn't\n # changed then don't call clean() to avoid trigger validation errors.\n if form.empty_permitted and not form.has_changed():\n value = bf.data or ''\n else:\n value = bf.field.clean(bf.data) or ''\n if isinstance(value, basestring):"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98820:If_L53_C8", "label": "if", "type": "if", "loc": [53, 56], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98820:For_L50_C4", "vector": [4, 2, 0.8651, 0.0635, 2, 0.26, 0.0, 0, 0, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if form.empty_permitted and not form.has_changed():\n value = bf.data or ''\n else:\n value = bf.field.clean(bf.data) or ''"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98820:Assign_L54_C12", "label": "value =", "type": "assigned_variable", "loc": [54, 54], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98820:If_L53_C8", "vector": [14, 3, 0.8571, 0.0159, 3, 0.69, 0.0, 441, 0, 0, 0, 0, 0, 0, 0], "semantic": {"name": "value", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " value = bf.data or ''"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98820:Assign_L56_C12", "label": "value =", "type": "assigned_variable", "loc": [56, 56], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98820:If_L53_C8", "vector": [14, 3, 0.8889, 0.0159, 3, 0.69, 1.0, 441, 0, 0, 0, 0, 0, 0, 1], "semantic": {"name": "value", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " value = bf.field.clean(bf.data) or ''"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98820:If_L57_C8", "label": "if", "type": "if", "loc": [57, 58], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98820:For_L50_C4", "vector": [4, 2, 0.9127, 0.0317, 2, 0.26, 0.5, 0, 3, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if isinstance(value, basestring):\n value = value.strip()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98820:Assign_L58_C12", "label": "value = strip()", "type": "assigned_variable", "loc": [58, 58], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98820:If_L57_C8", "vector": [14, 3, 0.9206, 0.0159, 3, 0.72, 0.0, 441, 3, 0, 0, 0, 973, 10, 1], "semantic": {"name": "value", "arg_names": [], "import_names": [], "rhs_call_name": "strip", "annotation": ""}, "snippet": " value = value.strip()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98820:Expr_L59_C8", "label": "append()", "type": "expression", "loc": [59, 59], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98820:For_L50_C4", "vector": [8, 2, 0.9365, 0.0159, 2, 0.26, 1.0, 243, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "append", "arg_names": [], "import_names": [], "rhs_call_name": "append", "annotation": ""}, "snippet": " data.append((bf.name, value))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98820:Assign_L61_C4", "label": "pickled = dumps()", "type": "assigned_variable", "loc": [61, 61], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98820:FunctionDef_L45_C0", "vector": [14, 1, 0.9683, 0.0159, 1, 0.96, 0.6, 271, 3, 2, 0, 0, 160, 10, 1], "semantic": {"name": "pickled", "arg_names": [], "import_names": [], "rhs_call_name": "dumps", "annotation": ""}, "snippet": " pickled = pickle.dumps(data, pickle.HIGHEST_PROTOCOL)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98820:Assign_L62_C4", "label": "key_salt =", "type": "assigned_variable", "loc": [62, 62], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98820:FunctionDef_L45_C0", "vector": [14, 1, 0.9841, 0.0159, 1, 0.96, 0.8, 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.formtools'"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98820:Return_L63_C4", "label": "return", "type": "return", "loc": [63, 63], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98820:FunctionDef_L45_C0", "vector": [13, 1, 1.0, 0.0159, 1, 0.96, 1.0, 0, 3, 0, 0, 0, 0, 10, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return salted_hmac(key_salt, pickled).hexdigest()"}]
[{"f": "ajibawa-2023/Python-Code-Large/train/row_98820:Try_L1_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98820:Import_L2_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98820:Try_L1_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98820:Import_L4_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98820:FunctionDef_L12_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98820:Expr_L13_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98820:FunctionDef_L12_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98820:Import_L20_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98820:FunctionDef_L12_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98820:Expr_L21_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98820:FunctionDef_L12_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98820:Assign_L23_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98820:FunctionDef_L12_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98820:For_L24_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98820:For_L24_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98820:If_L27_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98820:If_L27_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98820:Assign_L28_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98820:If_L27_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98820:Assign_L30_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98820:For_L24_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98820:If_L31_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98820:If_L31_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98820:Assign_L32_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98820:For_L24_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98820:Expr_L33_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98820:FunctionDef_L12_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98820:Expr_L35_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98820:FunctionDef_L12_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98820:Expr_L36_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98820:FunctionDef_L12_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98820:Assign_L40_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98820:FunctionDef_L12_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98820:Return_L42_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98820:FunctionDef_L45_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98820:Expr_L46_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98820:FunctionDef_L45_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98820:Assign_L49_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98820:FunctionDef_L45_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98820:For_L50_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98820:For_L50_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98820:If_L53_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98820:If_L53_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98820:Assign_L54_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98820:If_L53_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98820:Assign_L56_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98820:For_L50_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98820:If_L57_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98820:If_L57_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98820:Assign_L58_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98820:For_L50_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98820:Expr_L59_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98820:FunctionDef_L45_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98820:Assign_L61_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98820:FunctionDef_L45_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98820:Assign_L62_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98820:FunctionDef_L45_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98820:Return_L63_C4"}]
""" FormWizard class -- implements a multi-page form, validating between each step and storing the form's state as HTML hidden fields so that no state is stored on the server side. """ import cPickle as pickle from django import forms from django.conf import settings from django.contrib.formtools.utils import security_hash, form_hmac from django.http import Http404 from django.shortcuts import render_to_response from django.template.context import RequestContext from django.utils.crypto import constant_time_compare from django.utils.hashcompat import md5_constructor from django.utils.translation import ugettext_lazy as _ from django.utils.decorators import method_decorator from django.views.decorators.csrf import csrf_protect class FormWizard(object): # The HTML (and POST data) field name for the "step" variable. step_field_name="wizard_step" # METHODS SUBCLASSES SHOULDN'T OVERRIDE ################################### def __init__(self, form_list, initial=None): """ Start a new wizard with a list of forms. form_list should be a list of Form classes (not instances). """ self.form_list = form_list[:] self.initial = initial or {} # Dictionary of extra template context variables. self.extra_context = {} # A zero-based counter keeping track of which step we're in. self.step = 0 def __repr__(self): return "step: %d\nform_list: %s\ninitial_data: %s" % (self.step, self.form_list, self.initial) def get_form(self, step, data=None): "Helper method that returns the Form instance for the given step." return self.form_list[step](data, prefix=self.prefix_for_step(step), initial=self.initial.get(step, None)) def num_steps(self): "Helper method that returns the number of steps." # You might think we should just set "self.num_steps = len(form_list)" # in __init__(), but this calculation needs to be dynamic, because some # hook methods might alter self.form_list. return len(self.form_list) def _check_security_hash(self, token, request, form): expected = self.security_hash(request, form) if constant_time_compare(token, expected): return True else: # Fall back to Django 1.2 method, for compatibility with forms that # are in the middle of being used when the upgrade occurs. However, # we don't want to do this fallback if a subclass has provided their # own security_hash method - because they might have implemented a # more secure method, and this would punch a hole in that. # PendingDeprecationWarning <- left here to remind us that this # compatibility fallback should be removed in Django 1.5 FormWizard_expected = FormWizard.security_hash(self, request, form) if expected == FormWizard_expected: # They didn't override security_hash, do the fallback: old_expected = security_hash(request, form) return constant_time_compare(token, old_expected) else: return False @method_decorator(csrf_protect) def __call__(self, request, *args, **kwargs): """ Main method that does all the hard work, conforming to the Django view interface. """ if 'extra_context' in kwargs: self.extra_context.update(kwargs['extra_context']) current_step = self.determine_step(request, *args, **kwargs) self.parse_params(request, *args, **kwargs) # Sanity check. if current_step >= self.num_steps(): raise Http404('Step %s does not exist' % current_step) # Process the current step. If it's valid, go to the next step or call # done(), depending on whether any steps remain. if request.method == 'POST': form = self.get_form(current_step, request.POST) else: form = self.get_form(current_step) if form.is_valid(): # Validate all the forms. If any of them fail validation, that # must mean the validator relied on some other input, such as # an external Web site. # It is also possible that validation might fail under certain # attack situations: an attacker might be able to bypass previous # stages, and generate correct security hashes for all the # skipped stages by virtue of: # 1) having filled out an identical form which doesn't have the # validation (and does something different at the end), # 2) or having filled out a previous version of the same form # which had some validation missing, # 3) or previously having filled out the form when they had # more privileges than they do now. # # Since the hashes only take into account values, and not other # other validation the form might do, we must re-do validation # now for security reasons. current_form_list = [self.get_form(i, request.POST) for i in range(current_step)] for i, f in enumerate(current_form_list): if not self._check_security_hash(request.POST.get("hash_%d" % i, ''), request, f): return self.render_hash_failure(request, i) if not f.is_valid(): return self.render_revalidation_failure(request, i, f) else: self.process_step(request, f, i) # Now progress to processing this step: self.process_step(request, form, current_step) next_step = current_step + 1 if next_step == self.num_steps(): return self.done(request, current_form_list) else: form = self.get_form(next_step) self.step = current_step = next_step return self.render(form, request, current_step) def render(self, form, request, step, context=None): "Renders the given Form object, returning an HttpResponse." old_data = request.POST prev_fields = [] if old_data: hidden = forms.HiddenInput() # Collect all data from previous steps and render it as HTML hidden fields. for i in range(step): old_form = self.get_form(i, old_data) hash_name = 'hash_%s' % i prev_fields.extend([bf.as_hidden() for bf in old_form]) prev_fields.append(hidden.render(hash_name, old_data.get(hash_name, self.security_hash(request, old_form)))) return self.render_template(request, form, ''.join(prev_fields), step, context) # METHODS SUBCLASSES MIGHT OVERRIDE IF APPROPRIATE ######################## def prefix_for_step(self, step): "Given the step, returns a Form prefix to use." return str(step) def render_hash_failure(self, request, step): """ Hook for rendering a template if a hash check failed. step is the step that failed. Any previous step is guaranteed to be valid. This default implementation simply renders the form for the given step, but subclasses may want to display an error message, etc. """ return self.render(self.get_form(step), request, step, context={'wizard_error': _('We apologize, but your form has expired. Please continue filling out the form from this page.')}) def render_revalidation_failure(self, request, step, form): """ Hook for rendering a template if final revalidation failed. It is highly unlikely that this point would ever be reached, but See the comment in __call__() for an explanation. """ return self.render(form, request, step) def security_hash(self, request, form): """ Calculates the security hash for the given HttpRequest and Form instances. Subclasses may want to take into account request-specific information, such as the IP address. """ return form_hmac(form) def determine_step(self, request, *args, **kwargs): """ Given the request object and whatever *args and **kwargs were passed to __call__(), returns the current step (which is zero-based). Note that the result should not be trusted. It may even be a completely invalid number. It's not the job of this method to validate it. """ if not request.POST: return 0 try: step = int(request.POST.get(self.step_field_name, 0)) except ValueError: return 0 return step def parse_params(self, request, *args, **kwargs): """ Hook for setting some state, given the request object and whatever *args and **kwargs were passed to __call__(), sets some state. This is called at the beginning of __call__(). """ pass def get_template(self, step): """ Hook for specifying the name of the template to use for a given step. Note that this can return a tuple of template names if you'd like to use the template system's select_template() hook. """ return 'forms/wizard.html' def render_template(self, request, form, previous_fields, step, context=None): """ Renders the template for the given step, returning an HttpResponse object. Override this method if you want to add a custom context, return a different MIME type, etc. If you only need to override the template name, use get_template() instead. The template will be rendered with the following context: step_field -- The name of the hidden field containing the step. step0 -- The current step (zero-based). step -- The current step (one-based). step_count -- The total number of steps. form -- The Form instance for the current step (either empty or with errors). previous_fields -- A string representing every previous data field, plus hashes for completed forms, all in the form of hidden fields. Note that you'll need to run this through the "safe" template filter, to prevent auto-escaping, because it's raw HTML. """ context = context or {} context.update(self.extra_context) return render_to_response(self.get_template(step), dict(context, step_field=self.step_field_name, step0=step, step=step + 1, step_count=self.num_steps(), form=form, previous_fields=previous_fields ), context_instance=RequestContext(request)) def process_step(self, request, form, step): """ Hook for modifying the FormWizard's internal state, given a fully validated Form object. The Form is guaranteed to have clean, valid data. This method should *not* modify any of that data. Rather, it might want to set self.extra_context or dynamically alter self.form_list, based on previously submitted forms. Note that this method is called every time a page is rendered for *all* submitted steps. """ pass # METHODS SUBCLASSES MUST OVERRIDE ######################################## def done(self, request, form_list): """ Hook for doing something with the validated data. This is responsible for the final processing. form_list is a list of Form instances, each containing clean, valid data. """ raise NotImplementedError("Your %s class has not defined a done() method, which is required." % self.__class__.__name__)
ajibawa-2023/Python-Code-Large/train/row_98821
109
283
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_98821:Expr_L1_C0", "label": "expression", "type": "expression", "loc": [1, 5], "level": 0, "parent": null, "vector": [8, 0, 0.0106, 0.0177, 0, 0.66, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "\"\"\"\nFormWizard class -- implements a multi-page form, validating between each\nstep and storing the form's state as HTML hidden fields so that no state is\nstored on the server side.\n\"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98821:Import_L7_C0", "label": "cPickle import pickle", "type": "import", "loc": [7, 7], "level": 0, "parent": null, "vector": [1, 0, 0.0247, 0.0035, 0, 0.66, 0.0769, 279, 0, 1, 0, 0, 279, 0, 0], "semantic": {"name": "cPickle", "arg_names": [], "import_names": ["pickle"], "rhs_call_name": "", "annotation": ""}, "snippet": "import cPickle as pickle"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98821:ImportFrom_L9_C0", "label": "from django import forms", "type": "import", "loc": [9, 9], "level": 0, "parent": null, "vector": [1, 0, 0.0318, 0.0035, 0, 0.66, 0.1538, 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_98821:ImportFrom_L10_C0", "label": "from django.conf import settings", "type": "import", "loc": [10, 10], "level": 0, "parent": null, "vector": [1, 0, 0.0353, 0.0035, 0, 0.66, 0.2308, 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_98821:ImportFrom_L11_C0", "label": "from django.contrib.formtools.utils import security_hash, form_hmac", "type": "import", "loc": [11, 11], "level": 0, "parent": null, "vector": [1, 0, 0.0389, 0.0035, 0, 0.66, 0.3077, 839, 0, 2, 0, 0, 839, 0, 0], "semantic": {"name": "django.contrib.formtools.utils", "arg_names": [], "import_names": ["security_hash", "form_hmac"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.contrib.formtools.utils import security_hash, form_hmac"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98821:ImportFrom_L12_C0", "label": "from django.http import Http404", "type": "import", "loc": [12, 12], "level": 0, "parent": null, "vector": [1, 0, 0.0424, 0.0035, 0, 0.66, 0.3846, 779, 0, 1, 0, 0, 779, 0, 0], "semantic": {"name": "django.http", "arg_names": [], "import_names": ["Http404"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.http import Http404"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98821:ImportFrom_L13_C0", "label": "from django.shortcuts import render_to_response", "type": "import", "loc": [13, 13], "level": 0, "parent": null, "vector": [1, 0, 0.0459, 0.0035, 0, 0.66, 0.4615, 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_98821:ImportFrom_L14_C0", "label": "from django.template.context import RequestContext", "type": "import", "loc": [14, 14], "level": 0, "parent": null, "vector": [1, 0, 0.0495, 0.0035, 0, 0.66, 0.5385, 925, 0, 1, 0, 0, 925, 0, 0], "semantic": {"name": "django.template.context", "arg_names": [], "import_names": ["RequestContext"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.template.context import RequestContext"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98821:ImportFrom_L15_C0", "label": "from django.utils.crypto import constant_time_compare", "type": "import", "loc": [15, 15], "level": 0, "parent": null, "vector": [1, 0, 0.053, 0.0035, 0, 0.66, 0.6154, 657, 0, 1, 0, 0, 657, 0, 0], "semantic": {"name": "django.utils.crypto", "arg_names": [], "import_names": ["constant_time_compare"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.utils.crypto import constant_time_compare"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98821:ImportFrom_L16_C0", "label": "from django.utils.hashcompat import md5_constructor", "type": "import", "loc": [16, 16], "level": 0, "parent": null, "vector": [1, 0, 0.0565, 0.0035, 0, 0.66, 0.6923, 474, 0, 1, 0, 0, 474, 0, 0], "semantic": {"name": "django.utils.hashcompat", "arg_names": [], "import_names": ["md5_constructor"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.utils.hashcompat import md5_constructor"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98821:ImportFrom_L17_C0", "label": "from django.utils.translation import _", "type": "import", "loc": [17, 17], "level": 0, "parent": null, "vector": [1, 0, 0.0601, 0.0035, 0, 0.66, 0.7692, 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_98821:ImportFrom_L18_C0", "label": "from django.utils.decorators import method_decorator", "type": "import", "loc": [18, 18], "level": 0, "parent": null, "vector": [1, 0, 0.0636, 0.0035, 0, 0.66, 0.8462, 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_98821:ImportFrom_L19_C0", "label": "from django.views.decorators.csrf import csrf_protect", "type": "import", "loc": [19, 19], "level": 0, "parent": null, "vector": [1, 0, 0.0671, 0.0035, 0, 0.66, 0.9231, 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_98821:ClassDef_L22_C0", "label": "FormWizard", "type": "class", "loc": [22, 283], "level": 0, "parent": null, "vector": [3, 0, 0.5389, 0.9258, 0, 0.66, 1.0, 79, 0, 17, 0, 0, 186, 0, 58], "semantic": {"name": "FormWizard", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class FormWizard(object):\n # The HTML (and POST data) field name for the \"step\" variable.\n step_field_name=\"wizard_step\"\n\n # METHODS SUBCLASSES SHOULDN'T OVERRIDE ###################################\n\n def __init__(self, form_list, initial=None):\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98821:Assign_L24_C4", "label": "step_field_name =", "type": "assigned_variable", "loc": [24, 24], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98821:ClassDef_L22_C0", "vector": [14, 1, 0.0848, 0.0035, 1, 0.0, 0.0, 536, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "step_field_name", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " step_field_name=\"wizard_step\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98821:FunctionDef_L28_C4", "label": "__init__", "type": "function", "loc": [28, 41], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98821:ClassDef_L22_C0", "vector": [2, 1, 0.1219, 0.0495, 1, 0.0, 0.0588, 555, 0, 3, 0, 0, 0, 0, 0], "semantic": {"name": "__init__", "arg_names": ["self", "form_list", "initial"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def __init__(self, form_list, initial=None):\n \"\"\"\n Start a new wizard with a list of forms.\n\n form_list should be a list of Form classes (not instances).\n \"\"\"\n self.form_list = form_list[:]\n self.initial = initial or {}"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98821:Expr_L29_C8", "label": "expression", "type": "expression", "loc": [29, 33], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98821:FunctionDef_L28_C4", "vector": [8, 2, 0.1095, 0.0177, 2, 0.1, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"\n Start a new wizard with a list of forms.\n\n form_list should be a list of Form classes (not instances).\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98821:Assign_L34_C8", "label": "self.form_list =", "type": "assigned_variable", "loc": [34, 34], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98821:FunctionDef_L28_C4", "vector": [14, 2, 0.1201, 0.0035, 2, 0.1, 0.25, 779, 6, 0, 0, 0, 0, 0, 0], "semantic": {"name": "self.form_list", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.form_list = form_list[:]"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98821:Assign_L35_C8", "label": "self.initial =", "type": "assigned_variable", "loc": [35, 35], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98821:FunctionDef_L28_C4", "vector": [14, 2, 0.1237, 0.0035, 2, 0.1, 0.5, 385, 0, 0, 0, 0, 0, 0, 0], "semantic": {"name": "self.initial", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.initial = initial or {}"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98821:Assign_L38_C8", "label": "self.extra_context =", "type": "assigned_variable", "loc": [38, 38], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98821:FunctionDef_L28_C4", "vector": [14, 2, 0.1343, 0.0035, 2, 0.1, 0.75, 195, 0, 0, 0, 0, 0, 6, 0], "semantic": {"name": "self.extra_context", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.extra_context = {}"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98821:Assign_L41_C8", "label": "self.step =", "type": "assigned_variable", "loc": [41, 41], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98821:FunctionDef_L28_C4", "vector": [14, 2, 0.1449, 0.0035, 2, 0.1, 1.0, 382, 1, 0, 0, 0, 0, 1, 0], "semantic": {"name": "self.step", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.step = 0"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98821:FunctionDef_L43_C4", "label": "__repr__", "type": "function", "loc": [43, 44], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98821:ClassDef_L22_C0", "vector": [2, 1, 0.1537, 0.0071, 1, 0.0, 0.1176, 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 \"step: %d\\nform_list: %s\\ninitial_data: %s\" % (self.step, self.form_list, self.initial)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98821:Return_L44_C8", "label": "return", "type": "return", "loc": [44, 44], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98821:FunctionDef_L43_C4", "vector": [13, 2, 0.1555, 0.0035, 2, 0.94, 0.0, 0, 4, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return \"step: %d\\nform_list: %s\\ninitial_data: %s\" % (self.step, self.form_list, self.initial)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98821:FunctionDef_L46_C4", "label": "get_form", "type": "function", "loc": [46, 48], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98821:ClassDef_L22_C0", "vector": [2, 1, 0.1661, 0.0106, 1, 0.0, 0.1765, 265, 0, 3, 1, 0, 0, 0, 3], "semantic": {"name": "get_form", "arg_names": ["self", "step", "data"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def get_form(self, step, data=None):\n \"Helper method that returns the Form instance for the given step.\"\n return self.form_list[step](data, prefix=self.prefix_for_step(step), initial=self.initial.get(step, None))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98821:Expr_L47_C8", "label": "expression", "type": "expression", "loc": [47, 47], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98821:FunctionDef_L46_C4", "vector": [8, 2, 0.1661, 0.0035, 2, 0.3, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"Helper method that returns the Form instance for the given step.\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98821:Return_L48_C8", "label": "return", "type": "return", "loc": [48, 48], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98821:FunctionDef_L46_C4", "vector": [13, 2, 0.1696, 0.0035, 2, 0.3, 1.0, 0, 3, 0, 0, 0, 0, 10, 3], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return self.form_list[step](data, prefix=self.prefix_for_step(step), initial=self.initial.get(step, None))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98821:FunctionDef_L50_C4", "label": "num_steps", "type": "function", "loc": [50, 55], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98821:ClassDef_L22_C0", "vector": [2, 1, 0.1855, 0.0212, 1, 0.0, 0.2353, 40, 0, 1, 1, 0, 0, 0, 1], "semantic": {"name": "num_steps", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def num_steps(self):\n \"Helper method that returns the number of steps.\"\n # You might think we should just set \"self.num_steps = len(form_list)\"\n # in __init__(), but this calculation needs to be dynamic, because some\n # hook methods might alter self.form_list.\n return len(self.form_list)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98821:Expr_L51_C8", "label": "expression", "type": "expression", "loc": [51, 51], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98821:FunctionDef_L50_C4", "vector": [8, 2, 0.1802, 0.0035, 2, 0.86, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"Helper method that returns the number of steps.\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98821:Return_L55_C8", "label": "return", "type": "return", "loc": [55, 55], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98821:FunctionDef_L50_C4", "vector": [13, 2, 0.1943, 0.0035, 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 len(self.form_list)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98821:FunctionDef_L57_C4", "label": "_check_security_hash", "type": "function", "loc": [57, 76], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98821:ClassDef_L22_C0", "vector": [2, 1, 0.235, 0.0707, 1, 0.0, 0.2941, 266, 0, 4, 1, 0, 0, 0, 5], "semantic": {"name": "_check_security_hash", "arg_names": ["self", "token", "request", "form"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def _check_security_hash(self, token, request, form):\n expected = self.security_hash(request, form)\n if constant_time_compare(token, expected):\n return True\n else:\n # Fall back to Django 1.2 method, for compatibility with forms that\n # are in the middle of being used when the upgrade occurs. However,\n # we don't want to do this fallback if a subclass has provided their"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98821:Assign_L58_C8", "label": "expected = security_hash()", "type": "assigned_variable", "loc": [58, 58], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98821:FunctionDef_L57_C4", "vector": [14, 2, 0.2049, 0.0035, 2, 0.39, 0.0, 361, 3, 2, 0, 0, 234, 10, 1], "semantic": {"name": "expected", "arg_names": [], "import_names": [], "rhs_call_name": "security_hash", "annotation": ""}, "snippet": " expected = self.security_hash(request, form)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98821:If_L59_C8", "label": "if", "type": "if", "loc": [59, 76], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98821:FunctionDef_L57_C4", "vector": [4, 2, 0.2385, 0.0636, 2, 0.39, 1.0, 0, 3, 0, 0, 0, 0, 0, 4], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if constant_time_compare(token, expected):\n return True\n else:\n # Fall back to Django 1.2 method, for compatibility with forms that\n # are in the middle of being used when the upgrade occurs. However,\n # we don't want to do this fallback if a subclass has provided their\n # own security_hash method - because they might have implemented a\n # more secure method, and this would punch a hole in that."}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98821:Return_L60_C12", "label": "return", "type": "return", "loc": [60, 60], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98821:If_L59_C8", "vector": [13, 3, 0.212, 0.0035, 3, 0.48, 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_98821:Assign_L70_C12", "label": "FormWizard_expected = security_hash()", "type": "assigned_variable", "loc": [70, 70], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98821:If_L59_C8", "vector": [14, 3, 0.2473, 0.0035, 3, 0.48, 0.5, 350, 3, 3, 0, 0, 234, 10, 1], "semantic": {"name": "FormWizard_expected", "arg_names": [], "import_names": [], "rhs_call_name": "security_hash", "annotation": ""}, "snippet": " FormWizard_expected = FormWizard.security_hash(self, request, form)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98821:If_L71_C12", "label": "if", "type": "if", "loc": [71, 76], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98821:If_L59_C8", "vector": [4, 3, 0.2597, 0.0212, 3, 0.48, 1.0, 0, 0, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if expected == FormWizard_expected:\n # They didn't override security_hash, do the fallback:\n old_expected = security_hash(request, form)\n return constant_time_compare(token, old_expected)\n else:\n return False"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98821:Assign_L73_C16", "label": "old_expected = security_hash()", "type": "assigned_variable", "loc": [73, 73], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98821:If_L71_C12", "vector": [14, 4, 0.258, 0.0035, 4, 0.85, 0.0, 644, 3, 2, 0, 0, 234, 10, 1], "semantic": {"name": "old_expected", "arg_names": [], "import_names": [], "rhs_call_name": "security_hash", "annotation": ""}, "snippet": " old_expected = security_hash(request, form)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98821:Return_L74_C16", "label": "return", "type": "return", "loc": [74, 74], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98821:If_L71_C12", "vector": [13, 4, 0.2615, 0.0035, 4, 0.85, 0.5, 0, 3, 0, 0, 0, 0, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return constant_time_compare(token, old_expected)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98821:Return_L76_C16", "label": "return", "type": "return", "loc": [76, 76], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98821:If_L71_C12", "vector": [13, 4, 0.2686, 0.0035, 4, 0.85, 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_98821:FunctionDef_L79_C4", "label": "__call__", "type": "function", "loc": [79, 140], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98821:ClassDef_L22_C0", "vector": [2, 1, 0.3869, 0.2191, 1, 0.0, 0.3529, 319, 0, 4, 1, 0, 0, 0, 23], "semantic": {"name": "__call__", "arg_names": ["self", "request", "args", "kwargs"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def __call__(self, request, *args, **kwargs):\n \"\"\"\n Main method that does all the hard work, conforming to the Django view\n interface.\n \"\"\"\n if 'extra_context' in kwargs:\n self.extra_context.update(kwargs['extra_context'])\n current_step = self.determine_step(request, *args, **kwargs)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98821:Expr_L80_C8", "label": "expression", "type": "expression", "loc": [80, 83], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98821:FunctionDef_L79_C4", "vector": [8, 2, 0.288, 0.0141, 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 Main method that does all the hard work, conforming to the Django view\n interface.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98821:If_L84_C8", "label": "if", "type": "if", "loc": [84, 85], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98821:FunctionDef_L79_C4", "vector": [4, 2, 0.2986, 0.0071, 2, 0.85, 0.1429, 0, 0, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if 'extra_context' in kwargs:\n self.extra_context.update(kwargs['extra_context'])"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98821:Expr_L85_C12", "label": "update()", "type": "expression", "loc": [85, 85], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98821:If_L84_C8", "vector": [8, 3, 0.3004, 0.0035, 3, 0.26, 0.0, 637, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "update", "arg_names": [], "import_names": [], "rhs_call_name": "update", "annotation": ""}, "snippet": " self.extra_context.update(kwargs['extra_context'])"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98821:Assign_L86_C8", "label": "current_step = determine_step()", "type": "assigned_variable", "loc": [86, 86], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98821:FunctionDef_L79_C4", "vector": [14, 2, 0.3039, 0.0035, 2, 0.85, 0.2857, 972, 3, 3, 0, 0, 157, 10, 1], "semantic": {"name": "current_step", "arg_names": [], "import_names": [], "rhs_call_name": "determine_step", "annotation": ""}, "snippet": " current_step = self.determine_step(request, *args, **kwargs)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98821:Expr_L87_C8", "label": "parse_params()", "type": "expression", "loc": [87, 87], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98821:FunctionDef_L79_C4", "vector": [8, 2, 0.3074, 0.0035, 2, 0.85, 0.4286, 26, 3, 3, 0, 0, 0, 0, 1], "semantic": {"name": "parse_params", "arg_names": [], "import_names": [], "rhs_call_name": "parse_params", "annotation": ""}, "snippet": " self.parse_params(request, *args, **kwargs)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98821:If_L90_C8", "label": "if", "type": "if", "loc": [90, 91], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98821:FunctionDef_L79_C4", "vector": [4, 2, 0.3198, 0.0071, 2, 0.85, 0.5714, 0, 0, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if current_step >= self.num_steps():\n raise Http404('Step %s does not exist' % current_step)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98821:If_L95_C8", "label": "if", "type": "if", "loc": [95, 98], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98821:FunctionDef_L79_C4", "vector": [4, 2, 0.341, 0.0141, 2, 0.85, 0.7143, 0, 0, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if request.method == 'POST':\n form = self.get_form(current_step, request.POST)\n else:\n form = self.get_form(current_step)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98821:Assign_L96_C12", "label": "form = get_form()", "type": "assigned_variable", "loc": [96, 96], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98821:If_L95_C8", "vector": [14, 3, 0.3392, 0.0035, 3, 0.43, 0.0, 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(current_step, request.POST)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98821:Assign_L98_C12", "label": "form = get_form()", "type": "assigned_variable", "loc": [98, 98], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98821:If_L95_C8", "vector": [14, 3, 0.3463, 0.0035, 3, 0.43, 1.0, 761, 3, 1, 0, 0, 265, 10, 1], "semantic": {"name": "form", "arg_names": [], "import_names": [], "rhs_call_name": "get_form", "annotation": ""}, "snippet": " form = self.get_form(current_step)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98821:If_L100_C8", "label": "if", "type": "if", "loc": [100, 138], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98821:FunctionDef_L79_C4", "vector": [4, 2, 0.4205, 0.1378, 2, 0.85, 0.8571, 0, 3, 0, 0, 0, 0, 0, 14], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if form.is_valid():\n # Validate all the forms. If any of them fail validation, that\n # must mean the validator relied on some other input, such as\n # an external Web site.\n\n # It is also possible that validation might fail under certain\n # attack situations: an attacker might be able to bypass previous\n # stages, and generate correct security hashes for all the"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98821:Assign_L119_C12", "label": "current_form_list =", "type": "assigned_variable", "loc": [119, 119], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98821:If_L100_C8", "vector": [14, 3, 0.4205, 0.0035, 3, 0.88, 0.0, 895, 5, 0, 0, 0, 0, 0, 2], "semantic": {"name": "current_form_list", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " current_form_list = [self.get_form(i, request.POST) for i in range(current_step)]"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98821:For_L121_C12", "label": "for i, f", "type": "for", "loc": [121, 128], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98821:If_L100_C8", "vector": [6, 3, 0.4399, 0.0283, 3, 0.88, 0.25, 291, 3, 0, 0, 0, 0, 0, 7], "semantic": {"name": "i, f", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for i, f in enumerate(current_form_list):\n if not self._check_security_hash(request.POST.get(\"hash_%d\" % i, ''), request, f):\n return self.render_hash_failure(request, i)\n\n if not f.is_valid():\n return self.render_revalidation_failure(request, i, f)\n else:\n self.process_step(request, f, i)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98821:If_L122_C16", "label": "if", "type": "if", "loc": [122, 123], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98821:For_L121_C12", "vector": [4, 4, 0.4329, 0.0071, 4, 0.65, 0.0, 0, 0, 0, 0, 0, 0, 0, 3], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if not self._check_security_hash(request.POST.get(\"hash_%d\" % i, ''), request, f):\n return self.render_hash_failure(request, i)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98821:Return_L123_C20", "label": "return", "type": "return", "loc": [123, 123], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98821:If_L122_C16", "vector": [13, 5, 0.4346, 0.0035, 5, 0.68, 0.0, 0, 3, 0, 0, 0, 0, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return self.render_hash_failure(request, i)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98821:If_L125_C16", "label": "if", "type": "if", "loc": [125, 128], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98821:For_L121_C12", "vector": [4, 4, 0.447, 0.0141, 4, 0.65, 1.0, 0, 0, 0, 0, 0, 0, 0, 3], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if not f.is_valid():\n return self.render_revalidation_failure(request, i, f)\n else:\n self.process_step(request, f, i)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98821:Return_L126_C20", "label": "return", "type": "return", "loc": [126, 126], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98821:If_L125_C16", "vector": [13, 5, 0.4452, 0.0035, 5, 0.92, 0.0, 0, 3, 0, 0, 0, 0, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return self.render_revalidation_failure(request, i, f)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98821:Expr_L128_C20", "label": "process_step()", "type": "expression", "loc": [128, 128], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98821:If_L125_C16", "vector": [8, 5, 0.4523, 0.0035, 5, 0.92, 1.0, 470, 3, 3, 0, 0, 0, 0, 1], "semantic": {"name": "process_step", "arg_names": [], "import_names": [], "rhs_call_name": "process_step", "annotation": ""}, "snippet": " self.process_step(request, f, i)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98821:Expr_L131_C12", "label": "process_step()", "type": "expression", "loc": [131, 131], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98821:If_L100_C8", "vector": [8, 3, 0.4629, 0.0035, 3, 0.88, 0.5, 470, 3, 3, 0, 0, 0, 0, 1], "semantic": {"name": "process_step", "arg_names": [], "import_names": [], "rhs_call_name": "process_step", "annotation": ""}, "snippet": " self.process_step(request, form, current_step)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98821:Assign_L132_C12", "label": "next_step =", "type": "assigned_variable", "loc": [132, 132], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98821:If_L100_C8", "vector": [14, 3, 0.4664, 0.0035, 3, 0.88, 0.75, 980, 4, 0, 0, 0, 0, 0, 0], "semantic": {"name": "next_step", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " next_step = current_step + 1"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98821:If_L134_C12", "label": "if", "type": "if", "loc": [134, 138], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98821:If_L100_C8", "vector": [4, 3, 0.4806, 0.0177, 3, 0.88, 1.0, 0, 0, 0, 0, 0, 0, 0, 3], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if next_step == self.num_steps():\n return self.done(request, current_form_list)\n else:\n form = self.get_form(next_step)\n self.step = current_step = next_step"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98821:Return_L135_C16", "label": "return", "type": "return", "loc": [135, 135], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98821:If_L134_C12", "vector": [13, 4, 0.477, 0.0035, 4, 0.92, 0.0, 0, 3, 0, 0, 0, 0, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return self.done(request, current_form_list)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98821:Assign_L137_C16", "label": "form = get_form()", "type": "assigned_variable", "loc": [137, 137], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98821:If_L134_C12", "vector": [14, 4, 0.4841, 0.0035, 4, 0.92, 0.5, 761, 3, 1, 0, 0, 265, 10, 1], "semantic": {"name": "form", "arg_names": [], "import_names": [], "rhs_call_name": "get_form", "annotation": ""}, "snippet": " form = self.get_form(next_step)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98821:Assign_L138_C16", "label": "self.step =", "type": "assigned_variable", "loc": [138, 138], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98821:If_L134_C12", "vector": [14, 4, 0.4876, 0.0035, 4, 0.92, 1.0, 382, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "self.step", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.step = current_step = next_step"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98821:Return_L140_C8", "label": "return", "type": "return", "loc": [140, 140], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98821:FunctionDef_L79_C4", "vector": [13, 2, 0.4947, 0.0035, 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 self.render(form, request, current_step)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98821:FunctionDef_L142_C4", "label": "render", "type": "function", "loc": [142, 154], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98821:ClassDef_L22_C0", "vector": [2, 1, 0.523, 0.0459, 1, 0.0, 0.4118, 24, 0, 5, 1, 0, 0, 0, 11], "semantic": {"name": "render", "arg_names": ["self", "form", "request", "step", "context"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def render(self, form, request, step, context=None):\n \"Renders the given Form object, returning an HttpResponse.\"\n old_data = request.POST\n prev_fields = []\n if old_data:\n hidden = forms.HiddenInput()\n # Collect all data from previous steps and render it as HTML hidden fields.\n for i in range(step):"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98821:Expr_L143_C8", "label": "expression", "type": "expression", "loc": [143, 143], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98821:FunctionDef_L142_C4", "vector": [8, 2, 0.5053, 0.0035, 2, 0.2, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"Renders the given Form object, returning an HttpResponse.\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98821:Assign_L144_C8", "label": "old_data =", "type": "assigned_variable", "loc": [144, 144], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98821:FunctionDef_L142_C4", "vector": [14, 2, 0.5088, 0.0035, 2, 0.2, 0.25, 411, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "old_data", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " old_data = request.POST"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98821:Assign_L145_C8", "label": "prev_fields =", "type": "assigned_variable", "loc": [145, 145], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98821:FunctionDef_L142_C4", "vector": [14, 2, 0.5124, 0.0035, 2, 0.2, 0.5, 475, 0, 0, 0, 0, 0, 5, 0], "semantic": {"name": "prev_fields", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " prev_fields = []"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98821:If_L146_C8", "label": "if", "type": "if", "loc": [146, 153], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98821:FunctionDef_L142_C4", "vector": [4, 2, 0.5283, 0.0283, 2, 0.2, 0.75, 0, 2, 0, 0, 0, 0, 0, 9], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if old_data:\n hidden = forms.HiddenInput()\n # Collect all data from previous steps and render it as HTML hidden fields.\n for i in range(step):\n old_form = self.get_form(i, old_data)\n hash_name = 'hash_%s' % i\n prev_fields.extend([bf.as_hidden() for bf in old_form])\n prev_fields.append(hidden.render(hash_name, old_data.get(hash_name, self.security_hash(request, old_form))))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98821:Assign_L147_C12", "label": "hidden = HiddenInput()", "type": "assigned_variable", "loc": [147, 147], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98821:If_L146_C8", "vector": [14, 3, 0.5194, 0.0035, 3, 0.96, 0.0, 524, 3, 0, 0, 0, 961, 10, 1], "semantic": {"name": "hidden", "arg_names": [], "import_names": [], "rhs_call_name": "HiddenInput", "annotation": ""}, "snippet": " hidden = forms.HiddenInput()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98821:For_L149_C12", "label": "for i", "type": "for", "loc": [149, 153], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98821:If_L146_C8", "vector": [6, 3, 0.5336, 0.0177, 3, 0.96, 1.0, 826, 3, 0, 0, 0, 0, 0, 8], "semantic": {"name": "i", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for i in range(step):\n old_form = self.get_form(i, old_data)\n hash_name = 'hash_%s' % i\n prev_fields.extend([bf.as_hidden() for bf in old_form])\n prev_fields.append(hidden.render(hash_name, old_data.get(hash_name, self.security_hash(request, old_form))))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98821:Assign_L150_C16", "label": "old_form = get_form()", "type": "assigned_variable", "loc": [150, 150], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98821:For_L149_C12", "vector": [14, 4, 0.53, 0.0035, 4, 0.8, 0.0, 659, 3, 2, 0, 0, 265, 10, 1], "semantic": {"name": "old_form", "arg_names": [], "import_names": [], "rhs_call_name": "get_form", "annotation": ""}, "snippet": " old_form = self.get_form(i, old_data)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98821:Assign_L151_C16", "label": "hash_name =", "type": "assigned_variable", "loc": [151, 151], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98821:For_L149_C12", "vector": [14, 4, 0.5336, 0.0035, 4, 0.8, 0.3333, 507, 4, 0, 0, 0, 0, 0, 0], "semantic": {"name": "hash_name", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " hash_name = 'hash_%s' % i"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98821:Expr_L152_C16", "label": "extend()", "type": "expression", "loc": [152, 152], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98821:For_L149_C12", "vector": [8, 4, 0.5371, 0.0035, 4, 0.8, 0.6667, 660, 3, 1, 0, 0, 0, 0, 2], "semantic": {"name": "extend", "arg_names": [], "import_names": [], "rhs_call_name": "extend", "annotation": ""}, "snippet": " prev_fields.extend([bf.as_hidden() for bf in old_form])"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98821:Expr_L153_C16", "label": "append()", "type": "expression", "loc": [153, 153], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98821:For_L149_C12", "vector": [8, 4, 0.5406, 0.0035, 4, 0.8, 1.0, 243, 3, 1, 0, 0, 0, 0, 4], "semantic": {"name": "append", "arg_names": [], "import_names": [], "rhs_call_name": "append", "annotation": ""}, "snippet": " prev_fields.append(hidden.render(hash_name, old_data.get(hash_name, self.security_hash(request, old_form))))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98821:Return_L154_C8", "label": "return", "type": "return", "loc": [154, 154], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98821:FunctionDef_L142_C4", "vector": [13, 2, 0.5442, 0.0035, 2, 0.2, 1.0, 0, 3, 0, 0, 0, 0, 10, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return self.render_template(request, form, ''.join(prev_fields), step, context)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98821:FunctionDef_L158_C4", "label": "prefix_for_step", "type": "function", "loc": [158, 160], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98821:ClassDef_L22_C0", "vector": [2, 1, 0.5618, 0.0106, 1, 0.0, 0.4706, 599, 0, 2, 1, 0, 0, 0, 1], "semantic": {"name": "prefix_for_step", "arg_names": ["self", "step"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def prefix_for_step(self, step):\n \"Given the step, returns a Form prefix to use.\"\n return str(step)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98821:Expr_L159_C8", "label": "expression", "type": "expression", "loc": [159, 159], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98821:FunctionDef_L158_C4", "vector": [8, 2, 0.5618, 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": " \"Given the step, returns a Form prefix to use.\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98821:Return_L160_C8", "label": "return", "type": "return", "loc": [160, 160], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98821:FunctionDef_L158_C4", "vector": [13, 2, 0.5654, 0.0035, 2, 0.29, 1.0, 0, 3, 0, 0, 0, 0, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return str(step)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98821:FunctionDef_L162_C4", "label": "render_hash_failure", "type": "function", "loc": [162, 172], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98821:ClassDef_L22_C0", "vector": [2, 1, 0.5901, 0.0389, 1, 0.0, 0.5294, 285, 0, 3, 1, 0, 0, 0, 3], "semantic": {"name": "render_hash_failure", "arg_names": ["self", "request", "step"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def render_hash_failure(self, request, step):\n \"\"\"\n Hook for rendering a template if a hash check failed.\n\n step is the step that failed. Any previous step is guaranteed to be\n valid.\n\n This default implementation simply renders the form for the given step,"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98821:Expr_L163_C8", "label": "expression", "type": "expression", "loc": [163, 171], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98821:FunctionDef_L162_C4", "vector": [8, 2, 0.5901, 0.0318, 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 Hook for rendering a template if a hash check failed.\n\n step is the step that failed. Any previous step is guaranteed to be\n valid.\n\n This default implementation simply renders the form for the given step,\n but subclasses may want to display an error message, etc."}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98821:Return_L172_C8", "label": "return", "type": "return", "loc": [172, 172], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98821:FunctionDef_L162_C4", "vector": [13, 2, 0.6078, 0.0035, 2, 0.77, 1.0, 0, 3, 0, 0, 0, 0, 10, 3], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return self.render(self.get_form(step), request, step, context={'wizard_error': _('We apologize, but your form has expired. Please continue filling out the form from this page.')})"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98821:FunctionDef_L174_C4", "label": "render_revalidation_failure", "type": "function", "loc": [174, 181], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98821:ClassDef_L22_C0", "vector": [2, 1, 0.6272, 0.0283, 1, 0.0, 0.5882, 433, 0, 4, 1, 0, 0, 0, 1], "semantic": {"name": "render_revalidation_failure", "arg_names": ["self", "request", "step", "form"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def render_revalidation_failure(self, request, step, form):\n \"\"\"\n Hook for rendering a template if final revalidation failed.\n\n It is highly unlikely that this point would ever be reached, but See\n the comment in __call__() for an explanation.\n \"\"\"\n return self.render(form, request, step)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98821:Expr_L175_C8", "label": "expression", "type": "expression", "loc": [175, 180], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98821:FunctionDef_L174_C4", "vector": [8, 2, 0.6272, 0.0212, 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 Hook for rendering a template if final revalidation failed.\n\n It is highly unlikely that this point would ever be reached, but See\n the comment in __call__() for an explanation.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98821:Return_L181_C8", "label": "return", "type": "return", "loc": [181, 181], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98821:FunctionDef_L174_C4", "vector": [13, 2, 0.6396, 0.0035, 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 self.render(form, request, step)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98821:FunctionDef_L183_C4", "label": "security_hash", "type": "function", "loc": [183, 190], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98821:ClassDef_L22_C0", "vector": [2, 1, 0.659, 0.0283, 1, 0.0, 0.6471, 234, 0, 3, 1, 0, 0, 0, 1], "semantic": {"name": "security_hash", "arg_names": ["self", "request", "form"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def security_hash(self, request, form):\n \"\"\"\n Calculates the security hash for the given HttpRequest and Form instances.\n\n Subclasses may want to take into account request-specific information,\n such as the IP address.\n \"\"\"\n return form_hmac(form)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98821:Expr_L184_C8", "label": "expression", "type": "expression", "loc": [184, 189], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98821:FunctionDef_L183_C4", "vector": [8, 2, 0.659, 0.0212, 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 Calculates the security hash for the given HttpRequest and Form instances.\n\n Subclasses may want to take into account request-specific information,\n such as the IP address.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98821:Return_L190_C8", "label": "return", "type": "return", "loc": [190, 190], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98821:FunctionDef_L183_C4", "vector": [13, 2, 0.6714, 0.0035, 2, 0.44, 1.0, 0, 3, 0, 0, 0, 0, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return form_hmac(form)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98821:FunctionDef_L192_C4", "label": "determine_step", "type": "function", "loc": [192, 206], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98821:ClassDef_L22_C0", "vector": [2, 1, 0.7032, 0.053, 1, 0.0, 0.7059, 157, 0, 4, 1, 0, 0, 0, 2], "semantic": {"name": "determine_step", "arg_names": ["self", "request", "args", "kwargs"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def determine_step(self, request, *args, **kwargs):\n \"\"\"\n Given the request object and whatever *args and **kwargs were passed to\n __call__(), returns the current step (which is zero-based).\n\n Note that the result should not be trusted. It may even be a completely\n invalid number. It's not the job of this method to validate it.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98821:Expr_L193_C8", "label": "expression", "type": "expression", "loc": [193, 199], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98821:FunctionDef_L192_C4", "vector": [8, 2, 0.6926, 0.0247, 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 Given the request object and whatever *args and **kwargs were passed to\n __call__(), returns the current step (which is zero-based).\n\n Note that the result should not be trusted. It may even be a completely\n invalid number. It's not the job of this method to validate it.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98821:If_L200_C8", "label": "if", "type": "if", "loc": [200, 201], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98821:FunctionDef_L192_C4", "vector": [4, 2, 0.7085, 0.0071, 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 not request.POST:\n return 0"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98821:Return_L201_C12", "label": "return", "type": "return", "loc": [201, 201], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98821:If_L200_C8", "vector": [13, 3, 0.7102, 0.0035, 3, 0.7, 0.0, 0, 1, 0, 0, 0, 0, 1, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return 0"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98821:Try_L202_C8", "label": "try", "type": "try", "loc": [202, 205], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98821:FunctionDef_L192_C4", "vector": [7, 2, 0.7191, 0.0141, 2, 0.38, 0.6667, 0, 0, 1, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " try:\n step = int(request.POST.get(self.step_field_name, 0))\n except ValueError:\n return 0"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98821:Assign_L203_C12", "label": "step = int()", "type": "assigned_variable", "loc": [203, 203], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98821:Try_L202_C8", "vector": [14, 3, 0.7173, 0.0035, 3, 0.16, 0.0, 880, 3, 1, 0, 0, 901, 10, 2], "semantic": {"name": "step", "arg_names": [], "import_names": [], "rhs_call_name": "int", "annotation": ""}, "snippet": " step = int(request.POST.get(self.step_field_name, 0))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98821:Return_L205_C12", "label": "return", "type": "return", "loc": [205, 205], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98821:Try_L202_C8", "vector": [13, 3, 0.7244, 0.0035, 3, 0.16, 0.0, 0, 1, 0, 0, 0, 0, 1, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return 0"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98821:Return_L206_C8", "label": "return", "type": "return", "loc": [206, 206], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98821:FunctionDef_L192_C4", "vector": [13, 2, 0.7279, 0.0035, 2, 0.38, 1.0, 0, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return step"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98821:FunctionDef_L208_C4", "label": "parse_params", "type": "function", "loc": [208, 215], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98821:ClassDef_L22_C0", "vector": [2, 1, 0.7473, 0.0283, 1, 0.0, 0.7647, 26, 0, 4, 0, 0, 0, 0, 0], "semantic": {"name": "parse_params", "arg_names": ["self", "request", "args", "kwargs"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def parse_params(self, request, *args, **kwargs):\n \"\"\"\n Hook for setting some state, given the request object and whatever\n *args and **kwargs were passed to __call__(), sets some state.\n\n This is called at the beginning of __call__().\n \"\"\"\n pass"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98821:Expr_L209_C8", "label": "expression", "type": "expression", "loc": [209, 214], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98821:FunctionDef_L208_C4", "vector": [8, 2, 0.7473, 0.0212, 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 Hook for setting some state, given the request object and whatever\n *args and **kwargs were passed to __call__(), sets some state.\n\n This is called at the beginning of __call__().\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98821:FunctionDef_L217_C4", "label": "get_template", "type": "function", "loc": [217, 224], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98821:ClassDef_L22_C0", "vector": [2, 1, 0.7792, 0.0283, 1, 0.0, 0.8235, 27, 0, 2, 1, 0, 0, 0, 0], "semantic": {"name": "get_template", "arg_names": ["self", "step"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def get_template(self, step):\n \"\"\"\n Hook for specifying the name of the template to use for a given step.\n\n Note that this can return a tuple of template names if you'd like to\n use the template system's select_template() hook.\n \"\"\"\n return 'forms/wizard.html'"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98821:Expr_L218_C8", "label": "expression", "type": "expression", "loc": [218, 223], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98821:FunctionDef_L217_C4", "vector": [8, 2, 0.7792, 0.0212, 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 Hook for specifying the name of the template to use for a given step.\n\n Note that this can return a tuple of template names if you'd like to\n use the template system's select_template() hook.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98821:Return_L224_C8", "label": "return", "type": "return", "loc": [224, 224], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98821:FunctionDef_L217_C4", "vector": [13, 2, 0.7915, 0.0035, 2, 0.99, 1.0, 0, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return 'forms/wizard.html'"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98821:FunctionDef_L226_C4", "label": "render_template", "type": "function", "loc": [226, 256], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98821:ClassDef_L22_C0", "vector": [2, 1, 0.8516, 0.1095, 1, 0.0, 0.8824, 106, 0, 6, 1, 0, 0, 0, 6], "semantic": {"name": "render_template", "arg_names": ["self", "request", "form", "previous_fields", "step", "context"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def render_template(self, request, form, previous_fields, step, context=None):\n \"\"\"\n Renders the template for the given step, returning an HttpResponse object.\n\n Override this method if you want to add a custom context, return a\n different MIME type, etc. If you only need to override the template\n name, use get_template() instead.\n"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98821:Expr_L227_C8", "label": "expression", "type": "expression", "loc": [227, 246], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98821:FunctionDef_L226_C4", "vector": [8, 2, 0.8357, 0.0707, 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 Renders the template for the given step, returning an HttpResponse object.\n\n Override this method if you want to add a custom context, return a\n different MIME type, etc. If you only need to override the template\n name, use get_template() instead.\n\n The template will be rendered with the following context:"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98821:Assign_L247_C8", "label": "context =", "type": "assigned_variable", "loc": [247, 247], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98821:FunctionDef_L226_C4", "vector": [14, 2, 0.8728, 0.0035, 2, 0.4, 0.3333, 954, 0, 0, 0, 0, 0, 0, 0], "semantic": {"name": "context", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " context = context or {}"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98821:Expr_L248_C8", "label": "update()", "type": "expression", "loc": [248, 248], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98821:FunctionDef_L226_C4", "vector": [8, 2, 0.8763, 0.0035, 2, 0.4, 0.6667, 637, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "update", "arg_names": [], "import_names": [], "rhs_call_name": "update", "annotation": ""}, "snippet": " context.update(self.extra_context)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98821:Return_L249_C8", "label": "return", "type": "return", "loc": [249, 256], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98821:FunctionDef_L226_C4", "vector": [13, 2, 0.8922, 0.0283, 2, 0.4, 1.0, 0, 3, 0, 0, 0, 0, 10, 5], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return render_to_response(self.get_template(step), dict(context,\n step_field=self.step_field_name,\n step0=step,\n step=step + 1,\n step_count=self.num_steps(),\n form=form,\n previous_fields=previous_fields\n ), context_instance=RequestContext(request))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98821:FunctionDef_L258_C4", "label": "process_step", "type": "function", "loc": [258, 271], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98821:ClassDef_L22_C0", "vector": [2, 1, 0.9346, 0.0495, 1, 0.0, 0.9412, 470, 0, 4, 0, 0, 0, 0, 0], "semantic": {"name": "process_step", "arg_names": ["self", "request", "form", "step"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def process_step(self, request, form, step):\n \"\"\"\n Hook for modifying the FormWizard's internal state, given a fully\n validated Form object. The Form is guaranteed to have clean, valid\n data.\n\n This method should *not* modify any of that data. Rather, it might want\n to set self.extra_context or dynamically alter self.form_list, based on"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98821:Expr_L259_C8", "label": "expression", "type": "expression", "loc": [259, 270], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98821:FunctionDef_L258_C4", "vector": [8, 2, 0.9346, 0.0424, 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 Hook for modifying the FormWizard's internal state, given a fully\n validated Form object. The Form is guaranteed to have clean, valid\n data.\n\n This method should *not* modify any of that data. Rather, it might want\n to set self.extra_context or dynamically alter self.form_list, based on\n previously submitted forms."}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98821:FunctionDef_L275_C4", "label": "done", "type": "function", "loc": [275, 283], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98821:ClassDef_L22_C0", "vector": [2, 1, 0.9859, 0.0318, 1, 0.0, 1.0, 151, 0, 3, 0, 0, 0, 0, 1], "semantic": {"name": "done", "arg_names": ["self", "request", "form_list"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def done(self, request, form_list):\n \"\"\"\n Hook for doing something with the validated data. This is responsible\n for the final processing.\n\n form_list is a list of Form instances, each containing clean, valid\n data.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98821:Expr_L276_C8", "label": "expression", "type": "expression", "loc": [276, 282], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98821:FunctionDef_L275_C4", "vector": [8, 2, 0.9859, 0.0247, 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 Hook for doing something with the validated data. This is responsible\n for the final processing.\n\n form_list is a list of Form instances, each containing clean, valid\n data.\n \"\"\""}]
[{"f": "ajibawa-2023/Python-Code-Large/train/row_98821:ClassDef_L22_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98821:Assign_L24_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98821:ClassDef_L22_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98821:FunctionDef_L28_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98821:FunctionDef_L28_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98821:Expr_L29_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98821:FunctionDef_L28_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98821:Assign_L34_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98821:FunctionDef_L28_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98821:Assign_L35_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98821:FunctionDef_L28_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98821:Assign_L38_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98821:FunctionDef_L28_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98821:Assign_L41_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98821:ClassDef_L22_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98821:FunctionDef_L43_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98821:FunctionDef_L43_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98821:Return_L44_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98821:ClassDef_L22_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98821:FunctionDef_L46_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98821:FunctionDef_L46_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98821:Expr_L47_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98821:FunctionDef_L46_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98821:Return_L48_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98821:ClassDef_L22_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98821:FunctionDef_L50_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98821:FunctionDef_L50_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98821:Expr_L51_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98821:FunctionDef_L50_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98821:Return_L55_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98821:ClassDef_L22_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98821:FunctionDef_L57_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98821:FunctionDef_L57_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98821:Assign_L58_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98821:FunctionDef_L57_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98821:If_L59_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98821:If_L59_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98821:Return_L60_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98821:If_L59_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98821:Assign_L70_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98821:If_L59_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98821:If_L71_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98821:If_L71_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98821:Assign_L73_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98821:If_L71_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98821:Return_L74_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98821:If_L71_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98821:Return_L76_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98821:ClassDef_L22_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98821:FunctionDef_L79_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98821:FunctionDef_L79_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98821:Expr_L80_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98821:FunctionDef_L79_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98821:If_L84_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98821:If_L84_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98821:Expr_L85_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98821:FunctionDef_L79_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98821:Assign_L86_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98821:FunctionDef_L79_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98821:Expr_L87_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98821:FunctionDef_L79_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98821:If_L90_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98821:FunctionDef_L79_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98821:If_L95_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98821:If_L95_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98821:Assign_L96_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98821:If_L95_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98821:Assign_L98_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98821:FunctionDef_L79_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98821:If_L100_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98821:If_L100_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98821:Assign_L119_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98821:If_L100_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98821:For_L121_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98821:For_L121_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98821:If_L122_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98821:If_L122_C16", "t": "ajibawa-2023/Python-Code-Large/train/row_98821:Return_L123_C20"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98821:For_L121_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98821:If_L125_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98821:If_L125_C16", "t": "ajibawa-2023/Python-Code-Large/train/row_98821:Return_L126_C20"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98821:If_L125_C16", "t": "ajibawa-2023/Python-Code-Large/train/row_98821:Expr_L128_C20"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98821:If_L100_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98821:Expr_L131_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98821:If_L100_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98821:Assign_L132_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98821:If_L100_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98821:If_L134_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98821:If_L134_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98821:Return_L135_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98821:If_L134_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98821:Assign_L137_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98821:If_L134_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98821:Assign_L138_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98821:FunctionDef_L79_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98821:Return_L140_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98821:ClassDef_L22_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98821:FunctionDef_L142_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98821:FunctionDef_L142_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98821:Expr_L143_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98821:FunctionDef_L142_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98821:Assign_L144_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98821:FunctionDef_L142_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98821:Assign_L145_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98821:FunctionDef_L142_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98821:If_L146_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98821:If_L146_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98821:Assign_L147_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98821:If_L146_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98821:For_L149_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98821:For_L149_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98821:Assign_L150_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98821:For_L149_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98821:Assign_L151_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98821:For_L149_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98821:Expr_L152_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98821:For_L149_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98821:Expr_L153_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98821:FunctionDef_L142_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98821:Return_L154_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98821:ClassDef_L22_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98821:FunctionDef_L158_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98821:FunctionDef_L158_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98821:Expr_L159_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98821:FunctionDef_L158_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98821:Return_L160_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98821:ClassDef_L22_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98821:FunctionDef_L162_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98821:FunctionDef_L162_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98821:Expr_L163_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98821:FunctionDef_L162_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98821:Return_L172_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98821:ClassDef_L22_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98821:FunctionDef_L174_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98821:FunctionDef_L174_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98821:Expr_L175_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98821:FunctionDef_L174_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98821:Return_L181_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98821:ClassDef_L22_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98821:FunctionDef_L183_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98821:FunctionDef_L183_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98821:Expr_L184_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98821:FunctionDef_L183_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98821:Return_L190_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98821:ClassDef_L22_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98821:FunctionDef_L192_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98821:FunctionDef_L192_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98821:Expr_L193_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98821:FunctionDef_L192_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98821:If_L200_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98821:If_L200_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98821:Return_L201_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98821:FunctionDef_L192_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98821:Try_L202_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98821:Try_L202_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98821:Assign_L203_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98821:Try_L202_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98821:Return_L205_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98821:FunctionDef_L192_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98821:Return_L206_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98821:ClassDef_L22_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98821:FunctionDef_L208_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98821:FunctionDef_L208_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98821:Expr_L209_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98821:ClassDef_L22_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98821:FunctionDef_L217_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98821:FunctionDef_L217_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98821:Expr_L218_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98821:FunctionDef_L217_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98821:Return_L224_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98821:ClassDef_L22_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98821:FunctionDef_L226_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98821:FunctionDef_L226_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98821:Expr_L227_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98821:FunctionDef_L226_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98821:Assign_L247_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98821:FunctionDef_L226_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98821:Expr_L248_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98821:FunctionDef_L226_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98821:Return_L249_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98821:ClassDef_L22_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98821:FunctionDef_L258_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98821:FunctionDef_L258_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98821:Expr_L259_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98821:ClassDef_L22_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98821:FunctionDef_L275_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98821:FunctionDef_L275_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98821:Expr_L276_C8"}]
from django.core.exceptions import MiddlewareNotUsed from django.utils.http import http_date class ConditionalGetMiddleware(object): """ Handles conditional GET operations. If the response has a ETag or Last-Modified header, and the request has If-None-Match or If-Modified-Since, the response is replaced by an HttpNotModified. Also sets the Date and Content-Length response-headers. """ def process_response(self, request, response): response['Date'] = http_date() if not response.has_header('Content-Length'): response['Content-Length'] = str(len(response.content)) if response.has_header('ETag'): if_none_match = request.META.get('HTTP_IF_NONE_MATCH', None) if if_none_match == response['ETag']: # Setting the status is enough here. The response handling path # automatically removes content for this status code (in # http.conditional_content_removal()). response.status_code = 304 if response.has_header('Last-Modified'): if_modified_since = request.META.get('HTTP_IF_MODIFIED_SINCE', None) if if_modified_since == response['Last-Modified']: # Setting the status code is enough here (same reasons as # above). response.status_code = 304 return response
ajibawa-2023/Python-Code-Large/train/row_98822
17
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_98822:ImportFrom_L1_C0", "label": "from django.core.exceptions import MiddlewareNotUsed", "type": "import", "loc": [1, 1], "level": 0, "parent": null, "vector": [1, 0, 0.0312, 0.0312, 0, 0.66, 0.0, 160, 0, 1, 0, 0, 160, 0, 0], "semantic": {"name": "django.core.exceptions", "arg_names": [], "import_names": ["MiddlewareNotUsed"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.core.exceptions import MiddlewareNotUsed"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98822:ImportFrom_L2_C0", "label": "from django.utils.http import http_date", "type": "import", "loc": [2, 2], "level": 0, "parent": null, "vector": [1, 0, 0.0625, 0.0312, 0, 0.66, 0.5, 516, 0, 1, 0, 0, 516, 0, 0], "semantic": {"name": "django.utils.http", "arg_names": [], "import_names": ["http_date"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.utils.http import http_date"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98822:ClassDef_L4_C0", "label": "ConditionalGetMiddleware", "type": "class", "loc": [4, 32], "level": 0, "parent": null, "vector": [3, 0, 0.5625, 0.9062, 0, 0.66, 1.0, 362, 0, 1, 0, 0, 186, 0, 8], "semantic": {"name": "ConditionalGetMiddleware", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class ConditionalGetMiddleware(object):\n \"\"\"\n Handles conditional GET operations. If the response has a ETag or\n Last-Modified header, and the request has If-None-Match or\n If-Modified-Since, the response is replaced by an HttpNotModified.\n\n Also sets the Date and Content-Length response-headers.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98822:Expr_L5_C4", "label": "expression", "type": "expression", "loc": [5, 11], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98822:ClassDef_L4_C0", "vector": [8, 1, 0.25, 0.2188, 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 Handles conditional GET operations. If the response has a ETag or\n Last-Modified header, and the request has If-None-Match or\n If-Modified-Since, the response is replaced by an HttpNotModified.\n\n Also sets the Date and Content-Length response-headers.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98822:FunctionDef_L12_C4", "label": "process_response", "type": "function", "loc": [12, 32], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98822:ClassDef_L4_C0", "vector": [2, 1, 0.6875, 0.6562, 1, 0.63, 1.0, 298, 0, 3, 1, 0, 0, 0, 8], "semantic": {"name": "process_response", "arg_names": ["self", "request", "response"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def process_response(self, request, response):\n response['Date'] = http_date()\n if not response.has_header('Content-Length'):\n response['Content-Length'] = str(len(response.content))\n\n if response.has_header('ETag'):\n if_none_match = request.META.get('HTTP_IF_NONE_MATCH', None)\n if if_none_match == response['ETag']:"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98822:Assign_L13_C8", "label": " = http_date()", "type": "assigned_variable", "loc": [13, 13], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98822:FunctionDef_L12_C4", "vector": [14, 2, 0.4062, 0.0312, 2, 0.56, 0.0, 0, 3, 0, 0, 0, 564, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "http_date", "annotation": ""}, "snippet": " response['Date'] = http_date()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98822:If_L14_C8", "label": "if", "type": "if", "loc": [14, 15], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98822:FunctionDef_L12_C4", "vector": [4, 2, 0.4531, 0.0625, 2, 0.56, 0.25, 0, 0, 0, 0, 0, 0, 0, 3], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if not response.has_header('Content-Length'):\n response['Content-Length'] = str(len(response.content))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98822:Assign_L15_C12", "label": " = str()", "type": "assigned_variable", "loc": [15, 15], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98822:If_L14_C8", "vector": [14, 3, 0.4688, 0.0312, 3, 0.16, 0.0, 0, 3, 1, 0, 0, 52, 10, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "str", "annotation": ""}, "snippet": " response['Content-Length'] = str(len(response.content))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98822:If_L17_C8", "label": "if", "type": "if", "loc": [17, 23], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98822:FunctionDef_L12_C4", "vector": [4, 2, 0.625, 0.2188, 2, 0.56, 0.5, 0, 3, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if response.has_header('ETag'):\n if_none_match = request.META.get('HTTP_IF_NONE_MATCH', None)\n if if_none_match == response['ETag']:\n # Setting the status is enough here. The response handling path\n # automatically removes content for this status code (in\n # http.conditional_content_removal()).\n response.status_code = 304"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98822:Assign_L18_C12", "label": "if_none_match = get()", "type": "assigned_variable", "loc": [18, 18], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98822:If_L17_C8", "vector": [14, 3, 0.5625, 0.0312, 3, 0.91, 0.0, 907, 3, 2, 0, 0, 607, 10, 1], "semantic": {"name": "if_none_match", "arg_names": [], "import_names": [], "rhs_call_name": "get", "annotation": ""}, "snippet": " if_none_match = request.META.get('HTTP_IF_NONE_MATCH', None)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98822:If_L19_C12", "label": "if", "type": "if", "loc": [19, 23], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98822:If_L17_C8", "vector": [4, 3, 0.6562, 0.1562, 3, 0.91, 1.0, 0, 0, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if if_none_match == response['ETag']:\n # Setting the status is enough here. The response handling path\n # automatically removes content for this status code (in\n # http.conditional_content_removal()).\n response.status_code = 304"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98822:Assign_L23_C16", "label": "response.status_code =", "type": "assigned_variable", "loc": [23, 23], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98822:If_L19_C12", "vector": [14, 4, 0.7188, 0.0312, 4, 0.51, 0.0, 942, 1, 0, 0, 0, 0, 1, 0], "semantic": {"name": "response.status_code", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " response.status_code = 304"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98822:If_L25_C8", "label": "if", "type": "if", "loc": [25, 30], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98822:FunctionDef_L12_C4", "vector": [4, 2, 0.8594, 0.1875, 2, 0.56, 0.75, 0, 3, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if response.has_header('Last-Modified'):\n if_modified_since = request.META.get('HTTP_IF_MODIFIED_SINCE', None)\n if if_modified_since == response['Last-Modified']:\n # Setting the status code is enough here (same reasons as\n # above).\n response.status_code = 304"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98822:Assign_L26_C12", "label": "if_modified_since = get()", "type": "assigned_variable", "loc": [26, 26], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98822:If_L25_C8", "vector": [14, 3, 0.8125, 0.0312, 3, 0.26, 0.0, 880, 3, 2, 0, 0, 607, 10, 1], "semantic": {"name": "if_modified_since", "arg_names": [], "import_names": [], "rhs_call_name": "get", "annotation": ""}, "snippet": " if_modified_since = request.META.get('HTTP_IF_MODIFIED_SINCE', None)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98822:If_L27_C12", "label": "if", "type": "if", "loc": [27, 30], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98822:If_L25_C8", "vector": [4, 3, 0.8906, 0.125, 3, 0.26, 1.0, 0, 0, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if if_modified_since == response['Last-Modified']:\n # Setting the status code is enough here (same reasons as\n # above).\n response.status_code = 304"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98822:Assign_L30_C16", "label": "response.status_code =", "type": "assigned_variable", "loc": [30, 30], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98822:If_L27_C12", "vector": [14, 4, 0.9375, 0.0312, 4, 0.76, 0.0, 942, 1, 0, 0, 0, 0, 1, 0], "semantic": {"name": "response.status_code", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " response.status_code = 304"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98822:Return_L32_C8", "label": "return", "type": "return", "loc": [32, 32], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98822:FunctionDef_L12_C4", "vector": [13, 2, 1.0, 0.0312, 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 response"}]
[{"f": "ajibawa-2023/Python-Code-Large/train/row_98822:ClassDef_L4_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98822:Expr_L5_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98822:ClassDef_L4_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98822:FunctionDef_L12_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98822:FunctionDef_L12_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98822:Assign_L13_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98822:FunctionDef_L12_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98822:If_L14_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98822:If_L14_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98822:Assign_L15_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98822:FunctionDef_L12_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98822:If_L17_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98822:If_L17_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98822:Assign_L18_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98822:If_L17_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98822:If_L19_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98822:If_L19_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98822:Assign_L23_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98822:FunctionDef_L12_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98822:If_L25_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98822:If_L25_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98822:Assign_L26_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98822:If_L25_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98822:If_L27_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98822:If_L27_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98822:Assign_L30_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98822:FunctionDef_L12_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98822:Return_L32_C8"}]
"this is the locale selecting middleware that will look at accept headers" from django.utils.cache import patch_vary_headers from django.utils import translation class LocaleMiddleware(object): """ This is a very simple middleware that parses a request and decides what translation object to install in the current thread context. This allows pages to be dynamically translated to the language the user desires (if the language is available, of course). """ def process_request(self, request): language = translation.get_language_from_request(request) translation.activate(language) request.LANGUAGE_CODE = translation.get_language() def process_response(self, request, response): patch_vary_headers(response, ('Accept-Language',)) if 'Content-Language' not in response: response['Content-Language'] = translation.get_language() translation.deactivate() return response
ajibawa-2023/Python-Code-Large/train/row_98823
15
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_98823:Expr_L1_C0", "label": "expression", "type": "expression", "loc": [1, 1], "level": 0, "parent": null, "vector": [8, 0, 0.04, 0.04, 0, 0.66, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "\"this is the locale selecting middleware that will look at accept headers\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98823:ImportFrom_L3_C0", "label": "from django.utils.cache import patch_vary_headers", "type": "import", "loc": [3, 3], "level": 0, "parent": null, "vector": [1, 0, 0.12, 0.04, 0, 0.66, 0.3333, 53, 0, 1, 0, 0, 53, 0, 0], "semantic": {"name": "django.utils.cache", "arg_names": [], "import_names": ["patch_vary_headers"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.utils.cache import patch_vary_headers"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98823:ImportFrom_L4_C0", "label": "from django.utils import translation", "type": "import", "loc": [4, 4], "level": 0, "parent": null, "vector": [1, 0, 0.16, 0.04, 0, 0.66, 0.6667, 944, 0, 1, 0, 0, 944, 0, 0], "semantic": {"name": "django.utils", "arg_names": [], "import_names": ["translation"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.utils import translation"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98823:ClassDef_L6_C0", "label": "LocaleMiddleware", "type": "class", "loc": [6, 25], "level": 0, "parent": null, "vector": [3, 0, 0.62, 0.8, 0, 0.66, 1.0, 495, 0, 2, 0, 0, 186, 0, 6], "semantic": {"name": "LocaleMiddleware", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class LocaleMiddleware(object):\n \"\"\"\n This is a very simple middleware that parses a request\n and decides what translation object to install in the current\n thread context. This allows pages to be dynamically\n translated to the language the user desires (if the language\n is available, of course).\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98823:Expr_L7_C4", "label": "expression", "type": "expression", "loc": [7, 13], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98823:ClassDef_L6_C0", "vector": [8, 1, 0.4, 0.28, 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 This is a very simple middleware that parses a request\n and decides what translation object to install in the current\n thread context. This allows pages to be dynamically\n translated to the language the user desires (if the language\n is available, of course).\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98823:FunctionDef_L15_C4", "label": "process_request", "type": "function", "loc": [15, 18], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98823:ClassDef_L6_C0", "vector": [2, 1, 0.66, 0.16, 1, 0.52, 0.5, 81, 0, 2, 0, 0, 0, 0, 3], "semantic": {"name": "process_request", "arg_names": ["self", "request"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def process_request(self, request):\n language = translation.get_language_from_request(request)\n translation.activate(language)\n request.LANGUAGE_CODE = translation.get_language()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98823:Assign_L16_C8", "label": "language = get_language_from_request()", "type": "assigned_variable", "loc": [16, 16], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98823:FunctionDef_L15_C4", "vector": [14, 2, 0.64, 0.04, 2, 0.2, 0.0, 214, 3, 1, 0, 0, 441, 10, 1], "semantic": {"name": "language", "arg_names": [], "import_names": [], "rhs_call_name": "get_language_from_request", "annotation": ""}, "snippet": " language = translation.get_language_from_request(request)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98823:Expr_L17_C8", "label": "activate()", "type": "expression", "loc": [17, 17], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98823:FunctionDef_L15_C4", "vector": [8, 2, 0.68, 0.04, 2, 0.2, 0.5, 177, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "activate", "arg_names": [], "import_names": [], "rhs_call_name": "activate", "annotation": ""}, "snippet": " translation.activate(language)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98823:Assign_L18_C8", "label": "request.LANGUAGE_CODE = get_language()", "type": "assigned_variable", "loc": [18, 18], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98823:FunctionDef_L15_C4", "vector": [14, 2, 0.72, 0.04, 2, 0.2, 1.0, 591, 3, 0, 0, 0, 674, 10, 1], "semantic": {"name": "request.LANGUAGE_CODE", "arg_names": [], "import_names": [], "rhs_call_name": "get_language", "annotation": ""}, "snippet": " request.LANGUAGE_CODE = translation.get_language()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98823:FunctionDef_L20_C4", "label": "process_response", "type": "function", "loc": [20, 25], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98823:ClassDef_L6_C0", "vector": [2, 1, 0.9, 0.24, 1, 0.52, 1.0, 298, 0, 3, 1, 0, 0, 0, 3], "semantic": {"name": "process_response", "arg_names": ["self", "request", "response"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def process_response(self, request, response):\n patch_vary_headers(response, ('Accept-Language',))\n if 'Content-Language' not in response:\n response['Content-Language'] = translation.get_language()\n translation.deactivate()\n return response"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98823:Expr_L21_C8", "label": "patch_vary_headers()", "type": "expression", "loc": [21, 21], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98823:FunctionDef_L20_C4", "vector": [8, 2, 0.84, 0.04, 2, 0.37, 0.0, 726, 3, 2, 0, 0, 0, 0, 1], "semantic": {"name": "patch_vary_headers", "arg_names": [], "import_names": [], "rhs_call_name": "patch_vary_headers", "annotation": ""}, "snippet": " patch_vary_headers(response, ('Accept-Language',))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98823:If_L22_C8", "label": "if", "type": "if", "loc": [22, 23], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98823:FunctionDef_L20_C4", "vector": [4, 2, 0.9, 0.08, 2, 0.37, 0.3333, 0, 0, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if 'Content-Language' not in response:\n response['Content-Language'] = translation.get_language()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98823:Assign_L23_C12", "label": " = get_language()", "type": "assigned_variable", "loc": [23, 23], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98823:If_L22_C8", "vector": [14, 3, 0.92, 0.04, 3, 0.7, 0.0, 0, 3, 0, 0, 0, 674, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "get_language", "annotation": ""}, "snippet": " response['Content-Language'] = translation.get_language()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98823:Expr_L24_C8", "label": "deactivate()", "type": "expression", "loc": [24, 24], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98823:FunctionDef_L20_C4", "vector": [8, 2, 0.96, 0.04, 2, 0.37, 0.6667, 499, 3, 0, 0, 0, 0, 0, 1], "semantic": {"name": "deactivate", "arg_names": [], "import_names": [], "rhs_call_name": "deactivate", "annotation": ""}, "snippet": " translation.deactivate()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98823:Return_L25_C8", "label": "return", "type": "return", "loc": [25, 25], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98823:FunctionDef_L20_C4", "vector": [13, 2, 1.0, 0.04, 2, 0.37, 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_98823:ClassDef_L6_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98823:Expr_L7_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98823:ClassDef_L6_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98823:FunctionDef_L15_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98823:FunctionDef_L15_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98823:Assign_L16_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98823:FunctionDef_L15_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98823:Expr_L17_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98823:FunctionDef_L15_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98823:Assign_L18_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98823:ClassDef_L6_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98823:FunctionDef_L20_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98823:FunctionDef_L20_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98823:Expr_L21_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98823:FunctionDef_L20_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98823:If_L22_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98823:If_L22_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98823:Assign_L23_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98823:FunctionDef_L20_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98823:Expr_L24_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98823:FunctionDef_L20_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98823:Return_L25_C8"}]
import re from django.utils.text import compress_string from django.utils.cache import patch_vary_headers re_accepts_gzip = re.compile(r'\bgzip\b') class GZipMiddleware(object): """ This middleware compresses content if the browser allows gzip compression. It sets the Vary header accordingly, so that caches will base their storage on the Accept-Encoding header. """ def process_response(self, request, response): # It's not worth compressing non-OK or really short responses. if response.status_code != 200 or len(response.content) < 200: return response patch_vary_headers(response, ('Accept-Encoding',)) # Avoid gzipping if we've already got a content-encoding. if response.has_header('Content-Encoding'): return response # MSIE have issues with gzipped respones of various content types. if "msie" in request.META.get('HTTP_USER_AGENT', '').lower(): ctype = response.get('Content-Type', '').lower() if not ctype.startswith("text/") or "javascript" in ctype: return response ae = request.META.get('HTTP_ACCEPT_ENCODING', '') if not re_accepts_gzip.search(ae): return response response.content = compress_string(response.content) response['Content-Encoding'] = 'gzip' response['Content-Length'] = str(len(response.content)) return response
ajibawa-2023/Python-Code-Large/train/row_98824
23
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_98824:Import_L1_C0", "label": "re import re", "type": "import", "loc": [1, 1], "level": 0, "parent": null, "vector": [1, 0, 0.0263, 0.0263, 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_98824:ImportFrom_L3_C0", "label": "from django.utils.text import compress_string", "type": "import", "loc": [3, 3], "level": 0, "parent": null, "vector": [1, 0, 0.0789, 0.0263, 0, 0.66, 0.25, 590, 0, 1, 0, 0, 590, 0, 0], "semantic": {"name": "django.utils.text", "arg_names": [], "import_names": ["compress_string"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.utils.text import compress_string"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98824:ImportFrom_L4_C0", "label": "from django.utils.cache import patch_vary_headers", "type": "import", "loc": [4, 4], "level": 0, "parent": null, "vector": [1, 0, 0.1053, 0.0263, 0, 0.66, 0.5, 53, 0, 1, 0, 0, 53, 0, 0], "semantic": {"name": "django.utils.cache", "arg_names": [], "import_names": ["patch_vary_headers"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.utils.cache import patch_vary_headers"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98824:Assign_L6_C0", "label": "re_accepts_gzip = compile()", "type": "assigned_variable", "loc": [6, 6], "level": 0, "parent": null, "vector": [14, 0, 0.1579, 0.0263, 0, 0.66, 0.75, 449, 3, 1, 0, 0, 821, 10, 1], "semantic": {"name": "re_accepts_gzip", "arg_names": [], "import_names": [], "rhs_call_name": "compile", "annotation": ""}, "snippet": "re_accepts_gzip = re.compile(r'\\bgzip\\b')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98824:ClassDef_L8_C0", "label": "GZipMiddleware", "type": "class", "loc": [8, 38], "level": 0, "parent": null, "vector": [3, 0, 0.6053, 0.8158, 0, 0.66, 1.0, 509, 0, 1, 0, 0, 186, 0, 13], "semantic": {"name": "GZipMiddleware", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class GZipMiddleware(object):\n \"\"\"\n This middleware compresses content if the browser allows gzip compression.\n It sets the Vary header accordingly, so that caches will base their storage\n on the Accept-Encoding header.\n \"\"\"\n def process_response(self, request, response):\n # It's not worth compressing non-OK or really short responses."}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98824:Expr_L9_C4", "label": "expression", "type": "expression", "loc": [9, 13], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98824:ClassDef_L8_C0", "vector": [8, 1, 0.2895, 0.1316, 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 This middleware compresses content if the browser allows gzip compression.\n It sets the Vary header accordingly, so that caches will base their storage\n on the Accept-Encoding header.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98824:FunctionDef_L14_C4", "label": "process_response", "type": "function", "loc": [14, 38], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98824:ClassDef_L8_C0", "vector": [2, 1, 0.6842, 0.6579, 1, 0.66, 1.0, 298, 0, 3, 1, 0, 0, 0, 13], "semantic": {"name": "process_response", "arg_names": ["self", "request", "response"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def process_response(self, request, response):\n # It's not worth compressing non-OK or really short responses.\n if response.status_code != 200 or len(response.content) < 200:\n return response\n\n patch_vary_headers(response, ('Accept-Encoding',))\n\n # Avoid gzipping if we've already got a content-encoding."}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98824:If_L16_C8", "label": "if", "type": "if", "loc": [16, 17], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98824:FunctionDef_L14_C4", "vector": [4, 2, 0.4342, 0.0526, 2, 0.11, 0.0, 0, 0, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if response.status_code != 200 or len(response.content) < 200:\n return response"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98824:Return_L17_C12", "label": "return", "type": "return", "loc": [17, 17], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98824:If_L16_C8", "vector": [13, 3, 0.4474, 0.0263, 3, 0.94, 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_98824:Expr_L19_C8", "label": "patch_vary_headers()", "type": "expression", "loc": [19, 19], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98824:FunctionDef_L14_C4", "vector": [8, 2, 0.5, 0.0263, 2, 0.11, 0.1111, 726, 3, 2, 0, 0, 0, 0, 1], "semantic": {"name": "patch_vary_headers", "arg_names": [], "import_names": [], "rhs_call_name": "patch_vary_headers", "annotation": ""}, "snippet": " patch_vary_headers(response, ('Accept-Encoding',))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98824:If_L22_C8", "label": "if", "type": "if", "loc": [22, 23], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98824:FunctionDef_L14_C4", "vector": [4, 2, 0.5921, 0.0526, 2, 0.11, 0.2222, 0, 3, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if response.has_header('Content-Encoding'):\n return response"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98824:Return_L23_C12", "label": "return", "type": "return", "loc": [23, 23], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98824:If_L22_C8", "vector": [13, 3, 0.6053, 0.0263, 3, 0.29, 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_98824:If_L26_C8", "label": "if", "type": "if", "loc": [26, 29], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98824:FunctionDef_L14_C4", "vector": [4, 2, 0.7237, 0.1053, 2, 0.11, 0.3333, 0, 0, 0, 0, 0, 0, 0, 5], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if \"msie\" in request.META.get('HTTP_USER_AGENT', '').lower():\n ctype = response.get('Content-Type', '').lower()\n if not ctype.startswith(\"text/\") or \"javascript\" in ctype:\n return response"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98824:Assign_L27_C12", "label": "ctype = lower()", "type": "assigned_variable", "loc": [27, 27], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98824:If_L26_C8", "vector": [14, 3, 0.7105, 0.0263, 3, 0.28, 0.0, 53, 3, 0, 0, 0, 432, 10, 2], "semantic": {"name": "ctype", "arg_names": [], "import_names": [], "rhs_call_name": "lower", "annotation": ""}, "snippet": " ctype = response.get('Content-Type', '').lower()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98824:If_L28_C12", "label": "if", "type": "if", "loc": [28, 29], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98824:If_L26_C8", "vector": [4, 3, 0.75, 0.0526, 3, 0.28, 1.0, 0, 0, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if not ctype.startswith(\"text/\") or \"javascript\" in ctype:\n return response"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98824:Return_L29_C16", "label": "return", "type": "return", "loc": [29, 29], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98824:If_L28_C12", "vector": [13, 4, 0.7632, 0.0263, 4, 0.11, 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_98824:Assign_L31_C8", "label": "ae = get()", "type": "assigned_variable", "loc": [31, 31], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98824:FunctionDef_L14_C4", "vector": [14, 2, 0.8158, 0.0263, 2, 0.11, 0.4444, 80, 3, 2, 0, 0, 607, 10, 1], "semantic": {"name": "ae", "arg_names": [], "import_names": [], "rhs_call_name": "get", "annotation": ""}, "snippet": " ae = request.META.get('HTTP_ACCEPT_ENCODING', '')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98824:If_L32_C8", "label": "if", "type": "if", "loc": [32, 33], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98824:FunctionDef_L14_C4", "vector": [4, 2, 0.8553, 0.0526, 2, 0.11, 0.5556, 0, 0, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if not re_accepts_gzip.search(ae):\n return response"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98824:Return_L33_C12", "label": "return", "type": "return", "loc": [33, 33], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98824:If_L32_C8", "vector": [13, 3, 0.8684, 0.0263, 3, 0.81, 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_98824:Assign_L35_C8", "label": "response.content = compress_string()", "type": "assigned_variable", "loc": [35, 35], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98824:FunctionDef_L14_C4", "vector": [14, 2, 0.9211, 0.0263, 2, 0.11, 0.6667, 458, 3, 1, 0, 0, 72, 10, 1], "semantic": {"name": "response.content", "arg_names": [], "import_names": [], "rhs_call_name": "compress_string", "annotation": ""}, "snippet": " response.content = compress_string(response.content)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98824:Assign_L36_C8", "label": "assign", "type": "assigned_variable", "loc": [36, 36], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98824:FunctionDef_L14_C4", "vector": [14, 2, 0.9474, 0.0263, 2, 0.11, 0.7778, 0, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " response['Content-Encoding'] = 'gzip'"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98824:Assign_L37_C8", "label": " = str()", "type": "assigned_variable", "loc": [37, 37], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98824:FunctionDef_L14_C4", "vector": [14, 2, 0.9737, 0.0263, 2, 0.11, 0.8889, 0, 3, 1, 0, 0, 52, 10, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "str", "annotation": ""}, "snippet": " response['Content-Length'] = str(len(response.content))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98824:Return_L38_C8", "label": "return", "type": "return", "loc": [38, 38], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98824:FunctionDef_L14_C4", "vector": [13, 2, 1.0, 0.0263, 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 response"}]
[{"f": "ajibawa-2023/Python-Code-Large/train/row_98824:ClassDef_L8_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98824:Expr_L9_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98824:ClassDef_L8_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98824:FunctionDef_L14_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98824:FunctionDef_L14_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98824:If_L16_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98824:If_L16_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98824:Return_L17_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98824:FunctionDef_L14_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98824:Expr_L19_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98824:FunctionDef_L14_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98824:If_L22_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98824:If_L22_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98824:Return_L23_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98824:FunctionDef_L14_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98824:If_L26_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98824:If_L26_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98824:Assign_L27_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98824:If_L26_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98824:If_L28_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98824:If_L28_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98824:Return_L29_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98824:FunctionDef_L14_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98824:Assign_L31_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98824:FunctionDef_L14_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98824:If_L32_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98824:If_L32_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98824:Return_L33_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98824:FunctionDef_L14_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98824:Assign_L35_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98824:FunctionDef_L14_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98824:Assign_L36_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98824:FunctionDef_L14_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98824:Assign_L37_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98824:FunctionDef_L14_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98824:Return_L38_C8"}]
from django.conf import settings from django import http class XViewMiddleware(object): """ Adds an X-View header to internal HEAD requests -- used by the documentation system. """ def process_view(self, request, view_func, view_args, view_kwargs): """ If the request method is HEAD and either the IP is internal or the user is a logged-in staff member, quickly return with an x-header indicating the view function. This is used by the documentation module to lookup the view function for an arbitrary page. """ if request.method == 'HEAD' and (request.META.get('REMOTE_ADDR') in settings.INTERNAL_IPS or (request.user.is_active and request.user.is_staff)): response = http.HttpResponse() response['X-View'] = "%s.%s" % (view_func.__module__, view_func.__name__) return response
ajibawa-2023/Python-Code-Large/train/row_98825
10
19
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_98825:ImportFrom_L1_C0", "label": "from django.conf import settings", "type": "import", "loc": [1, 1], "level": 0, "parent": null, "vector": [1, 0, 0.0526, 0.0526, 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_98825:ImportFrom_L2_C0", "label": "from django import http", "type": "import", "loc": [2, 2], "level": 0, "parent": null, "vector": [1, 0, 0.1053, 0.0526, 0, 0.66, 0.5, 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_98825:ClassDef_L4_C0", "label": "XViewMiddleware", "type": "class", "loc": [4, 19], "level": 0, "parent": null, "vector": [3, 0, 0.6053, 0.8421, 0, 0.66, 1.0, 959, 0, 1, 0, 0, 186, 0, 2], "semantic": {"name": "XViewMiddleware", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class XViewMiddleware(object):\n \"\"\"\n Adds an X-View header to internal HEAD requests -- used by the documentation system.\n \"\"\"\n def process_view(self, request, view_func, view_args, view_kwargs):\n \"\"\"\n If the request method is HEAD and either the IP is internal or the\n user is a logged-in staff member, quickly return with an x-header"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98825:Expr_L5_C4", "label": "expression", "type": "expression", "loc": [5, 7], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98825:ClassDef_L4_C0", "vector": [8, 1, 0.3158, 0.1579, 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 Adds an X-View header to internal HEAD requests -- used by the documentation system.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98825:FunctionDef_L8_C4", "label": "process_view", "type": "function", "loc": [8, 19], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98825:ClassDef_L4_C0", "vector": [2, 1, 0.7105, 0.6316, 1, 0.68, 1.0, 785, 0, 5, 1, 0, 0, 0, 2], "semantic": {"name": "process_view", "arg_names": ["self", "request", "view_func", "view_args", "view_kwargs"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def process_view(self, request, view_func, view_args, view_kwargs):\n \"\"\"\n If the request method is HEAD and either the IP is internal or the\n user is a logged-in staff member, quickly return with an x-header\n indicating the view function. This is used by the documentation module\n to lookup the view function for an arbitrary page.\n \"\"\"\n if request.method == 'HEAD' and (request.META.get('REMOTE_ADDR') in settings.INTERNAL_IPS or"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98825:Expr_L9_C8", "label": "expression", "type": "expression", "loc": [9, 14], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98825:FunctionDef_L8_C4", "vector": [8, 2, 0.6053, 0.3158, 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 If the request method is HEAD and either the IP is internal or the\n user is a logged-in staff member, quickly return with an x-header\n indicating the view function. This is used by the documentation module\n to lookup the view function for an arbitrary page.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98825:If_L15_C8", "label": "if", "type": "if", "loc": [15, 19], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98825:FunctionDef_L8_C4", "vector": [4, 2, 0.8947, 0.2632, 2, 0.28, 1.0, 0, 0, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if request.method == 'HEAD' and (request.META.get('REMOTE_ADDR') in settings.INTERNAL_IPS or\n (request.user.is_active and request.user.is_staff)):\n response = http.HttpResponse()\n response['X-View'] = \"%s.%s\" % (view_func.__module__, view_func.__name__)\n return response"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98825:Assign_L17_C12", "label": "response = HttpResponse()", "type": "assigned_variable", "loc": [17, 17], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98825:If_L15_C8", "vector": [14, 3, 0.8947, 0.0526, 3, 0.71, 0.0, 511, 3, 0, 0, 0, 994, 10, 1], "semantic": {"name": "response", "arg_names": [], "import_names": [], "rhs_call_name": "HttpResponse", "annotation": ""}, "snippet": " response = http.HttpResponse()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98825:Assign_L18_C12", "label": "assign", "type": "assigned_variable", "loc": [18, 18], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98825:If_L15_C8", "vector": [14, 3, 0.9474, 0.0526, 3, 0.71, 0.5, 0, 4, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " response['X-View'] = \"%s.%s\" % (view_func.__module__, view_func.__name__)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98825:Return_L19_C12", "label": "return", "type": "return", "loc": [19, 19], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98825:If_L15_C8", "vector": [13, 3, 1.0, 0.0526, 3, 0.71, 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_98825:ClassDef_L4_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98825:Expr_L5_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98825:ClassDef_L4_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98825:FunctionDef_L8_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98825:FunctionDef_L8_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98825:Expr_L9_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98825:FunctionDef_L8_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98825:If_L15_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98825:If_L15_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98825:Assign_L17_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98825:If_L15_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98825:Assign_L18_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98825:If_L15_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98825:Return_L19_C12"}]
""" Cross Site Request Forgery Middleware. This module provides a middleware that implements protection against request forgeries from other sites. """ import itertools import re import random from django.conf import settings from django.core.urlresolvers import get_callable from django.utils.cache import patch_vary_headers from django.utils.hashcompat import md5_constructor from django.utils.log import getLogger from django.utils.safestring import mark_safe from django.utils.crypto import constant_time_compare _POST_FORM_RE = \ re.compile(r'(<form\W[^>]*\bmethod\s*=\s*(\'|"|)POST(\'|"|)\b[^>]*>)', re.IGNORECASE) _HTML_TYPES = ('text/html', 'application/xhtml+xml') logger = getLogger('django.request') # Use the system (hardware-based) random number generator if it exists. if hasattr(random, 'SystemRandom'): randrange = random.SystemRandom().randrange else: randrange = random.randrange _MAX_CSRF_KEY = 18446744073709551616L # 2 << 63 REASON_NO_REFERER = "Referer checking failed - no Referer." REASON_BAD_REFERER = "Referer checking failed - %s does not match %s." REASON_NO_COOKIE = "No CSRF or session cookie." REASON_NO_CSRF_COOKIE = "CSRF cookie not set." REASON_BAD_TOKEN = "CSRF token missing or incorrect." def _get_failure_view(): """ Returns the view to be used for CSRF rejections """ return get_callable(settings.CSRF_FAILURE_VIEW) def _get_new_csrf_key(): return md5_constructor("%s%s" % (randrange(0, _MAX_CSRF_KEY), settings.SECRET_KEY)).hexdigest() def _make_legacy_session_token(session_id): return md5_constructor(settings.SECRET_KEY + session_id).hexdigest() def get_token(request): """ Returns the the CSRF token required for a POST form. The token is an alphanumeric value. A side effect of calling this function is to make the the csrf_protect decorator and the CsrfViewMiddleware add a CSRF cookie and a 'Vary: Cookie' header to the outgoing response. For this reason, you may need to use this function lazily, as is done by the csrf context processor. """ request.META["CSRF_COOKIE_USED"] = True return request.META.get("CSRF_COOKIE", None) def _sanitize_token(token): # Allow only alphanum, and ensure we return a 'str' for the sake of the post # processing middleware. token = re.sub('[^a-zA-Z0-9]', '', str(token.decode('ascii', 'ignore'))) if token == "": # In case the cookie has been truncated to nothing at some point. return _get_new_csrf_key() else: return token class CsrfViewMiddleware(object): """ Middleware that requires a present and correct csrfmiddlewaretoken for POST requests that have a CSRF cookie, and sets an outgoing CSRF cookie. This middleware should be used in conjunction with the csrf_token template tag. """ # The _accept and _reject methods currently only exist for the sake of the # requires_csrf_token decorator. def _accept(self, request): # Avoid checking the request twice by adding a custom attribute to # request. This will be relevant when both decorator and middleware # are used. request.csrf_processing_done = True return None def _reject(self, request, reason): return _get_failure_view()(request, reason=reason) def process_view(self, request, callback, callback_args, callback_kwargs): if getattr(request, 'csrf_processing_done', False): return None # If the user doesn't have a CSRF cookie, generate one and store it in the # request, so it's available to the view. We'll store it in a cookie when # we reach the response. try: # In case of cookies from untrusted sources, we strip anything # dangerous at this point, so that the cookie + token will have the # same, sanitized value. request.META["CSRF_COOKIE"] = _sanitize_token(request.COOKIES[settings.CSRF_COOKIE_NAME]) cookie_is_new = False except KeyError: # No cookie, so create one. This will be sent with the next # response. request.META["CSRF_COOKIE"] = _get_new_csrf_key() # Set a flag to allow us to fall back and allow the session id in # place of a CSRF cookie for this request only. cookie_is_new = True # Wait until request.META["CSRF_COOKIE"] has been manipulated before # bailing out, so that get_token still works if getattr(callback, 'csrf_exempt', False): return None if request.method == 'POST': if getattr(request, '_dont_enforce_csrf_checks', False): # Mechanism to turn off CSRF checks for test suite. It comes after # the creation of CSRF cookies, so that everything else continues to # work exactly the same (e.g. cookies are sent etc), but before the # any branches that call reject() return self._accept(request) if request.is_ajax(): # .is_ajax() is based on the presence of X-Requested-With. In # the context of a browser, this can only be sent if using # XmlHttpRequest. Browsers implement careful policies for # XmlHttpRequest: # # * Normally, only same-domain requests are allowed. # # * Some browsers (e.g. Firefox 3.5 and later) relax this # carefully: # # * if it is a 'simple' GET or POST request (which can # include no custom headers), it is allowed to be cross # domain. These requests will not be recognized as AJAX. # # * if a 'preflight' check with the server confirms that the # server is expecting and allows the request, cross domain # requests even with custom headers are allowed. These # requests will be recognized as AJAX, but can only get # through when the developer has specifically opted in to # allowing the cross-domain POST request. # # So in all cases, it is safe to allow these requests through. return self._accept(request) if request.is_secure(): # Suppose user visits http://example.com/ # An active network attacker,(man-in-the-middle, MITM) sends a # POST form which targets https://example.com/detonate-bomb/ and # submits it via javascript. # # The attacker will need to provide a CSRF cookie and token, but # that is no problem for a MITM and the session independent # nonce we are using. So the MITM can circumvent the CSRF # protection. This is true for any HTTP connection, but anyone # using HTTPS expects better! For this reason, for # https://example.com/ we need additional protection that treats # http://example.com/ as completely untrusted. Under HTTPS, # Barth et al. found that the Referer header is missing for # same-domain requests in only about 0.2% of cases or less, so # we can use strict Referer checking. referer = request.META.get('HTTP_REFERER') if referer is None: logger.warning('Forbidden (%s): %s' % (REASON_NO_COOKIE, request.path), extra={ 'status_code': 403, 'request': request, } ) return self._reject(request, REASON_NO_REFERER) # The following check ensures that the referer is HTTPS, # the domains match and the ports match - the same origin policy. good_referer = 'https://%s/' % request.get_host() if not referer.startswith(good_referer): reason = REASON_BAD_REFERER % (referer, good_referer) logger.warning('Forbidden (%s): %s' % (reason, request.path), extra={ 'status_code': 403, 'request': request, } ) return self._reject(request, reason) # If the user didn't already have a CSRF cookie, then fall back to # the Django 1.1 method (hash of session ID), so a request is not # rejected if the form was sent to the user before upgrading to the # Django 1.2 method (session independent nonce) if cookie_is_new: try: session_id = request.COOKIES[settings.SESSION_COOKIE_NAME] csrf_token = _make_legacy_session_token(session_id) except KeyError: # No CSRF cookie and no session cookie. For POST requests, # we insist on a CSRF cookie, and in this way we can avoid # all CSRF attacks, including login CSRF. logger.warning('Forbidden (%s): %s' % (REASON_NO_COOKIE, request.path), extra={ 'status_code': 403, 'request': request, } ) return self._reject(request, REASON_NO_COOKIE) else: csrf_token = request.META["CSRF_COOKIE"] # check incoming token request_csrf_token = request.POST.get('csrfmiddlewaretoken', '') if not constant_time_compare(request_csrf_token, csrf_token): if cookie_is_new: # probably a problem setting the CSRF cookie logger.warning('Forbidden (%s): %s' % (REASON_NO_CSRF_COOKIE, request.path), extra={ 'status_code': 403, 'request': request, } ) return self._reject(request, REASON_NO_CSRF_COOKIE) else: logger.warning('Forbidden (%s): %s' % (REASON_BAD_TOKEN, request.path), extra={ 'status_code': 403, 'request': request, } ) return self._reject(request, REASON_BAD_TOKEN) return self._accept(request) def process_response(self, request, response): if getattr(response, 'csrf_processing_done', False): return response # If CSRF_COOKIE is unset, then CsrfViewMiddleware.process_view was # never called, probaby because a request middleware returned a response # (for example, contrib.auth redirecting to a login page). if request.META.get("CSRF_COOKIE") is None: return response if not request.META.get("CSRF_COOKIE_USED", False): return response # Set the CSRF cookie even if it's already set, so we renew the expiry timer. response.set_cookie(settings.CSRF_COOKIE_NAME, request.META["CSRF_COOKIE"], max_age = 60 * 60 * 24 * 7 * 52, domain=settings.CSRF_COOKIE_DOMAIN) # Content varies with the CSRF cookie, so set the Vary header. patch_vary_headers(response, ('Cookie',)) response.csrf_processing_done = True return response class CsrfResponseMiddleware(object): """ DEPRECATED Middleware that post-processes a response to add a csrfmiddlewaretoken. This exists for backwards compatibility and as an interim measure until applications are converted to using use the csrf_token template tag instead. It will be removed in Django 1.4. """ def __init__(self): import warnings warnings.warn( "CsrfResponseMiddleware and CsrfMiddleware are deprecated; use CsrfViewMiddleware and the template tag instead (see CSRF documentation).", DeprecationWarning ) def process_response(self, request, response): if getattr(response, 'csrf_exempt', False): return response if response['Content-Type'].split(';')[0] in _HTML_TYPES: csrf_token = get_token(request) # If csrf_token is None, we have no token for this request, which probably # means that this is a response from a request middleware. if csrf_token is None: return response # ensure we don't add the 'id' attribute twice (HTML validity) idattributes = itertools.chain(("id='csrfmiddlewaretoken'",), itertools.repeat('')) def add_csrf_field(match): """Returns the matched <form> tag plus the added <input> element""" return mark_safe(match.group() + "<div style='display:none;'>" + \ "<input type='hidden' " + idattributes.next() + \ " name='csrfmiddlewaretoken' value='" + csrf_token + \ "' /></div>") # Modify any POST forms response.content, n = _POST_FORM_RE.subn(add_csrf_field, response.content) if n > 0: # Content varies with the CSRF cookie, so set the Vary header. patch_vary_headers(response, ('Cookie',)) # Since the content has been modified, any Etag will now be # incorrect. We could recalculate, but only if we assume that # the Etag was set by CommonMiddleware. The safest thing is just # to delete. See bug #9163 del response['ETag'] return response class CsrfMiddleware(object): """ Django middleware that adds protection against Cross Site Request Forgeries by adding hidden form fields to POST forms and checking requests for the correct value. CsrfMiddleware uses two middleware, CsrfViewMiddleware and CsrfResponseMiddleware, which can be used independently. It is recommended to use only CsrfViewMiddleware and use the csrf_token template tag in templates for inserting the token. """ # We can't just inherit from CsrfViewMiddleware and CsrfResponseMiddleware # because both have process_response methods. def __init__(self): self.response_middleware = CsrfResponseMiddleware() self.view_middleware = CsrfViewMiddleware() def process_response(self, request, resp): # We must do the response post-processing first, because that calls # get_token(), which triggers a flag saying that the CSRF cookie needs # to be sent (done in CsrfViewMiddleware.process_response) resp2 = self.response_middleware.process_response(request, resp) return self.view_middleware.process_response(request, resp2) def process_view(self, request, callback, callback_args, callback_kwargs): return self.view_middleware.process_view(request, callback, callback_args, callback_kwargs)
ajibawa-2023/Python-Code-Large/train/row_98826
126
345
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_98826:Expr_L1_C0", "label": "expression", "type": "expression", "loc": [1, 6], "level": 0, "parent": null, "vector": [8, 0, 0.0101, 0.0174, 0, 0.66, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "\"\"\"\nCross Site Request Forgery Middleware.\n\nThis module provides a middleware that implements protection\nagainst request forgeries from other sites.\n\"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98826:Import_L8_C0", "label": "itertools import itertools", "type": "import", "loc": [8, 8], "level": 0, "parent": null, "vector": [1, 0, 0.0232, 0.0029, 0, 0.66, 0.037, 808, 0, 1, 0, 0, 808, 0, 0], "semantic": {"name": "itertools", "arg_names": [], "import_names": ["itertools"], "rhs_call_name": "", "annotation": ""}, "snippet": "import itertools"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98826:Import_L9_C0", "label": "re import re", "type": "import", "loc": [9, 9], "level": 0, "parent": null, "vector": [1, 0, 0.0261, 0.0029, 0, 0.66, 0.0741, 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_98826:Import_L10_C0", "label": "random import random", "type": "import", "loc": [10, 10], "level": 0, "parent": null, "vector": [1, 0, 0.029, 0.0029, 0, 0.66, 0.1111, 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_98826:ImportFrom_L12_C0", "label": "from django.conf import settings", "type": "import", "loc": [12, 12], "level": 0, "parent": null, "vector": [1, 0, 0.0348, 0.0029, 0, 0.66, 0.1481, 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_98826:ImportFrom_L13_C0", "label": "from django.core.urlresolvers import get_callable", "type": "import", "loc": [13, 13], "level": 0, "parent": null, "vector": [1, 0, 0.0377, 0.0029, 0, 0.66, 0.1852, 749, 0, 1, 0, 0, 749, 0, 0], "semantic": {"name": "django.core.urlresolvers", "arg_names": [], "import_names": ["get_callable"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.core.urlresolvers import get_callable"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98826:ImportFrom_L14_C0", "label": "from django.utils.cache import patch_vary_headers", "type": "import", "loc": [14, 14], "level": 0, "parent": null, "vector": [1, 0, 0.0406, 0.0029, 0, 0.66, 0.2222, 53, 0, 1, 0, 0, 53, 0, 0], "semantic": {"name": "django.utils.cache", "arg_names": [], "import_names": ["patch_vary_headers"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.utils.cache import patch_vary_headers"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98826:ImportFrom_L15_C0", "label": "from django.utils.hashcompat import md5_constructor", "type": "import", "loc": [15, 15], "level": 0, "parent": null, "vector": [1, 0, 0.0435, 0.0029, 0, 0.66, 0.2593, 474, 0, 1, 0, 0, 474, 0, 0], "semantic": {"name": "django.utils.hashcompat", "arg_names": [], "import_names": ["md5_constructor"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.utils.hashcompat import md5_constructor"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98826:ImportFrom_L16_C0", "label": "from django.utils.log import getLogger", "type": "import", "loc": [16, 16], "level": 0, "parent": null, "vector": [1, 0, 0.0464, 0.0029, 0, 0.66, 0.2963, 174, 0, 1, 0, 0, 174, 0, 0], "semantic": {"name": "django.utils.log", "arg_names": [], "import_names": ["getLogger"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.utils.log import getLogger"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98826:ImportFrom_L17_C0", "label": "from django.utils.safestring import mark_safe", "type": "import", "loc": [17, 17], "level": 0, "parent": null, "vector": [1, 0, 0.0493, 0.0029, 0, 0.66, 0.3333, 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_98826:ImportFrom_L18_C0", "label": "from django.utils.crypto import constant_time_compare", "type": "import", "loc": [18, 18], "level": 0, "parent": null, "vector": [1, 0, 0.0522, 0.0029, 0, 0.66, 0.3704, 657, 0, 1, 0, 0, 657, 0, 0], "semantic": {"name": "django.utils.crypto", "arg_names": [], "import_names": ["constant_time_compare"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.utils.crypto import constant_time_compare"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98826:Assign_L20_C0", "label": "_POST_FORM_RE = compile()", "type": "assigned_variable", "loc": [20, 21], "level": 0, "parent": null, "vector": [14, 0, 0.0594, 0.0058, 0, 0.66, 0.4074, 43, 3, 2, 0, 0, 821, 10, 1], "semantic": {"name": "_POST_FORM_RE", "arg_names": [], "import_names": [], "rhs_call_name": "compile", "annotation": ""}, "snippet": "_POST_FORM_RE = \\\n re.compile(r'(<form\\W[^>]*\\bmethod\\s*=\\s*(\\'|\"|)POST(\\'|\"|)\\b[^>]*>)', re.IGNORECASE)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98826:Assign_L23_C0", "label": "_HTML_TYPES =", "type": "assigned_variable", "loc": [23, 23], "level": 0, "parent": null, "vector": [14, 0, 0.0667, 0.0029, 0, 0.66, 0.4444, 966, 0, 0, 0, 0, 0, 8, 0], "semantic": {"name": "_HTML_TYPES", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "_HTML_TYPES = ('text/html', 'application/xhtml+xml')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98826:Assign_L25_C0", "label": "logger = getLogger()", "type": "assigned_variable", "loc": [25, 25], "level": 0, "parent": null, "vector": [14, 0, 0.0725, 0.0029, 0, 0.66, 0.4815, 532, 3, 1, 0, 0, 71, 10, 1], "semantic": {"name": "logger", "arg_names": [], "import_names": [], "rhs_call_name": "getLogger", "annotation": ""}, "snippet": "logger = getLogger('django.request')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98826:If_L28_C0", "label": "if", "type": "if", "loc": [28, 31], "level": 0, "parent": null, "vector": [4, 0, 0.0855, 0.0116, 0, 0.66, 0.5185, 0, 3, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "if hasattr(random, 'SystemRandom'):\n randrange = random.SystemRandom().randrange\nelse:\n randrange = random.randrange"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98826:Assign_L29_C4", "label": "randrange =", "type": "assigned_variable", "loc": [29, 29], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98826:If_L28_C0", "vector": [14, 1, 0.0841, 0.0029, 1, 0.71, 0.0, 28, 7, 0, 0, 0, 0, 0, 1], "semantic": {"name": "randrange", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " randrange = random.SystemRandom().randrange"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98826:Assign_L31_C4", "label": "randrange =", "type": "assigned_variable", "loc": [31, 31], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98826:If_L28_C0", "vector": [14, 1, 0.0899, 0.0029, 1, 0.71, 1.0, 28, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "randrange", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " randrange = random.randrange"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98826:Assign_L33_C0", "label": "REASON_NO_REFERER =", "type": "assigned_variable", "loc": [33, 33], "level": 0, "parent": null, "vector": [14, 0, 0.0957, 0.0029, 0, 0.66, 0.5556, 118, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "REASON_NO_REFERER", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "REASON_NO_REFERER = \"Referer checking failed - no Referer.\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98826:Assign_L34_C0", "label": "REASON_BAD_REFERER =", "type": "assigned_variable", "loc": [34, 34], "level": 0, "parent": null, "vector": [14, 0, 0.0986, 0.0029, 0, 0.66, 0.5926, 494, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "REASON_BAD_REFERER", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "REASON_BAD_REFERER = \"Referer checking failed - %s does not match %s.\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98826:Assign_L35_C0", "label": "REASON_NO_COOKIE =", "type": "assigned_variable", "loc": [35, 35], "level": 0, "parent": null, "vector": [14, 0, 0.1014, 0.0029, 0, 0.66, 0.6296, 644, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "REASON_NO_COOKIE", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "REASON_NO_COOKIE = \"No CSRF or session cookie.\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98826:Assign_L36_C0", "label": "REASON_NO_CSRF_COOKIE =", "type": "assigned_variable", "loc": [36, 36], "level": 0, "parent": null, "vector": [14, 0, 0.1043, 0.0029, 0, 0.66, 0.6667, 244, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "REASON_NO_CSRF_COOKIE", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "REASON_NO_CSRF_COOKIE = \"CSRF cookie not set.\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98826:Assign_L37_C0", "label": "REASON_BAD_TOKEN =", "type": "assigned_variable", "loc": [37, 37], "level": 0, "parent": null, "vector": [14, 0, 0.1072, 0.0029, 0, 0.66, 0.7037, 189, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "REASON_BAD_TOKEN", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "REASON_BAD_TOKEN = \"CSRF token missing or incorrect.\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98826:FunctionDef_L40_C0", "label": "_get_failure_view", "type": "function", "loc": [40, 44], "level": 0, "parent": null, "vector": [2, 0, 0.1217, 0.0145, 0, 0.66, 0.7407, 466, 0, 0, 1, 0, 0, 0, 1], "semantic": {"name": "_get_failure_view", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "def _get_failure_view():\n \"\"\"\n Returns the view to be used for CSRF rejections\n \"\"\"\n return get_callable(settings.CSRF_FAILURE_VIEW)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98826:Expr_L41_C4", "label": "expression", "type": "expression", "loc": [41, 43], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98826:FunctionDef_L40_C0", "vector": [8, 1, 0.1217, 0.0087, 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 Returns the view to be used for CSRF rejections\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98826:Return_L44_C4", "label": "return", "type": "return", "loc": [44, 44], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98826:FunctionDef_L40_C0", "vector": [13, 1, 0.1275, 0.0029, 1, 0.11, 1.0, 0, 3, 0, 0, 0, 0, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return get_callable(settings.CSRF_FAILURE_VIEW)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98826:FunctionDef_L47_C0", "label": "_get_new_csrf_key", "type": "function", "loc": [47, 49], "level": 0, "parent": null, "vector": [2, 0, 0.1391, 0.0087, 0, 0.66, 0.7778, 507, 0, 0, 1, 0, 0, 0, 3], "semantic": {"name": "_get_new_csrf_key", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "def _get_new_csrf_key():\n return md5_constructor(\"%s%s\"\n % (randrange(0, _MAX_CSRF_KEY), settings.SECRET_KEY)).hexdigest()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98826:Return_L48_C4", "label": "return", "type": "return", "loc": [48, 49], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98826:FunctionDef_L47_C0", "vector": [13, 1, 0.1406, 0.0058, 1, 0.22, 0.0, 0, 3, 0, 0, 0, 0, 10, 3], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return md5_constructor(\"%s%s\"\n % (randrange(0, _MAX_CSRF_KEY), settings.SECRET_KEY)).hexdigest()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98826:FunctionDef_L52_C0", "label": "_make_legacy_session_token", "type": "function", "loc": [52, 53], "level": 0, "parent": null, "vector": [2, 0, 0.1522, 0.0058, 0, 0.66, 0.8148, 991, 0, 1, 1, 0, 0, 0, 2], "semantic": {"name": "_make_legacy_session_token", "arg_names": ["session_id"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "def _make_legacy_session_token(session_id):\n return md5_constructor(settings.SECRET_KEY + session_id).hexdigest()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98826:Return_L53_C4", "label": "return", "type": "return", "loc": [53, 53], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98826:FunctionDef_L52_C0", "vector": [13, 1, 0.1536, 0.0029, 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 md5_constructor(settings.SECRET_KEY + session_id).hexdigest()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98826:FunctionDef_L56_C0", "label": "get_token", "type": "function", "loc": [56, 67], "level": 0, "parent": null, "vector": [2, 0, 0.1783, 0.0348, 0, 0.66, 0.8519, 224, 0, 1, 1, 0, 0, 0, 1], "semantic": {"name": "get_token", "arg_names": ["request"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "def get_token(request):\n \"\"\"\n Returns the the CSRF token required for a POST form. The token is an\n alphanumeric value.\n\n A side effect of calling this function is to make the the csrf_protect\n decorator and the CsrfViewMiddleware add a CSRF cookie and a 'Vary: Cookie'\n header to the outgoing response. For this reason, you may need to use this"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98826:Expr_L57_C4", "label": "expression", "type": "expression", "loc": [57, 65], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98826:FunctionDef_L56_C0", "vector": [8, 1, 0.1768, 0.0261, 1, 0.81, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"\n Returns the the CSRF token required for a POST form. The token is an\n alphanumeric value.\n\n A side effect of calling this function is to make the the csrf_protect\n decorator and the CsrfViewMiddleware add a CSRF cookie and a 'Vary: Cookie'\n header to the outgoing response. For this reason, you may need to use this\n function lazily, as is done by the csrf context processor."}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98826:Assign_L66_C4", "label": "assign", "type": "assigned_variable", "loc": [66, 66], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98826:FunctionDef_L56_C0", "vector": [14, 1, 0.1913, 0.0029, 1, 0.81, 0.5, 0, 1, 0, 0, 0, 0, 4, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " request.META[\"CSRF_COOKIE_USED\"] = True"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98826:Return_L67_C4", "label": "return", "type": "return", "loc": [67, 67], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98826:FunctionDef_L56_C0", "vector": [13, 1, 0.1942, 0.0029, 1, 0.81, 1.0, 0, 3, 0, 0, 0, 0, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return request.META.get(\"CSRF_COOKIE\", None)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98826:FunctionDef_L70_C0", "label": "_sanitize_token", "type": "function", "loc": [70, 78], "level": 0, "parent": null, "vector": [2, 0, 0.2145, 0.0261, 0, 0.66, 0.8889, 894, 0, 1, 1, 0, 0, 0, 4], "semantic": {"name": "_sanitize_token", "arg_names": ["token"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "def _sanitize_token(token):\n # Allow only alphanum, and ensure we return a 'str' for the sake of the post\n # processing middleware.\n token = re.sub('[^a-zA-Z0-9]', '', str(token.decode('ascii', 'ignore')))\n if token == \"\":\n # In case the cookie has been truncated to nothing at some point.\n return _get_new_csrf_key()\n else:"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98826:Assign_L73_C4", "label": "token = sub()", "type": "assigned_variable", "loc": [73, 73], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98826:FunctionDef_L70_C0", "vector": [14, 1, 0.2116, 0.0029, 1, 0.32, 0.0, 129, 3, 3, 0, 0, 819, 10, 3], "semantic": {"name": "token", "arg_names": [], "import_names": [], "rhs_call_name": "sub", "annotation": ""}, "snippet": " token = re.sub('[^a-zA-Z0-9]', '', str(token.decode('ascii', 'ignore')))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98826:If_L74_C4", "label": "if", "type": "if", "loc": [74, 78], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98826:FunctionDef_L70_C0", "vector": [4, 1, 0.2203, 0.0145, 1, 0.32, 1.0, 0, 0, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if token == \"\":\n # In case the cookie has been truncated to nothing at some point.\n return _get_new_csrf_key()\n else:\n return token"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98826:Return_L76_C8", "label": "return", "type": "return", "loc": [76, 76], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98826:If_L74_C4", "vector": [13, 2, 0.2203, 0.0029, 2, 0.08, 0.0, 0, 3, 0, 0, 0, 0, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return _get_new_csrf_key()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98826:Return_L78_C8", "label": "return", "type": "return", "loc": [78, 78], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98826:If_L74_C4", "vector": [13, 2, 0.2261, 0.0029, 2, 0.08, 1.0, 0, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return token"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98826:ClassDef_L81_C0", "label": "CsrfViewMiddleware", "type": "class", "loc": [81, 265], "level": 0, "parent": null, "vector": [3, 0, 0.5014, 0.5362, 0, 0.66, 0.9259, 447, 0, 4, 0, 0, 186, 0, 33], "semantic": {"name": "CsrfViewMiddleware", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class CsrfViewMiddleware(object):\n \"\"\"\n Middleware that requires a present and correct csrfmiddlewaretoken\n for POST requests that have a CSRF cookie, and sets an outgoing\n CSRF cookie.\n\n This middleware should be used in conjunction with the csrf_token template\n tag."}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98826:Expr_L82_C4", "label": "expression", "type": "expression", "loc": [82, 89], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98826:ClassDef_L81_C0", "vector": [8, 1, 0.2478, 0.0232, 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 Middleware that requires a present and correct csrfmiddlewaretoken\n for POST requests that have a CSRF cookie, and sets an outgoing\n CSRF cookie.\n\n This middleware should be used in conjunction with the csrf_token template\n tag.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98826:FunctionDef_L92_C4", "label": "_accept", "type": "function", "loc": [92, 97], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98826:ClassDef_L81_C0", "vector": [2, 1, 0.2739, 0.0174, 1, 0.09, 0.25, 462, 0, 2, 1, 0, 0, 0, 0], "semantic": {"name": "_accept", "arg_names": ["self", "request"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def _accept(self, request):\n # Avoid checking the request twice by adding a custom attribute to\n # request. This will be relevant when both decorator and middleware\n # are used.\n request.csrf_processing_done = True\n return None"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98826:Assign_L96_C8", "label": "request.csrf_processing_done =", "type": "assigned_variable", "loc": [96, 96], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98826:FunctionDef_L92_C4", "vector": [14, 2, 0.2783, 0.0029, 2, 0.99, 0.0, 265, 1, 0, 0, 0, 0, 4, 0], "semantic": {"name": "request.csrf_processing_done", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " request.csrf_processing_done = True"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98826:Return_L97_C8", "label": "return", "type": "return", "loc": [97, 97], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98826:FunctionDef_L92_C4", "vector": [13, 2, 0.2812, 0.0029, 2, 0.99, 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_98826:FunctionDef_L99_C4", "label": "_reject", "type": "function", "loc": [99, 100], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98826:ClassDef_L81_C0", "vector": [2, 1, 0.2884, 0.0058, 1, 0.09, 0.5, 805, 0, 3, 1, 0, 0, 0, 2], "semantic": {"name": "_reject", "arg_names": ["self", "request", "reason"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def _reject(self, request, reason):\n return _get_failure_view()(request, reason=reason)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98826:Return_L100_C8", "label": "return", "type": "return", "loc": [100, 100], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98826:FunctionDef_L99_C4", "vector": [13, 2, 0.2899, 0.0029, 2, 0.08, 0.0, 0, 3, 0, 0, 0, 0, 10, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return _get_failure_view()(request, reason=reason)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98826:FunctionDef_L102_C4", "label": "process_view", "type": "function", "loc": [102, 243], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98826:ClassDef_L81_C0", "vector": [2, 1, 0.5, 0.4116, 1, 0.09, 0.75, 785, 0, 5, 1, 0, 0, 0, 26], "semantic": {"name": "process_view", "arg_names": ["self", "request", "callback", "callback_args", "callback_kwargs"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def process_view(self, request, callback, callback_args, callback_kwargs):\n if getattr(request, 'csrf_processing_done', False):\n return None\n\n # If the user doesn't have a CSRF cookie, generate one and store it in the\n # request, so it's available to the view. We'll store it in a cookie when\n # we reach the response.\n try:"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98826:If_L103_C8", "label": "if", "type": "if", "loc": [103, 104], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98826:FunctionDef_L102_C4", "vector": [4, 2, 0.3, 0.0058, 2, 0.59, 0.0, 0, 3, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if getattr(request, 'csrf_processing_done', False):\n return None"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98826:Return_L104_C12", "label": "return", "type": "return", "loc": [104, 104], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98826:If_L103_C8", "vector": [13, 3, 0.3014, 0.0029, 3, 0.15, 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_98826:Try_L109_C8", "label": "try", "type": "try", "loc": [109, 121], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98826:FunctionDef_L102_C4", "vector": [7, 2, 0.3333, 0.0377, 2, 0.59, 0.25, 0, 0, 1, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " try:\n # In case of cookies from untrusted sources, we strip anything\n # dangerous at this point, so that the cookie + token will have the\n # same, sanitized value.\n request.META[\"CSRF_COOKIE\"] = _sanitize_token(request.COOKIES[settings.CSRF_COOKIE_NAME])\n cookie_is_new = False\n except KeyError:\n # No cookie, so create one. This will be sent with the next"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98826:Assign_L113_C12", "label": " = _sanitize_token()", "type": "assigned_variable", "loc": [113, 113], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98826:Try_L109_C8", "vector": [14, 3, 0.3275, 0.0029, 3, 0.24, 0.0, 0, 3, 1, 0, 0, 894, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "_sanitize_token", "annotation": ""}, "snippet": " request.META[\"CSRF_COOKIE\"] = _sanitize_token(request.COOKIES[settings.CSRF_COOKIE_NAME])"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98826:Assign_L114_C12", "label": "cookie_is_new =", "type": "assigned_variable", "loc": [114, 114], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98826:Try_L109_C8", "vector": [14, 3, 0.3304, 0.0029, 3, 0.24, 1.0, 447, 1, 0, 0, 0, 0, 4, 0], "semantic": {"name": "cookie_is_new", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " cookie_is_new = False"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98826:Assign_L118_C12", "label": " = _get_new_csrf_key()", "type": "assigned_variable", "loc": [118, 118], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98826:Try_L109_C8", "vector": [14, 3, 0.342, 0.0029, 3, 0.24, 0.0, 0, 3, 0, 0, 0, 507, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "_get_new_csrf_key", "annotation": ""}, "snippet": " request.META[\"CSRF_COOKIE\"] = _get_new_csrf_key()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98826:Assign_L121_C12", "label": "cookie_is_new =", "type": "assigned_variable", "loc": [121, 121], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98826:Try_L109_C8", "vector": [14, 3, 0.3507, 0.0029, 3, 0.24, 1.0, 447, 1, 0, 0, 0, 0, 4, 0], "semantic": {"name": "cookie_is_new", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " cookie_is_new = True"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98826:If_L125_C8", "label": "if", "type": "if", "loc": [125, 126], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98826:FunctionDef_L102_C4", "vector": [4, 2, 0.3638, 0.0058, 2, 0.59, 0.5, 0, 3, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if getattr(callback, 'csrf_exempt', False):\n return None"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98826:Return_L126_C12", "label": "return", "type": "return", "loc": [126, 126], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98826:If_L125_C8", "vector": [13, 3, 0.3652, 0.0029, 3, 0.31, 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_98826:If_L128_C8", "label": "if", "type": "if", "loc": [128, 241], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98826:FunctionDef_L102_C4", "vector": [4, 2, 0.5348, 0.3304, 2, 0.59, 0.75, 0, 0, 0, 0, 0, 0, 0, 21], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if request.method == 'POST':\n if getattr(request, '_dont_enforce_csrf_checks', False):\n # Mechanism to turn off CSRF checks for test suite. It comes after\n # the creation of CSRF cookies, so that everything else continues to\n # work exactly the same (e.g. cookies are sent etc), but before the\n # any branches that call reject()\n return self._accept(request)\n"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98826:If_L129_C12", "label": "if", "type": "if", "loc": [129, 134], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98826:If_L128_C8", "vector": [4, 3, 0.3812, 0.0174, 3, 0.17, 0.0, 0, 3, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if getattr(request, '_dont_enforce_csrf_checks', False):\n # Mechanism to turn off CSRF checks for test suite. It comes after\n # the creation of CSRF cookies, so that everything else continues to\n # work exactly the same (e.g. cookies are sent etc), but before the\n # any branches that call reject()\n return self._accept(request)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98826:Return_L134_C16", "label": "return", "type": "return", "loc": [134, 134], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98826:If_L129_C12", "vector": [13, 4, 0.3884, 0.0029, 4, 0.03, 0.0, 0, 3, 0, 0, 0, 0, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return self._accept(request)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98826:If_L136_C12", "label": "if", "type": "if", "loc": [136, 159], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98826:If_L128_C8", "vector": [4, 3, 0.4275, 0.0696, 3, 0.17, 0.2, 0, 3, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if request.is_ajax():\n # .is_ajax() is based on the presence of X-Requested-With. In\n # the context of a browser, this can only be sent if using\n # XmlHttpRequest. Browsers implement careful policies for\n # XmlHttpRequest:\n #\n # * Normally, only same-domain requests are allowed.\n #"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98826:Return_L159_C16", "label": "return", "type": "return", "loc": [159, 159], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98826:If_L136_C12", "vector": [13, 4, 0.4609, 0.0029, 4, 0.94, 0.0, 0, 3, 0, 0, 0, 0, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return self._accept(request)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98826:If_L161_C12", "label": "if", "type": "if", "loc": [161, 198], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98826:If_L128_C8", "vector": [4, 3, 0.5203, 0.1101, 3, 0.17, 0.4, 0, 3, 0, 0, 0, 0, 0, 8], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if request.is_secure():\n # Suppose user visits http://example.com/\n # An active network attacker,(man-in-the-middle, MITM) sends a\n # POST form which targets https://example.com/detonate-bomb/ and\n # submits it via javascript.\n #\n # The attacker will need to provide a CSRF cookie and token, but\n # that is no problem for a MITM and the session independent"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98826:Assign_L177_C16", "label": "referer = get()", "type": "assigned_variable", "loc": [177, 177], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98826:If_L161_C12", "vector": [14, 4, 0.513, 0.0029, 4, 0.1, 0.0, 105, 3, 1, 0, 0, 607, 10, 1], "semantic": {"name": "referer", "arg_names": [], "import_names": [], "rhs_call_name": "get", "annotation": ""}, "snippet": " referer = request.META.get('HTTP_REFERER')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98826:If_L178_C16", "label": "if", "type": "if", "loc": [178, 185], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98826:If_L161_C12", "vector": [4, 4, 0.5261, 0.0232, 4, 0.1, 0.3333, 0, 0, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if referer is None:\n logger.warning('Forbidden (%s): %s' % (REASON_NO_COOKIE, request.path),\n extra={\n 'status_code': 403,\n 'request': request,\n }\n )\n return self._reject(request, REASON_NO_REFERER)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98826:Expr_L179_C20", "label": "warning()", "type": "expression", "loc": [179, 184], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98826:If_L178_C16", "vector": [8, 5, 0.5261, 0.0174, 5, 0.9, 0.0, 320, 3, 2, 0, 0, 0, 0, 1], "semantic": {"name": "warning", "arg_names": [], "import_names": [], "rhs_call_name": "warning", "annotation": ""}, "snippet": " logger.warning('Forbidden (%s): %s' % (REASON_NO_COOKIE, request.path),\n extra={\n 'status_code': 403,\n 'request': request,\n }\n )"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98826:Return_L185_C20", "label": "return", "type": "return", "loc": [185, 185], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98826:If_L178_C16", "vector": [13, 5, 0.5362, 0.0029, 5, 0.9, 1.0, 0, 3, 0, 0, 0, 0, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return self._reject(request, REASON_NO_REFERER)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98826:Assign_L189_C16", "label": "good_referer =", "type": "assigned_variable", "loc": [189, 189], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98826:If_L161_C12", "vector": [14, 4, 0.5478, 0.0029, 4, 0.1, 0.6667, 108, 4, 0, 0, 0, 0, 0, 1], "semantic": {"name": "good_referer", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " good_referer = 'https://%s/' % request.get_host()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98826:If_L190_C16", "label": "if", "type": "if", "loc": [190, 198], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98826:If_L161_C12", "vector": [4, 4, 0.5623, 0.0261, 4, 0.1, 1.0, 0, 0, 0, 0, 0, 0, 0, 3], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if not referer.startswith(good_referer):\n reason = REASON_BAD_REFERER % (referer, good_referer)\n logger.warning('Forbidden (%s): %s' % (reason, request.path),\n extra={\n 'status_code': 403,\n 'request': request,\n }\n )"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98826:Assign_L191_C20", "label": "reason =", "type": "assigned_variable", "loc": [191, 191], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98826:If_L190_C16", "vector": [14, 5, 0.5536, 0.0029, 5, 0.07, 0.0, 424, 4, 0, 0, 0, 0, 0, 0], "semantic": {"name": "reason", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " reason = REASON_BAD_REFERER % (referer, good_referer)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98826:Expr_L192_C20", "label": "warning()", "type": "expression", "loc": [192, 197], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98826:If_L190_C16", "vector": [8, 5, 0.5638, 0.0174, 5, 0.07, 0.5, 320, 3, 2, 0, 0, 0, 0, 1], "semantic": {"name": "warning", "arg_names": [], "import_names": [], "rhs_call_name": "warning", "annotation": ""}, "snippet": " logger.warning('Forbidden (%s): %s' % (reason, request.path),\n extra={\n 'status_code': 403,\n 'request': request,\n }\n )"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98826:Return_L198_C20", "label": "return", "type": "return", "loc": [198, 198], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98826:If_L190_C16", "vector": [13, 5, 0.5739, 0.0029, 5, 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._reject(request, reason)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98826:If_L204_C12", "label": "if", "type": "if", "loc": [204, 220], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98826:If_L128_C8", "vector": [4, 3, 0.6145, 0.0493, 3, 0.17, 0.6, 0, 2, 0, 0, 0, 0, 0, 3], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if cookie_is_new:\n try:\n session_id = request.COOKIES[settings.SESSION_COOKIE_NAME]\n csrf_token = _make_legacy_session_token(session_id)\n except KeyError:\n # No CSRF cookie and no session cookie. For POST requests,\n # we insist on a CSRF cookie, and in this way we can avoid\n # all CSRF attacks, including login CSRF."}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98826:Try_L205_C16", "label": "try", "type": "try", "loc": [205, 218], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98826:If_L204_C12", "vector": [7, 4, 0.613, 0.0406, 4, 0.42, 0.0, 0, 0, 1, 0, 0, 0, 0, 3], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " try:\n session_id = request.COOKIES[settings.SESSION_COOKIE_NAME]\n csrf_token = _make_legacy_session_token(session_id)\n except KeyError:\n # No CSRF cookie and no session cookie. For POST requests,\n # we insist on a CSRF cookie, and in this way we can avoid\n # all CSRF attacks, including login CSRF.\n logger.warning('Forbidden (%s): %s' % (REASON_NO_COOKIE, request.path),"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98826:Assign_L206_C20", "label": "session_id =", "type": "assigned_variable", "loc": [206, 206], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98826:Try_L205_C16", "vector": [14, 5, 0.5971, 0.0029, 5, 0.28, 0.0, 82, 6, 0, 0, 0, 0, 0, 0], "semantic": {"name": "session_id", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " session_id = request.COOKIES[settings.SESSION_COOKIE_NAME]"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98826:Assign_L207_C20", "label": "csrf_token = _make_legacy_session_token()", "type": "assigned_variable", "loc": [207, 207], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98826:Try_L205_C16", "vector": [14, 5, 0.6, 0.0029, 5, 0.28, 1.0, 60, 3, 1, 0, 0, 991, 10, 1], "semantic": {"name": "csrf_token", "arg_names": [], "import_names": [], "rhs_call_name": "_make_legacy_session_token", "annotation": ""}, "snippet": " csrf_token = _make_legacy_session_token(session_id)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98826:Expr_L212_C20", "label": "warning()", "type": "expression", "loc": [212, 217], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98826:Try_L205_C16", "vector": [8, 5, 0.6217, 0.0174, 5, 0.28, 0.0, 320, 3, 2, 0, 0, 0, 0, 1], "semantic": {"name": "warning", "arg_names": [], "import_names": [], "rhs_call_name": "warning", "annotation": ""}, "snippet": " logger.warning('Forbidden (%s): %s' % (REASON_NO_COOKIE, request.path),\n extra={\n 'status_code': 403,\n 'request': request,\n }\n )"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98826:Return_L218_C20", "label": "return", "type": "return", "loc": [218, 218], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98826:Try_L205_C16", "vector": [13, 5, 0.6319, 0.0029, 5, 0.28, 1.0, 0, 3, 0, 0, 0, 0, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return self._reject(request, REASON_NO_COOKIE)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98826:Assign_L220_C16", "label": "csrf_token =", "type": "assigned_variable", "loc": [220, 220], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98826:If_L204_C12", "vector": [14, 4, 0.6377, 0.0029, 4, 0.42, 1.0, 60, 6, 0, 0, 0, 0, 0, 0], "semantic": {"name": "csrf_token", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " csrf_token = request.META[\"CSRF_COOKIE\"]"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98826:Assign_L223_C12", "label": "request_csrf_token = get()", "type": "assigned_variable", "loc": [223, 223], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98826:If_L128_C8", "vector": [14, 3, 0.6464, 0.0029, 3, 0.17, 0.8, 730, 3, 2, 0, 0, 607, 10, 1], "semantic": {"name": "request_csrf_token", "arg_names": [], "import_names": [], "rhs_call_name": "get", "annotation": ""}, "snippet": " request_csrf_token = request.POST.get('csrfmiddlewaretoken', '')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98826:If_L224_C12", "label": "if", "type": "if", "loc": [224, 241], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98826:If_L128_C8", "vector": [4, 3, 0.6739, 0.0522, 3, 0.17, 1.0, 0, 0, 0, 0, 0, 0, 0, 5], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if not constant_time_compare(request_csrf_token, csrf_token):\n if cookie_is_new:\n # probably a problem setting the CSRF cookie\n logger.warning('Forbidden (%s): %s' % (REASON_NO_CSRF_COOKIE, request.path),\n extra={\n 'status_code': 403,\n 'request': request,\n }"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98826:If_L225_C16", "label": "if", "type": "if", "loc": [225, 241], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98826:If_L224_C12", "vector": [4, 4, 0.6754, 0.0493, 4, 0.17, 0.0, 0, 2, 0, 0, 0, 0, 0, 4], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if cookie_is_new:\n # probably a problem setting the CSRF cookie\n logger.warning('Forbidden (%s): %s' % (REASON_NO_CSRF_COOKIE, request.path),\n extra={\n 'status_code': 403,\n 'request': request,\n }\n )"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98826:Expr_L227_C20", "label": "warning()", "type": "expression", "loc": [227, 232], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98826:If_L225_C16", "vector": [8, 5, 0.6652, 0.0174, 5, 0.75, 0.0, 320, 3, 2, 0, 0, 0, 0, 1], "semantic": {"name": "warning", "arg_names": [], "import_names": [], "rhs_call_name": "warning", "annotation": ""}, "snippet": " logger.warning('Forbidden (%s): %s' % (REASON_NO_CSRF_COOKIE, request.path),\n extra={\n 'status_code': 403,\n 'request': request,\n }\n )"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98826:Return_L233_C20", "label": "return", "type": "return", "loc": [233, 233], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98826:If_L225_C16", "vector": [13, 5, 0.6754, 0.0029, 5, 0.75, 0.3333, 0, 3, 0, 0, 0, 0, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return self._reject(request, REASON_NO_CSRF_COOKIE)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98826:Expr_L235_C20", "label": "warning()", "type": "expression", "loc": [235, 240], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98826:If_L225_C16", "vector": [8, 5, 0.6884, 0.0174, 5, 0.75, 0.6667, 320, 3, 2, 0, 0, 0, 0, 1], "semantic": {"name": "warning", "arg_names": [], "import_names": [], "rhs_call_name": "warning", "annotation": ""}, "snippet": " logger.warning('Forbidden (%s): %s' % (REASON_BAD_TOKEN, request.path),\n extra={\n 'status_code': 403,\n 'request': request,\n }\n )"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98826:Return_L241_C20", "label": "return", "type": "return", "loc": [241, 241], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98826:If_L225_C16", "vector": [13, 5, 0.6986, 0.0029, 5, 0.75, 1.0, 0, 3, 0, 0, 0, 0, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return self._reject(request, REASON_BAD_TOKEN)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98826:Return_L243_C8", "label": "return", "type": "return", "loc": [243, 243], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98826:FunctionDef_L102_C4", "vector": [13, 2, 0.7043, 0.0029, 2, 0.59, 1.0, 0, 3, 0, 0, 0, 0, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return self._accept(request)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98826:FunctionDef_L245_C4", "label": "process_response", "type": "function", "loc": [245, 265], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98826:ClassDef_L81_C0", "vector": [2, 1, 0.7391, 0.0609, 1, 0.09, 1.0, 298, 0, 3, 1, 0, 0, 0, 5], "semantic": {"name": "process_response", "arg_names": ["self", "request", "response"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def process_response(self, request, response):\n if getattr(response, 'csrf_processing_done', False):\n return response\n\n # If CSRF_COOKIE is unset, then CsrfViewMiddleware.process_view was\n # never called, probaby because a request middleware returned a response\n # (for example, contrib.auth redirecting to a login page).\n if request.META.get(\"CSRF_COOKIE\") is None:"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98826:If_L246_C8", "label": "if", "type": "if", "loc": [246, 247], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98826:FunctionDef_L245_C4", "vector": [4, 2, 0.7145, 0.0058, 2, 0.22, 0.0, 0, 3, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if getattr(response, 'csrf_processing_done', False):\n return response"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98826:Return_L247_C12", "label": "return", "type": "return", "loc": [247, 247], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98826:If_L246_C8", "vector": [13, 3, 0.7159, 0.0029, 3, 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_98826:If_L252_C8", "label": "if", "type": "if", "loc": [252, 253], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98826:FunctionDef_L245_C4", "vector": [4, 2, 0.7319, 0.0058, 2, 0.22, 0.1667, 0, 0, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if request.META.get(\"CSRF_COOKIE\") is None:\n return response"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98826:Return_L253_C12", "label": "return", "type": "return", "loc": [253, 253], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98826:If_L252_C8", "vector": [13, 3, 0.7333, 0.0029, 3, 0.44, 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_98826:If_L255_C8", "label": "if", "type": "if", "loc": [255, 256], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98826:FunctionDef_L245_C4", "vector": [4, 2, 0.7406, 0.0058, 2, 0.22, 0.3333, 0, 0, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if not request.META.get(\"CSRF_COOKIE_USED\", False):\n return response"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98826:Return_L256_C12", "label": "return", "type": "return", "loc": [256, 256], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98826:If_L255_C8", "vector": [13, 3, 0.742, 0.0029, 3, 0.31, 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_98826:Expr_L259_C8", "label": "set_cookie()", "type": "expression", "loc": [259, 261], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98826:FunctionDef_L245_C4", "vector": [8, 2, 0.7536, 0.0087, 2, 0.22, 0.5, 146, 3, 4, 0, 0, 0, 0, 1], "semantic": {"name": "set_cookie", "arg_names": [], "import_names": [], "rhs_call_name": "set_cookie", "annotation": ""}, "snippet": " response.set_cookie(settings.CSRF_COOKIE_NAME,\n request.META[\"CSRF_COOKIE\"], max_age = 60 * 60 * 24 * 7 * 52,\n domain=settings.CSRF_COOKIE_DOMAIN)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98826:Expr_L263_C8", "label": "patch_vary_headers()", "type": "expression", "loc": [263, 263], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98826:FunctionDef_L245_C4", "vector": [8, 2, 0.7623, 0.0029, 2, 0.22, 0.6667, 726, 3, 2, 0, 0, 0, 0, 1], "semantic": {"name": "patch_vary_headers", "arg_names": [], "import_names": [], "rhs_call_name": "patch_vary_headers", "annotation": ""}, "snippet": " patch_vary_headers(response, ('Cookie',))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98826:Assign_L264_C8", "label": "response.csrf_processing_done =", "type": "assigned_variable", "loc": [264, 264], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98826:FunctionDef_L245_C4", "vector": [14, 2, 0.7652, 0.0029, 2, 0.22, 0.8333, 551, 1, 0, 0, 0, 0, 4, 0], "semantic": {"name": "response.csrf_processing_done", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " response.csrf_processing_done = True"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98826:Return_L265_C8", "label": "return", "type": "return", "loc": [265, 265], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98826:FunctionDef_L245_C4", "vector": [13, 2, 0.7681, 0.0029, 2, 0.22, 1.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_98826:ClassDef_L268_C0", "label": "CsrfResponseMiddleware", "type": "class", "loc": [268, 316], "level": 0, "parent": null, "vector": [3, 0, 0.8464, 0.142, 0, 0.66, 0.963, 308, 0, 3, 0, 0, 186, 0, 11], "semantic": {"name": "CsrfResponseMiddleware", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class CsrfResponseMiddleware(object):\n \"\"\"\n DEPRECATED\n Middleware that post-processes a response to add a csrfmiddlewaretoken.\n\n This exists for backwards compatibility and as an interim measure until\n applications are converted to using use the csrf_token template tag\n instead. It will be removed in Django 1.4."}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98826:Expr_L269_C4", "label": "expression", "type": "expression", "loc": [269, 276], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98826:ClassDef_L268_C0", "vector": [8, 1, 0.7899, 0.0232, 1, 0.75, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"\n DEPRECATED\n Middleware that post-processes a response to add a csrfmiddlewaretoken.\n\n This exists for backwards compatibility and as an interim measure until\n applications are converted to using use the csrf_token template tag\n instead. It will be removed in Django 1.4.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98826:FunctionDef_L277_C4", "label": "__init__", "type": "function", "loc": [277, 282], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98826:ClassDef_L268_C0", "vector": [2, 1, 0.8101, 0.0174, 1, 0.75, 0.5, 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 import warnings\n warnings.warn(\n \"CsrfResponseMiddleware and CsrfMiddleware are deprecated; use CsrfViewMiddleware and the template tag instead (see CSRF documentation).\",\n DeprecationWarning\n )"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98826:Import_L278_C8", "label": "warnings import warnings", "type": "import", "loc": [278, 278], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98826:FunctionDef_L277_C4", "vector": [1, 2, 0.8058, 0.0029, 2, 0.25, 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_98826:Expr_L279_C8", "label": "warn()", "type": "expression", "loc": [279, 282], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98826:FunctionDef_L277_C4", "vector": [8, 2, 0.813, 0.0116, 2, 0.25, 1.0, 960, 3, 2, 0, 0, 0, 0, 1], "semantic": {"name": "warn", "arg_names": [], "import_names": [], "rhs_call_name": "warn", "annotation": ""}, "snippet": " warnings.warn(\n \"CsrfResponseMiddleware and CsrfMiddleware are deprecated; use CsrfViewMiddleware and the template tag instead (see CSRF documentation).\",\n DeprecationWarning\n )"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98826:FunctionDef_L284_C4", "label": "process_response", "type": "function", "loc": [284, 316], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98826:ClassDef_L268_C0", "vector": [2, 1, 0.8696, 0.0957, 1, 0.75, 1.0, 298, 0, 3, 1, 0, 0, 0, 10], "semantic": {"name": "process_response", "arg_names": ["self", "request", "response"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def process_response(self, request, response):\n if getattr(response, 'csrf_exempt', False):\n return response\n\n if response['Content-Type'].split(';')[0] in _HTML_TYPES:\n csrf_token = get_token(request)\n # If csrf_token is None, we have no token for this request, which probably\n # means that this is a response from a request middleware."}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98826:If_L285_C8", "label": "if", "type": "if", "loc": [285, 286], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98826:FunctionDef_L284_C4", "vector": [4, 2, 0.8275, 0.0058, 2, 0.07, 0.0, 0, 3, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if getattr(response, 'csrf_exempt', False):\n return response"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98826:Return_L286_C12", "label": "return", "type": "return", "loc": [286, 286], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98826:If_L285_C8", "vector": [13, 3, 0.829, 0.0029, 3, 0.87, 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_98826:If_L288_C8", "label": "if", "type": "if", "loc": [288, 315], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98826:FunctionDef_L284_C4", "vector": [4, 2, 0.8739, 0.0812, 2, 0.07, 0.5, 0, 0, 0, 0, 0, 0, 0, 9], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if response['Content-Type'].split(';')[0] in _HTML_TYPES:\n csrf_token = get_token(request)\n # If csrf_token is None, we have no token for this request, which probably\n # means that this is a response from a request middleware.\n if csrf_token is None:\n return response\n\n # ensure we don't add the 'id' attribute twice (HTML validity)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98826:Assign_L289_C12", "label": "csrf_token = get_token()", "type": "assigned_variable", "loc": [289, 289], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98826:If_L288_C8", "vector": [14, 3, 0.8377, 0.0029, 3, 0.53, 0.0, 60, 3, 1, 0, 0, 224, 10, 1], "semantic": {"name": "csrf_token", "arg_names": [], "import_names": [], "rhs_call_name": "get_token", "annotation": ""}, "snippet": " csrf_token = get_token(request)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98826:If_L292_C12", "label": "if", "type": "if", "loc": [292, 293], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98826:If_L288_C8", "vector": [4, 3, 0.8478, 0.0058, 3, 0.53, 0.2, 0, 0, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if csrf_token is None:\n return response"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98826:Return_L293_C16", "label": "return", "type": "return", "loc": [293, 293], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98826:If_L292_C12", "vector": [13, 4, 0.8493, 0.0029, 4, 0.96, 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_98826:Assign_L296_C12", "label": "idattributes = chain()", "type": "assigned_variable", "loc": [296, 297], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98826:If_L288_C8", "vector": [14, 3, 0.8594, 0.0058, 3, 0.53, 0.4, 593, 3, 2, 0, 0, 271, 10, 2], "semantic": {"name": "idattributes", "arg_names": [], "import_names": [], "rhs_call_name": "chain", "annotation": ""}, "snippet": " idattributes = itertools.chain((\"id='csrfmiddlewaretoken'\",),\n itertools.repeat(''))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98826:FunctionDef_L298_C12", "label": "add_csrf_field", "type": "function", "loc": [298, 303], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98826:If_L288_C8", "vector": [2, 3, 0.871, 0.0174, 3, 0.53, 0.6, 56, 0, 1, 1, 0, 0, 0, 3], "semantic": {"name": "add_csrf_field", "arg_names": ["match"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def add_csrf_field(match):\n \"\"\"Returns the matched <form> tag plus the added <input> element\"\"\"\n return mark_safe(match.group() + \"<div style='display:none;'>\" + \\\n \"<input type='hidden' \" + idattributes.next() + \\\n \" name='csrfmiddlewaretoken' value='\" + csrf_token + \\\n \"' /></div>\")"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98826:Expr_L299_C16", "label": "expression", "type": "expression", "loc": [299, 299], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98826:FunctionDef_L298_C12", "vector": [8, 4, 0.8667, 0.0029, 4, 0.34, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"Returns the matched <form> tag plus the added <input> element\"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98826:Return_L300_C16", "label": "return", "type": "return", "loc": [300, 303], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98826:FunctionDef_L298_C12", "vector": [13, 4, 0.8739, 0.0116, 4, 0.34, 1.0, 0, 3, 0, 0, 0, 0, 10, 3], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return mark_safe(match.group() + \"<div style='display:none;'>\" + \\\n \"<input type='hidden' \" + idattributes.next() + \\\n \" name='csrfmiddlewaretoken' value='\" + csrf_token + \\\n \"' /></div>\")"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98826:Assign_L306_C12", "label": "n = subn()", "type": "assigned_variable", "loc": [306, 306], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98826:If_L288_C8", "vector": [14, 3, 0.887, 0.0029, 3, 0.53, 0.8, 773, 3, 2, 0, 0, 556, 10, 1], "semantic": {"name": "n", "arg_names": [], "import_names": [], "rhs_call_name": "subn", "annotation": ""}, "snippet": " response.content, n = _POST_FORM_RE.subn(add_csrf_field, response.content)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98826:If_L307_C12", "label": "if", "type": "if", "loc": [307, 315], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98826:If_L288_C8", "vector": [4, 3, 0.9014, 0.0261, 3, 0.53, 1.0, 0, 0, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if n > 0:\n # Content varies with the CSRF cookie, so set the Vary header.\n patch_vary_headers(response, ('Cookie',))\n\n # Since the content has been modified, any Etag will now be\n # incorrect. We could recalculate, but only if we assume that\n # the Etag was set by CommonMiddleware. The safest thing is just\n # to delete. See bug #9163"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98826:Expr_L309_C16", "label": "patch_vary_headers()", "type": "expression", "loc": [309, 309], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98826:If_L307_C12", "vector": [8, 4, 0.8957, 0.0029, 4, 0.43, 0.0, 726, 3, 2, 0, 0, 0, 0, 1], "semantic": {"name": "patch_vary_headers", "arg_names": [], "import_names": [], "rhs_call_name": "patch_vary_headers", "annotation": ""}, "snippet": " patch_vary_headers(response, ('Cookie',))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98826:Return_L316_C8", "label": "return", "type": "return", "loc": [316, 316], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98826:FunctionDef_L284_C4", "vector": [13, 2, 0.9159, 0.0029, 2, 0.07, 1.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_98826:ClassDef_L319_C0", "label": "CsrfMiddleware", "type": "class", "loc": [319, 345], "level": 0, "parent": null, "vector": [3, 0, 0.9623, 0.0783, 0, 0.66, 1.0, 21, 0, 3, 0, 0, 186, 0, 5], "semantic": {"name": "CsrfMiddleware", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class CsrfMiddleware(object):\n \"\"\"\n Django middleware that adds protection against Cross Site\n Request Forgeries by adding hidden form fields to POST forms and\n checking requests for the correct value.\n\n CsrfMiddleware uses two middleware, CsrfViewMiddleware and\n CsrfResponseMiddleware, which can be used independently. It is recommended"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98826:Expr_L320_C4", "label": "expression", "type": "expression", "loc": [320, 329], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98826:ClassDef_L319_C0", "vector": [8, 1, 0.9406, 0.029, 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 Django middleware that adds protection against Cross Site\n Request Forgeries by adding hidden form fields to POST forms and\n checking requests for the correct value.\n\n CsrfMiddleware uses two middleware, CsrfViewMiddleware and\n CsrfResponseMiddleware, which can be used independently. It is recommended\n to use only CsrfViewMiddleware and use the csrf_token template tag in"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98826:FunctionDef_L332_C4", "label": "__init__", "type": "function", "loc": [332, 334], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98826:ClassDef_L319_C0", "vector": [2, 1, 0.9652, 0.0087, 1, 0.63, 0.3333, 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 self.response_middleware = CsrfResponseMiddleware()\n self.view_middleware = CsrfViewMiddleware()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98826:Assign_L333_C8", "label": "self.response_middleware = CsrfResponseMiddleware()", "type": "assigned_variable", "loc": [333, 333], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98826:FunctionDef_L332_C4", "vector": [14, 2, 0.9652, 0.0029, 2, 0.57, 0.0, 582, 3, 0, 0, 0, 308, 10, 1], "semantic": {"name": "self.response_middleware", "arg_names": [], "import_names": [], "rhs_call_name": "CsrfResponseMiddleware", "annotation": ""}, "snippet": " self.response_middleware = CsrfResponseMiddleware()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98826:Assign_L334_C8", "label": "self.view_middleware = CsrfViewMiddleware()", "type": "assigned_variable", "loc": [334, 334], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98826:FunctionDef_L332_C4", "vector": [14, 2, 0.9681, 0.0029, 2, 0.57, 1.0, 765, 3, 0, 0, 0, 447, 10, 1], "semantic": {"name": "self.view_middleware", "arg_names": [], "import_names": [], "rhs_call_name": "CsrfViewMiddleware", "annotation": ""}, "snippet": " self.view_middleware = CsrfViewMiddleware()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98826:FunctionDef_L336_C4", "label": "process_response", "type": "function", "loc": [336, 341], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98826:ClassDef_L319_C0", "vector": [2, 1, 0.9812, 0.0174, 1, 0.63, 0.6667, 298, 0, 3, 1, 0, 0, 0, 2], "semantic": {"name": "process_response", "arg_names": ["self", "request", "resp"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def process_response(self, request, resp):\n # We must do the response post-processing first, because that calls\n # get_token(), which triggers a flag saying that the CSRF cookie needs\n # to be sent (done in CsrfViewMiddleware.process_response)\n resp2 = self.response_middleware.process_response(request, resp)\n return self.view_middleware.process_response(request, resp2)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98826:Assign_L340_C8", "label": "resp2 = process_response()", "type": "assigned_variable", "loc": [340, 340], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98826:FunctionDef_L336_C4", "vector": [14, 2, 0.9855, 0.0029, 2, 0.69, 0.0, 271, 3, 2, 0, 0, 298, 10, 1], "semantic": {"name": "resp2", "arg_names": [], "import_names": [], "rhs_call_name": "process_response", "annotation": ""}, "snippet": " resp2 = self.response_middleware.process_response(request, resp)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98826:Return_L341_C8", "label": "return", "type": "return", "loc": [341, 341], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98826:FunctionDef_L336_C4", "vector": [13, 2, 0.9884, 0.0029, 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 self.view_middleware.process_response(request, resp2)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98826:FunctionDef_L343_C4", "label": "process_view", "type": "function", "loc": [343, 345], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98826:ClassDef_L319_C0", "vector": [2, 1, 0.9971, 0.0087, 1, 0.63, 1.0, 785, 0, 5, 1, 0, 0, 0, 1], "semantic": {"name": "process_view", "arg_names": ["self", "request", "callback", "callback_args", "callback_kwargs"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def process_view(self, request, callback, callback_args, callback_kwargs):\n return self.view_middleware.process_view(request, callback, callback_args,\n callback_kwargs)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98826:Return_L344_C8", "label": "return", "type": "return", "loc": [344, 345], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98826:FunctionDef_L343_C4", "vector": [13, 2, 0.9986, 0.0058, 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 self.view_middleware.process_view(request, callback, callback_args,\n callback_kwargs)"}]
[{"f": "ajibawa-2023/Python-Code-Large/train/row_98826:If_L28_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98826:Assign_L29_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98826:If_L28_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98826:Assign_L31_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98826:FunctionDef_L40_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98826:Expr_L41_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98826:FunctionDef_L40_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98826:Return_L44_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98826:FunctionDef_L47_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98826:Return_L48_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98826:FunctionDef_L52_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98826:Return_L53_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98826:FunctionDef_L56_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98826:Expr_L57_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98826:FunctionDef_L56_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98826:Assign_L66_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98826:FunctionDef_L56_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98826:Return_L67_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98826:FunctionDef_L70_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98826:Assign_L73_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98826:FunctionDef_L70_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98826:If_L74_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98826:If_L74_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98826:Return_L76_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98826:If_L74_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98826:Return_L78_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98826:ClassDef_L81_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98826:Expr_L82_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98826:ClassDef_L81_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98826:FunctionDef_L92_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98826:FunctionDef_L92_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98826:Assign_L96_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98826:FunctionDef_L92_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98826:Return_L97_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98826:ClassDef_L81_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98826:FunctionDef_L99_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98826:FunctionDef_L99_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98826:Return_L100_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98826:ClassDef_L81_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98826:FunctionDef_L102_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98826:FunctionDef_L102_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98826:If_L103_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98826:If_L103_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98826:Return_L104_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98826:FunctionDef_L102_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98826:Try_L109_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98826:Try_L109_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98826:Assign_L113_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98826:Try_L109_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98826:Assign_L114_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98826:Try_L109_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98826:Assign_L118_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98826:Try_L109_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98826:Assign_L121_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98826:FunctionDef_L102_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98826:If_L125_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98826:If_L125_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98826:Return_L126_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98826:FunctionDef_L102_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98826:If_L128_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98826:If_L128_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98826:If_L129_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98826:If_L129_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98826:Return_L134_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98826:If_L128_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98826:If_L136_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98826:If_L136_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98826:Return_L159_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98826:If_L128_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98826:If_L161_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98826:If_L161_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98826:Assign_L177_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98826:If_L161_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98826:If_L178_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98826:If_L178_C16", "t": "ajibawa-2023/Python-Code-Large/train/row_98826:Expr_L179_C20"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98826:If_L178_C16", "t": "ajibawa-2023/Python-Code-Large/train/row_98826:Return_L185_C20"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98826:If_L161_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98826:Assign_L189_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98826:If_L161_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98826:If_L190_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98826:If_L190_C16", "t": "ajibawa-2023/Python-Code-Large/train/row_98826:Assign_L191_C20"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98826:If_L190_C16", "t": "ajibawa-2023/Python-Code-Large/train/row_98826:Expr_L192_C20"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98826:If_L190_C16", "t": "ajibawa-2023/Python-Code-Large/train/row_98826:Return_L198_C20"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98826:If_L128_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98826:If_L204_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98826:If_L204_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98826:Try_L205_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98826:Try_L205_C16", "t": "ajibawa-2023/Python-Code-Large/train/row_98826:Assign_L206_C20"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98826:Try_L205_C16", "t": "ajibawa-2023/Python-Code-Large/train/row_98826:Assign_L207_C20"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98826:Try_L205_C16", "t": "ajibawa-2023/Python-Code-Large/train/row_98826:Expr_L212_C20"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98826:Try_L205_C16", "t": "ajibawa-2023/Python-Code-Large/train/row_98826:Return_L218_C20"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98826:If_L204_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98826:Assign_L220_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98826:If_L128_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98826:Assign_L223_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98826:If_L128_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98826:If_L224_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98826:If_L224_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98826:If_L225_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98826:If_L225_C16", "t": "ajibawa-2023/Python-Code-Large/train/row_98826:Expr_L227_C20"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98826:If_L225_C16", "t": "ajibawa-2023/Python-Code-Large/train/row_98826:Return_L233_C20"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98826:If_L225_C16", "t": "ajibawa-2023/Python-Code-Large/train/row_98826:Expr_L235_C20"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98826:If_L225_C16", "t": "ajibawa-2023/Python-Code-Large/train/row_98826:Return_L241_C20"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98826:FunctionDef_L102_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98826:Return_L243_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98826:ClassDef_L81_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98826:FunctionDef_L245_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98826:FunctionDef_L245_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98826:If_L246_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98826:If_L246_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98826:Return_L247_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98826:FunctionDef_L245_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98826:If_L252_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98826:If_L252_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98826:Return_L253_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98826:FunctionDef_L245_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98826:If_L255_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98826:If_L255_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98826:Return_L256_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98826:FunctionDef_L245_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98826:Expr_L259_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98826:FunctionDef_L245_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98826:Expr_L263_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98826:FunctionDef_L245_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98826:Assign_L264_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98826:FunctionDef_L245_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98826:Return_L265_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98826:ClassDef_L268_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98826:Expr_L269_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98826:ClassDef_L268_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98826:FunctionDef_L277_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98826:FunctionDef_L277_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98826:Import_L278_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98826:FunctionDef_L277_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98826:Expr_L279_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98826:ClassDef_L268_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98826:FunctionDef_L284_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98826:FunctionDef_L284_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98826:If_L285_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98826:If_L285_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98826:Return_L286_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98826:FunctionDef_L284_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98826:If_L288_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98826:If_L288_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98826:Assign_L289_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98826:If_L288_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98826:If_L292_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98826:If_L292_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98826:Return_L293_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98826:If_L288_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98826:Assign_L296_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98826:If_L288_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98826:FunctionDef_L298_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98826:FunctionDef_L298_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98826:Expr_L299_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98826:FunctionDef_L298_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98826:Return_L300_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98826:If_L288_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98826:Assign_L306_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98826:If_L288_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98826:If_L307_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98826:If_L307_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98826:Expr_L309_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98826:FunctionDef_L284_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98826:Return_L316_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98826:ClassDef_L319_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98826:Expr_L320_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98826:ClassDef_L319_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98826:FunctionDef_L332_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98826:FunctionDef_L332_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98826:Assign_L333_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98826:FunctionDef_L332_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98826:Assign_L334_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98826:ClassDef_L319_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98826:FunctionDef_L336_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98826:FunctionDef_L336_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98826:Assign_L340_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98826:FunctionDef_L336_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98826:Return_L341_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98826:ClassDef_L319_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98826:FunctionDef_L343_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98826:FunctionDef_L343_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98826:Return_L344_C8"}]
from django.db import transaction class TransactionMiddleware(object): """ Transaction middleware. If this is enabled, each view function will be run with commit_on_response activated - that way a save() doesn't do a direct commit, the commit is done when a successful response is created. If an exception happens, the database is rolled back. """ def process_request(self, request): """Enters transaction management""" transaction.enter_transaction_management() transaction.managed(True) def process_exception(self, request, exception): """Rolls back the database and leaves transaction management""" if transaction.is_dirty(): transaction.rollback() transaction.leave_transaction_management() def process_response(self, request, response): """Commits and leaves transaction management.""" if transaction.is_managed(): if transaction.is_dirty(): transaction.commit() transaction.leave_transaction_management() return response
ajibawa-2023/Python-Code-Large/train/row_98828
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_98828:ImportFrom_L1_C0", "label": "from django.db import transaction", "type": "import", "loc": [1, 1], "level": 0, "parent": null, "vector": [1, 0, 0.037, 0.037, 0, 0.66, 0.0, 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_98828:ClassDef_L3_C0", "label": "TransactionMiddleware", "type": "class", "loc": [3, 27], "level": 0, "parent": null, "vector": [3, 0, 0.5556, 0.9259, 0, 0.66, 1.0, 538, 0, 3, 0, 0, 186, 0, 9], "semantic": {"name": "TransactionMiddleware", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class TransactionMiddleware(object):\n \"\"\"\n Transaction middleware. If this is enabled, each view function will be run\n with commit_on_response activated - that way a save() doesn't do a direct\n commit, the commit is done when a successful response is created. If an\n exception happens, the database is rolled back.\n \"\"\"\n def process_request(self, request):"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98828:Expr_L4_C4", "label": "expression", "type": "expression", "loc": [4, 9], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98828:ClassDef_L3_C0", "vector": [8, 1, 0.2407, 0.2222, 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 Transaction middleware. If this is enabled, each view function will be run\n with commit_on_response activated - that way a save() doesn't do a direct\n commit, the commit is done when a successful response is created. If an\n exception happens, the database is rolled back.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98828:FunctionDef_L10_C4", "label": "process_request", "type": "function", "loc": [10, 13], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98828:ClassDef_L3_C0", "vector": [2, 1, 0.4259, 0.1481, 1, 0.4, 0.3333, 81, 0, 2, 0, 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 \"\"\"Enters transaction management\"\"\"\n transaction.enter_transaction_management()\n transaction.managed(True)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98828:Expr_L11_C8", "label": "expression", "type": "expression", "loc": [11, 11], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98828:FunctionDef_L10_C4", "vector": [8, 2, 0.4074, 0.037, 2, 0.98, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"Enters transaction management\"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98828:Expr_L12_C8", "label": "enter_transaction_management()", "type": "expression", "loc": [12, 12], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98828:FunctionDef_L10_C4", "vector": [8, 2, 0.4444, 0.037, 2, 0.98, 0.5, 871, 3, 0, 0, 0, 0, 0, 1], "semantic": {"name": "enter_transaction_management", "arg_names": [], "import_names": [], "rhs_call_name": "enter_transaction_management", "annotation": ""}, "snippet": " transaction.enter_transaction_management()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98828:Expr_L13_C8", "label": "managed()", "type": "expression", "loc": [13, 13], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98828:FunctionDef_L10_C4", "vector": [8, 2, 0.4815, 0.037, 2, 0.98, 1.0, 503, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "managed", "arg_names": [], "import_names": [], "rhs_call_name": "managed", "annotation": ""}, "snippet": " transaction.managed(True)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98828:FunctionDef_L15_C4", "label": "process_exception", "type": "function", "loc": [15, 19], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98828:ClassDef_L3_C0", "vector": [2, 1, 0.6296, 0.1852, 1, 0.4, 0.6667, 751, 0, 3, 0, 0, 0, 0, 3], "semantic": {"name": "process_exception", "arg_names": ["self", "request", "exception"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def process_exception(self, request, exception):\n \"\"\"Rolls back the database and leaves transaction management\"\"\"\n if transaction.is_dirty():\n transaction.rollback()\n transaction.leave_transaction_management()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98828:Expr_L16_C8", "label": "expression", "type": "expression", "loc": [16, 16], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98828:FunctionDef_L15_C4", "vector": [8, 2, 0.5926, 0.037, 2, 0.55, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"Rolls back the database and leaves transaction management\"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98828:If_L17_C8", "label": "if", "type": "if", "loc": [17, 18], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98828:FunctionDef_L15_C4", "vector": [4, 2, 0.6481, 0.0741, 2, 0.55, 0.5, 0, 3, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if transaction.is_dirty():\n transaction.rollback()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98828:Expr_L18_C12", "label": "rollback()", "type": "expression", "loc": [18, 18], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98828:If_L17_C8", "vector": [8, 3, 0.6667, 0.037, 3, 0.77, 0.0, 484, 3, 0, 0, 0, 0, 0, 1], "semantic": {"name": "rollback", "arg_names": [], "import_names": [], "rhs_call_name": "rollback", "annotation": ""}, "snippet": " transaction.rollback()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98828:Expr_L19_C8", "label": "leave_transaction_management()", "type": "expression", "loc": [19, 19], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98828:FunctionDef_L15_C4", "vector": [8, 2, 0.7037, 0.037, 2, 0.55, 1.0, 780, 3, 0, 0, 0, 0, 0, 1], "semantic": {"name": "leave_transaction_management", "arg_names": [], "import_names": [], "rhs_call_name": "leave_transaction_management", "annotation": ""}, "snippet": " transaction.leave_transaction_management()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98828:FunctionDef_L21_C4", "label": "process_response", "type": "function", "loc": [21, 27], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98828:ClassDef_L3_C0", "vector": [2, 1, 0.8889, 0.2593, 1, 0.4, 1.0, 298, 0, 3, 1, 0, 0, 0, 4], "semantic": {"name": "process_response", "arg_names": ["self", "request", "response"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def process_response(self, request, response):\n \"\"\"Commits and leaves transaction management.\"\"\"\n if transaction.is_managed():\n if transaction.is_dirty():\n transaction.commit()\n transaction.leave_transaction_management()\n return response"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98828:Expr_L22_C8", "label": "expression", "type": "expression", "loc": [22, 22], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98828:FunctionDef_L21_C4", "vector": [8, 2, 0.8148, 0.037, 2, 0.92, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"Commits and leaves transaction management.\"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98828:If_L23_C8", "label": "if", "type": "if", "loc": [23, 26], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98828:FunctionDef_L21_C4", "vector": [4, 2, 0.9074, 0.1481, 2, 0.92, 0.5, 0, 3, 0, 0, 0, 0, 0, 4], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if transaction.is_managed():\n if transaction.is_dirty():\n transaction.commit()\n transaction.leave_transaction_management()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98828:If_L24_C12", "label": "if", "type": "if", "loc": [24, 25], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98828:If_L23_C8", "vector": [4, 3, 0.9074, 0.0741, 3, 0.72, 0.0, 0, 3, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if transaction.is_dirty():\n transaction.commit()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98828:Expr_L25_C16", "label": "commit()", "type": "expression", "loc": [25, 25], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98828:If_L24_C12", "vector": [8, 4, 0.9259, 0.037, 4, 0.95, 0.0, 281, 3, 0, 0, 0, 0, 0, 1], "semantic": {"name": "commit", "arg_names": [], "import_names": [], "rhs_call_name": "commit", "annotation": ""}, "snippet": " transaction.commit()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98828:Expr_L26_C12", "label": "leave_transaction_management()", "type": "expression", "loc": [26, 26], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98828:If_L23_C8", "vector": [8, 3, 0.963, 0.037, 3, 0.72, 1.0, 780, 3, 0, 0, 0, 0, 0, 1], "semantic": {"name": "leave_transaction_management", "arg_names": [], "import_names": [], "rhs_call_name": "leave_transaction_management", "annotation": ""}, "snippet": " transaction.leave_transaction_management()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98828:Return_L27_C8", "label": "return", "type": "return", "loc": [27, 27], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98828:FunctionDef_L21_C4", "vector": [13, 2, 1.0, 0.037, 2, 0.92, 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_98828:ClassDef_L3_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98828:Expr_L4_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98828:ClassDef_L3_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98828:FunctionDef_L10_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98828:FunctionDef_L10_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98828:Expr_L11_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98828:FunctionDef_L10_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98828:Expr_L12_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98828:FunctionDef_L10_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98828:Expr_L13_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98828:ClassDef_L3_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98828:FunctionDef_L15_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98828:FunctionDef_L15_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98828:Expr_L16_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98828:FunctionDef_L15_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98828:If_L17_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98828:If_L17_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98828:Expr_L18_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98828:FunctionDef_L15_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98828:Expr_L19_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98828:ClassDef_L3_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98828:FunctionDef_L21_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98828:FunctionDef_L21_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98828:Expr_L22_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98828:FunctionDef_L21_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98828:If_L23_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98828:If_L23_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98828:If_L24_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98828:If_L24_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98828:Expr_L25_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98828:If_L23_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98828:Expr_L26_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98828:FunctionDef_L21_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98828:Return_L27_C8"}]
""" Cache middleware. If enabled, each Django-powered page will be cached based on URL. The canonical way to enable cache middleware is to set ``UpdateCacheMiddleware`` as your first piece of middleware, and ``FetchFromCacheMiddleware`` as the last:: MIDDLEWARE_CLASSES = [ 'django.middleware.cache.UpdateCacheMiddleware', ... 'django.middleware.cache.FetchFromCacheMiddleware' ] This is counter-intuitive, but correct: ``UpdateCacheMiddleware`` needs to run last during the response phase, which processes middleware bottom-up; ``FetchFromCacheMiddleware`` needs to run last during the request phase, which processes middleware top-down. The single-class ``CacheMiddleware`` can be used for some simple sites. However, if any other piece of middleware needs to affect the cache key, you'll need to use the two-part ``UpdateCacheMiddleware`` and ``FetchFromCacheMiddleware``. This'll most often happen when you're using Django's ``LocaleMiddleware``. More details about how the caching works: * Only parameter-less GET or HEAD-requests with status code 200 are cached. * The number of seconds each page is stored for is set by the "max-age" section of the response's "Cache-Control" header, falling back to the CACHE_MIDDLEWARE_SECONDS setting if the section was not found. * If CACHE_MIDDLEWARE_ANONYMOUS_ONLY is set to True, only anonymous requests (i.e., those not made by a logged-in user) will be cached. This is a simple and effective way of avoiding the caching of the Django admin (and any other user-specific content). * This middleware expects that a HEAD request is answered with the same response headers exactly like the corresponding GET request. * When a hit occurs, a shallow copy of the original response object is returned from process_request. * Pages will be cached based on the contents of the request headers listed in the response's "Vary" header. * This middleware also sets ETag, Last-Modified, Expires and Cache-Control headers on the response object. """ from django.conf import settings from django.core.cache import cache from django.utils.cache import get_cache_key, learn_cache_key, patch_response_headers, get_max_age class UpdateCacheMiddleware(object): """ Response-phase cache middleware that updates the cache if the response is cacheable. Must be used as part of the two-part update/fetch cache middleware. UpdateCacheMiddleware must be the first piece of middleware in MIDDLEWARE_CLASSES so that it'll get called last during the response phase. """ def __init__(self): self.cache_timeout = settings.CACHE_MIDDLEWARE_SECONDS self.key_prefix = settings.CACHE_MIDDLEWARE_KEY_PREFIX self.cache_anonymous_only = getattr(settings, 'CACHE_MIDDLEWARE_ANONYMOUS_ONLY', False) def process_response(self, request, response): """Sets the cache, if needed.""" if not hasattr(request, '_cache_update_cache') or not request._cache_update_cache: # We don't need to update the cache, just return. return response if not response.status_code == 200: return response # Try to get the timeout from the "max-age" section of the "Cache- # Control" header before reverting to using the default cache_timeout # length. timeout = get_max_age(response) if timeout == None: timeout = self.cache_timeout elif timeout == 0: # max-age was set to 0, don't bother caching. return response patch_response_headers(response, timeout) if timeout: cache_key = learn_cache_key(request, response, timeout, self.key_prefix) cache.set(cache_key, response, timeout) return response class FetchFromCacheMiddleware(object): """ Request-phase cache middleware that fetches a page from the cache. Must be used as part of the two-part update/fetch cache middleware. FetchFromCacheMiddleware must be the last piece of middleware in MIDDLEWARE_CLASSES so that it'll get called last during the request phase. """ def __init__(self): self.cache_timeout = settings.CACHE_MIDDLEWARE_SECONDS self.key_prefix = settings.CACHE_MIDDLEWARE_KEY_PREFIX self.cache_anonymous_only = getattr(settings, 'CACHE_MIDDLEWARE_ANONYMOUS_ONLY', False) def process_request(self, request): """ Checks whether the page is already cached and returns the cached version if available. """ if self.cache_anonymous_only: assert hasattr(request, 'user'), "The Django cache middleware with CACHE_MIDDLEWARE_ANONYMOUS_ONLY=True requires authentication middleware to be installed. Edit your MIDDLEWARE_CLASSES setting to insert 'django.contrib.auth.middleware.AuthenticationMiddleware' before the CacheMiddleware." if not request.method in ('GET', 'HEAD') or request.GET: request._cache_update_cache = False return None # Don't bother checking the cache. if self.cache_anonymous_only and request.user.is_authenticated(): request._cache_update_cache = False return None # Don't cache requests from authenticated users. # try and get the cached GET response cache_key = get_cache_key(request, self.key_prefix, 'GET') if cache_key is None: request._cache_update_cache = True return None # No cache information available, need to rebuild. response = cache.get(cache_key, None) # if it wasn't found and we are looking for a HEAD, try looking just for that if response is None and request.method == 'HEAD': cache_key = get_cache_key(request, self.key_prefix, 'HEAD') response = cache.get(cache_key, None) if response is None: request._cache_update_cache = True return None # No cache information available, need to rebuild. # hit, return cached response request._cache_update_cache = False return response class CacheMiddleware(UpdateCacheMiddleware, FetchFromCacheMiddleware): """ Cache middleware that provides basic behavior for many simple sites. Also used as the hook point for the cache decorator, which is generated using the decorator-from-middleware utility. """ def __init__(self, cache_timeout=None, key_prefix=None, cache_anonymous_only=None): self.cache_timeout = cache_timeout if cache_timeout is None: self.cache_timeout = settings.CACHE_MIDDLEWARE_SECONDS self.key_prefix = key_prefix if key_prefix is None: self.key_prefix = settings.CACHE_MIDDLEWARE_KEY_PREFIX if cache_anonymous_only is None: self.cache_anonymous_only = getattr(settings, 'CACHE_MIDDLEWARE_ANONYMOUS_ONLY', False) else: self.cache_anonymous_only = cache_anonymous_only
ajibawa-2023/Python-Code-Large/train/row_98829
66
159
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_98829:Expr_L1_C0", "label": "expression", "type": "expression", "loc": [1, 49], "level": 0, "parent": null, "vector": [8, 0, 0.1572, 0.3082, 0, 0.66, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "\"\"\"\nCache middleware. If enabled, each Django-powered page will be cached based on\nURL. The canonical way to enable cache middleware is to set\n``UpdateCacheMiddleware`` as your first piece of middleware, and\n``FetchFromCacheMiddleware`` as the last::\n\n MIDDLEWARE_CLASSES = [\n 'django.middleware.cache.UpdateCacheMiddleware',"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98829:ImportFrom_L51_C0", "label": "from django.conf import settings", "type": "import", "loc": [51, 51], "level": 0, "parent": null, "vector": [1, 0, 0.3208, 0.0063, 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_98829:ImportFrom_L52_C0", "label": "from django.core.cache import cache", "type": "import", "loc": [52, 52], "level": 0, "parent": null, "vector": [1, 0, 0.327, 0.0063, 0, 0.66, 0.3333, 734, 0, 1, 0, 0, 734, 0, 0], "semantic": {"name": "django.core.cache", "arg_names": [], "import_names": ["cache"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.core.cache import cache"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98829:ImportFrom_L53_C0", "label": "from django.utils.cache import get_cache_key, learn_cache_key, patch_response_headers\u2026", "type": "import", "loc": [53, 53], "level": 0, "parent": null, "vector": [1, 0, 0.3333, 0.0063, 0, 0.66, 0.5, 53, 0, 4, 0, 0, 53, 0, 0], "semantic": {"name": "django.utils.cache", "arg_names": [], "import_names": ["get_cache_key", "learn_cache_key", "patch_response_headers", "get_max_age"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.utils.cache import get_cache_key, learn_cache_key, patch_response_headers, get_max_age"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98829:ClassDef_L55_C0", "label": "UpdateCacheMiddleware", "type": "class", "loc": [55, 89], "level": 0, "parent": null, "vector": [3, 0, 0.4528, 0.2201, 0, 0.66, 0.6667, 785, 0, 2, 0, 0, 186, 0, 6], "semantic": {"name": "UpdateCacheMiddleware", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class UpdateCacheMiddleware(object):\n \"\"\"\n Response-phase cache middleware that updates the cache if the response is\n cacheable.\n\n Must be used as part of the two-part update/fetch cache middleware.\n UpdateCacheMiddleware must be the first piece of middleware in\n MIDDLEWARE_CLASSES so that it'll get called last during the response phase."}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98829:Expr_L56_C4", "label": "expression", "type": "expression", "loc": [56, 63], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98829:ClassDef_L55_C0", "vector": [8, 1, 0.3742, 0.0503, 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 Response-phase cache middleware that updates the cache if the response is\n cacheable.\n\n Must be used as part of the two-part update/fetch cache middleware.\n UpdateCacheMiddleware must be the first piece of middleware in\n MIDDLEWARE_CLASSES so that it'll get called last during the response phase.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98829:FunctionDef_L64_C4", "label": "__init__", "type": "function", "loc": [64, 67], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98829:ClassDef_L55_C0", "vector": [2, 1, 0.4119, 0.0252, 1, 0.99, 0.5, 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.cache_timeout = settings.CACHE_MIDDLEWARE_SECONDS\n self.key_prefix = settings.CACHE_MIDDLEWARE_KEY_PREFIX\n self.cache_anonymous_only = getattr(settings, 'CACHE_MIDDLEWARE_ANONYMOUS_ONLY', False)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98829:Assign_L65_C8", "label": "self.cache_timeout =", "type": "assigned_variable", "loc": [65, 65], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98829:FunctionDef_L64_C4", "vector": [14, 2, 0.4088, 0.0063, 2, 0.95, 0.0, 823, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "self.cache_timeout", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.cache_timeout = settings.CACHE_MIDDLEWARE_SECONDS"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98829:Assign_L66_C8", "label": "self.key_prefix =", "type": "assigned_variable", "loc": [66, 66], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98829:FunctionDef_L64_C4", "vector": [14, 2, 0.4151, 0.0063, 2, 0.95, 0.5, 473, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "self.key_prefix", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.key_prefix = settings.CACHE_MIDDLEWARE_KEY_PREFIX"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98829:Assign_L67_C8", "label": "self.cache_anonymous_only = getattr()", "type": "assigned_variable", "loc": [67, 67], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98829:FunctionDef_L64_C4", "vector": [14, 2, 0.4214, 0.0063, 2, 0.95, 1.0, 751, 3, 3, 0, 0, 121, 10, 1], "semantic": {"name": "self.cache_anonymous_only", "arg_names": [], "import_names": [], "rhs_call_name": "getattr", "annotation": ""}, "snippet": " self.cache_anonymous_only = getattr(settings, 'CACHE_MIDDLEWARE_ANONYMOUS_ONLY', False)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98829:FunctionDef_L69_C4", "label": "process_response", "type": "function", "loc": [69, 89], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98829:ClassDef_L55_C0", "vector": [2, 1, 0.4969, 0.1321, 1, 0.99, 1.0, 298, 0, 3, 1, 0, 0, 0, 5], "semantic": {"name": "process_response", "arg_names": ["self", "request", "response"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def process_response(self, request, response):\n \"\"\"Sets the cache, if needed.\"\"\"\n if not hasattr(request, '_cache_update_cache') or not request._cache_update_cache:\n # We don't need to update the cache, just return.\n return response\n if not response.status_code == 200:\n return response\n # Try to get the timeout from the \"max-age\" section of the \"Cache-"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98829:Expr_L70_C8", "label": "expression", "type": "expression", "loc": [70, 70], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98829:FunctionDef_L69_C4", "vector": [8, 2, 0.4403, 0.0063, 2, 0.6, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"Sets the cache, if needed.\"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98829:If_L71_C8", "label": "if", "type": "if", "loc": [71, 73], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98829:FunctionDef_L69_C4", "vector": [4, 2, 0.4528, 0.0189, 2, 0.6, 0.1429, 0, 0, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if not hasattr(request, '_cache_update_cache') or not request._cache_update_cache:\n # We don't need to update the cache, just return.\n return response"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98829:Return_L73_C12", "label": "return", "type": "return", "loc": [73, 73], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98829:If_L71_C8", "vector": [13, 3, 0.4591, 0.0063, 3, 0.57, 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_98829:If_L74_C8", "label": "if", "type": "if", "loc": [74, 75], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98829:FunctionDef_L69_C4", "vector": [4, 2, 0.4686, 0.0126, 2, 0.6, 0.2857, 0, 0, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if not response.status_code == 200:\n return response"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98829:Return_L75_C12", "label": "return", "type": "return", "loc": [75, 75], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98829:If_L74_C8", "vector": [13, 3, 0.4717, 0.0063, 3, 0.98, 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_98829:Assign_L79_C8", "label": "timeout = get_max_age()", "type": "assigned_variable", "loc": [79, 79], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98829:FunctionDef_L69_C4", "vector": [14, 2, 0.4969, 0.0063, 2, 0.6, 0.4286, 616, 3, 1, 0, 0, 389, 10, 1], "semantic": {"name": "timeout", "arg_names": [], "import_names": [], "rhs_call_name": "get_max_age", "annotation": ""}, "snippet": " timeout = get_max_age(response)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98829:If_L80_C8", "label": "if", "type": "if", "loc": [80, 84], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98829:FunctionDef_L69_C4", "vector": [4, 2, 0.5157, 0.0314, 2, 0.6, 0.5714, 0, 0, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if timeout == None:\n timeout = self.cache_timeout\n elif timeout == 0:\n # max-age was set to 0, don't bother caching.\n return response"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98829:Assign_L81_C12", "label": "timeout =", "type": "assigned_variable", "loc": [81, 81], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98829:If_L80_C8", "vector": [14, 3, 0.5094, 0.0063, 3, 0.4, 0.0, 616, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "timeout", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " timeout = self.cache_timeout"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98829:If_L82_C8", "label": "if", "type": "if", "loc": [82, 84], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98829:If_L80_C8", "vector": [4, 3, 0.522, 0.0189, 3, 0.4, 1.0, 0, 0, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " elif timeout == 0:\n # max-age was set to 0, don't bother caching.\n return response"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98829:Return_L84_C12", "label": "return", "type": "return", "loc": [84, 84], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98829:If_L82_C8", "vector": [13, 4, 0.5283, 0.0063, 4, 0.35, 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_98829:Expr_L85_C8", "label": "patch_response_headers()", "type": "expression", "loc": [85, 85], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98829:FunctionDef_L69_C4", "vector": [8, 2, 0.5346, 0.0063, 2, 0.6, 0.7143, 984, 3, 2, 0, 0, 0, 0, 1], "semantic": {"name": "patch_response_headers", "arg_names": [], "import_names": [], "rhs_call_name": "patch_response_headers", "annotation": ""}, "snippet": " patch_response_headers(response, timeout)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98829:If_L86_C8", "label": "if", "type": "if", "loc": [86, 88], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98829:FunctionDef_L69_C4", "vector": [4, 2, 0.5472, 0.0189, 2, 0.6, 0.8571, 0, 2, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if timeout:\n cache_key = learn_cache_key(request, response, timeout, self.key_prefix)\n cache.set(cache_key, response, timeout)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98829:Assign_L87_C12", "label": "cache_key = learn_cache_key()", "type": "assigned_variable", "loc": [87, 87], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98829:If_L86_C8", "vector": [14, 3, 0.5472, 0.0063, 3, 0.39, 0.0, 62, 3, 4, 0, 0, 799, 10, 1], "semantic": {"name": "cache_key", "arg_names": [], "import_names": [], "rhs_call_name": "learn_cache_key", "annotation": ""}, "snippet": " cache_key = learn_cache_key(request, response, timeout, self.key_prefix)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98829:Expr_L88_C12", "label": "set()", "type": "expression", "loc": [88, 88], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98829:If_L86_C8", "vector": [8, 3, 0.5535, 0.0063, 3, 0.39, 1.0, 21, 3, 3, 0, 0, 0, 0, 1], "semantic": {"name": "set", "arg_names": [], "import_names": [], "rhs_call_name": "set", "annotation": ""}, "snippet": " cache.set(cache_key, response, timeout)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98829:Return_L89_C8", "label": "return", "type": "return", "loc": [89, 89], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98829:FunctionDef_L69_C4", "vector": [13, 2, 0.5597, 0.0063, 2, 0.6, 1.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_98829:ClassDef_L91_C0", "label": "FetchFromCacheMiddleware", "type": "class", "loc": [91, 140], "level": 0, "parent": null, "vector": [3, 0, 0.7264, 0.3145, 0, 0.66, 0.8333, 254, 0, 2, 0, 0, 186, 0, 7], "semantic": {"name": "FetchFromCacheMiddleware", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class FetchFromCacheMiddleware(object):\n \"\"\"\n Request-phase cache middleware that fetches a page from the cache.\n\n Must be used as part of the two-part update/fetch cache middleware.\n FetchFromCacheMiddleware must be the last piece of middleware in\n MIDDLEWARE_CLASSES so that it'll get called last during the request phase.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98829:Expr_L92_C4", "label": "expression", "type": "expression", "loc": [92, 98], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98829:ClassDef_L91_C0", "vector": [8, 1, 0.5975, 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 Request-phase cache middleware that fetches a page from the cache.\n\n Must be used as part of the two-part update/fetch cache middleware.\n FetchFromCacheMiddleware must be the last piece of middleware in\n MIDDLEWARE_CLASSES so that it'll get called last during the request phase.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98829:FunctionDef_L99_C4", "label": "__init__", "type": "function", "loc": [99, 102], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98829:ClassDef_L91_C0", "vector": [2, 1, 0.6321, 0.0252, 1, 0.4, 0.5, 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.cache_timeout = settings.CACHE_MIDDLEWARE_SECONDS\n self.key_prefix = settings.CACHE_MIDDLEWARE_KEY_PREFIX\n self.cache_anonymous_only = getattr(settings, 'CACHE_MIDDLEWARE_ANONYMOUS_ONLY', False)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98829:Assign_L100_C8", "label": "self.cache_timeout =", "type": "assigned_variable", "loc": [100, 100], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98829:FunctionDef_L99_C4", "vector": [14, 2, 0.6289, 0.0063, 2, 0.71, 0.0, 823, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "self.cache_timeout", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.cache_timeout = settings.CACHE_MIDDLEWARE_SECONDS"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98829:Assign_L101_C8", "label": "self.key_prefix =", "type": "assigned_variable", "loc": [101, 101], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98829:FunctionDef_L99_C4", "vector": [14, 2, 0.6352, 0.0063, 2, 0.71, 0.5, 473, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "self.key_prefix", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.key_prefix = settings.CACHE_MIDDLEWARE_KEY_PREFIX"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98829:Assign_L102_C8", "label": "self.cache_anonymous_only = getattr()", "type": "assigned_variable", "loc": [102, 102], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98829:FunctionDef_L99_C4", "vector": [14, 2, 0.6415, 0.0063, 2, 0.71, 1.0, 751, 3, 3, 0, 0, 121, 10, 1], "semantic": {"name": "self.cache_anonymous_only", "arg_names": [], "import_names": [], "rhs_call_name": "getattr", "annotation": ""}, "snippet": " self.cache_anonymous_only = getattr(settings, 'CACHE_MIDDLEWARE_ANONYMOUS_ONLY', False)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98829:FunctionDef_L104_C4", "label": "process_request", "type": "function", "loc": [104, 140], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98829:ClassDef_L91_C0", "vector": [2, 1, 0.7673, 0.2327, 1, 0.4, 1.0, 81, 0, 2, 1, 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 \"\"\"\n Checks whether the page is already cached and returns the cached\n version if available.\n \"\"\"\n if self.cache_anonymous_only:\n assert hasattr(request, 'user'), \"The Django cache middleware with CACHE_MIDDLEWARE_ANONYMOUS_ONLY=True requires authentication middleware to be installed. Edit your MIDDLEWARE_CLASSES setting to insert 'django.contrib.auth.middleware.AuthenticationMiddleware' before the CacheMiddleware.\"\n"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98829:Expr_L105_C8", "label": "expression", "type": "expression", "loc": [105, 108], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98829:FunctionDef_L104_C4", "vector": [8, 2, 0.6698, 0.0252, 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 Checks whether the page is already cached and returns the cached\n version if available.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98829:If_L109_C8", "label": "if", "type": "if", "loc": [109, 110], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98829:FunctionDef_L104_C4", "vector": [4, 2, 0.6887, 0.0126, 2, 0.66, 0.1, 0, 7, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if self.cache_anonymous_only:\n assert hasattr(request, 'user'), \"The Django cache middleware with CACHE_MIDDLEWARE_ANONYMOUS_ONLY=True requires authentication middleware to be installed. Edit your MIDDLEWARE_CLASSES setting to insert 'django.contrib.auth.middleware.AuthenticationMiddleware' before the CacheMiddleware.\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98829:If_L112_C8", "label": "if", "type": "if", "loc": [112, 114], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98829:FunctionDef_L104_C4", "vector": [4, 2, 0.7107, 0.0189, 2, 0.66, 0.2, 0, 0, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if not request.method in ('GET', 'HEAD') or request.GET:\n request._cache_update_cache = False\n return None # Don't bother checking the cache."}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98829:Assign_L113_C12", "label": "request._cache_update_cache =", "type": "assigned_variable", "loc": [113, 113], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98829:If_L112_C8", "vector": [14, 3, 0.7107, 0.0063, 3, 0.19, 0.0, 169, 1, 0, 0, 0, 0, 4, 0], "semantic": {"name": "request._cache_update_cache", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " request._cache_update_cache = False"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98829:Return_L114_C12", "label": "return", "type": "return", "loc": [114, 114], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98829:If_L112_C8", "vector": [13, 3, 0.717, 0.0063, 3, 0.19, 1.0, 0, 1, 0, 0, 0, 0, 9, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return None # Don't bother checking the cache."}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98829:If_L116_C8", "label": "if", "type": "if", "loc": [116, 118], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98829:FunctionDef_L104_C4", "vector": [4, 2, 0.7358, 0.0189, 2, 0.66, 0.3, 0, 0, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if self.cache_anonymous_only and request.user.is_authenticated():\n request._cache_update_cache = False\n return None # Don't cache requests from authenticated users."}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98829:Assign_L117_C12", "label": "request._cache_update_cache =", "type": "assigned_variable", "loc": [117, 117], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98829:If_L116_C8", "vector": [14, 3, 0.7358, 0.0063, 3, 0.11, 0.0, 169, 1, 0, 0, 0, 0, 4, 0], "semantic": {"name": "request._cache_update_cache", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " request._cache_update_cache = False"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98829:Return_L118_C12", "label": "return", "type": "return", "loc": [118, 118], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98829:If_L116_C8", "vector": [13, 3, 0.7421, 0.0063, 3, 0.11, 1.0, 0, 1, 0, 0, 0, 0, 9, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return None # Don't cache requests from authenticated users."}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98829:Assign_L121_C8", "label": "cache_key = get_cache_key()", "type": "assigned_variable", "loc": [121, 121], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98829:FunctionDef_L104_C4", "vector": [14, 2, 0.761, 0.0063, 2, 0.66, 0.4, 62, 3, 3, 0, 0, 392, 10, 1], "semantic": {"name": "cache_key", "arg_names": [], "import_names": [], "rhs_call_name": "get_cache_key", "annotation": ""}, "snippet": " cache_key = get_cache_key(request, self.key_prefix, 'GET')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98829:If_L123_C8", "label": "if", "type": "if", "loc": [123, 125], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98829:FunctionDef_L104_C4", "vector": [4, 2, 0.7799, 0.0189, 2, 0.66, 0.5, 0, 0, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if cache_key is None:\n request._cache_update_cache = True\n return None # No cache information available, need to rebuild."}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98829:Assign_L124_C12", "label": "request._cache_update_cache =", "type": "assigned_variable", "loc": [124, 124], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98829:If_L123_C8", "vector": [14, 3, 0.7799, 0.0063, 3, 0.55, 0.0, 169, 1, 0, 0, 0, 0, 4, 0], "semantic": {"name": "request._cache_update_cache", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " request._cache_update_cache = True"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98829:Return_L125_C12", "label": "return", "type": "return", "loc": [125, 125], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98829:If_L123_C8", "vector": [13, 3, 0.7862, 0.0063, 3, 0.55, 1.0, 0, 1, 0, 0, 0, 0, 9, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return None # No cache information available, need to rebuild."}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98829:Assign_L127_C8", "label": "response = get()", "type": "assigned_variable", "loc": [127, 127], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98829:FunctionDef_L104_C4", "vector": [14, 2, 0.7987, 0.0063, 2, 0.66, 0.6, 511, 3, 2, 0, 0, 607, 10, 1], "semantic": {"name": "response", "arg_names": [], "import_names": [], "rhs_call_name": "get", "annotation": ""}, "snippet": " response = cache.get(cache_key, None)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98829:If_L130_C8", "label": "if", "type": "if", "loc": [130, 132], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98829:FunctionDef_L104_C4", "vector": [4, 2, 0.8239, 0.0189, 2, 0.66, 0.7, 0, 0, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if response is None and request.method == 'HEAD':\n cache_key = get_cache_key(request, self.key_prefix, 'HEAD')\n response = cache.get(cache_key, None)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98829:Assign_L131_C12", "label": "cache_key = get_cache_key()", "type": "assigned_variable", "loc": [131, 131], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98829:If_L130_C8", "vector": [14, 3, 0.8239, 0.0063, 3, 0.15, 0.0, 62, 3, 3, 0, 0, 392, 10, 1], "semantic": {"name": "cache_key", "arg_names": [], "import_names": [], "rhs_call_name": "get_cache_key", "annotation": ""}, "snippet": " cache_key = get_cache_key(request, self.key_prefix, 'HEAD')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98829:Assign_L132_C12", "label": "response = get()", "type": "assigned_variable", "loc": [132, 132], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98829:If_L130_C8", "vector": [14, 3, 0.8302, 0.0063, 3, 0.15, 1.0, 511, 3, 2, 0, 0, 607, 10, 1], "semantic": {"name": "response", "arg_names": [], "import_names": [], "rhs_call_name": "get", "annotation": ""}, "snippet": " response = cache.get(cache_key, None)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98829:If_L134_C8", "label": "if", "type": "if", "loc": [134, 136], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98829:FunctionDef_L104_C4", "vector": [4, 2, 0.8491, 0.0189, 2, 0.66, 0.8, 0, 0, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if response is None:\n request._cache_update_cache = True\n return None # No cache information available, need to rebuild."}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98829:Assign_L135_C12", "label": "request._cache_update_cache =", "type": "assigned_variable", "loc": [135, 135], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98829:If_L134_C8", "vector": [14, 3, 0.8491, 0.0063, 3, 0.82, 0.0, 169, 1, 0, 0, 0, 0, 4, 0], "semantic": {"name": "request._cache_update_cache", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " request._cache_update_cache = True"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98829:Return_L136_C12", "label": "return", "type": "return", "loc": [136, 136], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98829:If_L134_C8", "vector": [13, 3, 0.8553, 0.0063, 3, 0.82, 1.0, 0, 1, 0, 0, 0, 0, 9, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return None # No cache information available, need to rebuild."}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98829:Assign_L139_C8", "label": "request._cache_update_cache =", "type": "assigned_variable", "loc": [139, 139], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98829:FunctionDef_L104_C4", "vector": [14, 2, 0.8742, 0.0063, 2, 0.66, 0.9, 169, 1, 0, 0, 0, 0, 4, 0], "semantic": {"name": "request._cache_update_cache", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " request._cache_update_cache = False"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98829:Return_L140_C8", "label": "return", "type": "return", "loc": [140, 140], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98829:FunctionDef_L104_C4", "vector": [13, 2, 0.8805, 0.0063, 2, 0.66, 1.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_98829:ClassDef_L142_C0", "label": "CacheMiddleware", "type": "class", "loc": [142, 159], "level": 0, "parent": null, "vector": [3, 0, 0.9465, 0.1132, 0, 0.66, 1.0, 210, 0, 1, 0, 0, 785, 0, 1], "semantic": {"name": "CacheMiddleware", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class CacheMiddleware(UpdateCacheMiddleware, FetchFromCacheMiddleware):\n \"\"\"\n Cache middleware that provides basic behavior for many simple sites.\n\n Also used as the hook point for the cache decorator, which is generated\n using the decorator-from-middleware utility.\n \"\"\"\n def __init__(self, cache_timeout=None, key_prefix=None, cache_anonymous_only=None):"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98829:Expr_L143_C4", "label": "expression", "type": "expression", "loc": [143, 148], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98829:ClassDef_L142_C0", "vector": [8, 1, 0.9151, 0.0377, 1, 0.22, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"\n Cache middleware that provides basic behavior for many simple sites.\n\n Also used as the hook point for the cache decorator, which is generated\n using the decorator-from-middleware utility.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98829:FunctionDef_L149_C4", "label": "__init__", "type": "function", "loc": [149, 159], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98829:ClassDef_L142_C0", "vector": [2, 1, 0.9686, 0.0692, 1, 0.22, 1.0, 555, 0, 4, 0, 0, 0, 0, 1], "semantic": {"name": "__init__", "arg_names": ["self", "cache_timeout", "key_prefix", "cache_anonymous_only"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def __init__(self, cache_timeout=None, key_prefix=None, cache_anonymous_only=None):\n self.cache_timeout = cache_timeout\n if cache_timeout is None:\n self.cache_timeout = settings.CACHE_MIDDLEWARE_SECONDS\n self.key_prefix = key_prefix\n if key_prefix is None:\n self.key_prefix = settings.CACHE_MIDDLEWARE_KEY_PREFIX\n if cache_anonymous_only is None:"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98829:Assign_L150_C8", "label": "self.cache_timeout =", "type": "assigned_variable", "loc": [150, 150], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98829:FunctionDef_L149_C4", "vector": [14, 2, 0.9434, 0.0063, 2, 0.37, 0.0, 823, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "self.cache_timeout", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.cache_timeout = cache_timeout"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98829:If_L151_C8", "label": "if", "type": "if", "loc": [151, 152], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98829:FunctionDef_L149_C4", "vector": [4, 2, 0.9528, 0.0126, 2, 0.37, 0.25, 0, 0, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if cache_timeout is None:\n self.cache_timeout = settings.CACHE_MIDDLEWARE_SECONDS"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98829:Assign_L152_C12", "label": "self.cache_timeout =", "type": "assigned_variable", "loc": [152, 152], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98829:If_L151_C8", "vector": [14, 3, 0.956, 0.0063, 3, 0.82, 0.0, 823, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "self.cache_timeout", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.cache_timeout = settings.CACHE_MIDDLEWARE_SECONDS"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98829:Assign_L153_C8", "label": "self.key_prefix =", "type": "assigned_variable", "loc": [153, 153], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98829:FunctionDef_L149_C4", "vector": [14, 2, 0.9623, 0.0063, 2, 0.37, 0.5, 473, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "self.key_prefix", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.key_prefix = key_prefix"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98829:If_L154_C8", "label": "if", "type": "if", "loc": [154, 155], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98829:FunctionDef_L149_C4", "vector": [4, 2, 0.9717, 0.0126, 2, 0.37, 0.75, 0, 0, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if key_prefix is None:\n self.key_prefix = settings.CACHE_MIDDLEWARE_KEY_PREFIX"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98829:Assign_L155_C12", "label": "self.key_prefix =", "type": "assigned_variable", "loc": [155, 155], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98829:If_L154_C8", "vector": [14, 3, 0.9748, 0.0063, 3, 0.37, 0.0, 473, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "self.key_prefix", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.key_prefix = settings.CACHE_MIDDLEWARE_KEY_PREFIX"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98829:If_L156_C8", "label": "if", "type": "if", "loc": [156, 159], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98829:FunctionDef_L149_C4", "vector": [4, 2, 0.9906, 0.0252, 2, 0.37, 1.0, 0, 0, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if cache_anonymous_only is None:\n self.cache_anonymous_only = getattr(settings, 'CACHE_MIDDLEWARE_ANONYMOUS_ONLY', False)\n else:\n self.cache_anonymous_only = cache_anonymous_only"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98829:Assign_L157_C12", "label": "self.cache_anonymous_only = getattr()", "type": "assigned_variable", "loc": [157, 157], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98829:If_L156_C8", "vector": [14, 3, 0.9874, 0.0063, 3, 0.34, 0.0, 751, 3, 3, 0, 0, 121, 10, 1], "semantic": {"name": "self.cache_anonymous_only", "arg_names": [], "import_names": [], "rhs_call_name": "getattr", "annotation": ""}, "snippet": " self.cache_anonymous_only = getattr(settings, 'CACHE_MIDDLEWARE_ANONYMOUS_ONLY', False)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98829:Assign_L159_C12", "label": "self.cache_anonymous_only =", "type": "assigned_variable", "loc": [159, 159], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98829:If_L156_C8", "vector": [14, 3, 1.0, 0.0063, 3, 0.34, 1.0, 751, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "self.cache_anonymous_only", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.cache_anonymous_only = cache_anonymous_only"}]
[{"f": "ajibawa-2023/Python-Code-Large/train/row_98829:ClassDef_L55_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98829:Expr_L56_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98829:ClassDef_L55_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98829:FunctionDef_L64_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98829:FunctionDef_L64_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98829:Assign_L65_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98829:FunctionDef_L64_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98829:Assign_L66_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98829:FunctionDef_L64_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98829:Assign_L67_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98829:ClassDef_L55_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98829:FunctionDef_L69_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98829:FunctionDef_L69_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98829:Expr_L70_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98829:FunctionDef_L69_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98829:If_L71_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98829:If_L71_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98829:Return_L73_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98829:FunctionDef_L69_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98829:If_L74_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98829:If_L74_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98829:Return_L75_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98829:FunctionDef_L69_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98829:Assign_L79_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98829:FunctionDef_L69_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98829:If_L80_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98829:If_L80_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98829:Assign_L81_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98829:If_L80_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98829:If_L82_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98829:If_L82_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98829:Return_L84_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98829:FunctionDef_L69_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98829:Expr_L85_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98829:FunctionDef_L69_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98829:If_L86_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98829:If_L86_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98829:Assign_L87_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98829:If_L86_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98829:Expr_L88_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98829:FunctionDef_L69_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98829:Return_L89_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98829:ClassDef_L91_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98829:Expr_L92_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98829:ClassDef_L91_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98829:FunctionDef_L99_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98829:FunctionDef_L99_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98829:Assign_L100_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98829:FunctionDef_L99_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98829:Assign_L101_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98829:FunctionDef_L99_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98829:Assign_L102_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98829:ClassDef_L91_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98829:FunctionDef_L104_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98829:FunctionDef_L104_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98829:Expr_L105_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98829:FunctionDef_L104_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98829:If_L109_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98829:FunctionDef_L104_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98829:If_L112_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98829:If_L112_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98829:Assign_L113_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98829:If_L112_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98829:Return_L114_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98829:FunctionDef_L104_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98829:If_L116_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98829:If_L116_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98829:Assign_L117_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98829:If_L116_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98829:Return_L118_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98829:FunctionDef_L104_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98829:Assign_L121_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98829:FunctionDef_L104_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98829:If_L123_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98829:If_L123_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98829:Assign_L124_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98829:If_L123_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98829:Return_L125_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98829:FunctionDef_L104_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98829:Assign_L127_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98829:FunctionDef_L104_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98829:If_L130_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98829:If_L130_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98829:Assign_L131_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98829:If_L130_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98829:Assign_L132_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98829:FunctionDef_L104_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98829:If_L134_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98829:If_L134_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98829:Assign_L135_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98829:If_L134_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98829:Return_L136_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98829:FunctionDef_L104_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98829:Assign_L139_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98829:FunctionDef_L104_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98829:Return_L140_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98829:ClassDef_L142_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98829:Expr_L143_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98829:ClassDef_L142_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98829:FunctionDef_L149_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98829:FunctionDef_L149_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98829:Assign_L150_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98829:FunctionDef_L149_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98829:If_L151_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98829:If_L151_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98829:Assign_L152_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98829:FunctionDef_L149_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98829:Assign_L153_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98829:FunctionDef_L149_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98829:If_L154_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98829:If_L154_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98829:Assign_L155_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98829:FunctionDef_L149_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98829:If_L156_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98829:If_L156_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98829:Assign_L157_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98829:If_L156_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98829:Assign_L159_C12"}]
from django.conf import settings from django.template import Node from django.template import TemplateSyntaxError, Library from django.utils import formats from django.utils.encoding import force_unicode register = Library() def localize(value): """ Forces a value to be rendered as a localized value, regardless of the value of ``settings.USE_L10N``. """ return force_unicode(formats.localize(value, use_l10n=True)) localize.is_safe = False def unlocalize(value): """ Forces a value to be rendered as a non-localized value, regardless of the value of ``settings.USE_L10N``. """ return force_unicode(value) unlocalize.is_safe = False class LocalizeNode(Node): def __init__(self, nodelist, use_l10n): self.nodelist = nodelist self.use_l10n = use_l10n def __repr__(self): return "<LocalizeNode>" def render(self, context): old_setting = context.use_l10n context.use_l10n = self.use_l10n output = self.nodelist.render(context) context.use_l10n = old_setting return output @register.tag('localize') def localize_tag(parser, token): """ Forces or prevents localization of values, regardless of the value of `settings.USE_L10N`. Sample usage:: {% localize off %} var pi = {{ 3.1415 }}; {% endlocalize %} """ use_l10n = None bits = list(token.split_contents()) if len(bits) == 1: use_l10n = True elif len(bits) > 2 or bits[1] not in ('on', 'off'): raise TemplateSyntaxError("%r argument should be 'on' or 'off'" % bits[0]) else: use_l10n = bits[1] == 'on' nodelist = parser.parse(('endlocalize',)) parser.delete_first_token() return LocalizeNode(nodelist, use_l10n) register.filter(localize) register.filter(unlocalize)
ajibawa-2023/Python-Code-Large/train/row_98830
39
67
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_98830:ImportFrom_L1_C0", "label": "from django.conf import settings", "type": "import", "loc": [1, 1], "level": 0, "parent": null, "vector": [1, 0, 0.0149, 0.0149, 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_98830:ImportFrom_L2_C0", "label": "from django.template import Node", "type": "import", "loc": [2, 2], "level": 0, "parent": null, "vector": [1, 0, 0.0299, 0.0149, 0, 0.66, 0.0769, 213, 0, 1, 0, 0, 213, 0, 0], "semantic": {"name": "django.template", "arg_names": [], "import_names": ["Node"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.template import Node"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98830:ImportFrom_L3_C0", "label": "from django.template import TemplateSyntaxError, Library", "type": "import", "loc": [3, 3], "level": 0, "parent": null, "vector": [1, 0, 0.0448, 0.0149, 0, 0.66, 0.1538, 213, 0, 2, 0, 0, 213, 0, 0], "semantic": {"name": "django.template", "arg_names": [], "import_names": ["TemplateSyntaxError", "Library"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.template import TemplateSyntaxError, Library"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98830:ImportFrom_L4_C0", "label": "from django.utils import formats", "type": "import", "loc": [4, 4], "level": 0, "parent": null, "vector": [1, 0, 0.0597, 0.0149, 0, 0.66, 0.2308, 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_98830:ImportFrom_L5_C0", "label": "from django.utils.encoding import force_unicode", "type": "import", "loc": [5, 5], "level": 0, "parent": null, "vector": [1, 0, 0.0746, 0.0149, 0, 0.66, 0.3077, 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_98830:Assign_L8_C0", "label": "register = Library()", "type": "assigned_variable", "loc": [8, 8], "level": 0, "parent": null, "vector": [14, 0, 0.1194, 0.0149, 0, 0.66, 0.3846, 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_98830:FunctionDef_L10_C0", "label": "localize", "type": "function", "loc": [10, 15], "level": 0, "parent": null, "vector": [2, 0, 0.1866, 0.0896, 0, 0.66, 0.4615, 30, 0, 1, 1, 0, 0, 0, 2], "semantic": {"name": "localize", "arg_names": ["value"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "def localize(value):\n \"\"\"\n Forces a value to be rendered as a localized value,\n regardless of the value of ``settings.USE_L10N``.\n \"\"\"\n return force_unicode(formats.localize(value, use_l10n=True))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98830:Expr_L11_C4", "label": "expression", "type": "expression", "loc": [11, 14], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98830:FunctionDef_L10_C0", "vector": [8, 1, 0.1866, 0.0597, 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 Forces a value to be rendered as a localized value,\n regardless of the value of ``settings.USE_L10N``.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98830:Return_L15_C4", "label": "return", "type": "return", "loc": [15, 15], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98830:FunctionDef_L10_C0", "vector": [13, 1, 0.2239, 0.0149, 1, 0.55, 1.0, 0, 3, 0, 0, 0, 0, 10, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return force_unicode(formats.localize(value, use_l10n=True))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98830:Assign_L16_C0", "label": "localize.is_safe =", "type": "assigned_variable", "loc": [16, 16], "level": 0, "parent": null, "vector": [14, 0, 0.2388, 0.0149, 0, 0.66, 0.5385, 632, 1, 0, 0, 0, 0, 4, 0], "semantic": {"name": "localize.is_safe", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "localize.is_safe = False"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98830:FunctionDef_L18_C0", "label": "unlocalize", "type": "function", "loc": [18, 23], "level": 0, "parent": null, "vector": [2, 0, 0.306, 0.0896, 0, 0.66, 0.6154, 776, 0, 1, 1, 0, 0, 0, 1], "semantic": {"name": "unlocalize", "arg_names": ["value"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "def unlocalize(value):\n \"\"\"\n Forces a value to be rendered as a non-localized value,\n regardless of the value of ``settings.USE_L10N``.\n \"\"\"\n return force_unicode(value)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98830:Expr_L19_C4", "label": "expression", "type": "expression", "loc": [19, 22], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98830:FunctionDef_L18_C0", "vector": [8, 1, 0.306, 0.0597, 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 Forces a value to be rendered as a non-localized value,\n regardless of the value of ``settings.USE_L10N``.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98830:Return_L23_C4", "label": "return", "type": "return", "loc": [23, 23], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98830:FunctionDef_L18_C0", "vector": [13, 1, 0.3433, 0.0149, 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 force_unicode(value)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98830:Assign_L24_C0", "label": "unlocalize.is_safe =", "type": "assigned_variable", "loc": [24, 24], "level": 0, "parent": null, "vector": [14, 0, 0.3582, 0.0149, 0, 0.66, 0.6923, 513, 1, 0, 0, 0, 0, 4, 0], "semantic": {"name": "unlocalize.is_safe", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "unlocalize.is_safe = False"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98830:ClassDef_L26_C0", "label": "LocalizeNode", "type": "class", "loc": [26, 39], "level": 0, "parent": null, "vector": [3, 0, 0.4851, 0.209, 0, 0.66, 0.7692, 315, 0, 3, 0, 0, 345, 0, 1], "semantic": {"name": "LocalizeNode", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class LocalizeNode(Node):\n def __init__(self, nodelist, use_l10n):\n self.nodelist = nodelist\n self.use_l10n = use_l10n\n\n def __repr__(self):\n return \"<LocalizeNode>\"\n"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98830:FunctionDef_L27_C4", "label": "__init__", "type": "function", "loc": [27, 29], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98830:ClassDef_L26_C0", "vector": [2, 1, 0.4179, 0.0448, 1, 0.93, 0.0, 555, 0, 3, 0, 0, 0, 0, 0], "semantic": {"name": "__init__", "arg_names": ["self", "nodelist", "use_l10n"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def __init__(self, nodelist, use_l10n):\n self.nodelist = nodelist\n self.use_l10n = use_l10n"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98830:Assign_L28_C8", "label": "self.nodelist =", "type": "assigned_variable", "loc": [28, 28], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98830:FunctionDef_L27_C4", "vector": [14, 2, 0.4179, 0.0149, 2, 0.29, 0.0, 870, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "self.nodelist", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.nodelist = nodelist"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98830:Assign_L29_C8", "label": "self.use_l10n =", "type": "assigned_variable", "loc": [29, 29], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98830:FunctionDef_L27_C4", "vector": [14, 2, 0.4328, 0.0149, 2, 0.29, 1.0, 47, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "self.use_l10n", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.use_l10n = use_l10n"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98830:FunctionDef_L31_C4", "label": "__repr__", "type": "function", "loc": [31, 32], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98830:ClassDef_L26_C0", "vector": [2, 1, 0.4701, 0.0299, 1, 0.93, 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 \"<LocalizeNode>\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98830:Return_L32_C8", "label": "return", "type": "return", "loc": [32, 32], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98830:FunctionDef_L31_C4", "vector": [13, 2, 0.4776, 0.0149, 2, 0.55, 0.0, 0, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return \"<LocalizeNode>\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98830:FunctionDef_L34_C4", "label": "render", "type": "function", "loc": [34, 39], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98830:ClassDef_L26_C0", "vector": [2, 1, 0.5448, 0.0896, 1, 0.93, 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 old_setting = context.use_l10n\n context.use_l10n = self.use_l10n\n output = self.nodelist.render(context)\n context.use_l10n = old_setting\n return output"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98830:Assign_L35_C8", "label": "old_setting =", "type": "assigned_variable", "loc": [35, 35], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98830:FunctionDef_L34_C4", "vector": [14, 2, 0.5224, 0.0149, 2, 0.45, 0.0, 669, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "old_setting", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " old_setting = context.use_l10n"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98830:Assign_L36_C8", "label": "context.use_l10n =", "type": "assigned_variable", "loc": [36, 36], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98830:FunctionDef_L34_C4", "vector": [14, 2, 0.5373, 0.0149, 2, 0.45, 0.25, 687, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "context.use_l10n", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " context.use_l10n = self.use_l10n"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98830:Assign_L37_C8", "label": "output = render()", "type": "assigned_variable", "loc": [37, 37], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98830:FunctionDef_L34_C4", "vector": [14, 2, 0.5522, 0.0149, 2, 0.45, 0.5, 886, 3, 1, 0, 0, 24, 10, 1], "semantic": {"name": "output", "arg_names": [], "import_names": [], "rhs_call_name": "render", "annotation": ""}, "snippet": " output = self.nodelist.render(context)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98830:Assign_L38_C8", "label": "context.use_l10n =", "type": "assigned_variable", "loc": [38, 38], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98830:FunctionDef_L34_C4", "vector": [14, 2, 0.5672, 0.0149, 2, 0.45, 0.75, 687, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "context.use_l10n", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " context.use_l10n = old_setting"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98830:Return_L39_C8", "label": "return", "type": "return", "loc": [39, 39], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98830:FunctionDef_L34_C4", "vector": [13, 2, 0.5821, 0.0149, 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 output"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98830:FunctionDef_L42_C0", "label": "localize_tag", "type": "function", "loc": [42, 64], "level": 0, "parent": null, "vector": [2, 0, 0.791, 0.3433, 0, 0.66, 0.8462, 415, 0, 2, 1, 0, 0, 0, 9], "semantic": {"name": "localize_tag", "arg_names": ["parser", "token"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "def localize_tag(parser, token):\n \"\"\"\n Forces or prevents localization of values, regardless of the value of\n `settings.USE_L10N`.\n\n Sample usage::\n\n {% localize off %}"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98830:Expr_L43_C4", "label": "expression", "type": "expression", "loc": [43, 53], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98830:FunctionDef_L42_C0", "vector": [8, 1, 0.7164, 0.1642, 1, 0.36, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"\n Forces or prevents localization of values, regardless of the value of\n `settings.USE_L10N`.\n\n Sample usage::\n\n {% localize off %}\n var pi = {{ 3.1415 }};"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98830:Assign_L54_C4", "label": "use_l10n =", "type": "assigned_variable", "loc": [54, 54], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98830:FunctionDef_L42_C0", "vector": [14, 1, 0.806, 0.0149, 1, 0.36, 0.1667, 218, 1, 0, 0, 0, 0, 9, 0], "semantic": {"name": "use_l10n", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " use_l10n = None"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98830:Assign_L55_C4", "label": "bits = list()", "type": "assigned_variable", "loc": [55, 55], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98830:FunctionDef_L42_C0", "vector": [14, 1, 0.8209, 0.0149, 1, 0.36, 0.3333, 593, 3, 1, 0, 0, 430, 10, 2], "semantic": {"name": "bits", "arg_names": [], "import_names": [], "rhs_call_name": "list", "annotation": ""}, "snippet": " bits = list(token.split_contents())"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98830:If_L56_C4", "label": "if", "type": "if", "loc": [56, 61], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98830:FunctionDef_L42_C0", "vector": [4, 1, 0.8731, 0.0896, 1, 0.36, 0.5, 0, 0, 0, 0, 0, 0, 0, 3], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if len(bits) == 1:\n use_l10n = True\n elif len(bits) > 2 or bits[1] not in ('on', 'off'):\n raise TemplateSyntaxError(\"%r argument should be 'on' or 'off'\" % bits[0])\n else:\n use_l10n = bits[1] == 'on'"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98830:Assign_L57_C8", "label": "use_l10n =", "type": "assigned_variable", "loc": [57, 57], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98830:If_L56_C4", "vector": [14, 2, 0.8507, 0.0149, 2, 0.45, 0.0, 218, 1, 0, 0, 0, 0, 4, 0], "semantic": {"name": "use_l10n", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " use_l10n = True"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98830:If_L58_C4", "label": "if", "type": "if", "loc": [58, 61], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98830:If_L56_C4", "vector": [4, 2, 0.8881, 0.0597, 2, 0.45, 1.0, 0, 0, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " elif len(bits) > 2 or bits[1] not in ('on', 'off'):\n raise TemplateSyntaxError(\"%r argument should be 'on' or 'off'\" % bits[0])\n else:\n use_l10n = bits[1] == 'on'"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98830:Assign_L61_C8", "label": "use_l10n =", "type": "assigned_variable", "loc": [61, 61], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98830:If_L58_C4", "vector": [14, 3, 0.9104, 0.0149, 3, 0.56, 0.0, 218, 0, 0, 0, 0, 0, 0, 0], "semantic": {"name": "use_l10n", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " use_l10n = bits[1] == 'on'"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98830:Assign_L62_C4", "label": "nodelist = parse()", "type": "assigned_variable", "loc": [62, 62], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98830:FunctionDef_L42_C0", "vector": [14, 1, 0.9254, 0.0149, 1, 0.36, 0.6667, 507, 3, 1, 0, 0, 678, 10, 1], "semantic": {"name": "nodelist", "arg_names": [], "import_names": [], "rhs_call_name": "parse", "annotation": ""}, "snippet": " nodelist = parser.parse(('endlocalize',))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98830:Expr_L63_C4", "label": "delete_first_token()", "type": "expression", "loc": [63, 63], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98830:FunctionDef_L42_C0", "vector": [8, 1, 0.9403, 0.0149, 1, 0.36, 0.8333, 405, 3, 0, 0, 0, 0, 0, 1], "semantic": {"name": "delete_first_token", "arg_names": [], "import_names": [], "rhs_call_name": "delete_first_token", "annotation": ""}, "snippet": " parser.delete_first_token()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98830:Return_L64_C4", "label": "return", "type": "return", "loc": [64, 64], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98830:FunctionDef_L42_C0", "vector": [13, 1, 0.9552, 0.0149, 1, 0.36, 1.0, 0, 3, 0, 0, 0, 0, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return LocalizeNode(nodelist, use_l10n)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98830:Expr_L66_C0", "label": "filter()", "type": "expression", "loc": [66, 66], "level": 0, "parent": null, "vector": [8, 0, 0.9851, 0.0149, 0, 0.66, 0.9231, 526, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "filter", "arg_names": [], "import_names": [], "rhs_call_name": "filter", "annotation": ""}, "snippet": "register.filter(localize)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98830:Expr_L67_C0", "label": "filter()", "type": "expression", "loc": [67, 67], "level": 0, "parent": null, "vector": [8, 0, 1.0, 0.0149, 0, 0.66, 1.0, 526, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "filter", "arg_names": [], "import_names": [], "rhs_call_name": "filter", "annotation": ""}, "snippet": "register.filter(unlocalize)"}]
[{"f": "ajibawa-2023/Python-Code-Large/train/row_98830:FunctionDef_L10_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98830:Expr_L11_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98830:FunctionDef_L10_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98830:Return_L15_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98830:FunctionDef_L18_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98830:Expr_L19_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98830:FunctionDef_L18_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98830:Return_L23_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98830:ClassDef_L26_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98830:FunctionDef_L27_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98830:FunctionDef_L27_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98830:Assign_L28_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98830:FunctionDef_L27_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98830:Assign_L29_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98830:ClassDef_L26_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98830:FunctionDef_L31_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98830:FunctionDef_L31_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98830:Return_L32_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98830:ClassDef_L26_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98830:FunctionDef_L34_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98830:FunctionDef_L34_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98830:Assign_L35_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98830:FunctionDef_L34_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98830:Assign_L36_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98830:FunctionDef_L34_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98830:Assign_L37_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98830:FunctionDef_L34_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98830:Assign_L38_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98830:FunctionDef_L34_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98830:Return_L39_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98830:FunctionDef_L42_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98830:Expr_L43_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98830:FunctionDef_L42_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98830:Assign_L54_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98830:FunctionDef_L42_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98830:Assign_L55_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98830:FunctionDef_L42_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98830:If_L56_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98830:If_L56_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98830:Assign_L57_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98830:If_L56_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98830:If_L58_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98830:If_L58_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98830:Assign_L61_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98830:FunctionDef_L42_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98830:Assign_L62_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98830:FunctionDef_L42_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98830:Expr_L63_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98830:FunctionDef_L42_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98830:Return_L64_C4"}]
import re from django.template import Node, Variable, VariableNode, _render_value_in_context from django.template import TemplateSyntaxError, TokenParser, Library from django.template import TOKEN_TEXT, TOKEN_VAR from django.utils import translation from django.utils.encoding import force_unicode register = Library() class GetAvailableLanguagesNode(Node): def __init__(self, variable): self.variable = variable def render(self, context): from django.conf import settings context[self.variable] = [(k, translation.ugettext(v)) for k, v in settings.LANGUAGES] return '' class GetCurrentLanguageNode(Node): def __init__(self, variable): self.variable = variable def render(self, context): context[self.variable] = translation.get_language() return '' class GetCurrentLanguageBidiNode(Node): def __init__(self, variable): self.variable = variable def render(self, context): context[self.variable] = translation.get_language_bidi() return '' class TranslateNode(Node): def __init__(self, filter_expression, noop): self.noop = noop self.filter_expression = filter_expression if isinstance(self.filter_expression.var, basestring): self.filter_expression.var = Variable(u"'%s'" % self.filter_expression.var) def render(self, context): self.filter_expression.var.translate = not self.noop output = self.filter_expression.resolve(context) return _render_value_in_context(output, context) class BlockTranslateNode(Node): def __init__(self, extra_context, singular, plural=None, countervar=None, counter=None): self.extra_context = extra_context self.singular = singular self.plural = plural self.countervar = countervar self.counter = counter def render_token_list(self, tokens): result = [] vars = [] for token in tokens: if token.token_type == TOKEN_TEXT: result.append(token.contents) elif token.token_type == TOKEN_VAR: result.append(u'%%(%s)s' % token.contents) vars.append(token.contents) return ''.join(result), vars def render(self, context): tmp_context = {} for var, val in self.extra_context.items(): tmp_context[var] = val.render(context) # Update() works like a push(), so corresponding context.pop() is at # the end of function context.update(tmp_context) singular, vars = self.render_token_list(self.singular) if self.plural and self.countervar and self.counter: count = self.counter.resolve(context) context[self.countervar] = count plural, plural_vars = self.render_token_list(self.plural) result = translation.ungettext(singular, plural, count) vars.extend(plural_vars) else: result = translation.ugettext(singular) # Escape all isolated '%' before substituting in the context. result = re.sub(u'%(?!\()', u'%%', result) data = dict([(v, _render_value_in_context(context[v], context)) for v in vars]) context.pop() return result % data def do_get_available_languages(parser, token): """ This will store a list of available languages in the context. Usage:: {% get_available_languages as languages %} {% for language in languages %} ... {% endfor %} This will just pull the LANGUAGES setting from your setting file (or the default settings) and put it into the named variable. """ args = token.contents.split() if len(args) != 3 or args[1] != 'as': raise TemplateSyntaxError("'get_available_languages' requires 'as variable' (got %r)" % args) return GetAvailableLanguagesNode(args[2]) def do_get_current_language(parser, token): """ This will store the current language in the context. Usage:: {% get_current_language as language %} This will fetch the currently active language and put it's value into the ``language`` context variable. """ args = token.contents.split() if len(args) != 3 or args[1] != 'as': raise TemplateSyntaxError("'get_current_language' requires 'as variable' (got %r)" % args) return GetCurrentLanguageNode(args[2]) def do_get_current_language_bidi(parser, token): """ This will store the current language layout in the context. Usage:: {% get_current_language_bidi as bidi %} This will fetch the currently active language's layout and put it's value into the ``bidi`` context variable. True indicates right-to-left layout, otherwise left-to-right """ args = token.contents.split() if len(args) != 3 or args[1] != 'as': raise TemplateSyntaxError("'get_current_language_bidi' requires 'as variable' (got %r)" % args) return GetCurrentLanguageBidiNode(args[2]) def do_translate(parser, token): """ This will mark a string for translation and will translate the string for the current language. Usage:: {% trans "this is a test" %} This will mark the string for translation so it will be pulled out by mark-messages.py into the .po files and will run the string through the translation engine. There is a second form:: {% trans "this is a test" noop %} This will only mark for translation, but will return the string unchanged. Use it when you need to store values into forms that should be translated later on. You can use variables instead of constant strings to translate stuff you marked somewhere else:: {% trans variable %} This will just try to translate the contents of the variable ``variable``. Make sure that the string in there is something that is in the .po file. """ class TranslateParser(TokenParser): def top(self): value = self.value() # Backwards Compatiblity fix: # FilterExpression does not support single-quoted strings, # so we make a cheap localized fix in order to maintain # backwards compatibility with existing uses of ``trans`` # where single quote use is supported. if value[0] == "'": pos = None m = re.match("^'([^']+)'(\|.*$)",value) if m: value = '"%s"%s' % (m.group(1).replace('"','\\"'),m.group(2)) elif value[-1] == "'": value = '"%s"' % value[1:-1].replace('"','\\"') if self.more(): if self.tag() == 'noop': noop = True else: raise TemplateSyntaxError("only option for 'trans' is 'noop'") else: noop = False return (value, noop) value, noop = TranslateParser(token.contents).top() return TranslateNode(parser.compile_filter(value), noop) def do_block_translate(parser, token): """ This will translate a block of text with parameters. Usage:: {% blocktrans with foo|filter as bar and baz|filter as boo %} This is {{ bar }} and {{ boo }}. {% endblocktrans %} Additionally, this supports pluralization:: {% blocktrans count var|length as count %} There is {{ count }} object. {% plural %} There are {{ count }} objects. {% endblocktrans %} This is much like ngettext, only in template syntax. """ class BlockTranslateParser(TokenParser): def top(self): countervar = None counter = None extra_context = {} while self.more(): tag = self.tag() if tag == 'with' or tag == 'and': value = self.value() if self.tag() != 'as': raise TemplateSyntaxError("variable bindings in 'blocktrans' must be 'with value as variable'") extra_context[self.tag()] = VariableNode( parser.compile_filter(value)) elif tag == 'count': counter = parser.compile_filter(self.value()) if self.tag() != 'as': raise TemplateSyntaxError("counter specification in 'blocktrans' must be 'count value as variable'") countervar = self.tag() else: raise TemplateSyntaxError("unknown subtag %s for 'blocktrans' found" % tag) return (countervar, counter, extra_context) countervar, counter, extra_context = BlockTranslateParser(token.contents).top() singular = [] plural = [] while parser.tokens: token = parser.next_token() if token.token_type in (TOKEN_VAR, TOKEN_TEXT): singular.append(token) else: break if countervar and counter: if token.contents.strip() != 'plural': raise TemplateSyntaxError("'blocktrans' doesn't allow other block tags inside it") while parser.tokens: token = parser.next_token() if token.token_type in (TOKEN_VAR, TOKEN_TEXT): plural.append(token) else: break if token.contents.strip() != 'endblocktrans': raise TemplateSyntaxError("'blocktrans' doesn't allow other block tags (seen %r) inside it" % token.contents) return BlockTranslateNode(extra_context, singular, plural, countervar, counter) register.tag('get_available_languages', do_get_available_languages) register.tag('get_current_language', do_get_current_language) register.tag('get_current_language_bidi', do_get_current_language_bidi) register.tag('trans', do_translate) register.tag('blocktrans', do_block_translate)
ajibawa-2023/Python-Code-Large/train/row_98831
142
274
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_98831:Import_L1_C0", "label": "re import re", "type": "import", "loc": [1, 1], "level": 0, "parent": null, "vector": [1, 0, 0.0036, 0.0036, 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_98831:ImportFrom_L3_C0", "label": "from django.template import Node, Variable, VariableNode\u2026", "type": "import", "loc": [3, 3], "level": 0, "parent": null, "vector": [1, 0, 0.0109, 0.0036, 0, 0.66, 0.0476, 213, 0, 4, 0, 0, 213, 0, 0], "semantic": {"name": "django.template", "arg_names": [], "import_names": ["Node", "Variable", "VariableNode", "_render_value_in_context"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.template import Node, Variable, VariableNode, _render_value_in_context"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98831:ImportFrom_L4_C0", "label": "from django.template import TemplateSyntaxError, TokenParser, Library", "type": "import", "loc": [4, 4], "level": 0, "parent": null, "vector": [1, 0, 0.0146, 0.0036, 0, 0.66, 0.0952, 213, 0, 3, 0, 0, 213, 0, 0], "semantic": {"name": "django.template", "arg_names": [], "import_names": ["TemplateSyntaxError", "TokenParser", "Library"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.template import TemplateSyntaxError, TokenParser, Library"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98831:ImportFrom_L5_C0", "label": "from django.template import TOKEN_TEXT, TOKEN_VAR", "type": "import", "loc": [5, 5], "level": 0, "parent": null, "vector": [1, 0, 0.0182, 0.0036, 0, 0.66, 0.1429, 213, 0, 2, 0, 0, 213, 0, 0], "semantic": {"name": "django.template", "arg_names": [], "import_names": ["TOKEN_TEXT", "TOKEN_VAR"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.template import TOKEN_TEXT, TOKEN_VAR"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98831:ImportFrom_L6_C0", "label": "from django.utils import translation", "type": "import", "loc": [6, 6], "level": 0, "parent": null, "vector": [1, 0, 0.0219, 0.0036, 0, 0.66, 0.1905, 944, 0, 1, 0, 0, 944, 0, 0], "semantic": {"name": "django.utils", "arg_names": [], "import_names": ["translation"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.utils import translation"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98831:ImportFrom_L7_C0", "label": "from django.utils.encoding import force_unicode", "type": "import", "loc": [7, 7], "level": 0, "parent": null, "vector": [1, 0, 0.0255, 0.0036, 0, 0.66, 0.2381, 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_98831:Assign_L9_C0", "label": "register = Library()", "type": "assigned_variable", "loc": [9, 9], "level": 0, "parent": null, "vector": [14, 0, 0.0328, 0.0036, 0, 0.66, 0.2857, 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_98831:ClassDef_L11_C0", "label": "GetAvailableLanguagesNode", "type": "class", "loc": [11, 18], "level": 0, "parent": null, "vector": [3, 0, 0.0529, 0.0292, 0, 0.66, 0.3333, 609, 0, 2, 0, 0, 345, 0, 1], "semantic": {"name": "GetAvailableLanguagesNode", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class GetAvailableLanguagesNode(Node):\n def __init__(self, variable):\n self.variable = variable\n\n def render(self, context):\n from django.conf import settings\n context[self.variable] = [(k, translation.ugettext(v)) for k, v in settings.LANGUAGES]\n return ''"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98831:FunctionDef_L12_C4", "label": "__init__", "type": "function", "loc": [12, 13], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98831:ClassDef_L11_C0", "vector": [2, 1, 0.0456, 0.0073, 1, 0.6, 0.0, 555, 0, 2, 0, 0, 0, 0, 0], "semantic": {"name": "__init__", "arg_names": ["self", "variable"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def __init__(self, variable):\n self.variable = variable"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98831:Assign_L13_C8", "label": "self.variable =", "type": "assigned_variable", "loc": [13, 13], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98831:FunctionDef_L12_C4", "vector": [14, 2, 0.0474, 0.0036, 2, 0.94, 0.0, 139, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "self.variable", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.variable = variable"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98831:FunctionDef_L15_C4", "label": "render", "type": "function", "loc": [15, 18], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98831:ClassDef_L11_C0", "vector": [2, 1, 0.0602, 0.0146, 1, 0.6, 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 from django.conf import settings\n context[self.variable] = [(k, translation.ugettext(v)) for k, v in settings.LANGUAGES]\n return ''"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98831:ImportFrom_L16_C8", "label": "from django.conf import settings", "type": "import", "loc": [16, 16], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98831:FunctionDef_L15_C4", "vector": [1, 2, 0.0584, 0.0036, 2, 0.3, 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_98831:Assign_L17_C8", "label": "assign", "type": "assigned_variable", "loc": [17, 17], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98831:FunctionDef_L15_C4", "vector": [14, 2, 0.062, 0.0036, 2, 0.3, 0.5, 0, 5, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " context[self.variable] = [(k, translation.ugettext(v)) for k, v in settings.LANGUAGES]"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98831:Return_L18_C8", "label": "return", "type": "return", "loc": [18, 18], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98831:FunctionDef_L15_C4", "vector": [13, 2, 0.0657, 0.0036, 2, 0.3, 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_98831:ClassDef_L20_C0", "label": "GetCurrentLanguageNode", "type": "class", "loc": [20, 26], "level": 0, "parent": null, "vector": [3, 0, 0.0839, 0.0255, 0, 0.66, 0.381, 84, 0, 2, 0, 0, 345, 0, 1], "semantic": {"name": "GetCurrentLanguageNode", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class GetCurrentLanguageNode(Node):\n def __init__(self, variable):\n self.variable = variable\n\n def render(self, context):\n context[self.variable] = translation.get_language()\n return ''"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98831:FunctionDef_L21_C4", "label": "__init__", "type": "function", "loc": [21, 22], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98831:ClassDef_L20_C0", "vector": [2, 1, 0.0785, 0.0073, 1, 0.81, 0.0, 555, 0, 2, 0, 0, 0, 0, 0], "semantic": {"name": "__init__", "arg_names": ["self", "variable"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def __init__(self, variable):\n self.variable = variable"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98831:Assign_L22_C8", "label": "self.variable =", "type": "assigned_variable", "loc": [22, 22], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98831:FunctionDef_L21_C4", "vector": [14, 2, 0.0803, 0.0036, 2, 0.99, 0.0, 139, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "self.variable", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.variable = variable"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98831:FunctionDef_L24_C4", "label": "render", "type": "function", "loc": [24, 26], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98831:ClassDef_L20_C0", "vector": [2, 1, 0.0912, 0.0109, 1, 0.81, 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.variable] = translation.get_language()\n return ''"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98831:Assign_L25_C8", "label": " = get_language()", "type": "assigned_variable", "loc": [25, 25], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98831:FunctionDef_L24_C4", "vector": [14, 2, 0.0912, 0.0036, 2, 0.26, 0.0, 0, 3, 0, 0, 0, 674, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "get_language", "annotation": ""}, "snippet": " context[self.variable] = translation.get_language()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98831:Return_L26_C8", "label": "return", "type": "return", "loc": [26, 26], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98831:FunctionDef_L24_C4", "vector": [13, 2, 0.0949, 0.0036, 2, 0.26, 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_98831:ClassDef_L28_C0", "label": "GetCurrentLanguageBidiNode", "type": "class", "loc": [28, 34], "level": 0, "parent": null, "vector": [3, 0, 0.1131, 0.0255, 0, 0.66, 0.4286, 835, 0, 2, 0, 0, 345, 0, 1], "semantic": {"name": "GetCurrentLanguageBidiNode", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class GetCurrentLanguageBidiNode(Node):\n def __init__(self, variable):\n self.variable = variable\n\n def render(self, context):\n context[self.variable] = translation.get_language_bidi()\n return ''"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98831:FunctionDef_L29_C4", "label": "__init__", "type": "function", "loc": [29, 30], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98831:ClassDef_L28_C0", "vector": [2, 1, 0.1077, 0.0073, 1, 0.42, 0.0, 555, 0, 2, 0, 0, 0, 0, 0], "semantic": {"name": "__init__", "arg_names": ["self", "variable"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def __init__(self, variable):\n self.variable = variable"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98831:Assign_L30_C8", "label": "self.variable =", "type": "assigned_variable", "loc": [30, 30], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98831:FunctionDef_L29_C4", "vector": [14, 2, 0.1095, 0.0036, 2, 0.32, 0.0, 139, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "self.variable", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.variable = variable"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98831:FunctionDef_L32_C4", "label": "render", "type": "function", "loc": [32, 34], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98831:ClassDef_L28_C0", "vector": [2, 1, 0.1204, 0.0109, 1, 0.42, 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.variable] = translation.get_language_bidi()\n return ''"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98831:Assign_L33_C8", "label": " = get_language_bidi()", "type": "assigned_variable", "loc": [33, 33], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98831:FunctionDef_L32_C4", "vector": [14, 2, 0.1204, 0.0036, 2, 0.08, 0.0, 0, 3, 0, 0, 0, 583, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "get_language_bidi", "annotation": ""}, "snippet": " context[self.variable] = translation.get_language_bidi()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98831:Return_L34_C8", "label": "return", "type": "return", "loc": [34, 34], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98831:FunctionDef_L32_C4", "vector": [13, 2, 0.1241, 0.0036, 2, 0.08, 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_98831:ClassDef_L36_C0", "label": "TranslateNode", "type": "class", "loc": [36, 46], "level": 0, "parent": null, "vector": [3, 0, 0.1496, 0.0401, 0, 0.66, 0.4762, 656, 0, 2, 0, 0, 345, 0, 4], "semantic": {"name": "TranslateNode", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class TranslateNode(Node):\n def __init__(self, filter_expression, noop):\n self.noop = noop\n self.filter_expression = filter_expression\n if isinstance(self.filter_expression.var, basestring):\n self.filter_expression.var = Variable(u\"'%s'\" % self.filter_expression.var)\n\n def render(self, context):"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98831:FunctionDef_L37_C4", "label": "__init__", "type": "function", "loc": [37, 41], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98831:ClassDef_L36_C0", "vector": [2, 1, 0.1423, 0.0182, 1, 0.21, 0.0, 555, 0, 3, 0, 0, 0, 0, 2], "semantic": {"name": "__init__", "arg_names": ["self", "filter_expression", "noop"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def __init__(self, filter_expression, noop):\n self.noop = noop\n self.filter_expression = filter_expression\n if isinstance(self.filter_expression.var, basestring):\n self.filter_expression.var = Variable(u\"'%s'\" % self.filter_expression.var)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98831:Assign_L38_C8", "label": "self.noop =", "type": "assigned_variable", "loc": [38, 38], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98831:FunctionDef_L37_C4", "vector": [14, 2, 0.1387, 0.0036, 2, 0.6, 0.0, 872, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "self.noop", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.noop = noop"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98831:Assign_L39_C8", "label": "self.filter_expression =", "type": "assigned_variable", "loc": [39, 39], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98831:FunctionDef_L37_C4", "vector": [14, 2, 0.1423, 0.0036, 2, 0.6, 0.5, 737, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "self.filter_expression", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.filter_expression = filter_expression"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98831:If_L40_C8", "label": "if", "type": "if", "loc": [40, 41], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98831:FunctionDef_L37_C4", "vector": [4, 2, 0.1478, 0.0073, 2, 0.6, 1.0, 0, 3, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if isinstance(self.filter_expression.var, basestring):\n self.filter_expression.var = Variable(u\"'%s'\" % self.filter_expression.var)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98831:Assign_L41_C12", "label": "self.filter_expression.var = Variable()", "type": "assigned_variable", "loc": [41, 41], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98831:If_L40_C8", "vector": [14, 3, 0.1496, 0.0036, 3, 0.86, 0.0, 494, 3, 1, 0, 0, 807, 10, 1], "semantic": {"name": "self.filter_expression.var", "arg_names": [], "import_names": [], "rhs_call_name": "Variable", "annotation": ""}, "snippet": " self.filter_expression.var = Variable(u\"'%s'\" % self.filter_expression.var)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98831:FunctionDef_L43_C4", "label": "render", "type": "function", "loc": [43, 46], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98831:ClassDef_L36_C0", "vector": [2, 1, 0.1624, 0.0146, 1, 0.21, 1.0, 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 self.filter_expression.var.translate = not self.noop\n output = self.filter_expression.resolve(context)\n return _render_value_in_context(output, context)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98831:Assign_L44_C8", "label": "self.filter_expression.var.translate =", "type": "assigned_variable", "loc": [44, 44], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98831:FunctionDef_L43_C4", "vector": [14, 2, 0.1606, 0.0036, 2, 0.87, 0.0, 888, 0, 0, 0, 0, 0, 0, 0], "semantic": {"name": "self.filter_expression.var.translate", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.filter_expression.var.translate = not self.noop"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98831:Assign_L45_C8", "label": "output = resolve()", "type": "assigned_variable", "loc": [45, 45], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98831:FunctionDef_L43_C4", "vector": [14, 2, 0.1642, 0.0036, 2, 0.87, 0.5, 886, 3, 1, 0, 0, 675, 10, 1], "semantic": {"name": "output", "arg_names": [], "import_names": [], "rhs_call_name": "resolve", "annotation": ""}, "snippet": " output = self.filter_expression.resolve(context)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98831:Return_L46_C8", "label": "return", "type": "return", "loc": [46, 46], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98831:FunctionDef_L43_C4", "vector": [13, 2, 0.1679, 0.0036, 2, 0.87, 1.0, 0, 3, 0, 0, 0, 0, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return _render_value_in_context(output, context)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98831:ClassDef_L48_C0", "label": "BlockTranslateNode", "type": "class", "loc": [48, 88], "level": 0, "parent": null, "vector": [3, 0, 0.2482, 0.1496, 0, 0.66, 0.5238, 898, 0, 3, 0, 0, 345, 0, 17], "semantic": {"name": "BlockTranslateNode", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class BlockTranslateNode(Node):\n def __init__(self, extra_context, singular, plural=None, countervar=None,\n counter=None):\n self.extra_context = extra_context\n self.singular = singular\n self.plural = plural\n self.countervar = countervar\n self.counter = counter"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98831:FunctionDef_L49_C4", "label": "__init__", "type": "function", "loc": [49, 55], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98831:ClassDef_L48_C0", "vector": [2, 1, 0.1898, 0.0255, 1, 0.07, 0.0, 555, 0, 6, 0, 0, 0, 0, 0], "semantic": {"name": "__init__", "arg_names": ["self", "extra_context", "singular", "plural", "countervar", "counter"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def __init__(self, extra_context, singular, plural=None, countervar=None,\n counter=None):\n self.extra_context = extra_context\n self.singular = singular\n self.plural = plural\n self.countervar = countervar\n self.counter = counter"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98831:Assign_L51_C8", "label": "self.extra_context =", "type": "assigned_variable", "loc": [51, 51], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98831:FunctionDef_L49_C4", "vector": [14, 2, 0.1861, 0.0036, 2, 0.2, 0.0, 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_98831:Assign_L52_C8", "label": "self.singular =", "type": "assigned_variable", "loc": [52, 52], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98831:FunctionDef_L49_C4", "vector": [14, 2, 0.1898, 0.0036, 2, 0.2, 0.25, 772, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "self.singular", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.singular = singular"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98831:Assign_L53_C8", "label": "self.plural =", "type": "assigned_variable", "loc": [53, 53], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98831:FunctionDef_L49_C4", "vector": [14, 2, 0.1934, 0.0036, 2, 0.2, 0.5, 988, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "self.plural", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.plural = plural"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98831:Assign_L54_C8", "label": "self.countervar =", "type": "assigned_variable", "loc": [54, 54], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98831:FunctionDef_L49_C4", "vector": [14, 2, 0.1971, 0.0036, 2, 0.2, 0.75, 286, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "self.countervar", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.countervar = countervar"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98831:Assign_L55_C8", "label": "self.counter =", "type": "assigned_variable", "loc": [55, 55], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98831:FunctionDef_L49_C4", "vector": [14, 2, 0.2007, 0.0036, 2, 0.2, 1.0, 785, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "self.counter", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.counter = counter"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98831:FunctionDef_L57_C4", "label": "render_token_list", "type": "function", "loc": [57, 66], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98831:ClassDef_L48_C0", "vector": [2, 1, 0.2245, 0.0365, 1, 0.07, 0.5, 250, 0, 2, 1, 0, 0, 0, 4], "semantic": {"name": "render_token_list", "arg_names": ["self", "tokens"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def render_token_list(self, tokens):\n result = []\n vars = []\n for token in tokens:\n if token.token_type == TOKEN_TEXT:\n result.append(token.contents)\n elif token.token_type == TOKEN_VAR:\n result.append(u'%%(%s)s' % token.contents)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98831:Assign_L58_C8", "label": "result =", "type": "assigned_variable", "loc": [58, 58], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98831:FunctionDef_L57_C4", "vector": [14, 2, 0.2117, 0.0036, 2, 0.56, 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_98831:Assign_L59_C8", "label": "vars =", "type": "assigned_variable", "loc": [59, 59], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98831:FunctionDef_L57_C4", "vector": [14, 2, 0.2153, 0.0036, 2, 0.56, 0.3333, 302, 0, 0, 0, 0, 0, 5, 0], "semantic": {"name": "vars", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " vars = []"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98831:For_L60_C8", "label": "for token", "type": "for", "loc": [60, 65], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98831:FunctionDef_L57_C4", "vector": [6, 2, 0.2281, 0.0219, 2, 0.56, 0.6667, 129, 2, 0, 0, 0, 0, 0, 3], "semantic": {"name": "token", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for token in tokens:\n if token.token_type == TOKEN_TEXT:\n result.append(token.contents)\n elif token.token_type == TOKEN_VAR:\n result.append(u'%%(%s)s' % token.contents)\n vars.append(token.contents)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98831:If_L61_C12", "label": "if", "type": "if", "loc": [61, 65], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98831:For_L60_C8", "vector": [4, 3, 0.2299, 0.0182, 3, 0.18, 0.0, 0, 0, 0, 0, 0, 0, 0, 3], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if token.token_type == TOKEN_TEXT:\n result.append(token.contents)\n elif token.token_type == TOKEN_VAR:\n result.append(u'%%(%s)s' % token.contents)\n vars.append(token.contents)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98831:Expr_L62_C16", "label": "append()", "type": "expression", "loc": [62, 62], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98831:If_L61_C12", "vector": [8, 4, 0.2263, 0.0036, 4, 0.99, 0.0, 243, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "append", "arg_names": [], "import_names": [], "rhs_call_name": "append", "annotation": ""}, "snippet": " result.append(token.contents)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98831:If_L63_C12", "label": "if", "type": "if", "loc": [63, 65], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98831:If_L61_C12", "vector": [4, 4, 0.2336, 0.0109, 4, 0.99, 1.0, 0, 0, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " elif token.token_type == TOKEN_VAR:\n result.append(u'%%(%s)s' % token.contents)\n vars.append(token.contents)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98831:Expr_L64_C16", "label": "append()", "type": "expression", "loc": [64, 64], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98831:If_L63_C12", "vector": [8, 5, 0.2336, 0.0036, 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": " result.append(u'%%(%s)s' % token.contents)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98831:Expr_L65_C16", "label": "append()", "type": "expression", "loc": [65, 65], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98831:If_L63_C12", "vector": [8, 5, 0.2372, 0.0036, 5, 0.9, 1.0, 243, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "append", "arg_names": [], "import_names": [], "rhs_call_name": "append", "annotation": ""}, "snippet": " vars.append(token.contents)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98831:Return_L66_C8", "label": "return", "type": "return", "loc": [66, 66], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98831:FunctionDef_L57_C4", "vector": [13, 2, 0.2409, 0.0036, 2, 0.56, 1.0, 0, 0, 0, 0, 0, 0, 8, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return ''.join(result), vars"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98831:FunctionDef_L68_C4", "label": "render", "type": "function", "loc": [68, 88], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98831:ClassDef_L48_C0", "vector": [2, 1, 0.2847, 0.0766, 1, 0.07, 1.0, 24, 0, 2, 1, 0, 0, 0, 13], "semantic": {"name": "render", "arg_names": ["self", "context"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def render(self, context):\n tmp_context = {}\n for var, val in self.extra_context.items():\n tmp_context[var] = val.render(context)\n # Update() works like a push(), so corresponding context.pop() is at\n # the end of function\n context.update(tmp_context)\n singular, vars = self.render_token_list(self.singular)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98831:Assign_L69_C8", "label": "tmp_context =", "type": "assigned_variable", "loc": [69, 69], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98831:FunctionDef_L68_C4", "vector": [14, 2, 0.2518, 0.0036, 2, 0.02, 0.0, 161, 0, 0, 0, 0, 0, 6, 0], "semantic": {"name": "tmp_context", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " tmp_context = {}"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98831:For_L70_C8", "label": "for var, val", "type": "for", "loc": [70, 71], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98831:FunctionDef_L68_C4", "vector": [6, 2, 0.2573, 0.0073, 2, 0.02, 0.125, 490, 3, 0, 0, 0, 0, 0, 2], "semantic": {"name": "var, val", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for var, val in self.extra_context.items():\n tmp_context[var] = val.render(context)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98831:Assign_L71_C12", "label": " = render()", "type": "assigned_variable", "loc": [71, 71], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98831:For_L70_C8", "vector": [14, 3, 0.2591, 0.0036, 3, 0.25, 0.0, 0, 3, 1, 0, 0, 24, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "render", "annotation": ""}, "snippet": " tmp_context[var] = val.render(context)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98831:Expr_L74_C8", "label": "update()", "type": "expression", "loc": [74, 74], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98831:FunctionDef_L68_C4", "vector": [8, 2, 0.2701, 0.0036, 2, 0.02, 0.25, 637, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "update", "arg_names": [], "import_names": [], "rhs_call_name": "update", "annotation": ""}, "snippet": " context.update(tmp_context)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98831:Assign_L75_C8", "label": "singular, vars = render_token_list()", "type": "assigned_variable", "loc": [75, 75], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98831:FunctionDef_L68_C4", "vector": [14, 2, 0.2737, 0.0036, 2, 0.02, 0.375, 200, 3, 1, 0, 0, 250, 10, 1], "semantic": {"name": "singular, vars", "arg_names": [], "import_names": [], "rhs_call_name": "render_token_list", "annotation": ""}, "snippet": " singular, vars = self.render_token_list(self.singular)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98831:If_L76_C8", "label": "if", "type": "if", "loc": [76, 83], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98831:FunctionDef_L68_C4", "vector": [4, 2, 0.2901, 0.0292, 2, 0.02, 0.5, 0, 0, 0, 0, 0, 0, 0, 5], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if self.plural and self.countervar and self.counter:\n count = self.counter.resolve(context)\n context[self.countervar] = count\n plural, plural_vars = self.render_token_list(self.plural)\n result = translation.ungettext(singular, plural, count)\n vars.extend(plural_vars)\n else:\n result = translation.ugettext(singular)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98831:Assign_L77_C12", "label": "count = resolve()", "type": "assigned_variable", "loc": [77, 77], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98831:If_L76_C8", "vector": [14, 3, 0.281, 0.0036, 3, 0.29, 0.0, 778, 3, 1, 0, 0, 675, 10, 1], "semantic": {"name": "count", "arg_names": [], "import_names": [], "rhs_call_name": "resolve", "annotation": ""}, "snippet": " count = self.counter.resolve(context)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98831:Assign_L78_C12", "label": "assign", "type": "assigned_variable", "loc": [78, 78], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98831:If_L76_C8", "vector": [14, 3, 0.2847, 0.0036, 3, 0.29, 0.2, 0, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " context[self.countervar] = count"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98831:Assign_L79_C12", "label": "plural, plural_vars = render_token_list()", "type": "assigned_variable", "loc": [79, 79], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98831:If_L76_C8", "vector": [14, 3, 0.2883, 0.0036, 3, 0.29, 0.4, 536, 3, 1, 0, 0, 250, 10, 1], "semantic": {"name": "plural, plural_vars", "arg_names": [], "import_names": [], "rhs_call_name": "render_token_list", "annotation": ""}, "snippet": " plural, plural_vars = self.render_token_list(self.plural)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98831:Assign_L80_C12", "label": "result = ungettext()", "type": "assigned_variable", "loc": [80, 80], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98831:If_L76_C8", "vector": [14, 3, 0.292, 0.0036, 3, 0.29, 0.6, 51, 3, 3, 0, 0, 950, 10, 1], "semantic": {"name": "result", "arg_names": [], "import_names": [], "rhs_call_name": "ungettext", "annotation": ""}, "snippet": " result = translation.ungettext(singular, plural, count)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98831:Expr_L81_C12", "label": "extend()", "type": "expression", "loc": [81, 81], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98831:If_L76_C8", "vector": [8, 3, 0.2956, 0.0036, 3, 0.29, 0.8, 660, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "extend", "arg_names": [], "import_names": [], "rhs_call_name": "extend", "annotation": ""}, "snippet": " vars.extend(plural_vars)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98831:Assign_L83_C12", "label": "result = ugettext()", "type": "assigned_variable", "loc": [83, 83], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98831:If_L76_C8", "vector": [14, 3, 0.3029, 0.0036, 3, 0.29, 1.0, 51, 3, 1, 0, 0, 461, 10, 1], "semantic": {"name": "result", "arg_names": [], "import_names": [], "rhs_call_name": "ugettext", "annotation": ""}, "snippet": " result = translation.ugettext(singular)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98831:Assign_L85_C8", "label": "result = sub()", "type": "assigned_variable", "loc": [85, 85], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98831:FunctionDef_L68_C4", "vector": [14, 2, 0.3102, 0.0036, 2, 0.02, 0.625, 51, 3, 3, 0, 0, 819, 10, 1], "semantic": {"name": "result", "arg_names": [], "import_names": [], "rhs_call_name": "sub", "annotation": ""}, "snippet": " result = re.sub(u'%(?!\\()', u'%%', result)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98831:Assign_L86_C8", "label": "data = dict()", "type": "assigned_variable", "loc": [86, 86], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98831:FunctionDef_L68_C4", "vector": [14, 2, 0.3139, 0.0036, 2, 0.02, 0.75, 929, 3, 1, 0, 0, 827, 10, 2], "semantic": {"name": "data", "arg_names": [], "import_names": [], "rhs_call_name": "dict", "annotation": ""}, "snippet": " data = dict([(v, _render_value_in_context(context[v], context)) for v in vars])"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98831:Expr_L87_C8", "label": "pop()", "type": "expression", "loc": [87, 87], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98831:FunctionDef_L68_C4", "vector": [8, 2, 0.3175, 0.0036, 2, 0.02, 0.875, 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_98831:Return_L88_C8", "label": "return", "type": "return", "loc": [88, 88], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98831:FunctionDef_L68_C4", "vector": [13, 2, 0.3212, 0.0036, 2, 0.02, 1.0, 0, 4, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return result % data"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98831:FunctionDef_L90_C0", "label": "do_get_available_languages", "type": "function", "loc": [90, 109], "level": 0, "parent": null, "vector": [2, 0, 0.3631, 0.073, 0, 0.66, 0.5714, 949, 0, 2, 1, 0, 0, 0, 4], "semantic": {"name": "do_get_available_languages", "arg_names": ["parser", "token"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "def do_get_available_languages(parser, token):\n \"\"\"\n This will store a list of available languages\n in the context.\n\n Usage::\n\n {% get_available_languages as languages %}"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98831:Expr_L91_C4", "label": "expression", "type": "expression", "loc": [91, 105], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98831:FunctionDef_L90_C0", "vector": [8, 1, 0.3577, 0.0547, 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 This will store a list of available languages\n in the context.\n\n Usage::\n\n {% get_available_languages as languages %}\n {% for language in languages %}"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98831:Assign_L106_C4", "label": "args = split()", "type": "assigned_variable", "loc": [106, 106], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98831:FunctionDef_L90_C0", "vector": [14, 1, 0.3869, 0.0036, 1, 0.3, 0.3333, 805, 3, 0, 0, 0, 908, 10, 1], "semantic": {"name": "args", "arg_names": [], "import_names": [], "rhs_call_name": "split", "annotation": ""}, "snippet": " args = token.contents.split()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98831:If_L107_C4", "label": "if", "type": "if", "loc": [107, 108], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98831:FunctionDef_L90_C0", "vector": [4, 1, 0.3923, 0.0073, 1, 0.3, 0.6667, 0, 0, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if len(args) != 3 or args[1] != 'as':\n raise TemplateSyntaxError(\"'get_available_languages' requires 'as variable' (got %r)\" % args)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98831:Return_L109_C4", "label": "return", "type": "return", "loc": [109, 109], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98831:FunctionDef_L90_C0", "vector": [13, 1, 0.3978, 0.0036, 1, 0.3, 1.0, 0, 3, 0, 0, 0, 0, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return GetAvailableLanguagesNode(args[2])"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98831:FunctionDef_L111_C0", "label": "do_get_current_language", "type": "function", "loc": [111, 126], "level": 0, "parent": null, "vector": [2, 0, 0.4325, 0.0584, 0, 0.66, 0.619, 254, 0, 2, 1, 0, 0, 0, 4], "semantic": {"name": "do_get_current_language", "arg_names": ["parser", "token"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "def do_get_current_language(parser, token):\n \"\"\"\n This will store the current language in the context.\n\n Usage::\n\n {% get_current_language as language %}\n"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98831:Expr_L112_C4", "label": "expression", "type": "expression", "loc": [112, 122], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98831:FunctionDef_L111_C0", "vector": [8, 1, 0.427, 0.0401, 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 This will store the current language in the context.\n\n Usage::\n\n {% get_current_language as language %}\n\n This will fetch the currently active language and"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98831:Assign_L123_C4", "label": "args = split()", "type": "assigned_variable", "loc": [123, 123], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98831:FunctionDef_L111_C0", "vector": [14, 1, 0.4489, 0.0036, 1, 0.88, 0.3333, 805, 3, 0, 0, 0, 908, 10, 1], "semantic": {"name": "args", "arg_names": [], "import_names": [], "rhs_call_name": "split", "annotation": ""}, "snippet": " args = token.contents.split()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98831:If_L124_C4", "label": "if", "type": "if", "loc": [124, 125], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98831:FunctionDef_L111_C0", "vector": [4, 1, 0.4544, 0.0073, 1, 0.88, 0.6667, 0, 0, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if len(args) != 3 or args[1] != 'as':\n raise TemplateSyntaxError(\"'get_current_language' requires 'as variable' (got %r)\" % args)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98831:Return_L126_C4", "label": "return", "type": "return", "loc": [126, 126], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98831:FunctionDef_L111_C0", "vector": [13, 1, 0.4599, 0.0036, 1, 0.88, 1.0, 0, 3, 0, 0, 0, 0, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return GetCurrentLanguageNode(args[2])"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98831:FunctionDef_L128_C0", "label": "do_get_current_language_bidi", "type": "function", "loc": [128, 143], "level": 0, "parent": null, "vector": [2, 0, 0.4945, 0.0584, 0, 0.66, 0.6667, 284, 0, 2, 1, 0, 0, 0, 4], "semantic": {"name": "do_get_current_language_bidi", "arg_names": ["parser", "token"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "def do_get_current_language_bidi(parser, token):\n \"\"\"\n This will store the current language layout in the context.\n\n Usage::\n\n {% get_current_language_bidi as bidi %}\n"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98831:Expr_L129_C4", "label": "expression", "type": "expression", "loc": [129, 139], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98831:FunctionDef_L128_C0", "vector": [8, 1, 0.4891, 0.0401, 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 This will store the current language layout in the context.\n\n Usage::\n\n {% get_current_language_bidi as bidi %}\n\n This will fetch the currently active language's layout and"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98831:Assign_L140_C4", "label": "args = split()", "type": "assigned_variable", "loc": [140, 140], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98831:FunctionDef_L128_C0", "vector": [14, 1, 0.5109, 0.0036, 1, 0.61, 0.3333, 805, 3, 0, 0, 0, 908, 10, 1], "semantic": {"name": "args", "arg_names": [], "import_names": [], "rhs_call_name": "split", "annotation": ""}, "snippet": " args = token.contents.split()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98831:If_L141_C4", "label": "if", "type": "if", "loc": [141, 142], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98831:FunctionDef_L128_C0", "vector": [4, 1, 0.5164, 0.0073, 1, 0.61, 0.6667, 0, 0, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if len(args) != 3 or args[1] != 'as':\n raise TemplateSyntaxError(\"'get_current_language_bidi' requires 'as variable' (got %r)\" % args)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98831:Return_L143_C4", "label": "return", "type": "return", "loc": [143, 143], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98831:FunctionDef_L128_C0", "vector": [13, 1, 0.5219, 0.0036, 1, 0.61, 1.0, 0, 3, 0, 0, 0, 0, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return GetCurrentLanguageBidiNode(args[2])"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98831:FunctionDef_L145_C0", "label": "do_translate", "type": "function", "loc": [145, 201], "level": 0, "parent": null, "vector": [2, 0, 0.6314, 0.208, 0, 0.66, 0.7143, 10, 0, 2, 1, 0, 0, 0, 13], "semantic": {"name": "do_translate", "arg_names": ["parser", "token"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "def do_translate(parser, token):\n \"\"\"\n This will mark a string for translation and will\n translate the string for the current language.\n\n Usage::\n\n {% trans \"this is a test\" %}"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98831:Expr_L146_C4", "label": "expression", "type": "expression", "loc": [146, 174], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98831:FunctionDef_L145_C0", "vector": [8, 1, 0.5839, 0.1058, 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 This will mark a string for translation and will\n translate the string for the current language.\n\n Usage::\n\n {% trans \"this is a test\" %}\n"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98831:ClassDef_L175_C4", "label": "TranslateParser", "type": "class", "loc": [175, 199], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98831:FunctionDef_L145_C0", "vector": [3, 1, 0.6825, 0.0912, 1, 0.05, 0.3333, 893, 0, 1, 0, 0, 139, 0, 9], "semantic": {"name": "TranslateParser", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " class TranslateParser(TokenParser):\n def top(self):\n value = self.value()\n\n # Backwards Compatiblity fix:\n # FilterExpression does not support single-quoted strings,\n # so we make a cheap localized fix in order to maintain\n # backwards compatibility with existing uses of ``trans``"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98831:FunctionDef_L176_C8", "label": "top", "type": "function", "loc": [176, 199], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98831:ClassDef_L175_C4", "vector": [2, 2, 0.6843, 0.0876, 2, 0.39, 0.0, 208, 0, 1, 1, 0, 0, 0, 9], "semantic": {"name": "top", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def top(self):\n value = self.value()\n\n # Backwards Compatiblity fix:\n # FilterExpression does not support single-quoted strings,\n # so we make a cheap localized fix in order to maintain\n # backwards compatibility with existing uses of ``trans``\n # where single quote use is supported."}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98831:Assign_L177_C12", "label": "value = value()", "type": "assigned_variable", "loc": [177, 177], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98831:FunctionDef_L176_C8", "vector": [14, 3, 0.646, 0.0036, 3, 0.8, 0.0, 441, 3, 0, 0, 0, 441, 10, 1], "semantic": {"name": "value", "arg_names": [], "import_names": [], "rhs_call_name": "value", "annotation": ""}, "snippet": " value = self.value()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98831:If_L184_C12", "label": "if", "type": "if", "loc": [184, 190], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98831:FunctionDef_L176_C8", "vector": [4, 3, 0.6825, 0.0255, 3, 0.8, 0.3333, 0, 0, 0, 0, 0, 0, 0, 5], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if value[0] == \"'\":\n pos = None\n m = re.match(\"^'([^']+)'(\\|.*$)\",value)\n if m:\n value = '\"%s\"%s' % (m.group(1).replace('\"','\\\\\"'),m.group(2))\n elif value[-1] == \"'\":\n value = '\"%s\"' % value[1:-1].replace('\"','\\\\\"')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98831:Assign_L185_C16", "label": "pos =", "type": "assigned_variable", "loc": [185, 185], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98831:If_L184_C12", "vector": [14, 4, 0.6752, 0.0036, 4, 0.8, 0.0, 627, 1, 0, 0, 0, 0, 9, 0], "semantic": {"name": "pos", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " pos = None"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98831:Assign_L186_C16", "label": "m = match()", "type": "assigned_variable", "loc": [186, 186], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98831:If_L184_C12", "vector": [14, 4, 0.6788, 0.0036, 4, 0.8, 0.5, 711, 3, 2, 0, 0, 36, 10, 1], "semantic": {"name": "m", "arg_names": [], "import_names": [], "rhs_call_name": "match", "annotation": ""}, "snippet": " m = re.match(\"^'([^']+)'(\\|.*$)\",value)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98831:If_L187_C16", "label": "if", "type": "if", "loc": [187, 190], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98831:If_L184_C12", "vector": [4, 4, 0.688, 0.0146, 4, 0.8, 1.0, 0, 2, 0, 0, 0, 0, 0, 4], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if m:\n value = '\"%s\"%s' % (m.group(1).replace('\"','\\\\\"'),m.group(2))\n elif value[-1] == \"'\":\n value = '\"%s\"' % value[1:-1].replace('\"','\\\\\"')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98831:Assign_L188_C20", "label": "value =", "type": "assigned_variable", "loc": [188, 188], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98831:If_L187_C16", "vector": [14, 5, 0.6861, 0.0036, 5, 0.79, 0.0, 441, 4, 0, 0, 0, 0, 0, 3], "semantic": {"name": "value", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " value = '\"%s\"%s' % (m.group(1).replace('\"','\\\\\"'),m.group(2))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98831:If_L189_C16", "label": "if", "type": "if", "loc": [189, 190], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98831:If_L187_C16", "vector": [4, 5, 0.6916, 0.0073, 5, 0.79, 1.0, 0, 0, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " elif value[-1] == \"'\":\n value = '\"%s\"' % value[1:-1].replace('\"','\\\\\"')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98831:Assign_L190_C20", "label": "value =", "type": "assigned_variable", "loc": [190, 190], "level": 6, "parent": "ajibawa-2023/Python-Code-Large/train/row_98831:If_L189_C16", "vector": [14, 6, 0.6934, 0.0036, 6, 0.41, 0.0, 441, 4, 0, 0, 0, 0, 0, 1], "semantic": {"name": "value", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " value = '\"%s\"' % value[1:-1].replace('\"','\\\\\"')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98831:If_L192_C12", "label": "if", "type": "if", "loc": [192, 198], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98831:FunctionDef_L176_C8", "vector": [4, 3, 0.7117, 0.0255, 3, 0.8, 0.6667, 0, 3, 0, 0, 0, 0, 0, 3], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if self.more():\n if self.tag() == 'noop':\n noop = True\n else:\n raise TemplateSyntaxError(\"only option for 'trans' is 'noop'\")\n else:\n noop = False"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98831:If_L193_C16", "label": "if", "type": "if", "loc": [193, 196], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98831:If_L192_C12", "vector": [4, 4, 0.7099, 0.0146, 4, 0.2, 0.0, 0, 0, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if self.tag() == 'noop':\n noop = True\n else:\n raise TemplateSyntaxError(\"only option for 'trans' is 'noop'\")"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98831:Assign_L194_C20", "label": "noop =", "type": "assigned_variable", "loc": [194, 194], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98831:If_L193_C16", "vector": [14, 5, 0.708, 0.0036, 5, 0.35, 0.0, 907, 1, 0, 0, 0, 0, 4, 0], "semantic": {"name": "noop", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " noop = True"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98831:Assign_L198_C16", "label": "noop =", "type": "assigned_variable", "loc": [198, 198], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98831:If_L192_C12", "vector": [14, 4, 0.7226, 0.0036, 4, 0.2, 1.0, 907, 1, 0, 0, 0, 0, 4, 0], "semantic": {"name": "noop", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " noop = False"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98831:Return_L199_C12", "label": "return", "type": "return", "loc": [199, 199], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98831:FunctionDef_L176_C8", "vector": [13, 3, 0.7263, 0.0036, 3, 0.8, 1.0, 0, 0, 0, 0, 0, 0, 8, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return (value, noop)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98831:Assign_L200_C4", "label": "value, noop = top()", "type": "assigned_variable", "loc": [200, 200], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98831:FunctionDef_L145_C0", "vector": [14, 1, 0.7299, 0.0036, 1, 0.05, 0.6667, 419, 3, 0, 0, 0, 208, 10, 2], "semantic": {"name": "value, noop", "arg_names": [], "import_names": [], "rhs_call_name": "top", "annotation": ""}, "snippet": " value, noop = TranslateParser(token.contents).top()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98831:Return_L201_C4", "label": "return", "type": "return", "loc": [201, 201], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98831:FunctionDef_L145_C0", "vector": [13, 1, 0.7336, 0.0036, 1, 0.05, 1.0, 0, 3, 0, 0, 0, 0, 10, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return TranslateNode(parser.compile_filter(value), noop)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98831:FunctionDef_L203_C0", "label": "do_block_translate", "type": "function", "loc": [203, 268], "level": 0, "parent": null, "vector": [2, 0, 0.8595, 0.2409, 0, 0.66, 0.7619, 337, 0, 2, 1, 0, 0, 0, 25], "semantic": {"name": "do_block_translate", "arg_names": ["parser", "token"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "def do_block_translate(parser, token):\n \"\"\"\n This will translate a block of text with parameters.\n\n Usage::\n\n {% blocktrans with foo|filter as bar and baz|filter as boo %}\n This is {{ bar }} and {{ boo }}."}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98831:Expr_L204_C4", "label": "expression", "type": "expression", "loc": [204, 222], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98831:FunctionDef_L203_C0", "vector": [8, 1, 0.7774, 0.0693, 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 This will translate a block of text with parameters.\n\n Usage::\n\n {% blocktrans with foo|filter as bar and baz|filter as boo %}\n This is {{ bar }} and {{ boo }}.\n {% endblocktrans %}"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98831:ClassDef_L223_C4", "label": "BlockTranslateParser", "type": "class", "loc": [223, 243], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98831:FunctionDef_L203_C0", "vector": [3, 1, 0.8504, 0.0766, 1, 0.3, 0.125, 639, 0, 1, 0, 0, 139, 0, 14], "semantic": {"name": "BlockTranslateParser", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " class BlockTranslateParser(TokenParser):\n def top(self):\n countervar = None\n counter = None\n extra_context = {}\n while self.more():\n tag = self.tag()\n if tag == 'with' or tag == 'and':"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98831:FunctionDef_L224_C8", "label": "top", "type": "function", "loc": [224, 243], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98831:ClassDef_L223_C4", "vector": [2, 2, 0.8522, 0.073, 2, 0.66, 0.0, 208, 0, 1, 1, 0, 0, 0, 14], "semantic": {"name": "top", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def top(self):\n countervar = None\n counter = None\n extra_context = {}\n while self.more():\n tag = self.tag()\n if tag == 'with' or tag == 'and':\n value = self.value()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98831:Assign_L225_C12", "label": "countervar =", "type": "assigned_variable", "loc": [225, 225], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98831:FunctionDef_L224_C8", "vector": [14, 3, 0.8212, 0.0036, 3, 0.8, 0.0, 977, 1, 0, 0, 0, 0, 9, 0], "semantic": {"name": "countervar", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " countervar = None"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98831:Assign_L226_C12", "label": "counter =", "type": "assigned_variable", "loc": [226, 226], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98831:FunctionDef_L224_C8", "vector": [14, 3, 0.8248, 0.0036, 3, 0.8, 0.25, 7, 1, 0, 0, 0, 0, 9, 0], "semantic": {"name": "counter", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " counter = None"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98831:Assign_L227_C12", "label": "extra_context =", "type": "assigned_variable", "loc": [227, 227], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98831:FunctionDef_L224_C8", "vector": [14, 3, 0.8285, 0.0036, 3, 0.8, 0.5, 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_98831:While_L228_C12", "label": "while", "type": "while", "loc": [228, 242], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98831:FunctionDef_L224_C8", "vector": [5, 3, 0.8577, 0.0547, 3, 0.8, 0.75, 0, 3, 0, 0, 0, 0, 0, 14], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " while self.more():\n tag = self.tag()\n if tag == 'with' or tag == 'and':\n value = self.value()\n if self.tag() != 'as':\n raise TemplateSyntaxError(\"variable bindings in 'blocktrans' must be 'with value as variable'\")\n extra_context[self.tag()] = VariableNode(\n parser.compile_filter(value))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98831:Assign_L229_C16", "label": "tag = tag()", "type": "assigned_variable", "loc": [229, 229], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98831:While_L228_C12", "vector": [14, 4, 0.8358, 0.0036, 4, 0.06, 0.0, 732, 3, 0, 0, 0, 732, 10, 1], "semantic": {"name": "tag", "arg_names": [], "import_names": [], "rhs_call_name": "tag", "annotation": ""}, "snippet": " tag = self.tag()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98831:If_L230_C16", "label": "if", "type": "if", "loc": [230, 242], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98831:While_L228_C12", "vector": [4, 4, 0.8613, 0.0474, 4, 0.06, 1.0, 0, 0, 0, 0, 0, 0, 0, 12], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if tag == 'with' or tag == 'and':\n value = self.value()\n if self.tag() != 'as':\n raise TemplateSyntaxError(\"variable bindings in 'blocktrans' must be 'with value as variable'\")\n extra_context[self.tag()] = VariableNode(\n parser.compile_filter(value))\n elif tag == 'count':\n counter = parser.compile_filter(self.value())"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98831:Assign_L231_C20", "label": "value = value()", "type": "assigned_variable", "loc": [231, 231], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98831:If_L230_C16", "vector": [14, 5, 0.8431, 0.0036, 5, 0.7, 0.0, 441, 3, 0, 0, 0, 441, 10, 1], "semantic": {"name": "value", "arg_names": [], "import_names": [], "rhs_call_name": "value", "annotation": ""}, "snippet": " value = self.value()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98831:If_L232_C20", "label": "if", "type": "if", "loc": [232, 233], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98831:If_L230_C16", "vector": [4, 5, 0.8485, 0.0073, 5, 0.7, 0.3333, 0, 0, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if self.tag() != 'as':\n raise TemplateSyntaxError(\"variable bindings in 'blocktrans' must be 'with value as variable'\")"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98831:Assign_L234_C20", "label": " = VariableNode()", "type": "assigned_variable", "loc": [234, 235], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98831:If_L230_C16", "vector": [14, 5, 0.8558, 0.0073, 5, 0.7, 0.6667, 0, 3, 1, 0, 0, 363, 10, 3], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "VariableNode", "annotation": ""}, "snippet": " extra_context[self.tag()] = VariableNode(\n parser.compile_filter(value))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98831:If_L236_C16", "label": "if", "type": "if", "loc": [236, 242], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98831:If_L230_C16", "vector": [4, 5, 0.8723, 0.0255, 5, 0.7, 1.0, 0, 0, 0, 0, 0, 0, 0, 6], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " elif tag == 'count':\n counter = parser.compile_filter(self.value())\n if self.tag() != 'as':\n raise TemplateSyntaxError(\"counter specification in 'blocktrans' must be 'count value as variable'\")\n countervar = self.tag()\n else:\n raise TemplateSyntaxError(\"unknown subtag %s for 'blocktrans' found\" % tag)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98831:Assign_L237_C20", "label": "counter = compile_filter()", "type": "assigned_variable", "loc": [237, 237], "level": 6, "parent": "ajibawa-2023/Python-Code-Large/train/row_98831:If_L236_C16", "vector": [14, 6, 0.865, 0.0036, 6, 0.91, 0.0, 7, 3, 1, 0, 0, 511, 10, 2], "semantic": {"name": "counter", "arg_names": [], "import_names": [], "rhs_call_name": "compile_filter", "annotation": ""}, "snippet": " counter = parser.compile_filter(self.value())"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98831:If_L238_C20", "label": "if", "type": "if", "loc": [238, 239], "level": 6, "parent": "ajibawa-2023/Python-Code-Large/train/row_98831:If_L236_C16", "vector": [4, 6, 0.8704, 0.0073, 6, 0.91, 0.5, 0, 0, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if self.tag() != 'as':\n raise TemplateSyntaxError(\"counter specification in 'blocktrans' must be 'count value as variable'\")"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98831:Assign_L240_C20", "label": "countervar = tag()", "type": "assigned_variable", "loc": [240, 240], "level": 6, "parent": "ajibawa-2023/Python-Code-Large/train/row_98831:If_L236_C16", "vector": [14, 6, 0.8759, 0.0036, 6, 0.91, 1.0, 977, 3, 0, 0, 0, 732, 10, 1], "semantic": {"name": "countervar", "arg_names": [], "import_names": [], "rhs_call_name": "tag", "annotation": ""}, "snippet": " countervar = self.tag()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98831:Return_L243_C12", "label": "return", "type": "return", "loc": [243, 243], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98831:FunctionDef_L224_C8", "vector": [13, 3, 0.8869, 0.0036, 3, 0.8, 1.0, 0, 0, 0, 0, 0, 0, 8, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return (countervar, counter, extra_context)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98831:Assign_L245_C4", "label": "countervar, counter, extra_context = top()", "type": "assigned_variable", "loc": [245, 245], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98831:FunctionDef_L203_C0", "vector": [14, 1, 0.8942, 0.0036, 1, 0.3, 0.25, 158, 3, 0, 0, 0, 208, 10, 2], "semantic": {"name": "countervar, counter, extra_context", "arg_names": [], "import_names": [], "rhs_call_name": "top", "annotation": ""}, "snippet": " countervar, counter, extra_context = BlockTranslateParser(token.contents).top()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98831:Assign_L247_C4", "label": "singular =", "type": "assigned_variable", "loc": [247, 247], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98831:FunctionDef_L203_C0", "vector": [14, 1, 0.9015, 0.0036, 1, 0.3, 0.375, 85, 0, 0, 0, 0, 0, 5, 0], "semantic": {"name": "singular", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " singular = []"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98831:Assign_L248_C4", "label": "plural =", "type": "assigned_variable", "loc": [248, 248], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98831:FunctionDef_L203_C0", "vector": [14, 1, 0.9051, 0.0036, 1, 0.3, 0.5, 235, 0, 0, 0, 0, 0, 5, 0], "semantic": {"name": "plural", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " plural = []"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98831:While_L249_C4", "label": "while", "type": "while", "loc": [249, 254], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98831:FunctionDef_L203_C0", "vector": [5, 1, 0.9179, 0.0219, 1, 0.3, 0.625, 0, 7, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " while parser.tokens:\n token = parser.next_token()\n if token.token_type in (TOKEN_VAR, TOKEN_TEXT):\n singular.append(token)\n else:\n break"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98831:Assign_L250_C8", "label": "token = next_token()", "type": "assigned_variable", "loc": [250, 250], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98831:While_L249_C4", "vector": [14, 2, 0.9124, 0.0036, 2, 0.7, 0.0, 129, 3, 0, 0, 0, 663, 10, 1], "semantic": {"name": "token", "arg_names": [], "import_names": [], "rhs_call_name": "next_token", "annotation": ""}, "snippet": " token = parser.next_token()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98831:If_L251_C8", "label": "if", "type": "if", "loc": [251, 254], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98831:While_L249_C4", "vector": [4, 2, 0.9215, 0.0146, 2, 0.7, 1.0, 0, 0, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if token.token_type in (TOKEN_VAR, TOKEN_TEXT):\n singular.append(token)\n else:\n break"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98831:Expr_L252_C12", "label": "append()", "type": "expression", "loc": [252, 252], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98831:If_L251_C8", "vector": [8, 3, 0.9197, 0.0036, 3, 0.76, 0.0, 243, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "append", "arg_names": [], "import_names": [], "rhs_call_name": "append", "annotation": ""}, "snippet": " singular.append(token)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98831:If_L255_C4", "label": "if", "type": "if", "loc": [255, 263], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98831:FunctionDef_L203_C0", "vector": [4, 1, 0.9453, 0.0328, 1, 0.3, 0.75, 0, 0, 0, 0, 0, 0, 0, 4], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if countervar and counter:\n if token.contents.strip() != 'plural':\n raise TemplateSyntaxError(\"'blocktrans' doesn't allow other block tags inside it\")\n while parser.tokens:\n token = parser.next_token()\n if token.token_type in (TOKEN_VAR, TOKEN_TEXT):\n plural.append(token)\n else:"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98831:If_L256_C8", "label": "if", "type": "if", "loc": [256, 257], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98831:If_L255_C4", "vector": [4, 2, 0.9361, 0.0073, 2, 0.41, 0.0, 0, 0, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if token.contents.strip() != 'plural':\n raise TemplateSyntaxError(\"'blocktrans' doesn't allow other block tags inside it\")"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98831:While_L258_C8", "label": "while", "type": "while", "loc": [258, 263], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98831:If_L255_C4", "vector": [5, 2, 0.9507, 0.0219, 2, 0.41, 1.0, 0, 7, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " while parser.tokens:\n token = parser.next_token()\n if token.token_type in (TOKEN_VAR, TOKEN_TEXT):\n plural.append(token)\n else:\n break"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98831:Assign_L259_C12", "label": "token = next_token()", "type": "assigned_variable", "loc": [259, 259], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98831:While_L258_C8", "vector": [14, 3, 0.9453, 0.0036, 3, 0.31, 0.0, 129, 3, 0, 0, 0, 663, 10, 1], "semantic": {"name": "token", "arg_names": [], "import_names": [], "rhs_call_name": "next_token", "annotation": ""}, "snippet": " token = parser.next_token()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98831:If_L260_C12", "label": "if", "type": "if", "loc": [260, 263], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98831:While_L258_C8", "vector": [4, 3, 0.9544, 0.0146, 3, 0.31, 1.0, 0, 0, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if token.token_type in (TOKEN_VAR, TOKEN_TEXT):\n plural.append(token)\n else:\n break"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98831:Expr_L261_C16", "label": "append()", "type": "expression", "loc": [261, 261], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98831:If_L260_C12", "vector": [8, 4, 0.9526, 0.0036, 4, 0.21, 0.0, 243, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "append", "arg_names": [], "import_names": [], "rhs_call_name": "append", "annotation": ""}, "snippet": " plural.append(token)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98831:If_L264_C4", "label": "if", "type": "if", "loc": [264, 265], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98831:FunctionDef_L203_C0", "vector": [4, 1, 0.9653, 0.0073, 1, 0.3, 0.875, 0, 0, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if token.contents.strip() != 'endblocktrans':\n raise TemplateSyntaxError(\"'blocktrans' doesn't allow other block tags (seen %r) inside it\" % token.contents)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98831:Return_L267_C4", "label": "return", "type": "return", "loc": [267, 268], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98831:FunctionDef_L203_C0", "vector": [13, 1, 0.9763, 0.0073, 1, 0.3, 1.0, 0, 3, 0, 0, 0, 0, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return BlockTranslateNode(extra_context, singular, plural, countervar,\n counter)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98831:Expr_L270_C0", "label": "tag()", "type": "expression", "loc": [270, 270], "level": 0, "parent": null, "vector": [8, 0, 0.9854, 0.0036, 0, 0.66, 0.8095, 732, 3, 2, 0, 0, 0, 0, 1], "semantic": {"name": "tag", "arg_names": [], "import_names": [], "rhs_call_name": "tag", "annotation": ""}, "snippet": "register.tag('get_available_languages', do_get_available_languages)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98831:Expr_L271_C0", "label": "tag()", "type": "expression", "loc": [271, 271], "level": 0, "parent": null, "vector": [8, 0, 0.9891, 0.0036, 0, 0.66, 0.8571, 732, 3, 2, 0, 0, 0, 0, 1], "semantic": {"name": "tag", "arg_names": [], "import_names": [], "rhs_call_name": "tag", "annotation": ""}, "snippet": "register.tag('get_current_language', do_get_current_language)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98831:Expr_L272_C0", "label": "tag()", "type": "expression", "loc": [272, 272], "level": 0, "parent": null, "vector": [8, 0, 0.9927, 0.0036, 0, 0.66, 0.9048, 732, 3, 2, 0, 0, 0, 0, 1], "semantic": {"name": "tag", "arg_names": [], "import_names": [], "rhs_call_name": "tag", "annotation": ""}, "snippet": "register.tag('get_current_language_bidi', do_get_current_language_bidi)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98831:Expr_L273_C0", "label": "tag()", "type": "expression", "loc": [273, 273], "level": 0, "parent": null, "vector": [8, 0, 0.9964, 0.0036, 0, 0.66, 0.9524, 732, 3, 2, 0, 0, 0, 0, 1], "semantic": {"name": "tag", "arg_names": [], "import_names": [], "rhs_call_name": "tag", "annotation": ""}, "snippet": "register.tag('trans', do_translate)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98831:Expr_L274_C0", "label": "tag()", "type": "expression", "loc": [274, 274], "level": 0, "parent": null, "vector": [8, 0, 1.0, 0.0036, 0, 0.66, 1.0, 732, 3, 2, 0, 0, 0, 0, 1], "semantic": {"name": "tag", "arg_names": [], "import_names": [], "rhs_call_name": "tag", "annotation": ""}, "snippet": "register.tag('blocktrans', do_block_translate)"}]
[{"f": "ajibawa-2023/Python-Code-Large/train/row_98831:ClassDef_L11_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98831:FunctionDef_L12_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98831:FunctionDef_L12_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98831:Assign_L13_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98831:ClassDef_L11_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98831:FunctionDef_L15_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98831:FunctionDef_L15_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98831:ImportFrom_L16_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98831:FunctionDef_L15_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98831:Assign_L17_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98831:FunctionDef_L15_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98831:Return_L18_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98831:ClassDef_L20_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98831:FunctionDef_L21_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98831:FunctionDef_L21_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98831:Assign_L22_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98831:ClassDef_L20_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98831:FunctionDef_L24_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98831:FunctionDef_L24_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98831:Assign_L25_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98831:FunctionDef_L24_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98831:Return_L26_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98831:ClassDef_L28_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98831:FunctionDef_L29_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98831:FunctionDef_L29_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98831:Assign_L30_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98831:ClassDef_L28_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98831:FunctionDef_L32_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98831:FunctionDef_L32_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98831:Assign_L33_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98831:FunctionDef_L32_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98831:Return_L34_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98831:ClassDef_L36_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98831:FunctionDef_L37_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98831:FunctionDef_L37_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98831:Assign_L38_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98831:FunctionDef_L37_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98831:Assign_L39_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98831:FunctionDef_L37_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98831:If_L40_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98831:If_L40_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98831:Assign_L41_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98831:ClassDef_L36_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98831:FunctionDef_L43_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98831:FunctionDef_L43_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98831:Assign_L44_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98831:FunctionDef_L43_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98831:Assign_L45_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98831:FunctionDef_L43_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98831:Return_L46_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98831:ClassDef_L48_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98831:FunctionDef_L49_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98831:FunctionDef_L49_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98831:Assign_L51_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98831:FunctionDef_L49_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98831:Assign_L52_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98831:FunctionDef_L49_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98831:Assign_L53_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98831:FunctionDef_L49_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98831:Assign_L54_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98831:FunctionDef_L49_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98831:Assign_L55_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98831:ClassDef_L48_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98831:FunctionDef_L57_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98831:FunctionDef_L57_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98831:Assign_L58_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98831:FunctionDef_L57_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98831:Assign_L59_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98831:FunctionDef_L57_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98831:For_L60_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98831:For_L60_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98831:If_L61_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98831:If_L61_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98831:Expr_L62_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98831:If_L61_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98831:If_L63_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98831:If_L63_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98831:Expr_L64_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98831:If_L63_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98831:Expr_L65_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98831:FunctionDef_L57_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98831:Return_L66_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98831:ClassDef_L48_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98831:FunctionDef_L68_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98831:FunctionDef_L68_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98831:Assign_L69_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98831:FunctionDef_L68_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98831:For_L70_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98831:For_L70_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98831:Assign_L71_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98831:FunctionDef_L68_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98831:Expr_L74_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98831:FunctionDef_L68_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98831:Assign_L75_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98831:FunctionDef_L68_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98831:If_L76_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98831:If_L76_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98831:Assign_L77_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98831:If_L76_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98831:Assign_L78_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98831:If_L76_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98831:Assign_L79_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98831:If_L76_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98831:Assign_L80_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98831:If_L76_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98831:Expr_L81_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98831:If_L76_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98831:Assign_L83_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98831:FunctionDef_L68_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98831:Assign_L85_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98831:FunctionDef_L68_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98831:Assign_L86_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98831:FunctionDef_L68_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98831:Expr_L87_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98831:FunctionDef_L68_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98831:Return_L88_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98831:FunctionDef_L90_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98831:Expr_L91_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98831:FunctionDef_L90_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98831:Assign_L106_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98831:FunctionDef_L90_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98831:If_L107_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98831:FunctionDef_L90_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98831:Return_L109_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98831:FunctionDef_L111_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98831:Expr_L112_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98831:FunctionDef_L111_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98831:Assign_L123_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98831:FunctionDef_L111_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98831:If_L124_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98831:FunctionDef_L111_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98831:Return_L126_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98831:FunctionDef_L128_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98831:Expr_L129_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98831:FunctionDef_L128_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98831:Assign_L140_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98831:FunctionDef_L128_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98831:If_L141_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98831:FunctionDef_L128_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98831:Return_L143_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98831:FunctionDef_L145_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98831:Expr_L146_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98831:FunctionDef_L145_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98831:ClassDef_L175_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98831:ClassDef_L175_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98831:FunctionDef_L176_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98831:FunctionDef_L176_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98831:Assign_L177_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98831:FunctionDef_L176_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98831:If_L184_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98831:If_L184_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98831:Assign_L185_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98831:If_L184_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98831:Assign_L186_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98831:If_L184_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98831:If_L187_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98831:If_L187_C16", "t": "ajibawa-2023/Python-Code-Large/train/row_98831:Assign_L188_C20"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98831:If_L187_C16", "t": "ajibawa-2023/Python-Code-Large/train/row_98831:If_L189_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98831:If_L189_C16", "t": "ajibawa-2023/Python-Code-Large/train/row_98831:Assign_L190_C20"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98831:FunctionDef_L176_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98831:If_L192_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98831:If_L192_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98831:If_L193_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98831:If_L193_C16", "t": "ajibawa-2023/Python-Code-Large/train/row_98831:Assign_L194_C20"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98831:If_L192_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98831:Assign_L198_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98831:FunctionDef_L176_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98831:Return_L199_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98831:FunctionDef_L145_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98831:Assign_L200_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98831:FunctionDef_L145_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98831:Return_L201_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98831:FunctionDef_L203_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98831:Expr_L204_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98831:FunctionDef_L203_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98831:ClassDef_L223_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98831:ClassDef_L223_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98831:FunctionDef_L224_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98831:FunctionDef_L224_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98831:Assign_L225_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98831:FunctionDef_L224_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98831:Assign_L226_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98831:FunctionDef_L224_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98831:Assign_L227_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98831:FunctionDef_L224_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98831:While_L228_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98831:While_L228_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98831:Assign_L229_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98831:While_L228_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98831:If_L230_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98831:If_L230_C16", "t": "ajibawa-2023/Python-Code-Large/train/row_98831:Assign_L231_C20"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98831:If_L230_C16", "t": "ajibawa-2023/Python-Code-Large/train/row_98831:If_L232_C20"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98831:If_L230_C16", "t": "ajibawa-2023/Python-Code-Large/train/row_98831:Assign_L234_C20"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98831:If_L230_C16", "t": "ajibawa-2023/Python-Code-Large/train/row_98831:If_L236_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98831:If_L236_C16", "t": "ajibawa-2023/Python-Code-Large/train/row_98831:Assign_L237_C20"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98831:If_L236_C16", "t": "ajibawa-2023/Python-Code-Large/train/row_98831:If_L238_C20"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98831:If_L236_C16", "t": "ajibawa-2023/Python-Code-Large/train/row_98831:Assign_L240_C20"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98831:FunctionDef_L224_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98831:Return_L243_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98831:FunctionDef_L203_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98831:Assign_L245_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98831:FunctionDef_L203_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98831:Assign_L247_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98831:FunctionDef_L203_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98831:Assign_L248_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98831:FunctionDef_L203_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98831:While_L249_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98831:While_L249_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98831:Assign_L250_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98831:While_L249_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98831:If_L251_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98831:If_L251_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98831:Expr_L252_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98831:FunctionDef_L203_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98831:If_L255_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98831:If_L255_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98831:If_L256_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98831:If_L255_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98831:While_L258_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98831:While_L258_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98831:Assign_L259_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98831:While_L258_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98831:If_L260_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98831:If_L260_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98831:Expr_L261_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98831:FunctionDef_L203_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98831:If_L264_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98831:FunctionDef_L203_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98831:Return_L267_C4"}]
from django.template import Library, Node, TemplateSyntaxError, Variable, VariableDoesNotExist from django.template import resolve_variable from django.core.cache import cache from django.utils.encoding import force_unicode from django.utils.http import urlquote from django.utils.hashcompat import md5_constructor register = Library() class CacheNode(Node): def __init__(self, nodelist, expire_time_var, fragment_name, vary_on): self.nodelist = nodelist self.expire_time_var = Variable(expire_time_var) self.fragment_name = fragment_name self.vary_on = vary_on def render(self, context): try: expire_time = self.expire_time_var.resolve(context) except VariableDoesNotExist: raise TemplateSyntaxError('"cache" tag got an unknown variable: %r' % self.expire_time_var.var) try: expire_time = int(expire_time) except (ValueError, TypeError): raise TemplateSyntaxError('"cache" tag got a non-integer timeout value: %r' % expire_time) # Build a unicode key for this fragment and all vary-on's. args = md5_constructor(u':'.join([urlquote(resolve_variable(var, context)) for var in self.vary_on])) cache_key = 'template.cache.%s.%s' % (self.fragment_name, args.hexdigest()) value = cache.get(cache_key) if value is None: value = self.nodelist.render(context) cache.set(cache_key, value, expire_time) return value def do_cache(parser, token): """ This will cache the contents of a template fragment for a given amount of time. Usage:: {% load cache %} {% cache [expire_time] [fragment_name] %} .. some expensive processing .. {% endcache %} This tag also supports varying by a list of arguments:: {% load cache %} {% cache [expire_time] [fragment_name] [var1] [var2] .. %} .. some expensive processing .. {% endcache %} Each unique set of arguments will result in a unique cache entry. """ nodelist = parser.parse(('endcache',)) parser.delete_first_token() tokens = token.contents.split() if len(tokens) < 3: raise TemplateSyntaxError(u"'%r' tag requires at least 2 arguments." % tokens[0]) return CacheNode(nodelist, tokens[1], tokens[2], tokens[3:]) register.tag('cache', do_cache)
ajibawa-2023/Python-Code-Large/train/row_98832
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_98832:ImportFrom_L1_C0", "label": "from django.template import Library, Node, TemplateSyntaxError\u2026", "type": "import", "loc": [1, 1], "level": 0, "parent": null, "vector": [1, 0, 0.0159, 0.0159, 0, 0.66, 0.0, 213, 0, 5, 0, 0, 213, 0, 0], "semantic": {"name": "django.template", "arg_names": [], "import_names": ["Library", "Node", "TemplateSyntaxError", "Variable", "VariableDoesNotExist"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.template import Library, Node, TemplateSyntaxError, Variable, VariableDoesNotExist"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98832:ImportFrom_L2_C0", "label": "from django.template import resolve_variable", "type": "import", "loc": [2, 2], "level": 0, "parent": null, "vector": [1, 0, 0.0317, 0.0159, 0, 0.66, 0.1111, 213, 0, 1, 0, 0, 213, 0, 0], "semantic": {"name": "django.template", "arg_names": [], "import_names": ["resolve_variable"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.template import resolve_variable"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98832:ImportFrom_L3_C0", "label": "from django.core.cache import cache", "type": "import", "loc": [3, 3], "level": 0, "parent": null, "vector": [1, 0, 0.0476, 0.0159, 0, 0.66, 0.2222, 734, 0, 1, 0, 0, 734, 0, 0], "semantic": {"name": "django.core.cache", "arg_names": [], "import_names": ["cache"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.core.cache import cache"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98832:ImportFrom_L4_C0", "label": "from django.utils.encoding import force_unicode", "type": "import", "loc": [4, 4], "level": 0, "parent": null, "vector": [1, 0, 0.0635, 0.0159, 0, 0.66, 0.3333, 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_98832:ImportFrom_L5_C0", "label": "from django.utils.http import urlquote", "type": "import", "loc": [5, 5], "level": 0, "parent": null, "vector": [1, 0, 0.0794, 0.0159, 0, 0.66, 0.4444, 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_98832:ImportFrom_L6_C0", "label": "from django.utils.hashcompat import md5_constructor", "type": "import", "loc": [6, 6], "level": 0, "parent": null, "vector": [1, 0, 0.0952, 0.0159, 0, 0.66, 0.5556, 474, 0, 1, 0, 0, 474, 0, 0], "semantic": {"name": "django.utils.hashcompat", "arg_names": [], "import_names": ["md5_constructor"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.utils.hashcompat import md5_constructor"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98832:Assign_L8_C0", "label": "register = Library()", "type": "assigned_variable", "loc": [8, 8], "level": 0, "parent": null, "vector": [14, 0, 0.127, 0.0159, 0, 0.66, 0.6667, 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_98832:ClassDef_L10_C0", "label": "CacheNode", "type": "class", "loc": [10, 33], "level": 0, "parent": null, "vector": [3, 0, 0.3413, 0.381, 0, 0.66, 0.7778, 38, 0, 2, 0, 0, 345, 0, 13], "semantic": {"name": "CacheNode", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class CacheNode(Node):\n def __init__(self, nodelist, expire_time_var, fragment_name, vary_on):\n self.nodelist = nodelist\n self.expire_time_var = Variable(expire_time_var)\n self.fragment_name = fragment_name\n self.vary_on = vary_on\n\n def render(self, context):"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98832:FunctionDef_L11_C4", "label": "__init__", "type": "function", "loc": [11, 15], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98832:ClassDef_L10_C0", "vector": [2, 1, 0.2063, 0.0794, 1, 0.9, 0.0, 555, 0, 5, 0, 0, 0, 0, 1], "semantic": {"name": "__init__", "arg_names": ["self", "nodelist", "expire_time_var", "fragment_name", "vary_on"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def __init__(self, nodelist, expire_time_var, fragment_name, vary_on):\n self.nodelist = nodelist\n self.expire_time_var = Variable(expire_time_var)\n self.fragment_name = fragment_name\n self.vary_on = vary_on"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98832:Assign_L12_C8", "label": "self.nodelist =", "type": "assigned_variable", "loc": [12, 12], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98832:FunctionDef_L11_C4", "vector": [14, 2, 0.1905, 0.0159, 2, 0.41, 0.0, 870, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "self.nodelist", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.nodelist = nodelist"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98832:Assign_L13_C8", "label": "self.expire_time_var = Variable()", "type": "assigned_variable", "loc": [13, 13], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98832:FunctionDef_L11_C4", "vector": [14, 2, 0.2063, 0.0159, 2, 0.41, 0.3333, 849, 3, 1, 0, 0, 807, 10, 1], "semantic": {"name": "self.expire_time_var", "arg_names": [], "import_names": [], "rhs_call_name": "Variable", "annotation": ""}, "snippet": " self.expire_time_var = Variable(expire_time_var)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98832:Assign_L14_C8", "label": "self.fragment_name =", "type": "assigned_variable", "loc": [14, 14], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98832:FunctionDef_L11_C4", "vector": [14, 2, 0.2222, 0.0159, 2, 0.41, 0.6667, 306, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "self.fragment_name", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.fragment_name = fragment_name"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98832:Assign_L15_C8", "label": "self.vary_on =", "type": "assigned_variable", "loc": [15, 15], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98832:FunctionDef_L11_C4", "vector": [14, 2, 0.2381, 0.0159, 2, 0.41, 1.0, 433, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "self.vary_on", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.vary_on = vary_on"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98832:FunctionDef_L17_C4", "label": "render", "type": "function", "loc": [17, 33], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98832:ClassDef_L10_C0", "vector": [2, 1, 0.3968, 0.2698, 1, 0.9, 1.0, 24, 0, 2, 1, 0, 0, 0, 12], "semantic": {"name": "render", "arg_names": ["self", "context"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def render(self, context):\n try:\n expire_time = self.expire_time_var.resolve(context)\n except VariableDoesNotExist:\n raise TemplateSyntaxError('\"cache\" tag got an unknown variable: %r' % self.expire_time_var.var)\n try:\n expire_time = int(expire_time)\n except (ValueError, TypeError):"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98832:Try_L18_C8", "label": "try", "type": "try", "loc": [18, 21], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98832:FunctionDef_L17_C4", "vector": [7, 2, 0.3095, 0.0635, 2, 0.95, 0.0, 0, 0, 1, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " try:\n expire_time = self.expire_time_var.resolve(context)\n except VariableDoesNotExist:\n raise TemplateSyntaxError('\"cache\" tag got an unknown variable: %r' % self.expire_time_var.var)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98832:Assign_L19_C12", "label": "expire_time = resolve()", "type": "assigned_variable", "loc": [19, 19], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98832:Try_L18_C8", "vector": [14, 3, 0.3016, 0.0159, 3, 0.8, 0.0, 7, 3, 1, 0, 0, 675, 10, 1], "semantic": {"name": "expire_time", "arg_names": [], "import_names": [], "rhs_call_name": "resolve", "annotation": ""}, "snippet": " expire_time = self.expire_time_var.resolve(context)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98832:Try_L22_C8", "label": "try", "type": "try", "loc": [22, 25], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98832:FunctionDef_L17_C4", "vector": [7, 2, 0.373, 0.0635, 2, 0.95, 0.1667, 0, 0, 1, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " try:\n expire_time = int(expire_time)\n except (ValueError, TypeError):\n raise TemplateSyntaxError('\"cache\" tag got a non-integer timeout value: %r' % expire_time)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98832:Assign_L23_C12", "label": "expire_time = int()", "type": "assigned_variable", "loc": [23, 23], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98832:Try_L22_C8", "vector": [14, 3, 0.3651, 0.0159, 3, 0.74, 0.0, 7, 3, 1, 0, 0, 901, 10, 1], "semantic": {"name": "expire_time", "arg_names": [], "import_names": [], "rhs_call_name": "int", "annotation": ""}, "snippet": " expire_time = int(expire_time)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98832:Assign_L27_C8", "label": "args = md5_constructor()", "type": "assigned_variable", "loc": [27, 27], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98832:FunctionDef_L17_C4", "vector": [14, 2, 0.4286, 0.0159, 2, 0.95, 0.3333, 805, 3, 1, 0, 0, 448, 10, 4], "semantic": {"name": "args", "arg_names": [], "import_names": [], "rhs_call_name": "md5_constructor", "annotation": ""}, "snippet": " args = md5_constructor(u':'.join([urlquote(resolve_variable(var, context)) for var in self.vary_on]))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98832:Assign_L28_C8", "label": "cache_key =", "type": "assigned_variable", "loc": [28, 28], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98832:FunctionDef_L17_C4", "vector": [14, 2, 0.4444, 0.0159, 2, 0.95, 0.5, 62, 4, 0, 0, 0, 0, 0, 1], "semantic": {"name": "cache_key", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " cache_key = 'template.cache.%s.%s' % (self.fragment_name, args.hexdigest())"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98832:Assign_L29_C8", "label": "value = get()", "type": "assigned_variable", "loc": [29, 29], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98832:FunctionDef_L17_C4", "vector": [14, 2, 0.4603, 0.0159, 2, 0.95, 0.6667, 441, 3, 1, 0, 0, 607, 10, 1], "semantic": {"name": "value", "arg_names": [], "import_names": [], "rhs_call_name": "get", "annotation": ""}, "snippet": " value = cache.get(cache_key)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98832:If_L30_C8", "label": "if", "type": "if", "loc": [30, 32], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98832:FunctionDef_L17_C4", "vector": [4, 2, 0.4921, 0.0476, 2, 0.95, 0.8333, 0, 0, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if value is None:\n value = self.nodelist.render(context)\n cache.set(cache_key, value, expire_time)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98832:Assign_L31_C12", "label": "value = render()", "type": "assigned_variable", "loc": [31, 31], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98832:If_L30_C8", "vector": [14, 3, 0.4921, 0.0159, 3, 0.85, 0.0, 441, 3, 1, 0, 0, 24, 10, 1], "semantic": {"name": "value", "arg_names": [], "import_names": [], "rhs_call_name": "render", "annotation": ""}, "snippet": " value = self.nodelist.render(context)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98832:Expr_L32_C12", "label": "set()", "type": "expression", "loc": [32, 32], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98832:If_L30_C8", "vector": [8, 3, 0.5079, 0.0159, 3, 0.85, 1.0, 21, 3, 3, 0, 0, 0, 0, 1], "semantic": {"name": "set", "arg_names": [], "import_names": [], "rhs_call_name": "set", "annotation": ""}, "snippet": " cache.set(cache_key, value, expire_time)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98832:Return_L33_C8", "label": "return", "type": "return", "loc": [33, 33], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98832:FunctionDef_L17_C4", "vector": [13, 2, 0.5238, 0.0159, 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 value"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98832:FunctionDef_L35_C0", "label": "do_cache", "type": "function", "loc": [35, 61], "level": 0, "parent": null, "vector": [2, 0, 0.7619, 0.4286, 0, 0.66, 0.8889, 802, 0, 2, 1, 0, 0, 0, 6], "semantic": {"name": "do_cache", "arg_names": ["parser", "token"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "def do_cache(parser, token):\n \"\"\"\n This will cache the contents of a template fragment for a given amount\n of time.\n\n Usage::\n\n {% load cache %}"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98832:Expr_L36_C4", "label": "expression", "type": "expression", "loc": [36, 55], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98832:FunctionDef_L35_C0", "vector": [8, 1, 0.7222, 0.3175, 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 This will cache the contents of a template fragment for a given amount\n of time.\n\n Usage::\n\n {% load cache %}\n {% cache [expire_time] [fragment_name] %}"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98832:Assign_L56_C4", "label": "nodelist = parse()", "type": "assigned_variable", "loc": [56, 56], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98832:FunctionDef_L35_C0", "vector": [14, 1, 0.8889, 0.0159, 1, 0.95, 0.2, 507, 3, 1, 0, 0, 678, 10, 1], "semantic": {"name": "nodelist", "arg_names": [], "import_names": [], "rhs_call_name": "parse", "annotation": ""}, "snippet": " nodelist = parser.parse(('endcache',))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98832:Expr_L57_C4", "label": "delete_first_token()", "type": "expression", "loc": [57, 57], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98832:FunctionDef_L35_C0", "vector": [8, 1, 0.9048, 0.0159, 1, 0.95, 0.4, 405, 3, 0, 0, 0, 0, 0, 1], "semantic": {"name": "delete_first_token", "arg_names": [], "import_names": [], "rhs_call_name": "delete_first_token", "annotation": ""}, "snippet": " parser.delete_first_token()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98832:Assign_L58_C4", "label": "tokens = split()", "type": "assigned_variable", "loc": [58, 58], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98832:FunctionDef_L35_C0", "vector": [14, 1, 0.9206, 0.0159, 1, 0.95, 0.6, 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_98832:If_L59_C4", "label": "if", "type": "if", "loc": [59, 60], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98832:FunctionDef_L35_C0", "vector": [4, 1, 0.9444, 0.0317, 1, 0.95, 0.8, 0, 0, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if len(tokens) < 3:\n raise TemplateSyntaxError(u\"'%r' tag requires at least 2 arguments.\" % tokens[0])"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98832:Return_L61_C4", "label": "return", "type": "return", "loc": [61, 61], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98832:FunctionDef_L35_C0", "vector": [13, 1, 0.9683, 0.0159, 1, 0.95, 1.0, 0, 3, 0, 0, 0, 0, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return CacheNode(nodelist, tokens[1], tokens[2], tokens[3:])"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98832:Expr_L63_C0", "label": "tag()", "type": "expression", "loc": [63, 63], "level": 0, "parent": null, "vector": [8, 0, 1.0, 0.0159, 0, 0.66, 1.0, 732, 3, 2, 0, 0, 0, 0, 1], "semantic": {"name": "tag", "arg_names": [], "import_names": [], "rhs_call_name": "tag", "annotation": ""}, "snippet": "register.tag('cache', do_cache)"}]
[{"f": "ajibawa-2023/Python-Code-Large/train/row_98832:ClassDef_L10_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98832:FunctionDef_L11_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98832:FunctionDef_L11_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98832:Assign_L12_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98832:FunctionDef_L11_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98832:Assign_L13_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98832:FunctionDef_L11_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98832:Assign_L14_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98832:FunctionDef_L11_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98832:Assign_L15_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98832:ClassDef_L10_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98832:FunctionDef_L17_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98832:FunctionDef_L17_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98832:Try_L18_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98832:Try_L18_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98832:Assign_L19_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98832:FunctionDef_L17_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98832:Try_L22_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98832:Try_L22_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98832:Assign_L23_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98832:FunctionDef_L17_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98832:Assign_L27_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98832:FunctionDef_L17_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98832:Assign_L28_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98832:FunctionDef_L17_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98832:Assign_L29_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98832:FunctionDef_L17_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98832:If_L30_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98832:If_L30_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98832:Assign_L31_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98832:If_L30_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98832:Expr_L32_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98832:FunctionDef_L17_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98832:Return_L33_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98832:FunctionDef_L35_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98832:Expr_L36_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98832:FunctionDef_L35_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98832:Assign_L56_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98832:FunctionDef_L35_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98832:Expr_L57_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98832:FunctionDef_L35_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98832:Assign_L58_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98832:FunctionDef_L35_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98832:If_L59_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98832:FunctionDef_L35_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98832:Return_L61_C4"}]
# This module is DEPRECATED! # # You should no longer be using django.template_loader. # # Use django.template.loader instead. from django.template.loader import *
ajibawa-2023/Python-Code-Large/train/row_98833
1
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_98833:ImportFrom_L7_C0", "label": "from django.template.loader import *", "type": "import", "loc": [7, 7], "level": 0, "parent": null, "vector": [1, 0, 1.0, 0.1429, 0, 0.66, 0.0, 970, 0, 1, 0, 0, 970, 0, 0], "semantic": {"name": "django.template.loader", "arg_names": [], "import_names": ["*"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.template.loader import *"}]
[]
""" YAML serializer. Requires PyYaml (http://pyyaml.org/), but that's checked for in __init__. """ from StringIO import StringIO import decimal import yaml from django.db import models from django.core.serializers.python import Serializer as PythonSerializer from django.core.serializers.python import Deserializer as PythonDeserializer class DjangoSafeDumper(yaml.SafeDumper): def represent_decimal(self, data): return self.represent_scalar('tag:yaml.org,2002:str', str(data)) DjangoSafeDumper.add_representer(decimal.Decimal, DjangoSafeDumper.represent_decimal) class Serializer(PythonSerializer): """ Convert a queryset to YAML. """ internal_use_only = False def handle_field(self, obj, field): # A nasty special case: base YAML doesn't support serialization of time # types (as opposed to dates or datetimes, which it does support). Since # we want to use the "safe" serializer for better interoperability, we # need to do something with those pesky times. Converting 'em to strings # isn't perfect, but it's better than a "!!python/time" type which would # halt deserialization under any other language. if isinstance(field, models.TimeField) and getattr(obj, field.name) is not None: self._current[field.name] = str(getattr(obj, field.name)) else: super(Serializer, self).handle_field(obj, field) def end_serialization(self): self.options.pop('stream', None) self.options.pop('fields', None) self.options.pop('use_natural_keys', None) yaml.dump(self.objects, self.stream, Dumper=DjangoSafeDumper, **self.options) def getvalue(self): return self.stream.getvalue() def Deserializer(stream_or_string, **options): """ Deserialize a stream or string of YAML data. """ if isinstance(stream_or_string, basestring): stream = StringIO(stream_or_string) else: stream = stream_or_string for obj in PythonDeserializer(yaml.load(stream), **options): yield obj
ajibawa-2023/Python-Code-Large/train/row_98834
32
59
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_98834:Expr_L1_C0", "label": "expression", "type": "expression", "loc": [1, 5], "level": 0, "parent": null, "vector": [8, 0, 0.0508, 0.0847, 0, 0.66, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "\"\"\"\nYAML serializer.\n\nRequires PyYaml (http://pyyaml.org/), but that's checked for in __init__.\n\"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98834:ImportFrom_L7_C0", "label": "from StringIO import StringIO", "type": "import", "loc": [7, 7], "level": 0, "parent": null, "vector": [1, 0, 0.1186, 0.0169, 0, 0.66, 0.1, 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_98834:Import_L8_C0", "label": "decimal import decimal", "type": "import", "loc": [8, 8], "level": 0, "parent": null, "vector": [1, 0, 0.1356, 0.0169, 0, 0.66, 0.2, 349, 0, 1, 0, 0, 349, 0, 0], "semantic": {"name": "decimal", "arg_names": [], "import_names": ["decimal"], "rhs_call_name": "", "annotation": ""}, "snippet": "import decimal"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98834:Import_L9_C0", "label": "yaml import yaml", "type": "import", "loc": [9, 9], "level": 0, "parent": null, "vector": [1, 0, 0.1525, 0.0169, 0, 0.66, 0.3, 960, 0, 1, 0, 0, 960, 0, 0], "semantic": {"name": "yaml", "arg_names": [], "import_names": ["yaml"], "rhs_call_name": "", "annotation": ""}, "snippet": "import yaml"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98834:ImportFrom_L11_C0", "label": "from django.db import models", "type": "import", "loc": [11, 11], "level": 0, "parent": null, "vector": [1, 0, 0.1864, 0.0169, 0, 0.66, 0.4, 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_98834:ImportFrom_L12_C0", "label": "from django.core.serializers.python import PythonSerializer", "type": "import", "loc": [12, 12], "level": 0, "parent": null, "vector": [1, 0, 0.2034, 0.0169, 0, 0.66, 0.5, 535, 0, 1, 0, 0, 535, 0, 0], "semantic": {"name": "django.core.serializers.python", "arg_names": [], "import_names": ["PythonSerializer"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.core.serializers.python import Serializer as PythonSerializer"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98834:ImportFrom_L13_C0", "label": "from django.core.serializers.python import PythonDeserializer", "type": "import", "loc": [13, 13], "level": 0, "parent": null, "vector": [1, 0, 0.2203, 0.0169, 0, 0.66, 0.6, 535, 0, 1, 0, 0, 535, 0, 0], "semantic": {"name": "django.core.serializers.python", "arg_names": [], "import_names": ["PythonDeserializer"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.core.serializers.python import Deserializer as PythonDeserializer"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98834:ClassDef_L15_C0", "label": "DjangoSafeDumper", "type": "class", "loc": [15, 17], "level": 0, "parent": null, "vector": [3, 0, 0.2712, 0.0508, 0, 0.66, 0.7, 723, 0, 1, 0, 0, 200, 0, 2], "semantic": {"name": "DjangoSafeDumper", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class DjangoSafeDumper(yaml.SafeDumper):\n def represent_decimal(self, data):\n return self.represent_scalar('tag:yaml.org,2002:str', str(data))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98834:FunctionDef_L16_C4", "label": "represent_decimal", "type": "function", "loc": [16, 17], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98834:ClassDef_L15_C0", "vector": [2, 1, 0.2797, 0.0339, 1, 0.74, 0.0, 241, 0, 2, 1, 0, 0, 0, 2], "semantic": {"name": "represent_decimal", "arg_names": ["self", "data"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def represent_decimal(self, data):\n return self.represent_scalar('tag:yaml.org,2002:str', str(data))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98834:Return_L17_C8", "label": "return", "type": "return", "loc": [17, 17], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98834:FunctionDef_L16_C4", "vector": [13, 2, 0.2881, 0.0169, 2, 0.09, 0.0, 0, 3, 0, 0, 0, 0, 10, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return self.represent_scalar('tag:yaml.org,2002:str', str(data))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98834:Expr_L19_C0", "label": "add_representer()", "type": "expression", "loc": [19, 19], "level": 0, "parent": null, "vector": [8, 0, 0.322, 0.0169, 0, 0.66, 0.8, 935, 3, 2, 0, 0, 0, 0, 1], "semantic": {"name": "add_representer", "arg_names": [], "import_names": [], "rhs_call_name": "add_representer", "annotation": ""}, "snippet": "DjangoSafeDumper.add_representer(decimal.Decimal, DjangoSafeDumper.represent_decimal)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98834:ClassDef_L21_C0", "label": "Serializer", "type": "class", "loc": [21, 47], "level": 0, "parent": null, "vector": [3, 0, 0.5763, 0.4576, 0, 0.66, 0.9, 577, 0, 3, 0, 0, 468, 0, 11], "semantic": {"name": "Serializer", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class Serializer(PythonSerializer):\n \"\"\"\n Convert a queryset to YAML.\n \"\"\"\n\n internal_use_only = False\n\n def handle_field(self, obj, field):"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98834:Expr_L22_C4", "label": "expression", "type": "expression", "loc": [22, 24], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98834:ClassDef_L21_C0", "vector": [8, 1, 0.3898, 0.0508, 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 Convert a queryset to YAML.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98834:Assign_L26_C4", "label": "internal_use_only =", "type": "assigned_variable", "loc": [26, 26], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98834:ClassDef_L21_C0", "vector": [14, 1, 0.4407, 0.0169, 1, 0.59, 0.25, 17, 1, 0, 0, 0, 0, 4, 0], "semantic": {"name": "internal_use_only", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " internal_use_only = False"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98834:FunctionDef_L28_C4", "label": "handle_field", "type": "function", "loc": [28, 38], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98834:ClassDef_L21_C0", "vector": [2, 1, 0.5593, 0.1864, 1, 0.59, 0.5, 277, 0, 3, 0, 0, 0, 0, 6], "semantic": {"name": "handle_field", "arg_names": ["self", "obj", "field"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def handle_field(self, obj, field):\n # A nasty special case: base YAML doesn't support serialization of time\n # types (as opposed to dates or datetimes, which it does support). Since\n # we want to use the \"safe\" serializer for better interoperability, we\n # need to do something with those pesky times. Converting 'em to strings\n # isn't perfect, but it's better than a \"!!python/time\" type which would\n # halt deserialization under any other language.\n if isinstance(field, models.TimeField) and getattr(obj, field.name) is not None:"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98834:If_L35_C8", "label": "if", "type": "if", "loc": [35, 38], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98834:FunctionDef_L28_C4", "vector": [4, 2, 0.6186, 0.0678, 2, 0.53, 0.0, 0, 0, 0, 0, 0, 0, 0, 6], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if isinstance(field, models.TimeField) and getattr(obj, field.name) is not None:\n self._current[field.name] = str(getattr(obj, field.name))\n else:\n super(Serializer, self).handle_field(obj, field)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98834:Assign_L36_C12", "label": " = str()", "type": "assigned_variable", "loc": [36, 36], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98834:If_L35_C8", "vector": [14, 3, 0.6102, 0.0169, 3, 0.7, 0.0, 0, 3, 1, 0, 0, 52, 10, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "str", "annotation": ""}, "snippet": " self._current[field.name] = str(getattr(obj, field.name))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98834:Expr_L38_C12", "label": "handle_field()", "type": "expression", "loc": [38, 38], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98834:If_L35_C8", "vector": [8, 3, 0.6441, 0.0169, 3, 0.7, 1.0, 277, 3, 2, 0, 0, 0, 0, 2], "semantic": {"name": "handle_field", "arg_names": [], "import_names": [], "rhs_call_name": "handle_field", "annotation": ""}, "snippet": " super(Serializer, self).handle_field(obj, field)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98834:FunctionDef_L40_C4", "label": "end_serialization", "type": "function", "loc": [40, 44], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98834:ClassDef_L21_C0", "vector": [2, 1, 0.7119, 0.0847, 1, 0.59, 0.75, 673, 0, 1, 0, 0, 0, 0, 4], "semantic": {"name": "end_serialization", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def end_serialization(self):\n self.options.pop('stream', None)\n self.options.pop('fields', None)\n self.options.pop('use_natural_keys', None)\n yaml.dump(self.objects, self.stream, Dumper=DjangoSafeDumper, **self.options)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98834:Expr_L41_C8", "label": "pop()", "type": "expression", "loc": [41, 41], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98834:FunctionDef_L40_C4", "vector": [8, 2, 0.6949, 0.0169, 2, 0.54, 0.0, 969, 3, 2, 0, 0, 0, 0, 1], "semantic": {"name": "pop", "arg_names": [], "import_names": [], "rhs_call_name": "pop", "annotation": ""}, "snippet": " self.options.pop('stream', None)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98834:Expr_L42_C8", "label": "pop()", "type": "expression", "loc": [42, 42], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98834:FunctionDef_L40_C4", "vector": [8, 2, 0.7119, 0.0169, 2, 0.54, 0.3333, 969, 3, 2, 0, 0, 0, 0, 1], "semantic": {"name": "pop", "arg_names": [], "import_names": [], "rhs_call_name": "pop", "annotation": ""}, "snippet": " self.options.pop('fields', None)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98834:Expr_L43_C8", "label": "pop()", "type": "expression", "loc": [43, 43], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98834:FunctionDef_L40_C4", "vector": [8, 2, 0.7288, 0.0169, 2, 0.54, 0.6667, 969, 3, 2, 0, 0, 0, 0, 1], "semantic": {"name": "pop", "arg_names": [], "import_names": [], "rhs_call_name": "pop", "annotation": ""}, "snippet": " self.options.pop('use_natural_keys', None)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98834:Expr_L44_C8", "label": "dump()", "type": "expression", "loc": [44, 44], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98834:FunctionDef_L40_C4", "vector": [8, 2, 0.7458, 0.0169, 2, 0.54, 1.0, 952, 3, 4, 0, 0, 0, 0, 1], "semantic": {"name": "dump", "arg_names": [], "import_names": [], "rhs_call_name": "dump", "annotation": ""}, "snippet": " yaml.dump(self.objects, self.stream, Dumper=DjangoSafeDumper, **self.options)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98834:FunctionDef_L46_C4", "label": "getvalue", "type": "function", "loc": [46, 47], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98834:ClassDef_L21_C0", "vector": [2, 1, 0.7881, 0.0339, 1, 0.59, 1.0, 626, 0, 1, 1, 0, 0, 0, 1], "semantic": {"name": "getvalue", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def getvalue(self):\n return self.stream.getvalue()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98834:Return_L47_C8", "label": "return", "type": "return", "loc": [47, 47], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98834:FunctionDef_L46_C4", "vector": [13, 2, 0.7966, 0.0169, 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.stream.getvalue()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98834:FunctionDef_L49_C0", "label": "Deserializer", "type": "function", "loc": [49, 58], "level": 0, "parent": null, "vector": [2, 0, 0.9068, 0.1695, 0, 0.66, 1.0, 604, 0, 2, 0, 0, 0, 0, 4], "semantic": {"name": "Deserializer", "arg_names": ["stream_or_string", "options"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "def Deserializer(stream_or_string, **options):\n \"\"\"\n Deserialize a stream or string of YAML data.\n \"\"\"\n if isinstance(stream_or_string, basestring):\n stream = StringIO(stream_or_string)\n else:\n stream = stream_or_string"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98834:Expr_L50_C4", "label": "expression", "type": "expression", "loc": [50, 52], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98834:FunctionDef_L49_C0", "vector": [8, 1, 0.8644, 0.0508, 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 Deserialize a stream or string of YAML data.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98834:If_L53_C4", "label": "if", "type": "if", "loc": [53, 56], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98834:FunctionDef_L49_C0", "vector": [4, 1, 0.9237, 0.0678, 1, 0.2, 0.5, 0, 3, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if isinstance(stream_or_string, basestring):\n stream = StringIO(stream_or_string)\n else:\n stream = stream_or_string"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98834:Assign_L54_C8", "label": "stream = StringIO()", "type": "assigned_variable", "loc": [54, 54], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98834:If_L53_C4", "vector": [14, 2, 0.9153, 0.0169, 2, 0.11, 0.0, 517, 3, 1, 0, 0, 609, 10, 1], "semantic": {"name": "stream", "arg_names": [], "import_names": [], "rhs_call_name": "StringIO", "annotation": ""}, "snippet": " stream = StringIO(stream_or_string)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98834:Assign_L56_C8", "label": "stream =", "type": "assigned_variable", "loc": [56, 56], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98834:If_L53_C4", "vector": [14, 2, 0.9492, 0.0169, 2, 0.11, 1.0, 517, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "stream", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " stream = stream_or_string"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98834:For_L57_C4", "label": "for obj", "type": "for", "loc": [57, 58], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98834:FunctionDef_L49_C0", "vector": [6, 1, 0.9746, 0.0339, 1, 0.2, 1.0, 505, 3, 0, 0, 0, 0, 0, 2], "semantic": {"name": "obj", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for obj in PythonDeserializer(yaml.load(stream), **options):\n yield obj"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98834:Expr_L58_C8", "label": "expression", "type": "expression", "loc": [58, 58], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98834:For_L57_C4", "vector": [8, 2, 0.9831, 0.0169, 2, 0.15, 0.0, 0, 0, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " yield obj"}]
[{"f": "ajibawa-2023/Python-Code-Large/train/row_98834:ClassDef_L15_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98834:FunctionDef_L16_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98834:FunctionDef_L16_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98834:Return_L17_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98834:ClassDef_L21_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98834:Expr_L22_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98834:ClassDef_L21_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98834:Assign_L26_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98834:ClassDef_L21_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98834:FunctionDef_L28_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98834:FunctionDef_L28_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98834:If_L35_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98834:If_L35_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98834:Assign_L36_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98834:If_L35_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98834:Expr_L38_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98834:ClassDef_L21_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98834:FunctionDef_L40_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98834:FunctionDef_L40_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98834:Expr_L41_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98834:FunctionDef_L40_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98834:Expr_L42_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98834:FunctionDef_L40_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98834:Expr_L43_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98834:FunctionDef_L40_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98834:Expr_L44_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98834:ClassDef_L21_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98834:FunctionDef_L46_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98834:FunctionDef_L46_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98834:Return_L47_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98834:FunctionDef_L49_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98834:Expr_L50_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98834:FunctionDef_L49_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98834:If_L53_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98834:If_L53_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98834:Assign_L54_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98834:If_L53_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98834:Assign_L56_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98834:FunctionDef_L49_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98834:For_L57_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98834:For_L57_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98834:Expr_L58_C8"}]
""" Serialize data to/from JSON """ import datetime import decimal from StringIO import StringIO from django.core.serializers.python import Serializer as PythonSerializer from django.core.serializers.python import Deserializer as PythonDeserializer from django.utils import datetime_safe from django.utils import simplejson class Serializer(PythonSerializer): """ Convert a queryset to JSON. """ internal_use_only = False def end_serialization(self): self.options.pop('stream', None) self.options.pop('fields', None) self.options.pop('use_natural_keys', None) simplejson.dump(self.objects, self.stream, cls=DjangoJSONEncoder, **self.options) def getvalue(self): if callable(getattr(self.stream, 'getvalue', None)): return self.stream.getvalue() def Deserializer(stream_or_string, **options): """ Deserialize a stream or string of JSON data. """ if isinstance(stream_or_string, basestring): stream = StringIO(stream_or_string) else: stream = stream_or_string for obj in PythonDeserializer(simplejson.load(stream), **options): yield obj class DjangoJSONEncoder(simplejson.JSONEncoder): """ JSONEncoder subclass that knows how to encode date/time and decimal types. """ DATE_FORMAT = "%Y-%m-%d" TIME_FORMAT = "%H:%M:%S" def default(self, o): if isinstance(o, datetime.datetime): d = datetime_safe.new_datetime(o) return d.strftime("%s %s" % (self.DATE_FORMAT, self.TIME_FORMAT)) elif isinstance(o, datetime.date): d = datetime_safe.new_date(o) return d.strftime(self.DATE_FORMAT) elif isinstance(o, datetime.time): return o.strftime(self.TIME_FORMAT) elif isinstance(o, decimal.Decimal): return str(o) else: return super(DjangoJSONEncoder, self).default(o) # Older, deprecated class name (for backwards compatibility purposes). DateTimeAwareJSONEncoder = DjangoJSONEncoder
ajibawa-2023/Python-Code-Large/train/row_98835
43
65
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_98835:Expr_L1_C0", "label": "expression", "type": "expression", "loc": [1, 3], "level": 0, "parent": null, "vector": [8, 0, 0.0308, 0.0462, 0, 0.66, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "\"\"\"\nSerialize data to/from JSON\n\"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98835:Import_L5_C0", "label": "datetime import datetime", "type": "import", "loc": [5, 5], "level": 0, "parent": null, "vector": [1, 0, 0.0769, 0.0154, 0, 0.66, 0.0909, 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_98835:Import_L6_C0", "label": "decimal import decimal", "type": "import", "loc": [6, 6], "level": 0, "parent": null, "vector": [1, 0, 0.0923, 0.0154, 0, 0.66, 0.1818, 349, 0, 1, 0, 0, 349, 0, 0], "semantic": {"name": "decimal", "arg_names": [], "import_names": ["decimal"], "rhs_call_name": "", "annotation": ""}, "snippet": "import decimal"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98835:ImportFrom_L7_C0", "label": "from StringIO import StringIO", "type": "import", "loc": [7, 7], "level": 0, "parent": null, "vector": [1, 0, 0.1077, 0.0154, 0, 0.66, 0.2727, 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_98835:ImportFrom_L9_C0", "label": "from django.core.serializers.python import PythonSerializer", "type": "import", "loc": [9, 9], "level": 0, "parent": null, "vector": [1, 0, 0.1385, 0.0154, 0, 0.66, 0.3636, 535, 0, 1, 0, 0, 535, 0, 0], "semantic": {"name": "django.core.serializers.python", "arg_names": [], "import_names": ["PythonSerializer"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.core.serializers.python import Serializer as PythonSerializer"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98835:ImportFrom_L10_C0", "label": "from django.core.serializers.python import PythonDeserializer", "type": "import", "loc": [10, 10], "level": 0, "parent": null, "vector": [1, 0, 0.1538, 0.0154, 0, 0.66, 0.4545, 535, 0, 1, 0, 0, 535, 0, 0], "semantic": {"name": "django.core.serializers.python", "arg_names": [], "import_names": ["PythonDeserializer"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.core.serializers.python import Deserializer as PythonDeserializer"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98835:ImportFrom_L11_C0", "label": "from django.utils import datetime_safe", "type": "import", "loc": [11, 11], "level": 0, "parent": null, "vector": [1, 0, 0.1692, 0.0154, 0, 0.66, 0.5455, 944, 0, 1, 0, 0, 944, 0, 0], "semantic": {"name": "django.utils", "arg_names": [], "import_names": ["datetime_safe"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.utils import datetime_safe"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98835:ImportFrom_L12_C0", "label": "from django.utils import simplejson", "type": "import", "loc": [12, 12], "level": 0, "parent": null, "vector": [1, 0, 0.1846, 0.0154, 0, 0.66, 0.6364, 944, 0, 1, 0, 0, 944, 0, 0], "semantic": {"name": "django.utils", "arg_names": [], "import_names": ["simplejson"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.utils import simplejson"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98835:ClassDef_L14_C0", "label": "Serializer", "type": "class", "loc": [14, 28], "level": 0, "parent": null, "vector": [3, 0, 0.3231, 0.2308, 0, 0.66, 0.7273, 577, 0, 2, 0, 0, 468, 0, 7], "semantic": {"name": "Serializer", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class Serializer(PythonSerializer):\n \"\"\"\n Convert a queryset to JSON.\n \"\"\"\n internal_use_only = False\n\n def end_serialization(self):\n self.options.pop('stream', None)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98835:Expr_L15_C4", "label": "expression", "type": "expression", "loc": [15, 17], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98835:ClassDef_L14_C0", "vector": [8, 1, 0.2462, 0.0462, 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 Convert a queryset to JSON.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98835:Assign_L18_C4", "label": "internal_use_only =", "type": "assigned_variable", "loc": [18, 18], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98835:ClassDef_L14_C0", "vector": [14, 1, 0.2769, 0.0154, 1, 0.73, 0.3333, 17, 1, 0, 0, 0, 0, 4, 0], "semantic": {"name": "internal_use_only", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " internal_use_only = False"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98835:FunctionDef_L20_C4", "label": "end_serialization", "type": "function", "loc": [20, 24], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98835:ClassDef_L14_C0", "vector": [2, 1, 0.3385, 0.0769, 1, 0.73, 0.6667, 673, 0, 1, 0, 0, 0, 0, 4], "semantic": {"name": "end_serialization", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def end_serialization(self):\n self.options.pop('stream', None)\n self.options.pop('fields', None)\n self.options.pop('use_natural_keys', None)\n simplejson.dump(self.objects, self.stream, cls=DjangoJSONEncoder, **self.options)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98835:Expr_L21_C8", "label": "pop()", "type": "expression", "loc": [21, 21], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98835:FunctionDef_L20_C4", "vector": [8, 2, 0.3231, 0.0154, 2, 0.19, 0.0, 969, 3, 2, 0, 0, 0, 0, 1], "semantic": {"name": "pop", "arg_names": [], "import_names": [], "rhs_call_name": "pop", "annotation": ""}, "snippet": " self.options.pop('stream', None)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98835:Expr_L22_C8", "label": "pop()", "type": "expression", "loc": [22, 22], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98835:FunctionDef_L20_C4", "vector": [8, 2, 0.3385, 0.0154, 2, 0.19, 0.3333, 969, 3, 2, 0, 0, 0, 0, 1], "semantic": {"name": "pop", "arg_names": [], "import_names": [], "rhs_call_name": "pop", "annotation": ""}, "snippet": " self.options.pop('fields', None)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98835:Expr_L23_C8", "label": "pop()", "type": "expression", "loc": [23, 23], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98835:FunctionDef_L20_C4", "vector": [8, 2, 0.3538, 0.0154, 2, 0.19, 0.6667, 969, 3, 2, 0, 0, 0, 0, 1], "semantic": {"name": "pop", "arg_names": [], "import_names": [], "rhs_call_name": "pop", "annotation": ""}, "snippet": " self.options.pop('use_natural_keys', None)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98835:Expr_L24_C8", "label": "dump()", "type": "expression", "loc": [24, 24], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98835:FunctionDef_L20_C4", "vector": [8, 2, 0.3692, 0.0154, 2, 0.19, 1.0, 952, 3, 4, 0, 0, 0, 0, 1], "semantic": {"name": "dump", "arg_names": [], "import_names": [], "rhs_call_name": "dump", "annotation": ""}, "snippet": " simplejson.dump(self.objects, self.stream, cls=DjangoJSONEncoder, **self.options)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98835:FunctionDef_L26_C4", "label": "getvalue", "type": "function", "loc": [26, 28], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98835:ClassDef_L14_C0", "vector": [2, 1, 0.4154, 0.0462, 1, 0.73, 1.0, 626, 0, 1, 1, 0, 0, 0, 3], "semantic": {"name": "getvalue", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def getvalue(self):\n if callable(getattr(self.stream, 'getvalue', None)):\n return self.stream.getvalue()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98835:If_L27_C8", "label": "if", "type": "if", "loc": [27, 28], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98835:FunctionDef_L26_C4", "vector": [4, 2, 0.4231, 0.0308, 2, 0.31, 0.0, 0, 3, 0, 0, 0, 0, 0, 3], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if callable(getattr(self.stream, 'getvalue', None)):\n return self.stream.getvalue()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98835:Return_L28_C12", "label": "return", "type": "return", "loc": [28, 28], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98835:If_L27_C8", "vector": [13, 3, 0.4308, 0.0154, 3, 0.31, 0.0, 0, 3, 0, 0, 0, 0, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return self.stream.getvalue()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98835:FunctionDef_L30_C0", "label": "Deserializer", "type": "function", "loc": [30, 39], "level": 0, "parent": null, "vector": [2, 0, 0.5308, 0.1538, 0, 0.66, 0.8182, 604, 0, 2, 0, 0, 0, 0, 4], "semantic": {"name": "Deserializer", "arg_names": ["stream_or_string", "options"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "def Deserializer(stream_or_string, **options):\n \"\"\"\n Deserialize a stream or string of JSON data.\n \"\"\"\n if isinstance(stream_or_string, basestring):\n stream = StringIO(stream_or_string)\n else:\n stream = stream_or_string"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98835:Expr_L31_C4", "label": "expression", "type": "expression", "loc": [31, 33], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98835:FunctionDef_L30_C0", "vector": [8, 1, 0.4923, 0.0462, 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 Deserialize a stream or string of JSON data.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98835:If_L34_C4", "label": "if", "type": "if", "loc": [34, 37], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98835:FunctionDef_L30_C0", "vector": [4, 1, 0.5462, 0.0615, 1, 0.63, 0.5, 0, 3, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if isinstance(stream_or_string, basestring):\n stream = StringIO(stream_or_string)\n else:\n stream = stream_or_string"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98835:Assign_L35_C8", "label": "stream = StringIO()", "type": "assigned_variable", "loc": [35, 35], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98835:If_L34_C4", "vector": [14, 2, 0.5385, 0.0154, 2, 0.68, 0.0, 517, 3, 1, 0, 0, 609, 10, 1], "semantic": {"name": "stream", "arg_names": [], "import_names": [], "rhs_call_name": "StringIO", "annotation": ""}, "snippet": " stream = StringIO(stream_or_string)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98835:Assign_L37_C8", "label": "stream =", "type": "assigned_variable", "loc": [37, 37], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98835:If_L34_C4", "vector": [14, 2, 0.5692, 0.0154, 2, 0.68, 1.0, 517, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "stream", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " stream = stream_or_string"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98835:For_L38_C4", "label": "for obj", "type": "for", "loc": [38, 39], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98835:FunctionDef_L30_C0", "vector": [6, 1, 0.5923, 0.0308, 1, 0.63, 1.0, 505, 3, 0, 0, 0, 0, 0, 2], "semantic": {"name": "obj", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for obj in PythonDeserializer(simplejson.load(stream), **options):\n yield obj"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98835:Expr_L39_C8", "label": "expression", "type": "expression", "loc": [39, 39], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98835:For_L38_C4", "vector": [8, 2, 0.6, 0.0154, 2, 0.93, 0.0, 0, 0, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " yield obj"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98835:ClassDef_L41_C0", "label": "DjangoJSONEncoder", "type": "class", "loc": [41, 61], "level": 0, "parent": null, "vector": [3, 0, 0.7846, 0.3231, 0, 0.66, 0.9091, 791, 0, 1, 0, 0, 221, 0, 12], "semantic": {"name": "DjangoJSONEncoder", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class DjangoJSONEncoder(simplejson.JSONEncoder):\n \"\"\"\n JSONEncoder subclass that knows how to encode date/time and decimal types.\n \"\"\"\n\n DATE_FORMAT = \"%Y-%m-%d\"\n TIME_FORMAT = \"%H:%M:%S\"\n"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98835:Expr_L42_C4", "label": "expression", "type": "expression", "loc": [42, 44], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98835:ClassDef_L41_C0", "vector": [8, 1, 0.6615, 0.0462, 1, 0.46, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"\n JSONEncoder subclass that knows how to encode date/time and decimal types.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98835:Assign_L46_C4", "label": "DATE_FORMAT =", "type": "assigned_variable", "loc": [46, 46], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98835:ClassDef_L41_C0", "vector": [14, 1, 0.7077, 0.0154, 1, 0.46, 0.3333, 843, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "DATE_FORMAT", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " DATE_FORMAT = \"%Y-%m-%d\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98835:Assign_L47_C4", "label": "TIME_FORMAT =", "type": "assigned_variable", "loc": [47, 47], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98835:ClassDef_L41_C0", "vector": [14, 1, 0.7231, 0.0154, 1, 0.46, 0.6667, 662, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "TIME_FORMAT", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " TIME_FORMAT = \"%H:%M:%S\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98835:FunctionDef_L49_C4", "label": "default", "type": "function", "loc": [49, 61], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98835:ClassDef_L41_C0", "vector": [2, 1, 0.8462, 0.2, 1, 0.46, 1.0, 977, 0, 2, 1, 0, 0, 0, 12], "semantic": {"name": "default", "arg_names": ["self", "o"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def default(self, o):\n if isinstance(o, datetime.datetime):\n d = datetime_safe.new_datetime(o)\n return d.strftime(\"%s %s\" % (self.DATE_FORMAT, self.TIME_FORMAT))\n elif isinstance(o, datetime.date):\n d = datetime_safe.new_date(o)\n return d.strftime(self.DATE_FORMAT)\n elif isinstance(o, datetime.time):"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98835:If_L50_C8", "label": "if", "type": "if", "loc": [50, 61], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98835:FunctionDef_L49_C4", "vector": [4, 2, 0.8538, 0.1846, 2, 0.81, 0.0, 0, 3, 0, 0, 0, 0, 0, 12], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if isinstance(o, datetime.datetime):\n d = datetime_safe.new_datetime(o)\n return d.strftime(\"%s %s\" % (self.DATE_FORMAT, self.TIME_FORMAT))\n elif isinstance(o, datetime.date):\n d = datetime_safe.new_date(o)\n return d.strftime(self.DATE_FORMAT)\n elif isinstance(o, datetime.time):\n return o.strftime(self.TIME_FORMAT)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98835:Assign_L51_C12", "label": "d = new_datetime()", "type": "assigned_variable", "loc": [51, 51], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98835:If_L50_C8", "vector": [14, 3, 0.7846, 0.0154, 3, 0.71, 0.0, 355, 3, 1, 0, 0, 422, 10, 1], "semantic": {"name": "d", "arg_names": [], "import_names": [], "rhs_call_name": "new_datetime", "annotation": ""}, "snippet": " d = datetime_safe.new_datetime(o)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98835:Return_L52_C12", "label": "return", "type": "return", "loc": [52, 52], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98835:If_L50_C8", "vector": [13, 3, 0.8, 0.0154, 3, 0.71, 0.5, 0, 3, 0, 0, 0, 0, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return d.strftime(\"%s %s\" % (self.DATE_FORMAT, self.TIME_FORMAT))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98835:If_L53_C8", "label": "if", "type": "if", "loc": [53, 61], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98835:If_L50_C8", "vector": [4, 3, 0.8769, 0.1385, 3, 0.71, 1.0, 0, 3, 0, 0, 0, 0, 0, 9], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " elif isinstance(o, datetime.date):\n d = datetime_safe.new_date(o)\n return d.strftime(self.DATE_FORMAT)\n elif isinstance(o, datetime.time):\n return o.strftime(self.TIME_FORMAT)\n elif isinstance(o, decimal.Decimal):\n return str(o)\n else:"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98835:Assign_L54_C12", "label": "d = new_date()", "type": "assigned_variable", "loc": [54, 54], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98835:If_L53_C8", "vector": [14, 4, 0.8308, 0.0154, 4, 0.13, 0.0, 355, 3, 1, 0, 0, 584, 10, 1], "semantic": {"name": "d", "arg_names": [], "import_names": [], "rhs_call_name": "new_date", "annotation": ""}, "snippet": " d = datetime_safe.new_date(o)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98835:Return_L55_C12", "label": "return", "type": "return", "loc": [55, 55], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98835:If_L53_C8", "vector": [13, 4, 0.8462, 0.0154, 4, 0.13, 0.5, 0, 3, 0, 0, 0, 0, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return d.strftime(self.DATE_FORMAT)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98835:If_L56_C8", "label": "if", "type": "if", "loc": [56, 61], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98835:If_L53_C8", "vector": [4, 4, 0.9, 0.0923, 4, 0.13, 1.0, 0, 3, 0, 0, 0, 0, 0, 6], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " elif isinstance(o, datetime.time):\n return o.strftime(self.TIME_FORMAT)\n elif isinstance(o, decimal.Decimal):\n return str(o)\n else:\n return super(DjangoJSONEncoder, self).default(o)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98835:Return_L57_C12", "label": "return", "type": "return", "loc": [57, 57], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98835:If_L56_C8", "vector": [13, 5, 0.8769, 0.0154, 5, 0.76, 0.0, 0, 3, 0, 0, 0, 0, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return o.strftime(self.TIME_FORMAT)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98835:If_L58_C8", "label": "if", "type": "if", "loc": [58, 61], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98835:If_L56_C8", "vector": [4, 5, 0.9154, 0.0615, 5, 0.76, 1.0, 0, 3, 0, 0, 0, 0, 0, 4], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " elif isinstance(o, decimal.Decimal):\n return str(o)\n else:\n return super(DjangoJSONEncoder, self).default(o)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98835:Return_L59_C12", "label": "return", "type": "return", "loc": [59, 59], "level": 6, "parent": "ajibawa-2023/Python-Code-Large/train/row_98835:If_L58_C8", "vector": [13, 6, 0.9077, 0.0154, 6, 0.82, 0.0, 0, 3, 0, 0, 0, 0, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return str(o)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98835:Return_L61_C12", "label": "return", "type": "return", "loc": [61, 61], "level": 6, "parent": "ajibawa-2023/Python-Code-Large/train/row_98835:If_L58_C8", "vector": [13, 6, 0.9385, 0.0154, 6, 0.82, 1.0, 0, 3, 0, 0, 0, 0, 10, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return super(DjangoJSONEncoder, self).default(o)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98835:Assign_L64_C0", "label": "DateTimeAwareJSONEncoder =", "type": "assigned_variable", "loc": [64, 64], "level": 0, "parent": null, "vector": [14, 0, 0.9846, 0.0154, 0, 0.66, 1.0, 270, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "DateTimeAwareJSONEncoder", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "DateTimeAwareJSONEncoder = DjangoJSONEncoder"}]
[{"f": "ajibawa-2023/Python-Code-Large/train/row_98835:ClassDef_L14_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98835:Expr_L15_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98835:ClassDef_L14_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98835:Assign_L18_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98835:ClassDef_L14_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98835:FunctionDef_L20_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98835:FunctionDef_L20_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98835:Expr_L21_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98835:FunctionDef_L20_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98835:Expr_L22_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98835:FunctionDef_L20_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98835:Expr_L23_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98835:FunctionDef_L20_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98835:Expr_L24_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98835:ClassDef_L14_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98835:FunctionDef_L26_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98835:FunctionDef_L26_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98835:If_L27_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98835:If_L27_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98835:Return_L28_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98835:FunctionDef_L30_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98835:Expr_L31_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98835:FunctionDef_L30_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98835:If_L34_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98835:If_L34_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98835:Assign_L35_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98835:If_L34_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98835:Assign_L37_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98835:FunctionDef_L30_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98835:For_L38_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98835:For_L38_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98835:Expr_L39_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98835:ClassDef_L41_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98835:Expr_L42_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98835:ClassDef_L41_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98835:Assign_L46_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98835:ClassDef_L41_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98835:Assign_L47_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98835:ClassDef_L41_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98835:FunctionDef_L49_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98835:FunctionDef_L49_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98835:If_L50_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98835:If_L50_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98835:Assign_L51_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98835:If_L50_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98835:Return_L52_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98835:If_L50_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98835:If_L53_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98835:If_L53_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98835:Assign_L54_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98835:If_L53_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98835:Return_L55_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98835:If_L53_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98835:If_L56_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98835:If_L56_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98835:Return_L57_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98835:If_L56_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98835:If_L58_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98835:If_L58_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98835:Return_L59_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98835:If_L58_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98835:Return_L61_C12"}]
""" XML serializer. """ from django.conf import settings from django.core.serializers import base from django.db import models, DEFAULT_DB_ALIAS from django.utils.xmlutils import SimplerXMLGenerator from django.utils.encoding import smart_unicode from xml.dom import pulldom class Serializer(base.Serializer): """ Serializes a QuerySet to XML. """ def indent(self, level): if self.options.get('indent', None) is not None: self.xml.ignorableWhitespace('\n' + ' ' * self.options.get('indent', None) * level) def start_serialization(self): """ Start serialization -- open the XML document and the root element. """ self.xml = SimplerXMLGenerator(self.stream, self.options.get("encoding", settings.DEFAULT_CHARSET)) self.xml.startDocument() self.xml.startElement("django-objects", {"version" : "1.0"}) def end_serialization(self): """ End serialization -- end the document. """ self.indent(0) self.xml.endElement("django-objects") self.xml.endDocument() def start_object(self, obj): """ Called as each object is handled. """ if not hasattr(obj, "_meta"): raise base.SerializationError("Non-model object (%s) encountered during serialization" % type(obj)) self.indent(1) obj_pk = obj._get_pk_val() if obj_pk is None: attrs = {"model": smart_unicode(obj._meta),} else: attrs = { "pk": smart_unicode(obj._get_pk_val()), "model": smart_unicode(obj._meta), } self.xml.startElement("object", attrs) def end_object(self, obj): """ Called after handling all fields for an object. """ self.indent(1) self.xml.endElement("object") def handle_field(self, obj, field): """ Called to handle each field on an object (except for ForeignKeys and ManyToManyFields) """ self.indent(2) self.xml.startElement("field", { "name" : field.name, "type" : field.get_internal_type() }) # Get a "string version" of the object's data. if getattr(obj, field.name) is not None: self.xml.characters(field.value_to_string(obj)) else: self.xml.addQuickElement("None") self.xml.endElement("field") def handle_fk_field(self, obj, field): """ Called to handle a ForeignKey (we need to treat them slightly differently from regular fields). """ self._start_relational_field(field) related = getattr(obj, field.name) if related is not None: if self.use_natural_keys and hasattr(related, 'natural_key'): # If related object has a natural key, use it related = related.natural_key() # Iterable natural keys are rolled out as subelements for key_value in related: self.xml.startElement("natural", {}) self.xml.characters(smart_unicode(key_value)) self.xml.endElement("natural") else: if field.rel.field_name == related._meta.pk.name: # Related to remote object via primary key related = related._get_pk_val() else: # Related to remote object via other field related = getattr(related, field.rel.field_name) self.xml.characters(smart_unicode(related)) else: self.xml.addQuickElement("None") self.xml.endElement("field") def handle_m2m_field(self, obj, field): """ Called to handle a ManyToManyField. Related objects are only serialized as references to the object's PK (i.e. the related *data* is not dumped, just the relation). """ if field.rel.through._meta.auto_created: self._start_relational_field(field) if self.use_natural_keys and hasattr(field.rel.to, 'natural_key'): # If the objects in the m2m have a natural key, use it def handle_m2m(value): natural = value.natural_key() # Iterable natural keys are rolled out as subelements self.xml.startElement("object", {}) for key_value in natural: self.xml.startElement("natural", {}) self.xml.characters(smart_unicode(key_value)) self.xml.endElement("natural") self.xml.endElement("object") else: def handle_m2m(value): self.xml.addQuickElement("object", attrs={ 'pk' : smart_unicode(value._get_pk_val()) }) for relobj in getattr(obj, field.name).iterator(): handle_m2m(relobj) self.xml.endElement("field") def _start_relational_field(self, field): """ Helper to output the <field> element for relational fields """ self.indent(2) self.xml.startElement("field", { "name" : field.name, "rel" : field.rel.__class__.__name__, "to" : smart_unicode(field.rel.to._meta), }) class Deserializer(base.Deserializer): """ Deserialize XML. """ def __init__(self, stream_or_string, **options): super(Deserializer, self).__init__(stream_or_string, **options) self.event_stream = pulldom.parse(self.stream) self.db = options.pop('using', DEFAULT_DB_ALIAS) def next(self): for event, node in self.event_stream: if event == "START_ELEMENT" and node.nodeName == "object": self.event_stream.expandNode(node) return self._handle_object(node) raise StopIteration def _handle_object(self, node): """ Convert an <object> node to a DeserializedObject. """ # Look up the model using the model loading mechanism. If this fails, # bail. Model = self._get_model_from_node(node, "model") # Start building a data dictionary from the object. # If the node is missing the pk set it to None if node.hasAttribute("pk"): pk = node.getAttribute("pk") else: pk = None data = {Model._meta.pk.attname : Model._meta.pk.to_python(pk)} # Also start building a dict of m2m data (this is saved as # {m2m_accessor_attribute : [list_of_related_objects]}) m2m_data = {} # Deseralize each field. for field_node in node.getElementsByTagName("field"): # If the field is missing the name attribute, bail (are you # sensing a pattern here?) field_name = field_node.getAttribute("name") if not field_name: raise base.DeserializationError("<field> node is missing the 'name' attribute") # Get the field from the Model. This will raise a # FieldDoesNotExist if, well, the field doesn't exist, which will # be propagated correctly. field = Model._meta.get_field(field_name) # As is usually the case, relation fields get the special treatment. if field.rel and isinstance(field.rel, models.ManyToManyRel): m2m_data[field.name] = self._handle_m2m_field_node(field_node, field) elif field.rel and isinstance(field.rel, models.ManyToOneRel): data[field.attname] = self._handle_fk_field_node(field_node, field) else: if field_node.getElementsByTagName('None'): value = None else: value = field.to_python(getInnerText(field_node).strip()) data[field.name] = value # Return a DeserializedObject so that the m2m data has a place to live. return base.DeserializedObject(Model(**data), m2m_data) def _handle_fk_field_node(self, node, field): """ Handle a <field> node for a ForeignKey """ # Check if there is a child node named 'None', returning None if so. if node.getElementsByTagName('None'): return None else: if hasattr(field.rel.to._default_manager, 'get_by_natural_key'): keys = node.getElementsByTagName('natural') if keys: # If there are 'natural' subelements, it must be a natural key field_value = [getInnerText(k).strip() for k in keys] obj = field.rel.to._default_manager.db_manager(self.db).get_by_natural_key(*field_value) obj_pk = getattr(obj, field.rel.field_name) # If this is a natural foreign key to an object that # has a FK/O2O as the foreign key, use the FK value if field.rel.to._meta.pk.rel: obj_pk = obj_pk.pk else: # Otherwise, treat like a normal PK field_value = getInnerText(node).strip() obj_pk = field.rel.to._meta.get_field(field.rel.field_name).to_python(field_value) return obj_pk else: field_value = getInnerText(node).strip() return field.rel.to._meta.get_field(field.rel.field_name).to_python(field_value) def _handle_m2m_field_node(self, node, field): """ Handle a <field> node for a ManyToManyField. """ if hasattr(field.rel.to._default_manager, 'get_by_natural_key'): def m2m_convert(n): keys = n.getElementsByTagName('natural') if keys: # If there are 'natural' subelements, it must be a natural key field_value = [getInnerText(k).strip() for k in keys] obj_pk = field.rel.to._default_manager.db_manager(self.db).get_by_natural_key(*field_value).pk else: # Otherwise, treat like a normal PK value. obj_pk = field.rel.to._meta.pk.to_python(n.getAttribute('pk')) return obj_pk else: m2m_convert = lambda n: field.rel.to._meta.pk.to_python(n.getAttribute('pk')) return [m2m_convert(c) for c in node.getElementsByTagName("object")] def _get_model_from_node(self, node, attr): """ Helper to look up a model from a <object model=...> or a <field rel=... to=...> node. """ model_identifier = node.getAttribute(attr) if not model_identifier: raise base.DeserializationError( "<%s> node is missing the required '%s' attribute" \ % (node.nodeName, attr)) try: Model = models.get_model(*model_identifier.split(".")) except TypeError: Model = None if Model is None: raise base.DeserializationError( "<%s> node has invalid model identifier: '%s'" % \ (node.nodeName, model_identifier)) return Model def getInnerText(node): """ Get all the inner text of a DOM node (recursively). """ # inspired by http://mail.python.org/pipermail/xml-sig/2005-March/011022.html inner_text = [] for child in node.childNodes: if child.nodeType == child.TEXT_NODE or child.nodeType == child.CDATA_SECTION_NODE: inner_text.append(child.data) elif child.nodeType == child.ELEMENT_NODE: inner_text.extend(getInnerText(child)) else: pass return u"".join(inner_text)
ajibawa-2023/Python-Code-Large/train/row_98836
161
297
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_98836:Expr_L1_C0", "label": "expression", "type": "expression", "loc": [1, 3], "level": 0, "parent": null, "vector": [8, 0, 0.0067, 0.0101, 0, 0.66, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "\"\"\"\nXML serializer.\n\"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98836:ImportFrom_L5_C0", "label": "from django.conf import settings", "type": "import", "loc": [5, 5], "level": 0, "parent": null, "vector": [1, 0, 0.0168, 0.0034, 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_98836:ImportFrom_L6_C0", "label": "from django.core.serializers import base", "type": "import", "loc": [6, 6], "level": 0, "parent": null, "vector": [1, 0, 0.0202, 0.0034, 0, 0.66, 0.2222, 10, 0, 1, 0, 0, 10, 0, 0], "semantic": {"name": "django.core.serializers", "arg_names": [], "import_names": ["base"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.core.serializers import base"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98836:ImportFrom_L7_C0", "label": "from django.db import models, DEFAULT_DB_ALIAS", "type": "import", "loc": [7, 7], "level": 0, "parent": null, "vector": [1, 0, 0.0236, 0.0034, 0, 0.66, 0.3333, 40, 0, 2, 0, 0, 40, 0, 0], "semantic": {"name": "django.db", "arg_names": [], "import_names": ["models", "DEFAULT_DB_ALIAS"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.db import models, DEFAULT_DB_ALIAS"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98836:ImportFrom_L8_C0", "label": "from django.utils.xmlutils import SimplerXMLGenerator", "type": "import", "loc": [8, 8], "level": 0, "parent": null, "vector": [1, 0, 0.0269, 0.0034, 0, 0.66, 0.4444, 990, 0, 1, 0, 0, 990, 0, 0], "semantic": {"name": "django.utils.xmlutils", "arg_names": [], "import_names": ["SimplerXMLGenerator"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.utils.xmlutils import SimplerXMLGenerator"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98836:ImportFrom_L9_C0", "label": "from django.utils.encoding import smart_unicode", "type": "import", "loc": [9, 9], "level": 0, "parent": null, "vector": [1, 0, 0.0303, 0.0034, 0, 0.66, 0.5556, 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_98836:ImportFrom_L10_C0", "label": "from xml.dom import pulldom", "type": "import", "loc": [10, 10], "level": 0, "parent": null, "vector": [1, 0, 0.0337, 0.0034, 0, 0.66, 0.6667, 290, 0, 1, 0, 0, 290, 0, 0], "semantic": {"name": "xml.dom", "arg_names": [], "import_names": ["pulldom"], "rhs_call_name": "", "annotation": ""}, "snippet": "from xml.dom import pulldom"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98836:ClassDef_L12_C0", "label": "Serializer", "type": "class", "loc": [12, 148], "level": 0, "parent": null, "vector": [3, 0, 0.2694, 0.4613, 0, 0.66, 0.7778, 577, 0, 11, 0, 0, 160, 0, 63], "semantic": {"name": "Serializer", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class Serializer(base.Serializer):\n \"\"\"\n Serializes a QuerySet to XML.\n \"\"\"\n\n def indent(self, level):\n if self.options.get('indent', None) is not None:\n self.xml.ignorableWhitespace('\\n' + ' ' * self.options.get('indent', None) * level)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98836:Expr_L13_C4", "label": "expression", "type": "expression", "loc": [13, 15], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98836:ClassDef_L12_C0", "vector": [8, 1, 0.0471, 0.0101, 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 Serializes a QuerySet to XML.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98836:FunctionDef_L17_C4", "label": "indent", "type": "function", "loc": [17, 19], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98836:ClassDef_L12_C0", "vector": [2, 1, 0.0606, 0.0101, 1, 0.71, 0.1111, 231, 0, 2, 0, 0, 0, 0, 3], "semantic": {"name": "indent", "arg_names": ["self", "level"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def indent(self, level):\n if self.options.get('indent', None) is not None:\n self.xml.ignorableWhitespace('\\n' + ' ' * self.options.get('indent', None) * level)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98836:If_L18_C8", "label": "if", "type": "if", "loc": [18, 19], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98836:FunctionDef_L17_C4", "vector": [4, 2, 0.0623, 0.0067, 2, 0.66, 0.0, 0, 0, 0, 0, 0, 0, 0, 3], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if self.options.get('indent', None) is not None:\n self.xml.ignorableWhitespace('\\n' + ' ' * self.options.get('indent', None) * level)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98836:Expr_L19_C12", "label": "ignorableWhitespace()", "type": "expression", "loc": [19, 19], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98836:If_L18_C8", "vector": [8, 3, 0.064, 0.0034, 3, 0.83, 0.0, 104, 3, 1, 0, 0, 0, 0, 2], "semantic": {"name": "ignorableWhitespace", "arg_names": [], "import_names": [], "rhs_call_name": "ignorableWhitespace", "annotation": ""}, "snippet": " self.xml.ignorableWhitespace('\\n' + ' ' * self.options.get('indent', None) * level)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98836:FunctionDef_L21_C4", "label": "start_serialization", "type": "function", "loc": [21, 27], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98836:ClassDef_L12_C0", "vector": [2, 1, 0.0808, 0.0236, 1, 0.71, 0.2222, 476, 0, 1, 0, 0, 0, 0, 4], "semantic": {"name": "start_serialization", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def start_serialization(self):\n \"\"\"\n Start serialization -- open the XML document and the root element.\n \"\"\"\n self.xml = SimplerXMLGenerator(self.stream, self.options.get(\"encoding\", settings.DEFAULT_CHARSET))\n self.xml.startDocument()\n self.xml.startElement(\"django-objects\", {\"version\" : \"1.0\"})"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98836:Expr_L22_C8", "label": "expression", "type": "expression", "loc": [22, 24], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98836:FunctionDef_L21_C4", "vector": [8, 2, 0.0774, 0.0101, 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 Start serialization -- open the XML document and the root element.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98836:Assign_L25_C8", "label": "self.xml = SimplerXMLGenerator()", "type": "assigned_variable", "loc": [25, 25], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98836:FunctionDef_L21_C4", "vector": [14, 2, 0.0842, 0.0034, 2, 0.75, 0.3333, 20, 3, 2, 0, 0, 255, 10, 2], "semantic": {"name": "self.xml", "arg_names": [], "import_names": [], "rhs_call_name": "SimplerXMLGenerator", "annotation": ""}, "snippet": " self.xml = SimplerXMLGenerator(self.stream, self.options.get(\"encoding\", settings.DEFAULT_CHARSET))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98836:Expr_L26_C8", "label": "startDocument()", "type": "expression", "loc": [26, 26], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98836:FunctionDef_L21_C4", "vector": [8, 2, 0.0875, 0.0034, 2, 0.75, 0.6667, 326, 3, 0, 0, 0, 0, 0, 1], "semantic": {"name": "startDocument", "arg_names": [], "import_names": [], "rhs_call_name": "startDocument", "annotation": ""}, "snippet": " self.xml.startDocument()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98836:Expr_L27_C8", "label": "startElement()", "type": "expression", "loc": [27, 27], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98836:FunctionDef_L21_C4", "vector": [8, 2, 0.0909, 0.0034, 2, 0.75, 1.0, 862, 3, 2, 0, 0, 0, 0, 1], "semantic": {"name": "startElement", "arg_names": [], "import_names": [], "rhs_call_name": "startElement", "annotation": ""}, "snippet": " self.xml.startElement(\"django-objects\", {\"version\" : \"1.0\"})"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98836:FunctionDef_L29_C4", "label": "end_serialization", "type": "function", "loc": [29, 35], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98836:ClassDef_L12_C0", "vector": [2, 1, 0.1077, 0.0236, 1, 0.71, 0.3333, 673, 0, 1, 0, 0, 0, 0, 3], "semantic": {"name": "end_serialization", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def end_serialization(self):\n \"\"\"\n End serialization -- end the document.\n \"\"\"\n self.indent(0)\n self.xml.endElement(\"django-objects\")\n self.xml.endDocument()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98836:Expr_L30_C8", "label": "expression", "type": "expression", "loc": [30, 32], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98836:FunctionDef_L29_C4", "vector": [8, 2, 0.1044, 0.0101, 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 End serialization -- end the document.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98836:Expr_L33_C8", "label": "indent()", "type": "expression", "loc": [33, 33], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98836:FunctionDef_L29_C4", "vector": [8, 2, 0.1111, 0.0034, 2, 0.32, 0.3333, 231, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "indent", "arg_names": [], "import_names": [], "rhs_call_name": "indent", "annotation": ""}, "snippet": " self.indent(0)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98836:Expr_L34_C8", "label": "endElement()", "type": "expression", "loc": [34, 34], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98836:FunctionDef_L29_C4", "vector": [8, 2, 0.1145, 0.0034, 2, 0.32, 0.6667, 563, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "endElement", "arg_names": [], "import_names": [], "rhs_call_name": "endElement", "annotation": ""}, "snippet": " self.xml.endElement(\"django-objects\")"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98836:Expr_L35_C8", "label": "endDocument()", "type": "expression", "loc": [35, 35], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98836:FunctionDef_L29_C4", "vector": [8, 2, 0.1178, 0.0034, 2, 0.32, 1.0, 761, 3, 0, 0, 0, 0, 0, 1], "semantic": {"name": "endDocument", "arg_names": [], "import_names": [], "rhs_call_name": "endDocument", "annotation": ""}, "snippet": " self.xml.endDocument()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98836:FunctionDef_L37_C4", "label": "start_object", "type": "function", "loc": [37, 54], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98836:ClassDef_L12_C0", "vector": [2, 1, 0.1532, 0.0606, 1, 0.71, 0.4444, 939, 0, 2, 0, 0, 0, 0, 10], "semantic": {"name": "start_object", "arg_names": ["self", "obj"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def start_object(self, obj):\n \"\"\"\n Called as each object is handled.\n \"\"\"\n if not hasattr(obj, \"_meta\"):\n raise base.SerializationError(\"Non-model object (%s) encountered during serialization\" % type(obj))\n\n self.indent(1)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98836:Expr_L38_C8", "label": "expression", "type": "expression", "loc": [38, 40], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98836:FunctionDef_L37_C4", "vector": [8, 2, 0.1313, 0.0101, 2, 0.37, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"\n Called as each object is handled.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98836:If_L41_C8", "label": "if", "type": "if", "loc": [41, 42], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98836:FunctionDef_L37_C4", "vector": [4, 2, 0.1397, 0.0067, 2, 0.37, 0.2, 0, 0, 0, 0, 0, 0, 0, 3], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if not hasattr(obj, \"_meta\"):\n raise base.SerializationError(\"Non-model object (%s) encountered during serialization\" % type(obj))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98836:Expr_L44_C8", "label": "indent()", "type": "expression", "loc": [44, 44], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98836:FunctionDef_L37_C4", "vector": [8, 2, 0.1481, 0.0034, 2, 0.37, 0.4, 231, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "indent", "arg_names": [], "import_names": [], "rhs_call_name": "indent", "annotation": ""}, "snippet": " self.indent(1)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98836:Assign_L45_C8", "label": "obj_pk = _get_pk_val()", "type": "assigned_variable", "loc": [45, 45], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98836:FunctionDef_L37_C4", "vector": [14, 2, 0.1515, 0.0034, 2, 0.37, 0.6, 190, 3, 0, 0, 0, 743, 10, 1], "semantic": {"name": "obj_pk", "arg_names": [], "import_names": [], "rhs_call_name": "_get_pk_val", "annotation": ""}, "snippet": " obj_pk = obj._get_pk_val()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98836:If_L46_C8", "label": "if", "type": "if", "loc": [46, 52], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98836:FunctionDef_L37_C4", "vector": [4, 2, 0.165, 0.0236, 2, 0.37, 0.8, 0, 0, 0, 0, 0, 0, 0, 4], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if obj_pk is None:\n attrs = {\"model\": smart_unicode(obj._meta),}\n else:\n attrs = {\n \"pk\": smart_unicode(obj._get_pk_val()),\n \"model\": smart_unicode(obj._meta),\n }"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98836:Assign_L47_C12", "label": "attrs =", "type": "assigned_variable", "loc": [47, 47], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98836:If_L46_C8", "vector": [14, 3, 0.1582, 0.0034, 3, 0.55, 0.0, 251, 0, 0, 0, 0, 0, 6, 1], "semantic": {"name": "attrs", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " attrs = {\"model\": smart_unicode(obj._meta),}"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98836:Assign_L49_C12", "label": "attrs =", "type": "assigned_variable", "loc": [49, 52], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98836:If_L46_C8", "vector": [14, 3, 0.17, 0.0135, 3, 0.55, 1.0, 251, 0, 0, 0, 0, 0, 6, 3], "semantic": {"name": "attrs", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " attrs = {\n \"pk\": smart_unicode(obj._get_pk_val()),\n \"model\": smart_unicode(obj._meta),\n }"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98836:Expr_L54_C8", "label": "startElement()", "type": "expression", "loc": [54, 54], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98836:FunctionDef_L37_C4", "vector": [8, 2, 0.1818, 0.0034, 2, 0.37, 1.0, 862, 3, 2, 0, 0, 0, 0, 1], "semantic": {"name": "startElement", "arg_names": [], "import_names": [], "rhs_call_name": "startElement", "annotation": ""}, "snippet": " self.xml.startElement(\"object\", attrs)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98836:FunctionDef_L56_C4", "label": "end_object", "type": "function", "loc": [56, 61], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98836:ClassDef_L12_C0", "vector": [2, 1, 0.197, 0.0202, 1, 0.71, 0.5556, 857, 0, 2, 0, 0, 0, 0, 2], "semantic": {"name": "end_object", "arg_names": ["self", "obj"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def end_object(self, obj):\n \"\"\"\n Called after handling all fields for an object.\n \"\"\"\n self.indent(1)\n self.xml.endElement(\"object\")"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98836:Expr_L57_C8", "label": "expression", "type": "expression", "loc": [57, 59], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98836:FunctionDef_L56_C4", "vector": [8, 2, 0.1953, 0.0101, 2, 0.55, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"\n Called after handling all fields for an object.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98836:Expr_L60_C8", "label": "indent()", "type": "expression", "loc": [60, 60], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98836:FunctionDef_L56_C4", "vector": [8, 2, 0.202, 0.0034, 2, 0.55, 0.5, 231, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "indent", "arg_names": [], "import_names": [], "rhs_call_name": "indent", "annotation": ""}, "snippet": " self.indent(1)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98836:Expr_L61_C8", "label": "endElement()", "type": "expression", "loc": [61, 61], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98836:FunctionDef_L56_C4", "vector": [8, 2, 0.2054, 0.0034, 2, 0.55, 1.0, 563, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "endElement", "arg_names": [], "import_names": [], "rhs_call_name": "endElement", "annotation": ""}, "snippet": " self.xml.endElement(\"object\")"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98836:FunctionDef_L63_C4", "label": "handle_field", "type": "function", "loc": [63, 80], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98836:ClassDef_L12_C0", "vector": [2, 1, 0.2407, 0.0606, 1, 0.71, 0.6667, 277, 0, 3, 0, 0, 0, 0, 8], "semantic": {"name": "handle_field", "arg_names": ["self", "obj", "field"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def handle_field(self, obj, field):\n \"\"\"\n Called to handle each field on an object (except for ForeignKeys and\n ManyToManyFields)\n \"\"\"\n self.indent(2)\n self.xml.startElement(\"field\", {\n \"name\" : field.name,"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98836:Expr_L64_C8", "label": "expression", "type": "expression", "loc": [64, 67], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98836:FunctionDef_L63_C4", "vector": [8, 2, 0.2205, 0.0135, 2, 0.51, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"\n Called to handle each field on an object (except for ForeignKeys and\n ManyToManyFields)\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98836:Expr_L68_C8", "label": "indent()", "type": "expression", "loc": [68, 68], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98836:FunctionDef_L63_C4", "vector": [8, 2, 0.229, 0.0034, 2, 0.51, 0.25, 231, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "indent", "arg_names": [], "import_names": [], "rhs_call_name": "indent", "annotation": ""}, "snippet": " self.indent(2)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98836:Expr_L69_C8", "label": "startElement()", "type": "expression", "loc": [69, 72], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98836:FunctionDef_L63_C4", "vector": [8, 2, 0.2374, 0.0135, 2, 0.51, 0.5, 862, 3, 2, 0, 0, 0, 0, 2], "semantic": {"name": "startElement", "arg_names": [], "import_names": [], "rhs_call_name": "startElement", "annotation": ""}, "snippet": " self.xml.startElement(\"field\", {\n \"name\" : field.name,\n \"type\" : field.get_internal_type()\n })"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98836:If_L75_C8", "label": "if", "type": "if", "loc": [75, 78], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98836:FunctionDef_L63_C4", "vector": [4, 2, 0.2576, 0.0135, 2, 0.51, 0.75, 0, 0, 0, 0, 0, 0, 0, 4], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if getattr(obj, field.name) is not None:\n self.xml.characters(field.value_to_string(obj))\n else:\n self.xml.addQuickElement(\"None\")"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98836:Expr_L76_C12", "label": "characters()", "type": "expression", "loc": [76, 76], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98836:If_L75_C8", "vector": [8, 3, 0.2559, 0.0034, 3, 0.88, 0.0, 731, 3, 1, 0, 0, 0, 0, 2], "semantic": {"name": "characters", "arg_names": [], "import_names": [], "rhs_call_name": "characters", "annotation": ""}, "snippet": " self.xml.characters(field.value_to_string(obj))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98836:Expr_L78_C12", "label": "addQuickElement()", "type": "expression", "loc": [78, 78], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98836:If_L75_C8", "vector": [8, 3, 0.2626, 0.0034, 3, 0.88, 1.0, 928, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "addQuickElement", "arg_names": [], "import_names": [], "rhs_call_name": "addQuickElement", "annotation": ""}, "snippet": " self.xml.addQuickElement(\"None\")"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98836:Expr_L80_C8", "label": "endElement()", "type": "expression", "loc": [80, 80], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98836:FunctionDef_L63_C4", "vector": [8, 2, 0.2694, 0.0034, 2, 0.51, 1.0, 563, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "endElement", "arg_names": [], "import_names": [], "rhs_call_name": "endElement", "annotation": ""}, "snippet": " self.xml.endElement(\"field\")"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98836:FunctionDef_L82_C4", "label": "handle_fk_field", "type": "function", "loc": [82, 108], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98836:ClassDef_L12_C0", "vector": [2, 1, 0.3199, 0.0909, 1, 0.71, 0.7778, 279, 0, 3, 0, 0, 0, 0, 14], "semantic": {"name": "handle_fk_field", "arg_names": ["self", "obj", "field"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def handle_fk_field(self, obj, field):\n \"\"\"\n Called to handle a ForeignKey (we need to treat them slightly\n differently from regular fields).\n \"\"\"\n self._start_relational_field(field)\n related = getattr(obj, field.name)\n if related is not None:"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98836:Expr_L83_C8", "label": "expression", "type": "expression", "loc": [83, 86], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98836:FunctionDef_L82_C4", "vector": [8, 2, 0.2845, 0.0135, 2, 0.18, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"\n Called to handle a ForeignKey (we need to treat them slightly\n differently from regular fields).\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98836:Expr_L87_C8", "label": "_start_relational_field()", "type": "expression", "loc": [87, 87], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98836:FunctionDef_L82_C4", "vector": [8, 2, 0.2929, 0.0034, 2, 0.18, 0.25, 605, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "_start_relational_field", "arg_names": [], "import_names": [], "rhs_call_name": "_start_relational_field", "annotation": ""}, "snippet": " self._start_relational_field(field)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98836:Assign_L88_C8", "label": "related = getattr()", "type": "assigned_variable", "loc": [88, 88], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98836:FunctionDef_L82_C4", "vector": [14, 2, 0.2963, 0.0034, 2, 0.18, 0.5, 462, 3, 2, 0, 0, 121, 10, 1], "semantic": {"name": "related", "arg_names": [], "import_names": [], "rhs_call_name": "getattr", "annotation": ""}, "snippet": " related = getattr(obj, field.name)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98836:If_L89_C8", "label": "if", "type": "if", "loc": [89, 107], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98836:FunctionDef_L82_C4", "vector": [4, 2, 0.33, 0.064, 2, 0.18, 0.75, 0, 0, 0, 0, 0, 0, 0, 11], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if related is not None:\n if self.use_natural_keys and hasattr(related, 'natural_key'):\n # If related object has a natural key, use it\n related = related.natural_key()\n # Iterable natural keys are rolled out as subelements\n for key_value in related:\n self.xml.startElement(\"natural\", {})\n self.xml.characters(smart_unicode(key_value))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98836:If_L90_C12", "label": "if", "type": "if", "loc": [90, 105], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98836:If_L89_C8", "vector": [4, 3, 0.3283, 0.0539, 3, 0.98, 0.0, 0, 0, 0, 0, 0, 0, 0, 10], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if self.use_natural_keys and hasattr(related, 'natural_key'):\n # If related object has a natural key, use it\n related = related.natural_key()\n # Iterable natural keys are rolled out as subelements\n for key_value in related:\n self.xml.startElement(\"natural\", {})\n self.xml.characters(smart_unicode(key_value))\n self.xml.endElement(\"natural\")"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98836:Assign_L92_C16", "label": "related = natural_key()", "type": "assigned_variable", "loc": [92, 92], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98836:If_L90_C12", "vector": [14, 4, 0.3098, 0.0034, 4, 0.48, 0.0, 462, 3, 0, 0, 0, 449, 10, 1], "semantic": {"name": "related", "arg_names": [], "import_names": [], "rhs_call_name": "natural_key", "annotation": ""}, "snippet": " related = related.natural_key()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98836:For_L94_C16", "label": "for key_value", "type": "for", "loc": [94, 97], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98836:If_L90_C12", "vector": [6, 4, 0.3215, 0.0135, 4, 0.48, 0.3333, 519, 2, 0, 0, 0, 0, 0, 4], "semantic": {"name": "key_value", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for key_value in related:\n self.xml.startElement(\"natural\", {})\n self.xml.characters(smart_unicode(key_value))\n self.xml.endElement(\"natural\")"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98836:Expr_L95_C20", "label": "startElement()", "type": "expression", "loc": [95, 95], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98836:For_L94_C16", "vector": [8, 5, 0.3199, 0.0034, 5, 0.0, 0.0, 862, 3, 2, 0, 0, 0, 0, 1], "semantic": {"name": "startElement", "arg_names": [], "import_names": [], "rhs_call_name": "startElement", "annotation": ""}, "snippet": " self.xml.startElement(\"natural\", {})"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98836:Expr_L96_C20", "label": "characters()", "type": "expression", "loc": [96, 96], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98836:For_L94_C16", "vector": [8, 5, 0.3232, 0.0034, 5, 0.0, 0.5, 731, 3, 1, 0, 0, 0, 0, 2], "semantic": {"name": "characters", "arg_names": [], "import_names": [], "rhs_call_name": "characters", "annotation": ""}, "snippet": " self.xml.characters(smart_unicode(key_value))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98836:Expr_L97_C20", "label": "endElement()", "type": "expression", "loc": [97, 97], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98836:For_L94_C16", "vector": [8, 5, 0.3266, 0.0034, 5, 0.0, 1.0, 563, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "endElement", "arg_names": [], "import_names": [], "rhs_call_name": "endElement", "annotation": ""}, "snippet": " self.xml.endElement(\"natural\")"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98836:If_L99_C16", "label": "if", "type": "if", "loc": [99, 104], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98836:If_L90_C12", "vector": [4, 4, 0.3418, 0.0202, 4, 0.48, 0.6667, 0, 0, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if field.rel.field_name == related._meta.pk.name:\n # Related to remote object via primary key\n related = related._get_pk_val()\n else:\n # Related to remote object via other field\n related = getattr(related, field.rel.field_name)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98836:Assign_L101_C20", "label": "related = _get_pk_val()", "type": "assigned_variable", "loc": [101, 101], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98836:If_L99_C16", "vector": [14, 5, 0.3401, 0.0034, 5, 0.65, 0.0, 462, 3, 0, 0, 0, 743, 10, 1], "semantic": {"name": "related", "arg_names": [], "import_names": [], "rhs_call_name": "_get_pk_val", "annotation": ""}, "snippet": " related = related._get_pk_val()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98836:Assign_L104_C20", "label": "related = getattr()", "type": "assigned_variable", "loc": [104, 104], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98836:If_L99_C16", "vector": [14, 5, 0.3502, 0.0034, 5, 0.65, 1.0, 462, 3, 2, 0, 0, 121, 10, 1], "semantic": {"name": "related", "arg_names": [], "import_names": [], "rhs_call_name": "getattr", "annotation": ""}, "snippet": " related = getattr(related, field.rel.field_name)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98836:Expr_L105_C16", "label": "characters()", "type": "expression", "loc": [105, 105], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98836:If_L90_C12", "vector": [8, 4, 0.3535, 0.0034, 4, 0.48, 1.0, 731, 3, 1, 0, 0, 0, 0, 2], "semantic": {"name": "characters", "arg_names": [], "import_names": [], "rhs_call_name": "characters", "annotation": ""}, "snippet": " self.xml.characters(smart_unicode(related))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98836:Expr_L107_C12", "label": "addQuickElement()", "type": "expression", "loc": [107, 107], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98836:If_L89_C8", "vector": [8, 3, 0.3603, 0.0034, 3, 0.98, 1.0, 928, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "addQuickElement", "arg_names": [], "import_names": [], "rhs_call_name": "addQuickElement", "annotation": ""}, "snippet": " self.xml.addQuickElement(\"None\")"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98836:Expr_L108_C8", "label": "endElement()", "type": "expression", "loc": [108, 108], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98836:FunctionDef_L82_C4", "vector": [8, 2, 0.3636, 0.0034, 2, 0.18, 1.0, 563, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "endElement", "arg_names": [], "import_names": [], "rhs_call_name": "endElement", "annotation": ""}, "snippet": " self.xml.endElement(\"field\")"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98836:FunctionDef_L110_C4", "label": "handle_m2m_field", "type": "function", "loc": [110, 137], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98836:ClassDef_L12_C0", "vector": [2, 1, 0.4158, 0.0943, 1, 0.71, 0.8889, 261, 0, 3, 0, 0, 0, 0, 16], "semantic": {"name": "handle_m2m_field", "arg_names": ["self", "obj", "field"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def handle_m2m_field(self, obj, field):\n \"\"\"\n Called to handle a ManyToManyField. Related objects are only\n serialized as references to the object's PK (i.e. the related *data*\n is not dumped, just the relation).\n \"\"\"\n if field.rel.through._meta.auto_created:\n self._start_relational_field(field)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98836:Expr_L111_C8", "label": "expression", "type": "expression", "loc": [111, 115], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98836:FunctionDef_L110_C4", "vector": [8, 2, 0.3805, 0.0168, 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 Called to handle a ManyToManyField. Related objects are only\n serialized as references to the object's PK (i.e. the related *data*\n is not dumped, just the relation).\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98836:If_L116_C8", "label": "if", "type": "if", "loc": [116, 137], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98836:FunctionDef_L110_C4", "vector": [4, 2, 0.4259, 0.0741, 2, 0.02, 1.0, 0, 7, 0, 0, 0, 0, 0, 16], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if field.rel.through._meta.auto_created:\n self._start_relational_field(field)\n if self.use_natural_keys and hasattr(field.rel.to, 'natural_key'):\n # If the objects in the m2m have a natural key, use it\n def handle_m2m(value):\n natural = value.natural_key()\n # Iterable natural keys are rolled out as subelements\n self.xml.startElement(\"object\", {})"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98836:Expr_L117_C12", "label": "_start_relational_field()", "type": "expression", "loc": [117, 117], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98836:If_L116_C8", "vector": [8, 3, 0.3939, 0.0034, 3, 0.09, 0.0, 605, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "_start_relational_field", "arg_names": [], "import_names": [], "rhs_call_name": "_start_relational_field", "annotation": ""}, "snippet": " self._start_relational_field(field)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98836:If_L118_C12", "label": "if", "type": "if", "loc": [118, 133], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98836:If_L116_C8", "vector": [4, 3, 0.4226, 0.0539, 3, 0.09, 0.3333, 0, 0, 0, 0, 0, 0, 0, 11], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if self.use_natural_keys and hasattr(field.rel.to, 'natural_key'):\n # If the objects in the m2m have a natural key, use it\n def handle_m2m(value):\n natural = value.natural_key()\n # Iterable natural keys are rolled out as subelements\n self.xml.startElement(\"object\", {})\n for key_value in natural:\n self.xml.startElement(\"natural\", {})"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98836:FunctionDef_L120_C16", "label": "handle_m2m", "type": "function", "loc": [120, 128], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98836:If_L118_C12", "vector": [2, 4, 0.4175, 0.0303, 4, 0.63, 0.0, 234, 0, 1, 0, 0, 0, 0, 7], "semantic": {"name": "handle_m2m", "arg_names": ["value"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def handle_m2m(value):\n natural = value.natural_key()\n # Iterable natural keys are rolled out as subelements\n self.xml.startElement(\"object\", {})\n for key_value in natural:\n self.xml.startElement(\"natural\", {})\n self.xml.characters(smart_unicode(key_value))\n self.xml.endElement(\"natural\")"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98836:Assign_L121_C20", "label": "natural = natural_key()", "type": "assigned_variable", "loc": [121, 121], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98836:FunctionDef_L120_C16", "vector": [14, 5, 0.4074, 0.0034, 5, 0.96, 0.0, 98, 3, 0, 0, 0, 449, 10, 1], "semantic": {"name": "natural", "arg_names": [], "import_names": [], "rhs_call_name": "natural_key", "annotation": ""}, "snippet": " natural = value.natural_key()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98836:Expr_L123_C20", "label": "startElement()", "type": "expression", "loc": [123, 123], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98836:FunctionDef_L120_C16", "vector": [8, 5, 0.4141, 0.0034, 5, 0.96, 0.3333, 862, 3, 2, 0, 0, 0, 0, 1], "semantic": {"name": "startElement", "arg_names": [], "import_names": [], "rhs_call_name": "startElement", "annotation": ""}, "snippet": " self.xml.startElement(\"object\", {})"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98836:For_L124_C20", "label": "for key_value", "type": "for", "loc": [124, 127], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98836:FunctionDef_L120_C16", "vector": [6, 5, 0.4226, 0.0135, 5, 0.96, 0.6667, 519, 2, 0, 0, 0, 0, 0, 4], "semantic": {"name": "key_value", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for key_value in natural:\n self.xml.startElement(\"natural\", {})\n self.xml.characters(smart_unicode(key_value))\n self.xml.endElement(\"natural\")"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98836:Expr_L125_C24", "label": "startElement()", "type": "expression", "loc": [125, 125], "level": 6, "parent": "ajibawa-2023/Python-Code-Large/train/row_98836:For_L124_C20", "vector": [8, 6, 0.4209, 0.0034, 6, 0.74, 0.0, 862, 3, 2, 0, 0, 0, 0, 1], "semantic": {"name": "startElement", "arg_names": [], "import_names": [], "rhs_call_name": "startElement", "annotation": ""}, "snippet": " self.xml.startElement(\"natural\", {})"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98836:Expr_L126_C24", "label": "characters()", "type": "expression", "loc": [126, 126], "level": 6, "parent": "ajibawa-2023/Python-Code-Large/train/row_98836:For_L124_C20", "vector": [8, 6, 0.4242, 0.0034, 6, 0.74, 0.5, 731, 3, 1, 0, 0, 0, 0, 2], "semantic": {"name": "characters", "arg_names": [], "import_names": [], "rhs_call_name": "characters", "annotation": ""}, "snippet": " self.xml.characters(smart_unicode(key_value))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98836:Expr_L127_C24", "label": "endElement()", "type": "expression", "loc": [127, 127], "level": 6, "parent": "ajibawa-2023/Python-Code-Large/train/row_98836:For_L124_C20", "vector": [8, 6, 0.4276, 0.0034, 6, 0.74, 1.0, 563, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "endElement", "arg_names": [], "import_names": [], "rhs_call_name": "endElement", "annotation": ""}, "snippet": " self.xml.endElement(\"natural\")"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98836:Expr_L128_C20", "label": "endElement()", "type": "expression", "loc": [128, 128], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98836:FunctionDef_L120_C16", "vector": [8, 5, 0.431, 0.0034, 5, 0.96, 1.0, 563, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "endElement", "arg_names": [], "import_names": [], "rhs_call_name": "endElement", "annotation": ""}, "snippet": " self.xml.endElement(\"object\")"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98836:FunctionDef_L130_C16", "label": "handle_m2m", "type": "function", "loc": [130, 133], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98836:If_L118_C12", "vector": [2, 4, 0.4428, 0.0135, 4, 0.63, 1.0, 234, 0, 1, 0, 0, 0, 0, 3], "semantic": {"name": "handle_m2m", "arg_names": ["value"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def handle_m2m(value):\n self.xml.addQuickElement(\"object\", attrs={\n 'pk' : smart_unicode(value._get_pk_val())\n })"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98836:Expr_L131_C20", "label": "addQuickElement()", "type": "expression", "loc": [131, 133], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98836:FunctionDef_L130_C16", "vector": [8, 5, 0.4444, 0.0101, 5, 0.83, 0.0, 928, 3, 2, 0, 0, 0, 0, 3], "semantic": {"name": "addQuickElement", "arg_names": [], "import_names": [], "rhs_call_name": "addQuickElement", "annotation": ""}, "snippet": " self.xml.addQuickElement(\"object\", attrs={\n 'pk' : smart_unicode(value._get_pk_val())\n })"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98836:For_L134_C12", "label": "for relobj", "type": "for", "loc": [134, 135], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98836:If_L116_C8", "vector": [6, 3, 0.4529, 0.0067, 3, 0.09, 0.6667, 713, 3, 0, 0, 0, 0, 0, 3], "semantic": {"name": "relobj", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for relobj in getattr(obj, field.name).iterator():\n handle_m2m(relobj)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98836:Expr_L135_C16", "label": "handle_m2m()", "type": "expression", "loc": [135, 135], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98836:For_L134_C12", "vector": [8, 4, 0.4545, 0.0034, 4, 0.48, 0.0, 234, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "handle_m2m", "arg_names": [], "import_names": [], "rhs_call_name": "handle_m2m", "annotation": ""}, "snippet": " handle_m2m(relobj)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98836:Expr_L137_C12", "label": "endElement()", "type": "expression", "loc": [137, 137], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98836:If_L116_C8", "vector": [8, 3, 0.4613, 0.0034, 3, 0.09, 1.0, 563, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "endElement", "arg_names": [], "import_names": [], "rhs_call_name": "endElement", "annotation": ""}, "snippet": " self.xml.endElement(\"field\")"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98836:FunctionDef_L139_C4", "label": "_start_relational_field", "type": "function", "loc": [139, 148], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98836:ClassDef_L12_C0", "vector": [2, 1, 0.4832, 0.0337, 1, 0.71, 1.0, 605, 0, 2, 0, 0, 0, 0, 3], "semantic": {"name": "_start_relational_field", "arg_names": ["self", "field"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def _start_relational_field(self, field):\n \"\"\"\n Helper to output the <field> element for relational fields\n \"\"\"\n self.indent(2)\n self.xml.startElement(\"field\", {\n \"name\" : field.name,\n \"rel\" : field.rel.__class__.__name__,"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98836:Expr_L140_C8", "label": "expression", "type": "expression", "loc": [140, 142], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98836:FunctionDef_L139_C4", "vector": [8, 2, 0.4747, 0.0101, 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 Helper to output the <field> element for relational fields\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98836:Expr_L143_C8", "label": "indent()", "type": "expression", "loc": [143, 143], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98836:FunctionDef_L139_C4", "vector": [8, 2, 0.4815, 0.0034, 2, 0.48, 0.5, 231, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "indent", "arg_names": [], "import_names": [], "rhs_call_name": "indent", "annotation": ""}, "snippet": " self.indent(2)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98836:Expr_L144_C8", "label": "startElement()", "type": "expression", "loc": [144, 148], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98836:FunctionDef_L139_C4", "vector": [8, 2, 0.4916, 0.0168, 2, 0.48, 1.0, 862, 3, 2, 0, 0, 0, 0, 2], "semantic": {"name": "startElement", "arg_names": [], "import_names": [], "rhs_call_name": "startElement", "annotation": ""}, "snippet": " self.xml.startElement(\"field\", {\n \"name\" : field.name,\n \"rel\" : field.rel.__class__.__name__,\n \"to\" : smart_unicode(field.rel.to._meta),\n })"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98836:ClassDef_L150_C0", "label": "Deserializer", "type": "class", "loc": [150, 281], "level": 0, "parent": null, "vector": [3, 0, 0.7256, 0.4444, 0, 0.66, 0.8889, 604, 0, 7, 0, 0, 420, 0, 57], "semantic": {"name": "Deserializer", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class Deserializer(base.Deserializer):\n \"\"\"\n Deserialize XML.\n \"\"\"\n\n def __init__(self, stream_or_string, **options):\n super(Deserializer, self).__init__(stream_or_string, **options)\n self.event_stream = pulldom.parse(self.stream)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98836:Expr_L151_C4", "label": "expression", "type": "expression", "loc": [151, 153], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98836:ClassDef_L150_C0", "vector": [8, 1, 0.5118, 0.0101, 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 Deserialize XML.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98836:FunctionDef_L155_C4", "label": "__init__", "type": "function", "loc": [155, 158], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98836:ClassDef_L150_C0", "vector": [2, 1, 0.5269, 0.0135, 1, 0.55, 0.1667, 555, 0, 3, 0, 0, 0, 0, 4], "semantic": {"name": "__init__", "arg_names": ["self", "stream_or_string", "options"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def __init__(self, stream_or_string, **options):\n super(Deserializer, self).__init__(stream_or_string, **options)\n self.event_stream = pulldom.parse(self.stream)\n self.db = options.pop('using', DEFAULT_DB_ALIAS)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98836:Expr_L156_C8", "label": "__init__()", "type": "expression", "loc": [156, 156], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98836:FunctionDef_L155_C4", "vector": [8, 2, 0.5253, 0.0034, 2, 0.38, 0.0, 555, 3, 2, 0, 0, 0, 0, 2], "semantic": {"name": "__init__", "arg_names": [], "import_names": [], "rhs_call_name": "__init__", "annotation": ""}, "snippet": " super(Deserializer, self).__init__(stream_or_string, **options)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98836:Assign_L157_C8", "label": "self.event_stream = parse()", "type": "assigned_variable", "loc": [157, 157], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98836:FunctionDef_L155_C4", "vector": [14, 2, 0.5286, 0.0034, 2, 0.38, 0.5, 450, 3, 1, 0, 0, 678, 10, 1], "semantic": {"name": "self.event_stream", "arg_names": [], "import_names": [], "rhs_call_name": "parse", "annotation": ""}, "snippet": " self.event_stream = pulldom.parse(self.stream)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98836:Assign_L158_C8", "label": "self.db = pop()", "type": "assigned_variable", "loc": [158, 158], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98836:FunctionDef_L155_C4", "vector": [14, 2, 0.532, 0.0034, 2, 0.38, 1.0, 990, 3, 2, 0, 0, 969, 10, 1], "semantic": {"name": "self.db", "arg_names": [], "import_names": [], "rhs_call_name": "pop", "annotation": ""}, "snippet": " self.db = options.pop('using', DEFAULT_DB_ALIAS)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98836:FunctionDef_L160_C4", "label": "next", "type": "function", "loc": [160, 165], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98836:ClassDef_L150_C0", "vector": [2, 1, 0.5471, 0.0202, 1, 0.55, 0.3333, 11, 0, 1, 1, 0, 0, 0, 2], "semantic": {"name": "next", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def next(self):\n for event, node in self.event_stream:\n if event == \"START_ELEMENT\" and node.nodeName == \"object\":\n self.event_stream.expandNode(node)\n return self._handle_object(node)\n raise StopIteration"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98836:For_L161_C8", "label": "for event, node", "type": "for", "loc": [161, 164], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98836:FunctionDef_L160_C4", "vector": [6, 2, 0.5471, 0.0135, 2, 0.29, 0.0, 207, 7, 0, 0, 0, 0, 0, 2], "semantic": {"name": "event, node", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for event, node in self.event_stream:\n if event == \"START_ELEMENT\" and node.nodeName == \"object\":\n self.event_stream.expandNode(node)\n return self._handle_object(node)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98836:If_L162_C12", "label": "if", "type": "if", "loc": [162, 164], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98836:For_L161_C8", "vector": [4, 3, 0.5488, 0.0101, 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 event == \"START_ELEMENT\" and node.nodeName == \"object\":\n self.event_stream.expandNode(node)\n return self._handle_object(node)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98836:Expr_L163_C16", "label": "expandNode()", "type": "expression", "loc": [163, 163], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98836:If_L162_C12", "vector": [8, 4, 0.5488, 0.0034, 4, 0.0, 0.0, 985, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "expandNode", "arg_names": [], "import_names": [], "rhs_call_name": "expandNode", "annotation": ""}, "snippet": " self.event_stream.expandNode(node)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98836:Return_L164_C16", "label": "return", "type": "return", "loc": [164, 164], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98836:If_L162_C12", "vector": [13, 4, 0.5522, 0.0034, 4, 0.0, 1.0, 0, 3, 0, 0, 0, 0, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return self._handle_object(node)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98836:FunctionDef_L167_C4", "label": "_handle_object", "type": "function", "loc": [167, 214], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98836:ClassDef_L150_C0", "vector": [2, 1, 0.6414, 0.1616, 1, 0.55, 0.5, 366, 0, 2, 1, 0, 0, 0, 18], "semantic": {"name": "_handle_object", "arg_names": ["self", "node"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def _handle_object(self, node):\n \"\"\"\n Convert an <object> node to a DeserializedObject.\n \"\"\"\n # Look up the model using the model loading mechanism. If this fails,\n # bail.\n Model = self._get_model_from_node(node, \"model\")\n"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98836:Expr_L168_C8", "label": "expression", "type": "expression", "loc": [168, 170], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98836:FunctionDef_L167_C4", "vector": [8, 2, 0.569, 0.0101, 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 Convert an <object> node to a DeserializedObject.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98836:Assign_L173_C8", "label": "Model = _get_model_from_node()", "type": "assigned_variable", "loc": [173, 173], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98836:FunctionDef_L167_C4", "vector": [14, 2, 0.5825, 0.0034, 2, 0.47, 0.1667, 929, 3, 2, 0, 0, 683, 10, 1], "semantic": {"name": "Model", "arg_names": [], "import_names": [], "rhs_call_name": "_get_model_from_node", "annotation": ""}, "snippet": " Model = self._get_model_from_node(node, \"model\")"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98836:If_L177_C8", "label": "if", "type": "if", "loc": [177, 180], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98836:FunctionDef_L167_C4", "vector": [4, 2, 0.601, 0.0135, 2, 0.47, 0.3333, 0, 3, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if node.hasAttribute(\"pk\"):\n pk = node.getAttribute(\"pk\")\n else:\n pk = None"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98836:Assign_L178_C12", "label": "pk = getAttribute()", "type": "assigned_variable", "loc": [178, 178], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98836:If_L177_C8", "vector": [14, 3, 0.5993, 0.0034, 3, 0.26, 0.0, 164, 3, 1, 0, 0, 607, 10, 1], "semantic": {"name": "pk", "arg_names": [], "import_names": [], "rhs_call_name": "getAttribute", "annotation": ""}, "snippet": " pk = node.getAttribute(\"pk\")"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98836:Assign_L180_C12", "label": "pk =", "type": "assigned_variable", "loc": [180, 180], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98836:If_L177_C8", "vector": [14, 3, 0.6061, 0.0034, 3, 0.26, 1.0, 164, 1, 0, 0, 0, 0, 9, 0], "semantic": {"name": "pk", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " pk = None"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98836:Assign_L182_C8", "label": "data =", "type": "assigned_variable", "loc": [182, 182], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98836:FunctionDef_L167_C4", "vector": [14, 2, 0.6128, 0.0034, 2, 0.47, 0.5, 929, 0, 0, 0, 0, 0, 6, 1], "semantic": {"name": "data", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " data = {Model._meta.pk.attname : Model._meta.pk.to_python(pk)}"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98836:Assign_L186_C8", "label": "m2m_data =", "type": "assigned_variable", "loc": [186, 186], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98836:FunctionDef_L167_C4", "vector": [14, 2, 0.6263, 0.0034, 2, 0.47, 0.6667, 586, 0, 0, 0, 0, 0, 6, 0], "semantic": {"name": "m2m_data", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " m2m_data = {}"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98836:For_L189_C8", "label": "for field_node", "type": "for", "loc": [189, 211], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98836:FunctionDef_L167_C4", "vector": [6, 2, 0.6734, 0.0774, 2, 0.47, 0.8333, 228, 3, 0, 0, 0, 0, 0, 12], "semantic": {"name": "field_node", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for field_node in node.getElementsByTagName(\"field\"):\n # If the field is missing the name attribute, bail (are you\n # sensing a pattern here?)\n field_name = field_node.getAttribute(\"name\")\n if not field_name:\n raise base.DeserializationError(\"<field> node is missing the 'name' attribute\")\n\n # Get the field from the Model. This will raise a"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98836:Assign_L192_C12", "label": "field_name = getAttribute()", "type": "assigned_variable", "loc": [192, 192], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98836:For_L189_C8", "vector": [14, 3, 0.6465, 0.0034, 3, 0.12, 0.0, 918, 3, 1, 0, 0, 607, 10, 1], "semantic": {"name": "field_name", "arg_names": [], "import_names": [], "rhs_call_name": "getAttribute", "annotation": ""}, "snippet": " field_name = field_node.getAttribute(\"name\")"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98836:If_L193_C12", "label": "if", "type": "if", "loc": [193, 194], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98836:For_L189_C8", "vector": [4, 3, 0.6515, 0.0067, 3, 0.12, 0.3333, 0, 0, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if not field_name:\n raise base.DeserializationError(\"<field> node is missing the 'name' attribute\")"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98836:Assign_L199_C12", "label": "field = get_field()", "type": "assigned_variable", "loc": [199, 199], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98836:For_L189_C8", "vector": [14, 3, 0.67, 0.0034, 3, 0.12, 0.6667, 480, 3, 1, 0, 0, 389, 10, 1], "semantic": {"name": "field", "arg_names": [], "import_names": [], "rhs_call_name": "get_field", "annotation": ""}, "snippet": " field = Model._meta.get_field(field_name)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98836:If_L202_C12", "label": "if", "type": "if", "loc": [202, 211], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98836:For_L189_C8", "vector": [4, 3, 0.6953, 0.0337, 3, 0.12, 1.0, 0, 0, 0, 0, 0, 0, 0, 8], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if field.rel and isinstance(field.rel, models.ManyToManyRel):\n m2m_data[field.name] = self._handle_m2m_field_node(field_node, field)\n elif field.rel and isinstance(field.rel, models.ManyToOneRel):\n data[field.attname] = self._handle_fk_field_node(field_node, field)\n else:\n if field_node.getElementsByTagName('None'):\n value = None\n else:"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98836:Assign_L203_C16", "label": " = _handle_m2m_field_node()", "type": "assigned_variable", "loc": [203, 203], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98836:If_L202_C12", "vector": [14, 4, 0.6835, 0.0034, 4, 0.23, 0.0, 0, 3, 2, 0, 0, 483, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "_handle_m2m_field_node", "annotation": ""}, "snippet": " m2m_data[field.name] = self._handle_m2m_field_node(field_node, field)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98836:If_L204_C12", "label": "if", "type": "if", "loc": [204, 211], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98836:If_L202_C12", "vector": [4, 4, 0.6987, 0.0269, 4, 0.23, 1.0, 0, 0, 0, 0, 0, 0, 0, 6], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " elif field.rel and isinstance(field.rel, models.ManyToOneRel):\n data[field.attname] = self._handle_fk_field_node(field_node, field)\n else:\n if field_node.getElementsByTagName('None'):\n value = None\n else:\n value = field.to_python(getInnerText(field_node).strip())\n data[field.name] = value"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98836:Assign_L205_C16", "label": " = _handle_fk_field_node()", "type": "assigned_variable", "loc": [205, 205], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98836:If_L204_C12", "vector": [14, 5, 0.6902, 0.0034, 5, 0.51, 0.0, 0, 3, 2, 0, 0, 970, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "_handle_fk_field_node", "annotation": ""}, "snippet": " data[field.attname] = self._handle_fk_field_node(field_node, field)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98836:If_L207_C16", "label": "if", "type": "if", "loc": [207, 210], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98836:If_L204_C12", "vector": [4, 5, 0.702, 0.0135, 5, 0.51, 0.5, 0, 3, 0, 0, 0, 0, 0, 4], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if field_node.getElementsByTagName('None'):\n value = None\n else:\n value = field.to_python(getInnerText(field_node).strip())"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98836:Assign_L208_C20", "label": "value =", "type": "assigned_variable", "loc": [208, 208], "level": 6, "parent": "ajibawa-2023/Python-Code-Large/train/row_98836:If_L207_C16", "vector": [14, 6, 0.7003, 0.0034, 6, 0.96, 0.0, 441, 1, 0, 0, 0, 0, 9, 0], "semantic": {"name": "value", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " value = None"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98836:Assign_L210_C20", "label": "value = to_python()", "type": "assigned_variable", "loc": [210, 210], "level": 6, "parent": "ajibawa-2023/Python-Code-Large/train/row_98836:If_L207_C16", "vector": [14, 6, 0.7071, 0.0034, 6, 0.96, 1.0, 441, 3, 1, 0, 0, 800, 10, 3], "semantic": {"name": "value", "arg_names": [], "import_names": [], "rhs_call_name": "to_python", "annotation": ""}, "snippet": " value = field.to_python(getInnerText(field_node).strip())"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98836:Assign_L211_C16", "label": "assign", "type": "assigned_variable", "loc": [211, 211], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98836:If_L204_C12", "vector": [14, 5, 0.7104, 0.0034, 5, 0.51, 1.0, 0, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " data[field.name] = value"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98836:Return_L214_C8", "label": "return", "type": "return", "loc": [214, 214], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98836:FunctionDef_L167_C4", "vector": [13, 2, 0.7205, 0.0034, 2, 0.47, 1.0, 0, 3, 0, 0, 0, 0, 10, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return base.DeserializedObject(Model(**data), m2m_data)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98836:FunctionDef_L216_C4", "label": "_handle_fk_field_node", "type": "function", "loc": [216, 242], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98836:ClassDef_L150_C0", "vector": [2, 1, 0.771, 0.0909, 1, 0.55, 0.6667, 970, 0, 3, 1, 0, 0, 0, 16], "semantic": {"name": "_handle_fk_field_node", "arg_names": ["self", "node", "field"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def _handle_fk_field_node(self, node, field):\n \"\"\"\n Handle a <field> node for a ForeignKey\n \"\"\"\n # Check if there is a child node named 'None', returning None if so.\n if node.getElementsByTagName('None'):\n return None\n else:"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98836:Expr_L217_C8", "label": "expression", "type": "expression", "loc": [217, 219], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98836:FunctionDef_L216_C4", "vector": [8, 2, 0.734, 0.0101, 2, 0.83, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"\n Handle a <field> node for a ForeignKey\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98836:If_L221_C8", "label": "if", "type": "if", "loc": [221, 242], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98836:FunctionDef_L216_C4", "vector": [4, 2, 0.7795, 0.0741, 2, 0.83, 1.0, 0, 3, 0, 0, 0, 0, 0, 16], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if node.getElementsByTagName('None'):\n return None\n else:\n if hasattr(field.rel.to._default_manager, 'get_by_natural_key'):\n keys = node.getElementsByTagName('natural')\n if keys:\n # If there are 'natural' subelements, it must be a natural key\n field_value = [getInnerText(k).strip() for k in keys]"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98836:Return_L222_C12", "label": "return", "type": "return", "loc": [222, 222], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98836:If_L221_C8", "vector": [13, 3, 0.7475, 0.0034, 3, 0.56, 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_98836:If_L224_C12", "label": "if", "type": "if", "loc": [224, 242], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98836:If_L221_C8", "vector": [4, 3, 0.7845, 0.064, 3, 0.56, 1.0, 0, 3, 0, 0, 0, 0, 0, 15], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if hasattr(field.rel.to._default_manager, 'get_by_natural_key'):\n keys = node.getElementsByTagName('natural')\n if keys:\n # If there are 'natural' subelements, it must be a natural key\n field_value = [getInnerText(k).strip() for k in keys]\n obj = field.rel.to._default_manager.db_manager(self.db).get_by_natural_key(*field_value)\n obj_pk = getattr(obj, field.rel.field_name)\n # If this is a natural foreign key to an object that"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98836:Assign_L225_C16", "label": "keys = getElementsByTagName()", "type": "assigned_variable", "loc": [225, 225], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98836:If_L224_C12", "vector": [14, 4, 0.7576, 0.0034, 4, 0.2, 0.0, 204, 3, 1, 0, 0, 989, 10, 1], "semantic": {"name": "keys", "arg_names": [], "import_names": [], "rhs_call_name": "getElementsByTagName", "annotation": ""}, "snippet": " keys = node.getElementsByTagName('natural')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98836:If_L226_C16", "label": "if", "type": "if", "loc": [226, 238], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98836:If_L224_C12", "vector": [4, 4, 0.7811, 0.0438, 4, 0.2, 0.25, 0, 2, 0, 0, 0, 0, 0, 9], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if keys:\n # If there are 'natural' subelements, it must be a natural key\n field_value = [getInnerText(k).strip() for k in keys]\n obj = field.rel.to._default_manager.db_manager(self.db).get_by_natural_key(*field_value)\n obj_pk = getattr(obj, field.rel.field_name)\n # If this is a natural foreign key to an object that\n # has a FK/O2O as the foreign key, use the FK value\n if field.rel.to._meta.pk.rel:"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98836:Assign_L228_C20", "label": "field_value =", "type": "assigned_variable", "loc": [228, 228], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98836:If_L226_C16", "vector": [14, 5, 0.7677, 0.0034, 5, 0.09, 0.0, 900, 5, 0, 0, 0, 0, 0, 2], "semantic": {"name": "field_value", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " field_value = [getInnerText(k).strip() for k in keys]"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98836:Assign_L229_C20", "label": "obj = get_by_natural_key()", "type": "assigned_variable", "loc": [229, 229], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98836:If_L226_C16", "vector": [14, 5, 0.771, 0.0034, 5, 0.09, 0.2, 505, 3, 1, 0, 0, 668, 10, 2], "semantic": {"name": "obj", "arg_names": [], "import_names": [], "rhs_call_name": "get_by_natural_key", "annotation": ""}, "snippet": " obj = field.rel.to._default_manager.db_manager(self.db).get_by_natural_key(*field_value)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98836:Assign_L230_C20", "label": "obj_pk = getattr()", "type": "assigned_variable", "loc": [230, 230], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98836:If_L226_C16", "vector": [14, 5, 0.7744, 0.0034, 5, 0.09, 0.4, 190, 3, 2, 0, 0, 121, 10, 1], "semantic": {"name": "obj_pk", "arg_names": [], "import_names": [], "rhs_call_name": "getattr", "annotation": ""}, "snippet": " obj_pk = getattr(obj, field.rel.field_name)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98836:If_L233_C20", "label": "if", "type": "if", "loc": [233, 234], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98836:If_L226_C16", "vector": [4, 5, 0.7862, 0.0067, 5, 0.09, 0.6, 0, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if field.rel.to._meta.pk.rel:\n obj_pk = obj_pk.pk"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98836:Assign_L234_C24", "label": "obj_pk =", "type": "assigned_variable", "loc": [234, 234], "level": 6, "parent": "ajibawa-2023/Python-Code-Large/train/row_98836:If_L233_C20", "vector": [14, 6, 0.7879, 0.0034, 6, 0.01, 0.0, 190, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "obj_pk", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " obj_pk = obj_pk.pk"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98836:Assign_L237_C20", "label": "field_value = strip()", "type": "assigned_variable", "loc": [237, 237], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98836:If_L226_C16", "vector": [14, 5, 0.798, 0.0034, 5, 0.09, 0.8, 900, 3, 0, 0, 0, 973, 10, 2], "semantic": {"name": "field_value", "arg_names": [], "import_names": [], "rhs_call_name": "strip", "annotation": ""}, "snippet": " field_value = getInnerText(node).strip()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98836:Assign_L238_C20", "label": "obj_pk = to_python()", "type": "assigned_variable", "loc": [238, 238], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98836:If_L226_C16", "vector": [14, 5, 0.8013, 0.0034, 5, 0.09, 1.0, 190, 3, 1, 0, 0, 800, 10, 2], "semantic": {"name": "obj_pk", "arg_names": [], "import_names": [], "rhs_call_name": "to_python", "annotation": ""}, "snippet": " obj_pk = field.rel.to._meta.get_field(field.rel.field_name).to_python(field_value)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98836:Return_L239_C16", "label": "return", "type": "return", "loc": [239, 239], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98836:If_L224_C12", "vector": [13, 4, 0.8047, 0.0034, 4, 0.2, 0.5, 0, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return obj_pk"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98836:Assign_L241_C16", "label": "field_value = strip()", "type": "assigned_variable", "loc": [241, 241], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98836:If_L224_C12", "vector": [14, 4, 0.8114, 0.0034, 4, 0.2, 0.75, 900, 3, 0, 0, 0, 973, 10, 2], "semantic": {"name": "field_value", "arg_names": [], "import_names": [], "rhs_call_name": "strip", "annotation": ""}, "snippet": " field_value = getInnerText(node).strip()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98836:Return_L242_C16", "label": "return", "type": "return", "loc": [242, 242], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98836:If_L224_C12", "vector": [13, 4, 0.8148, 0.0034, 4, 0.2, 1.0, 0, 3, 0, 0, 0, 0, 10, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return field.rel.to._meta.get_field(field.rel.field_name).to_python(field_value)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98836:FunctionDef_L244_C4", "label": "_handle_m2m_field_node", "type": "function", "loc": [244, 261], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98836:ClassDef_L150_C0", "vector": [2, 1, 0.8502, 0.0606, 1, 0.55, 0.8333, 483, 0, 3, 1, 0, 0, 0, 12], "semantic": {"name": "_handle_m2m_field_node", "arg_names": ["self", "node", "field"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def _handle_m2m_field_node(self, node, field):\n \"\"\"\n Handle a <field> node for a ManyToManyField.\n \"\"\"\n if hasattr(field.rel.to._default_manager, 'get_by_natural_key'):\n def m2m_convert(n):\n keys = n.getElementsByTagName('natural')\n if keys:"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98836:Expr_L245_C8", "label": "expression", "type": "expression", "loc": [245, 247], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98836:FunctionDef_L244_C4", "vector": [8, 2, 0.8283, 0.0101, 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 Handle a <field> node for a ManyToManyField.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98836:If_L248_C8", "label": "if", "type": "if", "loc": [248, 260], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98836:FunctionDef_L244_C4", "vector": [4, 2, 0.8552, 0.0438, 2, 0.65, 0.5, 0, 3, 0, 0, 0, 0, 0, 10], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if hasattr(field.rel.to._default_manager, 'get_by_natural_key'):\n def m2m_convert(n):\n keys = n.getElementsByTagName('natural')\n if keys:\n # If there are 'natural' subelements, it must be a natural key\n field_value = [getInnerText(k).strip() for k in keys]\n obj_pk = field.rel.to._default_manager.db_manager(self.db).get_by_natural_key(*field_value).pk\n else:"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98836:FunctionDef_L249_C12", "label": "m2m_convert", "type": "function", "loc": [249, 258], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98836:If_L248_C8", "vector": [2, 3, 0.8535, 0.0337, 3, 0.29, 0.0, 675, 0, 1, 1, 0, 0, 0, 7], "semantic": {"name": "m2m_convert", "arg_names": ["n"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def m2m_convert(n):\n keys = n.getElementsByTagName('natural')\n if keys:\n # If there are 'natural' subelements, it must be a natural key\n field_value = [getInnerText(k).strip() for k in keys]\n obj_pk = field.rel.to._default_manager.db_manager(self.db).get_by_natural_key(*field_value).pk\n else:\n # Otherwise, treat like a normal PK value."}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98836:Assign_L250_C16", "label": "keys = getElementsByTagName()", "type": "assigned_variable", "loc": [250, 250], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98836:FunctionDef_L249_C12", "vector": [14, 4, 0.8418, 0.0034, 4, 0.44, 0.0, 204, 3, 1, 0, 0, 989, 10, 1], "semantic": {"name": "keys", "arg_names": [], "import_names": [], "rhs_call_name": "getElementsByTagName", "annotation": ""}, "snippet": " keys = n.getElementsByTagName('natural')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98836:If_L251_C16", "label": "if", "type": "if", "loc": [251, 257], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98836:FunctionDef_L249_C12", "vector": [4, 4, 0.8552, 0.0236, 4, 0.44, 0.5, 0, 2, 0, 0, 0, 0, 0, 6], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if keys:\n # If there are 'natural' subelements, it must be a natural key\n field_value = [getInnerText(k).strip() for k in keys]\n obj_pk = field.rel.to._default_manager.db_manager(self.db).get_by_natural_key(*field_value).pk\n else:\n # Otherwise, treat like a normal PK value.\n obj_pk = field.rel.to._meta.pk.to_python(n.getAttribute('pk'))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98836:Assign_L253_C20", "label": "field_value =", "type": "assigned_variable", "loc": [253, 253], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98836:If_L251_C16", "vector": [14, 5, 0.8519, 0.0034, 5, 0.75, 0.0, 900, 5, 0, 0, 0, 0, 0, 2], "semantic": {"name": "field_value", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " field_value = [getInnerText(k).strip() for k in keys]"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98836:Assign_L254_C20", "label": "obj_pk =", "type": "assigned_variable", "loc": [254, 254], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98836:If_L251_C16", "vector": [14, 5, 0.8552, 0.0034, 5, 0.75, 0.5, 190, 7, 0, 0, 0, 0, 0, 2], "semantic": {"name": "obj_pk", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " obj_pk = field.rel.to._default_manager.db_manager(self.db).get_by_natural_key(*field_value).pk"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98836:Assign_L257_C20", "label": "obj_pk = to_python()", "type": "assigned_variable", "loc": [257, 257], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98836:If_L251_C16", "vector": [14, 5, 0.8653, 0.0034, 5, 0.75, 1.0, 190, 3, 1, 0, 0, 800, 10, 2], "semantic": {"name": "obj_pk", "arg_names": [], "import_names": [], "rhs_call_name": "to_python", "annotation": ""}, "snippet": " obj_pk = field.rel.to._meta.pk.to_python(n.getAttribute('pk'))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98836:Return_L258_C16", "label": "return", "type": "return", "loc": [258, 258], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98836:FunctionDef_L249_C12", "vector": [13, 4, 0.8687, 0.0034, 4, 0.44, 1.0, 0, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return obj_pk"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98836:Assign_L260_C12", "label": "m2m_convert =", "type": "assigned_variable", "loc": [260, 260], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98836:If_L248_C8", "vector": [14, 3, 0.8754, 0.0034, 3, 0.29, 1.0, 675, 9, 0, 0, 0, 0, 0, 2], "semantic": {"name": "m2m_convert", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " m2m_convert = lambda n: field.rel.to._meta.pk.to_python(n.getAttribute('pk'))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98836:Return_L261_C8", "label": "return", "type": "return", "loc": [261, 261], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98836:FunctionDef_L244_C4", "vector": [13, 2, 0.8788, 0.0034, 2, 0.65, 1.0, 0, 5, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return [m2m_convert(c) for c in node.getElementsByTagName(\"object\")]"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98836:FunctionDef_L263_C4", "label": "_get_model_from_node", "type": "function", "loc": [263, 281], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98836:ClassDef_L150_C0", "vector": [2, 1, 0.9158, 0.064, 1, 0.55, 1.0, 683, 0, 3, 1, 0, 0, 0, 5], "semantic": {"name": "_get_model_from_node", "arg_names": ["self", "node", "attr"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def _get_model_from_node(self, node, attr):\n \"\"\"\n Helper to look up a model from a <object model=...> or a <field\n rel=... to=...> node.\n \"\"\"\n model_identifier = node.getAttribute(attr)\n if not model_identifier:\n raise base.DeserializationError("}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98836:Expr_L264_C8", "label": "expression", "type": "expression", "loc": [264, 267], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98836:FunctionDef_L263_C4", "vector": [8, 2, 0.8939, 0.0135, 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 Helper to look up a model from a <object model=...> or a <field\n rel=... to=...> node.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98836:Assign_L268_C8", "label": "model_identifier = getAttribute()", "type": "assigned_variable", "loc": [268, 268], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98836:FunctionDef_L263_C4", "vector": [14, 2, 0.9024, 0.0034, 2, 0.65, 0.2, 189, 3, 1, 0, 0, 607, 10, 1], "semantic": {"name": "model_identifier", "arg_names": [], "import_names": [], "rhs_call_name": "getAttribute", "annotation": ""}, "snippet": " model_identifier = node.getAttribute(attr)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98836:If_L269_C8", "label": "if", "type": "if", "loc": [269, 272], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98836:FunctionDef_L263_C4", "vector": [4, 2, 0.9108, 0.0135, 2, 0.65, 0.4, 0, 0, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if not model_identifier:\n raise base.DeserializationError(\n \"<%s> node is missing the required '%s' attribute\" \\\n % (node.nodeName, attr))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98836:Try_L273_C8", "label": "try", "type": "try", "loc": [273, 276], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98836:FunctionDef_L263_C4", "vector": [7, 2, 0.9242, 0.0135, 2, 0.65, 0.6, 0, 0, 1, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " try:\n Model = models.get_model(*model_identifier.split(\".\"))\n except TypeError:\n Model = None"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98836:Assign_L274_C12", "label": "Model = get_model()", "type": "assigned_variable", "loc": [274, 274], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98836:Try_L273_C8", "vector": [14, 3, 0.9226, 0.0034, 3, 0.04, 0.0, 929, 3, 1, 0, 0, 115, 10, 2], "semantic": {"name": "Model", "arg_names": [], "import_names": [], "rhs_call_name": "get_model", "annotation": ""}, "snippet": " Model = models.get_model(*model_identifier.split(\".\"))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98836:Assign_L276_C12", "label": "Model =", "type": "assigned_variable", "loc": [276, 276], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98836:Try_L273_C8", "vector": [14, 3, 0.9293, 0.0034, 3, 0.04, 0.0, 929, 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_98836:If_L277_C8", "label": "if", "type": "if", "loc": [277, 280], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98836:FunctionDef_L263_C4", "vector": [4, 2, 0.9377, 0.0135, 2, 0.65, 0.8, 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 base.DeserializationError(\n \"<%s> node has invalid model identifier: '%s'\" % \\\n (node.nodeName, model_identifier))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98836:Return_L281_C8", "label": "return", "type": "return", "loc": [281, 281], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98836:FunctionDef_L263_C4", "vector": [13, 2, 0.9461, 0.0034, 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 Model"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98836:FunctionDef_L284_C0", "label": "getInnerText", "type": "function", "loc": [284, 297], "level": 0, "parent": null, "vector": [2, 0, 0.9781, 0.0471, 0, 0.66, 1.0, 724, 0, 1, 1, 0, 0, 0, 4], "semantic": {"name": "getInnerText", "arg_names": ["node"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "def getInnerText(node):\n \"\"\"\n Get all the inner text of a DOM node (recursively).\n \"\"\"\n # inspired by http://mail.python.org/pipermail/xml-sig/2005-March/011022.html\n inner_text = []\n for child in node.childNodes:\n if child.nodeType == child.TEXT_NODE or child.nodeType == child.CDATA_SECTION_NODE:"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98836:Expr_L285_C4", "label": "expression", "type": "expression", "loc": [285, 287], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98836:FunctionDef_L284_C0", "vector": [8, 1, 0.963, 0.0101, 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 Get all the inner text of a DOM node (recursively).\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98836:Assign_L289_C4", "label": "inner_text =", "type": "assigned_variable", "loc": [289, 289], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98836:FunctionDef_L284_C0", "vector": [14, 1, 0.9731, 0.0034, 1, 0.99, 0.3333, 794, 0, 0, 0, 0, 0, 5, 0], "semantic": {"name": "inner_text", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " inner_text = []"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98836:For_L290_C4", "label": "for child", "type": "for", "loc": [290, 296], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98836:FunctionDef_L284_C0", "vector": [6, 1, 0.9865, 0.0236, 1, 0.99, 0.6667, 967, 7, 0, 0, 0, 0, 0, 3], "semantic": {"name": "child", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for child in node.childNodes:\n if child.nodeType == child.TEXT_NODE or child.nodeType == child.CDATA_SECTION_NODE:\n inner_text.append(child.data)\n elif child.nodeType == child.ELEMENT_NODE:\n inner_text.extend(getInnerText(child))\n else:\n pass"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98836:If_L291_C8", "label": "if", "type": "if", "loc": [291, 296], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98836:For_L290_C4", "vector": [4, 2, 0.9882, 0.0202, 2, 0.15, 0.0, 0, 0, 0, 0, 0, 0, 0, 3], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if child.nodeType == child.TEXT_NODE or child.nodeType == child.CDATA_SECTION_NODE:\n inner_text.append(child.data)\n elif child.nodeType == child.ELEMENT_NODE:\n inner_text.extend(getInnerText(child))\n else:\n pass"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98836:Expr_L292_C12", "label": "append()", "type": "expression", "loc": [292, 292], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98836:If_L291_C8", "vector": [8, 3, 0.9832, 0.0034, 3, 0.65, 0.0, 243, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "append", "arg_names": [], "import_names": [], "rhs_call_name": "append", "annotation": ""}, "snippet": " inner_text.append(child.data)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98836:If_L293_C8", "label": "if", "type": "if", "loc": [293, 296], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98836:If_L291_C8", "vector": [4, 3, 0.9916, 0.0135, 3, 0.65, 1.0, 0, 0, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " elif child.nodeType == child.ELEMENT_NODE:\n inner_text.extend(getInnerText(child))\n else:\n pass"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98836:Expr_L294_C12", "label": "extend()", "type": "expression", "loc": [294, 294], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98836:If_L293_C8", "vector": [8, 4, 0.9899, 0.0034, 4, 0.59, 0.0, 660, 3, 1, 0, 0, 0, 0, 2], "semantic": {"name": "extend", "arg_names": [], "import_names": [], "rhs_call_name": "extend", "annotation": ""}, "snippet": " inner_text.extend(getInnerText(child))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98836:Return_L297_C4", "label": "return", "type": "return", "loc": [297, 297], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98836:FunctionDef_L284_C0", "vector": [13, 1, 1.0, 0.0034, 1, 0.99, 1.0, 0, 3, 0, 0, 0, 0, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return u\"\".join(inner_text)"}]
[{"f": "ajibawa-2023/Python-Code-Large/train/row_98836:ClassDef_L12_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98836:Expr_L13_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98836:ClassDef_L12_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98836:FunctionDef_L17_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98836:FunctionDef_L17_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98836:If_L18_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98836:If_L18_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98836:Expr_L19_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98836:ClassDef_L12_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98836:FunctionDef_L21_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98836:FunctionDef_L21_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98836:Expr_L22_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98836:FunctionDef_L21_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98836:Assign_L25_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98836:FunctionDef_L21_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98836:Expr_L26_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98836:FunctionDef_L21_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98836:Expr_L27_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98836:ClassDef_L12_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98836:FunctionDef_L29_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98836:FunctionDef_L29_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98836:Expr_L30_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98836:FunctionDef_L29_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98836:Expr_L33_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98836:FunctionDef_L29_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98836:Expr_L34_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98836:FunctionDef_L29_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98836:Expr_L35_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98836:ClassDef_L12_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98836:FunctionDef_L37_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98836:FunctionDef_L37_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98836:Expr_L38_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98836:FunctionDef_L37_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98836:If_L41_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98836:FunctionDef_L37_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98836:Expr_L44_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98836:FunctionDef_L37_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98836:Assign_L45_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98836:FunctionDef_L37_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98836:If_L46_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98836:If_L46_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98836:Assign_L47_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98836:If_L46_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98836:Assign_L49_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98836:FunctionDef_L37_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98836:Expr_L54_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98836:ClassDef_L12_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98836:FunctionDef_L56_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98836:FunctionDef_L56_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98836:Expr_L57_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98836:FunctionDef_L56_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98836:Expr_L60_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98836:FunctionDef_L56_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98836:Expr_L61_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98836:ClassDef_L12_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98836:FunctionDef_L63_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98836:FunctionDef_L63_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98836:Expr_L64_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98836:FunctionDef_L63_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98836:Expr_L68_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98836:FunctionDef_L63_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98836:Expr_L69_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98836:FunctionDef_L63_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98836:If_L75_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98836:If_L75_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98836:Expr_L76_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98836:If_L75_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98836:Expr_L78_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98836:FunctionDef_L63_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98836:Expr_L80_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98836:ClassDef_L12_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98836:FunctionDef_L82_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98836:FunctionDef_L82_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98836:Expr_L83_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98836:FunctionDef_L82_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98836:Expr_L87_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98836:FunctionDef_L82_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98836:Assign_L88_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98836:FunctionDef_L82_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98836:If_L89_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98836:If_L89_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98836:If_L90_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98836:If_L90_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98836:Assign_L92_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98836:If_L90_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98836:For_L94_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98836:For_L94_C16", "t": "ajibawa-2023/Python-Code-Large/train/row_98836:Expr_L95_C20"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98836:For_L94_C16", "t": "ajibawa-2023/Python-Code-Large/train/row_98836:Expr_L96_C20"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98836:For_L94_C16", "t": "ajibawa-2023/Python-Code-Large/train/row_98836:Expr_L97_C20"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98836:If_L90_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98836:If_L99_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98836:If_L99_C16", "t": "ajibawa-2023/Python-Code-Large/train/row_98836:Assign_L101_C20"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98836:If_L99_C16", "t": "ajibawa-2023/Python-Code-Large/train/row_98836:Assign_L104_C20"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98836:If_L90_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98836:Expr_L105_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98836:If_L89_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98836:Expr_L107_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98836:FunctionDef_L82_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98836:Expr_L108_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98836:ClassDef_L12_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98836:FunctionDef_L110_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98836:FunctionDef_L110_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98836:Expr_L111_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98836:FunctionDef_L110_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98836:If_L116_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98836:If_L116_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98836:Expr_L117_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98836:If_L116_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98836:If_L118_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98836:If_L118_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98836:FunctionDef_L120_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98836:FunctionDef_L120_C16", "t": "ajibawa-2023/Python-Code-Large/train/row_98836:Assign_L121_C20"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98836:FunctionDef_L120_C16", "t": "ajibawa-2023/Python-Code-Large/train/row_98836:Expr_L123_C20"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98836:FunctionDef_L120_C16", "t": "ajibawa-2023/Python-Code-Large/train/row_98836:For_L124_C20"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98836:For_L124_C20", "t": "ajibawa-2023/Python-Code-Large/train/row_98836:Expr_L125_C24"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98836:For_L124_C20", "t": "ajibawa-2023/Python-Code-Large/train/row_98836:Expr_L126_C24"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98836:For_L124_C20", "t": "ajibawa-2023/Python-Code-Large/train/row_98836:Expr_L127_C24"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98836:FunctionDef_L120_C16", "t": "ajibawa-2023/Python-Code-Large/train/row_98836:Expr_L128_C20"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98836:If_L118_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98836:FunctionDef_L130_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98836:FunctionDef_L130_C16", "t": "ajibawa-2023/Python-Code-Large/train/row_98836:Expr_L131_C20"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98836:If_L116_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98836:For_L134_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98836:For_L134_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98836:Expr_L135_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98836:If_L116_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98836:Expr_L137_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98836:ClassDef_L12_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98836:FunctionDef_L139_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98836:FunctionDef_L139_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98836:Expr_L140_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98836:FunctionDef_L139_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98836:Expr_L143_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98836:FunctionDef_L139_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98836:Expr_L144_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98836:ClassDef_L150_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98836:Expr_L151_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98836:ClassDef_L150_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98836:FunctionDef_L155_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98836:FunctionDef_L155_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98836:Expr_L156_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98836:FunctionDef_L155_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98836:Assign_L157_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98836:FunctionDef_L155_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98836:Assign_L158_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98836:ClassDef_L150_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98836:FunctionDef_L160_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98836:FunctionDef_L160_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98836:For_L161_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98836:For_L161_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98836:If_L162_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98836:If_L162_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98836:Expr_L163_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98836:If_L162_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98836:Return_L164_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98836:ClassDef_L150_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98836:FunctionDef_L167_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98836:FunctionDef_L167_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98836:Expr_L168_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98836:FunctionDef_L167_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98836:Assign_L173_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98836:FunctionDef_L167_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98836:If_L177_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98836:If_L177_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98836:Assign_L178_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98836:If_L177_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98836:Assign_L180_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98836:FunctionDef_L167_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98836:Assign_L182_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98836:FunctionDef_L167_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98836:Assign_L186_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98836:FunctionDef_L167_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98836:For_L189_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98836:For_L189_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98836:Assign_L192_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98836:For_L189_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98836:If_L193_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98836:For_L189_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98836:Assign_L199_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98836:For_L189_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98836:If_L202_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98836:If_L202_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98836:Assign_L203_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98836:If_L202_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98836:If_L204_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98836:If_L204_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98836:Assign_L205_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98836:If_L204_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98836:If_L207_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98836:If_L207_C16", "t": "ajibawa-2023/Python-Code-Large/train/row_98836:Assign_L208_C20"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98836:If_L207_C16", "t": "ajibawa-2023/Python-Code-Large/train/row_98836:Assign_L210_C20"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98836:If_L204_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98836:Assign_L211_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98836:FunctionDef_L167_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98836:Return_L214_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98836:ClassDef_L150_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98836:FunctionDef_L216_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98836:FunctionDef_L216_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98836:Expr_L217_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98836:FunctionDef_L216_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98836:If_L221_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98836:If_L221_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98836:Return_L222_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98836:If_L221_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98836:If_L224_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98836:If_L224_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98836:Assign_L225_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98836:If_L224_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98836:If_L226_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98836:If_L226_C16", "t": "ajibawa-2023/Python-Code-Large/train/row_98836:Assign_L228_C20"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98836:If_L226_C16", "t": "ajibawa-2023/Python-Code-Large/train/row_98836:Assign_L229_C20"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98836:If_L226_C16", "t": "ajibawa-2023/Python-Code-Large/train/row_98836:Assign_L230_C20"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98836:If_L226_C16", "t": "ajibawa-2023/Python-Code-Large/train/row_98836:If_L233_C20"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98836:If_L233_C20", "t": "ajibawa-2023/Python-Code-Large/train/row_98836:Assign_L234_C24"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98836:If_L226_C16", "t": "ajibawa-2023/Python-Code-Large/train/row_98836:Assign_L237_C20"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98836:If_L226_C16", "t": "ajibawa-2023/Python-Code-Large/train/row_98836:Assign_L238_C20"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98836:If_L224_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98836:Return_L239_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98836:If_L224_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98836:Assign_L241_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98836:If_L224_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98836:Return_L242_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98836:ClassDef_L150_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98836:FunctionDef_L244_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98836:FunctionDef_L244_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98836:Expr_L245_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98836:FunctionDef_L244_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98836:If_L248_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98836:If_L248_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98836:FunctionDef_L249_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98836:FunctionDef_L249_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98836:Assign_L250_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98836:FunctionDef_L249_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98836:If_L251_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98836:If_L251_C16", "t": "ajibawa-2023/Python-Code-Large/train/row_98836:Assign_L253_C20"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98836:If_L251_C16", "t": "ajibawa-2023/Python-Code-Large/train/row_98836:Assign_L254_C20"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98836:If_L251_C16", "t": "ajibawa-2023/Python-Code-Large/train/row_98836:Assign_L257_C20"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98836:FunctionDef_L249_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98836:Return_L258_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98836:If_L248_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98836:Assign_L260_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98836:FunctionDef_L244_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98836:Return_L261_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98836:ClassDef_L150_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98836:FunctionDef_L263_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98836:FunctionDef_L263_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98836:Expr_L264_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98836:FunctionDef_L263_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98836:Assign_L268_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98836:FunctionDef_L263_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98836:If_L269_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98836:FunctionDef_L263_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98836:Try_L273_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98836:Try_L273_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98836:Assign_L274_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98836:Try_L273_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98836:Assign_L276_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98836:FunctionDef_L263_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98836:If_L277_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98836:FunctionDef_L263_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98836:Return_L281_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98836:FunctionDef_L284_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98836:Expr_L285_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98836:FunctionDef_L284_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98836:Assign_L289_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98836:FunctionDef_L284_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98836:For_L290_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98836:For_L290_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98836:If_L291_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98836:If_L291_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98836:Expr_L292_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98836:If_L291_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98836:If_L293_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98836:If_L293_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98836:Expr_L294_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98836:FunctionDef_L284_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98836:Return_L297_C4"}]
""" A Python "serializer". Doesn't do much serializing per se -- just converts to and from basic Python data types (lists, dicts, strings, etc.). Useful as a basis for other serializers. """ from django.conf import settings from django.core.serializers import base from django.db import models, DEFAULT_DB_ALIAS from django.utils.encoding import smart_unicode, is_protected_type class Serializer(base.Serializer): """ Serializes a QuerySet to basic Python objects. """ internal_use_only = True def start_serialization(self): self._current = None self.objects = [] def end_serialization(self): pass def start_object(self, obj): self._current = {} def end_object(self, obj): self.objects.append({ "model" : smart_unicode(obj._meta), "pk" : smart_unicode(obj._get_pk_val(), strings_only=True), "fields" : self._current }) self._current = None def handle_field(self, obj, field): value = field._get_val_from_obj(obj) # Protected types (i.e., primitives like None, numbers, dates, # and Decimals) are passed through as is. All other values are # converted to string first. if is_protected_type(value): self._current[field.name] = value else: self._current[field.name] = field.value_to_string(obj) def handle_fk_field(self, obj, field): related = getattr(obj, field.name) if related is not None: if self.use_natural_keys and hasattr(related, 'natural_key'): related = related.natural_key() else: if field.rel.field_name == related._meta.pk.name: # Related to remote object via primary key related = related._get_pk_val() else: # Related to remote object via other field related = smart_unicode(getattr(related, field.rel.field_name), strings_only=True) self._current[field.name] = related def handle_m2m_field(self, obj, field): if field.rel.through._meta.auto_created: if self.use_natural_keys and hasattr(field.rel.to, 'natural_key'): m2m_value = lambda value: value.natural_key() else: m2m_value = lambda value: smart_unicode(value._get_pk_val(), strings_only=True) self._current[field.name] = [m2m_value(related) for related in getattr(obj, field.name).iterator()] def getvalue(self): return self.objects def Deserializer(object_list, **options): """ Deserialize simple Python objects back into Django ORM instances. It's expected that you pass the Python objects themselves (instead of a stream or a string) to the constructor """ db = options.pop('using', DEFAULT_DB_ALIAS) models.get_apps() for d in object_list: # Look up the model and starting build a dict of data for it. Model = _get_model(d["model"]) data = {Model._meta.pk.attname : Model._meta.pk.to_python(d["pk"])} m2m_data = {} # Handle each field for (field_name, field_value) in d["fields"].iteritems(): if isinstance(field_value, str): field_value = smart_unicode(field_value, options.get("encoding", settings.DEFAULT_CHARSET), strings_only=True) field = Model._meta.get_field(field_name) # Handle M2M relations if field.rel and isinstance(field.rel, models.ManyToManyRel): if hasattr(field.rel.to._default_manager, 'get_by_natural_key'): def m2m_convert(value): if hasattr(value, '__iter__'): return field.rel.to._default_manager.db_manager(db).get_by_natural_key(*value).pk else: return smart_unicode(field.rel.to._meta.pk.to_python(value)) else: m2m_convert = lambda v: smart_unicode(field.rel.to._meta.pk.to_python(v)) m2m_data[field.name] = [m2m_convert(pk) for pk in field_value] # Handle FK fields elif field.rel and isinstance(field.rel, models.ManyToOneRel): if field_value is not None: if hasattr(field.rel.to._default_manager, 'get_by_natural_key'): if hasattr(field_value, '__iter__'): obj = field.rel.to._default_manager.db_manager(db).get_by_natural_key(*field_value) value = getattr(obj, field.rel.field_name) # If this is a natural foreign key to an object that # has a FK/O2O as the foreign key, use the FK value if field.rel.to._meta.pk.rel: value = value.pk else: value = field.rel.to._meta.get_field(field.rel.field_name).to_python(field_value) data[field.attname] = value else: data[field.attname] = field.rel.to._meta.get_field(field.rel.field_name).to_python(field_value) else: data[field.attname] = None # Handle all other fields else: data[field.name] = field.to_python(field_value) yield base.DeserializedObject(Model(**data), m2m_data) def _get_model(model_identifier): """ Helper to look up a model from an "app_label.module_name" string. """ try: Model = models.get_model(*model_identifier.split(".")) except TypeError: Model = None if Model is None: raise base.DeserializationError(u"Invalid model identifier: '%s'" % model_identifier) return Model
ajibawa-2023/Python-Code-Large/train/row_98837
80
142
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_98837:Expr_L1_C0", "label": "expression", "type": "expression", "loc": [1, 5], "level": 0, "parent": null, "vector": [8, 0, 0.0211, 0.0352, 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 Python \"serializer\". Doesn't do much serializing per se -- just converts to\nand from basic Python data types (lists, dicts, strings, etc.). Useful as a basis for\nother serializers.\n\"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98837:ImportFrom_L7_C0", "label": "from django.conf import settings", "type": "import", "loc": [7, 7], "level": 0, "parent": null, "vector": [1, 0, 0.0493, 0.007, 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_98837:ImportFrom_L8_C0", "label": "from django.core.serializers import base", "type": "import", "loc": [8, 8], "level": 0, "parent": null, "vector": [1, 0, 0.0563, 0.007, 0, 0.66, 0.2857, 10, 0, 1, 0, 0, 10, 0, 0], "semantic": {"name": "django.core.serializers", "arg_names": [], "import_names": ["base"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.core.serializers import base"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98837:ImportFrom_L9_C0", "label": "from django.db import models, DEFAULT_DB_ALIAS", "type": "import", "loc": [9, 9], "level": 0, "parent": null, "vector": [1, 0, 0.0634, 0.007, 0, 0.66, 0.4286, 40, 0, 2, 0, 0, 40, 0, 0], "semantic": {"name": "django.db", "arg_names": [], "import_names": ["models", "DEFAULT_DB_ALIAS"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.db import models, DEFAULT_DB_ALIAS"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98837:ImportFrom_L10_C0", "label": "from django.utils.encoding import smart_unicode, is_protected_type", "type": "import", "loc": [10, 10], "level": 0, "parent": null, "vector": [1, 0, 0.0704, 0.007, 0, 0.66, 0.5714, 96, 0, 2, 0, 0, 96, 0, 0], "semantic": {"name": "django.utils.encoding", "arg_names": [], "import_names": ["smart_unicode", "is_protected_type"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.utils.encoding import smart_unicode, is_protected_type"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98837:ClassDef_L12_C0", "label": "Serializer", "type": "class", "loc": [12, 71], "level": 0, "parent": null, "vector": [3, 0, 0.2923, 0.4225, 0, 0.66, 0.7143, 577, 0, 8, 0, 0, 160, 0, 20], "semantic": {"name": "Serializer", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class Serializer(base.Serializer):\n \"\"\"\n Serializes a QuerySet to basic Python objects.\n \"\"\"\n\n internal_use_only = True\n\n def start_serialization(self):"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98837:Expr_L13_C4", "label": "expression", "type": "expression", "loc": [13, 15], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98837:ClassDef_L12_C0", "vector": [8, 1, 0.0986, 0.0211, 1, 0.83, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"\n Serializes a QuerySet to basic Python objects.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98837:Assign_L17_C4", "label": "internal_use_only =", "type": "assigned_variable", "loc": [17, 17], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98837:ClassDef_L12_C0", "vector": [14, 1, 0.1197, 0.007, 1, 0.83, 0.1111, 17, 1, 0, 0, 0, 0, 4, 0], "semantic": {"name": "internal_use_only", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " internal_use_only = True"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98837:FunctionDef_L19_C4", "label": "start_serialization", "type": "function", "loc": [19, 21], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98837:ClassDef_L12_C0", "vector": [2, 1, 0.1408, 0.0211, 1, 0.83, 0.2222, 476, 0, 1, 0, 0, 0, 0, 0], "semantic": {"name": "start_serialization", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def start_serialization(self):\n self._current = None\n self.objects = []"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98837:Assign_L20_C8", "label": "self._current =", "type": "assigned_variable", "loc": [20, 20], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98837:FunctionDef_L19_C4", "vector": [14, 2, 0.1408, 0.007, 2, 0.94, 0.0, 649, 1, 0, 0, 0, 0, 9, 0], "semantic": {"name": "self._current", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self._current = None"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98837:Assign_L21_C8", "label": "self.objects =", "type": "assigned_variable", "loc": [21, 21], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98837:FunctionDef_L19_C4", "vector": [14, 2, 0.1479, 0.007, 2, 0.94, 1.0, 350, 0, 0, 0, 0, 0, 5, 0], "semantic": {"name": "self.objects", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.objects = []"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98837:FunctionDef_L23_C4", "label": "end_serialization", "type": "function", "loc": [23, 24], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98837:ClassDef_L12_C0", "vector": [2, 1, 0.1655, 0.0141, 1, 0.83, 0.3333, 673, 0, 1, 0, 0, 0, 0, 0], "semantic": {"name": "end_serialization", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def end_serialization(self):\n pass"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98837:FunctionDef_L26_C4", "label": "start_object", "type": "function", "loc": [26, 27], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98837:ClassDef_L12_C0", "vector": [2, 1, 0.1866, 0.0141, 1, 0.83, 0.4444, 939, 0, 2, 0, 0, 0, 0, 0], "semantic": {"name": "start_object", "arg_names": ["self", "obj"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def start_object(self, obj):\n self._current = {}"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98837:Assign_L27_C8", "label": "self._current =", "type": "assigned_variable", "loc": [27, 27], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98837:FunctionDef_L26_C4", "vector": [14, 2, 0.1901, 0.007, 2, 0.79, 0.0, 649, 0, 0, 0, 0, 0, 6, 0], "semantic": {"name": "self._current", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self._current = {}"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98837:FunctionDef_L29_C4", "label": "end_object", "type": "function", "loc": [29, 35], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98837:ClassDef_L12_C0", "vector": [2, 1, 0.2254, 0.0493, 1, 0.83, 0.5556, 857, 0, 2, 0, 0, 0, 0, 4], "semantic": {"name": "end_object", "arg_names": ["self", "obj"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def end_object(self, obj):\n self.objects.append({\n \"model\" : smart_unicode(obj._meta),\n \"pk\" : smart_unicode(obj._get_pk_val(), strings_only=True),\n \"fields\" : self._current\n })\n self._current = None"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98837:Expr_L30_C8", "label": "append()", "type": "expression", "loc": [30, 34], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98837:FunctionDef_L29_C4", "vector": [8, 2, 0.2254, 0.0352, 2, 0.34, 0.0, 243, 3, 1, 0, 0, 0, 0, 4], "semantic": {"name": "append", "arg_names": [], "import_names": [], "rhs_call_name": "append", "annotation": ""}, "snippet": " self.objects.append({\n \"model\" : smart_unicode(obj._meta),\n \"pk\" : smart_unicode(obj._get_pk_val(), strings_only=True),\n \"fields\" : self._current\n })"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98837:Assign_L35_C8", "label": "self._current =", "type": "assigned_variable", "loc": [35, 35], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98837:FunctionDef_L29_C4", "vector": [14, 2, 0.2465, 0.007, 2, 0.34, 1.0, 649, 1, 0, 0, 0, 0, 9, 0], "semantic": {"name": "self._current", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self._current = None"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98837:FunctionDef_L37_C4", "label": "handle_field", "type": "function", "loc": [37, 45], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98837:ClassDef_L12_C0", "vector": [2, 1, 0.2887, 0.0634, 1, 0.83, 0.6667, 277, 0, 3, 0, 0, 0, 0, 3], "semantic": {"name": "handle_field", "arg_names": ["self", "obj", "field"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def handle_field(self, obj, field):\n value = field._get_val_from_obj(obj)\n # Protected types (i.e., primitives like None, numbers, dates,\n # and Decimals) are passed through as is. All other values are\n # converted to string first.\n if is_protected_type(value):\n self._current[field.name] = value\n else:"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98837:Assign_L38_C8", "label": "value = _get_val_from_obj()", "type": "assigned_variable", "loc": [38, 38], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98837:FunctionDef_L37_C4", "vector": [14, 2, 0.2676, 0.007, 2, 0.92, 0.0, 441, 3, 1, 0, 0, 280, 10, 1], "semantic": {"name": "value", "arg_names": [], "import_names": [], "rhs_call_name": "_get_val_from_obj", "annotation": ""}, "snippet": " value = field._get_val_from_obj(obj)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98837:If_L42_C8", "label": "if", "type": "if", "loc": [42, 45], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98837:FunctionDef_L37_C4", "vector": [4, 2, 0.3063, 0.0282, 2, 0.92, 1.0, 0, 3, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if is_protected_type(value):\n self._current[field.name] = value\n else:\n self._current[field.name] = field.value_to_string(obj)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98837:Assign_L43_C12", "label": "assign", "type": "assigned_variable", "loc": [43, 43], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98837:If_L42_C8", "vector": [14, 3, 0.3028, 0.007, 3, 0.87, 0.0, 0, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self._current[field.name] = value"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98837:Assign_L45_C12", "label": " = value_to_string()", "type": "assigned_variable", "loc": [45, 45], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98837:If_L42_C8", "vector": [14, 3, 0.3169, 0.007, 3, 0.87, 1.0, 0, 3, 1, 0, 0, 303, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "value_to_string", "annotation": ""}, "snippet": " self._current[field.name] = field.value_to_string(obj)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98837:FunctionDef_L47_C4", "label": "handle_fk_field", "type": "function", "loc": [47, 59], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98837:ClassDef_L12_C0", "vector": [2, 1, 0.3732, 0.0915, 1, 0.83, 0.7778, 279, 0, 3, 0, 0, 0, 0, 6], "semantic": {"name": "handle_fk_field", "arg_names": ["self", "obj", "field"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def handle_fk_field(self, obj, field):\n related = getattr(obj, field.name)\n if related is not None:\n if self.use_natural_keys and hasattr(related, 'natural_key'):\n related = related.natural_key()\n else:\n if field.rel.field_name == related._meta.pk.name:\n # Related to remote object via primary key"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98837:Assign_L48_C8", "label": "related = getattr()", "type": "assigned_variable", "loc": [48, 48], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98837:FunctionDef_L47_C4", "vector": [14, 2, 0.338, 0.007, 2, 0.44, 0.0, 462, 3, 2, 0, 0, 121, 10, 1], "semantic": {"name": "related", "arg_names": [], "import_names": [], "rhs_call_name": "getattr", "annotation": ""}, "snippet": " related = getattr(obj, field.name)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98837:If_L49_C8", "label": "if", "type": "if", "loc": [49, 58], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98837:FunctionDef_L47_C4", "vector": [4, 2, 0.3768, 0.0704, 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 related is not None:\n if self.use_natural_keys and hasattr(related, 'natural_key'):\n related = related.natural_key()\n else:\n if field.rel.field_name == related._meta.pk.name:\n # Related to remote object via primary key\n related = related._get_pk_val()\n else:"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98837:If_L50_C12", "label": "if", "type": "if", "loc": [50, 58], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98837:If_L49_C8", "vector": [4, 3, 0.3803, 0.0634, 3, 0.62, 0.0, 0, 0, 0, 0, 0, 0, 0, 5], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if self.use_natural_keys and hasattr(related, 'natural_key'):\n related = related.natural_key()\n else:\n if field.rel.field_name == related._meta.pk.name:\n # Related to remote object via primary key\n related = related._get_pk_val()\n else:\n # Related to remote object via other field"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98837:Assign_L51_C16", "label": "related = natural_key()", "type": "assigned_variable", "loc": [51, 51], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98837:If_L50_C12", "vector": [14, 4, 0.3592, 0.007, 4, 0.9, 0.0, 462, 3, 0, 0, 0, 449, 10, 1], "semantic": {"name": "related", "arg_names": [], "import_names": [], "rhs_call_name": "natural_key", "annotation": ""}, "snippet": " related = related.natural_key()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98837:If_L53_C16", "label": "if", "type": "if", "loc": [53, 58], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98837:If_L50_C12", "vector": [4, 4, 0.3908, 0.0423, 4, 0.9, 1.0, 0, 0, 0, 0, 0, 0, 0, 3], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if field.rel.field_name == related._meta.pk.name:\n # Related to remote object via primary key\n related = related._get_pk_val()\n else:\n # Related to remote object via other field\n related = smart_unicode(getattr(related, field.rel.field_name), strings_only=True)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98837:Assign_L55_C20", "label": "related = _get_pk_val()", "type": "assigned_variable", "loc": [55, 55], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98837:If_L53_C16", "vector": [14, 5, 0.3873, 0.007, 5, 0.81, 0.0, 462, 3, 0, 0, 0, 743, 10, 1], "semantic": {"name": "related", "arg_names": [], "import_names": [], "rhs_call_name": "_get_pk_val", "annotation": ""}, "snippet": " related = related._get_pk_val()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98837:Assign_L58_C20", "label": "related = smart_unicode()", "type": "assigned_variable", "loc": [58, 58], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98837:If_L53_C16", "vector": [14, 5, 0.4085, 0.007, 5, 0.81, 1.0, 462, 3, 2, 0, 0, 349, 10, 2], "semantic": {"name": "related", "arg_names": [], "import_names": [], "rhs_call_name": "smart_unicode", "annotation": ""}, "snippet": " related = smart_unicode(getattr(related, field.rel.field_name), strings_only=True)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98837:Assign_L59_C8", "label": "assign", "type": "assigned_variable", "loc": [59, 59], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98837:FunctionDef_L47_C4", "vector": [14, 2, 0.4155, 0.007, 2, 0.44, 1.0, 0, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self._current[field.name] = related"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98837:FunctionDef_L61_C4", "label": "handle_m2m_field", "type": "function", "loc": [61, 68], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98837:ClassDef_L12_C0", "vector": [2, 1, 0.4542, 0.0563, 1, 0.83, 0.8889, 261, 0, 3, 0, 0, 0, 0, 7], "semantic": {"name": "handle_m2m_field", "arg_names": ["self", "obj", "field"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def handle_m2m_field(self, obj, field):\n if field.rel.through._meta.auto_created:\n if self.use_natural_keys and hasattr(field.rel.to, 'natural_key'):\n m2m_value = lambda value: value.natural_key()\n else:\n m2m_value = lambda value: smart_unicode(value._get_pk_val(), strings_only=True)\n self._current[field.name] = [m2m_value(related)\n for related in getattr(obj, field.name).iterator()]"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98837:If_L62_C8", "label": "if", "type": "if", "loc": [62, 68], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98837:FunctionDef_L61_C4", "vector": [4, 2, 0.4577, 0.0493, 2, 0.63, 0.0, 0, 7, 0, 0, 0, 0, 0, 7], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if field.rel.through._meta.auto_created:\n if self.use_natural_keys and hasattr(field.rel.to, 'natural_key'):\n m2m_value = lambda value: value.natural_key()\n else:\n m2m_value = lambda value: smart_unicode(value._get_pk_val(), strings_only=True)\n self._current[field.name] = [m2m_value(related)\n for related in getattr(obj, field.name).iterator()]"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98837:If_L63_C12", "label": "if", "type": "if", "loc": [63, 66], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98837:If_L62_C8", "vector": [4, 3, 0.4542, 0.0282, 3, 0.28, 0.0, 0, 0, 0, 0, 0, 0, 0, 4], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if self.use_natural_keys and hasattr(field.rel.to, 'natural_key'):\n m2m_value = lambda value: value.natural_key()\n else:\n m2m_value = lambda value: smart_unicode(value._get_pk_val(), strings_only=True)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98837:Assign_L64_C16", "label": "m2m_value =", "type": "assigned_variable", "loc": [64, 64], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98837:If_L63_C12", "vector": [14, 4, 0.4507, 0.007, 4, 0.57, 0.0, 990, 9, 0, 0, 0, 0, 0, 1], "semantic": {"name": "m2m_value", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " m2m_value = lambda value: value.natural_key()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98837:Assign_L66_C16", "label": "m2m_value =", "type": "assigned_variable", "loc": [66, 66], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98837:If_L63_C12", "vector": [14, 4, 0.4648, 0.007, 4, 0.57, 1.0, 990, 9, 0, 0, 0, 0, 0, 2], "semantic": {"name": "m2m_value", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " m2m_value = lambda value: smart_unicode(value._get_pk_val(), strings_only=True)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98837:Assign_L67_C12", "label": "assign", "type": "assigned_variable", "loc": [67, 68], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98837:If_L62_C8", "vector": [14, 3, 0.4754, 0.0141, 3, 0.28, 1.0, 0, 5, 0, 0, 0, 0, 0, 3], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self._current[field.name] = [m2m_value(related)\n for related in getattr(obj, field.name).iterator()]"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98837:FunctionDef_L70_C4", "label": "getvalue", "type": "function", "loc": [70, 71], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98837:ClassDef_L12_C0", "vector": [2, 1, 0.4965, 0.0141, 1, 0.83, 1.0, 626, 0, 1, 1, 0, 0, 0, 0], "semantic": {"name": "getvalue", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def getvalue(self):\n return self.objects"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98837:Return_L71_C8", "label": "return", "type": "return", "loc": [71, 71], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98837:FunctionDef_L70_C4", "vector": [13, 2, 0.5, 0.007, 2, 0.36, 0.0, 0, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return self.objects"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98837:FunctionDef_L73_C0", "label": "Deserializer", "type": "function", "loc": [73, 130], "level": 0, "parent": null, "vector": [2, 0, 0.7148, 0.4085, 0, 0.66, 0.8571, 604, 0, 2, 1, 0, 0, 0, 32], "semantic": {"name": "Deserializer", "arg_names": ["object_list", "options"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "def Deserializer(object_list, **options):\n \"\"\"\n Deserialize simple Python objects back into Django ORM instances.\n\n It's expected that you pass the Python objects themselves (instead of a\n stream or a string) to the constructor\n \"\"\"\n db = options.pop('using', DEFAULT_DB_ALIAS)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98837:Expr_L74_C4", "label": "expression", "type": "expression", "loc": [74, 79], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98837:FunctionDef_L73_C0", "vector": [8, 1, 0.5387, 0.0423, 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 Deserialize simple Python objects back into Django ORM instances.\n\n It's expected that you pass the Python objects themselves (instead of a\n stream or a string) to the constructor\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98837:Assign_L80_C4", "label": "db = pop()", "type": "assigned_variable", "loc": [80, 80], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98837:FunctionDef_L73_C0", "vector": [14, 1, 0.5634, 0.007, 1, 0.91, 0.3333, 761, 3, 2, 0, 0, 969, 10, 1], "semantic": {"name": "db", "arg_names": [], "import_names": [], "rhs_call_name": "pop", "annotation": ""}, "snippet": " db = options.pop('using', DEFAULT_DB_ALIAS)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98837:Expr_L81_C4", "label": "get_apps()", "type": "expression", "loc": [81, 81], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98837:FunctionDef_L73_C0", "vector": [8, 1, 0.5704, 0.007, 1, 0.91, 0.6667, 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_98837:For_L82_C4", "label": "for d", "type": "for", "loc": [82, 130], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98837:FunctionDef_L73_C0", "vector": [6, 1, 0.7465, 0.3451, 1, 0.91, 1.0, 355, 2, 0, 0, 0, 0, 0, 30], "semantic": {"name": "d", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for d in object_list:\n # Look up the model and starting build a dict of data for it.\n Model = _get_model(d[\"model\"])\n data = {Model._meta.pk.attname : Model._meta.pk.to_python(d[\"pk\"])}\n m2m_data = {}\n\n # Handle each field\n for (field_name, field_value) in d[\"fields\"].iteritems():"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98837:Assign_L84_C8", "label": "Model = _get_model()", "type": "assigned_variable", "loc": [84, 84], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98837:For_L82_C4", "vector": [14, 2, 0.5915, 0.007, 2, 0.0, 0.0, 929, 3, 1, 0, 0, 990, 10, 1], "semantic": {"name": "Model", "arg_names": [], "import_names": [], "rhs_call_name": "_get_model", "annotation": ""}, "snippet": " Model = _get_model(d[\"model\"])"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98837:Assign_L85_C8", "label": "data =", "type": "assigned_variable", "loc": [85, 85], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98837:For_L82_C4", "vector": [14, 2, 0.5986, 0.007, 2, 0.0, 0.25, 929, 0, 0, 0, 0, 0, 6, 1], "semantic": {"name": "data", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " data = {Model._meta.pk.attname : Model._meta.pk.to_python(d[\"pk\"])}"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98837:Assign_L86_C8", "label": "m2m_data =", "type": "assigned_variable", "loc": [86, 86], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98837:For_L82_C4", "vector": [14, 2, 0.6056, 0.007, 2, 0.0, 0.5, 586, 0, 0, 0, 0, 0, 6, 0], "semantic": {"name": "m2m_data", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " m2m_data = {}"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98837:For_L89_C8", "label": "for field_name, field_value", "type": "for", "loc": [89, 128], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98837:For_L82_C4", "vector": [6, 2, 0.7641, 0.2817, 2, 0.0, 0.75, 47, 3, 0, 0, 0, 0, 0, 26], "semantic": {"name": "field_name, field_value", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for (field_name, field_value) in d[\"fields\"].iteritems():\n if isinstance(field_value, str):\n field_value = smart_unicode(field_value, options.get(\"encoding\", settings.DEFAULT_CHARSET), strings_only=True)\n\n field = Model._meta.get_field(field_name)\n\n # Handle M2M relations\n if field.rel and isinstance(field.rel, models.ManyToManyRel):"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98837:If_L90_C12", "label": "if", "type": "if", "loc": [90, 91], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98837:For_L89_C8", "vector": [4, 3, 0.6373, 0.0141, 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 isinstance(field_value, str):\n field_value = smart_unicode(field_value, options.get(\"encoding\", settings.DEFAULT_CHARSET), strings_only=True)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98837:Assign_L91_C16", "label": "field_value = smart_unicode()", "type": "assigned_variable", "loc": [91, 91], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98837:If_L90_C12", "vector": [14, 4, 0.6408, 0.007, 4, 0.44, 0.0, 900, 3, 3, 0, 0, 349, 10, 2], "semantic": {"name": "field_value", "arg_names": [], "import_names": [], "rhs_call_name": "smart_unicode", "annotation": ""}, "snippet": " field_value = smart_unicode(field_value, options.get(\"encoding\", settings.DEFAULT_CHARSET), strings_only=True)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98837:Assign_L93_C12", "label": "field = get_field()", "type": "assigned_variable", "loc": [93, 93], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98837:For_L89_C8", "vector": [14, 3, 0.6549, 0.007, 3, 0.11, 0.5, 480, 3, 1, 0, 0, 389, 10, 1], "semantic": {"name": "field", "arg_names": [], "import_names": [], "rhs_call_name": "get_field", "annotation": ""}, "snippet": " field = Model._meta.get_field(field_name)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98837:If_L96_C12", "label": "if", "type": "if", "loc": [96, 128], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98837:For_L89_C8", "vector": [4, 3, 0.7887, 0.2324, 3, 0.11, 1.0, 0, 0, 0, 0, 0, 0, 0, 21], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if field.rel and isinstance(field.rel, models.ManyToManyRel):\n if hasattr(field.rel.to._default_manager, 'get_by_natural_key'):\n def m2m_convert(value):\n if hasattr(value, '__iter__'):\n return field.rel.to._default_manager.db_manager(db).get_by_natural_key(*value).pk\n else:\n return smart_unicode(field.rel.to._meta.pk.to_python(value))\n else:"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98837:If_L97_C16", "label": "if", "type": "if", "loc": [97, 104], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98837:If_L96_C12", "vector": [4, 4, 0.7077, 0.0563, 4, 0.01, 0.0, 0, 3, 0, 0, 0, 0, 0, 8], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if hasattr(field.rel.to._default_manager, 'get_by_natural_key'):\n def m2m_convert(value):\n if hasattr(value, '__iter__'):\n return field.rel.to._default_manager.db_manager(db).get_by_natural_key(*value).pk\n else:\n return smart_unicode(field.rel.to._meta.pk.to_python(value))\n else:\n m2m_convert = lambda v: smart_unicode(field.rel.to._meta.pk.to_python(v))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98837:FunctionDef_L98_C20", "label": "m2m_convert", "type": "function", "loc": [98, 102], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98837:If_L97_C16", "vector": [2, 5, 0.7042, 0.0352, 5, 0.97, 0.0, 675, 0, 1, 1, 0, 0, 0, 5], "semantic": {"name": "m2m_convert", "arg_names": ["value"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def m2m_convert(value):\n if hasattr(value, '__iter__'):\n return field.rel.to._default_manager.db_manager(db).get_by_natural_key(*value).pk\n else:\n return smart_unicode(field.rel.to._meta.pk.to_python(value))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98837:If_L99_C24", "label": "if", "type": "if", "loc": [99, 102], "level": 6, "parent": "ajibawa-2023/Python-Code-Large/train/row_98837:FunctionDef_L98_C20", "vector": [4, 6, 0.7077, 0.0282, 6, 0.07, 0.0, 0, 3, 0, 0, 0, 0, 0, 5], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if hasattr(value, '__iter__'):\n return field.rel.to._default_manager.db_manager(db).get_by_natural_key(*value).pk\n else:\n return smart_unicode(field.rel.to._meta.pk.to_python(value))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98837:Return_L100_C28", "label": "return", "type": "return", "loc": [100, 100], "level": 7, "parent": "ajibawa-2023/Python-Code-Large/train/row_98837:If_L99_C24", "vector": [13, 7, 0.7042, 0.007, 7, 0.94, 0.0, 0, 7, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return field.rel.to._default_manager.db_manager(db).get_by_natural_key(*value).pk"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98837:Return_L102_C28", "label": "return", "type": "return", "loc": [102, 102], "level": 7, "parent": "ajibawa-2023/Python-Code-Large/train/row_98837:If_L99_C24", "vector": [13, 7, 0.7183, 0.007, 7, 0.94, 1.0, 0, 3, 0, 0, 0, 0, 10, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return smart_unicode(field.rel.to._meta.pk.to_python(value))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98837:Assign_L104_C20", "label": "m2m_convert =", "type": "assigned_variable", "loc": [104, 104], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98837:If_L97_C16", "vector": [14, 5, 0.7324, 0.007, 5, 0.97, 1.0, 675, 9, 0, 0, 0, 0, 0, 2], "semantic": {"name": "m2m_convert", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " m2m_convert = lambda v: smart_unicode(field.rel.to._meta.pk.to_python(v))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98837:Assign_L105_C16", "label": "assign", "type": "assigned_variable", "loc": [105, 105], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98837:If_L96_C12", "vector": [14, 4, 0.7394, 0.007, 4, 0.01, 0.5, 0, 5, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " m2m_data[field.name] = [m2m_convert(pk) for pk in field_value]"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98837:If_L108_C12", "label": "if", "type": "if", "loc": [108, 128], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98837:If_L96_C12", "vector": [4, 4, 0.831, 0.1479, 4, 0.01, 1.0, 0, 0, 0, 0, 0, 0, 0, 11], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " elif field.rel and isinstance(field.rel, models.ManyToOneRel):\n if field_value is not None:\n if hasattr(field.rel.to._default_manager, 'get_by_natural_key'):\n if hasattr(field_value, '__iter__'):\n obj = field.rel.to._default_manager.db_manager(db).get_by_natural_key(*field_value)\n value = getattr(obj, field.rel.field_name)\n # If this is a natural foreign key to an object that\n # has a FK/O2O as the foreign key, use the FK value"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98837:If_L109_C16", "label": "if", "type": "if", "loc": [109, 124], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98837:If_L108_C12", "vector": [4, 5, 0.8204, 0.1127, 5, 0.5, 0.0, 0, 0, 0, 0, 0, 0, 0, 9], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if field_value is not None:\n if hasattr(field.rel.to._default_manager, 'get_by_natural_key'):\n if hasattr(field_value, '__iter__'):\n obj = field.rel.to._default_manager.db_manager(db).get_by_natural_key(*field_value)\n value = getattr(obj, field.rel.field_name)\n # If this is a natural foreign key to an object that\n # has a FK/O2O as the foreign key, use the FK value\n if field.rel.to._meta.pk.rel:"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98837:If_L110_C20", "label": "if", "type": "if", "loc": [110, 122], "level": 6, "parent": "ajibawa-2023/Python-Code-Large/train/row_98837:If_L109_C16", "vector": [4, 6, 0.8169, 0.0915, 6, 0.68, 0.0, 0, 3, 0, 0, 0, 0, 0, 9], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if hasattr(field.rel.to._default_manager, 'get_by_natural_key'):\n if hasattr(field_value, '__iter__'):\n obj = field.rel.to._default_manager.db_manager(db).get_by_natural_key(*field_value)\n value = getattr(obj, field.rel.field_name)\n # If this is a natural foreign key to an object that\n # has a FK/O2O as the foreign key, use the FK value\n if field.rel.to._meta.pk.rel:\n value = value.pk"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98837:If_L111_C24", "label": "if", "type": "if", "loc": [111, 119], "level": 7, "parent": "ajibawa-2023/Python-Code-Large/train/row_98837:If_L110_C20", "vector": [4, 7, 0.8099, 0.0634, 7, 0.91, 0.0, 0, 3, 0, 0, 0, 0, 0, 6], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if hasattr(field_value, '__iter__'):\n obj = field.rel.to._default_manager.db_manager(db).get_by_natural_key(*field_value)\n value = getattr(obj, field.rel.field_name)\n # If this is a natural foreign key to an object that\n # has a FK/O2O as the foreign key, use the FK value\n if field.rel.to._meta.pk.rel:\n value = value.pk\n else:"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98837:Assign_L112_C28", "label": "obj = get_by_natural_key()", "type": "assigned_variable", "loc": [112, 112], "level": 8, "parent": "ajibawa-2023/Python-Code-Large/train/row_98837:If_L111_C24", "vector": [14, 8, 0.7887, 0.007, 8, 0.45, 0.0, 505, 3, 1, 0, 0, 668, 10, 2], "semantic": {"name": "obj", "arg_names": [], "import_names": [], "rhs_call_name": "get_by_natural_key", "annotation": ""}, "snippet": " obj = field.rel.to._default_manager.db_manager(db).get_by_natural_key(*field_value)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98837:Assign_L113_C28", "label": "value = getattr()", "type": "assigned_variable", "loc": [113, 113], "level": 8, "parent": "ajibawa-2023/Python-Code-Large/train/row_98837:If_L111_C24", "vector": [14, 8, 0.7958, 0.007, 8, 0.45, 0.3333, 441, 3, 2, 0, 0, 121, 10, 1], "semantic": {"name": "value", "arg_names": [], "import_names": [], "rhs_call_name": "getattr", "annotation": ""}, "snippet": " value = getattr(obj, field.rel.field_name)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98837:If_L116_C28", "label": "if", "type": "if", "loc": [116, 117], "level": 8, "parent": "ajibawa-2023/Python-Code-Large/train/row_98837:If_L111_C24", "vector": [4, 8, 0.8204, 0.0141, 8, 0.45, 0.6667, 0, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if field.rel.to._meta.pk.rel:\n value = value.pk"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98837:Assign_L117_C32", "label": "value =", "type": "assigned_variable", "loc": [117, 117], "level": 9, "parent": "ajibawa-2023/Python-Code-Large/train/row_98837:If_L116_C28", "vector": [14, 9, 0.8239, 0.007, 9, 0.34, 0.0, 441, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "value", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " value = value.pk"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98837:Assign_L119_C28", "label": "value = to_python()", "type": "assigned_variable", "loc": [119, 119], "level": 8, "parent": "ajibawa-2023/Python-Code-Large/train/row_98837:If_L111_C24", "vector": [14, 8, 0.838, 0.007, 8, 0.45, 1.0, 441, 3, 1, 0, 0, 800, 10, 2], "semantic": {"name": "value", "arg_names": [], "import_names": [], "rhs_call_name": "to_python", "annotation": ""}, "snippet": " value = field.rel.to._meta.get_field(field.rel.field_name).to_python(field_value)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98837:Assign_L120_C24", "label": "assign", "type": "assigned_variable", "loc": [120, 120], "level": 7, "parent": "ajibawa-2023/Python-Code-Large/train/row_98837:If_L110_C20", "vector": [14, 7, 0.8451, 0.007, 7, 0.91, 0.5, 0, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " data[field.attname] = value"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98837:Assign_L122_C24", "label": " = to_python()", "type": "assigned_variable", "loc": [122, 122], "level": 7, "parent": "ajibawa-2023/Python-Code-Large/train/row_98837:If_L110_C20", "vector": [14, 7, 0.8592, 0.007, 7, 0.91, 1.0, 0, 3, 1, 0, 0, 800, 10, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "to_python", "annotation": ""}, "snippet": " data[field.attname] = field.rel.to._meta.get_field(field.rel.field_name).to_python(field_value)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98837:Assign_L124_C20", "label": "assign", "type": "assigned_variable", "loc": [124, 124], "level": 6, "parent": "ajibawa-2023/Python-Code-Large/train/row_98837:If_L109_C16", "vector": [14, 6, 0.8732, 0.007, 6, 0.68, 1.0, 0, 1, 0, 0, 0, 0, 9, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " data[field.attname] = None"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98837:Assign_L128_C16", "label": " = to_python()", "type": "assigned_variable", "loc": [128, 128], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98837:If_L108_C12", "vector": [14, 5, 0.9014, 0.007, 5, 0.5, 1.0, 0, 3, 1, 0, 0, 800, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "to_python", "annotation": ""}, "snippet": " data[field.name] = field.to_python(field_value)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98837:Expr_L130_C8", "label": "expression", "type": "expression", "loc": [130, 130], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98837:For_L82_C4", "vector": [8, 2, 0.9155, 0.007, 2, 0.0, 1.0, 0, 0, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " yield base.DeserializedObject(Model(**data), m2m_data)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98837:FunctionDef_L132_C0", "label": "_get_model", "type": "function", "loc": [132, 142], "level": 0, "parent": null, "vector": [2, 0, 0.9648, 0.0775, 0, 0.66, 1.0, 990, 0, 1, 1, 0, 0, 0, 3], "semantic": {"name": "_get_model", "arg_names": ["model_identifier"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "def _get_model(model_identifier):\n \"\"\"\n Helper to look up a model from an \"app_label.module_name\" string.\n \"\"\"\n try:\n Model = models.get_model(*model_identifier.split(\".\"))\n except TypeError:\n Model = None"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98837:Expr_L133_C4", "label": "expression", "type": "expression", "loc": [133, 135], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98837:FunctionDef_L132_C0", "vector": [8, 1, 0.9437, 0.0211, 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 Helper to look up a model from an \"app_label.module_name\" string.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98837:Try_L136_C4", "label": "try", "type": "try", "loc": [136, 139], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98837:FunctionDef_L132_C0", "vector": [7, 1, 0.9683, 0.0282, 1, 0.28, 0.3333, 0, 0, 1, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " try:\n Model = models.get_model(*model_identifier.split(\".\"))\n except TypeError:\n Model = None"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98837:Assign_L137_C8", "label": "Model = get_model()", "type": "assigned_variable", "loc": [137, 137], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98837:Try_L136_C4", "vector": [14, 2, 0.9648, 0.007, 2, 0.28, 0.0, 929, 3, 1, 0, 0, 115, 10, 2], "semantic": {"name": "Model", "arg_names": [], "import_names": [], "rhs_call_name": "get_model", "annotation": ""}, "snippet": " Model = models.get_model(*model_identifier.split(\".\"))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98837:Assign_L139_C8", "label": "Model =", "type": "assigned_variable", "loc": [139, 139], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98837:Try_L136_C4", "vector": [14, 2, 0.9789, 0.007, 2, 0.28, 0.0, 929, 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_98837:If_L140_C4", "label": "if", "type": "if", "loc": [140, 141], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98837:FunctionDef_L132_C0", "vector": [4, 1, 0.9894, 0.0141, 1, 0.28, 0.6667, 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 base.DeserializationError(u\"Invalid model identifier: '%s'\" % model_identifier)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98837:Return_L142_C4", "label": "return", "type": "return", "loc": [142, 142], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98837:FunctionDef_L132_C0", "vector": [13, 1, 1.0, 0.007, 1, 0.28, 1.0, 0, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return Model"}]
[{"f": "ajibawa-2023/Python-Code-Large/train/row_98837:ClassDef_L12_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98837:Expr_L13_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98837:ClassDef_L12_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98837:Assign_L17_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98837:ClassDef_L12_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98837:FunctionDef_L19_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98837:FunctionDef_L19_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98837:Assign_L20_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98837:FunctionDef_L19_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98837:Assign_L21_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98837:ClassDef_L12_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98837:FunctionDef_L23_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98837:ClassDef_L12_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98837:FunctionDef_L26_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98837:FunctionDef_L26_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98837:Assign_L27_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98837:ClassDef_L12_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98837:FunctionDef_L29_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98837:FunctionDef_L29_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98837:Expr_L30_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98837:FunctionDef_L29_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98837:Assign_L35_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98837:ClassDef_L12_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98837:FunctionDef_L37_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98837:FunctionDef_L37_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98837:Assign_L38_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98837:FunctionDef_L37_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98837:If_L42_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98837:If_L42_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98837:Assign_L43_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98837:If_L42_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98837:Assign_L45_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98837:ClassDef_L12_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98837:FunctionDef_L47_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98837:FunctionDef_L47_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98837:Assign_L48_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98837:FunctionDef_L47_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98837:If_L49_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98837:If_L49_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98837:If_L50_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98837:If_L50_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98837:Assign_L51_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98837:If_L50_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98837:If_L53_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98837:If_L53_C16", "t": "ajibawa-2023/Python-Code-Large/train/row_98837:Assign_L55_C20"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98837:If_L53_C16", "t": "ajibawa-2023/Python-Code-Large/train/row_98837:Assign_L58_C20"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98837:FunctionDef_L47_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98837:Assign_L59_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98837:ClassDef_L12_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98837:FunctionDef_L61_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98837:FunctionDef_L61_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98837:If_L62_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98837:If_L62_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98837:If_L63_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98837:If_L63_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98837:Assign_L64_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98837:If_L63_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98837:Assign_L66_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98837:If_L62_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98837:Assign_L67_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98837:ClassDef_L12_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98837:FunctionDef_L70_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98837:FunctionDef_L70_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98837:Return_L71_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98837:FunctionDef_L73_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98837:Expr_L74_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98837:FunctionDef_L73_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98837:Assign_L80_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98837:FunctionDef_L73_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98837:Expr_L81_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98837:FunctionDef_L73_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98837:For_L82_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98837:For_L82_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98837:Assign_L84_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98837:For_L82_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98837:Assign_L85_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98837:For_L82_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98837:Assign_L86_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98837:For_L82_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98837:For_L89_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98837:For_L89_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98837:If_L90_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98837:If_L90_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98837:Assign_L91_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98837:For_L89_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98837:Assign_L93_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98837:For_L89_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98837:If_L96_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98837:If_L96_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98837:If_L97_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98837:If_L97_C16", "t": "ajibawa-2023/Python-Code-Large/train/row_98837:FunctionDef_L98_C20"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98837:FunctionDef_L98_C20", "t": "ajibawa-2023/Python-Code-Large/train/row_98837:If_L99_C24"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98837:If_L99_C24", "t": "ajibawa-2023/Python-Code-Large/train/row_98837:Return_L100_C28"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98837:If_L99_C24", "t": "ajibawa-2023/Python-Code-Large/train/row_98837:Return_L102_C28"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98837:If_L97_C16", "t": "ajibawa-2023/Python-Code-Large/train/row_98837:Assign_L104_C20"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98837:If_L96_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98837:Assign_L105_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98837:If_L96_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98837:If_L108_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98837:If_L108_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98837:If_L109_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98837:If_L109_C16", "t": "ajibawa-2023/Python-Code-Large/train/row_98837:If_L110_C20"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98837:If_L110_C20", "t": "ajibawa-2023/Python-Code-Large/train/row_98837:If_L111_C24"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98837:If_L111_C24", "t": "ajibawa-2023/Python-Code-Large/train/row_98837:Assign_L112_C28"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98837:If_L111_C24", "t": "ajibawa-2023/Python-Code-Large/train/row_98837:Assign_L113_C28"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98837:If_L111_C24", "t": "ajibawa-2023/Python-Code-Large/train/row_98837:If_L116_C28"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98837:If_L116_C28", "t": "ajibawa-2023/Python-Code-Large/train/row_98837:Assign_L117_C32"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98837:If_L111_C24", "t": "ajibawa-2023/Python-Code-Large/train/row_98837:Assign_L119_C28"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98837:If_L110_C20", "t": "ajibawa-2023/Python-Code-Large/train/row_98837:Assign_L120_C24"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98837:If_L110_C20", "t": "ajibawa-2023/Python-Code-Large/train/row_98837:Assign_L122_C24"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98837:If_L109_C16", "t": "ajibawa-2023/Python-Code-Large/train/row_98837:Assign_L124_C20"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98837:If_L108_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98837:Assign_L128_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98837:For_L82_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98837:Expr_L130_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98837:FunctionDef_L132_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98837:Expr_L133_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98837:FunctionDef_L132_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98837:Try_L136_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98837:Try_L136_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98837:Assign_L137_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98837:Try_L136_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98837:Assign_L139_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98837:FunctionDef_L132_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98837:If_L140_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98837:FunctionDef_L132_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98837:Return_L142_C4"}]
""" Module for abstract serializer/unserializer base classes. """ from StringIO import StringIO from django.db import models from django.utils.encoding import smart_str, smart_unicode from django.utils import datetime_safe class SerializationError(Exception): """Something bad happened during serialization.""" pass class DeserializationError(Exception): """Something bad happened during deserialization.""" pass class Serializer(object): """ Abstract serializer base class. """ # Indicates if the implemented serializer is only available for # internal Django use. internal_use_only = False def serialize(self, queryset, **options): """ Serialize a queryset. """ self.options = options self.stream = options.get("stream", StringIO()) self.selected_fields = options.get("fields") self.use_natural_keys = options.get("use_natural_keys", False) self.start_serialization() for obj in queryset: self.start_object(obj) for field in obj._meta.local_fields: if field.serialize: if field.rel is None: if self.selected_fields is None or field.attname in self.selected_fields: self.handle_field(obj, field) else: if self.selected_fields is None or field.attname[:-3] in self.selected_fields: self.handle_fk_field(obj, field) for field in obj._meta.many_to_many: if field.serialize: if self.selected_fields is None or field.attname in self.selected_fields: self.handle_m2m_field(obj, field) self.end_object(obj) self.end_serialization() return self.getvalue() def get_string_value(self, obj, field): """ Convert a field's value to a string. """ return smart_unicode(field.value_to_string(obj)) def start_serialization(self): """ Called when serializing of the queryset starts. """ raise NotImplementedError def end_serialization(self): """ Called when serializing of the queryset ends. """ pass def start_object(self, obj): """ Called when serializing of an object starts. """ raise NotImplementedError def end_object(self, obj): """ Called when serializing of an object ends. """ pass def handle_field(self, obj, field): """ Called to handle each individual (non-relational) field on an object. """ raise NotImplementedError def handle_fk_field(self, obj, field): """ Called to handle a ForeignKey field. """ raise NotImplementedError def handle_m2m_field(self, obj, field): """ Called to handle a ManyToManyField. """ raise NotImplementedError def getvalue(self): """ Return the fully serialized queryset (or None if the output stream is not seekable). """ if callable(getattr(self.stream, 'getvalue', None)): return self.stream.getvalue() class Deserializer(object): """ Abstract base deserializer class. """ def __init__(self, stream_or_string, **options): """ Init this serializer given a stream or a string """ self.options = options if isinstance(stream_or_string, basestring): self.stream = StringIO(stream_or_string) else: self.stream = stream_or_string # hack to make sure that the models have all been loaded before # deserialization starts (otherwise subclass calls to get_model() # and friends might fail...) models.get_apps() def __iter__(self): return self def next(self): """Iteration iterface -- return the next item in the stream""" raise NotImplementedError class DeserializedObject(object): """ A deserialized model. Basically a container for holding the pre-saved deserialized data along with the many-to-many data saved with the object. Call ``save()`` to save the object (with the many-to-many data) to the database; call ``save(save_m2m=False)`` to save just the object fields (and not touch the many-to-many stuff.) """ def __init__(self, obj, m2m_data=None): self.object = obj self.m2m_data = m2m_data def __repr__(self): return "<DeserializedObject: %s.%s(pk=%s)>" % ( self.object._meta.app_label, self.object._meta.object_name, self.object.pk) def save(self, save_m2m=True, using=None): # Call save on the Model baseclass directly. This bypasses any # model-defined save. The save is also forced to be raw. # This ensures that the data that is deserialized is literally # what came from the file, not post-processed by pre_save/save # methods. models.Model.save_base(self.object, using=using, raw=True) if self.m2m_data and save_m2m: for accessor_name, object_list in self.m2m_data.items(): setattr(self.object, accessor_name, object_list) # prevent a second (possibly accidental) call to save() from saving # the m2m data twice. self.m2m_data = None
ajibawa-2023/Python-Code-Large/train/row_98838
82
172
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_98838:Expr_L1_C0", "label": "expression", "type": "expression", "loc": [1, 3], "level": 0, "parent": null, "vector": [8, 0, 0.0116, 0.0174, 0, 0.66, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "\"\"\"\nModule for abstract serializer/unserializer base classes.\n\"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98838:ImportFrom_L5_C0", "label": "from StringIO import StringIO", "type": "import", "loc": [5, 5], "level": 0, "parent": null, "vector": [1, 0, 0.0291, 0.0058, 0, 0.66, 0.1111, 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_98838:ImportFrom_L7_C0", "label": "from django.db import models", "type": "import", "loc": [7, 7], "level": 0, "parent": null, "vector": [1, 0, 0.0407, 0.0058, 0, 0.66, 0.2222, 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_98838:ImportFrom_L8_C0", "label": "from django.utils.encoding import smart_str, smart_unicode", "type": "import", "loc": [8, 8], "level": 0, "parent": null, "vector": [1, 0, 0.0465, 0.0058, 0, 0.66, 0.3333, 96, 0, 2, 0, 0, 96, 0, 0], "semantic": {"name": "django.utils.encoding", "arg_names": [], "import_names": ["smart_str", "smart_unicode"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.utils.encoding import smart_str, smart_unicode"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98838:ImportFrom_L9_C0", "label": "from django.utils import datetime_safe", "type": "import", "loc": [9, 9], "level": 0, "parent": null, "vector": [1, 0, 0.0523, 0.0058, 0, 0.66, 0.4444, 944, 0, 1, 0, 0, 944, 0, 0], "semantic": {"name": "django.utils", "arg_names": [], "import_names": ["datetime_safe"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.utils import datetime_safe"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98838:ClassDef_L11_C0", "label": "SerializationError", "type": "class", "loc": [11, 13], "level": 0, "parent": null, "vector": [3, 0, 0.0698, 0.0174, 0, 0.66, 0.5556, 57, 0, 0, 0, 0, 645, 0, 0], "semantic": {"name": "SerializationError", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class SerializationError(Exception):\n \"\"\"Something bad happened during serialization.\"\"\"\n pass"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98838:Expr_L12_C4", "label": "expression", "type": "expression", "loc": [12, 12], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98838:ClassDef_L11_C0", "vector": [8, 1, 0.0698, 0.0058, 1, 0.77, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"Something bad happened during serialization.\"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98838:ClassDef_L15_C0", "label": "DeserializationError", "type": "class", "loc": [15, 17], "level": 0, "parent": null, "vector": [3, 0, 0.093, 0.0174, 0, 0.66, 0.6667, 81, 0, 0, 0, 0, 645, 0, 0], "semantic": {"name": "DeserializationError", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class DeserializationError(Exception):\n \"\"\"Something bad happened during deserialization.\"\"\"\n pass"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98838:Expr_L16_C4", "label": "expression", "type": "expression", "loc": [16, 16], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98838:ClassDef_L15_C0", "vector": [8, 1, 0.093, 0.0058, 1, 0.84, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"Something bad happened during deserialization.\"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98838:ClassDef_L19_C0", "label": "Serializer", "type": "class", "loc": [19, 111], "level": 0, "parent": null, "vector": [3, 0, 0.3779, 0.5407, 0, 0.66, 0.7778, 577, 0, 10, 0, 0, 186, 0, 17], "semantic": {"name": "Serializer", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class Serializer(object):\n \"\"\"\n Abstract serializer base class.\n \"\"\"\n\n # Indicates if the implemented serializer is only available for\n # internal Django use.\n internal_use_only = False"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98838:Expr_L20_C4", "label": "expression", "type": "expression", "loc": [20, 22], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98838:ClassDef_L19_C0", "vector": [8, 1, 0.1221, 0.0174, 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 Abstract serializer base class.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98838:Assign_L26_C4", "label": "internal_use_only =", "type": "assigned_variable", "loc": [26, 26], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98838:ClassDef_L19_C0", "vector": [14, 1, 0.1512, 0.0058, 1, 0.71, 0.0909, 17, 1, 0, 0, 0, 0, 4, 0], "semantic": {"name": "internal_use_only", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " internal_use_only = False"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98838:FunctionDef_L28_C4", "label": "serialize", "type": "function", "loc": [28, 55], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98838:ClassDef_L19_C0", "vector": [2, 1, 0.2413, 0.1628, 1, 0.71, 0.1818, 50, 0, 3, 1, 0, 0, 0, 12], "semantic": {"name": "serialize", "arg_names": ["self", "queryset", "options"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def serialize(self, queryset, **options):\n \"\"\"\n Serialize a queryset.\n \"\"\"\n self.options = options\n\n self.stream = options.get(\"stream\", StringIO())\n self.selected_fields = options.get(\"fields\")"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98838:Expr_L29_C8", "label": "expression", "type": "expression", "loc": [29, 31], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98838:FunctionDef_L28_C4", "vector": [8, 2, 0.1744, 0.0174, 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 Serialize a queryset.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98838:Assign_L32_C8", "label": "self.options =", "type": "assigned_variable", "loc": [32, 32], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98838:FunctionDef_L28_C4", "vector": [14, 2, 0.186, 0.0058, 2, 0.32, 0.125, 968, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "self.options", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.options = options"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98838:Assign_L34_C8", "label": "self.stream = get()", "type": "assigned_variable", "loc": [34, 34], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98838:FunctionDef_L28_C4", "vector": [14, 2, 0.1977, 0.0058, 2, 0.32, 0.25, 207, 3, 2, 0, 0, 607, 10, 2], "semantic": {"name": "self.stream", "arg_names": [], "import_names": [], "rhs_call_name": "get", "annotation": ""}, "snippet": " self.stream = options.get(\"stream\", StringIO())"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98838:Assign_L35_C8", "label": "self.selected_fields = get()", "type": "assigned_variable", "loc": [35, 35], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98838:FunctionDef_L28_C4", "vector": [14, 2, 0.2035, 0.0058, 2, 0.32, 0.375, 758, 3, 1, 0, 0, 607, 10, 1], "semantic": {"name": "self.selected_fields", "arg_names": [], "import_names": [], "rhs_call_name": "get", "annotation": ""}, "snippet": " self.selected_fields = options.get(\"fields\")"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98838:Assign_L36_C8", "label": "self.use_natural_keys = get()", "type": "assigned_variable", "loc": [36, 36], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98838:FunctionDef_L28_C4", "vector": [14, 2, 0.2093, 0.0058, 2, 0.32, 0.5, 515, 3, 2, 0, 0, 607, 10, 1], "semantic": {"name": "self.use_natural_keys", "arg_names": [], "import_names": [], "rhs_call_name": "get", "annotation": ""}, "snippet": " self.use_natural_keys = options.get(\"use_natural_keys\", False)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98838:Expr_L38_C8", "label": "start_serialization()", "type": "expression", "loc": [38, 38], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98838:FunctionDef_L28_C4", "vector": [8, 2, 0.2209, 0.0058, 2, 0.32, 0.625, 476, 3, 0, 0, 0, 0, 0, 1], "semantic": {"name": "start_serialization", "arg_names": [], "import_names": [], "rhs_call_name": "start_serialization", "annotation": ""}, "snippet": " self.start_serialization()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98838:For_L39_C8", "label": "for obj", "type": "for", "loc": [39, 53], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98838:FunctionDef_L28_C4", "vector": [6, 2, 0.2674, 0.0872, 2, 0.32, 0.75, 505, 2, 0, 0, 0, 0, 0, 5], "semantic": {"name": "obj", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for obj in queryset:\n self.start_object(obj)\n for field in obj._meta.local_fields:\n if field.serialize:\n if field.rel is None:\n if self.selected_fields is None or field.attname in self.selected_fields:\n self.handle_field(obj, field)\n else:"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98838:Expr_L40_C12", "label": "start_object()", "type": "expression", "loc": [40, 40], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98838:For_L39_C8", "vector": [8, 3, 0.2326, 0.0058, 3, 0.93, 0.0, 939, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "start_object", "arg_names": [], "import_names": [], "rhs_call_name": "start_object", "annotation": ""}, "snippet": " self.start_object(obj)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98838:For_L41_C12", "label": "for field", "type": "for", "loc": [41, 48], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98838:For_L39_C8", "vector": [6, 3, 0.2587, 0.0465, 3, 0.93, 0.3333, 480, 7, 0, 0, 0, 0, 0, 2], "semantic": {"name": "field", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for field in obj._meta.local_fields:\n if field.serialize:\n if field.rel is None:\n if self.selected_fields is None or field.attname in self.selected_fields:\n self.handle_field(obj, field)\n else:\n if self.selected_fields is None or field.attname[:-3] in self.selected_fields:\n self.handle_fk_field(obj, field)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98838:If_L42_C16", "label": "if", "type": "if", "loc": [42, 48], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98838:For_L41_C12", "vector": [4, 4, 0.2616, 0.0407, 4, 0.78, 0.0, 0, 7, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if field.serialize:\n if field.rel is None:\n if self.selected_fields is None or field.attname in self.selected_fields:\n self.handle_field(obj, field)\n else:\n if self.selected_fields is None or field.attname[:-3] in self.selected_fields:\n self.handle_fk_field(obj, field)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98838:If_L43_C20", "label": "if", "type": "if", "loc": [43, 48], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98838:If_L42_C16", "vector": [4, 5, 0.2645, 0.0349, 5, 0.61, 0.0, 0, 0, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if field.rel is None:\n if self.selected_fields is None or field.attname in self.selected_fields:\n self.handle_field(obj, field)\n else:\n if self.selected_fields is None or field.attname[:-3] in self.selected_fields:\n self.handle_fk_field(obj, field)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98838:If_L44_C24", "label": "if", "type": "if", "loc": [44, 45], "level": 6, "parent": "ajibawa-2023/Python-Code-Large/train/row_98838:If_L43_C20", "vector": [4, 6, 0.2587, 0.0116, 6, 0.33, 0.0, 0, 0, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if self.selected_fields is None or field.attname in self.selected_fields:\n self.handle_field(obj, field)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98838:Expr_L45_C28", "label": "handle_field()", "type": "expression", "loc": [45, 45], "level": 7, "parent": "ajibawa-2023/Python-Code-Large/train/row_98838:If_L44_C24", "vector": [8, 7, 0.2616, 0.0058, 7, 0.34, 0.0, 277, 3, 2, 0, 0, 0, 0, 1], "semantic": {"name": "handle_field", "arg_names": [], "import_names": [], "rhs_call_name": "handle_field", "annotation": ""}, "snippet": " self.handle_field(obj, field)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98838:If_L47_C24", "label": "if", "type": "if", "loc": [47, 48], "level": 6, "parent": "ajibawa-2023/Python-Code-Large/train/row_98838:If_L43_C20", "vector": [4, 6, 0.2762, 0.0116, 6, 0.33, 1.0, 0, 0, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if self.selected_fields is None or field.attname[:-3] in self.selected_fields:\n self.handle_fk_field(obj, field)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98838:Expr_L48_C28", "label": "handle_fk_field()", "type": "expression", "loc": [48, 48], "level": 7, "parent": "ajibawa-2023/Python-Code-Large/train/row_98838:If_L47_C24", "vector": [8, 7, 0.2791, 0.0058, 7, 0.82, 0.0, 279, 3, 2, 0, 0, 0, 0, 1], "semantic": {"name": "handle_fk_field", "arg_names": [], "import_names": [], "rhs_call_name": "handle_fk_field", "annotation": ""}, "snippet": " self.handle_fk_field(obj, field)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98838:For_L49_C12", "label": "for field", "type": "for", "loc": [49, 52], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98838:For_L39_C8", "vector": [6, 3, 0.2936, 0.0233, 3, 0.93, 0.6667, 480, 7, 0, 0, 0, 0, 0, 1], "semantic": {"name": "field", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for field in obj._meta.many_to_many:\n if field.serialize:\n if self.selected_fields is None or field.attname in self.selected_fields:\n self.handle_m2m_field(obj, field)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98838:If_L50_C16", "label": "if", "type": "if", "loc": [50, 52], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98838:For_L49_C12", "vector": [4, 4, 0.2965, 0.0174, 4, 0.38, 0.0, 0, 7, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if field.serialize:\n if self.selected_fields is None or field.attname in self.selected_fields:\n self.handle_m2m_field(obj, field)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98838:If_L51_C20", "label": "if", "type": "if", "loc": [51, 52], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98838:If_L50_C16", "vector": [4, 5, 0.2994, 0.0116, 5, 0.99, 0.0, 0, 0, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if self.selected_fields is None or field.attname in self.selected_fields:\n self.handle_m2m_field(obj, field)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98838:Expr_L52_C24", "label": "handle_m2m_field()", "type": "expression", "loc": [52, 52], "level": 6, "parent": "ajibawa-2023/Python-Code-Large/train/row_98838:If_L51_C20", "vector": [8, 6, 0.3023, 0.0058, 6, 0.69, 0.0, 261, 3, 2, 0, 0, 0, 0, 1], "semantic": {"name": "handle_m2m_field", "arg_names": [], "import_names": [], "rhs_call_name": "handle_m2m_field", "annotation": ""}, "snippet": " self.handle_m2m_field(obj, field)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98838:Expr_L53_C12", "label": "end_object()", "type": "expression", "loc": [53, 53], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98838:For_L39_C8", "vector": [8, 3, 0.3081, 0.0058, 3, 0.93, 1.0, 857, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "end_object", "arg_names": [], "import_names": [], "rhs_call_name": "end_object", "annotation": ""}, "snippet": " self.end_object(obj)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98838:Expr_L54_C8", "label": "end_serialization()", "type": "expression", "loc": [54, 54], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98838:FunctionDef_L28_C4", "vector": [8, 2, 0.314, 0.0058, 2, 0.32, 0.875, 673, 3, 0, 0, 0, 0, 0, 1], "semantic": {"name": "end_serialization", "arg_names": [], "import_names": [], "rhs_call_name": "end_serialization", "annotation": ""}, "snippet": " self.end_serialization()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98838:Return_L55_C8", "label": "return", "type": "return", "loc": [55, 55], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98838:FunctionDef_L28_C4", "vector": [13, 2, 0.3198, 0.0058, 2, 0.32, 1.0, 0, 3, 0, 0, 0, 0, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return self.getvalue()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98838:FunctionDef_L57_C4", "label": "get_string_value", "type": "function", "loc": [57, 61], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98838:ClassDef_L19_C0", "vector": [2, 1, 0.343, 0.0291, 1, 0.71, 0.2727, 187, 0, 3, 1, 0, 0, 0, 2], "semantic": {"name": "get_string_value", "arg_names": ["self", "obj", "field"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def get_string_value(self, obj, field):\n \"\"\"\n Convert a field's value to a string.\n \"\"\"\n return smart_unicode(field.value_to_string(obj))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98838:Expr_L58_C8", "label": "expression", "type": "expression", "loc": [58, 60], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98838:FunctionDef_L57_C4", "vector": [8, 2, 0.343, 0.0174, 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 Convert a field's value to a string.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98838:Return_L61_C8", "label": "return", "type": "return", "loc": [61, 61], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98838:FunctionDef_L57_C4", "vector": [13, 2, 0.3547, 0.0058, 2, 0.57, 1.0, 0, 3, 0, 0, 0, 0, 10, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return smart_unicode(field.value_to_string(obj))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98838:FunctionDef_L63_C4", "label": "start_serialization", "type": "function", "loc": [63, 67], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98838:ClassDef_L19_C0", "vector": [2, 1, 0.3779, 0.0291, 1, 0.71, 0.3636, 476, 0, 1, 0, 0, 0, 0, 0], "semantic": {"name": "start_serialization", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def start_serialization(self):\n \"\"\"\n Called when serializing of the queryset starts.\n \"\"\"\n raise NotImplementedError"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98838:Expr_L64_C8", "label": "expression", "type": "expression", "loc": [64, 66], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98838:FunctionDef_L63_C4", "vector": [8, 2, 0.3779, 0.0174, 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 Called when serializing of the queryset starts.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98838:FunctionDef_L69_C4", "label": "end_serialization", "type": "function", "loc": [69, 73], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98838:ClassDef_L19_C0", "vector": [2, 1, 0.4128, 0.0291, 1, 0.71, 0.4545, 673, 0, 1, 0, 0, 0, 0, 0], "semantic": {"name": "end_serialization", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def end_serialization(self):\n \"\"\"\n Called when serializing of the queryset ends.\n \"\"\"\n pass"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98838:Expr_L70_C8", "label": "expression", "type": "expression", "loc": [70, 72], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98838:FunctionDef_L69_C4", "vector": [8, 2, 0.4128, 0.0174, 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 Called when serializing of the queryset ends.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98838:FunctionDef_L75_C4", "label": "start_object", "type": "function", "loc": [75, 79], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98838:ClassDef_L19_C0", "vector": [2, 1, 0.4477, 0.0291, 1, 0.71, 0.5455, 939, 0, 2, 0, 0, 0, 0, 0], "semantic": {"name": "start_object", "arg_names": ["self", "obj"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def start_object(self, obj):\n \"\"\"\n Called when serializing of an object starts.\n \"\"\"\n raise NotImplementedError"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98838:Expr_L76_C8", "label": "expression", "type": "expression", "loc": [76, 78], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98838:FunctionDef_L75_C4", "vector": [8, 2, 0.4477, 0.0174, 2, 0.98, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"\n Called when serializing of an object starts.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98838:FunctionDef_L81_C4", "label": "end_object", "type": "function", "loc": [81, 85], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98838:ClassDef_L19_C0", "vector": [2, 1, 0.4826, 0.0291, 1, 0.71, 0.6364, 857, 0, 2, 0, 0, 0, 0, 0], "semantic": {"name": "end_object", "arg_names": ["self", "obj"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def end_object(self, obj):\n \"\"\"\n Called when serializing of an object ends.\n \"\"\"\n pass"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98838:Expr_L82_C8", "label": "expression", "type": "expression", "loc": [82, 84], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98838:FunctionDef_L81_C4", "vector": [8, 2, 0.4826, 0.0174, 2, 0.1, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"\n Called when serializing of an object ends.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98838:FunctionDef_L87_C4", "label": "handle_field", "type": "function", "loc": [87, 91], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98838:ClassDef_L19_C0", "vector": [2, 1, 0.5174, 0.0291, 1, 0.71, 0.7273, 277, 0, 3, 0, 0, 0, 0, 0], "semantic": {"name": "handle_field", "arg_names": ["self", "obj", "field"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def handle_field(self, obj, field):\n \"\"\"\n Called to handle each individual (non-relational) field on an object.\n \"\"\"\n raise NotImplementedError"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98838:Expr_L88_C8", "label": "expression", "type": "expression", "loc": [88, 90], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98838:FunctionDef_L87_C4", "vector": [8, 2, 0.5174, 0.0174, 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 Called to handle each individual (non-relational) field on an object.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98838:FunctionDef_L93_C4", "label": "handle_fk_field", "type": "function", "loc": [93, 97], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98838:ClassDef_L19_C0", "vector": [2, 1, 0.5523, 0.0291, 1, 0.71, 0.8182, 279, 0, 3, 0, 0, 0, 0, 0], "semantic": {"name": "handle_fk_field", "arg_names": ["self", "obj", "field"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def handle_fk_field(self, obj, field):\n \"\"\"\n Called to handle a ForeignKey field.\n \"\"\"\n raise NotImplementedError"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98838:Expr_L94_C8", "label": "expression", "type": "expression", "loc": [94, 96], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98838:FunctionDef_L93_C4", "vector": [8, 2, 0.5523, 0.0174, 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 Called to handle a ForeignKey field.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98838:FunctionDef_L99_C4", "label": "handle_m2m_field", "type": "function", "loc": [99, 103], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98838:ClassDef_L19_C0", "vector": [2, 1, 0.5872, 0.0291, 1, 0.71, 0.9091, 261, 0, 3, 0, 0, 0, 0, 0], "semantic": {"name": "handle_m2m_field", "arg_names": ["self", "obj", "field"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def handle_m2m_field(self, obj, field):\n \"\"\"\n Called to handle a ManyToManyField.\n \"\"\"\n raise NotImplementedError"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98838:Expr_L100_C8", "label": "expression", "type": "expression", "loc": [100, 102], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98838:FunctionDef_L99_C4", "vector": [8, 2, 0.5872, 0.0174, 2, 0.33, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"\n Called to handle a ManyToManyField.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98838:FunctionDef_L105_C4", "label": "getvalue", "type": "function", "loc": [105, 111], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98838:ClassDef_L19_C0", "vector": [2, 1, 0.6279, 0.0407, 1, 0.71, 1.0, 626, 0, 1, 1, 0, 0, 0, 3], "semantic": {"name": "getvalue", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def getvalue(self):\n \"\"\"\n Return the fully serialized queryset (or None if the output stream is\n not seekable).\n \"\"\"\n if callable(getattr(self.stream, 'getvalue', None)):\n return self.stream.getvalue()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98838:Expr_L106_C8", "label": "expression", "type": "expression", "loc": [106, 109], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98838:FunctionDef_L105_C4", "vector": [8, 2, 0.625, 0.0233, 2, 0.15, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"\n Return the fully serialized queryset (or None if the output stream is\n not seekable).\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98838:If_L110_C8", "label": "if", "type": "if", "loc": [110, 111], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98838:FunctionDef_L105_C4", "vector": [4, 2, 0.6424, 0.0116, 2, 0.15, 1.0, 0, 3, 0, 0, 0, 0, 0, 3], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if callable(getattr(self.stream, 'getvalue', None)):\n return self.stream.getvalue()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98838:Return_L111_C12", "label": "return", "type": "return", "loc": [111, 111], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98838:If_L110_C8", "vector": [13, 3, 0.6453, 0.0058, 3, 0.85, 0.0, 0, 3, 0, 0, 0, 0, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return self.stream.getvalue()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98838:ClassDef_L113_C0", "label": "Deserializer", "type": "class", "loc": [113, 137], "level": 0, "parent": null, "vector": [3, 0, 0.7267, 0.1453, 0, 0.66, 0.8889, 604, 0, 3, 0, 0, 186, 0, 3], "semantic": {"name": "Deserializer", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class Deserializer(object):\n \"\"\"\n Abstract base deserializer class.\n \"\"\"\n\n def __init__(self, stream_or_string, **options):\n \"\"\"\n Init this serializer given a stream or a string"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98838:Expr_L114_C4", "label": "expression", "type": "expression", "loc": [114, 116], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98838:ClassDef_L113_C0", "vector": [8, 1, 0.6686, 0.0174, 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 Abstract base deserializer class.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98838:FunctionDef_L118_C4", "label": "__init__", "type": "function", "loc": [118, 130], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98838:ClassDef_L113_C0", "vector": [2, 1, 0.7209, 0.0756, 1, 0.2, 0.3333, 555, 0, 3, 0, 0, 0, 0, 3], "semantic": {"name": "__init__", "arg_names": ["self", "stream_or_string", "options"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def __init__(self, stream_or_string, **options):\n \"\"\"\n Init this serializer given a stream or a string\n \"\"\"\n self.options = options\n if isinstance(stream_or_string, basestring):\n self.stream = StringIO(stream_or_string)\n else:"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98838:Expr_L119_C8", "label": "expression", "type": "expression", "loc": [119, 121], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98838:FunctionDef_L118_C4", "vector": [8, 2, 0.6977, 0.0174, 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 Init this serializer given a stream or a string\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98838:Assign_L122_C8", "label": "self.options =", "type": "assigned_variable", "loc": [122, 122], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98838:FunctionDef_L118_C4", "vector": [14, 2, 0.7093, 0.0058, 2, 0.91, 0.3333, 968, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "self.options", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.options = options"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98838:If_L123_C8", "label": "if", "type": "if", "loc": [123, 126], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98838:FunctionDef_L118_C4", "vector": [4, 2, 0.7238, 0.0233, 2, 0.91, 0.6667, 0, 3, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if isinstance(stream_or_string, basestring):\n self.stream = StringIO(stream_or_string)\n else:\n self.stream = stream_or_string"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98838:Assign_L124_C12", "label": "self.stream = StringIO()", "type": "assigned_variable", "loc": [124, 124], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98838:If_L123_C8", "vector": [14, 3, 0.7209, 0.0058, 3, 0.42, 0.0, 207, 3, 1, 0, 0, 609, 10, 1], "semantic": {"name": "self.stream", "arg_names": [], "import_names": [], "rhs_call_name": "StringIO", "annotation": ""}, "snippet": " self.stream = StringIO(stream_or_string)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98838:Assign_L126_C12", "label": "self.stream =", "type": "assigned_variable", "loc": [126, 126], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98838:If_L123_C8", "vector": [14, 3, 0.7326, 0.0058, 3, 0.42, 1.0, 207, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "self.stream", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.stream = stream_or_string"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98838:Expr_L130_C8", "label": "get_apps()", "type": "expression", "loc": [130, 130], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98838:FunctionDef_L118_C4", "vector": [8, 2, 0.7558, 0.0058, 2, 0.91, 1.0, 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_98838:FunctionDef_L132_C4", "label": "__iter__", "type": "function", "loc": [132, 133], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98838:ClassDef_L113_C0", "vector": [2, 1, 0.7703, 0.0116, 1, 0.2, 0.6667, 891, 0, 1, 1, 0, 0, 0, 0], "semantic": {"name": "__iter__", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def __iter__(self):\n return self"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98838:Return_L133_C8", "label": "return", "type": "return", "loc": [133, 133], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98838:FunctionDef_L132_C4", "vector": [13, 2, 0.7733, 0.0058, 2, 0.36, 0.0, 0, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return self"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98838:FunctionDef_L135_C4", "label": "next", "type": "function", "loc": [135, 137], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98838:ClassDef_L113_C0", "vector": [2, 1, 0.7907, 0.0174, 1, 0.2, 1.0, 11, 0, 1, 0, 0, 0, 0, 0], "semantic": {"name": "next", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def next(self):\n \"\"\"Iteration iterface -- return the next item in the stream\"\"\"\n raise NotImplementedError"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98838:Expr_L136_C8", "label": "expression", "type": "expression", "loc": [136, 136], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98838:FunctionDef_L135_C4", "vector": [8, 2, 0.7907, 0.0058, 2, 0.94, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"Iteration iterface -- return the next item in the stream\"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98838:ClassDef_L139_C0", "label": "DeserializedObject", "type": "class", "loc": [139, 172], "level": 0, "parent": null, "vector": [3, 0, 0.9041, 0.1977, 0, 0.66, 1.0, 585, 0, 3, 0, 0, 186, 0, 3], "semantic": {"name": "DeserializedObject", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class DeserializedObject(object):\n \"\"\"\n A deserialized model.\n\n Basically a container for holding the pre-saved deserialized data along\n with the many-to-many data saved with the object.\n\n Call ``save()`` to save the object (with the many-to-many data) to the"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98838:Expr_L140_C4", "label": "expression", "type": "expression", "loc": [140, 149], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98838:ClassDef_L139_C0", "vector": [8, 1, 0.8401, 0.0581, 1, 0.87, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"\n A deserialized model.\n\n Basically a container for holding the pre-saved deserialized data along\n with the many-to-many data saved with the object.\n\n Call ``save()`` to save the object (with the many-to-many data) to the\n database; call ``save(save_m2m=False)`` to save just the object fields"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98838:FunctionDef_L151_C4", "label": "__init__", "type": "function", "loc": [151, 153], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98838:ClassDef_L139_C0", "vector": [2, 1, 0.8837, 0.0174, 1, 0.87, 0.3333, 555, 0, 3, 0, 0, 0, 0, 0], "semantic": {"name": "__init__", "arg_names": ["self", "obj", "m2m_data"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def __init__(self, obj, m2m_data=None):\n self.object = obj\n self.m2m_data = m2m_data"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98838:Assign_L152_C8", "label": "self.object =", "type": "assigned_variable", "loc": [152, 152], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98838:FunctionDef_L151_C4", "vector": [14, 2, 0.8837, 0.0058, 2, 0.78, 0.0, 485, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "self.object", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.object = obj"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98838:Assign_L153_C8", "label": "self.m2m_data =", "type": "assigned_variable", "loc": [153, 153], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98838:FunctionDef_L151_C4", "vector": [14, 2, 0.8895, 0.0058, 2, 0.78, 1.0, 298, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "self.m2m_data", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.m2m_data = m2m_data"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98838:FunctionDef_L155_C4", "label": "__repr__", "type": "function", "loc": [155, 157], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98838:ClassDef_L139_C0", "vector": [2, 1, 0.907, 0.0174, 1, 0.87, 0.6667, 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 \"<DeserializedObject: %s.%s(pk=%s)>\" % (\n self.object._meta.app_label, self.object._meta.object_name, self.object.pk)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98838:Return_L156_C8", "label": "return", "type": "return", "loc": [156, 157], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98838:FunctionDef_L155_C4", "vector": [13, 2, 0.9099, 0.0116, 2, 0.34, 0.0, 0, 4, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return \"<DeserializedObject: %s.%s(pk=%s)>\" % (\n self.object._meta.app_label, self.object._meta.object_name, self.object.pk)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98838:FunctionDef_L159_C4", "label": "save", "type": "function", "loc": [159, 172], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98838:ClassDef_L139_C0", "vector": [2, 1, 0.9622, 0.0814, 1, 0.87, 1.0, 928, 0, 3, 0, 0, 0, 0, 3], "semantic": {"name": "save", "arg_names": ["self", "save_m2m", "using"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def save(self, save_m2m=True, using=None):\n # Call save on the Model baseclass directly. This bypasses any\n # model-defined save. The save is also forced to be raw.\n # This ensures that the data that is deserialized is literally\n # what came from the file, not post-processed by pre_save/save\n # methods.\n models.Model.save_base(self.object, using=using, raw=True)\n if self.m2m_data and save_m2m:"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98838:Expr_L165_C8", "label": "save_base()", "type": "expression", "loc": [165, 165], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98838:FunctionDef_L159_C4", "vector": [8, 2, 0.9593, 0.0058, 2, 0.33, 0.0, 113, 3, 3, 0, 0, 0, 0, 1], "semantic": {"name": "save_base", "arg_names": [], "import_names": [], "rhs_call_name": "save_base", "annotation": ""}, "snippet": " models.Model.save_base(self.object, using=using, raw=True)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98838:If_L166_C8", "label": "if", "type": "if", "loc": [166, 168], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98838:FunctionDef_L159_C4", "vector": [4, 2, 0.9709, 0.0174, 2, 0.33, 0.5, 0, 0, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if self.m2m_data and save_m2m:\n for accessor_name, object_list in self.m2m_data.items():\n setattr(self.object, accessor_name, object_list)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98838:For_L167_C12", "label": "for accessor_name, object_list", "type": "for", "loc": [167, 168], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98838:If_L166_C8", "vector": [6, 3, 0.9738, 0.0116, 3, 0.29, 0.0, 483, 3, 0, 0, 0, 0, 0, 2], "semantic": {"name": "accessor_name, object_list", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for accessor_name, object_list in self.m2m_data.items():\n setattr(self.object, accessor_name, object_list)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98838:Expr_L168_C16", "label": "setattr()", "type": "expression", "loc": [168, 168], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98838:For_L167_C12", "vector": [8, 4, 0.9767, 0.0058, 4, 0.64, 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.object, accessor_name, object_list)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98838:Assign_L172_C8", "label": "self.m2m_data =", "type": "assigned_variable", "loc": [172, 172], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98838:FunctionDef_L159_C4", "vector": [14, 2, 1.0, 0.0058, 2, 0.33, 1.0, 298, 1, 0, 0, 0, 0, 9, 0], "semantic": {"name": "self.m2m_data", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.m2m_data = None"}]
[{"f": "ajibawa-2023/Python-Code-Large/train/row_98838:ClassDef_L11_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98838:Expr_L12_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98838:ClassDef_L15_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98838:Expr_L16_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98838:ClassDef_L19_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98838:Expr_L20_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98838:ClassDef_L19_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98838:Assign_L26_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98838:ClassDef_L19_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98838:FunctionDef_L28_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98838:FunctionDef_L28_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98838:Expr_L29_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98838:FunctionDef_L28_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98838:Assign_L32_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98838:FunctionDef_L28_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98838:Assign_L34_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98838:FunctionDef_L28_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98838:Assign_L35_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98838:FunctionDef_L28_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98838:Assign_L36_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98838:FunctionDef_L28_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98838:Expr_L38_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98838:FunctionDef_L28_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98838:For_L39_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98838:For_L39_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98838:Expr_L40_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98838:For_L39_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98838:For_L41_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98838:For_L41_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98838:If_L42_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98838:If_L42_C16", "t": "ajibawa-2023/Python-Code-Large/train/row_98838:If_L43_C20"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98838:If_L43_C20", "t": "ajibawa-2023/Python-Code-Large/train/row_98838:If_L44_C24"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98838:If_L44_C24", "t": "ajibawa-2023/Python-Code-Large/train/row_98838:Expr_L45_C28"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98838:If_L43_C20", "t": "ajibawa-2023/Python-Code-Large/train/row_98838:If_L47_C24"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98838:If_L47_C24", "t": "ajibawa-2023/Python-Code-Large/train/row_98838:Expr_L48_C28"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98838:For_L39_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98838:For_L49_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98838:For_L49_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98838:If_L50_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98838:If_L50_C16", "t": "ajibawa-2023/Python-Code-Large/train/row_98838:If_L51_C20"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98838:If_L51_C20", "t": "ajibawa-2023/Python-Code-Large/train/row_98838:Expr_L52_C24"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98838:For_L39_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98838:Expr_L53_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98838:FunctionDef_L28_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98838:Expr_L54_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98838:FunctionDef_L28_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98838:Return_L55_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98838:ClassDef_L19_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98838:FunctionDef_L57_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98838:FunctionDef_L57_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98838:Expr_L58_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98838:FunctionDef_L57_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98838:Return_L61_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98838:ClassDef_L19_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98838:FunctionDef_L63_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98838:FunctionDef_L63_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98838:Expr_L64_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98838:ClassDef_L19_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98838:FunctionDef_L69_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98838:FunctionDef_L69_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98838:Expr_L70_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98838:ClassDef_L19_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98838:FunctionDef_L75_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98838:FunctionDef_L75_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98838:Expr_L76_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98838:ClassDef_L19_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98838:FunctionDef_L81_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98838:FunctionDef_L81_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98838:Expr_L82_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98838:ClassDef_L19_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98838:FunctionDef_L87_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98838:FunctionDef_L87_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98838:Expr_L88_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98838:ClassDef_L19_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98838:FunctionDef_L93_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98838:FunctionDef_L93_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98838:Expr_L94_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98838:ClassDef_L19_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98838:FunctionDef_L99_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98838:FunctionDef_L99_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98838:Expr_L100_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98838:ClassDef_L19_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98838:FunctionDef_L105_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98838:FunctionDef_L105_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98838:Expr_L106_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98838:FunctionDef_L105_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98838:If_L110_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98838:If_L110_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98838:Return_L111_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98838:ClassDef_L113_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98838:Expr_L114_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98838:ClassDef_L113_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98838:FunctionDef_L118_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98838:FunctionDef_L118_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98838:Expr_L119_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98838:FunctionDef_L118_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98838:Assign_L122_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98838:FunctionDef_L118_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98838:If_L123_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98838:If_L123_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98838:Assign_L124_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98838:If_L123_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98838:Assign_L126_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98838:FunctionDef_L118_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98838:Expr_L130_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98838:ClassDef_L113_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98838:FunctionDef_L132_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98838:FunctionDef_L132_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98838:Return_L133_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98838:ClassDef_L113_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98838:FunctionDef_L135_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98838:FunctionDef_L135_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98838:Expr_L136_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98838:ClassDef_L139_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98838:Expr_L140_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98838:ClassDef_L139_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98838:FunctionDef_L151_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98838:FunctionDef_L151_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98838:Assign_L152_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98838:FunctionDef_L151_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98838:Assign_L153_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98838:ClassDef_L139_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98838:FunctionDef_L155_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98838:FunctionDef_L155_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98838:Return_L156_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98838:ClassDef_L139_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98838:FunctionDef_L159_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98838:FunctionDef_L159_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98838:Expr_L165_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98838:FunctionDef_L159_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98838:If_L166_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98838:If_L166_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98838:For_L167_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98838:For_L167_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98838:Expr_L168_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98838:FunctionDef_L159_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98838:Assign_L172_C8"}]
""" Interfaces for serializing Django objects. Usage:: from django.core import serializers json = serializers.serialize("json", some_query_set) objects = list(serializers.deserialize("json", json)) To add your own serializers, use the SERIALIZATION_MODULES setting:: SERIALIZATION_MODULES = { "csv" : "path.to.csv.serializer", "txt" : "path.to.txt.serializer", } """ from django.conf import settings from django.utils import importlib # Built-in serializers BUILTIN_SERIALIZERS = { "xml" : "django.core.serializers.xml_serializer", "python" : "django.core.serializers.python", "json" : "django.core.serializers.json", } # Check for PyYaml and register the serializer if it's available. try: import yaml BUILTIN_SERIALIZERS["yaml"] = "django.core.serializers.pyyaml" except ImportError: pass _serializers = {} def register_serializer(format, serializer_module, serializers=None): """"Register a new serializer. ``serializer_module`` should be the fully qualified module name for the serializer. If ``serializers`` is provided, the registration will be added to the provided dictionary. If ``serializers`` is not provided, the registration will be made directly into the global register of serializers. Adding serializers directly is not a thread-safe operation. """ module = importlib.import_module(serializer_module) if serializers is None: _serializers[format] = module else: serializers[format] = module def unregister_serializer(format): "Unregister a given serializer. This is not a thread-safe operation." del _serializers[format] def get_serializer(format): if not _serializers: _load_serializers() return _serializers[format].Serializer def get_serializer_formats(): if not _serializers: _load_serializers() return _serializers.keys() def get_public_serializer_formats(): if not _serializers: _load_serializers() return [k for k, v in _serializers.iteritems() if not v.Serializer.internal_use_only] def get_deserializer(format): if not _serializers: _load_serializers() return _serializers[format].Deserializer def serialize(format, queryset, **options): """ Serialize a queryset (or any iterator that returns database objects) using a certain serializer. """ s = get_serializer(format)() s.serialize(queryset, **options) return s.getvalue() def deserialize(format, stream_or_string, **options): """ Deserialize a stream or a string. Returns an iterator that yields ``(obj, m2m_relation_dict)``, where ``obj`` is a instantiated -- but *unsaved* -- object, and ``m2m_relation_dict`` is a dictionary of ``{m2m_field_name : list_of_related_objects}``. """ d = get_deserializer(format) return d(stream_or_string, **options) def _load_serializers(): """ Register built-in and settings-defined serializers. This is done lazily so that user code has a chance to (e.g.) set up custom settings without needing to be careful of import order. """ global _serializers serializers = {} for format in BUILTIN_SERIALIZERS: register_serializer(format, BUILTIN_SERIALIZERS[format], serializers) if hasattr(settings, "SERIALIZATION_MODULES"): for format in settings.SERIALIZATION_MODULES: register_serializer(format, settings.SERIALIZATION_MODULES[format], serializers) _serializers = serializers
ajibawa-2023/Python-Code-Large/train/row_98839
50
113
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_98839:Expr_L1_C0", "label": "expression", "type": "expression", "loc": [1, 17], "level": 0, "parent": null, "vector": [8, 0, 0.0796, 0.1504, 0, 0.66, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "\"\"\"\nInterfaces for serializing Django objects.\n\nUsage::\n\n from django.core import serializers\n json = serializers.serialize(\"json\", some_query_set)\n objects = list(serializers.deserialize(\"json\", json))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98839:ImportFrom_L19_C0", "label": "from django.conf import settings", "type": "import", "loc": [19, 19], "level": 0, "parent": null, "vector": [1, 0, 0.1681, 0.0088, 0, 0.66, 0.0714, 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_98839:ImportFrom_L20_C0", "label": "from django.utils import importlib", "type": "import", "loc": [20, 20], "level": 0, "parent": null, "vector": [1, 0, 0.177, 0.0088, 0, 0.66, 0.1429, 944, 0, 1, 0, 0, 944, 0, 0], "semantic": {"name": "django.utils", "arg_names": [], "import_names": ["importlib"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.utils import importlib"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98839:Assign_L23_C0", "label": "BUILTIN_SERIALIZERS =", "type": "assigned_variable", "loc": [23, 27], "level": 0, "parent": null, "vector": [14, 0, 0.2212, 0.0442, 0, 0.66, 0.2143, 414, 0, 0, 0, 0, 0, 6, 0], "semantic": {"name": "BUILTIN_SERIALIZERS", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "BUILTIN_SERIALIZERS = {\n \"xml\" : \"django.core.serializers.xml_serializer\",\n \"python\" : \"django.core.serializers.python\",\n \"json\" : \"django.core.serializers.json\",\n}"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98839:Try_L30_C0", "label": "try", "type": "try", "loc": [30, 34], "level": 0, "parent": null, "vector": [7, 0, 0.2832, 0.0442, 0, 0.66, 0.2857, 0, 0, 1, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "try:\n import yaml\n BUILTIN_SERIALIZERS[\"yaml\"] = \"django.core.serializers.pyyaml\"\nexcept ImportError:\n pass"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98839:Import_L31_C4", "label": "yaml import yaml", "type": "import", "loc": [31, 31], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98839:Try_L30_C0", "vector": [1, 1, 0.2743, 0.0088, 1, 0.59, 0.0, 960, 0, 1, 0, 0, 960, 0, 0], "semantic": {"name": "yaml", "arg_names": [], "import_names": ["yaml"], "rhs_call_name": "", "annotation": ""}, "snippet": " import yaml"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98839:Assign_L32_C4", "label": "assign", "type": "assigned_variable", "loc": [32, 32], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98839:Try_L30_C0", "vector": [14, 1, 0.2832, 0.0088, 1, 0.59, 1.0, 0, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " BUILTIN_SERIALIZERS[\"yaml\"] = \"django.core.serializers.pyyaml\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98839:Assign_L36_C0", "label": "_serializers =", "type": "assigned_variable", "loc": [36, 36], "level": 0, "parent": null, "vector": [14, 0, 0.3186, 0.0088, 0, 0.66, 0.3571, 687, 0, 0, 0, 0, 0, 6, 0], "semantic": {"name": "_serializers", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "_serializers = {}"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98839:FunctionDef_L38_C0", "label": "register_serializer", "type": "function", "loc": [38, 55], "level": 0, "parent": null, "vector": [2, 0, 0.4115, 0.1593, 0, 0.66, 0.4286, 418, 0, 3, 0, 0, 0, 0, 1], "semantic": {"name": "register_serializer", "arg_names": ["format", "serializer_module", "serializers"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "def register_serializer(format, serializer_module, serializers=None):\n \"\"\"\"Register a new serializer.\n\n ``serializer_module`` should be the fully qualified module name\n for the serializer.\n\n If ``serializers`` is provided, the registration will be added\n to the provided dictionary."}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98839:Expr_L39_C4", "label": "expression", "type": "expression", "loc": [39, 50], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98839:FunctionDef_L38_C0", "vector": [8, 1, 0.3938, 0.1062, 1, 0.34, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"\"Register a new serializer.\n\n ``serializer_module`` should be the fully qualified module name\n for the serializer.\n\n If ``serializers`` is provided, the registration will be added\n to the provided dictionary.\n"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98839:Assign_L51_C4", "label": "module = import_module()", "type": "assigned_variable", "loc": [51, 51], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98839:FunctionDef_L38_C0", "vector": [14, 1, 0.4513, 0.0088, 1, 0.34, 0.5, 98, 3, 1, 0, 0, 637, 10, 1], "semantic": {"name": "module", "arg_names": [], "import_names": [], "rhs_call_name": "import_module", "annotation": ""}, "snippet": " module = importlib.import_module(serializer_module)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98839:If_L52_C4", "label": "if", "type": "if", "loc": [52, 55], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98839:FunctionDef_L38_C0", "vector": [4, 1, 0.4735, 0.0354, 1, 0.34, 1.0, 0, 0, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if serializers is None:\n _serializers[format] = module\n else:\n serializers[format] = module"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98839:Assign_L53_C8", "label": "assign", "type": "assigned_variable", "loc": [53, 53], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98839:If_L52_C4", "vector": [14, 2, 0.469, 0.0088, 2, 0.86, 0.0, 0, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " _serializers[format] = module"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98839:Assign_L55_C8", "label": "assign", "type": "assigned_variable", "loc": [55, 55], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98839:If_L52_C4", "vector": [14, 2, 0.4867, 0.0088, 2, 0.86, 1.0, 0, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " serializers[format] = module"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98839:FunctionDef_L57_C0", "label": "unregister_serializer", "type": "function", "loc": [57, 59], "level": 0, "parent": null, "vector": [2, 0, 0.5133, 0.0265, 0, 0.66, 0.5, 797, 0, 1, 0, 0, 0, 0, 0], "semantic": {"name": "unregister_serializer", "arg_names": ["format"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "def unregister_serializer(format):\n \"Unregister a given serializer. This is not a thread-safe operation.\"\n del _serializers[format]"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98839:Expr_L58_C4", "label": "expression", "type": "expression", "loc": [58, 58], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98839:FunctionDef_L57_C0", "vector": [8, 1, 0.5133, 0.0088, 1, 0.13, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"Unregister a given serializer. This is not a thread-safe operation.\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98839:FunctionDef_L61_C0", "label": "get_serializer", "type": "function", "loc": [61, 64], "level": 0, "parent": null, "vector": [2, 0, 0.5531, 0.0354, 0, 0.66, 0.5714, 124, 0, 1, 1, 0, 0, 0, 1], "semantic": {"name": "get_serializer", "arg_names": ["format"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "def get_serializer(format):\n if not _serializers:\n _load_serializers()\n return _serializers[format].Serializer"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98839:If_L62_C4", "label": "if", "type": "if", "loc": [62, 63], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98839:FunctionDef_L61_C0", "vector": [4, 1, 0.5531, 0.0177, 1, 0.64, 0.0, 0, 0, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if not _serializers:\n _load_serializers()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98839:Expr_L63_C8", "label": "_load_serializers()", "type": "expression", "loc": [63, 63], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98839:If_L62_C4", "vector": [8, 2, 0.5575, 0.0088, 2, 0.0, 0.0, 62, 3, 0, 0, 0, 0, 0, 1], "semantic": {"name": "_load_serializers", "arg_names": [], "import_names": [], "rhs_call_name": "_load_serializers", "annotation": ""}, "snippet": " _load_serializers()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98839:Return_L64_C4", "label": "return", "type": "return", "loc": [64, 64], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98839:FunctionDef_L61_C0", "vector": [13, 1, 0.5664, 0.0088, 1, 0.64, 1.0, 0, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return _serializers[format].Serializer"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98839:FunctionDef_L66_C0", "label": "get_serializer_formats", "type": "function", "loc": [66, 69], "level": 0, "parent": null, "vector": [2, 0, 0.5973, 0.0354, 0, 0.66, 0.6429, 249, 0, 0, 1, 0, 0, 0, 2], "semantic": {"name": "get_serializer_formats", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "def get_serializer_formats():\n if not _serializers:\n _load_serializers()\n return _serializers.keys()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98839:If_L67_C4", "label": "if", "type": "if", "loc": [67, 68], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98839:FunctionDef_L66_C0", "vector": [4, 1, 0.5973, 0.0177, 1, 0.87, 0.0, 0, 0, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if not _serializers:\n _load_serializers()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98839:Expr_L68_C8", "label": "_load_serializers()", "type": "expression", "loc": [68, 68], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98839:If_L67_C4", "vector": [8, 2, 0.6018, 0.0088, 2, 0.94, 0.0, 62, 3, 0, 0, 0, 0, 0, 1], "semantic": {"name": "_load_serializers", "arg_names": [], "import_names": [], "rhs_call_name": "_load_serializers", "annotation": ""}, "snippet": " _load_serializers()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98839:Return_L69_C4", "label": "return", "type": "return", "loc": [69, 69], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98839:FunctionDef_L66_C0", "vector": [13, 1, 0.6106, 0.0088, 1, 0.87, 1.0, 0, 3, 0, 0, 0, 0, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return _serializers.keys()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98839:FunctionDef_L71_C0", "label": "get_public_serializer_formats", "type": "function", "loc": [71, 74], "level": 0, "parent": null, "vector": [2, 0, 0.6416, 0.0354, 0, 0.66, 0.7143, 289, 0, 0, 1, 0, 0, 0, 2], "semantic": {"name": "get_public_serializer_formats", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "def get_public_serializer_formats():\n if not _serializers:\n _load_serializers()\n return [k for k, v in _serializers.iteritems() if not v.Serializer.internal_use_only]"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98839:If_L72_C4", "label": "if", "type": "if", "loc": [72, 73], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98839:FunctionDef_L71_C0", "vector": [4, 1, 0.6416, 0.0177, 1, 0.21, 0.0, 0, 0, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if not _serializers:\n _load_serializers()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98839:Expr_L73_C8", "label": "_load_serializers()", "type": "expression", "loc": [73, 73], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98839:If_L72_C4", "vector": [8, 2, 0.646, 0.0088, 2, 0.51, 0.0, 62, 3, 0, 0, 0, 0, 0, 1], "semantic": {"name": "_load_serializers", "arg_names": [], "import_names": [], "rhs_call_name": "_load_serializers", "annotation": ""}, "snippet": " _load_serializers()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98839:Return_L74_C4", "label": "return", "type": "return", "loc": [74, 74], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98839:FunctionDef_L71_C0", "vector": [13, 1, 0.6549, 0.0088, 1, 0.21, 1.0, 0, 5, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return [k for k, v in _serializers.iteritems() if not v.Serializer.internal_use_only]"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98839:FunctionDef_L76_C0", "label": "get_deserializer", "type": "function", "loc": [76, 79], "level": 0, "parent": null, "vector": [2, 0, 0.6858, 0.0354, 0, 0.66, 0.7857, 928, 0, 1, 1, 0, 0, 0, 1], "semantic": {"name": "get_deserializer", "arg_names": ["format"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "def get_deserializer(format):\n if not _serializers:\n _load_serializers()\n return _serializers[format].Deserializer"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98839:If_L77_C4", "label": "if", "type": "if", "loc": [77, 78], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98839:FunctionDef_L76_C0", "vector": [4, 1, 0.6858, 0.0177, 1, 0.5, 0.0, 0, 0, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if not _serializers:\n _load_serializers()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98839:Expr_L78_C8", "label": "_load_serializers()", "type": "expression", "loc": [78, 78], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98839:If_L77_C4", "vector": [8, 2, 0.6903, 0.0088, 2, 0.33, 0.0, 62, 3, 0, 0, 0, 0, 0, 1], "semantic": {"name": "_load_serializers", "arg_names": [], "import_names": [], "rhs_call_name": "_load_serializers", "annotation": ""}, "snippet": " _load_serializers()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98839:Return_L79_C4", "label": "return", "type": "return", "loc": [79, 79], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98839:FunctionDef_L76_C0", "vector": [13, 1, 0.6991, 0.0088, 1, 0.5, 1.0, 0, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return _serializers[format].Deserializer"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98839:FunctionDef_L81_C0", "label": "serialize", "type": "function", "loc": [81, 88], "level": 0, "parent": null, "vector": [2, 0, 0.7478, 0.0708, 0, 0.66, 0.8571, 50, 0, 3, 1, 0, 0, 0, 4], "semantic": {"name": "serialize", "arg_names": ["format", "queryset", "options"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "def serialize(format, queryset, **options):\n \"\"\"\n Serialize a queryset (or any iterator that returns database objects) using\n a certain serializer.\n \"\"\"\n s = get_serializer(format)()\n s.serialize(queryset, **options)\n return s.getvalue()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98839:Expr_L82_C4", "label": "expression", "type": "expression", "loc": [82, 85], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98839:FunctionDef_L81_C0", "vector": [8, 1, 0.7389, 0.0354, 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 Serialize a queryset (or any iterator that returns database objects) using\n a certain serializer.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98839:Assign_L86_C4", "label": "s =", "type": "assigned_variable", "loc": [86, 86], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98839:FunctionDef_L81_C0", "vector": [14, 1, 0.7611, 0.0088, 1, 0.2, 0.3333, 553, 3, 0, 0, 0, 0, 10, 2], "semantic": {"name": "s", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " s = get_serializer(format)()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98839:Expr_L87_C4", "label": "serialize()", "type": "expression", "loc": [87, 87], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98839:FunctionDef_L81_C0", "vector": [8, 1, 0.7699, 0.0088, 1, 0.2, 0.6667, 50, 3, 2, 0, 0, 0, 0, 1], "semantic": {"name": "serialize", "arg_names": [], "import_names": [], "rhs_call_name": "serialize", "annotation": ""}, "snippet": " s.serialize(queryset, **options)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98839:Return_L88_C4", "label": "return", "type": "return", "loc": [88, 88], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98839:FunctionDef_L81_C0", "vector": [13, 1, 0.7788, 0.0088, 1, 0.2, 1.0, 0, 3, 0, 0, 0, 0, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return s.getvalue()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98839:FunctionDef_L90_C0", "label": "deserialize", "type": "function", "loc": [90, 98], "level": 0, "parent": null, "vector": [2, 0, 0.8319, 0.0796, 0, 0.66, 0.9286, 223, 0, 3, 1, 0, 0, 0, 2], "semantic": {"name": "deserialize", "arg_names": ["format", "stream_or_string", "options"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "def deserialize(format, stream_or_string, **options):\n \"\"\"\n Deserialize a stream or a string. Returns an iterator that yields ``(obj,\n m2m_relation_dict)``, where ``obj`` is a instantiated -- but *unsaved* --\n object, and ``m2m_relation_dict`` is a dictionary of ``{m2m_field_name :\n list_of_related_objects}``.\n \"\"\"\n d = get_deserializer(format)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98839:Expr_L91_C4", "label": "expression", "type": "expression", "loc": [91, 96], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98839:FunctionDef_L90_C0", "vector": [8, 1, 0.8274, 0.0531, 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 Deserialize a stream or a string. Returns an iterator that yields ``(obj,\n m2m_relation_dict)``, where ``obj`` is a instantiated -- but *unsaved* --\n object, and ``m2m_relation_dict`` is a dictionary of ``{m2m_field_name :\n list_of_related_objects}``.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98839:Assign_L97_C4", "label": "d = get_deserializer()", "type": "assigned_variable", "loc": [97, 97], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98839:FunctionDef_L90_C0", "vector": [14, 1, 0.8584, 0.0088, 1, 0.08, 0.5, 355, 3, 1, 0, 0, 928, 10, 1], "semantic": {"name": "d", "arg_names": [], "import_names": [], "rhs_call_name": "get_deserializer", "annotation": ""}, "snippet": " d = get_deserializer(format)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98839:Return_L98_C4", "label": "return", "type": "return", "loc": [98, 98], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98839:FunctionDef_L90_C0", "vector": [13, 1, 0.8673, 0.0088, 1, 0.08, 1.0, 0, 3, 0, 0, 0, 0, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return d(stream_or_string, **options)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98839:FunctionDef_L100_C0", "label": "_load_serializers", "type": "function", "loc": [100, 113], "level": 0, "parent": null, "vector": [2, 0, 0.9425, 0.1239, 0, 0.66, 1.0, 62, 0, 0, 0, 0, 0, 0, 3], "semantic": {"name": "_load_serializers", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "def _load_serializers():\n \"\"\"\n Register built-in and settings-defined serializers. This is done lazily so\n that user code has a chance to (e.g.) set up custom settings without\n needing to be careful of import order.\n \"\"\"\n global _serializers\n serializers = {}"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98839:Expr_L101_C4", "label": "expression", "type": "expression", "loc": [101, 105], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98839:FunctionDef_L100_C0", "vector": [8, 1, 0.9115, 0.0442, 1, 0.21, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"\n Register built-in and settings-defined serializers. This is done lazily so\n that user code has a chance to (e.g.) set up custom settings without\n needing to be careful of import order.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98839:Assign_L107_C4", "label": "serializers =", "type": "assigned_variable", "loc": [107, 107], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98839:FunctionDef_L100_C0", "vector": [14, 1, 0.9469, 0.0088, 1, 0.21, 0.25, 370, 0, 0, 0, 0, 0, 6, 0], "semantic": {"name": "serializers", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " serializers = {}"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98839:For_L108_C4", "label": "for format", "type": "for", "loc": [108, 109], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98839:FunctionDef_L100_C0", "vector": [6, 1, 0.9602, 0.0177, 1, 0.21, 0.5, 293, 2, 0, 0, 0, 0, 0, 1], "semantic": {"name": "format", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for format in BUILTIN_SERIALIZERS:\n register_serializer(format, BUILTIN_SERIALIZERS[format], serializers)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98839:Expr_L109_C8", "label": "register_serializer()", "type": "expression", "loc": [109, 109], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98839:For_L108_C4", "vector": [8, 2, 0.9646, 0.0088, 2, 0.96, 0.0, 418, 3, 3, 0, 0, 0, 0, 1], "semantic": {"name": "register_serializer", "arg_names": [], "import_names": [], "rhs_call_name": "register_serializer", "annotation": ""}, "snippet": " register_serializer(format, BUILTIN_SERIALIZERS[format], serializers)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98839:If_L110_C4", "label": "if", "type": "if", "loc": [110, 112], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98839:FunctionDef_L100_C0", "vector": [4, 1, 0.9823, 0.0265, 1, 0.21, 0.75, 0, 3, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if hasattr(settings, \"SERIALIZATION_MODULES\"):\n for format in settings.SERIALIZATION_MODULES:\n register_serializer(format, settings.SERIALIZATION_MODULES[format], serializers)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98839:For_L111_C8", "label": "for format", "type": "for", "loc": [111, 112], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98839:If_L110_C4", "vector": [6, 2, 0.9867, 0.0177, 2, 0.68, 0.0, 293, 7, 0, 0, 0, 0, 0, 1], "semantic": {"name": "format", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for format in settings.SERIALIZATION_MODULES:\n register_serializer(format, settings.SERIALIZATION_MODULES[format], serializers)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98839:Expr_L112_C12", "label": "register_serializer()", "type": "expression", "loc": [112, 112], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98839:For_L111_C8", "vector": [8, 3, 0.9912, 0.0088, 3, 0.61, 0.0, 418, 3, 3, 0, 0, 0, 0, 1], "semantic": {"name": "register_serializer", "arg_names": [], "import_names": [], "rhs_call_name": "register_serializer", "annotation": ""}, "snippet": " register_serializer(format, settings.SERIALIZATION_MODULES[format], serializers)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98839:Assign_L113_C4", "label": "_serializers =", "type": "assigned_variable", "loc": [113, 113], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98839:FunctionDef_L100_C0", "vector": [14, 1, 1.0, 0.0088, 1, 0.21, 1.0, 687, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "_serializers", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " _serializers = serializers"}]
[{"f": "ajibawa-2023/Python-Code-Large/train/row_98839:Try_L30_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98839:Import_L31_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98839:Try_L30_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98839:Assign_L32_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98839:FunctionDef_L38_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98839:Expr_L39_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98839:FunctionDef_L38_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98839:Assign_L51_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98839:FunctionDef_L38_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98839:If_L52_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98839:If_L52_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98839:Assign_L53_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98839:If_L52_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98839:Assign_L55_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98839:FunctionDef_L57_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98839:Expr_L58_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98839:FunctionDef_L61_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98839:If_L62_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98839:If_L62_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98839:Expr_L63_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98839:FunctionDef_L61_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98839:Return_L64_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98839:FunctionDef_L66_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98839:If_L67_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98839:If_L67_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98839:Expr_L68_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98839:FunctionDef_L66_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98839:Return_L69_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98839:FunctionDef_L71_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98839:If_L72_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98839:If_L72_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98839:Expr_L73_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98839:FunctionDef_L71_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98839:Return_L74_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98839:FunctionDef_L76_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98839:If_L77_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98839:If_L77_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98839:Expr_L78_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98839:FunctionDef_L76_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98839:Return_L79_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98839:FunctionDef_L81_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98839:Expr_L82_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98839:FunctionDef_L81_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98839:Assign_L86_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98839:FunctionDef_L81_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98839:Expr_L87_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98839:FunctionDef_L81_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98839:Return_L88_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98839:FunctionDef_L90_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98839:Expr_L91_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98839:FunctionDef_L90_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98839:Assign_L97_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98839:FunctionDef_L90_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98839:Return_L98_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98839:FunctionDef_L100_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98839:Expr_L101_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98839:FunctionDef_L100_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98839:Assign_L107_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98839:FunctionDef_L100_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98839:For_L108_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98839:For_L108_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98839:Expr_L109_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98839:FunctionDef_L100_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98839:If_L110_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98839:If_L110_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98839:For_L111_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98839:For_L111_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98839:Expr_L112_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98839:FunctionDef_L100_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98839:Assign_L113_C4"}]
""" A set of request processors that return dictionaries to be merged into a template context. Each function takes the request object as its only parameter and returns a dictionary to add to the context. These are referenced from the setting TEMPLATE_CONTEXT_PROCESSORS and used by RequestContext. """ from django.conf import settings from django.middleware.csrf import get_token from django.utils.functional import lazy def auth(request): """ DEPRECATED. This context processor is the old location, and has been moved to `django.contrib.auth.context_processors`. This function still exists for backwards-compatibility; it will be removed in Django 1.4. """ import warnings warnings.warn( "The context processor at `django.core.context_processors.auth` is " \ "deprecated; use the path `django.contrib.auth.context_processors.auth` " \ "instead.", DeprecationWarning ) from django.contrib.auth.context_processors import auth as auth_context_processor return auth_context_processor(request) def csrf(request): """ Context processor that provides a CSRF token, or the string 'NOTPROVIDED' if it has not been provided by either a view decorator or the middleware """ def _get_val(): token = get_token(request) if token is None: # In order to be able to provide debugging info in the # case of misconfiguration, we use a sentinel value # instead of returning an empty dict. return 'NOTPROVIDED' else: return token _get_val = lazy(_get_val, str) return {'csrf_token': _get_val() } def debug(request): "Returns context variables helpful for debugging." context_extras = {} if settings.DEBUG and request.META.get('REMOTE_ADDR') in settings.INTERNAL_IPS: context_extras['debug'] = True from django.db import connection context_extras['sql_queries'] = connection.queries return context_extras def i18n(request): from django.utils import translation context_extras = {} context_extras['LANGUAGES'] = settings.LANGUAGES context_extras['LANGUAGE_CODE'] = translation.get_language() context_extras['LANGUAGE_BIDI'] = translation.get_language_bidi() return context_extras def media(request): """ Adds media-related context variables to the context. """ return {'MEDIA_URL': settings.MEDIA_URL} def request(request): return {'request': request} # PermWrapper and PermLookupDict proxy the permissions system into objects that # the template system can understand. class PermLookupDict(object): def __init__(self, user, module_name): self.user, self.module_name = user, module_name def __repr__(self): return str(self.user.get_all_permissions()) def __getitem__(self, perm_name): return self.user.has_perm("%s.%s" % (self.module_name, perm_name)) def __nonzero__(self): return self.user.has_module_perms(self.module_name) class PermWrapper(object): def __init__(self, user): self.user = user def __getitem__(self, module_name): return PermLookupDict(self.user, module_name) def __iter__(self): # I am large, I contain multitudes. raise TypeError("PermWrapper is not iterable.")
ajibawa-2023/Python-Code-Large/train/row_98840
54
104
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_98840:Expr_L1_C0", "label": "expression", "type": "expression", "loc": [1, 8], "level": 0, "parent": null, "vector": [8, 0, 0.0433, 0.0769, 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 set of request processors that return dictionaries to be merged into a\ntemplate context. Each function takes the request object as its only parameter\nand returns a dictionary to add to the context.\n\nThese are referenced from the setting TEMPLATE_CONTEXT_PROCESSORS and used by\nRequestContext.\n\"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98840:ImportFrom_L10_C0", "label": "from django.conf import settings", "type": "import", "loc": [10, 10], "level": 0, "parent": null, "vector": [1, 0, 0.0962, 0.0096, 0, 0.66, 0.0909, 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_98840:ImportFrom_L11_C0", "label": "from django.middleware.csrf import get_token", "type": "import", "loc": [11, 11], "level": 0, "parent": null, "vector": [1, 0, 0.1058, 0.0096, 0, 0.66, 0.1818, 574, 0, 1, 0, 0, 574, 0, 0], "semantic": {"name": "django.middleware.csrf", "arg_names": [], "import_names": ["get_token"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.middleware.csrf import get_token"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98840:ImportFrom_L12_C0", "label": "from django.utils.functional import lazy", "type": "import", "loc": [12, 12], "level": 0, "parent": null, "vector": [1, 0, 0.1154, 0.0096, 0, 0.66, 0.2727, 375, 0, 1, 0, 0, 375, 0, 0], "semantic": {"name": "django.utils.functional", "arg_names": [], "import_names": ["lazy"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.utils.functional import lazy"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98840:FunctionDef_L14_C0", "label": "auth", "type": "function", "loc": [14, 30], "level": 0, "parent": null, "vector": [2, 0, 0.2115, 0.1635, 0, 0.66, 0.3636, 280, 0, 1, 1, 0, 0, 0, 2], "semantic": {"name": "auth", "arg_names": ["request"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "def auth(request):\n \"\"\"\n DEPRECATED. This context processor is the old location, and has been moved\n to `django.contrib.auth.context_processors`.\n\n This function still exists for backwards-compatibility; it will be removed\n in Django 1.4.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98840:Expr_L15_C4", "label": "expression", "type": "expression", "loc": [15, 21], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98840:FunctionDef_L14_C0", "vector": [8, 1, 0.1731, 0.0673, 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 DEPRECATED. This context processor is the old location, and has been moved\n to `django.contrib.auth.context_processors`.\n\n This function still exists for backwards-compatibility; it will be removed\n in Django 1.4.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98840:Import_L22_C4", "label": "warnings import warnings", "type": "import", "loc": [22, 22], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98840:FunctionDef_L14_C0", "vector": [1, 1, 0.2115, 0.0096, 1, 0.18, 0.25, 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_98840:Expr_L23_C4", "label": "warn()", "type": "expression", "loc": [23, 28], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98840:FunctionDef_L14_C0", "vector": [8, 1, 0.2452, 0.0577, 1, 0.18, 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(\n \"The context processor at `django.core.context_processors.auth` is \" \\\n \"deprecated; use the path `django.contrib.auth.context_processors.auth` \" \\\n \"instead.\",\n DeprecationWarning\n )"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98840:ImportFrom_L29_C4", "label": "from django.contrib.auth.context_processors import auth_context_processor", "type": "import", "loc": [29, 29], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98840:FunctionDef_L14_C0", "vector": [1, 1, 0.2788, 0.0096, 1, 0.18, 0.75, 257, 0, 1, 0, 0, 257, 0, 0], "semantic": {"name": "django.contrib.auth.context_processors", "arg_names": [], "import_names": ["auth_context_processor"], "rhs_call_name": "", "annotation": ""}, "snippet": " from django.contrib.auth.context_processors import auth as auth_context_processor"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98840:Return_L30_C4", "label": "return", "type": "return", "loc": [30, 30], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98840:FunctionDef_L14_C0", "vector": [13, 1, 0.2885, 0.0096, 1, 0.18, 1.0, 0, 3, 0, 0, 0, 0, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return auth_context_processor(request)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98840:FunctionDef_L32_C0", "label": "csrf", "type": "function", "loc": [32, 48], "level": 0, "parent": null, "vector": [2, 0, 0.3846, 0.1635, 0, 0.66, 0.4545, 505, 0, 1, 1, 0, 0, 0, 3], "semantic": {"name": "csrf", "arg_names": ["request"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "def csrf(request):\n \"\"\"\n Context processor that provides a CSRF token, or the string 'NOTPROVIDED' if\n it has not been provided by either a view decorator or the middleware\n \"\"\"\n def _get_val():\n token = get_token(request)\n if token is None:"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98840:Expr_L33_C4", "label": "expression", "type": "expression", "loc": [33, 36], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98840:FunctionDef_L32_C0", "vector": [8, 1, 0.3317, 0.0385, 1, 0.36, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"\n Context processor that provides a CSRF token, or the string 'NOTPROVIDED' if\n it has not been provided by either a view decorator or the middleware\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98840:FunctionDef_L37_C4", "label": "_get_val", "type": "function", "loc": [37, 45], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98840:FunctionDef_L32_C0", "vector": [2, 1, 0.3942, 0.0865, 1, 0.36, 0.3333, 980, 0, 0, 1, 0, 0, 0, 1], "semantic": {"name": "_get_val", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def _get_val():\n token = get_token(request)\n if token is None:\n # In order to be able to provide debugging info in the\n # case of misconfiguration, we use a sentinel value\n # instead of returning an empty dict.\n return 'NOTPROVIDED'\n else:"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98840:Assign_L38_C8", "label": "token = get_token()", "type": "assigned_variable", "loc": [38, 38], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98840:FunctionDef_L37_C4", "vector": [14, 2, 0.3654, 0.0096, 2, 0.67, 0.0, 129, 3, 1, 0, 0, 224, 10, 1], "semantic": {"name": "token", "arg_names": [], "import_names": [], "rhs_call_name": "get_token", "annotation": ""}, "snippet": " token = get_token(request)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98840:If_L39_C8", "label": "if", "type": "if", "loc": [39, 45], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98840:FunctionDef_L37_C4", "vector": [4, 2, 0.4038, 0.0673, 2, 0.67, 1.0, 0, 0, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if token is None:\n # In order to be able to provide debugging info in the\n # case of misconfiguration, we use a sentinel value\n # instead of returning an empty dict.\n return 'NOTPROVIDED'\n else:\n return token"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98840:Return_L43_C12", "label": "return", "type": "return", "loc": [43, 43], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98840:If_L39_C8", "vector": [13, 3, 0.4135, 0.0096, 3, 0.79, 0.0, 0, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return 'NOTPROVIDED'"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98840:Return_L45_C12", "label": "return", "type": "return", "loc": [45, 45], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98840:If_L39_C8", "vector": [13, 3, 0.4327, 0.0096, 3, 0.79, 1.0, 0, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return token"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98840:Assign_L46_C4", "label": "_get_val = lazy()", "type": "assigned_variable", "loc": [46, 46], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98840:FunctionDef_L32_C0", "vector": [14, 1, 0.4423, 0.0096, 1, 0.36, 0.6667, 980, 3, 2, 0, 0, 528, 10, 1], "semantic": {"name": "_get_val", "arg_names": [], "import_names": [], "rhs_call_name": "lazy", "annotation": ""}, "snippet": " _get_val = lazy(_get_val, str)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98840:Return_L48_C4", "label": "return", "type": "return", "loc": [48, 48], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98840:FunctionDef_L32_C0", "vector": [13, 1, 0.4615, 0.0096, 1, 0.36, 1.0, 0, 0, 0, 0, 0, 0, 6, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return {'csrf_token': _get_val() }"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98840:FunctionDef_L50_C0", "label": "debug", "type": "function", "loc": [50, 57], "level": 0, "parent": null, "vector": [2, 0, 0.5144, 0.0769, 0, 0.66, 0.5455, 924, 0, 1, 1, 0, 0, 0, 1], "semantic": {"name": "debug", "arg_names": ["request"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "def debug(request):\n \"Returns context variables helpful for debugging.\"\n context_extras = {}\n if settings.DEBUG and request.META.get('REMOTE_ADDR') in settings.INTERNAL_IPS:\n context_extras['debug'] = True\n from django.db import connection\n context_extras['sql_queries'] = connection.queries\n return context_extras"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98840:Expr_L51_C4", "label": "expression", "type": "expression", "loc": [51, 51], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98840:FunctionDef_L50_C0", "vector": [8, 1, 0.4904, 0.0096, 1, 0.77, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"Returns context variables helpful for debugging.\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98840:Assign_L52_C4", "label": "context_extras =", "type": "assigned_variable", "loc": [52, 52], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98840:FunctionDef_L50_C0", "vector": [14, 1, 0.5, 0.0096, 1, 0.77, 0.3333, 133, 0, 0, 0, 0, 0, 6, 0], "semantic": {"name": "context_extras", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " context_extras = {}"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98840:If_L53_C4", "label": "if", "type": "if", "loc": [53, 56], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98840:FunctionDef_L50_C0", "vector": [4, 1, 0.524, 0.0385, 1, 0.77, 0.6667, 0, 0, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if settings.DEBUG and request.META.get('REMOTE_ADDR') in settings.INTERNAL_IPS:\n context_extras['debug'] = True\n from django.db import connection\n context_extras['sql_queries'] = connection.queries"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98840:Assign_L54_C8", "label": "assign", "type": "assigned_variable", "loc": [54, 54], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98840:If_L53_C4", "vector": [14, 2, 0.5192, 0.0096, 2, 0.43, 0.0, 0, 1, 0, 0, 0, 0, 4, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " context_extras['debug'] = True"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98840:ImportFrom_L55_C8", "label": "from django.db import connection", "type": "import", "loc": [55, 55], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98840:If_L53_C4", "vector": [1, 2, 0.5288, 0.0096, 2, 0.43, 0.5, 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_98840:Assign_L56_C8", "label": "assign", "type": "assigned_variable", "loc": [56, 56], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98840:If_L53_C4", "vector": [14, 2, 0.5385, 0.0096, 2, 0.43, 1.0, 0, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " context_extras['sql_queries'] = connection.queries"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98840:Return_L57_C4", "label": "return", "type": "return", "loc": [57, 57], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98840:FunctionDef_L50_C0", "vector": [13, 1, 0.5481, 0.0096, 1, 0.77, 1.0, 0, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return context_extras"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98840:FunctionDef_L59_C0", "label": "i18n", "type": "function", "loc": [59, 67], "level": 0, "parent": null, "vector": [2, 0, 0.6058, 0.0865, 0, 0.66, 0.6364, 274, 0, 1, 1, 0, 0, 0, 2], "semantic": {"name": "i18n", "arg_names": ["request"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "def i18n(request):\n from django.utils import translation\n\n context_extras = {}\n context_extras['LANGUAGES'] = settings.LANGUAGES\n context_extras['LANGUAGE_CODE'] = translation.get_language()\n context_extras['LANGUAGE_BIDI'] = translation.get_language_bidi()\n"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98840:ImportFrom_L60_C4", "label": "from django.utils import translation", "type": "import", "loc": [60, 60], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98840:FunctionDef_L59_C0", "vector": [1, 1, 0.5769, 0.0096, 1, 0.81, 0.0, 944, 0, 1, 0, 0, 944, 0, 0], "semantic": {"name": "django.utils", "arg_names": [], "import_names": ["translation"], "rhs_call_name": "", "annotation": ""}, "snippet": " from django.utils import translation"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98840:Assign_L62_C4", "label": "context_extras =", "type": "assigned_variable", "loc": [62, 62], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98840:FunctionDef_L59_C0", "vector": [14, 1, 0.5962, 0.0096, 1, 0.81, 0.2, 133, 0, 0, 0, 0, 0, 6, 0], "semantic": {"name": "context_extras", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " context_extras = {}"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98840:Assign_L63_C4", "label": "assign", "type": "assigned_variable", "loc": [63, 63], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98840:FunctionDef_L59_C0", "vector": [14, 1, 0.6058, 0.0096, 1, 0.81, 0.4, 0, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " context_extras['LANGUAGES'] = settings.LANGUAGES"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98840:Assign_L64_C4", "label": " = get_language()", "type": "assigned_variable", "loc": [64, 64], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98840:FunctionDef_L59_C0", "vector": [14, 1, 0.6154, 0.0096, 1, 0.81, 0.6, 0, 3, 0, 0, 0, 674, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "get_language", "annotation": ""}, "snippet": " context_extras['LANGUAGE_CODE'] = translation.get_language()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98840:Assign_L65_C4", "label": " = get_language_bidi()", "type": "assigned_variable", "loc": [65, 65], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98840:FunctionDef_L59_C0", "vector": [14, 1, 0.625, 0.0096, 1, 0.81, 0.8, 0, 3, 0, 0, 0, 583, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "get_language_bidi", "annotation": ""}, "snippet": " context_extras['LANGUAGE_BIDI'] = translation.get_language_bidi()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98840:Return_L67_C4", "label": "return", "type": "return", "loc": [67, 67], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98840:FunctionDef_L59_C0", "vector": [13, 1, 0.6442, 0.0096, 1, 0.81, 1.0, 0, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return context_extras"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98840:FunctionDef_L69_C0", "label": "media", "type": "function", "loc": [69, 74], "level": 0, "parent": null, "vector": [2, 0, 0.6875, 0.0577, 0, 0.66, 0.7273, 317, 0, 1, 1, 0, 0, 0, 0], "semantic": {"name": "media", "arg_names": ["request"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "def media(request):\n \"\"\"\n Adds media-related context variables to the context.\n\n \"\"\"\n return {'MEDIA_URL': settings.MEDIA_URL}"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98840:Expr_L70_C4", "label": "expression", "type": "expression", "loc": [70, 73], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98840:FunctionDef_L69_C0", "vector": [8, 1, 0.6875, 0.0385, 1, 0.57, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"\n Adds media-related context variables to the context.\n\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98840:Return_L74_C4", "label": "return", "type": "return", "loc": [74, 74], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98840:FunctionDef_L69_C0", "vector": [13, 1, 0.7115, 0.0096, 1, 0.57, 1.0, 0, 0, 0, 0, 0, 0, 6, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return {'MEDIA_URL': settings.MEDIA_URL}"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98840:FunctionDef_L76_C0", "label": "request", "type": "function", "loc": [76, 77], "level": 0, "parent": null, "vector": [2, 0, 0.7356, 0.0192, 0, 0.66, 0.8182, 50, 0, 1, 1, 0, 0, 0, 0], "semantic": {"name": "request", "arg_names": ["request"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "def request(request):\n return {'request': request}"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98840:Return_L77_C4", "label": "return", "type": "return", "loc": [77, 77], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98840:FunctionDef_L76_C0", "vector": [13, 1, 0.7404, 0.0096, 1, 0.0, 0.0, 0, 0, 0, 0, 0, 0, 6, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return {'request': request}"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98840:ClassDef_L82_C0", "label": "PermLookupDict", "type": "class", "loc": [82, 93], "level": 0, "parent": null, "vector": [3, 0, 0.8413, 0.1154, 0, 0.66, 0.9091, 495, 0, 4, 0, 0, 186, 0, 4], "semantic": {"name": "PermLookupDict", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class PermLookupDict(object):\n def __init__(self, user, module_name):\n self.user, self.module_name = user, module_name\n\n def __repr__(self):\n return str(self.user.get_all_permissions())\n\n def __getitem__(self, perm_name):"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98840:FunctionDef_L83_C4", "label": "__init__", "type": "function", "loc": [83, 84], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98840:ClassDef_L82_C0", "vector": [2, 1, 0.8029, 0.0192, 1, 0.96, 0.0, 555, 0, 3, 0, 0, 0, 0, 0], "semantic": {"name": "__init__", "arg_names": ["self", "user", "module_name"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def __init__(self, user, module_name):\n self.user, self.module_name = user, module_name"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98840:Assign_L84_C8", "label": "assign", "type": "assigned_variable", "loc": [84, 84], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98840:FunctionDef_L83_C4", "vector": [14, 2, 0.8077, 0.0096, 2, 0.22, 0.0, 0, 0, 0, 0, 0, 0, 8, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.user, self.module_name = user, module_name"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98840:FunctionDef_L86_C4", "label": "__repr__", "type": "function", "loc": [86, 87], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98840:ClassDef_L82_C0", "vector": [2, 1, 0.8317, 0.0192, 1, 0.96, 0.3333, 204, 0, 1, 1, 0, 0, 0, 2], "semantic": {"name": "__repr__", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def __repr__(self):\n return str(self.user.get_all_permissions())"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98840:Return_L87_C8", "label": "return", "type": "return", "loc": [87, 87], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98840:FunctionDef_L86_C4", "vector": [13, 2, 0.8365, 0.0096, 2, 0.33, 0.0, 0, 3, 0, 0, 0, 0, 10, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return str(self.user.get_all_permissions())"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98840:FunctionDef_L89_C4", "label": "__getitem__", "type": "function", "loc": [89, 90], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98840:ClassDef_L82_C0", "vector": [2, 1, 0.8606, 0.0192, 1, 0.96, 0.6667, 698, 0, 2, 1, 0, 0, 0, 1], "semantic": {"name": "__getitem__", "arg_names": ["self", "perm_name"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def __getitem__(self, perm_name):\n return self.user.has_perm(\"%s.%s\" % (self.module_name, perm_name))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98840:Return_L90_C8", "label": "return", "type": "return", "loc": [90, 90], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98840:FunctionDef_L89_C4", "vector": [13, 2, 0.8654, 0.0096, 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.user.has_perm(\"%s.%s\" % (self.module_name, perm_name))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98840:FunctionDef_L92_C4", "label": "__nonzero__", "type": "function", "loc": [92, 93], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98840:ClassDef_L82_C0", "vector": [2, 1, 0.8894, 0.0192, 1, 0.96, 1.0, 322, 0, 1, 1, 0, 0, 0, 1], "semantic": {"name": "__nonzero__", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def __nonzero__(self):\n return self.user.has_module_perms(self.module_name)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98840:Return_L93_C8", "label": "return", "type": "return", "loc": [93, 93], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98840:FunctionDef_L92_C4", "vector": [13, 2, 0.8942, 0.0096, 2, 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.user.has_module_perms(self.module_name)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98840:ClassDef_L95_C0", "label": "PermWrapper", "type": "class", "loc": [95, 104], "level": 0, "parent": null, "vector": [3, 0, 0.9567, 0.0962, 0, 0.66, 1.0, 448, 0, 3, 0, 0, 186, 0, 2], "semantic": {"name": "PermWrapper", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class PermWrapper(object):\n def __init__(self, user):\n self.user = user\n\n def __getitem__(self, module_name):\n return PermLookupDict(self.user, module_name)\n\n def __iter__(self):"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98840:FunctionDef_L96_C4", "label": "__init__", "type": "function", "loc": [96, 97], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98840:ClassDef_L95_C0", "vector": [2, 1, 0.9279, 0.0192, 1, 0.32, 0.0, 555, 0, 2, 0, 0, 0, 0, 0], "semantic": {"name": "__init__", "arg_names": ["self", "user"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def __init__(self, user):\n self.user = user"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98840:Assign_L97_C8", "label": "self.user =", "type": "assigned_variable", "loc": [97, 97], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98840:FunctionDef_L96_C4", "vector": [14, 2, 0.9327, 0.0096, 2, 0.47, 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_98840:FunctionDef_L99_C4", "label": "__getitem__", "type": "function", "loc": [99, 100], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98840:ClassDef_L95_C0", "vector": [2, 1, 0.9567, 0.0192, 1, 0.32, 0.5, 698, 0, 2, 1, 0, 0, 0, 1], "semantic": {"name": "__getitem__", "arg_names": ["self", "module_name"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def __getitem__(self, module_name):\n return PermLookupDict(self.user, module_name)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98840:Return_L100_C8", "label": "return", "type": "return", "loc": [100, 100], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98840:FunctionDef_L99_C4", "vector": [13, 2, 0.9615, 0.0096, 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 PermLookupDict(self.user, module_name)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98840:FunctionDef_L102_C4", "label": "__iter__", "type": "function", "loc": [102, 104], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98840:ClassDef_L95_C0", "vector": [2, 1, 0.9904, 0.0288, 1, 0.32, 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 # I am large, I contain multitudes.\n raise TypeError(\"PermWrapper is not iterable.\")"}]
[{"f": "ajibawa-2023/Python-Code-Large/train/row_98840:FunctionDef_L14_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98840:Expr_L15_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98840:FunctionDef_L14_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98840:Import_L22_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98840:FunctionDef_L14_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98840:Expr_L23_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98840:FunctionDef_L14_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98840:ImportFrom_L29_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98840:FunctionDef_L14_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98840:Return_L30_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98840:FunctionDef_L32_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98840:Expr_L33_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98840:FunctionDef_L32_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98840:FunctionDef_L37_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98840:FunctionDef_L37_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98840:Assign_L38_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98840:FunctionDef_L37_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98840:If_L39_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98840:If_L39_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98840:Return_L43_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98840:If_L39_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98840:Return_L45_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98840:FunctionDef_L32_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98840:Assign_L46_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98840:FunctionDef_L32_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98840:Return_L48_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98840:FunctionDef_L50_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98840:Expr_L51_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98840:FunctionDef_L50_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98840:Assign_L52_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98840:FunctionDef_L50_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98840:If_L53_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98840:If_L53_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98840:Assign_L54_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98840:If_L53_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98840:ImportFrom_L55_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98840:If_L53_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98840:Assign_L56_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98840:FunctionDef_L50_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98840:Return_L57_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98840:FunctionDef_L59_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98840:ImportFrom_L60_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98840:FunctionDef_L59_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98840:Assign_L62_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98840:FunctionDef_L59_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98840:Assign_L63_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98840:FunctionDef_L59_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98840:Assign_L64_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98840:FunctionDef_L59_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98840:Assign_L65_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98840:FunctionDef_L59_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98840:Return_L67_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98840:FunctionDef_L69_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98840:Expr_L70_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98840:FunctionDef_L69_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98840:Return_L74_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98840:FunctionDef_L76_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98840:Return_L77_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98840:ClassDef_L82_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98840:FunctionDef_L83_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98840:FunctionDef_L83_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98840:Assign_L84_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98840:ClassDef_L82_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98840:FunctionDef_L86_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98840:FunctionDef_L86_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98840:Return_L87_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98840:ClassDef_L82_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98840:FunctionDef_L89_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98840:FunctionDef_L89_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98840:Return_L90_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98840:ClassDef_L82_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98840:FunctionDef_L92_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98840:FunctionDef_L92_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98840:Return_L93_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98840:ClassDef_L95_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98840:FunctionDef_L96_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98840:FunctionDef_L96_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98840:Assign_L97_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98840:ClassDef_L95_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98840:FunctionDef_L99_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98840:FunctionDef_L99_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98840:Return_L100_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98840:ClassDef_L95_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98840:FunctionDef_L102_C4"}]
import mimetypes import os import random import time from email import Charset, Encoders from email.MIMEText import MIMEText from email.MIMEMultipart import MIMEMultipart from email.MIMEBase import MIMEBase from email.Header import Header from email.Utils import formatdate, getaddresses, formataddr from django.conf import settings from django.core.mail.utils import DNS_NAME from django.utils.encoding import smart_str, force_unicode # Don't BASE64-encode UTF-8 messages so that we avoid unwanted attention from # some spam filters. Charset.add_charset('utf-8', Charset.SHORTEST, Charset.QP, 'utf-8') # Default MIME type to use on attachments (if it is not explicitly given # and cannot be guessed). DEFAULT_ATTACHMENT_MIME_TYPE = 'application/octet-stream' class BadHeaderError(ValueError): pass # Copied from Python standard library, with the following modifications: # * Used cached hostname for performance. # * Added try/except to support lack of getpid() in Jython (#5496). def make_msgid(idstring=None): """Returns a string suitable for RFC 2822 compliant Message-ID, e.g: <20020201195627.33539.96671@nightshade.la.mastaler.com> Optional idstring if given is a string used to strengthen the uniqueness of the message id. """ timeval = time.time() utcdate = time.strftime('%Y%m%d%H%M%S', time.gmtime(timeval)) try: pid = os.getpid() except AttributeError: # No getpid() in Jython, for example. pid = 1 randint = random.randrange(100000) if idstring is None: idstring = '' else: idstring = '.' + idstring idhost = DNS_NAME msgid = '<%s.%s.%s%s@%s>' % (utcdate, pid, randint, idstring, idhost) return msgid def forbid_multi_line_headers(name, val, encoding): """Forbids multi-line headers, to prevent header injection.""" encoding = encoding or settings.DEFAULT_CHARSET val = force_unicode(val) if '\n' in val or '\r' in val: raise BadHeaderError("Header values can't contain newlines (got %r for header %r)" % (val, name)) try: val = val.encode('ascii') except UnicodeEncodeError: if name.lower() in ('to', 'from', 'cc'): result = [] for nm, addr in getaddresses((val,)): nm = str(Header(nm.encode(encoding), encoding)) try: addr = addr.encode('ascii') except UnicodeEncodeError: # IDN addr = str(Header(addr.encode(encoding), encoding)) result.append(formataddr((nm, addr))) val = ', '.join(result) else: val = Header(val.encode(encoding), encoding) else: if name.lower() == 'subject': val = Header(val) return name, val class SafeMIMEText(MIMEText): def __init__(self, text, subtype, charset): self.encoding = charset MIMEText.__init__(self, text, subtype, charset) def __setitem__(self, name, val): name, val = forbid_multi_line_headers(name, val, self.encoding) MIMEText.__setitem__(self, name, val) class SafeMIMEMultipart(MIMEMultipart): def __init__(self, _subtype='mixed', boundary=None, _subparts=None, encoding=None, **_params): self.encoding = encoding MIMEMultipart.__init__(self, _subtype, boundary, _subparts, **_params) def __setitem__(self, name, val): name, val = forbid_multi_line_headers(name, val, self.encoding) MIMEMultipart.__setitem__(self, name, val) class EmailMessage(object): """ A container for email information. """ content_subtype = 'plain' mixed_subtype = 'mixed' encoding = None # None => use settings default def __init__(self, subject='', body='', from_email=None, to=None, bcc=None, connection=None, attachments=None, headers=None, cc=None): """ Initialize a single email message (which can be sent to multiple recipients). All strings used to create the message can be unicode strings (or UTF-8 bytestrings). The SafeMIMEText class will handle any necessary encoding conversions. """ if to: assert not isinstance(to, basestring), '"to" argument must be a list or tuple' self.to = list(to) else: self.to = [] if cc: assert not isinstance(cc, basestring), '"cc" argument must be a list or tuple' self.cc = list(cc) else: self.cc = [] if bcc: assert not isinstance(bcc, basestring), '"bcc" argument must be a list or tuple' self.bcc = list(bcc) else: self.bcc = [] self.from_email = from_email or settings.DEFAULT_FROM_EMAIL self.subject = subject self.body = body self.attachments = attachments or [] self.extra_headers = headers or {} self.connection = connection def get_connection(self, fail_silently=False): from django.core.mail import get_connection if not self.connection: self.connection = get_connection(fail_silently=fail_silently) return self.connection def message(self): encoding = self.encoding or settings.DEFAULT_CHARSET msg = SafeMIMEText(smart_str(self.body, encoding), self.content_subtype, encoding) msg = self._create_message(msg) msg['Subject'] = self.subject msg['From'] = self.extra_headers.get('From', self.from_email) msg['To'] = ', '.join(self.to) if self.cc: msg['Cc'] = ', '.join(self.cc) # Email header names are case-insensitive (RFC 2045), so we have to # accommodate that when doing comparisons. header_names = [key.lower() for key in self.extra_headers] if 'date' not in header_names: msg['Date'] = formatdate() if 'message-id' not in header_names: msg['Message-ID'] = make_msgid() for name, value in self.extra_headers.items(): if name.lower() == 'from': # From is already handled continue msg[name] = value return msg def recipients(self): """ Returns a list of all recipients of the email (includes direct addressees as well as Cc and Bcc entries). """ return self.to + self.cc + self.bcc def send(self, fail_silently=False): """Sends the email message.""" if not self.recipients(): # Don't bother creating the network connection if there's nobody to # send to. return 0 return self.get_connection(fail_silently).send_messages([self]) def attach(self, filename=None, content=None, mimetype=None): """ Attaches a file with the given filename and content. The filename can be omitted and the mimetype is guessed, if not provided. If the first parameter is a MIMEBase subclass it is inserted directly into the resulting message attachments. """ if isinstance(filename, MIMEBase): assert content == mimetype == None self.attachments.append(filename) else: assert content is not None self.attachments.append((filename, content, mimetype)) def attach_file(self, path, mimetype=None): """Attaches a file from the filesystem.""" filename = os.path.basename(path) content = open(path, 'rb').read() self.attach(filename, content, mimetype) def _create_message(self, msg): return self._create_attachments(msg) def _create_attachments(self, msg): if self.attachments: encoding = self.encoding or settings.DEFAULT_CHARSET body_msg = msg msg = SafeMIMEMultipart(_subtype=self.mixed_subtype, encoding=encoding) if self.body: msg.attach(body_msg) for attachment in self.attachments: if isinstance(attachment, MIMEBase): msg.attach(attachment) else: msg.attach(self._create_attachment(*attachment)) return msg def _create_mime_attachment(self, content, mimetype): """ Converts the content, mimetype pair into a MIME attachment object. """ basetype, subtype = mimetype.split('/', 1) if basetype == 'text': encoding = self.encoding or settings.DEFAULT_CHARSET attachment = SafeMIMEText(smart_str(content, encoding), subtype, encoding) else: # Encode non-text attachments with base64. attachment = MIMEBase(basetype, subtype) attachment.set_payload(content) Encoders.encode_base64(attachment) return attachment def _create_attachment(self, filename, content, mimetype=None): """ Converts the filename, content, mimetype triple into a MIME attachment object. """ if mimetype is None: mimetype, _ = mimetypes.guess_type(filename) if mimetype is None: mimetype = DEFAULT_ATTACHMENT_MIME_TYPE attachment = self._create_mime_attachment(content, mimetype) if filename: attachment.add_header('Content-Disposition', 'attachment', filename=filename) return attachment class EmailMultiAlternatives(EmailMessage): """ A version of EmailMessage that makes it easy to send multipart/alternative messages. For example, including text and HTML versions of the text is made easier. """ alternative_subtype = 'alternative' def __init__(self, subject='', body='', from_email=None, to=None, bcc=None, connection=None, attachments=None, headers=None, alternatives=None, cc=None): """ Initialize a single email message (which can be sent to multiple recipients). All strings used to create the message can be unicode strings (or UTF-8 bytestrings). The SafeMIMEText class will handle any necessary encoding conversions. """ super(EmailMultiAlternatives, self).__init__(subject, body, from_email, to, bcc, connection, attachments, headers, cc) self.alternatives=alternatives or [] def attach_alternative(self, content, mimetype): """Attach an alternative content representation.""" assert content is not None assert mimetype is not None self.alternatives.append((content, mimetype)) def _create_message(self, msg): return self._create_attachments(self._create_alternatives(msg)) def _create_alternatives(self, msg): encoding = self.encoding or settings.DEFAULT_CHARSET if self.alternatives: body_msg = msg msg = SafeMIMEMultipart(_subtype=self.alternative_subtype, encoding=encoding) if self.body: msg.attach(body_msg) for alternative in self.alternatives: msg.attach(self._create_mime_attachment(*alternative)) return msg
ajibawa-2023/Python-Code-Large/train/row_98841
183
297
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_98841:Import_L1_C0", "label": "mimetypes import mimetypes", "type": "import", "loc": [1, 1], "level": 0, "parent": null, "vector": [1, 0, 0.0034, 0.0034, 0, 0.66, 0.0, 583, 0, 1, 0, 0, 583, 0, 0], "semantic": {"name": "mimetypes", "arg_names": [], "import_names": ["mimetypes"], "rhs_call_name": "", "annotation": ""}, "snippet": "import mimetypes"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98841:Import_L2_C0", "label": "os import os", "type": "import", "loc": [2, 2], "level": 0, "parent": null, "vector": [1, 0, 0.0067, 0.0034, 0, 0.66, 0.0476, 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_98841:Import_L3_C0", "label": "random import random", "type": "import", "loc": [3, 3], "level": 0, "parent": null, "vector": [1, 0, 0.0101, 0.0034, 0, 0.66, 0.0952, 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_98841:Import_L4_C0", "label": "time import time", "type": "import", "loc": [4, 4], "level": 0, "parent": null, "vector": [1, 0, 0.0135, 0.0034, 0, 0.66, 0.1429, 654, 0, 1, 0, 0, 654, 0, 0], "semantic": {"name": "time", "arg_names": [], "import_names": ["time"], "rhs_call_name": "", "annotation": ""}, "snippet": "import time"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98841:ImportFrom_L5_C0", "label": "from email import Charset, Encoders", "type": "import", "loc": [5, 5], "level": 0, "parent": null, "vector": [1, 0, 0.0168, 0.0034, 0, 0.66, 0.1905, 413, 0, 2, 0, 0, 413, 0, 0], "semantic": {"name": "email", "arg_names": [], "import_names": ["Charset", "Encoders"], "rhs_call_name": "", "annotation": ""}, "snippet": "from email import Charset, Encoders"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98841:ImportFrom_L6_C0", "label": "from email.MIMEText import MIMEText", "type": "import", "loc": [6, 6], "level": 0, "parent": null, "vector": [1, 0, 0.0202, 0.0034, 0, 0.66, 0.2381, 216, 0, 1, 0, 0, 216, 0, 0], "semantic": {"name": "email.MIMEText", "arg_names": [], "import_names": ["MIMEText"], "rhs_call_name": "", "annotation": ""}, "snippet": "from email.MIMEText import MIMEText"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98841:ImportFrom_L7_C0", "label": "from email.MIMEMultipart import MIMEMultipart", "type": "import", "loc": [7, 7], "level": 0, "parent": null, "vector": [1, 0, 0.0236, 0.0034, 0, 0.66, 0.2857, 349, 0, 1, 0, 0, 349, 0, 0], "semantic": {"name": "email.MIMEMultipart", "arg_names": [], "import_names": ["MIMEMultipart"], "rhs_call_name": "", "annotation": ""}, "snippet": "from email.MIMEMultipart import MIMEMultipart"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98841:ImportFrom_L8_C0", "label": "from email.MIMEBase import MIMEBase", "type": "import", "loc": [8, 8], "level": 0, "parent": null, "vector": [1, 0, 0.0269, 0.0034, 0, 0.66, 0.3333, 360, 0, 1, 0, 0, 360, 0, 0], "semantic": {"name": "email.MIMEBase", "arg_names": [], "import_names": ["MIMEBase"], "rhs_call_name": "", "annotation": ""}, "snippet": "from email.MIMEBase import MIMEBase"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98841:ImportFrom_L9_C0", "label": "from email.Header import Header", "type": "import", "loc": [9, 9], "level": 0, "parent": null, "vector": [1, 0, 0.0303, 0.0034, 0, 0.66, 0.381, 130, 0, 1, 0, 0, 130, 0, 0], "semantic": {"name": "email.Header", "arg_names": [], "import_names": ["Header"], "rhs_call_name": "", "annotation": ""}, "snippet": "from email.Header import Header"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98841:ImportFrom_L10_C0", "label": "from email.Utils import formatdate, getaddresses, formataddr", "type": "import", "loc": [10, 10], "level": 0, "parent": null, "vector": [1, 0, 0.0337, 0.0034, 0, 0.66, 0.4286, 589, 0, 3, 0, 0, 589, 0, 0], "semantic": {"name": "email.Utils", "arg_names": [], "import_names": ["formatdate", "getaddresses", "formataddr"], "rhs_call_name": "", "annotation": ""}, "snippet": "from email.Utils import formatdate, getaddresses, formataddr"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98841:ImportFrom_L12_C0", "label": "from django.conf import settings", "type": "import", "loc": [12, 12], "level": 0, "parent": null, "vector": [1, 0, 0.0404, 0.0034, 0, 0.66, 0.4762, 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_98841:ImportFrom_L13_C0", "label": "from django.core.mail.utils import DNS_NAME", "type": "import", "loc": [13, 13], "level": 0, "parent": null, "vector": [1, 0, 0.0438, 0.0034, 0, 0.66, 0.5238, 787, 0, 1, 0, 0, 787, 0, 0], "semantic": {"name": "django.core.mail.utils", "arg_names": [], "import_names": ["DNS_NAME"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.core.mail.utils import DNS_NAME"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98841:ImportFrom_L14_C0", "label": "from django.utils.encoding import smart_str, force_unicode", "type": "import", "loc": [14, 14], "level": 0, "parent": null, "vector": [1, 0, 0.0471, 0.0034, 0, 0.66, 0.5714, 96, 0, 2, 0, 0, 96, 0, 0], "semantic": {"name": "django.utils.encoding", "arg_names": [], "import_names": ["smart_str", "force_unicode"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.utils.encoding import smart_str, force_unicode"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98841:Expr_L18_C0", "label": "add_charset()", "type": "expression", "loc": [18, 18], "level": 0, "parent": null, "vector": [8, 0, 0.0606, 0.0034, 0, 0.66, 0.619, 400, 3, 4, 0, 0, 0, 0, 1], "semantic": {"name": "add_charset", "arg_names": [], "import_names": [], "rhs_call_name": "add_charset", "annotation": ""}, "snippet": "Charset.add_charset('utf-8', Charset.SHORTEST, Charset.QP, 'utf-8')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98841:Assign_L22_C0", "label": "DEFAULT_ATTACHMENT_MIME_TYPE =", "type": "assigned_variable", "loc": [22, 22], "level": 0, "parent": null, "vector": [14, 0, 0.0741, 0.0034, 0, 0.66, 0.6667, 604, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "DEFAULT_ATTACHMENT_MIME_TYPE", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "DEFAULT_ATTACHMENT_MIME_TYPE = 'application/octet-stream'"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98841:ClassDef_L25_C0", "label": "BadHeaderError", "type": "class", "loc": [25, 26], "level": 0, "parent": null, "vector": [3, 0, 0.0859, 0.0067, 0, 0.66, 0.7143, 538, 0, 0, 0, 0, 690, 0, 0], "semantic": {"name": "BadHeaderError", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class BadHeaderError(ValueError):\n pass"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98841:FunctionDef_L32_C0", "label": "make_msgid", "type": "function", "loc": [32, 54], "level": 0, "parent": null, "vector": [2, 0, 0.1448, 0.0774, 0, 0.66, 0.7619, 980, 0, 1, 1, 0, 0, 0, 5], "semantic": {"name": "make_msgid", "arg_names": ["idstring"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "def make_msgid(idstring=None):\n \"\"\"Returns a string suitable for RFC 2822 compliant Message-ID, e.g:\n\n <20020201195627.33539.96671@nightshade.la.mastaler.com>\n\n Optional idstring if given is a string used to strengthen the\n uniqueness of the message id.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98841:Expr_L33_C4", "label": "expression", "type": "expression", "loc": [33, 39], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98841:FunctionDef_L32_C0", "vector": [8, 1, 0.1212, 0.0236, 1, 0.37, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"Returns a string suitable for RFC 2822 compliant Message-ID, e.g:\n\n <20020201195627.33539.96671@nightshade.la.mastaler.com>\n\n Optional idstring if given is a string used to strengthen the\n uniqueness of the message id.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98841:Assign_L40_C4", "label": "timeval = time()", "type": "assigned_variable", "loc": [40, 40], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98841:FunctionDef_L32_C0", "vector": [14, 1, 0.1347, 0.0034, 1, 0.37, 0.125, 580, 3, 0, 0, 0, 654, 10, 1], "semantic": {"name": "timeval", "arg_names": [], "import_names": [], "rhs_call_name": "time", "annotation": ""}, "snippet": " timeval = time.time()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98841:Assign_L41_C4", "label": "utcdate = strftime()", "type": "assigned_variable", "loc": [41, 41], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98841:FunctionDef_L32_C0", "vector": [14, 1, 0.138, 0.0034, 1, 0.37, 0.25, 706, 3, 2, 0, 0, 668, 10, 2], "semantic": {"name": "utcdate", "arg_names": [], "import_names": [], "rhs_call_name": "strftime", "annotation": ""}, "snippet": " utcdate = time.strftime('%Y%m%d%H%M%S', time.gmtime(timeval))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98841:Try_L42_C4", "label": "try", "type": "try", "loc": [42, 46], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98841:FunctionDef_L32_C0", "vector": [7, 1, 0.1481, 0.0168, 1, 0.37, 0.375, 0, 0, 1, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " try:\n pid = os.getpid()\n except AttributeError:\n # No getpid() in Jython, for example.\n pid = 1"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98841:Assign_L43_C8", "label": "pid = getpid()", "type": "assigned_variable", "loc": [43, 43], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98841:Try_L42_C4", "vector": [14, 2, 0.1448, 0.0034, 2, 0.88, 0.0, 838, 3, 0, 0, 0, 896, 10, 1], "semantic": {"name": "pid", "arg_names": [], "import_names": [], "rhs_call_name": "getpid", "annotation": ""}, "snippet": " pid = os.getpid()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98841:Assign_L46_C8", "label": "pid =", "type": "assigned_variable", "loc": [46, 46], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98841:Try_L42_C4", "vector": [14, 2, 0.1549, 0.0034, 2, 0.88, 0.0, 838, 1, 0, 0, 0, 0, 1, 0], "semantic": {"name": "pid", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " pid = 1"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98841:Assign_L47_C4", "label": "randint = randrange()", "type": "assigned_variable", "loc": [47, 47], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98841:FunctionDef_L32_C0", "vector": [14, 1, 0.1582, 0.0034, 1, 0.37, 0.5, 449, 3, 1, 0, 0, 28, 10, 1], "semantic": {"name": "randint", "arg_names": [], "import_names": [], "rhs_call_name": "randrange", "annotation": ""}, "snippet": " randint = random.randrange(100000)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98841:If_L48_C4", "label": "if", "type": "if", "loc": [48, 51], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98841:FunctionDef_L32_C0", "vector": [4, 1, 0.1667, 0.0135, 1, 0.37, 0.625, 0, 0, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if idstring is None:\n idstring = ''\n else:\n idstring = '.' + idstring"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98841:Assign_L49_C8", "label": "idstring =", "type": "assigned_variable", "loc": [49, 49], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98841:If_L48_C4", "vector": [14, 2, 0.165, 0.0034, 2, 0.93, 0.0, 669, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "idstring", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " idstring = ''"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98841:Assign_L51_C8", "label": "idstring =", "type": "assigned_variable", "loc": [51, 51], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98841:If_L48_C4", "vector": [14, 2, 0.1717, 0.0034, 2, 0.93, 1.0, 669, 4, 0, 0, 0, 0, 0, 0], "semantic": {"name": "idstring", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " idstring = '.' + idstring"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98841:Assign_L52_C4", "label": "idhost =", "type": "assigned_variable", "loc": [52, 52], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98841:FunctionDef_L32_C0", "vector": [14, 1, 0.1751, 0.0034, 1, 0.37, 0.75, 550, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "idhost", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " idhost = DNS_NAME"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98841:Assign_L53_C4", "label": "msgid =", "type": "assigned_variable", "loc": [53, 53], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98841:FunctionDef_L32_C0", "vector": [14, 1, 0.1785, 0.0034, 1, 0.37, 0.875, 837, 4, 0, 0, 0, 0, 0, 0], "semantic": {"name": "msgid", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " msgid = '<%s.%s.%s%s@%s>' % (utcdate, pid, randint, idstring, idhost)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98841:Return_L54_C4", "label": "return", "type": "return", "loc": [54, 54], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98841:FunctionDef_L32_C0", "vector": [13, 1, 0.1818, 0.0034, 1, 0.37, 1.0, 0, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return msgid"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98841:FunctionDef_L57_C0", "label": "forbid_multi_line_headers", "type": "function", "loc": [57, 81], "level": 0, "parent": null, "vector": [2, 0, 0.2323, 0.0842, 0, 0.66, 0.8095, 585, 0, 3, 1, 0, 0, 0, 19], "semantic": {"name": "forbid_multi_line_headers", "arg_names": ["name", "val", "encoding"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "def forbid_multi_line_headers(name, val, encoding):\n \"\"\"Forbids multi-line headers, to prevent header injection.\"\"\"\n encoding = encoding or settings.DEFAULT_CHARSET\n val = force_unicode(val)\n if '\\n' in val or '\\r' in val:\n raise BadHeaderError(\"Header values can't contain newlines (got %r for header %r)\" % (val, name))\n try:\n val = val.encode('ascii')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98841:Expr_L58_C4", "label": "expression", "type": "expression", "loc": [58, 58], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98841:FunctionDef_L57_C0", "vector": [8, 1, 0.1953, 0.0034, 1, 0.55, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"Forbids multi-line headers, to prevent header injection.\"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98841:Assign_L59_C4", "label": "encoding =", "type": "assigned_variable", "loc": [59, 59], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98841:FunctionDef_L57_C0", "vector": [14, 1, 0.1987, 0.0034, 1, 0.55, 0.2, 325, 0, 0, 0, 0, 0, 0, 0], "semantic": {"name": "encoding", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " encoding = encoding or settings.DEFAULT_CHARSET"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98841:Assign_L60_C4", "label": "val = force_unicode()", "type": "assigned_variable", "loc": [60, 60], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98841:FunctionDef_L57_C0", "vector": [14, 1, 0.202, 0.0034, 1, 0.55, 0.4, 618, 3, 1, 0, 0, 870, 10, 1], "semantic": {"name": "val", "arg_names": [], "import_names": [], "rhs_call_name": "force_unicode", "annotation": ""}, "snippet": " val = force_unicode(val)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98841:If_L61_C4", "label": "if", "type": "if", "loc": [61, 62], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98841:FunctionDef_L57_C0", "vector": [4, 1, 0.2071, 0.0067, 1, 0.55, 0.6, 0, 0, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if '\\n' in val or '\\r' in val:\n raise BadHeaderError(\"Header values can't contain newlines (got %r for header %r)\" % (val, name))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98841:Try_L63_C4", "label": "try", "type": "try", "loc": [63, 80], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98841:FunctionDef_L57_C0", "vector": [7, 1, 0.2407, 0.0606, 1, 0.55, 0.8, 0, 0, 1, 0, 0, 0, 0, 17], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " try:\n val = val.encode('ascii')\n except UnicodeEncodeError:\n if name.lower() in ('to', 'from', 'cc'):\n result = []\n for nm, addr in getaddresses((val,)):\n nm = str(Header(nm.encode(encoding), encoding))\n try:"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98841:Assign_L64_C8", "label": "val = encode()", "type": "assigned_variable", "loc": [64, 64], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98841:Try_L63_C4", "vector": [14, 2, 0.2155, 0.0034, 2, 0.8, 0.0, 618, 3, 1, 0, 0, 623, 10, 1], "semantic": {"name": "val", "arg_names": [], "import_names": [], "rhs_call_name": "encode", "annotation": ""}, "snippet": " val = val.encode('ascii')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98841:If_L66_C8", "label": "if", "type": "if", "loc": [66, 77], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98841:Try_L63_C4", "vector": [4, 2, 0.2407, 0.0404, 2, 0.8, 0.0, 0, 0, 0, 0, 0, 0, 0, 14], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if name.lower() in ('to', 'from', 'cc'):\n result = []\n for nm, addr in getaddresses((val,)):\n nm = str(Header(nm.encode(encoding), encoding))\n try:\n addr = addr.encode('ascii')\n except UnicodeEncodeError: # IDN\n addr = str(Header(addr.encode(encoding), encoding))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98841:Assign_L67_C12", "label": "result =", "type": "assigned_variable", "loc": [67, 67], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98841:If_L66_C8", "vector": [14, 3, 0.2256, 0.0034, 3, 0.93, 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_98841:For_L68_C12", "label": "for nm, addr", "type": "for", "loc": [68, 74], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98841:If_L66_C8", "vector": [6, 3, 0.2391, 0.0236, 3, 0.93, 0.3333, 778, 3, 0, 0, 0, 0, 0, 10], "semantic": {"name": "nm, addr", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for nm, addr in getaddresses((val,)):\n nm = str(Header(nm.encode(encoding), encoding))\n try:\n addr = addr.encode('ascii')\n except UnicodeEncodeError: # IDN\n addr = str(Header(addr.encode(encoding), encoding))\n result.append(formataddr((nm, addr)))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98841:Assign_L69_C16", "label": "nm = str()", "type": "assigned_variable", "loc": [69, 69], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98841:For_L68_C12", "vector": [14, 4, 0.2323, 0.0034, 4, 0.16, 0.0, 931, 3, 1, 0, 0, 52, 10, 3], "semantic": {"name": "nm", "arg_names": [], "import_names": [], "rhs_call_name": "str", "annotation": ""}, "snippet": " nm = str(Header(nm.encode(encoding), encoding))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98841:Try_L70_C16", "label": "try", "type": "try", "loc": [70, 73], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98841:For_L68_C12", "vector": [7, 4, 0.2407, 0.0135, 4, 0.16, 0.5, 0, 0, 1, 0, 0, 0, 0, 4], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " try:\n addr = addr.encode('ascii')\n except UnicodeEncodeError: # IDN\n addr = str(Header(addr.encode(encoding), encoding))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98841:Assign_L71_C20", "label": "addr = encode()", "type": "assigned_variable", "loc": [71, 71], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98841:Try_L70_C16", "vector": [14, 5, 0.2391, 0.0034, 5, 0.41, 0.0, 526, 3, 1, 0, 0, 623, 10, 1], "semantic": {"name": "addr", "arg_names": [], "import_names": [], "rhs_call_name": "encode", "annotation": ""}, "snippet": " addr = addr.encode('ascii')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98841:Assign_L73_C20", "label": "addr = str()", "type": "assigned_variable", "loc": [73, 73], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98841:Try_L70_C16", "vector": [14, 5, 0.2458, 0.0034, 5, 0.41, 0.0, 526, 3, 1, 0, 0, 52, 10, 3], "semantic": {"name": "addr", "arg_names": [], "import_names": [], "rhs_call_name": "str", "annotation": ""}, "snippet": " addr = str(Header(addr.encode(encoding), encoding))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98841:Expr_L74_C16", "label": "append()", "type": "expression", "loc": [74, 74], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98841:For_L68_C12", "vector": [8, 4, 0.2492, 0.0034, 4, 0.16, 1.0, 243, 3, 1, 0, 0, 0, 0, 2], "semantic": {"name": "append", "arg_names": [], "import_names": [], "rhs_call_name": "append", "annotation": ""}, "snippet": " result.append(formataddr((nm, addr)))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98841:Assign_L75_C12", "label": "val = join()", "type": "assigned_variable", "loc": [75, 75], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98841:If_L66_C8", "vector": [14, 3, 0.2525, 0.0034, 3, 0.93, 0.6667, 618, 3, 1, 0, 0, 933, 10, 1], "semantic": {"name": "val", "arg_names": [], "import_names": [], "rhs_call_name": "join", "annotation": ""}, "snippet": " val = ', '.join(result)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98841:Assign_L77_C12", "label": "val = Header()", "type": "assigned_variable", "loc": [77, 77], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98841:If_L66_C8", "vector": [14, 3, 0.2593, 0.0034, 3, 0.93, 1.0, 618, 3, 2, 0, 0, 976, 10, 2], "semantic": {"name": "val", "arg_names": [], "import_names": [], "rhs_call_name": "Header", "annotation": ""}, "snippet": " val = Header(val.encode(encoding), encoding)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98841:If_L79_C8", "label": "if", "type": "if", "loc": [79, 80], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98841:Try_L63_C4", "vector": [4, 2, 0.2677, 0.0067, 2, 0.8, 1.0, 0, 0, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if name.lower() == 'subject':\n val = Header(val)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98841:Assign_L80_C12", "label": "val = Header()", "type": "assigned_variable", "loc": [80, 80], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98841:If_L79_C8", "vector": [14, 3, 0.2694, 0.0034, 3, 0.17, 0.0, 618, 3, 1, 0, 0, 976, 10, 1], "semantic": {"name": "val", "arg_names": [], "import_names": [], "rhs_call_name": "Header", "annotation": ""}, "snippet": " val = Header(val)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98841:Return_L81_C4", "label": "return", "type": "return", "loc": [81, 81], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98841:FunctionDef_L57_C0", "vector": [13, 1, 0.2727, 0.0034, 1, 0.55, 1.0, 0, 0, 0, 0, 0, 0, 8, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return name, val"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98841:ClassDef_L83_C0", "label": "SafeMIMEText", "type": "class", "loc": [83, 91], "level": 0, "parent": null, "vector": [3, 0, 0.2929, 0.0303, 0, 0.66, 0.8571, 874, 0, 2, 0, 0, 776, 0, 3], "semantic": {"name": "SafeMIMEText", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class SafeMIMEText(MIMEText):\n \n def __init__(self, text, subtype, charset):\n self.encoding = charset\n MIMEText.__init__(self, text, subtype, charset)\n \n def __setitem__(self, name, val): \n name, val = forbid_multi_line_headers(name, val, self.encoding)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98841:FunctionDef_L85_C4", "label": "__init__", "type": "function", "loc": [85, 87], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98841:ClassDef_L83_C0", "vector": [2, 1, 0.2896, 0.0101, 1, 0.2, 0.0, 555, 0, 4, 0, 0, 0, 0, 1], "semantic": {"name": "__init__", "arg_names": ["self", "text", "subtype", "charset"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def __init__(self, text, subtype, charset):\n self.encoding = charset\n MIMEText.__init__(self, text, subtype, charset)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98841:Assign_L86_C8", "label": "self.encoding =", "type": "assigned_variable", "loc": [86, 86], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98841:FunctionDef_L85_C4", "vector": [14, 2, 0.2896, 0.0034, 2, 0.62, 0.0, 564, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "self.encoding", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.encoding = charset"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98841:Expr_L87_C8", "label": "__init__()", "type": "expression", "loc": [87, 87], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98841:FunctionDef_L85_C4", "vector": [8, 2, 0.2929, 0.0034, 2, 0.62, 1.0, 555, 3, 4, 0, 0, 0, 0, 1], "semantic": {"name": "__init__", "arg_names": [], "import_names": [], "rhs_call_name": "__init__", "annotation": ""}, "snippet": " MIMEText.__init__(self, text, subtype, charset)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98841:FunctionDef_L89_C4", "label": "__setitem__", "type": "function", "loc": [89, 91], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98841:ClassDef_L83_C0", "vector": [2, 1, 0.303, 0.0101, 1, 0.2, 1.0, 343, 0, 3, 0, 0, 0, 0, 2], "semantic": {"name": "__setitem__", "arg_names": ["self", "name", "val"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def __setitem__(self, name, val): \n name, val = forbid_multi_line_headers(name, val, self.encoding)\n MIMEText.__setitem__(self, name, val)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98841:Assign_L90_C8", "label": "name, val = forbid_multi_line_headers()", "type": "assigned_variable", "loc": [90, 90], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98841:FunctionDef_L89_C4", "vector": [14, 2, 0.303, 0.0034, 2, 0.28, 0.0, 762, 3, 3, 0, 0, 585, 10, 1], "semantic": {"name": "name, val", "arg_names": [], "import_names": [], "rhs_call_name": "forbid_multi_line_headers", "annotation": ""}, "snippet": " name, val = forbid_multi_line_headers(name, val, self.encoding)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98841:Expr_L91_C8", "label": "__setitem__()", "type": "expression", "loc": [91, 91], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98841:FunctionDef_L89_C4", "vector": [8, 2, 0.3064, 0.0034, 2, 0.28, 1.0, 343, 3, 3, 0, 0, 0, 0, 1], "semantic": {"name": "__setitem__", "arg_names": [], "import_names": [], "rhs_call_name": "__setitem__", "annotation": ""}, "snippet": " MIMEText.__setitem__(self, name, val)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98841:ClassDef_L93_C0", "label": "SafeMIMEMultipart", "type": "class", "loc": [93, 101], "level": 0, "parent": null, "vector": [3, 0, 0.3266, 0.0303, 0, 0.66, 0.9048, 366, 0, 2, 0, 0, 621, 0, 3], "semantic": {"name": "SafeMIMEMultipart", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class SafeMIMEMultipart(MIMEMultipart):\n \n def __init__(self, _subtype='mixed', boundary=None, _subparts=None, encoding=None, **_params):\n self.encoding = encoding\n MIMEMultipart.__init__(self, _subtype, boundary, _subparts, **_params)\n \n def __setitem__(self, name, val):\n name, val = forbid_multi_line_headers(name, val, self.encoding)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98841:FunctionDef_L95_C4", "label": "__init__", "type": "function", "loc": [95, 97], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98841:ClassDef_L93_C0", "vector": [2, 1, 0.3232, 0.0101, 1, 0.45, 0.0, 555, 0, 6, 0, 0, 0, 0, 1], "semantic": {"name": "__init__", "arg_names": ["self", "_subtype", "boundary", "_subparts", "encoding", "_params"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def __init__(self, _subtype='mixed', boundary=None, _subparts=None, encoding=None, **_params):\n self.encoding = encoding\n MIMEMultipart.__init__(self, _subtype, boundary, _subparts, **_params)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98841:Assign_L96_C8", "label": "self.encoding =", "type": "assigned_variable", "loc": [96, 96], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98841:FunctionDef_L95_C4", "vector": [14, 2, 0.3232, 0.0034, 2, 0.25, 0.0, 564, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "self.encoding", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.encoding = encoding"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98841:Expr_L97_C8", "label": "__init__()", "type": "expression", "loc": [97, 97], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98841:FunctionDef_L95_C4", "vector": [8, 2, 0.3266, 0.0034, 2, 0.25, 1.0, 555, 3, 5, 0, 0, 0, 0, 1], "semantic": {"name": "__init__", "arg_names": [], "import_names": [], "rhs_call_name": "__init__", "annotation": ""}, "snippet": " MIMEMultipart.__init__(self, _subtype, boundary, _subparts, **_params)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98841:FunctionDef_L99_C4", "label": "__setitem__", "type": "function", "loc": [99, 101], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98841:ClassDef_L93_C0", "vector": [2, 1, 0.3367, 0.0101, 1, 0.45, 1.0, 343, 0, 3, 0, 0, 0, 0, 2], "semantic": {"name": "__setitem__", "arg_names": ["self", "name", "val"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def __setitem__(self, name, val):\n name, val = forbid_multi_line_headers(name, val, self.encoding)\n MIMEMultipart.__setitem__(self, name, val)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98841:Assign_L100_C8", "label": "name, val = forbid_multi_line_headers()", "type": "assigned_variable", "loc": [100, 100], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98841:FunctionDef_L99_C4", "vector": [14, 2, 0.3367, 0.0034, 2, 0.66, 0.0, 762, 3, 3, 0, 0, 585, 10, 1], "semantic": {"name": "name, val", "arg_names": [], "import_names": [], "rhs_call_name": "forbid_multi_line_headers", "annotation": ""}, "snippet": " name, val = forbid_multi_line_headers(name, val, self.encoding)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98841:Expr_L101_C8", "label": "__setitem__()", "type": "expression", "loc": [101, 101], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98841:FunctionDef_L99_C4", "vector": [8, 2, 0.3401, 0.0034, 2, 0.66, 1.0, 343, 3, 3, 0, 0, 0, 0, 1], "semantic": {"name": "__setitem__", "arg_names": [], "import_names": [], "rhs_call_name": "__setitem__", "annotation": ""}, "snippet": " MIMEMultipart.__setitem__(self, name, val)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98841:ClassDef_L103_C0", "label": "EmailMessage", "type": "class", "loc": [103, 254], "level": 0, "parent": null, "vector": [3, 0, 0.601, 0.5118, 0, 0.66, 0.9524, 291, 0, 11, 0, 0, 186, 0, 44], "semantic": {"name": "EmailMessage", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class EmailMessage(object):\n \"\"\"\n A container for email information.\n \"\"\"\n content_subtype = 'plain'\n mixed_subtype = 'mixed'\n encoding = None # None => use settings default\n"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98841:Expr_L104_C4", "label": "expression", "type": "expression", "loc": [104, 106], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98841:ClassDef_L103_C0", "vector": [8, 1, 0.3535, 0.0101, 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 A container for email information.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98841:Assign_L107_C4", "label": "content_subtype =", "type": "assigned_variable", "loc": [107, 107], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98841:ClassDef_L103_C0", "vector": [14, 1, 0.3603, 0.0034, 1, 0.09, 0.0714, 650, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "content_subtype", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " content_subtype = 'plain'"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98841:Assign_L108_C4", "label": "mixed_subtype =", "type": "assigned_variable", "loc": [108, 108], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98841:ClassDef_L103_C0", "vector": [14, 1, 0.3636, 0.0034, 1, 0.09, 0.1429, 255, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "mixed_subtype", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " mixed_subtype = 'mixed'"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98841:Assign_L109_C4", "label": "encoding =", "type": "assigned_variable", "loc": [109, 109], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98841:ClassDef_L103_C0", "vector": [14, 1, 0.367, 0.0034, 1, 0.09, 0.2143, 325, 1, 0, 0, 0, 0, 9, 0], "semantic": {"name": "encoding", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " encoding = None # None => use settings default"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98841:FunctionDef_L111_C4", "label": "__init__", "type": "function", "loc": [111, 141], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98841:ClassDef_L103_C0", "vector": [2, 1, 0.4242, 0.1044, 1, 0.09, 0.2857, 555, 0, 10, 0, 0, 0, 0, 6], "semantic": {"name": "__init__", "arg_names": ["self", "subject", "body", "from_email", "to", "bcc", "connection", "attachments", "headers", "cc"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def __init__(self, subject='', body='', from_email=None, to=None, bcc=None,\n connection=None, attachments=None, headers=None, cc=None):\n \"\"\"\n Initialize a single email message (which can be sent to multiple\n recipients).\n\n All strings used to create the message can be unicode strings\n (or UTF-8 bytestrings). The SafeMIMEText class will handle any"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98841:Expr_L113_C8", "label": "expression", "type": "expression", "loc": [113, 120], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98841:FunctionDef_L111_C4", "vector": [8, 2, 0.3923, 0.0269, 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 Initialize a single email message (which can be sent to multiple\n recipients).\n\n All strings used to create the message can be unicode strings\n (or UTF-8 bytestrings). The SafeMIMEText class will handle any\n necessary encoding conversions.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98841:If_L121_C8", "label": "if", "type": "if", "loc": [121, 125], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98841:FunctionDef_L111_C4", "vector": [4, 2, 0.4141, 0.0168, 2, 0.4, 0.1111, 0, 2, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if to:\n assert not isinstance(to, basestring), '\"to\" argument must be a list or tuple'\n self.to = list(to)\n else:\n self.to = []"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98841:Assign_L123_C12", "label": "self.to = list()", "type": "assigned_variable", "loc": [123, 123], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98841:If_L121_C8", "vector": [14, 3, 0.4141, 0.0034, 3, 0.55, 0.0, 807, 3, 1, 0, 0, 430, 10, 1], "semantic": {"name": "self.to", "arg_names": [], "import_names": [], "rhs_call_name": "list", "annotation": ""}, "snippet": " self.to = list(to)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98841:Assign_L125_C12", "label": "self.to =", "type": "assigned_variable", "loc": [125, 125], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98841:If_L121_C8", "vector": [14, 3, 0.4209, 0.0034, 3, 0.55, 1.0, 807, 0, 0, 0, 0, 0, 5, 0], "semantic": {"name": "self.to", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.to = []"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98841:If_L126_C8", "label": "if", "type": "if", "loc": [126, 130], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98841:FunctionDef_L111_C4", "vector": [4, 2, 0.431, 0.0168, 2, 0.4, 0.2222, 0, 2, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if cc:\n assert not isinstance(cc, basestring), '\"cc\" argument must be a list or tuple'\n self.cc = list(cc)\n else:\n self.cc = []"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98841:Assign_L128_C12", "label": "self.cc = list()", "type": "assigned_variable", "loc": [128, 128], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98841:If_L126_C8", "vector": [14, 3, 0.431, 0.0034, 3, 0.81, 0.0, 927, 3, 1, 0, 0, 430, 10, 1], "semantic": {"name": "self.cc", "arg_names": [], "import_names": [], "rhs_call_name": "list", "annotation": ""}, "snippet": " self.cc = list(cc)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98841:Assign_L130_C12", "label": "self.cc =", "type": "assigned_variable", "loc": [130, 130], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98841:If_L126_C8", "vector": [14, 3, 0.4377, 0.0034, 3, 0.81, 1.0, 927, 0, 0, 0, 0, 0, 5, 0], "semantic": {"name": "self.cc", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.cc = []"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98841:If_L131_C8", "label": "if", "type": "if", "loc": [131, 135], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98841:FunctionDef_L111_C4", "vector": [4, 2, 0.4478, 0.0168, 2, 0.4, 0.3333, 0, 2, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if bcc:\n assert not isinstance(bcc, basestring), '\"bcc\" argument must be a list or tuple'\n self.bcc = list(bcc)\n else:\n self.bcc = []"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98841:Assign_L133_C12", "label": "self.bcc = list()", "type": "assigned_variable", "loc": [133, 133], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98841:If_L131_C8", "vector": [14, 3, 0.4478, 0.0034, 3, 0.81, 0.0, 0, 3, 1, 0, 0, 430, 10, 1], "semantic": {"name": "self.bcc", "arg_names": [], "import_names": [], "rhs_call_name": "list", "annotation": ""}, "snippet": " self.bcc = list(bcc)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98841:Assign_L135_C12", "label": "self.bcc =", "type": "assigned_variable", "loc": [135, 135], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98841:If_L131_C8", "vector": [14, 3, 0.4545, 0.0034, 3, 0.81, 1.0, 0, 0, 0, 0, 0, 0, 5, 0], "semantic": {"name": "self.bcc", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.bcc = []"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98841:Assign_L136_C8", "label": "self.from_email =", "type": "assigned_variable", "loc": [136, 136], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98841:FunctionDef_L111_C4", "vector": [14, 2, 0.4579, 0.0034, 2, 0.4, 0.4444, 7, 0, 0, 0, 0, 0, 0, 0], "semantic": {"name": "self.from_email", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.from_email = from_email or settings.DEFAULT_FROM_EMAIL"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98841:Assign_L137_C8", "label": "self.subject =", "type": "assigned_variable", "loc": [137, 137], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98841:FunctionDef_L111_C4", "vector": [14, 2, 0.4613, 0.0034, 2, 0.4, 0.5556, 52, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "self.subject", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.subject = subject"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98841:Assign_L138_C8", "label": "self.body =", "type": "assigned_variable", "loc": [138, 138], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98841:FunctionDef_L111_C4", "vector": [14, 2, 0.4646, 0.0034, 2, 0.4, 0.6667, 523, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "self.body", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.body = body"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98841:Assign_L139_C8", "label": "self.attachments =", "type": "assigned_variable", "loc": [139, 139], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98841:FunctionDef_L111_C4", "vector": [14, 2, 0.468, 0.0034, 2, 0.4, 0.7778, 99, 0, 0, 0, 0, 0, 0, 0], "semantic": {"name": "self.attachments", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.attachments = attachments or []"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98841:Assign_L140_C8", "label": "self.extra_headers =", "type": "assigned_variable", "loc": [140, 140], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98841:FunctionDef_L111_C4", "vector": [14, 2, 0.4714, 0.0034, 2, 0.4, 0.8889, 624, 0, 0, 0, 0, 0, 0, 0], "semantic": {"name": "self.extra_headers", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.extra_headers = headers or {}"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98841:Assign_L141_C8", "label": "self.connection =", "type": "assigned_variable", "loc": [141, 141], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98841:FunctionDef_L111_C4", "vector": [14, 2, 0.4747, 0.0034, 2, 0.4, 1.0, 685, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "self.connection", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.connection = connection"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98841:FunctionDef_L143_C4", "label": "get_connection", "type": "function", "loc": [143, 147], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98841:ClassDef_L103_C0", "vector": [2, 1, 0.4882, 0.0168, 1, 0.09, 0.3571, 954, 0, 2, 1, 0, 0, 0, 1], "semantic": {"name": "get_connection", "arg_names": ["self", "fail_silently"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def get_connection(self, fail_silently=False):\n from django.core.mail import get_connection\n if not self.connection:\n self.connection = get_connection(fail_silently=fail_silently)\n return self.connection"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98841:ImportFrom_L144_C8", "label": "from django.core.mail import get_connection", "type": "import", "loc": [144, 144], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98841:FunctionDef_L143_C4", "vector": [1, 2, 0.4848, 0.0034, 2, 0.43, 0.0, 537, 0, 1, 0, 0, 537, 0, 0], "semantic": {"name": "django.core.mail", "arg_names": [], "import_names": ["get_connection"], "rhs_call_name": "", "annotation": ""}, "snippet": " from django.core.mail import get_connection"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98841:If_L145_C8", "label": "if", "type": "if", "loc": [145, 146], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98841:FunctionDef_L143_C4", "vector": [4, 2, 0.4899, 0.0067, 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 not self.connection:\n self.connection = get_connection(fail_silently=fail_silently)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98841:Assign_L146_C12", "label": "self.connection = get_connection()", "type": "assigned_variable", "loc": [146, 146], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98841:If_L145_C8", "vector": [14, 3, 0.4916, 0.0034, 3, 0.39, 0.0, 685, 3, 1, 0, 0, 954, 10, 1], "semantic": {"name": "self.connection", "arg_names": [], "import_names": [], "rhs_call_name": "get_connection", "annotation": ""}, "snippet": " self.connection = get_connection(fail_silently=fail_silently)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98841:Return_L147_C8", "label": "return", "type": "return", "loc": [147, 147], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98841:FunctionDef_L143_C4", "vector": [13, 2, 0.4949, 0.0034, 2, 0.43, 1.0, 0, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return self.connection"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98841:FunctionDef_L149_C4", "label": "message", "type": "function", "loc": [149, 171], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98841:ClassDef_L103_C0", "vector": [2, 1, 0.5387, 0.0774, 1, 0.09, 0.4286, 635, 0, 1, 1, 0, 0, 0, 11], "semantic": {"name": "message", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def message(self):\n encoding = self.encoding or settings.DEFAULT_CHARSET\n msg = SafeMIMEText(smart_str(self.body, encoding),\n self.content_subtype, encoding)\n msg = self._create_message(msg)\n msg['Subject'] = self.subject\n msg['From'] = self.extra_headers.get('From', self.from_email)\n msg['To'] = ', '.join(self.to)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98841:Assign_L150_C8", "label": "encoding =", "type": "assigned_variable", "loc": [150, 150], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98841:FunctionDef_L149_C4", "vector": [14, 2, 0.5051, 0.0034, 2, 0.15, 0.0, 325, 0, 0, 0, 0, 0, 0, 0], "semantic": {"name": "encoding", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " encoding = self.encoding or settings.DEFAULT_CHARSET"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98841:Assign_L151_C8", "label": "msg = SafeMIMEText()", "type": "assigned_variable", "loc": [151, 152], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98841:FunctionDef_L149_C4", "vector": [14, 2, 0.5101, 0.0067, 2, 0.15, 0.0909, 712, 3, 3, 0, 0, 874, 10, 2], "semantic": {"name": "msg", "arg_names": [], "import_names": [], "rhs_call_name": "SafeMIMEText", "annotation": ""}, "snippet": " msg = SafeMIMEText(smart_str(self.body, encoding),\n self.content_subtype, encoding)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98841:Assign_L153_C8", "label": "msg = _create_message()", "type": "assigned_variable", "loc": [153, 153], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98841:FunctionDef_L149_C4", "vector": [14, 2, 0.5152, 0.0034, 2, 0.15, 0.1818, 712, 3, 1, 0, 0, 713, 10, 1], "semantic": {"name": "msg", "arg_names": [], "import_names": [], "rhs_call_name": "_create_message", "annotation": ""}, "snippet": " msg = self._create_message(msg)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98841:Assign_L154_C8", "label": "assign", "type": "assigned_variable", "loc": [154, 154], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98841:FunctionDef_L149_C4", "vector": [14, 2, 0.5185, 0.0034, 2, 0.15, 0.2727, 0, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " msg['Subject'] = self.subject"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98841:Assign_L155_C8", "label": " = get()", "type": "assigned_variable", "loc": [155, 155], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98841:FunctionDef_L149_C4", "vector": [14, 2, 0.5219, 0.0034, 2, 0.15, 0.3636, 0, 3, 2, 0, 0, 607, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "get", "annotation": ""}, "snippet": " msg['From'] = self.extra_headers.get('From', self.from_email)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98841:Assign_L156_C8", "label": " = join()", "type": "assigned_variable", "loc": [156, 156], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98841:FunctionDef_L149_C4", "vector": [14, 2, 0.5253, 0.0034, 2, 0.15, 0.4545, 0, 3, 1, 0, 0, 933, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "join", "annotation": ""}, "snippet": " msg['To'] = ', '.join(self.to)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98841:If_L157_C8", "label": "if", "type": "if", "loc": [157, 158], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98841:FunctionDef_L149_C4", "vector": [4, 2, 0.5303, 0.0067, 2, 0.15, 0.5455, 0, 7, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if self.cc:\n msg['Cc'] = ', '.join(self.cc)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98841:Assign_L158_C12", "label": " = join()", "type": "assigned_variable", "loc": [158, 158], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98841:If_L157_C8", "vector": [14, 3, 0.532, 0.0034, 3, 0.52, 0.0, 0, 3, 1, 0, 0, 933, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "join", "annotation": ""}, "snippet": " msg['Cc'] = ', '.join(self.cc)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98841:Assign_L162_C8", "label": "header_names =", "type": "assigned_variable", "loc": [162, 162], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98841:FunctionDef_L149_C4", "vector": [14, 2, 0.5455, 0.0034, 2, 0.15, 0.6364, 289, 5, 0, 0, 0, 0, 0, 1], "semantic": {"name": "header_names", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " header_names = [key.lower() for key in self.extra_headers]"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98841:If_L163_C8", "label": "if", "type": "if", "loc": [163, 164], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98841:FunctionDef_L149_C4", "vector": [4, 2, 0.5505, 0.0067, 2, 0.15, 0.7273, 0, 0, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if 'date' not in header_names:\n msg['Date'] = formatdate()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98841:Assign_L164_C12", "label": " = formatdate()", "type": "assigned_variable", "loc": [164, 164], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98841:If_L163_C8", "vector": [14, 3, 0.5522, 0.0034, 3, 0.83, 0.0, 0, 3, 0, 0, 0, 722, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "formatdate", "annotation": ""}, "snippet": " msg['Date'] = formatdate()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98841:If_L165_C8", "label": "if", "type": "if", "loc": [165, 166], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98841:FunctionDef_L149_C4", "vector": [4, 2, 0.5572, 0.0067, 2, 0.15, 0.8182, 0, 0, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if 'message-id' not in header_names:\n msg['Message-ID'] = make_msgid()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98841:Assign_L166_C12", "label": " = make_msgid()", "type": "assigned_variable", "loc": [166, 166], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98841:If_L165_C8", "vector": [14, 3, 0.5589, 0.0034, 3, 0.26, 0.0, 0, 3, 0, 0, 0, 980, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "make_msgid", "annotation": ""}, "snippet": " msg['Message-ID'] = make_msgid()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98841:For_L167_C8", "label": "for name, value", "type": "for", "loc": [167, 170], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98841:FunctionDef_L149_C4", "vector": [6, 2, 0.5673, 0.0135, 2, 0.15, 0.9091, 509, 3, 0, 0, 0, 0, 0, 2], "semantic": {"name": "name, value", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for name, value in self.extra_headers.items():\n if name.lower() == 'from': # From is already handled\n continue\n msg[name] = value"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98841:If_L168_C12", "label": "if", "type": "if", "loc": [168, 169], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98841:For_L167_C8", "vector": [4, 3, 0.5673, 0.0067, 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 name.lower() == 'from': # From is already handled\n continue"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98841:Assign_L170_C12", "label": "assign", "type": "assigned_variable", "loc": [170, 170], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98841:For_L167_C8", "vector": [14, 3, 0.5724, 0.0034, 3, 0.6, 1.0, 0, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " msg[name] = value"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98841:Return_L171_C8", "label": "return", "type": "return", "loc": [171, 171], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98841:FunctionDef_L149_C4", "vector": [13, 2, 0.5758, 0.0034, 2, 0.15, 1.0, 0, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return msg"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98841:FunctionDef_L173_C4", "label": "recipients", "type": "function", "loc": [173, 178], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98841:ClassDef_L103_C0", "vector": [2, 1, 0.5909, 0.0202, 1, 0.09, 0.5, 986, 0, 1, 1, 0, 0, 0, 0], "semantic": {"name": "recipients", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def recipients(self):\n \"\"\"\n Returns a list of all recipients of the email (includes direct\n addressees as well as Cc and Bcc entries).\n \"\"\"\n return self.to + self.cc + self.bcc"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98841:Expr_L174_C8", "label": "expression", "type": "expression", "loc": [174, 177], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98841:FunctionDef_L173_C4", "vector": [8, 2, 0.5909, 0.0135, 2, 0.68, 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 all recipients of the email (includes direct\n addressees as well as Cc and Bcc entries).\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98841:Return_L178_C8", "label": "return", "type": "return", "loc": [178, 178], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98841:FunctionDef_L173_C4", "vector": [13, 2, 0.5993, 0.0034, 2, 0.68, 1.0, 0, 4, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return self.to + self.cc + self.bcc"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98841:FunctionDef_L180_C4", "label": "send", "type": "function", "loc": [180, 186], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98841:ClassDef_L103_C0", "vector": [2, 1, 0.6162, 0.0236, 1, 0.09, 0.5714, 826, 0, 2, 1, 0, 0, 0, 3], "semantic": {"name": "send", "arg_names": ["self", "fail_silently"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def send(self, fail_silently=False):\n \"\"\"Sends the email message.\"\"\"\n if not self.recipients():\n # Don't bother creating the network connection if there's nobody to\n # send to.\n return 0\n return self.get_connection(fail_silently).send_messages([self])"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98841:Expr_L181_C8", "label": "expression", "type": "expression", "loc": [181, 181], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98841:FunctionDef_L180_C4", "vector": [8, 2, 0.6094, 0.0034, 2, 0.23, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"Sends the email message.\"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98841:If_L182_C8", "label": "if", "type": "if", "loc": [182, 185], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98841:FunctionDef_L180_C4", "vector": [4, 2, 0.6178, 0.0135, 2, 0.23, 0.5, 0, 0, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if not self.recipients():\n # Don't bother creating the network connection if there's nobody to\n # send to.\n return 0"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98841:Return_L185_C12", "label": "return", "type": "return", "loc": [185, 185], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98841:If_L182_C8", "vector": [13, 3, 0.6229, 0.0034, 3, 0.23, 0.0, 0, 1, 0, 0, 0, 0, 1, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return 0"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98841:Return_L186_C8", "label": "return", "type": "return", "loc": [186, 186], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98841:FunctionDef_L180_C4", "vector": [13, 2, 0.6263, 0.0034, 2, 0.23, 1.0, 0, 3, 0, 0, 0, 0, 10, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return self.get_connection(fail_silently).send_messages([self])"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98841:FunctionDef_L188_C4", "label": "attach", "type": "function", "loc": [188, 201], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98841:ClassDef_L103_C0", "vector": [2, 1, 0.6549, 0.0471, 1, 0.09, 0.6429, 522, 0, 4, 0, 0, 0, 0, 3], "semantic": {"name": "attach", "arg_names": ["self", "filename", "content", "mimetype"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def attach(self, filename=None, content=None, mimetype=None):\n \"\"\"\n Attaches a file with the given filename and content. The filename can\n be omitted and the mimetype is guessed, if not provided.\n\n If the first parameter is a MIMEBase subclass it is inserted directly\n into the resulting message attachments.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98841:Expr_L189_C8", "label": "expression", "type": "expression", "loc": [189, 195], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98841:FunctionDef_L188_C4", "vector": [8, 2, 0.6465, 0.0236, 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 Attaches a file with the given filename and content. The filename can\n be omitted and the mimetype is guessed, if not provided.\n\n If the first parameter is a MIMEBase subclass it is inserted directly\n into the resulting message attachments.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98841:If_L196_C8", "label": "if", "type": "if", "loc": [196, 201], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98841:FunctionDef_L188_C4", "vector": [4, 2, 0.6684, 0.0202, 2, 0.2, 1.0, 0, 3, 0, 0, 0, 0, 0, 3], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if isinstance(filename, MIMEBase):\n assert content == mimetype == None\n self.attachments.append(filename)\n else:\n assert content is not None\n self.attachments.append((filename, content, mimetype))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98841:Expr_L198_C12", "label": "append()", "type": "expression", "loc": [198, 198], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98841:If_L196_C8", "vector": [8, 3, 0.6667, 0.0034, 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": " self.attachments.append(filename)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98841:Expr_L201_C12", "label": "append()", "type": "expression", "loc": [201, 201], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98841:If_L196_C8", "vector": [8, 3, 0.6768, 0.0034, 3, 0.11, 1.0, 243, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "append", "arg_names": [], "import_names": [], "rhs_call_name": "append", "annotation": ""}, "snippet": " self.attachments.append((filename, content, mimetype))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98841:FunctionDef_L203_C4", "label": "attach_file", "type": "function", "loc": [203, 207], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98841:ClassDef_L103_C0", "vector": [2, 1, 0.6902, 0.0168, 1, 0.09, 0.7143, 191, 0, 3, 0, 0, 0, 0, 4], "semantic": {"name": "attach_file", "arg_names": ["self", "path", "mimetype"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def attach_file(self, path, mimetype=None):\n \"\"\"Attaches a file from the filesystem.\"\"\"\n filename = os.path.basename(path)\n content = open(path, 'rb').read()\n self.attach(filename, content, mimetype)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98841:Expr_L204_C8", "label": "expression", "type": "expression", "loc": [204, 204], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98841:FunctionDef_L203_C4", "vector": [8, 2, 0.6869, 0.0034, 2, 0.23, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"Attaches a file from the filesystem.\"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98841:Assign_L205_C8", "label": "filename = basename()", "type": "assigned_variable", "loc": [205, 205], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98841:FunctionDef_L203_C4", "vector": [14, 2, 0.6902, 0.0034, 2, 0.23, 0.3333, 275, 3, 1, 0, 0, 164, 10, 1], "semantic": {"name": "filename", "arg_names": [], "import_names": [], "rhs_call_name": "basename", "annotation": ""}, "snippet": " filename = os.path.basename(path)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98841:Assign_L206_C8", "label": "content = read()", "type": "assigned_variable", "loc": [206, 206], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98841:FunctionDef_L203_C4", "vector": [14, 2, 0.6936, 0.0034, 2, 0.23, 0.6667, 273, 3, 0, 0, 0, 453, 10, 2], "semantic": {"name": "content", "arg_names": [], "import_names": [], "rhs_call_name": "read", "annotation": ""}, "snippet": " content = open(path, 'rb').read()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98841:Expr_L207_C8", "label": "attach()", "type": "expression", "loc": [207, 207], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98841:FunctionDef_L203_C4", "vector": [8, 2, 0.697, 0.0034, 2, 0.23, 1.0, 522, 3, 3, 0, 0, 0, 0, 1], "semantic": {"name": "attach", "arg_names": [], "import_names": [], "rhs_call_name": "attach", "annotation": ""}, "snippet": " self.attach(filename, content, mimetype)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98841:FunctionDef_L209_C4", "label": "_create_message", "type": "function", "loc": [209, 210], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98841:ClassDef_L103_C0", "vector": [2, 1, 0.7054, 0.0067, 1, 0.09, 0.7857, 713, 0, 2, 1, 0, 0, 0, 1], "semantic": {"name": "_create_message", "arg_names": ["self", "msg"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def _create_message(self, msg):\n return self._create_attachments(msg)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98841:Return_L210_C8", "label": "return", "type": "return", "loc": [210, 210], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98841:FunctionDef_L209_C4", "vector": [13, 2, 0.7071, 0.0034, 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._create_attachments(msg)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98841:FunctionDef_L212_C4", "label": "_create_attachments", "type": "function", "loc": [212, 224], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98841:ClassDef_L103_C0", "vector": [2, 1, 0.734, 0.0438, 1, 0.09, 0.8571, 153, 0, 2, 1, 0, 0, 0, 6], "semantic": {"name": "_create_attachments", "arg_names": ["self", "msg"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def _create_attachments(self, msg):\n if self.attachments:\n encoding = self.encoding or settings.DEFAULT_CHARSET\n body_msg = msg\n msg = SafeMIMEMultipart(_subtype=self.mixed_subtype, encoding=encoding)\n if self.body:\n msg.attach(body_msg)\n for attachment in self.attachments:"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98841:If_L213_C8", "label": "if", "type": "if", "loc": [213, 223], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98841:FunctionDef_L212_C4", "vector": [4, 2, 0.734, 0.037, 2, 0.04, 0.0, 0, 7, 0, 0, 0, 0, 0, 6], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if self.attachments:\n encoding = self.encoding or settings.DEFAULT_CHARSET\n body_msg = msg\n msg = SafeMIMEMultipart(_subtype=self.mixed_subtype, encoding=encoding)\n if self.body:\n msg.attach(body_msg)\n for attachment in self.attachments:\n if isinstance(attachment, MIMEBase):"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98841:Assign_L214_C12", "label": "encoding =", "type": "assigned_variable", "loc": [214, 214], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98841:If_L213_C8", "vector": [14, 3, 0.7205, 0.0034, 3, 0.4, 0.0, 325, 0, 0, 0, 0, 0, 0, 0], "semantic": {"name": "encoding", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " encoding = self.encoding or settings.DEFAULT_CHARSET"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98841:Assign_L215_C12", "label": "body_msg =", "type": "assigned_variable", "loc": [215, 215], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98841:If_L213_C8", "vector": [14, 3, 0.7239, 0.0034, 3, 0.4, 0.25, 504, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "body_msg", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " body_msg = msg"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98841:Assign_L216_C12", "label": "msg = SafeMIMEMultipart()", "type": "assigned_variable", "loc": [216, 216], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98841:If_L213_C8", "vector": [14, 3, 0.7273, 0.0034, 3, 0.4, 0.5, 712, 3, 2, 0, 0, 366, 10, 1], "semantic": {"name": "msg", "arg_names": [], "import_names": [], "rhs_call_name": "SafeMIMEMultipart", "annotation": ""}, "snippet": " msg = SafeMIMEMultipart(_subtype=self.mixed_subtype, encoding=encoding)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98841:If_L217_C12", "label": "if", "type": "if", "loc": [217, 218], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98841:If_L213_C8", "vector": [4, 3, 0.7323, 0.0067, 3, 0.4, 0.75, 0, 7, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if self.body:\n msg.attach(body_msg)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98841:Expr_L218_C16", "label": "attach()", "type": "expression", "loc": [218, 218], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98841:If_L217_C12", "vector": [8, 4, 0.734, 0.0034, 4, 0.48, 0.0, 522, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "attach", "arg_names": [], "import_names": [], "rhs_call_name": "attach", "annotation": ""}, "snippet": " msg.attach(body_msg)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98841:For_L219_C12", "label": "for attachment", "type": "for", "loc": [219, 223], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98841:If_L213_C8", "vector": [6, 3, 0.7441, 0.0168, 3, 0.4, 1.0, 113, 7, 0, 0, 0, 0, 0, 4], "semantic": {"name": "attachment", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for attachment in self.attachments:\n if isinstance(attachment, MIMEBase):\n msg.attach(attachment)\n else:\n msg.attach(self._create_attachment(*attachment))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98841:If_L220_C16", "label": "if", "type": "if", "loc": [220, 223], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98841:For_L219_C12", "vector": [4, 4, 0.7458, 0.0135, 4, 0.42, 0.0, 0, 3, 0, 0, 0, 0, 0, 4], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if isinstance(attachment, MIMEBase):\n msg.attach(attachment)\n else:\n msg.attach(self._create_attachment(*attachment))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98841:Expr_L221_C20", "label": "attach()", "type": "expression", "loc": [221, 221], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98841:If_L220_C16", "vector": [8, 5, 0.7441, 0.0034, 5, 0.85, 0.0, 522, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "attach", "arg_names": [], "import_names": [], "rhs_call_name": "attach", "annotation": ""}, "snippet": " msg.attach(attachment)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98841:Expr_L223_C20", "label": "attach()", "type": "expression", "loc": [223, 223], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98841:If_L220_C16", "vector": [8, 5, 0.7508, 0.0034, 5, 0.85, 1.0, 522, 3, 1, 0, 0, 0, 0, 2], "semantic": {"name": "attach", "arg_names": [], "import_names": [], "rhs_call_name": "attach", "annotation": ""}, "snippet": " msg.attach(self._create_attachment(*attachment))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98841:Return_L224_C8", "label": "return", "type": "return", "loc": [224, 224], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98841:FunctionDef_L212_C4", "vector": [13, 2, 0.7542, 0.0034, 2, 0.04, 1.0, 0, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return msg"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98841:FunctionDef_L226_C4", "label": "_create_mime_attachment", "type": "function", "loc": [226, 239], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98841:ClassDef_L103_C0", "vector": [2, 1, 0.7828, 0.0471, 1, 0.09, 0.9286, 739, 0, 3, 1, 0, 0, 0, 6], "semantic": {"name": "_create_mime_attachment", "arg_names": ["self", "content", "mimetype"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def _create_mime_attachment(self, content, mimetype):\n \"\"\"\n Converts the content, mimetype pair into a MIME attachment object.\n \"\"\"\n basetype, subtype = mimetype.split('/', 1)\n if basetype == 'text':\n encoding = self.encoding or settings.DEFAULT_CHARSET\n attachment = SafeMIMEText(smart_str(content, encoding), subtype, encoding)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98841:Expr_L227_C8", "label": "expression", "type": "expression", "loc": [227, 229], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98841:FunctionDef_L226_C4", "vector": [8, 2, 0.7677, 0.0101, 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 Converts the content, mimetype pair into a MIME attachment object.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98841:Assign_L230_C8", "label": "basetype, subtype = split()", "type": "assigned_variable", "loc": [230, 230], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98841:FunctionDef_L226_C4", "vector": [14, 2, 0.7744, 0.0034, 2, 0.45, 0.3333, 596, 3, 2, 0, 0, 908, 10, 1], "semantic": {"name": "basetype, subtype", "arg_names": [], "import_names": [], "rhs_call_name": "split", "annotation": ""}, "snippet": " basetype, subtype = mimetype.split('/', 1)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98841:If_L231_C8", "label": "if", "type": "if", "loc": [231, 238], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98841:FunctionDef_L226_C4", "vector": [4, 2, 0.7896, 0.0269, 2, 0.45, 0.6667, 0, 0, 0, 0, 0, 0, 0, 5], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if basetype == 'text':\n encoding = self.encoding or settings.DEFAULT_CHARSET\n attachment = SafeMIMEText(smart_str(content, encoding), subtype, encoding)\n else:\n # Encode non-text attachments with base64.\n attachment = MIMEBase(basetype, subtype)\n attachment.set_payload(content)\n Encoders.encode_base64(attachment)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98841:Assign_L232_C12", "label": "encoding =", "type": "assigned_variable", "loc": [232, 232], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98841:If_L231_C8", "vector": [14, 3, 0.7811, 0.0034, 3, 0.82, 0.0, 325, 0, 0, 0, 0, 0, 0, 0], "semantic": {"name": "encoding", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " encoding = self.encoding or settings.DEFAULT_CHARSET"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98841:Assign_L233_C12", "label": "attachment = SafeMIMEText()", "type": "assigned_variable", "loc": [233, 233], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98841:If_L231_C8", "vector": [14, 3, 0.7845, 0.0034, 3, 0.82, 0.25, 113, 3, 3, 0, 0, 874, 10, 2], "semantic": {"name": "attachment", "arg_names": [], "import_names": [], "rhs_call_name": "SafeMIMEText", "annotation": ""}, "snippet": " attachment = SafeMIMEText(smart_str(content, encoding), subtype, encoding)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98841:Assign_L236_C12", "label": "attachment = MIMEBase()", "type": "assigned_variable", "loc": [236, 236], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98841:If_L231_C8", "vector": [14, 3, 0.7946, 0.0034, 3, 0.82, 0.5, 113, 3, 2, 0, 0, 913, 10, 1], "semantic": {"name": "attachment", "arg_names": [], "import_names": [], "rhs_call_name": "MIMEBase", "annotation": ""}, "snippet": " attachment = MIMEBase(basetype, subtype)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98841:Expr_L237_C12", "label": "set_payload()", "type": "expression", "loc": [237, 237], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98841:If_L231_C8", "vector": [8, 3, 0.798, 0.0034, 3, 0.82, 0.75, 159, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "set_payload", "arg_names": [], "import_names": [], "rhs_call_name": "set_payload", "annotation": ""}, "snippet": " attachment.set_payload(content)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98841:Expr_L238_C12", "label": "encode_base64()", "type": "expression", "loc": [238, 238], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98841:If_L231_C8", "vector": [8, 3, 0.8013, 0.0034, 3, 0.82, 1.0, 661, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "encode_base64", "arg_names": [], "import_names": [], "rhs_call_name": "encode_base64", "annotation": ""}, "snippet": " Encoders.encode_base64(attachment)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98841:Return_L239_C8", "label": "return", "type": "return", "loc": [239, 239], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98841:FunctionDef_L226_C4", "vector": [13, 2, 0.8047, 0.0034, 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 attachment"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98841:FunctionDef_L241_C4", "label": "_create_attachment", "type": "function", "loc": [241, 254], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98841:ClassDef_L103_C0", "vector": [2, 1, 0.8333, 0.0471, 1, 0.09, 1.0, 946, 0, 4, 1, 0, 0, 0, 3], "semantic": {"name": "_create_attachment", "arg_names": ["self", "filename", "content", "mimetype"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def _create_attachment(self, filename, content, mimetype=None):\n \"\"\"\n Converts the filename, content, mimetype triple into a MIME attachment\n object.\n \"\"\"\n if mimetype is None:\n mimetype, _ = mimetypes.guess_type(filename)\n if mimetype is None:"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98841:Expr_L242_C8", "label": "expression", "type": "expression", "loc": [242, 245], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98841:FunctionDef_L241_C4", "vector": [8, 2, 0.8199, 0.0135, 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 Converts the filename, content, mimetype triple into a MIME attachment\n object.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98841:If_L246_C8", "label": "if", "type": "if", "loc": [246, 249], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98841:FunctionDef_L241_C4", "vector": [4, 2, 0.8333, 0.0135, 2, 0.77, 0.25, 0, 0, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if mimetype is None:\n mimetype, _ = mimetypes.guess_type(filename)\n if mimetype is None:\n mimetype = DEFAULT_ATTACHMENT_MIME_TYPE"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98841:Assign_L247_C12", "label": "mimetype, _ = guess_type()", "type": "assigned_variable", "loc": [247, 247], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98841:If_L246_C8", "vector": [14, 3, 0.8316, 0.0034, 3, 0.29, 0.0, 103, 3, 1, 0, 0, 213, 10, 1], "semantic": {"name": "mimetype, _", "arg_names": [], "import_names": [], "rhs_call_name": "guess_type", "annotation": ""}, "snippet": " mimetype, _ = mimetypes.guess_type(filename)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98841:If_L248_C12", "label": "if", "type": "if", "loc": [248, 249], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98841:If_L246_C8", "vector": [4, 3, 0.8367, 0.0067, 3, 0.29, 1.0, 0, 0, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if mimetype is None:\n mimetype = DEFAULT_ATTACHMENT_MIME_TYPE"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98841:Assign_L249_C16", "label": "mimetype =", "type": "assigned_variable", "loc": [249, 249], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98841:If_L248_C12", "vector": [14, 4, 0.8384, 0.0034, 4, 0.81, 0.0, 290, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "mimetype", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " mimetype = DEFAULT_ATTACHMENT_MIME_TYPE"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98841:Assign_L250_C8", "label": "attachment = _create_mime_attachment()", "type": "assigned_variable", "loc": [250, 250], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98841:FunctionDef_L241_C4", "vector": [14, 2, 0.8418, 0.0034, 2, 0.77, 0.5, 113, 3, 2, 0, 0, 739, 10, 1], "semantic": {"name": "attachment", "arg_names": [], "import_names": [], "rhs_call_name": "_create_mime_attachment", "annotation": ""}, "snippet": " attachment = self._create_mime_attachment(content, mimetype)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98841:If_L251_C8", "label": "if", "type": "if", "loc": [251, 253], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98841:FunctionDef_L241_C4", "vector": [4, 2, 0.8485, 0.0101, 2, 0.77, 0.75, 0, 2, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if filename:\n attachment.add_header('Content-Disposition', 'attachment',\n filename=filename)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98841:Expr_L252_C12", "label": "add_header()", "type": "expression", "loc": [252, 253], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98841:If_L251_C8", "vector": [8, 3, 0.8502, 0.0067, 3, 0.26, 0.0, 643, 3, 3, 0, 0, 0, 0, 1], "semantic": {"name": "add_header", "arg_names": [], "import_names": [], "rhs_call_name": "add_header", "annotation": ""}, "snippet": " attachment.add_header('Content-Disposition', 'attachment',\n filename=filename)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98841:Return_L254_C8", "label": "return", "type": "return", "loc": [254, 254], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98841:FunctionDef_L241_C4", "vector": [13, 2, 0.8552, 0.0034, 2, 0.77, 1.0, 0, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return attachment"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98841:ClassDef_L257_C0", "label": "EmailMultiAlternatives", "type": "class", "loc": [257, 297], "level": 0, "parent": null, "vector": [3, 0, 0.9327, 0.138, 0, 0.66, 1.0, 9, 0, 4, 0, 0, 291, 0, 9], "semantic": {"name": "EmailMultiAlternatives", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class EmailMultiAlternatives(EmailMessage):\n \"\"\"\n A version of EmailMessage that makes it easy to send multipart/alternative\n messages. For example, including text and HTML versions of the text is\n made easier.\n \"\"\"\n alternative_subtype = 'alternative'\n"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98841:Expr_L258_C4", "label": "expression", "type": "expression", "loc": [258, 262], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98841:ClassDef_L257_C0", "vector": [8, 1, 0.8754, 0.0168, 1, 0.58, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"\n A version of EmailMessage that makes it easy to send multipart/alternative\n messages. For example, including text and HTML versions of the text is\n made easier.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98841:Assign_L263_C4", "label": "alternative_subtype =", "type": "assigned_variable", "loc": [263, 263], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98841:ClassDef_L257_C0", "vector": [14, 1, 0.8855, 0.0034, 1, 0.58, 0.2, 127, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "alternative_subtype", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " alternative_subtype = 'alternative'"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98841:FunctionDef_L265_C4", "label": "__init__", "type": "function", "loc": [265, 277], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98841:ClassDef_L257_C0", "vector": [2, 1, 0.9125, 0.0438, 1, 0.58, 0.4, 555, 0, 11, 0, 0, 0, 0, 2], "semantic": {"name": "__init__", "arg_names": ["self", "subject", "body", "from_email", "to", "bcc", "connection", "attachments", "headers", "alternatives", "cc"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def __init__(self, subject='', body='', from_email=None, to=None, bcc=None,\n connection=None, attachments=None, headers=None, alternatives=None,\n cc=None):\n \"\"\"\n Initialize a single email message (which can be sent to multiple\n recipients).\n\n All strings used to create the message can be unicode strings (or UTF-8"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98841:Expr_L268_C8", "label": "expression", "type": "expression", "loc": [268, 275], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98841:FunctionDef_L265_C4", "vector": [8, 2, 0.9141, 0.0269, 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 Initialize a single email message (which can be sent to multiple\n recipients).\n\n All strings used to create the message can be unicode strings (or UTF-8\n bytestrings). The SafeMIMEText class will handle any necessary encoding\n conversions.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98841:Expr_L276_C8", "label": "__init__()", "type": "expression", "loc": [276, 276], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98841:FunctionDef_L265_C4", "vector": [8, 2, 0.9293, 0.0034, 2, 0.41, 0.5, 555, 3, 9, 0, 0, 0, 0, 2], "semantic": {"name": "__init__", "arg_names": [], "import_names": [], "rhs_call_name": "__init__", "annotation": ""}, "snippet": " super(EmailMultiAlternatives, self).__init__(subject, body, from_email, to, bcc, connection, attachments, headers, cc)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98841:Assign_L277_C8", "label": "self.alternatives =", "type": "assigned_variable", "loc": [277, 277], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98841:FunctionDef_L265_C4", "vector": [14, 2, 0.9327, 0.0034, 2, 0.41, 1.0, 961, 0, 0, 0, 0, 0, 0, 0], "semantic": {"name": "self.alternatives", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.alternatives=alternatives or []"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98841:FunctionDef_L279_C4", "label": "attach_alternative", "type": "function", "loc": [279, 283], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98841:ClassDef_L257_C0", "vector": [2, 1, 0.9461, 0.0168, 1, 0.58, 0.6, 268, 0, 3, 0, 0, 0, 0, 1], "semantic": {"name": "attach_alternative", "arg_names": ["self", "content", "mimetype"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def attach_alternative(self, content, mimetype):\n \"\"\"Attach an alternative content representation.\"\"\"\n assert content is not None\n assert mimetype is not None\n self.alternatives.append((content, mimetype))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98841:Expr_L280_C8", "label": "expression", "type": "expression", "loc": [280, 280], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98841:FunctionDef_L279_C4", "vector": [8, 2, 0.9428, 0.0034, 2, 0.57, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"Attach an alternative content representation.\"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98841:Expr_L283_C8", "label": "append()", "type": "expression", "loc": [283, 283], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98841:FunctionDef_L279_C4", "vector": [8, 2, 0.9529, 0.0034, 2, 0.57, 1.0, 243, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "append", "arg_names": [], "import_names": [], "rhs_call_name": "append", "annotation": ""}, "snippet": " self.alternatives.append((content, mimetype))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98841:FunctionDef_L285_C4", "label": "_create_message", "type": "function", "loc": [285, 286], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98841:ClassDef_L257_C0", "vector": [2, 1, 0.9613, 0.0067, 1, 0.58, 0.8, 713, 0, 2, 1, 0, 0, 0, 2], "semantic": {"name": "_create_message", "arg_names": ["self", "msg"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def _create_message(self, msg):\n return self._create_attachments(self._create_alternatives(msg))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98841:Return_L286_C8", "label": "return", "type": "return", "loc": [286, 286], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98841:FunctionDef_L285_C4", "vector": [13, 2, 0.963, 0.0034, 2, 0.08, 0.0, 0, 3, 0, 0, 0, 0, 10, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return self._create_attachments(self._create_alternatives(msg))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98841:FunctionDef_L288_C4", "label": "_create_alternatives", "type": "function", "loc": [288, 297], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98841:ClassDef_L257_C0", "vector": [2, 1, 0.9848, 0.0337, 1, 0.58, 1.0, 985, 0, 2, 1, 0, 0, 0, 4], "semantic": {"name": "_create_alternatives", "arg_names": ["self", "msg"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def _create_alternatives(self, msg):\n encoding = self.encoding or settings.DEFAULT_CHARSET\n if self.alternatives:\n body_msg = msg\n msg = SafeMIMEMultipart(_subtype=self.alternative_subtype, encoding=encoding)\n if self.body:\n msg.attach(body_msg)\n for alternative in self.alternatives:"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98841:Assign_L289_C8", "label": "encoding =", "type": "assigned_variable", "loc": [289, 289], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98841:FunctionDef_L288_C4", "vector": [14, 2, 0.9731, 0.0034, 2, 0.77, 0.0, 325, 0, 0, 0, 0, 0, 0, 0], "semantic": {"name": "encoding", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " encoding = self.encoding or settings.DEFAULT_CHARSET"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98841:If_L290_C8", "label": "if", "type": "if", "loc": [290, 296], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98841:FunctionDef_L288_C4", "vector": [4, 2, 0.9865, 0.0236, 2, 0.77, 0.5, 0, 7, 0, 0, 0, 0, 0, 4], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if self.alternatives:\n body_msg = msg\n msg = SafeMIMEMultipart(_subtype=self.alternative_subtype, encoding=encoding)\n if self.body:\n msg.attach(body_msg)\n for alternative in self.alternatives:\n msg.attach(self._create_mime_attachment(*alternative))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98841:Assign_L291_C12", "label": "body_msg =", "type": "assigned_variable", "loc": [291, 291], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98841:If_L290_C8", "vector": [14, 3, 0.9798, 0.0034, 3, 0.37, 0.0, 504, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "body_msg", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " body_msg = msg"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98841:Assign_L292_C12", "label": "msg = SafeMIMEMultipart()", "type": "assigned_variable", "loc": [292, 292], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98841:If_L290_C8", "vector": [14, 3, 0.9832, 0.0034, 3, 0.37, 0.3333, 712, 3, 2, 0, 0, 366, 10, 1], "semantic": {"name": "msg", "arg_names": [], "import_names": [], "rhs_call_name": "SafeMIMEMultipart", "annotation": ""}, "snippet": " msg = SafeMIMEMultipart(_subtype=self.alternative_subtype, encoding=encoding)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98841:If_L293_C12", "label": "if", "type": "if", "loc": [293, 294], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98841:If_L290_C8", "vector": [4, 3, 0.9882, 0.0067, 3, 0.37, 0.6667, 0, 7, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if self.body:\n msg.attach(body_msg)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98841:Expr_L294_C16", "label": "attach()", "type": "expression", "loc": [294, 294], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98841:If_L293_C12", "vector": [8, 4, 0.9899, 0.0034, 4, 0.21, 0.0, 522, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "attach", "arg_names": [], "import_names": [], "rhs_call_name": "attach", "annotation": ""}, "snippet": " msg.attach(body_msg)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98841:For_L295_C12", "label": "for alternative", "type": "for", "loc": [295, 296], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98841:If_L290_C8", "vector": [6, 3, 0.9949, 0.0067, 3, 0.37, 1.0, 579, 7, 0, 0, 0, 0, 0, 2], "semantic": {"name": "alternative", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for alternative in self.alternatives:\n msg.attach(self._create_mime_attachment(*alternative))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98841:Expr_L296_C16", "label": "attach()", "type": "expression", "loc": [296, 296], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98841:For_L295_C12", "vector": [8, 4, 0.9966, 0.0034, 4, 0.74, 0.0, 522, 3, 1, 0, 0, 0, 0, 2], "semantic": {"name": "attach", "arg_names": [], "import_names": [], "rhs_call_name": "attach", "annotation": ""}, "snippet": " msg.attach(self._create_mime_attachment(*alternative))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98841:Return_L297_C8", "label": "return", "type": "return", "loc": [297, 297], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98841:FunctionDef_L288_C4", "vector": [13, 2, 1.0, 0.0034, 2, 0.77, 1.0, 0, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return msg"}]
[{"f": "ajibawa-2023/Python-Code-Large/train/row_98841:FunctionDef_L32_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98841:Expr_L33_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98841:FunctionDef_L32_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98841:Assign_L40_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98841:FunctionDef_L32_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98841:Assign_L41_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98841:FunctionDef_L32_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98841:Try_L42_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98841:Try_L42_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98841:Assign_L43_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98841:Try_L42_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98841:Assign_L46_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98841:FunctionDef_L32_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98841:Assign_L47_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98841:FunctionDef_L32_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98841:If_L48_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98841:If_L48_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98841:Assign_L49_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98841:If_L48_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98841:Assign_L51_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98841:FunctionDef_L32_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98841:Assign_L52_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98841:FunctionDef_L32_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98841:Assign_L53_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98841:FunctionDef_L32_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98841:Return_L54_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98841:FunctionDef_L57_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98841:Expr_L58_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98841:FunctionDef_L57_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98841:Assign_L59_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98841:FunctionDef_L57_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98841:Assign_L60_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98841:FunctionDef_L57_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98841:If_L61_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98841:FunctionDef_L57_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98841:Try_L63_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98841:Try_L63_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98841:Assign_L64_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98841:Try_L63_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98841:If_L66_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98841:If_L66_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98841:Assign_L67_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98841:If_L66_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98841:For_L68_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98841:For_L68_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98841:Assign_L69_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98841:For_L68_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98841:Try_L70_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98841:Try_L70_C16", "t": "ajibawa-2023/Python-Code-Large/train/row_98841:Assign_L71_C20"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98841:Try_L70_C16", "t": "ajibawa-2023/Python-Code-Large/train/row_98841:Assign_L73_C20"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98841:For_L68_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98841:Expr_L74_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98841:If_L66_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98841:Assign_L75_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98841:If_L66_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98841:Assign_L77_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98841:Try_L63_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98841:If_L79_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98841:If_L79_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98841:Assign_L80_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98841:FunctionDef_L57_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98841:Return_L81_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98841:ClassDef_L83_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98841:FunctionDef_L85_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98841:FunctionDef_L85_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98841:Assign_L86_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98841:FunctionDef_L85_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98841:Expr_L87_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98841:ClassDef_L83_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98841:FunctionDef_L89_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98841:FunctionDef_L89_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98841:Assign_L90_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98841:FunctionDef_L89_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98841:Expr_L91_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98841:ClassDef_L93_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98841:FunctionDef_L95_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98841:FunctionDef_L95_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98841:Assign_L96_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98841:FunctionDef_L95_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98841:Expr_L97_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98841:ClassDef_L93_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98841:FunctionDef_L99_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98841:FunctionDef_L99_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98841:Assign_L100_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98841:FunctionDef_L99_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98841:Expr_L101_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98841:ClassDef_L103_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98841:Expr_L104_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98841:ClassDef_L103_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98841:Assign_L107_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98841:ClassDef_L103_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98841:Assign_L108_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98841:ClassDef_L103_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98841:Assign_L109_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98841:ClassDef_L103_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98841:FunctionDef_L111_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98841:FunctionDef_L111_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98841:Expr_L113_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98841:FunctionDef_L111_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98841:If_L121_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98841:If_L121_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98841:Assign_L123_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98841:If_L121_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98841:Assign_L125_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98841:FunctionDef_L111_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98841:If_L126_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98841:If_L126_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98841:Assign_L128_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98841:If_L126_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98841:Assign_L130_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98841:FunctionDef_L111_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98841:If_L131_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98841:If_L131_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98841:Assign_L133_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98841:If_L131_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98841:Assign_L135_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98841:FunctionDef_L111_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98841:Assign_L136_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98841:FunctionDef_L111_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98841:Assign_L137_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98841:FunctionDef_L111_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98841:Assign_L138_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98841:FunctionDef_L111_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98841:Assign_L139_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98841:FunctionDef_L111_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98841:Assign_L140_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98841:FunctionDef_L111_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98841:Assign_L141_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98841:ClassDef_L103_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98841:FunctionDef_L143_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98841:FunctionDef_L143_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98841:ImportFrom_L144_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98841:FunctionDef_L143_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98841:If_L145_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98841:If_L145_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98841:Assign_L146_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98841:FunctionDef_L143_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98841:Return_L147_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98841:ClassDef_L103_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98841:FunctionDef_L149_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98841:FunctionDef_L149_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98841:Assign_L150_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98841:FunctionDef_L149_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98841:Assign_L151_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98841:FunctionDef_L149_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98841:Assign_L153_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98841:FunctionDef_L149_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98841:Assign_L154_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98841:FunctionDef_L149_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98841:Assign_L155_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98841:FunctionDef_L149_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98841:Assign_L156_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98841:FunctionDef_L149_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98841:If_L157_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98841:If_L157_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98841:Assign_L158_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98841:FunctionDef_L149_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98841:Assign_L162_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98841:FunctionDef_L149_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98841:If_L163_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98841:If_L163_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98841:Assign_L164_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98841:FunctionDef_L149_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98841:If_L165_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98841:If_L165_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98841:Assign_L166_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98841:FunctionDef_L149_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98841:For_L167_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98841:For_L167_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98841:If_L168_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98841:For_L167_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98841:Assign_L170_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98841:FunctionDef_L149_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98841:Return_L171_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98841:ClassDef_L103_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98841:FunctionDef_L173_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98841:FunctionDef_L173_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98841:Expr_L174_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98841:FunctionDef_L173_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98841:Return_L178_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98841:ClassDef_L103_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98841:FunctionDef_L180_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98841:FunctionDef_L180_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98841:Expr_L181_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98841:FunctionDef_L180_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98841:If_L182_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98841:If_L182_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98841:Return_L185_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98841:FunctionDef_L180_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98841:Return_L186_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98841:ClassDef_L103_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98841:FunctionDef_L188_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98841:FunctionDef_L188_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98841:Expr_L189_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98841:FunctionDef_L188_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98841:If_L196_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98841:If_L196_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98841:Expr_L198_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98841:If_L196_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98841:Expr_L201_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98841:ClassDef_L103_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98841:FunctionDef_L203_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98841:FunctionDef_L203_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98841:Expr_L204_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98841:FunctionDef_L203_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98841:Assign_L205_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98841:FunctionDef_L203_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98841:Assign_L206_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98841:FunctionDef_L203_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98841:Expr_L207_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98841:ClassDef_L103_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98841:FunctionDef_L209_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98841:FunctionDef_L209_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98841:Return_L210_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98841:ClassDef_L103_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98841:FunctionDef_L212_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98841:FunctionDef_L212_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98841:If_L213_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98841:If_L213_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98841:Assign_L214_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98841:If_L213_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98841:Assign_L215_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98841:If_L213_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98841:Assign_L216_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98841:If_L213_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98841:If_L217_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98841:If_L217_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98841:Expr_L218_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98841:If_L213_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98841:For_L219_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98841:For_L219_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98841:If_L220_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98841:If_L220_C16", "t": "ajibawa-2023/Python-Code-Large/train/row_98841:Expr_L221_C20"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98841:If_L220_C16", "t": "ajibawa-2023/Python-Code-Large/train/row_98841:Expr_L223_C20"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98841:FunctionDef_L212_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98841:Return_L224_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98841:ClassDef_L103_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98841:FunctionDef_L226_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98841:FunctionDef_L226_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98841:Expr_L227_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98841:FunctionDef_L226_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98841:Assign_L230_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98841:FunctionDef_L226_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98841:If_L231_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98841:If_L231_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98841:Assign_L232_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98841:If_L231_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98841:Assign_L233_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98841:If_L231_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98841:Assign_L236_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98841:If_L231_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98841:Expr_L237_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98841:If_L231_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98841:Expr_L238_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98841:FunctionDef_L226_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98841:Return_L239_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98841:ClassDef_L103_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98841:FunctionDef_L241_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98841:FunctionDef_L241_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98841:Expr_L242_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98841:FunctionDef_L241_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98841:If_L246_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98841:If_L246_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98841:Assign_L247_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98841:If_L246_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98841:If_L248_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98841:If_L248_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98841:Assign_L249_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98841:FunctionDef_L241_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98841:Assign_L250_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98841:FunctionDef_L241_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98841:If_L251_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98841:If_L251_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98841:Expr_L252_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98841:FunctionDef_L241_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98841:Return_L254_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98841:ClassDef_L257_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98841:Expr_L258_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98841:ClassDef_L257_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98841:Assign_L263_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98841:ClassDef_L257_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98841:FunctionDef_L265_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98841:FunctionDef_L265_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98841:Expr_L268_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98841:FunctionDef_L265_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98841:Expr_L276_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98841:FunctionDef_L265_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98841:Assign_L277_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98841:ClassDef_L257_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98841:FunctionDef_L279_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98841:FunctionDef_L279_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98841:Expr_L280_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98841:FunctionDef_L279_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98841:Expr_L283_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98841:ClassDef_L257_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98841:FunctionDef_L285_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98841:FunctionDef_L285_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98841:Return_L286_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98841:ClassDef_L257_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98841:FunctionDef_L288_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98841:FunctionDef_L288_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98841:Assign_L289_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98841:FunctionDef_L288_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98841:If_L290_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98841:If_L290_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98841:Assign_L291_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98841:If_L290_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98841:Assign_L292_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98841:If_L290_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98841:If_L293_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98841:If_L293_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98841:Expr_L294_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98841:If_L290_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98841:For_L295_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98841:For_L295_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98841:Expr_L296_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98841:FunctionDef_L288_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98841:Return_L297_C8"}]
""" Email message and email sending related helper functions. """ import socket # Cache the hostname, but do it lazily: socket.getfqdn() can take a couple of # seconds, which slows down the restart of the server. class CachedDnsName(object): def __str__(self): return self.get_fqdn() def get_fqdn(self): if not hasattr(self, '_fqdn'): self._fqdn = socket.getfqdn() return self._fqdn DNS_NAME = CachedDnsName()
ajibawa-2023/Python-Code-Large/train/row_98842
10
19
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_98842:Expr_L1_C0", "label": "expression", "type": "expression", "loc": [1, 3], "level": 0, "parent": null, "vector": [8, 0, 0.1053, 0.1579, 0, 0.66, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "\"\"\"\nEmail message and email sending related helper functions.\n\"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98842:Import_L5_C0", "label": "socket import socket", "type": "import", "loc": [5, 5], "level": 0, "parent": null, "vector": [1, 0, 0.2632, 0.0526, 0, 0.66, 0.3333, 687, 0, 1, 0, 0, 687, 0, 0], "semantic": {"name": "socket", "arg_names": [], "import_names": ["socket"], "rhs_call_name": "", "annotation": ""}, "snippet": "import socket"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98842:ClassDef_L10_C0", "label": "CachedDnsName", "type": "class", "loc": [10, 17], "level": 0, "parent": null, "vector": [3, 0, 0.7105, 0.4211, 0, 0.66, 0.6667, 454, 0, 2, 0, 0, 186, 0, 3], "semantic": {"name": "CachedDnsName", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class CachedDnsName(object):\n def __str__(self):\n return self.get_fqdn()\n\n def get_fqdn(self):\n if not hasattr(self, '_fqdn'):\n self._fqdn = socket.getfqdn()\n return self._fqdn"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98842:FunctionDef_L11_C4", "label": "__str__", "type": "function", "loc": [11, 12], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98842:ClassDef_L10_C0", "vector": [2, 1, 0.6053, 0.1053, 1, 0.95, 0.0, 527, 0, 1, 1, 0, 0, 0, 1], "semantic": {"name": "__str__", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def __str__(self):\n return self.get_fqdn()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98842:Return_L12_C8", "label": "return", "type": "return", "loc": [12, 12], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98842:FunctionDef_L11_C4", "vector": [13, 2, 0.6316, 0.0526, 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 self.get_fqdn()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98842:FunctionDef_L14_C4", "label": "get_fqdn", "type": "function", "loc": [14, 17], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98842:ClassDef_L10_C0", "vector": [2, 1, 0.8158, 0.2105, 1, 0.95, 1.0, 959, 0, 1, 1, 0, 0, 0, 2], "semantic": {"name": "get_fqdn", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def get_fqdn(self):\n if not hasattr(self, '_fqdn'):\n self._fqdn = socket.getfqdn()\n return self._fqdn"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98842:If_L15_C8", "label": "if", "type": "if", "loc": [15, 16], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98842:FunctionDef_L14_C4", "vector": [4, 2, 0.8158, 0.1053, 2, 0.32, 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, '_fqdn'):\n self._fqdn = socket.getfqdn()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98842:Assign_L16_C12", "label": "self._fqdn = getfqdn()", "type": "assigned_variable", "loc": [16, 16], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98842:If_L15_C8", "vector": [14, 3, 0.8421, 0.0526, 3, 0.99, 0.0, 634, 3, 0, 0, 0, 767, 10, 1], "semantic": {"name": "self._fqdn", "arg_names": [], "import_names": [], "rhs_call_name": "getfqdn", "annotation": ""}, "snippet": " self._fqdn = socket.getfqdn()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98842:Return_L17_C8", "label": "return", "type": "return", "loc": [17, 17], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98842:FunctionDef_L14_C4", "vector": [13, 2, 0.8947, 0.0526, 2, 0.32, 1.0, 0, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return self._fqdn"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98842:Assign_L19_C0", "label": "DNS_NAME = CachedDnsName()", "type": "assigned_variable", "loc": [19, 19], "level": 0, "parent": null, "vector": [14, 0, 1.0, 0.0526, 0, 0.66, 1.0, 693, 3, 0, 0, 0, 454, 10, 1], "semantic": {"name": "DNS_NAME", "arg_names": [], "import_names": [], "rhs_call_name": "CachedDnsName", "annotation": ""}, "snippet": "DNS_NAME = CachedDnsName()"}]
[{"f": "ajibawa-2023/Python-Code-Large/train/row_98842:ClassDef_L10_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98842:FunctionDef_L11_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98842:FunctionDef_L11_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98842:Return_L12_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98842:ClassDef_L10_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98842:FunctionDef_L14_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98842:FunctionDef_L14_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98842:If_L15_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98842:If_L15_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98842:Assign_L16_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98842:FunctionDef_L14_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98842:Return_L17_C8"}]
""" Dummy email backend that does nothing. """ from django.core.mail.backends.base import BaseEmailBackend class EmailBackend(BaseEmailBackend): def send_messages(self, email_messages): return len(email_messages)
ajibawa-2023/Python-Code-Large/train/row_98843
5
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_98843:Expr_L1_C0", "label": "expression", "type": "expression", "loc": [1, 3], "level": 0, "parent": null, "vector": [8, 0, 0.2222, 0.3333, 0, 0.66, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "\"\"\"\nDummy email backend that does nothing.\n\"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98843:ImportFrom_L5_C0", "label": "from django.core.mail.backends.base import BaseEmailBackend", "type": "import", "loc": [5, 5], "level": 0, "parent": null, "vector": [1, 0, 0.5556, 0.1111, 0, 0.66, 0.5, 502, 0, 1, 0, 0, 502, 0, 0], "semantic": {"name": "django.core.mail.backends.base", "arg_names": [], "import_names": ["BaseEmailBackend"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.core.mail.backends.base import BaseEmailBackend"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98843:ClassDef_L7_C0", "label": "EmailBackend", "type": "class", "loc": [7, 9], "level": 0, "parent": null, "vector": [3, 0, 0.8889, 0.3333, 0, 0.66, 1.0, 635, 0, 1, 0, 0, 507, 0, 1], "semantic": {"name": "EmailBackend", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class EmailBackend(BaseEmailBackend):\n def send_messages(self, email_messages):\n return len(email_messages)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98843:FunctionDef_L8_C4", "label": "send_messages", "type": "function", "loc": [8, 9], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98843:ClassDef_L7_C0", "vector": [2, 1, 0.9444, 0.2222, 1, 0.52, 0.0, 655, 0, 2, 1, 0, 0, 0, 1], "semantic": {"name": "send_messages", "arg_names": ["self", "email_messages"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def send_messages(self, email_messages):\n return len(email_messages)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98843:Return_L9_C8", "label": "return", "type": "return", "loc": [9, 9], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98843:FunctionDef_L8_C4", "vector": [13, 2, 1.0, 0.1111, 2, 0.35, 0.0, 0, 3, 0, 0, 0, 0, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return len(email_messages)"}]
[{"f": "ajibawa-2023/Python-Code-Large/train/row_98843:ClassDef_L7_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98843:FunctionDef_L8_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98843:FunctionDef_L8_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98843:Return_L9_C8"}]
""" Email backend that writes messages to console instead of sending them. """ import sys import threading from django.core.mail.backends.base import BaseEmailBackend class EmailBackend(BaseEmailBackend): def __init__(self, *args, **kwargs): self.stream = kwargs.pop('stream', sys.stdout) self._lock = threading.RLock() super(EmailBackend, self).__init__(*args, **kwargs) def send_messages(self, email_messages): """Write all messages to the stream in a thread-safe way.""" if not email_messages: return self._lock.acquire() try: # The try-except is nested to allow for # Python 2.4 support (Refs #12147) try: stream_created = self.open() for message in email_messages: self.stream.write('%s\n' % message.message().as_string()) self.stream.write('-'*79) self.stream.write('\n') self.stream.flush() # flush after each message if stream_created: self.close() except: if not self.fail_silently: raise finally: self._lock.release() return len(email_messages)
ajibawa-2023/Python-Code-Large/train/row_98844
27
37
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_98844:Expr_L1_C0", "label": "expression", "type": "expression", "loc": [1, 3], "level": 0, "parent": null, "vector": [8, 0, 0.0541, 0.0811, 0, 0.66, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "\"\"\"\nEmail backend that writes messages to console instead of sending them.\n\"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98844:Import_L4_C0", "label": "sys import sys", "type": "import", "loc": [4, 4], "level": 0, "parent": null, "vector": [1, 0, 0.1081, 0.027, 0, 0.66, 0.25, 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_98844:Import_L5_C0", "label": "threading import threading", "type": "import", "loc": [5, 5], "level": 0, "parent": null, "vector": [1, 0, 0.1351, 0.027, 0, 0.66, 0.5, 83, 0, 1, 0, 0, 83, 0, 0], "semantic": {"name": "threading", "arg_names": [], "import_names": ["threading"], "rhs_call_name": "", "annotation": ""}, "snippet": "import threading"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98844:ImportFrom_L7_C0", "label": "from django.core.mail.backends.base import BaseEmailBackend", "type": "import", "loc": [7, 7], "level": 0, "parent": null, "vector": [1, 0, 0.1892, 0.027, 0, 0.66, 0.75, 502, 0, 1, 0, 0, 502, 0, 0], "semantic": {"name": "django.core.mail.backends.base", "arg_names": [], "import_names": ["BaseEmailBackend"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.core.mail.backends.base import BaseEmailBackend"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98844:ClassDef_L9_C0", "label": "EmailBackend", "type": "class", "loc": [9, 37], "level": 0, "parent": null, "vector": [3, 0, 0.6216, 0.7838, 0, 0.66, 1.0, 635, 0, 2, 0, 0, 507, 0, 15], "semantic": {"name": "EmailBackend", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class EmailBackend(BaseEmailBackend):\n def __init__(self, *args, **kwargs):\n self.stream = kwargs.pop('stream', sys.stdout)\n self._lock = threading.RLock()\n super(EmailBackend, self).__init__(*args, **kwargs)\n\n def send_messages(self, email_messages):\n \"\"\"Write all messages to the stream in a thread-safe way.\"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98844:FunctionDef_L10_C4", "label": "__init__", "type": "function", "loc": [10, 13], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98844:ClassDef_L9_C0", "vector": [2, 1, 0.3108, 0.1081, 1, 0.87, 0.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 self.stream = kwargs.pop('stream', sys.stdout)\n self._lock = threading.RLock()\n super(EmailBackend, self).__init__(*args, **kwargs)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98844:Assign_L11_C8", "label": "self.stream = pop()", "type": "assigned_variable", "loc": [11, 11], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98844:FunctionDef_L10_C4", "vector": [14, 2, 0.2973, 0.027, 2, 0.89, 0.0, 207, 3, 2, 0, 0, 969, 10, 1], "semantic": {"name": "self.stream", "arg_names": [], "import_names": [], "rhs_call_name": "pop", "annotation": ""}, "snippet": " self.stream = kwargs.pop('stream', sys.stdout)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98844:Assign_L12_C8", "label": "self._lock = RLock()", "type": "assigned_variable", "loc": [12, 12], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98844:FunctionDef_L10_C4", "vector": [14, 2, 0.3243, 0.027, 2, 0.89, 0.5, 143, 3, 0, 0, 0, 207, 10, 1], "semantic": {"name": "self._lock", "arg_names": [], "import_names": [], "rhs_call_name": "RLock", "annotation": ""}, "snippet": " self._lock = threading.RLock()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98844:Expr_L13_C8", "label": "__init__()", "type": "expression", "loc": [13, 13], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98844:FunctionDef_L10_C4", "vector": [8, 2, 0.3514, 0.027, 2, 0.89, 1.0, 555, 3, 2, 0, 0, 0, 0, 2], "semantic": {"name": "__init__", "arg_names": [], "import_names": [], "rhs_call_name": "__init__", "annotation": ""}, "snippet": " super(EmailBackend, self).__init__(*args, **kwargs)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98844:FunctionDef_L15_C4", "label": "send_messages", "type": "function", "loc": [15, 37], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98844:ClassDef_L9_C0", "vector": [2, 1, 0.7027, 0.6216, 1, 0.87, 1.0, 655, 0, 2, 1, 0, 0, 0, 11], "semantic": {"name": "send_messages", "arg_names": ["self", "email_messages"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def send_messages(self, email_messages):\n \"\"\"Write all messages to the stream in a thread-safe way.\"\"\"\n if not email_messages:\n return\n self._lock.acquire()\n try:\n # The try-except is nested to allow for\n # Python 2.4 support (Refs #12147)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98844:Expr_L16_C8", "label": "expression", "type": "expression", "loc": [16, 16], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98844:FunctionDef_L15_C4", "vector": [8, 2, 0.4324, 0.027, 2, 0.97, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"Write all messages to the stream in a thread-safe way.\"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98844:If_L17_C8", "label": "if", "type": "if", "loc": [17, 18], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98844:FunctionDef_L15_C4", "vector": [4, 2, 0.473, 0.0541, 2, 0.97, 0.25, 0, 0, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if not email_messages:\n return"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98844:Return_L18_C12", "label": "return", "type": "return", "loc": [18, 18], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98844:If_L17_C8", "vector": [13, 3, 0.4865, 0.027, 3, 0.25, 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_98844:Expr_L19_C8", "label": "acquire()", "type": "expression", "loc": [19, 19], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98844:FunctionDef_L15_C4", "vector": [8, 2, 0.5135, 0.027, 2, 0.97, 0.5, 229, 3, 0, 0, 0, 0, 0, 1], "semantic": {"name": "acquire", "arg_names": [], "import_names": [], "rhs_call_name": "acquire", "annotation": ""}, "snippet": " self._lock.acquire()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98844:Try_L20_C8", "label": "try", "type": "try", "loc": [20, 36], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98844:FunctionDef_L15_C4", "vector": [7, 2, 0.7568, 0.4595, 2, 0.97, 0.75, 0, 0, 0, 0, 0, 0, 0, 9], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " try:\n # The try-except is nested to allow for\n # Python 2.4 support (Refs #12147)\n try:\n stream_created = self.open()\n for message in email_messages:\n self.stream.write('%s\\n' % message.message().as_string())\n self.stream.write('-'*79)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98844:Try_L23_C12", "label": "try", "type": "try", "loc": [23, 34], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98844:Try_L20_C8", "vector": [7, 3, 0.7703, 0.3243, 3, 0.64, 0.0, 0, 0, 1, 0, 0, 0, 0, 8], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " try:\n stream_created = self.open()\n for message in email_messages:\n self.stream.write('%s\\n' % message.message().as_string())\n self.stream.write('-'*79)\n self.stream.write('\\n')\n self.stream.flush() # flush after each message\n if stream_created:"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98844:Assign_L24_C16", "label": "stream_created = open()", "type": "assigned_variable", "loc": [24, 24], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98844:Try_L23_C12", "vector": [14, 4, 0.6486, 0.027, 4, 0.82, 0.0, 189, 3, 0, 0, 0, 693, 10, 1], "semantic": {"name": "stream_created", "arg_names": [], "import_names": [], "rhs_call_name": "open", "annotation": ""}, "snippet": " stream_created = self.open()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98844:For_L25_C16", "label": "for message", "type": "for", "loc": [25, 29], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98844:Try_L23_C12", "vector": [6, 4, 0.7297, 0.1351, 4, 0.82, 0.5, 635, 2, 0, 0, 0, 0, 0, 6], "semantic": {"name": "message", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for message in email_messages:\n self.stream.write('%s\\n' % message.message().as_string())\n self.stream.write('-'*79)\n self.stream.write('\\n')\n self.stream.flush() # flush after each message"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98844:Expr_L26_C20", "label": "write()", "type": "expression", "loc": [26, 26], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98844:For_L25_C16", "vector": [8, 5, 0.7027, 0.027, 5, 0.36, 0.0, 837, 3, 1, 0, 0, 0, 0, 3], "semantic": {"name": "write", "arg_names": [], "import_names": [], "rhs_call_name": "write", "annotation": ""}, "snippet": " self.stream.write('%s\\n' % message.message().as_string())"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98844:Expr_L27_C20", "label": "write()", "type": "expression", "loc": [27, 27], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98844:For_L25_C16", "vector": [8, 5, 0.7297, 0.027, 5, 0.36, 0.3333, 837, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "write", "arg_names": [], "import_names": [], "rhs_call_name": "write", "annotation": ""}, "snippet": " self.stream.write('-'*79)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98844:Expr_L28_C20", "label": "write()", "type": "expression", "loc": [28, 28], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98844:For_L25_C16", "vector": [8, 5, 0.7568, 0.027, 5, 0.36, 0.6667, 837, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "write", "arg_names": [], "import_names": [], "rhs_call_name": "write", "annotation": ""}, "snippet": " self.stream.write('\\n')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98844:Expr_L29_C20", "label": "flush()", "type": "expression", "loc": [29, 29], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98844:For_L25_C16", "vector": [8, 5, 0.7838, 0.027, 5, 0.36, 1.0, 439, 3, 0, 0, 0, 0, 0, 1], "semantic": {"name": "flush", "arg_names": [], "import_names": [], "rhs_call_name": "flush", "annotation": ""}, "snippet": " self.stream.flush() # flush after each message"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98844:If_L30_C16", "label": "if", "type": "if", "loc": [30, 31], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98844:Try_L23_C12", "vector": [4, 4, 0.8243, 0.0541, 4, 0.82, 1.0, 0, 2, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if stream_created:\n self.close()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98844:Expr_L31_C20", "label": "close()", "type": "expression", "loc": [31, 31], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98844:If_L30_C16", "vector": [8, 5, 0.8378, 0.027, 5, 0.55, 0.0, 77, 3, 0, 0, 0, 0, 0, 1], "semantic": {"name": "close", "arg_names": [], "import_names": [], "rhs_call_name": "close", "annotation": ""}, "snippet": " self.close()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98844:If_L33_C16", "label": "if", "type": "if", "loc": [33, 34], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98844:Try_L23_C12", "vector": [4, 4, 0.9054, 0.0541, 4, 0.82, 0.0, 0, 0, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if not self.fail_silently:\n raise"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98844:Expr_L36_C12", "label": "release()", "type": "expression", "loc": [36, 36], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98844:Try_L20_C8", "vector": [8, 3, 0.973, 0.027, 3, 0.64, 1.0, 784, 3, 0, 0, 0, 0, 0, 1], "semantic": {"name": "release", "arg_names": [], "import_names": [], "rhs_call_name": "release", "annotation": ""}, "snippet": " self._lock.release()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98844:Return_L37_C8", "label": "return", "type": "return", "loc": [37, 37], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98844:FunctionDef_L15_C4", "vector": [13, 2, 1.0, 0.027, 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 len(email_messages)"}]
[{"f": "ajibawa-2023/Python-Code-Large/train/row_98844:ClassDef_L9_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98844:FunctionDef_L10_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98844:FunctionDef_L10_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98844:Assign_L11_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98844:FunctionDef_L10_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98844:Assign_L12_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98844:FunctionDef_L10_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98844:Expr_L13_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98844:ClassDef_L9_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98844:FunctionDef_L15_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98844:FunctionDef_L15_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98844:Expr_L16_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98844:FunctionDef_L15_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98844:If_L17_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98844:If_L17_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98844:Return_L18_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98844:FunctionDef_L15_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98844:Expr_L19_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98844:FunctionDef_L15_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98844:Try_L20_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98844:Try_L20_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98844:Try_L23_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98844:Try_L23_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98844:Assign_L24_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98844:Try_L23_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98844:For_L25_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98844:For_L25_C16", "t": "ajibawa-2023/Python-Code-Large/train/row_98844:Expr_L26_C20"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98844:For_L25_C16", "t": "ajibawa-2023/Python-Code-Large/train/row_98844:Expr_L27_C20"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98844:For_L25_C16", "t": "ajibawa-2023/Python-Code-Large/train/row_98844:Expr_L28_C20"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98844:For_L25_C16", "t": "ajibawa-2023/Python-Code-Large/train/row_98844:Expr_L29_C20"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98844:Try_L23_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98844:If_L30_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98844:If_L30_C16", "t": "ajibawa-2023/Python-Code-Large/train/row_98844:Expr_L31_C20"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98844:Try_L23_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98844:If_L33_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98844:Try_L20_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98844:Expr_L36_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98844:FunctionDef_L15_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98844:Return_L37_C8"}]
"""SMTP email backend class.""" import smtplib import socket import threading from django.conf import settings from django.core.mail.backends.base import BaseEmailBackend from django.core.mail.utils import DNS_NAME class EmailBackend(BaseEmailBackend): """ A wrapper that manages the SMTP network connection. """ def __init__(self, host=None, port=None, username=None, password=None, use_tls=None, fail_silently=False, **kwargs): super(EmailBackend, self).__init__(fail_silently=fail_silently) self.host = host or settings.EMAIL_HOST self.port = port or settings.EMAIL_PORT self.username = username or settings.EMAIL_HOST_USER self.password = password or settings.EMAIL_HOST_PASSWORD if use_tls is None: self.use_tls = settings.EMAIL_USE_TLS else: self.use_tls = use_tls self.connection = None self._lock = threading.RLock() def open(self): """ Ensures we have a connection to the email server. Returns whether or not a new connection was required (True or False). """ if self.connection: # Nothing to do if the connection is already open. return False try: # If local_hostname is not specified, socket.getfqdn() gets used. # For performance, we use the cached FQDN for local_hostname. self.connection = smtplib.SMTP(self.host, self.port, local_hostname=DNS_NAME.get_fqdn()) if self.use_tls: self.connection.ehlo() self.connection.starttls() self.connection.ehlo() if self.username and self.password: self.connection.login(self.username, self.password) return True except: if not self.fail_silently: raise def close(self): """Closes the connection to the email server.""" try: try: self.connection.quit() except socket.sslerror: # This happens when calling quit() on a TLS connection # sometimes. self.connection.close() except: if self.fail_silently: return raise finally: self.connection = None def send_messages(self, email_messages): """ Sends one or more EmailMessage objects and returns the number of email messages sent. """ if not email_messages: return self._lock.acquire() try: new_conn_created = self.open() if not self.connection: # We failed silently on open(). # Trying to send would be pointless. return num_sent = 0 for message in email_messages: sent = self._send(message) if sent: num_sent += 1 if new_conn_created: self.close() finally: self._lock.release() return num_sent def _send(self, email_message): """A helper method that does the actual sending.""" if not email_message.recipients(): return False try: self.connection.sendmail(email_message.from_email, email_message.recipients(), email_message.message().as_string()) except: if not self.fail_silently: raise return False return True
ajibawa-2023/Python-Code-Large/train/row_98845
69
106
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_98845:Expr_L1_C0", "label": "expression", "type": "expression", "loc": [1, 1], "level": 0, "parent": null, "vector": [8, 0, 0.0094, 0.0094, 0, 0.66, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "\"\"\"SMTP email backend class.\"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98845:Import_L3_C0", "label": "smtplib import smtplib", "type": "import", "loc": [3, 3], "level": 0, "parent": null, "vector": [1, 0, 0.0283, 0.0094, 0, 0.66, 0.1429, 389, 0, 1, 0, 0, 389, 0, 0], "semantic": {"name": "smtplib", "arg_names": [], "import_names": ["smtplib"], "rhs_call_name": "", "annotation": ""}, "snippet": "import smtplib"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98845:Import_L4_C0", "label": "socket import socket", "type": "import", "loc": [4, 4], "level": 0, "parent": null, "vector": [1, 0, 0.0377, 0.0094, 0, 0.66, 0.2857, 687, 0, 1, 0, 0, 687, 0, 0], "semantic": {"name": "socket", "arg_names": [], "import_names": ["socket"], "rhs_call_name": "", "annotation": ""}, "snippet": "import socket"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98845:Import_L5_C0", "label": "threading import threading", "type": "import", "loc": [5, 5], "level": 0, "parent": null, "vector": [1, 0, 0.0472, 0.0094, 0, 0.66, 0.4286, 83, 0, 1, 0, 0, 83, 0, 0], "semantic": {"name": "threading", "arg_names": [], "import_names": ["threading"], "rhs_call_name": "", "annotation": ""}, "snippet": "import threading"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98845:ImportFrom_L7_C0", "label": "from django.conf import settings", "type": "import", "loc": [7, 7], "level": 0, "parent": null, "vector": [1, 0, 0.066, 0.0094, 0, 0.66, 0.5714, 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_98845:ImportFrom_L8_C0", "label": "from django.core.mail.backends.base import BaseEmailBackend", "type": "import", "loc": [8, 8], "level": 0, "parent": null, "vector": [1, 0, 0.0755, 0.0094, 0, 0.66, 0.7143, 502, 0, 1, 0, 0, 502, 0, 0], "semantic": {"name": "django.core.mail.backends.base", "arg_names": [], "import_names": ["BaseEmailBackend"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.core.mail.backends.base import BaseEmailBackend"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98845:ImportFrom_L9_C0", "label": "from django.core.mail.utils import DNS_NAME", "type": "import", "loc": [9, 9], "level": 0, "parent": null, "vector": [1, 0, 0.0849, 0.0094, 0, 0.66, 0.8571, 787, 0, 1, 0, 0, 787, 0, 0], "semantic": {"name": "django.core.mail.utils", "arg_names": [], "import_names": ["DNS_NAME"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.core.mail.utils import DNS_NAME"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98845:ClassDef_L11_C0", "label": "EmailBackend", "type": "class", "loc": [11, 106], "level": 0, "parent": null, "vector": [3, 0, 0.5519, 0.9057, 0, 0.66, 1.0, 635, 0, 5, 0, 0, 507, 0, 21], "semantic": {"name": "EmailBackend", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class EmailBackend(BaseEmailBackend):\n \"\"\"\n A wrapper that manages the SMTP network connection.\n \"\"\"\n def __init__(self, host=None, port=None, username=None, password=None,\n use_tls=None, fail_silently=False, **kwargs):\n super(EmailBackend, self).__init__(fail_silently=fail_silently)\n self.host = host or settings.EMAIL_HOST"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98845:Expr_L12_C4", "label": "expression", "type": "expression", "loc": [12, 14], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98845:ClassDef_L11_C0", "vector": [8, 1, 0.1226, 0.0283, 1, 0.69, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"\n A wrapper that manages the SMTP network connection.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98845:FunctionDef_L15_C4", "label": "__init__", "type": "function", "loc": [15, 27], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98845:ClassDef_L11_C0", "vector": [2, 1, 0.1981, 0.1226, 1, 0.69, 0.2, 555, 0, 8, 0, 0, 0, 0, 3], "semantic": {"name": "__init__", "arg_names": ["self", "host", "port", "username", "password", "use_tls", "fail_silently", "kwargs"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def __init__(self, host=None, port=None, username=None, password=None,\n use_tls=None, fail_silently=False, **kwargs):\n super(EmailBackend, self).__init__(fail_silently=fail_silently)\n self.host = host or settings.EMAIL_HOST\n self.port = port or settings.EMAIL_PORT\n self.username = username or settings.EMAIL_HOST_USER\n self.password = password or settings.EMAIL_HOST_PASSWORD\n if use_tls is None:"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98845:Expr_L17_C8", "label": "__init__()", "type": "expression", "loc": [17, 17], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98845:FunctionDef_L15_C4", "vector": [8, 2, 0.1604, 0.0094, 2, 0.53, 0.0, 555, 3, 1, 0, 0, 0, 0, 2], "semantic": {"name": "__init__", "arg_names": [], "import_names": [], "rhs_call_name": "__init__", "annotation": ""}, "snippet": " super(EmailBackend, self).__init__(fail_silently=fail_silently)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98845:Assign_L18_C8", "label": "self.host =", "type": "assigned_variable", "loc": [18, 18], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98845:FunctionDef_L15_C4", "vector": [14, 2, 0.1698, 0.0094, 2, 0.53, 0.1429, 445, 0, 0, 0, 0, 0, 0, 0], "semantic": {"name": "self.host", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.host = host or settings.EMAIL_HOST"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98845:Assign_L19_C8", "label": "self.port =", "type": "assigned_variable", "loc": [19, 19], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98845:FunctionDef_L15_C4", "vector": [14, 2, 0.1792, 0.0094, 2, 0.53, 0.2857, 435, 0, 0, 0, 0, 0, 0, 0], "semantic": {"name": "self.port", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.port = port or settings.EMAIL_PORT"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98845:Assign_L20_C8", "label": "self.username =", "type": "assigned_variable", "loc": [20, 20], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98845:FunctionDef_L15_C4", "vector": [14, 2, 0.1887, 0.0094, 2, 0.53, 0.4286, 380, 0, 0, 0, 0, 0, 0, 0], "semantic": {"name": "self.username", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.username = username or settings.EMAIL_HOST_USER"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98845:Assign_L21_C8", "label": "self.password =", "type": "assigned_variable", "loc": [21, 21], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98845:FunctionDef_L15_C4", "vector": [14, 2, 0.1981, 0.0094, 2, 0.53, 0.5714, 902, 0, 0, 0, 0, 0, 0, 0], "semantic": {"name": "self.password", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.password = password or settings.EMAIL_HOST_PASSWORD"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98845:If_L22_C8", "label": "if", "type": "if", "loc": [22, 25], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98845:FunctionDef_L15_C4", "vector": [4, 2, 0.2217, 0.0377, 2, 0.53, 0.7143, 0, 0, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if use_tls is None:\n self.use_tls = settings.EMAIL_USE_TLS\n else:\n self.use_tls = use_tls"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98845:Assign_L23_C12", "label": "self.use_tls =", "type": "assigned_variable", "loc": [23, 23], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98845:If_L22_C8", "vector": [14, 3, 0.217, 0.0094, 3, 0.01, 0.0, 280, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "self.use_tls", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.use_tls = settings.EMAIL_USE_TLS"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98845:Assign_L25_C12", "label": "self.use_tls =", "type": "assigned_variable", "loc": [25, 25], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98845:If_L22_C8", "vector": [14, 3, 0.2358, 0.0094, 3, 0.01, 1.0, 280, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "self.use_tls", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.use_tls = use_tls"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98845:Assign_L26_C8", "label": "self.connection =", "type": "assigned_variable", "loc": [26, 26], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98845:FunctionDef_L15_C4", "vector": [14, 2, 0.2453, 0.0094, 2, 0.53, 0.8571, 685, 1, 0, 0, 0, 0, 9, 0], "semantic": {"name": "self.connection", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.connection = None"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98845:Assign_L27_C8", "label": "self._lock = RLock()", "type": "assigned_variable", "loc": [27, 27], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98845:FunctionDef_L15_C4", "vector": [14, 2, 0.2547, 0.0094, 2, 0.53, 1.0, 143, 3, 0, 0, 0, 207, 10, 1], "semantic": {"name": "self._lock", "arg_names": [], "import_names": [], "rhs_call_name": "RLock", "annotation": ""}, "snippet": " self._lock = threading.RLock()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98845:FunctionDef_L29_C4", "label": "open", "type": "function", "loc": [29, 51], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98845:ClassDef_L11_C0", "vector": [2, 1, 0.3774, 0.217, 1, 0.69, 0.4, 693, 0, 1, 1, 0, 0, 0, 6], "semantic": {"name": "open", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def open(self):\n \"\"\"\n Ensures we have a connection to the email server. Returns whether or\n not a new connection was required (True or False).\n \"\"\"\n if self.connection:\n # Nothing to do if the connection is already open.\n return False"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98845:Expr_L30_C8", "label": "expression", "type": "expression", "loc": [30, 33], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98845:FunctionDef_L29_C4", "vector": [8, 2, 0.2972, 0.0377, 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 Ensures we have a connection to the email server. Returns whether or\n not a new connection was required (True or False).\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98845:If_L34_C8", "label": "if", "type": "if", "loc": [34, 36], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98845:FunctionDef_L29_C4", "vector": [4, 2, 0.3302, 0.0283, 2, 0.36, 0.5, 0, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if self.connection:\n # Nothing to do if the connection is already open.\n return False"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98845:Return_L36_C12", "label": "return", "type": "return", "loc": [36, 36], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98845:If_L34_C8", "vector": [13, 3, 0.3396, 0.0094, 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_98845:Try_L37_C8", "label": "try", "type": "try", "loc": [37, 51], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98845:FunctionDef_L29_C4", "vector": [7, 2, 0.4151, 0.1415, 2, 0.36, 1.0, 0, 0, 1, 0, 0, 0, 0, 6], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " try:\n # If local_hostname is not specified, socket.getfqdn() gets used.\n # For performance, we use the cached FQDN for local_hostname.\n self.connection = smtplib.SMTP(self.host, self.port,\n local_hostname=DNS_NAME.get_fqdn())\n if self.use_tls:\n self.connection.ehlo()\n self.connection.starttls()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98845:Assign_L40_C12", "label": "self.connection = SMTP()", "type": "assigned_variable", "loc": [40, 41], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98845:Try_L37_C8", "vector": [14, 3, 0.3821, 0.0189, 3, 0.75, 0.0, 685, 3, 3, 0, 0, 709, 10, 2], "semantic": {"name": "self.connection", "arg_names": [], "import_names": [], "rhs_call_name": "SMTP", "annotation": ""}, "snippet": " self.connection = smtplib.SMTP(self.host, self.port,\n local_hostname=DNS_NAME.get_fqdn())"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98845:If_L42_C12", "label": "if", "type": "if", "loc": [42, 45], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98845:Try_L37_C8", "vector": [4, 3, 0.4104, 0.0377, 3, 0.75, 0.3333, 0, 7, 0, 0, 0, 0, 0, 3], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if self.use_tls:\n self.connection.ehlo()\n self.connection.starttls()\n self.connection.ehlo()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98845:Expr_L43_C16", "label": "ehlo()", "type": "expression", "loc": [43, 43], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98845:If_L42_C12", "vector": [8, 4, 0.4057, 0.0094, 4, 0.17, 0.0, 292, 3, 0, 0, 0, 0, 0, 1], "semantic": {"name": "ehlo", "arg_names": [], "import_names": [], "rhs_call_name": "ehlo", "annotation": ""}, "snippet": " self.connection.ehlo()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98845:Expr_L44_C16", "label": "starttls()", "type": "expression", "loc": [44, 44], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98845:If_L42_C12", "vector": [8, 4, 0.4151, 0.0094, 4, 0.17, 0.5, 262, 3, 0, 0, 0, 0, 0, 1], "semantic": {"name": "starttls", "arg_names": [], "import_names": [], "rhs_call_name": "starttls", "annotation": ""}, "snippet": " self.connection.starttls()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98845:Expr_L45_C16", "label": "ehlo()", "type": "expression", "loc": [45, 45], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98845:If_L42_C12", "vector": [8, 4, 0.4245, 0.0094, 4, 0.17, 1.0, 292, 3, 0, 0, 0, 0, 0, 1], "semantic": {"name": "ehlo", "arg_names": [], "import_names": [], "rhs_call_name": "ehlo", "annotation": ""}, "snippet": " self.connection.ehlo()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98845:If_L46_C12", "label": "if", "type": "if", "loc": [46, 47], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98845:Try_L37_C8", "vector": [4, 3, 0.4387, 0.0189, 3, 0.75, 0.6667, 0, 0, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if self.username and self.password:\n self.connection.login(self.username, self.password)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98845:Expr_L47_C16", "label": "login()", "type": "expression", "loc": [47, 47], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98845:If_L46_C12", "vector": [8, 4, 0.4434, 0.0094, 4, 0.63, 0.0, 724, 3, 2, 0, 0, 0, 0, 1], "semantic": {"name": "login", "arg_names": [], "import_names": [], "rhs_call_name": "login", "annotation": ""}, "snippet": " self.connection.login(self.username, self.password)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98845:Return_L48_C12", "label": "return", "type": "return", "loc": [48, 48], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98845:Try_L37_C8", "vector": [13, 3, 0.4528, 0.0094, 3, 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_98845:If_L50_C12", "label": "if", "type": "if", "loc": [50, 51], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98845:Try_L37_C8", "vector": [4, 3, 0.4764, 0.0189, 3, 0.75, 0.0, 0, 0, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if not self.fail_silently:\n raise"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98845:FunctionDef_L53_C4", "label": "close", "type": "function", "loc": [53, 67], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98845:ClassDef_L11_C0", "vector": [2, 1, 0.566, 0.1415, 1, 0.69, 0.6, 77, 0, 1, 0, 0, 0, 0, 2], "semantic": {"name": "close", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def close(self):\n \"\"\"Closes the connection to the email server.\"\"\"\n try:\n try:\n self.connection.quit()\n except socket.sslerror:\n # This happens when calling quit() on a TLS connection\n # sometimes."}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98845:Expr_L54_C8", "label": "expression", "type": "expression", "loc": [54, 54], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98845:FunctionDef_L53_C4", "vector": [8, 2, 0.5094, 0.0094, 2, 0.96, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"Closes the connection to the email server.\"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98845:Try_L55_C8", "label": "try", "type": "try", "loc": [55, 67], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98845:FunctionDef_L53_C4", "vector": [7, 2, 0.5755, 0.1226, 2, 0.96, 1.0, 0, 0, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " try:\n try:\n self.connection.quit()\n except socket.sslerror:\n # This happens when calling quit() on a TLS connection\n # sometimes.\n self.connection.close()\n except:"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98845:Try_L56_C12", "label": "try", "type": "try", "loc": [56, 65], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98845:Try_L55_C8", "vector": [7, 3, 0.5708, 0.0943, 3, 0.49, 0.0, 0, 0, 2, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " try:\n self.connection.quit()\n except socket.sslerror:\n # This happens when calling quit() on a TLS connection\n # sometimes.\n self.connection.close()\n except:\n if self.fail_silently:"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98845:Expr_L57_C16", "label": "quit()", "type": "expression", "loc": [57, 57], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98845:Try_L56_C12", "vector": [8, 4, 0.5377, 0.0094, 4, 0.96, 0.0, 219, 3, 0, 0, 0, 0, 0, 1], "semantic": {"name": "quit", "arg_names": [], "import_names": [], "rhs_call_name": "quit", "annotation": ""}, "snippet": " self.connection.quit()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98845:Expr_L61_C16", "label": "close()", "type": "expression", "loc": [61, 61], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98845:Try_L56_C12", "vector": [8, 4, 0.5755, 0.0094, 4, 0.96, 0.0, 77, 3, 0, 0, 0, 0, 0, 1], "semantic": {"name": "close", "arg_names": [], "import_names": [], "rhs_call_name": "close", "annotation": ""}, "snippet": " self.connection.close()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98845:If_L63_C16", "label": "if", "type": "if", "loc": [63, 64], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98845:Try_L56_C12", "vector": [4, 4, 0.5991, 0.0189, 4, 0.96, 0.0, 0, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if self.fail_silently:\n return"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98845:Return_L64_C20", "label": "return", "type": "return", "loc": [64, 64], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98845:If_L63_C16", "vector": [13, 5, 0.6038, 0.0094, 5, 0.61, 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_98845:Assign_L67_C12", "label": "self.connection =", "type": "assigned_variable", "loc": [67, 67], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98845:Try_L55_C8", "vector": [14, 3, 0.6321, 0.0094, 3, 0.49, 1.0, 685, 1, 0, 0, 0, 0, 9, 0], "semantic": {"name": "self.connection", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.connection = None"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98845:FunctionDef_L69_C4", "label": "send_messages", "type": "function", "loc": [69, 92], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98845:ClassDef_L11_C0", "vector": [2, 1, 0.7594, 0.2264, 1, 0.69, 0.8, 655, 0, 2, 1, 0, 0, 0, 5], "semantic": {"name": "send_messages", "arg_names": ["self", "email_messages"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def send_messages(self, email_messages):\n \"\"\"\n Sends one or more EmailMessage objects and returns the number of email\n messages sent.\n \"\"\"\n if not email_messages:\n return\n self._lock.acquire()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98845:Expr_L70_C8", "label": "expression", "type": "expression", "loc": [70, 73], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98845:FunctionDef_L69_C4", "vector": [8, 2, 0.6745, 0.0377, 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 Sends one or more EmailMessage objects and returns the number of email\n messages sent.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98845:If_L74_C8", "label": "if", "type": "if", "loc": [74, 75], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98845:FunctionDef_L69_C4", "vector": [4, 2, 0.7028, 0.0189, 2, 0.82, 0.25, 0, 0, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if not email_messages:\n return"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98845:Return_L75_C12", "label": "return", "type": "return", "loc": [75, 75], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98845:If_L74_C8", "vector": [13, 3, 0.7075, 0.0094, 3, 0.49, 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_98845:Expr_L76_C8", "label": "acquire()", "type": "expression", "loc": [76, 76], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98845:FunctionDef_L69_C4", "vector": [8, 2, 0.717, 0.0094, 2, 0.82, 0.5, 229, 3, 0, 0, 0, 0, 0, 1], "semantic": {"name": "acquire", "arg_names": [], "import_names": [], "rhs_call_name": "acquire", "annotation": ""}, "snippet": " self._lock.acquire()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98845:Try_L77_C8", "label": "try", "type": "try", "loc": [77, 91], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98845:FunctionDef_L69_C4", "vector": [7, 2, 0.7925, 0.1415, 2, 0.82, 0.75, 0, 0, 0, 0, 0, 0, 0, 4], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " try:\n new_conn_created = self.open()\n if not self.connection:\n # We failed silently on open().\n # Trying to send would be pointless.\n return\n num_sent = 0\n for message in email_messages:"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98845:Assign_L78_C12", "label": "new_conn_created = open()", "type": "assigned_variable", "loc": [78, 78], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98845:Try_L77_C8", "vector": [14, 3, 0.7358, 0.0094, 3, 0.86, 0.0, 46, 3, 0, 0, 0, 693, 10, 1], "semantic": {"name": "new_conn_created", "arg_names": [], "import_names": [], "rhs_call_name": "open", "annotation": ""}, "snippet": " new_conn_created = self.open()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98845:If_L79_C12", "label": "if", "type": "if", "loc": [79, 82], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98845:Try_L77_C8", "vector": [4, 3, 0.7594, 0.0377, 3, 0.86, 0.2, 0, 0, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if not self.connection:\n # We failed silently on open().\n # Trying to send would be pointless.\n return"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98845:Return_L82_C16", "label": "return", "type": "return", "loc": [82, 82], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98845:If_L79_C12", "vector": [13, 4, 0.7736, 0.0094, 4, 0.24, 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_98845:Assign_L83_C12", "label": "num_sent =", "type": "assigned_variable", "loc": [83, 83], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98845:Try_L77_C8", "vector": [14, 3, 0.783, 0.0094, 3, 0.86, 0.4, 923, 1, 0, 0, 0, 0, 1, 0], "semantic": {"name": "num_sent", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " num_sent = 0"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98845:For_L84_C12", "label": "for message", "type": "for", "loc": [84, 87], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98845:Try_L77_C8", "vector": [6, 3, 0.8066, 0.0377, 3, 0.86, 0.6, 635, 2, 0, 0, 0, 0, 0, 1], "semantic": {"name": "message", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for message in email_messages:\n sent = self._send(message)\n if sent:\n num_sent += 1"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98845:Assign_L85_C16", "label": "sent = _send()", "type": "assigned_variable", "loc": [85, 85], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98845:For_L84_C12", "vector": [14, 4, 0.8019, 0.0094, 4, 0.63, 0.0, 928, 3, 1, 0, 0, 791, 10, 1], "semantic": {"name": "sent", "arg_names": [], "import_names": [], "rhs_call_name": "_send", "annotation": ""}, "snippet": " sent = self._send(message)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98845:If_L86_C16", "label": "if", "type": "if", "loc": [86, 87], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98845:For_L84_C12", "vector": [4, 4, 0.816, 0.0189, 4, 0.63, 1.0, 0, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if sent:\n num_sent += 1"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98845:If_L88_C12", "label": "if", "type": "if", "loc": [88, 89], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98845:Try_L77_C8", "vector": [4, 3, 0.8349, 0.0189, 3, 0.86, 0.8, 0, 2, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if new_conn_created:\n self.close()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98845:Expr_L89_C16", "label": "close()", "type": "expression", "loc": [89, 89], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98845:If_L88_C12", "vector": [8, 4, 0.8396, 0.0094, 4, 0.62, 0.0, 77, 3, 0, 0, 0, 0, 0, 1], "semantic": {"name": "close", "arg_names": [], "import_names": [], "rhs_call_name": "close", "annotation": ""}, "snippet": " self.close()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98845:Expr_L91_C12", "label": "release()", "type": "expression", "loc": [91, 91], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98845:Try_L77_C8", "vector": [8, 3, 0.8585, 0.0094, 3, 0.86, 1.0, 784, 3, 0, 0, 0, 0, 0, 1], "semantic": {"name": "release", "arg_names": [], "import_names": [], "rhs_call_name": "release", "annotation": ""}, "snippet": " self._lock.release()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98845:Return_L92_C8", "label": "return", "type": "return", "loc": [92, 92], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98845:FunctionDef_L69_C4", "vector": [13, 2, 0.8679, 0.0094, 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 num_sent"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98845:FunctionDef_L94_C4", "label": "_send", "type": "function", "loc": [94, 106], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98845:ClassDef_L11_C0", "vector": [2, 1, 0.9434, 0.1226, 1, 0.69, 1.0, 791, 0, 2, 1, 0, 0, 0, 5], "semantic": {"name": "_send", "arg_names": ["self", "email_message"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def _send(self, email_message):\n \"\"\"A helper method that does the actual sending.\"\"\"\n if not email_message.recipients():\n return False\n try:\n self.connection.sendmail(email_message.from_email,\n email_message.recipients(),\n email_message.message().as_string())"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98845:Expr_L95_C8", "label": "expression", "type": "expression", "loc": [95, 95], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98845:FunctionDef_L94_C4", "vector": [8, 2, 0.8962, 0.0094, 2, 0.39, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"A helper method that does the actual sending.\"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98845:If_L96_C8", "label": "if", "type": "if", "loc": [96, 97], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98845:FunctionDef_L94_C4", "vector": [4, 2, 0.9104, 0.0189, 2, 0.39, 0.3333, 0, 0, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if not email_message.recipients():\n return False"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98845:Return_L97_C12", "label": "return", "type": "return", "loc": [97, 97], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98845:If_L96_C8", "vector": [13, 3, 0.9151, 0.0094, 3, 0.01, 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_98845:Try_L98_C8", "label": "try", "type": "try", "loc": [98, 105], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98845:FunctionDef_L94_C4", "vector": [7, 2, 0.9575, 0.0755, 2, 0.39, 0.6667, 0, 0, 1, 0, 0, 0, 0, 4], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " try:\n self.connection.sendmail(email_message.from_email,\n email_message.recipients(),\n email_message.message().as_string())\n except:\n if not self.fail_silently:\n raise\n return False"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98845:Expr_L99_C12", "label": "sendmail()", "type": "expression", "loc": [99, 101], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98845:Try_L98_C8", "vector": [8, 3, 0.9434, 0.0283, 3, 0.78, 0.0, 176, 3, 3, 0, 0, 0, 0, 4], "semantic": {"name": "sendmail", "arg_names": [], "import_names": [], "rhs_call_name": "sendmail", "annotation": ""}, "snippet": " self.connection.sendmail(email_message.from_email,\n email_message.recipients(),\n email_message.message().as_string())"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98845:If_L103_C12", "label": "if", "type": "if", "loc": [103, 104], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98845:Try_L98_C8", "vector": [4, 3, 0.9764, 0.0189, 3, 0.78, 0.0, 0, 0, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if not self.fail_silently:\n raise"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98845:Return_L105_C12", "label": "return", "type": "return", "loc": [105, 105], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98845:Try_L98_C8", "vector": [13, 3, 0.9906, 0.0094, 3, 0.78, 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_98845:Return_L106_C8", "label": "return", "type": "return", "loc": [106, 106], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98845:FunctionDef_L94_C4", "vector": [13, 2, 1.0, 0.0094, 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 True"}]
[{"f": "ajibawa-2023/Python-Code-Large/train/row_98845:ClassDef_L11_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98845:Expr_L12_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98845:ClassDef_L11_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98845:FunctionDef_L15_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98845:FunctionDef_L15_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98845:Expr_L17_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98845:FunctionDef_L15_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98845:Assign_L18_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98845:FunctionDef_L15_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98845:Assign_L19_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98845:FunctionDef_L15_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98845:Assign_L20_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98845:FunctionDef_L15_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98845:Assign_L21_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98845:FunctionDef_L15_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98845:If_L22_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98845:If_L22_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98845:Assign_L23_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98845:If_L22_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98845:Assign_L25_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98845:FunctionDef_L15_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98845:Assign_L26_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98845:FunctionDef_L15_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98845:Assign_L27_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98845:ClassDef_L11_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98845:FunctionDef_L29_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98845:FunctionDef_L29_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98845:Expr_L30_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98845:FunctionDef_L29_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98845:If_L34_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98845:If_L34_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98845:Return_L36_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98845:FunctionDef_L29_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98845:Try_L37_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98845:Try_L37_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98845:Assign_L40_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98845:Try_L37_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98845:If_L42_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98845:If_L42_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98845:Expr_L43_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98845:If_L42_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98845:Expr_L44_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98845:If_L42_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98845:Expr_L45_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98845:Try_L37_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98845:If_L46_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98845:If_L46_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98845:Expr_L47_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98845:Try_L37_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98845:Return_L48_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98845:Try_L37_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98845:If_L50_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98845:ClassDef_L11_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98845:FunctionDef_L53_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98845:FunctionDef_L53_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98845:Expr_L54_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98845:FunctionDef_L53_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98845:Try_L55_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98845:Try_L55_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98845:Try_L56_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98845:Try_L56_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98845:Expr_L57_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98845:Try_L56_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98845:Expr_L61_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98845:Try_L56_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98845:If_L63_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98845:If_L63_C16", "t": "ajibawa-2023/Python-Code-Large/train/row_98845:Return_L64_C20"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98845:Try_L55_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98845:Assign_L67_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98845:ClassDef_L11_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98845:FunctionDef_L69_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98845:FunctionDef_L69_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98845:Expr_L70_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98845:FunctionDef_L69_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98845:If_L74_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98845:If_L74_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98845:Return_L75_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98845:FunctionDef_L69_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98845:Expr_L76_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98845:FunctionDef_L69_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98845:Try_L77_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98845:Try_L77_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98845:Assign_L78_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98845:Try_L77_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98845:If_L79_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98845:If_L79_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98845:Return_L82_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98845:Try_L77_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98845:Assign_L83_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98845:Try_L77_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98845:For_L84_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98845:For_L84_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98845:Assign_L85_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98845:For_L84_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98845:If_L86_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98845:Try_L77_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98845:If_L88_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98845:If_L88_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98845:Expr_L89_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98845:Try_L77_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98845:Expr_L91_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98845:FunctionDef_L69_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98845:Return_L92_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98845:ClassDef_L11_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98845:FunctionDef_L94_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98845:FunctionDef_L94_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98845:Expr_L95_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98845:FunctionDef_L94_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98845:If_L96_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98845:If_L96_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98845:Return_L97_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98845:FunctionDef_L94_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98845:Try_L98_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98845:Try_L98_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98845:Expr_L99_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98845:Try_L98_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98845:If_L103_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98845:Try_L98_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98845:Return_L105_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98845:FunctionDef_L94_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98845:Return_L106_C8"}]
"""Base email backend class.""" class BaseEmailBackend(object): """ Base class for email backend implementations. Subclasses must at least overwrite send_messages(). """ def __init__(self, fail_silently=False, **kwargs): self.fail_silently = fail_silently def open(self): """Open a network connection. This method can be overwritten by backend implementations to open a network connection. It's up to the backend implementation to track the status of a network connection if it's needed by the backend. This method can be called by applications to force a single network connection to be used when sending mails. See the send_messages() method of the SMTP backend for a reference implementation. The default implementation does nothing. """ pass def close(self): """Close a network connection.""" pass def send_messages(self, email_messages): """ Sends one or more EmailMessage objects and returns the number of email messages sent. """ raise NotImplementedError
ajibawa-2023/Python-Code-Large/train/row_98846
11
39
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_98846:Expr_L1_C0", "label": "expression", "type": "expression", "loc": [1, 1], "level": 0, "parent": null, "vector": [8, 0, 0.0256, 0.0256, 0, 0.66, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "\"\"\"Base email backend class.\"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98846:ClassDef_L3_C0", "label": "BaseEmailBackend", "type": "class", "loc": [3, 39], "level": 0, "parent": null, "vector": [3, 0, 0.5385, 0.9487, 0, 0.66, 1.0, 507, 0, 4, 0, 0, 186, 0, 0], "semantic": {"name": "BaseEmailBackend", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class BaseEmailBackend(object):\n \"\"\"\n Base class for email backend implementations.\n\n Subclasses must at least overwrite send_messages().\n \"\"\"\n def __init__(self, fail_silently=False, **kwargs):\n self.fail_silently = fail_silently"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98846:Expr_L4_C4", "label": "expression", "type": "expression", "loc": [4, 8], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98846:ClassDef_L3_C0", "vector": [8, 1, 0.1538, 0.1282, 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 Base class for email backend implementations.\n\n Subclasses must at least overwrite send_messages().\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98846:FunctionDef_L9_C4", "label": "__init__", "type": "function", "loc": [9, 10], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98846:ClassDef_L3_C0", "vector": [2, 1, 0.2436, 0.0513, 1, 0.04, 0.25, 555, 0, 3, 0, 0, 0, 0, 0], "semantic": {"name": "__init__", "arg_names": ["self", "fail_silently", "kwargs"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def __init__(self, fail_silently=False, **kwargs):\n self.fail_silently = fail_silently"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98846:Assign_L10_C8", "label": "self.fail_silently =", "type": "assigned_variable", "loc": [10, 10], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98846:FunctionDef_L9_C4", "vector": [14, 2, 0.2564, 0.0256, 2, 0.02, 0.0, 759, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "self.fail_silently", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.fail_silently = fail_silently"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98846:FunctionDef_L12_C4", "label": "open", "type": "function", "loc": [12, 28], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98846:ClassDef_L3_C0", "vector": [2, 1, 0.5128, 0.4359, 1, 0.04, 0.5, 693, 0, 1, 0, 0, 0, 0, 0], "semantic": {"name": "open", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def open(self):\n \"\"\"Open a network connection.\n\n This method can be overwritten by backend implementations to\n open a network connection.\n\n It's up to the backend implementation to track the status of\n a network connection if it's needed by the backend."}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98846:Expr_L13_C8", "label": "expression", "type": "expression", "loc": [13, 27], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98846:FunctionDef_L12_C4", "vector": [8, 2, 0.5128, 0.3846, 2, 0.8, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"Open a network connection.\n\n This method can be overwritten by backend implementations to\n open a network connection.\n\n It's up to the backend implementation to track the status of\n a network connection if it's needed by the backend.\n"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98846:FunctionDef_L30_C4", "label": "close", "type": "function", "loc": [30, 32], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98846:ClassDef_L3_C0", "vector": [2, 1, 0.7949, 0.0769, 1, 0.04, 0.75, 77, 0, 1, 0, 0, 0, 0, 0], "semantic": {"name": "close", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def close(self):\n \"\"\"Close a network connection.\"\"\"\n pass"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98846:Expr_L31_C8", "label": "expression", "type": "expression", "loc": [31, 31], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98846:FunctionDef_L30_C4", "vector": [8, 2, 0.7949, 0.0256, 2, 0.21, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"Close a network connection.\"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98846:FunctionDef_L34_C4", "label": "send_messages", "type": "function", "loc": [34, 39], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98846:ClassDef_L3_C0", "vector": [2, 1, 0.9359, 0.1538, 1, 0.04, 1.0, 655, 0, 2, 0, 0, 0, 0, 0], "semantic": {"name": "send_messages", "arg_names": ["self", "email_messages"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def send_messages(self, email_messages):\n \"\"\"\n Sends one or more EmailMessage objects and returns the number of email\n messages sent.\n \"\"\"\n raise NotImplementedError"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98846:Expr_L35_C8", "label": "expression", "type": "expression", "loc": [35, 38], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98846:FunctionDef_L34_C4", "vector": [8, 2, 0.9359, 0.1026, 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 Sends one or more EmailMessage objects and returns the number of email\n messages sent.\n \"\"\""}]
[{"f": "ajibawa-2023/Python-Code-Large/train/row_98846:ClassDef_L3_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98846:Expr_L4_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98846:ClassDef_L3_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98846:FunctionDef_L9_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98846:FunctionDef_L9_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98846:Assign_L10_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98846:ClassDef_L3_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98846:FunctionDef_L12_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98846:FunctionDef_L12_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98846:Expr_L13_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98846:ClassDef_L3_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98846:FunctionDef_L30_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98846:FunctionDef_L30_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98846:Expr_L31_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98846:ClassDef_L3_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98846:FunctionDef_L34_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98846:FunctionDef_L34_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98846:Expr_L35_C8"}]
# Mail backends shipped with Django.
ajibawa-2023/Python-Code-Large/train/row_98847
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"]
[]
[]
""" Backend for test environment. """ from django.core import mail from django.core.mail.backends.base import BaseEmailBackend class EmailBackend(BaseEmailBackend): """A email backend for use during test sessions. The test connection stores email messages in a dummy outbox, rather than sending them out on the wire. The dummy outbox is accessible through the outbox instance attribute. """ def __init__(self, *args, **kwargs): super(EmailBackend, self).__init__(*args, **kwargs) if not hasattr(mail, 'outbox'): mail.outbox = [] def send_messages(self, messages): """Redirect messages to the dummy outbox""" mail.outbox.extend(messages) return len(messages)
ajibawa-2023/Python-Code-Large/train/row_98848
13
24
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_98848:Expr_L1_C0", "label": "expression", "type": "expression", "loc": [1, 3], "level": 0, "parent": null, "vector": [8, 0, 0.0833, 0.125, 0, 0.66, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "\"\"\"\nBackend for test environment.\n\"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98848:ImportFrom_L5_C0", "label": "from django.core import mail", "type": "import", "loc": [5, 5], "level": 0, "parent": null, "vector": [1, 0, 0.2083, 0.0417, 0, 0.66, 0.3333, 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_98848:ImportFrom_L6_C0", "label": "from django.core.mail.backends.base import BaseEmailBackend", "type": "import", "loc": [6, 6], "level": 0, "parent": null, "vector": [1, 0, 0.25, 0.0417, 0, 0.66, 0.6667, 502, 0, 1, 0, 0, 502, 0, 0], "semantic": {"name": "django.core.mail.backends.base", "arg_names": [], "import_names": ["BaseEmailBackend"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.core.mail.backends.base import BaseEmailBackend"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98848:ClassDef_L8_C0", "label": "EmailBackend", "type": "class", "loc": [8, 24], "level": 0, "parent": null, "vector": [3, 0, 0.6667, 0.7083, 0, 0.66, 1.0, 635, 0, 2, 0, 0, 507, 0, 5], "semantic": {"name": "EmailBackend", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class EmailBackend(BaseEmailBackend):\n \"\"\"A email backend for use during test sessions.\n\n The test connection stores email messages in a dummy outbox,\n rather than sending them out on the wire.\n\n The dummy outbox is accessible through the outbox instance attribute.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98848:Expr_L9_C4", "label": "expression", "type": "expression", "loc": [9, 15], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98848:ClassDef_L8_C0", "vector": [8, 1, 0.5, 0.2917, 1, 0.14, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"A email backend for use during test sessions.\n\n The test connection stores email messages in a dummy outbox,\n rather than sending them out on the wire.\n\n The dummy outbox is accessible through the outbox instance attribute.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98848:FunctionDef_L16_C4", "label": "__init__", "type": "function", "loc": [16, 19], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98848:ClassDef_L8_C0", "vector": [2, 1, 0.7292, 0.1667, 1, 0.14, 0.5, 555, 0, 3, 0, 0, 0, 0, 3], "semantic": {"name": "__init__", "arg_names": ["self", "args", "kwargs"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def __init__(self, *args, **kwargs):\n super(EmailBackend, self).__init__(*args, **kwargs)\n if not hasattr(mail, 'outbox'):\n mail.outbox = []"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98848:Expr_L17_C8", "label": "__init__()", "type": "expression", "loc": [17, 17], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98848:FunctionDef_L16_C4", "vector": [8, 2, 0.7083, 0.0417, 2, 0.67, 0.0, 555, 3, 2, 0, 0, 0, 0, 2], "semantic": {"name": "__init__", "arg_names": [], "import_names": [], "rhs_call_name": "__init__", "annotation": ""}, "snippet": " super(EmailBackend, self).__init__(*args, **kwargs)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98848:If_L18_C8", "label": "if", "type": "if", "loc": [18, 19], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98848:FunctionDef_L16_C4", "vector": [4, 2, 0.7708, 0.0833, 2, 0.67, 1.0, 0, 0, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if not hasattr(mail, 'outbox'):\n mail.outbox = []"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98848:Assign_L19_C12", "label": "mail.outbox =", "type": "assigned_variable", "loc": [19, 19], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98848:If_L18_C8", "vector": [14, 3, 0.7917, 0.0417, 3, 0.78, 0.0, 227, 0, 0, 0, 0, 0, 5, 0], "semantic": {"name": "mail.outbox", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " mail.outbox = []"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98848:FunctionDef_L21_C4", "label": "send_messages", "type": "function", "loc": [21, 24], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98848:ClassDef_L8_C0", "vector": [2, 1, 0.9375, 0.1667, 1, 0.14, 1.0, 655, 0, 2, 1, 0, 0, 0, 2], "semantic": {"name": "send_messages", "arg_names": ["self", "messages"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def send_messages(self, messages):\n \"\"\"Redirect messages to the dummy outbox\"\"\"\n mail.outbox.extend(messages)\n return len(messages)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98848:Expr_L22_C8", "label": "expression", "type": "expression", "loc": [22, 22], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98848:FunctionDef_L21_C4", "vector": [8, 2, 0.9167, 0.0417, 2, 0.83, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"Redirect messages to the dummy outbox\"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98848:Expr_L23_C8", "label": "extend()", "type": "expression", "loc": [23, 23], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98848:FunctionDef_L21_C4", "vector": [8, 2, 0.9583, 0.0417, 2, 0.83, 0.5, 660, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "extend", "arg_names": [], "import_names": [], "rhs_call_name": "extend", "annotation": ""}, "snippet": " mail.outbox.extend(messages)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98848:Return_L24_C8", "label": "return", "type": "return", "loc": [24, 24], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98848:FunctionDef_L21_C4", "vector": [13, 2, 1.0, 0.0417, 2, 0.83, 1.0, 0, 3, 0, 0, 0, 0, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return len(messages)"}]
[{"f": "ajibawa-2023/Python-Code-Large/train/row_98848:ClassDef_L8_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98848:Expr_L9_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98848:ClassDef_L8_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98848:FunctionDef_L16_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98848:FunctionDef_L16_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98848:Expr_L17_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98848:FunctionDef_L16_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98848:If_L18_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98848:If_L18_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98848:Assign_L19_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98848:ClassDef_L8_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98848:FunctionDef_L21_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98848:FunctionDef_L21_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98848:Expr_L22_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98848:FunctionDef_L21_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98848:Expr_L23_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98848:FunctionDef_L21_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98848:Return_L24_C8"}]
import os from pprint import pformat import sys from warnings import warn from django import http from django.core import signals from django.core.handlers.base import BaseHandler from django.core.urlresolvers import set_script_prefix from django.utils import datastructures from django.utils.encoding import force_unicode, smart_str, iri_to_uri from django.utils.log import getLogger logger = getLogger('django.request') # NOTE: do *not* import settings (or any module which eventually imports # settings) until after ModPythonHandler has been called; otherwise os.environ # won't be set up correctly (with respect to settings). class ModPythonRequest(http.HttpRequest): def __init__(self, req): self._req = req # FIXME: This isn't ideal. The request URI may be encoded (it's # non-normalized) slightly differently to the "real" SCRIPT_NAME # and PATH_INFO values. This causes problems when we compute path_info, # below. For now, don't use script names that will be subject to # encoding/decoding. self.path = force_unicode(req.uri) root = req.get_options().get('django.root', '') self.django_root = root # req.path_info isn't necessarily computed correctly in all # circumstances (it's out of mod_python's control a bit), so we use # req.uri and some string manipulations to get the right value. if root and req.uri.startswith(root): self.path_info = force_unicode(req.uri[len(root):]) else: self.path_info = self.path if not self.path_info: # Django prefers empty paths to be '/', rather than '', to give us # a common start character for URL patterns. So this is a little # naughty, but also pretty harmless. self.path_info = u'/' self._post_parse_error = False self._stream = self._req self._read_started = False def __repr__(self): # Since this is called as part of error handling, we need to be very # robust against potentially malformed input. try: get = pformat(self.GET) except: get = '<could not parse>' if self._post_parse_error: post = '<could not parse>' else: try: post = pformat(self.POST) except: post = '<could not parse>' try: cookies = pformat(self.COOKIES) except: cookies = '<could not parse>' try: meta = pformat(self.META) except: meta = '<could not parse>' return smart_str(u'<ModPythonRequest\npath:%s,\nGET:%s,\nPOST:%s,\nCOOKIES:%s,\nMETA:%s>' % (self.path, unicode(get), unicode(post), unicode(cookies), unicode(meta))) def get_full_path(self): # RFC 3986 requires self._req.args to be in the ASCII range, but this # doesn't always happen, so rather than crash, we defensively encode it. return '%s%s' % (self.path, self._req.args and ('?' + iri_to_uri(self._req.args)) or '') def is_secure(self): try: return self._req.is_https() except AttributeError: # mod_python < 3.2.10 doesn't have req.is_https(). return self._req.subprocess_env.get('HTTPS', '').lower() in ('on', '1') def _get_request(self): if not hasattr(self, '_request'): self._request = datastructures.MergeDict(self.POST, self.GET) return self._request def _get_get(self): if not hasattr(self, '_get'): self._get = http.QueryDict(self._req.args, encoding=self._encoding) return self._get def _set_get(self, get): self._get = get def _get_post(self): if not hasattr(self, '_post'): self._load_post_and_files() return self._post def _set_post(self, post): self._post = post def _get_cookies(self): if not hasattr(self, '_cookies'): self._cookies = http.parse_cookie(self._req.headers_in.get('cookie', '')) return self._cookies def _set_cookies(self, cookies): self._cookies = cookies def _get_files(self): if not hasattr(self, '_files'): self._load_post_and_files() return self._files def _get_meta(self): "Lazy loader that returns self.META dictionary" if not hasattr(self, '_meta'): self._meta = { 'AUTH_TYPE': self._req.ap_auth_type, 'CONTENT_LENGTH': self._req.headers_in.get('content-length', 0), 'CONTENT_TYPE': self._req.headers_in.get('content-type'), 'GATEWAY_INTERFACE': 'CGI/1.1', 'PATH_INFO': self.path_info, 'PATH_TRANSLATED': None, # Not supported 'QUERY_STRING': self._req.args, 'REMOTE_ADDR': self._req.connection.remote_ip, 'REMOTE_HOST': None, # DNS lookups not supported 'REMOTE_IDENT': self._req.connection.remote_logname, 'REMOTE_USER': self._req.user, 'REQUEST_METHOD': self._req.method, 'SCRIPT_NAME': self.django_root, 'SERVER_NAME': self._req.server.server_hostname, 'SERVER_PORT': self._req.connection.local_addr[1], 'SERVER_PROTOCOL': self._req.protocol, 'SERVER_SOFTWARE': 'mod_python' } for key, value in self._req.headers_in.items(): key = 'HTTP_' + key.upper().replace('-', '_') self._meta[key] = value return self._meta def _get_method(self): return self.META['REQUEST_METHOD'].upper() GET = property(_get_get, _set_get) POST = property(_get_post, _set_post) COOKIES = property(_get_cookies, _set_cookies) FILES = property(_get_files) META = property(_get_meta) REQUEST = property(_get_request) method = property(_get_method) class ModPythonHandler(BaseHandler): request_class = ModPythonRequest def __call__(self, req): warn(('The mod_python handler is deprecated; use a WSGI or FastCGI server instead.'), PendingDeprecationWarning) # mod_python fakes the environ, and thus doesn't process SetEnv. This fixes that os.environ.update(req.subprocess_env) # now that the environ works we can see the correct settings, so imports # that use settings now can work from django.conf import settings # if we need to set up middleware, now that settings works we can do it now. if self._request_middleware is None: self.load_middleware() set_script_prefix(req.get_options().get('django.root', '')) signals.request_started.send(sender=self.__class__) try: try: request = self.request_class(req) except UnicodeDecodeError: logger.warning('Bad Request (UnicodeDecodeError): %s' % request.path, exc_info=sys.exc_info(), extra={ 'status_code': 400, 'request': request } ) response = http.HttpResponseBadRequest() else: response = self.get_response(request) finally: signals.request_finished.send(sender=self.__class__) # Convert our custom HttpResponse object back into the mod_python req. req.content_type = response['Content-Type'] for key, value in response.items(): if key != 'content-type': req.headers_out[str(key)] = str(value) for c in response.cookies.values(): req.headers_out.add('Set-Cookie', c.output(header='')) req.status = response.status_code try: for chunk in response: req.write(chunk) finally: response.close() return 0 # mod_python.apache.OK def handler(req): # mod_python hooks into this function. return ModPythonHandler()(req)
ajibawa-2023/Python-Code-Large/train/row_98851
122
213
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_98851:Import_L1_C0", "label": "os import os", "type": "import", "loc": [1, 1], "level": 0, "parent": null, "vector": [1, 0, 0.0047, 0.0047, 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_98851:ImportFrom_L2_C0", "label": "from pprint import pformat", "type": "import", "loc": [2, 2], "level": 0, "parent": null, "vector": [1, 0, 0.0094, 0.0047, 0, 0.66, 0.0714, 276, 0, 1, 0, 0, 276, 0, 0], "semantic": {"name": "pprint", "arg_names": [], "import_names": ["pformat"], "rhs_call_name": "", "annotation": ""}, "snippet": "from pprint import pformat"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98851:Import_L3_C0", "label": "sys import sys", "type": "import", "loc": [3, 3], "level": 0, "parent": null, "vector": [1, 0, 0.0141, 0.0047, 0, 0.66, 0.1429, 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_98851:ImportFrom_L4_C0", "label": "from warnings import warn", "type": "import", "loc": [4, 4], "level": 0, "parent": null, "vector": [1, 0, 0.0188, 0.0047, 0, 0.66, 0.2143, 358, 0, 1, 0, 0, 358, 0, 0], "semantic": {"name": "warnings", "arg_names": [], "import_names": ["warn"], "rhs_call_name": "", "annotation": ""}, "snippet": "from warnings import warn"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98851:ImportFrom_L6_C0", "label": "from django import http", "type": "import", "loc": [6, 6], "level": 0, "parent": null, "vector": [1, 0, 0.0282, 0.0047, 0, 0.66, 0.2857, 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_98851:ImportFrom_L7_C0", "label": "from django.core import signals", "type": "import", "loc": [7, 7], "level": 0, "parent": null, "vector": [1, 0, 0.0329, 0.0047, 0, 0.66, 0.3571, 913, 0, 1, 0, 0, 913, 0, 0], "semantic": {"name": "django.core", "arg_names": [], "import_names": ["signals"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.core import signals"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98851:ImportFrom_L8_C0", "label": "from django.core.handlers.base import BaseHandler", "type": "import", "loc": [8, 8], "level": 0, "parent": null, "vector": [1, 0, 0.0376, 0.0047, 0, 0.66, 0.4286, 301, 0, 1, 0, 0, 301, 0, 0], "semantic": {"name": "django.core.handlers.base", "arg_names": [], "import_names": ["BaseHandler"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.core.handlers.base import BaseHandler"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98851:ImportFrom_L9_C0", "label": "from django.core.urlresolvers import set_script_prefix", "type": "import", "loc": [9, 9], "level": 0, "parent": null, "vector": [1, 0, 0.0423, 0.0047, 0, 0.66, 0.5, 749, 0, 1, 0, 0, 749, 0, 0], "semantic": {"name": "django.core.urlresolvers", "arg_names": [], "import_names": ["set_script_prefix"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.core.urlresolvers import set_script_prefix"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98851:ImportFrom_L10_C0", "label": "from django.utils import datastructures", "type": "import", "loc": [10, 10], "level": 0, "parent": null, "vector": [1, 0, 0.0469, 0.0047, 0, 0.66, 0.5714, 944, 0, 1, 0, 0, 944, 0, 0], "semantic": {"name": "django.utils", "arg_names": [], "import_names": ["datastructures"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.utils import datastructures"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98851:ImportFrom_L11_C0", "label": "from django.utils.encoding import force_unicode, smart_str, iri_to_uri", "type": "import", "loc": [11, 11], "level": 0, "parent": null, "vector": [1, 0, 0.0516, 0.0047, 0, 0.66, 0.6429, 96, 0, 3, 0, 0, 96, 0, 0], "semantic": {"name": "django.utils.encoding", "arg_names": [], "import_names": ["force_unicode", "smart_str", "iri_to_uri"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.utils.encoding import force_unicode, smart_str, iri_to_uri"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98851:ImportFrom_L12_C0", "label": "from django.utils.log import getLogger", "type": "import", "loc": [12, 12], "level": 0, "parent": null, "vector": [1, 0, 0.0563, 0.0047, 0, 0.66, 0.7143, 174, 0, 1, 0, 0, 174, 0, 0], "semantic": {"name": "django.utils.log", "arg_names": [], "import_names": ["getLogger"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.utils.log import getLogger"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98851:Assign_L14_C0", "label": "logger = getLogger()", "type": "assigned_variable", "loc": [14, 14], "level": 0, "parent": null, "vector": [14, 0, 0.0657, 0.0047, 0, 0.66, 0.7857, 532, 3, 1, 0, 0, 71, 10, 1], "semantic": {"name": "logger", "arg_names": [], "import_names": [], "rhs_call_name": "getLogger", "annotation": ""}, "snippet": "logger = getLogger('django.request')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98851:ClassDef_L21_C0", "label": "ModPythonRequest", "type": "class", "loc": [21, 156], "level": 0, "parent": null, "vector": [3, 0, 0.4155, 0.6385, 0, 0.66, 0.8571, 492, 0, 14, 0, 0, 764, 0, 44], "semantic": {"name": "ModPythonRequest", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class ModPythonRequest(http.HttpRequest):\n def __init__(self, req):\n self._req = req\n # FIXME: This isn't ideal. The request URI may be encoded (it's\n # non-normalized) slightly differently to the \"real\" SCRIPT_NAME\n # and PATH_INFO values. This causes problems when we compute path_info,\n # below. For now, don't use script names that will be subject to\n # encoding/decoding."}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98851:FunctionDef_L22_C4", "label": "__init__", "type": "function", "loc": [22, 46], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98851:ClassDef_L21_C0", "vector": [2, 1, 0.1596, 0.1174, 1, 0.56, 0.0, 555, 0, 2, 0, 0, 0, 0, 6], "semantic": {"name": "__init__", "arg_names": ["self", "req"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def __init__(self, req):\n self._req = req\n # FIXME: This isn't ideal. The request URI may be encoded (it's\n # non-normalized) slightly differently to the \"real\" SCRIPT_NAME\n # and PATH_INFO values. This causes problems when we compute path_info,\n # below. For now, don't use script names that will be subject to\n # encoding/decoding.\n self.path = force_unicode(req.uri)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98851:Assign_L23_C8", "label": "self._req =", "type": "assigned_variable", "loc": [23, 23], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98851:FunctionDef_L22_C4", "vector": [14, 2, 0.108, 0.0047, 2, 0.39, 0.0, 712, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "self._req", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self._req = req"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98851:Assign_L29_C8", "label": "self.path = force_unicode()", "type": "assigned_variable", "loc": [29, 29], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98851:FunctionDef_L22_C4", "vector": [14, 2, 0.1362, 0.0047, 2, 0.39, 0.125, 425, 3, 1, 0, 0, 870, 10, 1], "semantic": {"name": "self.path", "arg_names": [], "import_names": [], "rhs_call_name": "force_unicode", "annotation": ""}, "snippet": " self.path = force_unicode(req.uri)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98851:Assign_L30_C8", "label": "root = get()", "type": "assigned_variable", "loc": [30, 30], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98851:FunctionDef_L22_C4", "vector": [14, 2, 0.1408, 0.0047, 2, 0.39, 0.25, 696, 3, 2, 0, 0, 607, 10, 2], "semantic": {"name": "root", "arg_names": [], "import_names": [], "rhs_call_name": "get", "annotation": ""}, "snippet": " root = req.get_options().get('django.root', '')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98851:Assign_L31_C8", "label": "self.django_root =", "type": "assigned_variable", "loc": [31, 31], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98851:FunctionDef_L22_C4", "vector": [14, 2, 0.1455, 0.0047, 2, 0.39, 0.375, 845, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "self.django_root", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.django_root = root"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98851:If_L35_C8", "label": "if", "type": "if", "loc": [35, 38], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98851:FunctionDef_L22_C4", "vector": [4, 2, 0.1714, 0.0188, 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 root and req.uri.startswith(root):\n self.path_info = force_unicode(req.uri[len(root):])\n else:\n self.path_info = self.path"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98851:Assign_L36_C12", "label": "self.path_info = force_unicode()", "type": "assigned_variable", "loc": [36, 36], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98851:If_L35_C8", "vector": [14, 3, 0.169, 0.0047, 3, 0.73, 0.0, 442, 3, 1, 0, 0, 870, 10, 2], "semantic": {"name": "self.path_info", "arg_names": [], "import_names": [], "rhs_call_name": "force_unicode", "annotation": ""}, "snippet": " self.path_info = force_unicode(req.uri[len(root):])"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98851:Assign_L38_C12", "label": "self.path_info =", "type": "assigned_variable", "loc": [38, 38], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98851:If_L35_C8", "vector": [14, 3, 0.1784, 0.0047, 3, 0.73, 1.0, 442, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "self.path_info", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.path_info = self.path"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98851:If_L39_C8", "label": "if", "type": "if", "loc": [39, 43], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98851:FunctionDef_L22_C4", "vector": [4, 2, 0.1925, 0.0235, 2, 0.39, 0.625, 0, 0, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if not self.path_info:\n # Django prefers empty paths to be '/', rather than '', to give us\n # a common start character for URL patterns. So this is a little\n # naughty, but also pretty harmless.\n self.path_info = u'/'"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98851:Assign_L43_C12", "label": "self.path_info =", "type": "assigned_variable", "loc": [43, 43], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98851:If_L39_C8", "vector": [14, 3, 0.2019, 0.0047, 3, 0.08, 0.0, 442, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "self.path_info", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.path_info = u'/'"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98851:Assign_L44_C8", "label": "self._post_parse_error =", "type": "assigned_variable", "loc": [44, 44], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98851:FunctionDef_L22_C4", "vector": [14, 2, 0.2066, 0.0047, 2, 0.39, 0.75, 977, 1, 0, 0, 0, 0, 4, 0], "semantic": {"name": "self._post_parse_error", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self._post_parse_error = False"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98851:Assign_L45_C8", "label": "self._stream =", "type": "assigned_variable", "loc": [45, 45], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98851:FunctionDef_L22_C4", "vector": [14, 2, 0.2113, 0.0047, 2, 0.39, 0.875, 214, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "self._stream", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self._stream = self._req"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98851:Assign_L46_C8", "label": "self._read_started =", "type": "assigned_variable", "loc": [46, 46], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98851:FunctionDef_L22_C4", "vector": [14, 2, 0.216, 0.0047, 2, 0.39, 1.0, 430, 1, 0, 0, 0, 0, 4, 0], "semantic": {"name": "self._read_started", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self._read_started = False"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98851:FunctionDef_L48_C4", "label": "__repr__", "type": "function", "loc": [48, 72], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98851:ClassDef_L21_C0", "vector": [2, 1, 0.2817, 0.1174, 1, 0.56, 0.05, 204, 0, 1, 1, 0, 0, 0, 9], "semantic": {"name": "__repr__", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def __repr__(self):\n # Since this is called as part of error handling, we need to be very\n # robust against potentially malformed input.\n try:\n get = pformat(self.GET)\n except:\n get = '<could not parse>'\n if self._post_parse_error:"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98851:Try_L51_C8", "label": "try", "type": "try", "loc": [51, 54], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98851:FunctionDef_L48_C4", "vector": [7, 2, 0.2465, 0.0188, 2, 0.03, 0.0, 0, 0, 1, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " try:\n get = pformat(self.GET)\n except:\n get = '<could not parse>'"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98851:Assign_L52_C12", "label": "get = pformat()", "type": "assigned_variable", "loc": [52, 52], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98851:Try_L51_C8", "vector": [14, 3, 0.2441, 0.0047, 3, 0.75, 0.0, 607, 3, 1, 0, 0, 479, 10, 1], "semantic": {"name": "get", "arg_names": [], "import_names": [], "rhs_call_name": "pformat", "annotation": ""}, "snippet": " get = pformat(self.GET)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98851:Assign_L54_C12", "label": "get =", "type": "assigned_variable", "loc": [54, 54], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98851:Try_L51_C8", "vector": [14, 3, 0.2535, 0.0047, 3, 0.75, 0.0, 607, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "get", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " get = '<could not parse>'"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98851:If_L55_C8", "label": "if", "type": "if", "loc": [55, 61], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98851:FunctionDef_L48_C4", "vector": [4, 2, 0.2723, 0.0329, 2, 0.03, 0.25, 0, 7, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if self._post_parse_error:\n post = '<could not parse>'\n else:\n try:\n post = pformat(self.POST)\n except:\n post = '<could not parse>'"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98851:Assign_L56_C12", "label": "post =", "type": "assigned_variable", "loc": [56, 56], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98851:If_L55_C8", "vector": [14, 3, 0.2629, 0.0047, 3, 0.04, 0.0, 304, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "post", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " post = '<could not parse>'"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98851:Try_L58_C12", "label": "try", "type": "try", "loc": [58, 61], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98851:If_L55_C8", "vector": [7, 3, 0.2793, 0.0188, 3, 0.04, 1.0, 0, 0, 1, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " try:\n post = pformat(self.POST)\n except:\n post = '<could not parse>'"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98851:Assign_L59_C16", "label": "post = pformat()", "type": "assigned_variable", "loc": [59, 59], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98851:Try_L58_C12", "vector": [14, 4, 0.277, 0.0047, 4, 0.35, 0.0, 304, 3, 1, 0, 0, 479, 10, 1], "semantic": {"name": "post", "arg_names": [], "import_names": [], "rhs_call_name": "pformat", "annotation": ""}, "snippet": " post = pformat(self.POST)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98851:Assign_L61_C16", "label": "post =", "type": "assigned_variable", "loc": [61, 61], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98851:Try_L58_C12", "vector": [14, 4, 0.2864, 0.0047, 4, 0.35, 0.0, 304, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "post", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " post = '<could not parse>'"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98851:Try_L62_C8", "label": "try", "type": "try", "loc": [62, 65], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98851:FunctionDef_L48_C4", "vector": [7, 2, 0.2981, 0.0188, 2, 0.03, 0.5, 0, 0, 1, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " try:\n cookies = pformat(self.COOKIES)\n except:\n cookies = '<could not parse>'"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98851:Assign_L63_C12", "label": "cookies = pformat()", "type": "assigned_variable", "loc": [63, 63], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98851:Try_L62_C8", "vector": [14, 3, 0.2958, 0.0047, 3, 0.33, 0.0, 711, 3, 1, 0, 0, 479, 10, 1], "semantic": {"name": "cookies", "arg_names": [], "import_names": [], "rhs_call_name": "pformat", "annotation": ""}, "snippet": " cookies = pformat(self.COOKIES)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98851:Assign_L65_C12", "label": "cookies =", "type": "assigned_variable", "loc": [65, 65], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98851:Try_L62_C8", "vector": [14, 3, 0.3052, 0.0047, 3, 0.33, 0.0, 711, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "cookies", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " cookies = '<could not parse>'"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98851:Try_L66_C8", "label": "try", "type": "try", "loc": [66, 69], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98851:FunctionDef_L48_C4", "vector": [7, 2, 0.3169, 0.0188, 2, 0.03, 0.75, 0, 0, 1, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " try:\n meta = pformat(self.META)\n except:\n meta = '<could not parse>'"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98851:Assign_L67_C12", "label": "meta = pformat()", "type": "assigned_variable", "loc": [67, 67], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98851:Try_L66_C8", "vector": [14, 3, 0.3146, 0.0047, 3, 0.63, 0.0, 329, 3, 1, 0, 0, 479, 10, 1], "semantic": {"name": "meta", "arg_names": [], "import_names": [], "rhs_call_name": "pformat", "annotation": ""}, "snippet": " meta = pformat(self.META)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98851:Assign_L69_C12", "label": "meta =", "type": "assigned_variable", "loc": [69, 69], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98851:Try_L66_C8", "vector": [14, 3, 0.3239, 0.0047, 3, 0.63, 0.0, 329, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "meta", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " meta = '<could not parse>'"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98851:Return_L70_C8", "label": "return", "type": "return", "loc": [70, 72], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98851:FunctionDef_L48_C4", "vector": [13, 2, 0.3333, 0.0141, 2, 0.03, 1.0, 0, 3, 0, 0, 0, 0, 10, 5], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return smart_str(u'<ModPythonRequest\\npath:%s,\\nGET:%s,\\nPOST:%s,\\nCOOKIES:%s,\\nMETA:%s>' %\n (self.path, unicode(get), unicode(post),\n unicode(cookies), unicode(meta)))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98851:FunctionDef_L74_C4", "label": "get_full_path", "type": "function", "loc": [74, 77], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98851:ClassDef_L21_C0", "vector": [2, 1, 0.3545, 0.0188, 1, 0.56, 0.1, 451, 0, 1, 1, 0, 0, 0, 1], "semantic": {"name": "get_full_path", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def get_full_path(self):\n # RFC 3986 requires self._req.args to be in the ASCII range, but this\n # doesn't always happen, so rather than crash, we defensively encode it.\n return '%s%s' % (self.path, self._req.args and ('?' + iri_to_uri(self._req.args)) or '')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98851:Return_L77_C8", "label": "return", "type": "return", "loc": [77, 77], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98851:FunctionDef_L74_C4", "vector": [13, 2, 0.3615, 0.0047, 2, 0.87, 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.path, self._req.args and ('?' + iri_to_uri(self._req.args)) or '')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98851:FunctionDef_L79_C4", "label": "is_secure", "type": "function", "loc": [79, 84], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98851:ClassDef_L21_C0", "vector": [2, 1, 0.3826, 0.0282, 1, 0.56, 0.15, 797, 0, 1, 1, 0, 0, 0, 3], "semantic": {"name": "is_secure", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def is_secure(self):\n try:\n return self._req.is_https()\n except AttributeError:\n # mod_python < 3.2.10 doesn't have req.is_https().\n return self._req.subprocess_env.get('HTTPS', '').lower() in ('on', '1')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98851:Try_L80_C8", "label": "try", "type": "try", "loc": [80, 84], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98851:FunctionDef_L79_C4", "vector": [7, 2, 0.385, 0.0235, 2, 0.09, 0.0, 0, 0, 1, 0, 0, 0, 0, 3], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " try:\n return self._req.is_https()\n except AttributeError:\n # mod_python < 3.2.10 doesn't have req.is_https().\n return self._req.subprocess_env.get('HTTPS', '').lower() in ('on', '1')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98851:Return_L81_C12", "label": "return", "type": "return", "loc": [81, 81], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98851:Try_L80_C8", "vector": [13, 3, 0.3803, 0.0047, 3, 0.5, 0.0, 0, 3, 0, 0, 0, 0, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return self._req.is_https()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98851:Return_L84_C12", "label": "return", "type": "return", "loc": [84, 84], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98851:Try_L80_C8", "vector": [13, 3, 0.3944, 0.0047, 3, 0.5, 0.0, 0, 0, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return self._req.subprocess_env.get('HTTPS', '').lower() in ('on', '1')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98851:FunctionDef_L86_C4", "label": "_get_request", "type": "function", "loc": [86, 89], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98851:ClassDef_L21_C0", "vector": [2, 1, 0.4108, 0.0188, 1, 0.56, 0.2, 216, 0, 1, 1, 0, 0, 0, 2], "semantic": {"name": "_get_request", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def _get_request(self):\n if not hasattr(self, '_request'):\n self._request = datastructures.MergeDict(self.POST, self.GET)\n return self._request"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98851:If_L87_C8", "label": "if", "type": "if", "loc": [87, 88], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98851:FunctionDef_L86_C4", "vector": [4, 2, 0.4108, 0.0094, 2, 0.48, 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, '_request'):\n self._request = datastructures.MergeDict(self.POST, self.GET)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98851:Assign_L88_C12", "label": "self._request = MergeDict()", "type": "assigned_variable", "loc": [88, 88], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98851:If_L87_C8", "vector": [14, 3, 0.4131, 0.0047, 3, 0.58, 0.0, 149, 3, 2, 0, 0, 14, 10, 1], "semantic": {"name": "self._request", "arg_names": [], "import_names": [], "rhs_call_name": "MergeDict", "annotation": ""}, "snippet": " self._request = datastructures.MergeDict(self.POST, self.GET)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98851:Return_L89_C8", "label": "return", "type": "return", "loc": [89, 89], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98851:FunctionDef_L86_C4", "vector": [13, 2, 0.4178, 0.0047, 2, 0.48, 1.0, 0, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return self._request"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98851:FunctionDef_L91_C4", "label": "_get_get", "type": "function", "loc": [91, 94], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98851:ClassDef_L21_C0", "vector": [2, 1, 0.4343, 0.0188, 1, 0.56, 0.25, 656, 0, 1, 1, 0, 0, 0, 2], "semantic": {"name": "_get_get", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def _get_get(self):\n if not hasattr(self, '_get'):\n self._get = http.QueryDict(self._req.args, encoding=self._encoding)\n return self._get"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98851:If_L92_C8", "label": "if", "type": "if", "loc": [92, 93], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98851:FunctionDef_L91_C4", "vector": [4, 2, 0.4343, 0.0094, 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 not hasattr(self, '_get'):\n self._get = http.QueryDict(self._req.args, encoding=self._encoding)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98851:Assign_L93_C12", "label": "self._get = QueryDict()", "type": "assigned_variable", "loc": [93, 93], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98851:If_L92_C8", "vector": [14, 3, 0.4366, 0.0047, 3, 0.48, 0.0, 338, 3, 2, 0, 0, 457, 10, 1], "semantic": {"name": "self._get", "arg_names": [], "import_names": [], "rhs_call_name": "QueryDict", "annotation": ""}, "snippet": " self._get = http.QueryDict(self._req.args, encoding=self._encoding)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98851:Return_L94_C8", "label": "return", "type": "return", "loc": [94, 94], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98851:FunctionDef_L91_C4", "vector": [13, 2, 0.4413, 0.0047, 2, 0.46, 1.0, 0, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return self._get"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98851:FunctionDef_L96_C4", "label": "_set_get", "type": "function", "loc": [96, 97], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98851:ClassDef_L21_C0", "vector": [2, 1, 0.4531, 0.0094, 1, 0.56, 0.3, 197, 0, 2, 0, 0, 0, 0, 0], "semantic": {"name": "_set_get", "arg_names": ["self", "get"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def _set_get(self, get):\n self._get = get"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98851:Assign_L97_C8", "label": "self._get =", "type": "assigned_variable", "loc": [97, 97], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98851:FunctionDef_L96_C4", "vector": [14, 2, 0.4554, 0.0047, 2, 0.48, 0.0, 338, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "self._get", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self._get = get"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98851:FunctionDef_L99_C4", "label": "_get_post", "type": "function", "loc": [99, 102], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98851:ClassDef_L21_C0", "vector": [2, 1, 0.4718, 0.0188, 1, 0.56, 0.35, 847, 0, 1, 1, 0, 0, 0, 2], "semantic": {"name": "_get_post", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def _get_post(self):\n if not hasattr(self, '_post'):\n self._load_post_and_files()\n return self._post"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98851:If_L100_C8", "label": "if", "type": "if", "loc": [100, 101], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98851:FunctionDef_L99_C4", "vector": [4, 2, 0.4718, 0.0094, 2, 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 hasattr(self, '_post'):\n self._load_post_and_files()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98851:Expr_L101_C12", "label": "_load_post_and_files()", "type": "expression", "loc": [101, 101], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98851:If_L100_C8", "vector": [8, 3, 0.4742, 0.0047, 3, 0.59, 0.0, 153, 3, 0, 0, 0, 0, 0, 1], "semantic": {"name": "_load_post_and_files", "arg_names": [], "import_names": [], "rhs_call_name": "_load_post_and_files", "annotation": ""}, "snippet": " self._load_post_and_files()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98851:Return_L102_C8", "label": "return", "type": "return", "loc": [102, 102], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98851:FunctionDef_L99_C4", "vector": [13, 2, 0.4789, 0.0047, 2, 0.41, 1.0, 0, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return self._post"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98851:FunctionDef_L104_C4", "label": "_set_post", "type": "function", "loc": [104, 105], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98851:ClassDef_L21_C0", "vector": [2, 1, 0.4906, 0.0094, 1, 0.56, 0.4, 591, 0, 2, 0, 0, 0, 0, 0], "semantic": {"name": "_set_post", "arg_names": ["self", "post"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def _set_post(self, post):\n self._post = post"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98851:Assign_L105_C8", "label": "self._post =", "type": "assigned_variable", "loc": [105, 105], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98851:FunctionDef_L104_C4", "vector": [14, 2, 0.493, 0.0047, 2, 0.12, 0.0, 963, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "self._post", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self._post = post"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98851:FunctionDef_L107_C4", "label": "_get_cookies", "type": "function", "loc": [107, 110], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98851:ClassDef_L21_C0", "vector": [2, 1, 0.5094, 0.0188, 1, 0.56, 0.45, 532, 0, 1, 1, 0, 0, 0, 3], "semantic": {"name": "_get_cookies", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def _get_cookies(self):\n if not hasattr(self, '_cookies'):\n self._cookies = http.parse_cookie(self._req.headers_in.get('cookie', ''))\n return self._cookies"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98851:If_L108_C8", "label": "if", "type": "if", "loc": [108, 109], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98851:FunctionDef_L107_C4", "vector": [4, 2, 0.5094, 0.0094, 2, 0.86, 0.0, 0, 0, 0, 0, 0, 0, 0, 3], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if not hasattr(self, '_cookies'):\n self._cookies = http.parse_cookie(self._req.headers_in.get('cookie', ''))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98851:Assign_L109_C12", "label": "self._cookies = parse_cookie()", "type": "assigned_variable", "loc": [109, 109], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98851:If_L108_C8", "vector": [14, 3, 0.5117, 0.0047, 3, 0.77, 0.0, 598, 3, 1, 0, 0, 682, 10, 2], "semantic": {"name": "self._cookies", "arg_names": [], "import_names": [], "rhs_call_name": "parse_cookie", "annotation": ""}, "snippet": " self._cookies = http.parse_cookie(self._req.headers_in.get('cookie', ''))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98851:Return_L110_C8", "label": "return", "type": "return", "loc": [110, 110], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98851:FunctionDef_L107_C4", "vector": [13, 2, 0.5164, 0.0047, 2, 0.86, 1.0, 0, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return self._cookies"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98851:FunctionDef_L112_C4", "label": "_set_cookies", "type": "function", "loc": [112, 113], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98851:ClassDef_L21_C0", "vector": [2, 1, 0.5282, 0.0094, 1, 0.56, 0.5, 492, 0, 2, 0, 0, 0, 0, 0], "semantic": {"name": "_set_cookies", "arg_names": ["self", "cookies"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def _set_cookies(self, cookies):\n self._cookies = cookies"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98851:Assign_L113_C8", "label": "self._cookies =", "type": "assigned_variable", "loc": [113, 113], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98851:FunctionDef_L112_C4", "vector": [14, 2, 0.5305, 0.0047, 2, 0.04, 0.0, 598, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "self._cookies", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self._cookies = cookies"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98851:FunctionDef_L115_C4", "label": "_get_files", "type": "function", "loc": [115, 118], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98851:ClassDef_L21_C0", "vector": [2, 1, 0.5469, 0.0188, 1, 0.56, 0.55, 567, 0, 1, 1, 0, 0, 0, 2], "semantic": {"name": "_get_files", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def _get_files(self):\n if not hasattr(self, '_files'):\n self._load_post_and_files()\n return self._files"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98851:If_L116_C8", "label": "if", "type": "if", "loc": [116, 117], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98851:FunctionDef_L115_C4", "vector": [4, 2, 0.5469, 0.0094, 2, 0.19, 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, '_files'):\n self._load_post_and_files()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98851:Expr_L117_C12", "label": "_load_post_and_files()", "type": "expression", "loc": [117, 117], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98851:If_L116_C8", "vector": [8, 3, 0.5493, 0.0047, 3, 0.48, 0.0, 153, 3, 0, 0, 0, 0, 0, 1], "semantic": {"name": "_load_post_and_files", "arg_names": [], "import_names": [], "rhs_call_name": "_load_post_and_files", "annotation": ""}, "snippet": " self._load_post_and_files()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98851:Return_L118_C8", "label": "return", "type": "return", "loc": [118, 118], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98851:FunctionDef_L115_C4", "vector": [13, 2, 0.554, 0.0047, 2, 0.19, 1.0, 0, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return self._files"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98851:FunctionDef_L120_C4", "label": "_get_meta", "type": "function", "loc": [120, 145], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98851:ClassDef_L21_C0", "vector": [2, 1, 0.6221, 0.1221, 1, 0.56, 0.6, 75, 0, 1, 1, 0, 0, 0, 6], "semantic": {"name": "_get_meta", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def _get_meta(self):\n \"Lazy loader that returns self.META dictionary\"\n if not hasattr(self, '_meta'):\n self._meta = {\n 'AUTH_TYPE': self._req.ap_auth_type,\n 'CONTENT_LENGTH': self._req.headers_in.get('content-length', 0),\n 'CONTENT_TYPE': self._req.headers_in.get('content-type'),\n 'GATEWAY_INTERFACE': 'CGI/1.1',"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98851:Expr_L121_C8", "label": "expression", "type": "expression", "loc": [121, 121], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98851:FunctionDef_L120_C4", "vector": [8, 2, 0.5681, 0.0047, 2, 0.34, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"Lazy loader that returns self.META dictionary\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98851:If_L122_C8", "label": "if", "type": "if", "loc": [122, 144], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98851:FunctionDef_L120_C4", "vector": [4, 2, 0.6244, 0.108, 2, 0.34, 0.5, 0, 0, 0, 0, 0, 0, 0, 6], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if not hasattr(self, '_meta'):\n self._meta = {\n 'AUTH_TYPE': self._req.ap_auth_type,\n 'CONTENT_LENGTH': self._req.headers_in.get('content-length', 0),\n 'CONTENT_TYPE': self._req.headers_in.get('content-type'),\n 'GATEWAY_INTERFACE': 'CGI/1.1',\n 'PATH_INFO': self.path_info,\n 'PATH_TRANSLATED': None, # Not supported"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98851:Assign_L123_C12", "label": "self._meta =", "type": "assigned_variable", "loc": [123, 141], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98851:If_L122_C8", "vector": [14, 3, 0.6197, 0.0892, 3, 0.87, 0.0, 814, 0, 0, 0, 0, 0, 6, 2], "semantic": {"name": "self._meta", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self._meta = {\n 'AUTH_TYPE': self._req.ap_auth_type,\n 'CONTENT_LENGTH': self._req.headers_in.get('content-length', 0),\n 'CONTENT_TYPE': self._req.headers_in.get('content-type'),\n 'GATEWAY_INTERFACE': 'CGI/1.1',\n 'PATH_INFO': self.path_info,\n 'PATH_TRANSLATED': None, # Not supported\n 'QUERY_STRING': self._req.args,"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98851:For_L142_C12", "label": "for key, value", "type": "for", "loc": [142, 144], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98851:If_L122_C8", "vector": [6, 3, 0.6714, 0.0141, 3, 0.87, 1.0, 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 self._req.headers_in.items():\n key = 'HTTP_' + key.upper().replace('-', '_')\n self._meta[key] = value"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98851:Assign_L143_C16", "label": "key =", "type": "assigned_variable", "loc": [143, 143], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98851:For_L142_C12", "vector": [14, 4, 0.6714, 0.0047, 4, 0.58, 0.0, 230, 4, 0, 0, 0, 0, 0, 2], "semantic": {"name": "key", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " key = 'HTTP_' + key.upper().replace('-', '_')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98851:Assign_L144_C16", "label": "assign", "type": "assigned_variable", "loc": [144, 144], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98851:For_L142_C12", "vector": [14, 4, 0.6761, 0.0047, 4, 0.58, 1.0, 0, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self._meta[key] = value"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98851:Return_L145_C8", "label": "return", "type": "return", "loc": [145, 145], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98851:FunctionDef_L120_C4", "vector": [13, 2, 0.6808, 0.0047, 2, 0.34, 1.0, 0, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return self._meta"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98851:FunctionDef_L147_C4", "label": "_get_method", "type": "function", "loc": [147, 148], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98851:ClassDef_L21_C0", "vector": [2, 1, 0.6925, 0.0094, 1, 0.56, 0.65, 195, 0, 1, 1, 0, 0, 0, 1], "semantic": {"name": "_get_method", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def _get_method(self):\n return self.META['REQUEST_METHOD'].upper()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98851:Return_L148_C8", "label": "return", "type": "return", "loc": [148, 148], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98851:FunctionDef_L147_C4", "vector": [13, 2, 0.6948, 0.0047, 2, 0.81, 0.0, 0, 3, 0, 0, 0, 0, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return self.META['REQUEST_METHOD'].upper()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98851:Assign_L150_C4", "label": "GET = property()", "type": "assigned_variable", "loc": [150, 150], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98851:ClassDef_L21_C0", "vector": [14, 1, 0.7042, 0.0047, 1, 0.56, 0.7, 547, 3, 2, 0, 0, 244, 10, 1], "semantic": {"name": "GET", "arg_names": [], "import_names": [], "rhs_call_name": "property", "annotation": ""}, "snippet": " GET = property(_get_get, _set_get)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98851:Assign_L151_C4", "label": "POST = property()", "type": "assigned_variable", "loc": [151, 151], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98851:ClassDef_L21_C0", "vector": [14, 1, 0.7089, 0.0047, 1, 0.56, 0.75, 41, 3, 2, 0, 0, 244, 10, 1], "semantic": {"name": "POST", "arg_names": [], "import_names": [], "rhs_call_name": "property", "annotation": ""}, "snippet": " POST = property(_get_post, _set_post)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98851:Assign_L152_C4", "label": "COOKIES = property()", "type": "assigned_variable", "loc": [152, 152], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98851:ClassDef_L21_C0", "vector": [14, 1, 0.7136, 0.0047, 1, 0.56, 0.8, 266, 3, 2, 0, 0, 244, 10, 1], "semantic": {"name": "COOKIES", "arg_names": [], "import_names": [], "rhs_call_name": "property", "annotation": ""}, "snippet": " COOKIES = property(_get_cookies, _set_cookies)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98851:Assign_L153_C4", "label": "FILES = property()", "type": "assigned_variable", "loc": [153, 153], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98851:ClassDef_L21_C0", "vector": [14, 1, 0.7183, 0.0047, 1, 0.56, 0.85, 870, 3, 1, 0, 0, 244, 10, 1], "semantic": {"name": "FILES", "arg_names": [], "import_names": [], "rhs_call_name": "property", "annotation": ""}, "snippet": " FILES = property(_get_files)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98851:Assign_L154_C4", "label": "META = property()", "type": "assigned_variable", "loc": [154, 154], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98851:ClassDef_L21_C0", "vector": [14, 1, 0.723, 0.0047, 1, 0.56, 0.9, 315, 3, 1, 0, 0, 244, 10, 1], "semantic": {"name": "META", "arg_names": [], "import_names": [], "rhs_call_name": "property", "annotation": ""}, "snippet": " META = property(_get_meta)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98851:Assign_L155_C4", "label": "REQUEST = property()", "type": "assigned_variable", "loc": [155, 155], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98851:ClassDef_L21_C0", "vector": [14, 1, 0.7277, 0.0047, 1, 0.56, 0.95, 991, 3, 1, 0, 0, 244, 10, 1], "semantic": {"name": "REQUEST", "arg_names": [], "import_names": [], "rhs_call_name": "property", "annotation": ""}, "snippet": " REQUEST = property(_get_request)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98851:Assign_L156_C4", "label": "method = property()", "type": "assigned_variable", "loc": [156, 156], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98851:ClassDef_L21_C0", "vector": [14, 1, 0.7324, 0.0047, 1, 0.56, 1.0, 445, 3, 1, 0, 0, 244, 10, 1], "semantic": {"name": "method", "arg_names": [], "import_names": [], "rhs_call_name": "property", "annotation": ""}, "snippet": " method = property(_get_method)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98851:ClassDef_L158_C0", "label": "ModPythonHandler", "type": "class", "loc": [158, 209], "level": 0, "parent": null, "vector": [3, 0, 0.8615, 0.2441, 0, 0.66, 0.9286, 338, 0, 1, 0, 0, 94, 0, 21], "semantic": {"name": "ModPythonHandler", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class ModPythonHandler(BaseHandler):\n request_class = ModPythonRequest\n\n def __call__(self, req):\n warn(('The mod_python handler is deprecated; use a WSGI or FastCGI server instead.'),\n PendingDeprecationWarning)\n\n # mod_python fakes the environ, and thus doesn't process SetEnv. This fixes that"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98851:Assign_L159_C4", "label": "request_class =", "type": "assigned_variable", "loc": [159, 159], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98851:ClassDef_L158_C0", "vector": [14, 1, 0.7465, 0.0047, 1, 0.95, 0.0, 605, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "request_class", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " request_class = ModPythonRequest"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98851:FunctionDef_L161_C4", "label": "__call__", "type": "function", "loc": [161, 209], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98851:ClassDef_L158_C0", "vector": [2, 1, 0.8685, 0.23, 1, 0.95, 1.0, 319, 0, 2, 1, 0, 0, 0, 21], "semantic": {"name": "__call__", "arg_names": ["self", "req"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def __call__(self, req):\n warn(('The mod_python handler is deprecated; use a WSGI or FastCGI server instead.'),\n PendingDeprecationWarning)\n\n # mod_python fakes the environ, and thus doesn't process SetEnv. This fixes that\n os.environ.update(req.subprocess_env)\n\n # now that the environ works we can see the correct settings, so imports"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98851:Expr_L162_C8", "label": "warn()", "type": "expression", "loc": [162, 163], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98851:FunctionDef_L161_C4", "vector": [8, 2, 0.7629, 0.0094, 2, 0.36, 0.0, 960, 3, 2, 0, 0, 0, 0, 1], "semantic": {"name": "warn", "arg_names": [], "import_names": [], "rhs_call_name": "warn", "annotation": ""}, "snippet": " warn(('The mod_python handler is deprecated; use a WSGI or FastCGI server instead.'),\n PendingDeprecationWarning)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98851:Expr_L166_C8", "label": "update()", "type": "expression", "loc": [166, 166], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98851:FunctionDef_L161_C4", "vector": [8, 2, 0.7793, 0.0047, 2, 0.36, 0.0833, 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_98851:ImportFrom_L170_C8", "label": "from django.conf import settings", "type": "import", "loc": [170, 170], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98851:FunctionDef_L161_C4", "vector": [1, 2, 0.7981, 0.0047, 2, 0.36, 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_98851:If_L173_C8", "label": "if", "type": "if", "loc": [173, 174], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98851:FunctionDef_L161_C4", "vector": [4, 2, 0.8146, 0.0094, 2, 0.36, 0.25, 0, 0, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if self._request_middleware is None:\n self.load_middleware()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98851:Expr_L174_C12", "label": "load_middleware()", "type": "expression", "loc": [174, 174], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98851:If_L173_C8", "vector": [8, 3, 0.8169, 0.0047, 3, 0.49, 0.0, 421, 3, 0, 0, 0, 0, 0, 1], "semantic": {"name": "load_middleware", "arg_names": [], "import_names": [], "rhs_call_name": "load_middleware", "annotation": ""}, "snippet": " self.load_middleware()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98851:Expr_L176_C8", "label": "set_script_prefix()", "type": "expression", "loc": [176, 176], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98851:FunctionDef_L161_C4", "vector": [8, 2, 0.8263, 0.0047, 2, 0.36, 0.3333, 926, 3, 1, 0, 0, 0, 0, 3], "semantic": {"name": "set_script_prefix", "arg_names": [], "import_names": [], "rhs_call_name": "set_script_prefix", "annotation": ""}, "snippet": " set_script_prefix(req.get_options().get('django.root', ''))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98851:Expr_L177_C8", "label": "send()", "type": "expression", "loc": [177, 177], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98851:FunctionDef_L161_C4", "vector": [8, 2, 0.831, 0.0047, 2, 0.36, 0.4167, 826, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "send", "arg_names": [], "import_names": [], "rhs_call_name": "send", "annotation": ""}, "snippet": " signals.request_started.send(sender=self.__class__)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98851:Try_L178_C8", "label": "try", "type": "try", "loc": [178, 193], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98851:FunctionDef_L161_C4", "vector": [7, 2, 0.8709, 0.0751, 2, 0.36, 0.5, 0, 0, 0, 0, 0, 0, 0, 6], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " try:\n try:\n request = self.request_class(req)\n except UnicodeDecodeError:\n logger.warning('Bad Request (UnicodeDecodeError): %s' % request.path,\n exc_info=sys.exc_info(),\n extra={\n 'status_code': 400,"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98851:Try_L179_C12", "label": "try", "type": "try", "loc": [179, 191], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98851:Try_L178_C8", "vector": [7, 3, 0.8685, 0.061, 3, 0.44, 0.0, 0, 0, 1, 0, 0, 0, 0, 5], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " try:\n request = self.request_class(req)\n except UnicodeDecodeError:\n logger.warning('Bad Request (UnicodeDecodeError): %s' % request.path,\n exc_info=sys.exc_info(),\n extra={\n 'status_code': 400,\n 'request': request"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98851:Assign_L180_C16", "label": "request = request_class()", "type": "assigned_variable", "loc": [180, 180], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98851:Try_L179_C12", "vector": [14, 4, 0.8451, 0.0047, 4, 0.96, 0.0, 50, 3, 1, 0, 0, 605, 10, 1], "semantic": {"name": "request", "arg_names": [], "import_names": [], "rhs_call_name": "request_class", "annotation": ""}, "snippet": " request = self.request_class(req)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98851:Expr_L182_C16", "label": "warning()", "type": "expression", "loc": [182, 188], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98851:Try_L179_C12", "vector": [8, 4, 0.8685, 0.0329, 4, 0.96, 0.0, 320, 3, 3, 0, 0, 0, 0, 2], "semantic": {"name": "warning", "arg_names": [], "import_names": [], "rhs_call_name": "warning", "annotation": ""}, "snippet": " logger.warning('Bad Request (UnicodeDecodeError): %s' % request.path,\n exc_info=sys.exc_info(),\n extra={\n 'status_code': 400,\n 'request': request\n }\n )"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98851:Assign_L189_C16", "label": "response = HttpResponseBadRequest()", "type": "assigned_variable", "loc": [189, 189], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98851:Try_L179_C12", "vector": [14, 4, 0.8873, 0.0047, 4, 0.96, 1.0, 511, 3, 0, 0, 0, 989, 10, 1], "semantic": {"name": "response", "arg_names": [], "import_names": [], "rhs_call_name": "HttpResponseBadRequest", "annotation": ""}, "snippet": " response = http.HttpResponseBadRequest()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98851:Assign_L191_C16", "label": "response = get_response()", "type": "assigned_variable", "loc": [191, 191], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98851:Try_L179_C12", "vector": [14, 4, 0.8967, 0.0047, 4, 0.96, 1.0, 511, 3, 1, 0, 0, 819, 10, 1], "semantic": {"name": "response", "arg_names": [], "import_names": [], "rhs_call_name": "get_response", "annotation": ""}, "snippet": " response = self.get_response(request)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98851:Expr_L193_C12", "label": "send()", "type": "expression", "loc": [193, 193], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98851:Try_L178_C8", "vector": [8, 3, 0.9061, 0.0047, 3, 0.44, 1.0, 826, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "send", "arg_names": [], "import_names": [], "rhs_call_name": "send", "annotation": ""}, "snippet": " signals.request_finished.send(sender=self.__class__)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98851:Assign_L196_C8", "label": "req.content_type =", "type": "assigned_variable", "loc": [196, 196], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98851:FunctionDef_L161_C4", "vector": [14, 2, 0.9202, 0.0047, 2, 0.36, 0.5833, 325, 6, 0, 0, 0, 0, 0, 0], "semantic": {"name": "req.content_type", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " req.content_type = response['Content-Type']"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98851:For_L197_C8", "label": "for key, value", "type": "for", "loc": [197, 199], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98851:FunctionDef_L161_C4", "vector": [6, 2, 0.9296, 0.0141, 2, 0.36, 0.6667, 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 response.items():\n if key != 'content-type':\n req.headers_out[str(key)] = str(value)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98851:If_L198_C12", "label": "if", "type": "if", "loc": [198, 199], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98851:For_L197_C8", "vector": [4, 3, 0.9319, 0.0094, 3, 0.88, 0.0, 0, 0, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if key != 'content-type':\n req.headers_out[str(key)] = str(value)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98851:Assign_L199_C16", "label": " = str()", "type": "assigned_variable", "loc": [199, 199], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98851:If_L198_C12", "vector": [14, 4, 0.9343, 0.0047, 4, 0.23, 0.0, 0, 3, 1, 0, 0, 52, 10, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "str", "annotation": ""}, "snippet": " req.headers_out[str(key)] = str(value)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98851:For_L200_C8", "label": "for c", "type": "for", "loc": [200, 201], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98851:FunctionDef_L161_C4", "vector": [6, 2, 0.9413, 0.0094, 2, 0.36, 0.75, 411, 3, 0, 0, 0, 0, 0, 3], "semantic": {"name": "c", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for c in response.cookies.values():\n req.headers_out.add('Set-Cookie', c.output(header=''))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98851:Expr_L201_C12", "label": "add()", "type": "expression", "loc": [201, 201], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98851:For_L200_C8", "vector": [8, 3, 0.9437, 0.0047, 3, 0.06, 0.0, 241, 3, 2, 0, 0, 0, 0, 2], "semantic": {"name": "add", "arg_names": [], "import_names": [], "rhs_call_name": "add", "annotation": ""}, "snippet": " req.headers_out.add('Set-Cookie', c.output(header=''))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98851:Assign_L202_C8", "label": "req.status =", "type": "assigned_variable", "loc": [202, 202], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98851:FunctionDef_L161_C4", "vector": [14, 2, 0.9484, 0.0047, 2, 0.36, 0.8333, 672, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "req.status", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " req.status = response.status_code"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98851:Try_L203_C8", "label": "try", "type": "try", "loc": [203, 207], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98851:FunctionDef_L161_C4", "vector": [7, 2, 0.9624, 0.0235, 2, 0.36, 0.9167, 0, 0, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " try:\n for chunk in response:\n req.write(chunk)\n finally:\n response.close()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98851:For_L204_C12", "label": "for chunk", "type": "for", "loc": [204, 205], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98851:Try_L203_C8", "vector": [6, 3, 0.9601, 0.0094, 3, 0.63, 0.0, 637, 2, 0, 0, 0, 0, 0, 1], "semantic": {"name": "chunk", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for chunk in response:\n req.write(chunk)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98851:Expr_L205_C16", "label": "write()", "type": "expression", "loc": [205, 205], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98851:For_L204_C12", "vector": [8, 4, 0.9624, 0.0047, 4, 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": " req.write(chunk)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98851:Expr_L207_C12", "label": "close()", "type": "expression", "loc": [207, 207], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98851:Try_L203_C8", "vector": [8, 3, 0.9718, 0.0047, 3, 0.63, 1.0, 77, 3, 0, 0, 0, 0, 0, 1], "semantic": {"name": "close", "arg_names": [], "import_names": [], "rhs_call_name": "close", "annotation": ""}, "snippet": " response.close()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98851:Return_L209_C8", "label": "return", "type": "return", "loc": [209, 209], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98851:FunctionDef_L161_C4", "vector": [13, 2, 0.9812, 0.0047, 2, 0.36, 1.0, 0, 1, 0, 0, 0, 0, 1, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return 0 # mod_python.apache.OK"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98851:FunctionDef_L211_C0", "label": "handler", "type": "function", "loc": [211, 213], "level": 0, "parent": null, "vector": [2, 0, 0.9953, 0.0141, 0, 0.66, 1.0, 388, 0, 1, 1, 0, 0, 0, 2], "semantic": {"name": "handler", "arg_names": ["req"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "def handler(req):\n # mod_python hooks into this function.\n return ModPythonHandler()(req)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98851:Return_L213_C4", "label": "return", "type": "return", "loc": [213, 213], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98851:FunctionDef_L211_C0", "vector": [13, 1, 1.0, 0.0047, 1, 0.21, 0.0, 0, 3, 0, 0, 0, 0, 10, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return ModPythonHandler()(req)"}]
[{"f": "ajibawa-2023/Python-Code-Large/train/row_98851:ClassDef_L21_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98851:FunctionDef_L22_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98851:FunctionDef_L22_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98851:Assign_L23_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98851:FunctionDef_L22_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98851:Assign_L29_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98851:FunctionDef_L22_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98851:Assign_L30_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98851:FunctionDef_L22_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98851:Assign_L31_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98851:FunctionDef_L22_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98851:If_L35_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98851:If_L35_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98851:Assign_L36_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98851:If_L35_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98851:Assign_L38_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98851:FunctionDef_L22_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98851:If_L39_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98851:If_L39_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98851:Assign_L43_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98851:FunctionDef_L22_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98851:Assign_L44_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98851:FunctionDef_L22_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98851:Assign_L45_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98851:FunctionDef_L22_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98851:Assign_L46_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98851:ClassDef_L21_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98851:FunctionDef_L48_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98851:FunctionDef_L48_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98851:Try_L51_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98851:Try_L51_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98851:Assign_L52_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98851:Try_L51_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98851:Assign_L54_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98851:FunctionDef_L48_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98851:If_L55_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98851:If_L55_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98851:Assign_L56_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98851:If_L55_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98851:Try_L58_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98851:Try_L58_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98851:Assign_L59_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98851:Try_L58_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98851:Assign_L61_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98851:FunctionDef_L48_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98851:Try_L62_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98851:Try_L62_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98851:Assign_L63_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98851:Try_L62_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98851:Assign_L65_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98851:FunctionDef_L48_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98851:Try_L66_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98851:Try_L66_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98851:Assign_L67_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98851:Try_L66_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98851:Assign_L69_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98851:FunctionDef_L48_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98851:Return_L70_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98851:ClassDef_L21_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98851:FunctionDef_L74_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98851:FunctionDef_L74_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98851:Return_L77_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98851:ClassDef_L21_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98851:FunctionDef_L79_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98851:FunctionDef_L79_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98851:Try_L80_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98851:Try_L80_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98851:Return_L81_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98851:Try_L80_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98851:Return_L84_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98851:ClassDef_L21_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98851:FunctionDef_L86_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98851:FunctionDef_L86_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98851:If_L87_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98851:If_L87_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98851:Assign_L88_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98851:FunctionDef_L86_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98851:Return_L89_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98851:ClassDef_L21_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98851:FunctionDef_L91_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98851:FunctionDef_L91_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98851:If_L92_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98851:If_L92_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98851:Assign_L93_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98851:FunctionDef_L91_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98851:Return_L94_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98851:ClassDef_L21_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98851:FunctionDef_L96_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98851:FunctionDef_L96_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98851:Assign_L97_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98851:ClassDef_L21_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98851:FunctionDef_L99_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98851:FunctionDef_L99_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98851:If_L100_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98851:If_L100_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98851:Expr_L101_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98851:FunctionDef_L99_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98851:Return_L102_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98851:ClassDef_L21_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98851:FunctionDef_L104_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98851:FunctionDef_L104_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98851:Assign_L105_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98851:ClassDef_L21_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98851:FunctionDef_L107_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98851:FunctionDef_L107_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98851:If_L108_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98851:If_L108_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98851:Assign_L109_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98851:FunctionDef_L107_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98851:Return_L110_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98851:ClassDef_L21_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98851:FunctionDef_L112_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98851:FunctionDef_L112_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98851:Assign_L113_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98851:ClassDef_L21_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98851:FunctionDef_L115_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98851:FunctionDef_L115_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98851:If_L116_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98851:If_L116_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98851:Expr_L117_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98851:FunctionDef_L115_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98851:Return_L118_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98851:ClassDef_L21_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98851:FunctionDef_L120_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98851:FunctionDef_L120_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98851:Expr_L121_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98851:FunctionDef_L120_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98851:If_L122_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98851:If_L122_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98851:Assign_L123_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98851:If_L122_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98851:For_L142_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98851:For_L142_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98851:Assign_L143_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98851:For_L142_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98851:Assign_L144_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98851:FunctionDef_L120_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98851:Return_L145_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98851:ClassDef_L21_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98851:FunctionDef_L147_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98851:FunctionDef_L147_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98851:Return_L148_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98851:ClassDef_L21_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98851:Assign_L150_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98851:ClassDef_L21_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98851:Assign_L151_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98851:ClassDef_L21_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98851:Assign_L152_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98851:ClassDef_L21_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98851:Assign_L153_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98851:ClassDef_L21_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98851:Assign_L154_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98851:ClassDef_L21_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98851:Assign_L155_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98851:ClassDef_L21_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98851:Assign_L156_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98851:ClassDef_L158_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98851:Assign_L159_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98851:ClassDef_L158_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98851:FunctionDef_L161_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98851:FunctionDef_L161_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98851:Expr_L162_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98851:FunctionDef_L161_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98851:Expr_L166_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98851:FunctionDef_L161_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98851:ImportFrom_L170_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98851:FunctionDef_L161_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98851:If_L173_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98851:If_L173_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98851:Expr_L174_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98851:FunctionDef_L161_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98851:Expr_L176_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98851:FunctionDef_L161_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98851:Expr_L177_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98851:FunctionDef_L161_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98851:Try_L178_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98851:Try_L178_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98851:Try_L179_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98851:Try_L179_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98851:Assign_L180_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98851:Try_L179_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98851:Expr_L182_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98851:Try_L179_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98851:Assign_L189_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98851:Try_L179_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98851:Assign_L191_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98851:Try_L178_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98851:Expr_L193_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98851:FunctionDef_L161_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98851:Assign_L196_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98851:FunctionDef_L161_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98851:For_L197_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98851:For_L197_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98851:If_L198_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98851:If_L198_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98851:Assign_L199_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98851:FunctionDef_L161_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98851:For_L200_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98851:For_L200_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98851:Expr_L201_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98851:FunctionDef_L161_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98851:Assign_L202_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98851:FunctionDef_L161_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98851:Try_L203_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98851:Try_L203_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98851:For_L204_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98851:For_L204_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98851:Expr_L205_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98851:Try_L203_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98851:Expr_L207_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98851:FunctionDef_L161_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98851:Return_L209_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98851:FunctionDef_L211_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98851:Return_L213_C4"}]
import hotshot, time, os from django.core.handlers.modpython import ModPythonHandler PROFILE_DATA_DIR = "/var/log/cmsprofile" def handler(req): ''' Handler that uses hotshot to store profile data. Stores profile data in PROFILE_DATA_DIR. Since hotshot has no way (that I know of) to append profile data to a single file, each request gets its own profile. The file names are in the format <url>.<n>.prof where <url> is the request path with "/" replaced by ".", and <n> is a timestamp with microseconds to prevent overwriting files. Use the gather_profile_stats.py script to gather these individual request profiles into aggregated profiles by request path. ''' profname = "%s.%.3f.prof" % (req.uri.strip("/").replace('/', '.'), time.time()) profname = os.path.join(PROFILE_DATA_DIR, profname) prof = hotshot.Profile(profname) return prof.runcall(ModPythonHandler(), req)
ajibawa-2023/Python-Code-Large/train/row_98852
9
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_98852:Import_L1_C0", "label": "hotshot import hotshot, time, os", "type": "import", "loc": [1, 1], "level": 0, "parent": null, "vector": [1, 0, 0.0455, 0.0455, 0, 0.66, 0.0, 974, 0, 3, 0, 0, 974, 0, 0], "semantic": {"name": "hotshot", "arg_names": [], "import_names": ["hotshot", "time", "os"], "rhs_call_name": "", "annotation": ""}, "snippet": "import hotshot, time, os"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98852:ImportFrom_L2_C0", "label": "from django.core.handlers.modpython import ModPythonHandler", "type": "import", "loc": [2, 2], "level": 0, "parent": null, "vector": [1, 0, 0.0909, 0.0455, 0, 0.66, 0.3333, 978, 0, 1, 0, 0, 978, 0, 0], "semantic": {"name": "django.core.handlers.modpython", "arg_names": [], "import_names": ["ModPythonHandler"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.core.handlers.modpython import ModPythonHandler"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98852:Assign_L4_C0", "label": "PROFILE_DATA_DIR =", "type": "assigned_variable", "loc": [4, 4], "level": 0, "parent": null, "vector": [14, 0, 0.1818, 0.0455, 0, 0.66, 0.6667, 485, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "PROFILE_DATA_DIR", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "PROFILE_DATA_DIR = \"/var/log/cmsprofile\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98852:FunctionDef_L6_C0", "label": "handler", "type": "function", "loc": [6, 22], "level": 0, "parent": null, "vector": [2, 0, 0.6364, 0.7727, 0, 0.66, 1.0, 388, 0, 1, 1, 0, 0, 0, 7], "semantic": {"name": "handler", "arg_names": ["req"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "def handler(req):\n '''\n Handler that uses hotshot to store profile data.\n\n Stores profile data in PROFILE_DATA_DIR. Since hotshot has no way (that I\n know of) to append profile data to a single file, each request gets its own\n profile. The file names are in the format <url>.<n>.prof where <url> is\n the request path with \"/\" replaced by \".\", and <n> is a timestamp with"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98852:Expr_L7_C4", "label": "expression", "type": "expression", "loc": [7, 18], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98852:FunctionDef_L6_C0", "vector": [8, 1, 0.5682, 0.5455, 1, 0.46, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " '''\n Handler that uses hotshot to store profile data.\n\n Stores profile data in PROFILE_DATA_DIR. Since hotshot has no way (that I\n know of) to append profile data to a single file, each request gets its own\n profile. The file names are in the format <url>.<n>.prof where <url> is\n the request path with \"/\" replaced by \".\", and <n> is a timestamp with\n microseconds to prevent overwriting files."}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98852:Assign_L19_C4", "label": "profname =", "type": "assigned_variable", "loc": [19, 19], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98852:FunctionDef_L6_C0", "vector": [14, 1, 0.8636, 0.0455, 1, 0.46, 0.25, 519, 4, 0, 0, 0, 0, 0, 3], "semantic": {"name": "profname", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " profname = \"%s.%.3f.prof\" % (req.uri.strip(\"/\").replace('/', '.'), time.time())"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98852:Assign_L20_C4", "label": "profname = join()", "type": "assigned_variable", "loc": [20, 20], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98852:FunctionDef_L6_C0", "vector": [14, 1, 0.9091, 0.0455, 1, 0.46, 0.5, 519, 3, 2, 0, 0, 933, 10, 1], "semantic": {"name": "profname", "arg_names": [], "import_names": [], "rhs_call_name": "join", "annotation": ""}, "snippet": " profname = os.path.join(PROFILE_DATA_DIR, profname)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98852:Assign_L21_C4", "label": "prof = Profile()", "type": "assigned_variable", "loc": [21, 21], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98852:FunctionDef_L6_C0", "vector": [14, 1, 0.9545, 0.0455, 1, 0.46, 0.75, 301, 3, 1, 0, 0, 555, 10, 1], "semantic": {"name": "prof", "arg_names": [], "import_names": [], "rhs_call_name": "Profile", "annotation": ""}, "snippet": " prof = hotshot.Profile(profname)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98852:Return_L22_C4", "label": "return", "type": "return", "loc": [22, 22], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98852:FunctionDef_L6_C0", "vector": [13, 1, 1.0, 0.0455, 1, 0.46, 1.0, 0, 3, 0, 0, 0, 0, 10, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return prof.runcall(ModPythonHandler(), req)"}]
[{"f": "ajibawa-2023/Python-Code-Large/train/row_98852:FunctionDef_L6_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98852:Expr_L7_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98852:FunctionDef_L6_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98852:Assign_L19_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98852:FunctionDef_L6_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98852:Assign_L20_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98852:FunctionDef_L6_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98852:Assign_L21_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98852:FunctionDef_L6_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98852:Return_L22_C4"}]
from pprint import pformat import sys from threading import Lock try: from cStringIO import StringIO except ImportError: from StringIO import StringIO import socket from django import http from django.core import signals from django.core.handlers import base from django.core.urlresolvers import set_script_prefix from django.utils import datastructures from django.utils.encoding import force_unicode, iri_to_uri from django.utils.log import getLogger logger = getLogger('django.request') # See http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html STATUS_CODE_TEXT = { 100: 'CONTINUE', 101: 'SWITCHING PROTOCOLS', 200: 'OK', 201: 'CREATED', 202: 'ACCEPTED', 203: 'NON-AUTHORITATIVE INFORMATION', 204: 'NO CONTENT', 205: 'RESET CONTENT', 206: 'PARTIAL CONTENT', 300: 'MULTIPLE CHOICES', 301: 'MOVED PERMANENTLY', 302: 'FOUND', 303: 'SEE OTHER', 304: 'NOT MODIFIED', 305: 'USE PROXY', 306: 'RESERVED', 307: 'TEMPORARY REDIRECT', 400: 'BAD REQUEST', 401: 'UNAUTHORIZED', 402: 'PAYMENT REQUIRED', 403: 'FORBIDDEN', 404: 'NOT FOUND', 405: 'METHOD NOT ALLOWED', 406: 'NOT ACCEPTABLE', 407: 'PROXY AUTHENTICATION REQUIRED', 408: 'REQUEST TIMEOUT', 409: 'CONFLICT', 410: 'GONE', 411: 'LENGTH REQUIRED', 412: 'PRECONDITION FAILED', 413: 'REQUEST ENTITY TOO LARGE', 414: 'REQUEST-URI TOO LONG', 415: 'UNSUPPORTED MEDIA TYPE', 416: 'REQUESTED RANGE NOT SATISFIABLE', 417: 'EXPECTATION FAILED', 500: 'INTERNAL SERVER ERROR', 501: 'NOT IMPLEMENTED', 502: 'BAD GATEWAY', 503: 'SERVICE UNAVAILABLE', 504: 'GATEWAY TIMEOUT', 505: 'HTTP VERSION NOT SUPPORTED', } class LimitedStream(object): ''' LimitedStream wraps another stream in order to not allow reading from it past specified amount of bytes. ''' def __init__(self, stream, limit, buf_size=64 * 1024 * 1024): self.stream = stream self.remaining = limit self.buffer = '' self.buf_size = buf_size def _read_limited(self, size=None): if size is None or size > self.remaining: size = self.remaining if size == 0: return '' result = self.stream.read(size) self.remaining -= len(result) return result def read(self, size=None): if size is None: result = self.buffer + self._read_limited() self.buffer = '' elif size < len(self.buffer): result = self.buffer[:size] self.buffer = self.buffer[size:] else: # size >= len(self.buffer) result = self.buffer + self._read_limited(size - len(self.buffer)) self.buffer = '' return result def readline(self, size=None): while '\n' not in self.buffer or \ (size is not None and len(self.buffer) < size): if size: chunk = self._read_limited(size - len(self.buffer)) else: chunk = self._read_limited() if not chunk: break self.buffer += chunk sio = StringIO(self.buffer) if size: line = sio.readline(size) else: line = sio.readline() self.buffer = sio.read() return line class WSGIRequest(http.HttpRequest): def __init__(self, environ): script_name = base.get_script_name(environ) path_info = force_unicode(environ.get('PATH_INFO', u'/')) if not path_info or path_info == script_name: # Sometimes PATH_INFO exists, but is empty (e.g. accessing # the SCRIPT_NAME URL without a trailing slash). We really need to # operate as if they'd requested '/'. Not amazingly nice to force # the path like this, but should be harmless. # # (The comparison of path_info to script_name is to work around an # apparent bug in flup 1.0.1. Se Django ticket #8490). path_info = u'/' self.environ = environ self.path_info = path_info self.path = '%s%s' % (script_name, path_info) self.META = environ self.META['PATH_INFO'] = path_info self.META['SCRIPT_NAME'] = script_name self.method = environ['REQUEST_METHOD'].upper() self._post_parse_error = False if type(socket._fileobject) is type and isinstance(self.environ['wsgi.input'], socket._fileobject): # Under development server 'wsgi.input' is an instance of # socket._fileobject which hangs indefinitely on reading bytes past # available count. To prevent this it's wrapped in LimitedStream # that doesn't read past Content-Length bytes. # # This is not done for other kinds of inputs (like flup's FastCGI # streams) beacuse they don't suffer from this problem and we can # avoid using another wrapper with its own .read and .readline # implementation. # # The type check is done because for some reason, AppEngine # implements _fileobject as a function, not a class. try: content_length = int(self.environ.get('CONTENT_LENGTH', 0)) except (ValueError, TypeError): content_length = 0 self._stream = LimitedStream(self.environ['wsgi.input'], content_length) else: self._stream = self.environ['wsgi.input'] self._read_started = False def __repr__(self): # Since this is called as part of error handling, we need to be very # robust against potentially malformed input. try: get = pformat(self.GET) except: get = '<could not parse>' if self._post_parse_error: post = '<could not parse>' else: try: post = pformat(self.POST) except: post = '<could not parse>' try: cookies = pformat(self.COOKIES) except: cookies = '<could not parse>' try: meta = pformat(self.META) except: meta = '<could not parse>' return '<WSGIRequest\nGET:%s,\nPOST:%s,\nCOOKIES:%s,\nMETA:%s>' % \ (get, post, cookies, meta) def get_full_path(self): # RFC 3986 requires query string arguments to be in the ASCII range. # Rather than crash if this doesn't happen, we encode defensively. return '%s%s' % (self.path, self.environ.get('QUERY_STRING', '') and ('?' + iri_to_uri(self.environ.get('QUERY_STRING', ''))) or '') def is_secure(self): return 'wsgi.url_scheme' in self.environ \ and self.environ['wsgi.url_scheme'] == 'https' def _get_request(self): if not hasattr(self, '_request'): self._request = datastructures.MergeDict(self.POST, self.GET) return self._request def _get_get(self): if not hasattr(self, '_get'): # The WSGI spec says 'QUERY_STRING' may be absent. self._get = http.QueryDict(self.environ.get('QUERY_STRING', ''), encoding=self._encoding) return self._get def _set_get(self, get): self._get = get def _get_post(self): if not hasattr(self, '_post'): self._load_post_and_files() return self._post def _set_post(self, post): self._post = post def _get_cookies(self): if not hasattr(self, '_cookies'): self._cookies = http.parse_cookie(self.environ.get('HTTP_COOKIE', '')) return self._cookies def _set_cookies(self, cookies): self._cookies = cookies def _get_files(self): if not hasattr(self, '_files'): self._load_post_and_files() return self._files GET = property(_get_get, _set_get) POST = property(_get_post, _set_post) COOKIES = property(_get_cookies, _set_cookies) FILES = property(_get_files) REQUEST = property(_get_request) class WSGIHandler(base.BaseHandler): initLock = Lock() request_class = WSGIRequest def __call__(self, environ, start_response): from django.conf import settings # Set up middleware if needed. We couldn't do this earlier, because # settings weren't available. if self._request_middleware is None: self.initLock.acquire() # Check that middleware is still uninitialised. if self._request_middleware is None: self.load_middleware() self.initLock.release() set_script_prefix(base.get_script_name(environ)) signals.request_started.send(sender=self.__class__) try: try: request = self.request_class(environ) except UnicodeDecodeError: logger.warning('Bad Request (UnicodeDecodeError): %s' % request.path, exc_info=sys.exc_info(), extra={ 'status_code': 400, 'request': request } ) response = http.HttpResponseBadRequest() else: response = self.get_response(request) finally: signals.request_finished.send(sender=self.__class__) try: status_text = STATUS_CODE_TEXT[response.status_code] except KeyError: status_text = 'UNKNOWN STATUS CODE' status = '%s %s' % (response.status_code, status_text) response_headers = [(str(k), str(v)) for k, v in response.items()] for c in response.cookies.values(): response_headers.append(('Set-Cookie', str(c.output(header='')))) start_response(status, response_headers) return response
ajibawa-2023/Python-Code-Large/train/row_98854
152
279
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_98854:ImportFrom_L1_C0", "label": "from pprint import pformat", "type": "import", "loc": [1, 1], "level": 0, "parent": null, "vector": [1, 0, 0.0036, 0.0036, 0, 0.66, 0.0, 276, 0, 1, 0, 0, 276, 0, 0], "semantic": {"name": "pprint", "arg_names": [], "import_names": ["pformat"], "rhs_call_name": "", "annotation": ""}, "snippet": "from pprint import pformat"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98854:Import_L2_C0", "label": "sys import sys", "type": "import", "loc": [2, 2], "level": 0, "parent": null, "vector": [1, 0, 0.0072, 0.0036, 0, 0.66, 0.0625, 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_98854:ImportFrom_L3_C0", "label": "from threading import Lock", "type": "import", "loc": [3, 3], "level": 0, "parent": null, "vector": [1, 0, 0.0108, 0.0036, 0, 0.66, 0.125, 83, 0, 1, 0, 0, 83, 0, 0], "semantic": {"name": "threading", "arg_names": [], "import_names": ["Lock"], "rhs_call_name": "", "annotation": ""}, "snippet": "from threading import Lock"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98854:Try_L4_C0", "label": "try", "type": "try", "loc": [4, 7], "level": 0, "parent": null, "vector": [7, 0, 0.0197, 0.0143, 0, 0.66, 0.1875, 0, 0, 1, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "try:\n from cStringIO import StringIO\nexcept ImportError:\n from StringIO import StringIO"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98854:ImportFrom_L5_C4", "label": "from cStringIO import StringIO", "type": "import", "loc": [5, 5], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98854:Try_L4_C0", "vector": [1, 1, 0.0179, 0.0036, 1, 0.8, 0.0, 764, 0, 1, 0, 0, 764, 0, 0], "semantic": {"name": "cStringIO", "arg_names": [], "import_names": ["StringIO"], "rhs_call_name": "", "annotation": ""}, "snippet": " from cStringIO import StringIO"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98854:ImportFrom_L7_C4", "label": "from StringIO import StringIO", "type": "import", "loc": [7, 7], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98854:Try_L4_C0", "vector": [1, 1, 0.0251, 0.0036, 1, 0.8, 0.0, 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_98854:Import_L8_C0", "label": "socket import socket", "type": "import", "loc": [8, 8], "level": 0, "parent": null, "vector": [1, 0, 0.0287, 0.0036, 0, 0.66, 0.25, 687, 0, 1, 0, 0, 687, 0, 0], "semantic": {"name": "socket", "arg_names": [], "import_names": ["socket"], "rhs_call_name": "", "annotation": ""}, "snippet": "import socket"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98854:ImportFrom_L10_C0", "label": "from django import http", "type": "import", "loc": [10, 10], "level": 0, "parent": null, "vector": [1, 0, 0.0358, 0.0036, 0, 0.66, 0.3125, 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_98854:ImportFrom_L11_C0", "label": "from django.core import signals", "type": "import", "loc": [11, 11], "level": 0, "parent": null, "vector": [1, 0, 0.0394, 0.0036, 0, 0.66, 0.375, 913, 0, 1, 0, 0, 913, 0, 0], "semantic": {"name": "django.core", "arg_names": [], "import_names": ["signals"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.core import signals"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98854:ImportFrom_L12_C0", "label": "from django.core.handlers import base", "type": "import", "loc": [12, 12], "level": 0, "parent": null, "vector": [1, 0, 0.043, 0.0036, 0, 0.66, 0.4375, 260, 0, 1, 0, 0, 260, 0, 0], "semantic": {"name": "django.core.handlers", "arg_names": [], "import_names": ["base"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.core.handlers import base"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98854:ImportFrom_L13_C0", "label": "from django.core.urlresolvers import set_script_prefix", "type": "import", "loc": [13, 13], "level": 0, "parent": null, "vector": [1, 0, 0.0466, 0.0036, 0, 0.66, 0.5, 749, 0, 1, 0, 0, 749, 0, 0], "semantic": {"name": "django.core.urlresolvers", "arg_names": [], "import_names": ["set_script_prefix"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.core.urlresolvers import set_script_prefix"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98854:ImportFrom_L14_C0", "label": "from django.utils import datastructures", "type": "import", "loc": [14, 14], "level": 0, "parent": null, "vector": [1, 0, 0.0502, 0.0036, 0, 0.66, 0.5625, 944, 0, 1, 0, 0, 944, 0, 0], "semantic": {"name": "django.utils", "arg_names": [], "import_names": ["datastructures"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.utils import datastructures"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98854:ImportFrom_L15_C0", "label": "from django.utils.encoding import force_unicode, iri_to_uri", "type": "import", "loc": [15, 15], "level": 0, "parent": null, "vector": [1, 0, 0.0538, 0.0036, 0, 0.66, 0.625, 96, 0, 2, 0, 0, 96, 0, 0], "semantic": {"name": "django.utils.encoding", "arg_names": [], "import_names": ["force_unicode", "iri_to_uri"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.utils.encoding import force_unicode, iri_to_uri"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98854:ImportFrom_L16_C0", "label": "from django.utils.log import getLogger", "type": "import", "loc": [16, 16], "level": 0, "parent": null, "vector": [1, 0, 0.0573, 0.0036, 0, 0.66, 0.6875, 174, 0, 1, 0, 0, 174, 0, 0], "semantic": {"name": "django.utils.log", "arg_names": [], "import_names": ["getLogger"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.utils.log import getLogger"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98854:Assign_L18_C0", "label": "logger = getLogger()", "type": "assigned_variable", "loc": [18, 18], "level": 0, "parent": null, "vector": [14, 0, 0.0645, 0.0036, 0, 0.66, 0.75, 532, 3, 1, 0, 0, 71, 10, 1], "semantic": {"name": "logger", "arg_names": [], "import_names": [], "rhs_call_name": "getLogger", "annotation": ""}, "snippet": "logger = getLogger('django.request')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98854:Assign_L22_C0", "label": "STATUS_CODE_TEXT =", "type": "assigned_variable", "loc": [22, 64], "level": 0, "parent": null, "vector": [14, 0, 0.1541, 0.1541, 0, 0.66, 0.8125, 913, 0, 0, 0, 0, 0, 6, 0], "semantic": {"name": "STATUS_CODE_TEXT", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "STATUS_CODE_TEXT = {\n 100: 'CONTINUE',\n 101: 'SWITCHING PROTOCOLS',\n 200: 'OK',\n 201: 'CREATED',\n 202: 'ACCEPTED',\n 203: 'NON-AUTHORITATIVE INFORMATION',\n 204: 'NO CONTENT',"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98854:ClassDef_L66_C0", "label": "LimitedStream", "type": "class", "loc": [66, 114], "level": 0, "parent": null, "vector": [3, 0, 0.3226, 0.1756, 0, 0.66, 0.875, 876, 0, 4, 0, 0, 186, 0, 14], "semantic": {"name": "LimitedStream", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class LimitedStream(object):\n '''\n LimitedStream wraps another stream in order to not allow reading from it\n past specified amount of bytes.\n '''\n def __init__(self, stream, limit, buf_size=64 * 1024 * 1024):\n self.stream = stream\n self.remaining = limit"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98854:Expr_L67_C4", "label": "expression", "type": "expression", "loc": [67, 70], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98854:ClassDef_L66_C0", "vector": [8, 1, 0.2455, 0.0143, 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 LimitedStream wraps another stream in order to not allow reading from it\n past specified amount of bytes.\n '''"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98854:FunctionDef_L71_C4", "label": "__init__", "type": "function", "loc": [71, 75], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98854:ClassDef_L66_C0", "vector": [2, 1, 0.2616, 0.0179, 1, 0.01, 0.25, 555, 0, 4, 0, 0, 0, 0, 0], "semantic": {"name": "__init__", "arg_names": ["self", "stream", "limit", "buf_size"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def __init__(self, stream, limit, buf_size=64 * 1024 * 1024):\n self.stream = stream\n self.remaining = limit\n self.buffer = ''\n self.buf_size = buf_size"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98854:Assign_L72_C8", "label": "self.stream =", "type": "assigned_variable", "loc": [72, 72], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98854:FunctionDef_L71_C4", "vector": [14, 2, 0.2581, 0.0036, 2, 0.7, 0.0, 207, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "self.stream", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.stream = stream"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98854:Assign_L73_C8", "label": "self.remaining =", "type": "assigned_variable", "loc": [73, 73], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98854:FunctionDef_L71_C4", "vector": [14, 2, 0.2616, 0.0036, 2, 0.7, 0.3333, 39, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "self.remaining", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.remaining = limit"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98854:Assign_L74_C8", "label": "self.buffer =", "type": "assigned_variable", "loc": [74, 74], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98854:FunctionDef_L71_C4", "vector": [14, 2, 0.2652, 0.0036, 2, 0.7, 0.6667, 827, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "self.buffer", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.buffer = ''"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98854:Assign_L75_C8", "label": "self.buf_size =", "type": "assigned_variable", "loc": [75, 75], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98854:FunctionDef_L71_C4", "vector": [14, 2, 0.2688, 0.0036, 2, 0.7, 1.0, 900, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "self.buf_size", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.buf_size = buf_size"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98854:FunctionDef_L77_C4", "label": "_read_limited", "type": "function", "loc": [77, 84], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98854:ClassDef_L66_C0", "vector": [2, 1, 0.2885, 0.0287, 1, 0.01, 0.5, 354, 0, 2, 1, 0, 0, 0, 2], "semantic": {"name": "_read_limited", "arg_names": ["self", "size"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def _read_limited(self, size=None):\n if size is None or size > self.remaining:\n size = self.remaining\n if size == 0:\n return ''\n result = self.stream.read(size)\n self.remaining -= len(result)\n return result"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98854:If_L78_C8", "label": "if", "type": "if", "loc": [78, 79], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98854:FunctionDef_L77_C4", "vector": [4, 2, 0.2814, 0.0072, 2, 0.43, 0.0, 0, 0, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if size is None or size > self.remaining:\n size = self.remaining"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98854:Assign_L79_C12", "label": "size =", "type": "assigned_variable", "loc": [79, 79], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98854:If_L78_C8", "vector": [14, 3, 0.2832, 0.0036, 3, 0.26, 0.0, 714, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "size", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " size = self.remaining"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98854:If_L80_C8", "label": "if", "type": "if", "loc": [80, 81], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98854:FunctionDef_L77_C4", "vector": [4, 2, 0.2885, 0.0072, 2, 0.43, 0.3333, 0, 0, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if size == 0:\n return ''"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98854:Return_L81_C12", "label": "return", "type": "return", "loc": [81, 81], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98854:If_L80_C8", "vector": [13, 3, 0.2903, 0.0036, 3, 0.63, 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_98854:Assign_L82_C8", "label": "result = read()", "type": "assigned_variable", "loc": [82, 82], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98854:FunctionDef_L77_C4", "vector": [14, 2, 0.2939, 0.0036, 2, 0.43, 0.6667, 51, 3, 1, 0, 0, 453, 10, 1], "semantic": {"name": "result", "arg_names": [], "import_names": [], "rhs_call_name": "read", "annotation": ""}, "snippet": " result = self.stream.read(size)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98854:Return_L84_C8", "label": "return", "type": "return", "loc": [84, 84], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98854:FunctionDef_L77_C4", "vector": [13, 2, 0.3011, 0.0036, 2, 0.43, 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_98854:FunctionDef_L86_C4", "label": "read", "type": "function", "loc": [86, 96], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98854:ClassDef_L66_C0", "vector": [2, 1, 0.3262, 0.0394, 1, 0.01, 0.75, 453, 0, 2, 1, 0, 0, 0, 4], "semantic": {"name": "read", "arg_names": ["self", "size"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def read(self, size=None):\n if size is None:\n result = self.buffer + self._read_limited()\n self.buffer = ''\n elif size < len(self.buffer):\n result = self.buffer[:size]\n self.buffer = self.buffer[size:]\n else: # size >= len(self.buffer)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98854:If_L87_C8", "label": "if", "type": "if", "loc": [87, 95], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98854:FunctionDef_L86_C4", "vector": [4, 2, 0.3262, 0.0323, 2, 0.34, 0.0, 0, 0, 0, 0, 0, 0, 0, 4], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if size is None:\n result = self.buffer + self._read_limited()\n self.buffer = ''\n elif size < len(self.buffer):\n result = self.buffer[:size]\n self.buffer = self.buffer[size:]\n else: # size >= len(self.buffer)\n result = self.buffer + self._read_limited(size - len(self.buffer))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98854:Assign_L88_C12", "label": "result =", "type": "assigned_variable", "loc": [88, 88], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98854:If_L87_C8", "vector": [14, 3, 0.3154, 0.0036, 3, 0.06, 0.0, 51, 4, 0, 0, 0, 0, 0, 1], "semantic": {"name": "result", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " result = self.buffer + self._read_limited()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98854:Assign_L89_C12", "label": "self.buffer =", "type": "assigned_variable", "loc": [89, 89], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98854:If_L87_C8", "vector": [14, 3, 0.319, 0.0036, 3, 0.06, 0.5, 827, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "self.buffer", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.buffer = ''"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98854:If_L90_C8", "label": "if", "type": "if", "loc": [90, 95], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98854:If_L87_C8", "vector": [4, 3, 0.3315, 0.0215, 3, 0.06, 1.0, 0, 0, 0, 0, 0, 0, 0, 3], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " elif size < len(self.buffer):\n result = self.buffer[:size]\n self.buffer = self.buffer[size:]\n else: # size >= len(self.buffer)\n result = self.buffer + self._read_limited(size - len(self.buffer))\n self.buffer = ''"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98854:Assign_L91_C12", "label": "result =", "type": "assigned_variable", "loc": [91, 91], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98854:If_L90_C8", "vector": [14, 4, 0.3262, 0.0036, 4, 0.91, 0.0, 51, 6, 0, 0, 0, 0, 0, 0], "semantic": {"name": "result", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " result = self.buffer[:size]"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98854:Assign_L92_C12", "label": "self.buffer =", "type": "assigned_variable", "loc": [92, 92], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98854:If_L90_C8", "vector": [14, 4, 0.3297, 0.0036, 4, 0.91, 0.3333, 827, 6, 0, 0, 0, 0, 0, 0], "semantic": {"name": "self.buffer", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.buffer = self.buffer[size:]"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98854:Assign_L94_C12", "label": "result =", "type": "assigned_variable", "loc": [94, 94], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98854:If_L90_C8", "vector": [14, 4, 0.3369, 0.0036, 4, 0.91, 0.6667, 51, 4, 0, 0, 0, 0, 0, 2], "semantic": {"name": "result", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " result = self.buffer + self._read_limited(size - len(self.buffer))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98854:Assign_L95_C12", "label": "self.buffer =", "type": "assigned_variable", "loc": [95, 95], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98854:If_L90_C8", "vector": [14, 4, 0.3405, 0.0036, 4, 0.91, 1.0, 827, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "self.buffer", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.buffer = ''"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98854:Return_L96_C8", "label": "return", "type": "return", "loc": [96, 96], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98854:FunctionDef_L86_C4", "vector": [13, 2, 0.3441, 0.0036, 2, 0.34, 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_98854:FunctionDef_L98_C4", "label": "readline", "type": "function", "loc": [98, 114], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98854:ClassDef_L66_C0", "vector": [2, 1, 0.3799, 0.0609, 1, 0.01, 1.0, 303, 0, 2, 1, 0, 0, 0, 8], "semantic": {"name": "readline", "arg_names": ["self", "size"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def readline(self, size=None):\n while '\\n' not in self.buffer or \\\n (size is not None and len(self.buffer) < size):\n if size:\n chunk = self._read_limited(size - len(self.buffer))\n else:\n chunk = self._read_limited()\n if not chunk:"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98854:While_L99_C8", "label": "while", "type": "while", "loc": [99, 107], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98854:FunctionDef_L98_C4", "vector": [5, 2, 0.3692, 0.0323, 2, 0.34, 0.0, 0, 0, 0, 0, 0, 0, 0, 4], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " while '\\n' not in self.buffer or \\\n (size is not None and len(self.buffer) < size):\n if size:\n chunk = self._read_limited(size - len(self.buffer))\n else:\n chunk = self._read_limited()\n if not chunk:\n break"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98854:If_L101_C12", "label": "if", "type": "if", "loc": [101, 104], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98854:While_L99_C8", "vector": [4, 3, 0.3674, 0.0143, 3, 0.31, 0.0, 0, 2, 0, 0, 0, 0, 0, 3], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if size:\n chunk = self._read_limited(size - len(self.buffer))\n else:\n chunk = self._read_limited()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98854:Assign_L102_C16", "label": "chunk = _read_limited()", "type": "assigned_variable", "loc": [102, 102], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98854:If_L101_C12", "vector": [14, 4, 0.3656, 0.0036, 4, 0.98, 0.0, 637, 3, 1, 0, 0, 354, 10, 2], "semantic": {"name": "chunk", "arg_names": [], "import_names": [], "rhs_call_name": "_read_limited", "annotation": ""}, "snippet": " chunk = self._read_limited(size - len(self.buffer))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98854:Assign_L104_C16", "label": "chunk = _read_limited()", "type": "assigned_variable", "loc": [104, 104], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98854:If_L101_C12", "vector": [14, 4, 0.3728, 0.0036, 4, 0.98, 1.0, 637, 3, 0, 0, 0, 354, 10, 1], "semantic": {"name": "chunk", "arg_names": [], "import_names": [], "rhs_call_name": "_read_limited", "annotation": ""}, "snippet": " chunk = self._read_limited()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98854:If_L105_C12", "label": "if", "type": "if", "loc": [105, 106], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98854:While_L99_C8", "vector": [4, 3, 0.3781, 0.0072, 3, 0.31, 1.0, 0, 0, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if not chunk:\n break"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98854:Assign_L108_C8", "label": "sio = StringIO()", "type": "assigned_variable", "loc": [108, 108], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98854:FunctionDef_L98_C4", "vector": [14, 2, 0.3871, 0.0036, 2, 0.34, 0.25, 828, 3, 1, 0, 0, 609, 10, 1], "semantic": {"name": "sio", "arg_names": [], "import_names": [], "rhs_call_name": "StringIO", "annotation": ""}, "snippet": " sio = StringIO(self.buffer)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98854:If_L109_C8", "label": "if", "type": "if", "loc": [109, 112], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98854:FunctionDef_L98_C4", "vector": [4, 2, 0.3961, 0.0143, 2, 0.34, 0.5, 0, 2, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if size:\n line = sio.readline(size)\n else:\n line = sio.readline()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98854:Assign_L110_C12", "label": "line = readline()", "type": "assigned_variable", "loc": [110, 110], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98854:If_L109_C8", "vector": [14, 3, 0.3943, 0.0036, 3, 0.59, 0.0, 373, 3, 1, 0, 0, 303, 10, 1], "semantic": {"name": "line", "arg_names": [], "import_names": [], "rhs_call_name": "readline", "annotation": ""}, "snippet": " line = sio.readline(size)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98854:Assign_L112_C12", "label": "line = readline()", "type": "assigned_variable", "loc": [112, 112], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98854:If_L109_C8", "vector": [14, 3, 0.4014, 0.0036, 3, 0.59, 1.0, 373, 3, 0, 0, 0, 303, 10, 1], "semantic": {"name": "line", "arg_names": [], "import_names": [], "rhs_call_name": "readline", "annotation": ""}, "snippet": " line = sio.readline()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98854:Assign_L113_C8", "label": "self.buffer = read()", "type": "assigned_variable", "loc": [113, 113], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98854:FunctionDef_L98_C4", "vector": [14, 2, 0.405, 0.0036, 2, 0.34, 0.75, 827, 3, 0, 0, 0, 453, 10, 1], "semantic": {"name": "self.buffer", "arg_names": [], "import_names": [], "rhs_call_name": "read", "annotation": ""}, "snippet": " self.buffer = sio.read()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98854:Return_L114_C8", "label": "return", "type": "return", "loc": [114, 114], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98854:FunctionDef_L98_C4", "vector": [13, 2, 0.4086, 0.0036, 2, 0.34, 1.0, 0, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return line"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98854:ClassDef_L116_C0", "label": "WSGIRequest", "type": "class", "loc": [116, 232], "level": 0, "parent": null, "vector": [3, 0, 0.6237, 0.4194, 0, 0.66, 0.9375, 369, 0, 12, 0, 0, 764, 0, 33], "semantic": {"name": "WSGIRequest", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class WSGIRequest(http.HttpRequest):\n def __init__(self, environ):\n script_name = base.get_script_name(environ)\n path_info = force_unicode(environ.get('PATH_INFO', u'/'))\n if not path_info or path_info == script_name:\n # Sometimes PATH_INFO exists, but is empty (e.g. accessing\n # the SCRIPT_NAME URL without a trailing slash). We really need to\n # operate as if they'd requested '/'. Not amazingly nice to force"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98854:FunctionDef_L117_C4", "label": "__init__", "type": "function", "loc": [117, 157], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98854:ClassDef_L116_C0", "vector": [2, 1, 0.491, 0.147, 1, 0.3, 0.0, 555, 0, 2, 0, 0, 0, 0, 9], "semantic": {"name": "__init__", "arg_names": ["self", "environ"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def __init__(self, environ):\n script_name = base.get_script_name(environ)\n path_info = force_unicode(environ.get('PATH_INFO', u'/'))\n if not path_info or path_info == script_name:\n # Sometimes PATH_INFO exists, but is empty (e.g. accessing\n # the SCRIPT_NAME URL without a trailing slash). We really need to\n # operate as if they'd requested '/'. Not amazingly nice to force\n # the path like this, but should be harmless."}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98854:Assign_L118_C8", "label": "script_name = get_script_name()", "type": "assigned_variable", "loc": [118, 118], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98854:FunctionDef_L117_C4", "vector": [14, 2, 0.4229, 0.0036, 2, 0.58, 0.0, 307, 3, 1, 0, 0, 921, 10, 1], "semantic": {"name": "script_name", "arg_names": [], "import_names": [], "rhs_call_name": "get_script_name", "annotation": ""}, "snippet": " script_name = base.get_script_name(environ)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98854:Assign_L119_C8", "label": "path_info = force_unicode()", "type": "assigned_variable", "loc": [119, 119], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98854:FunctionDef_L117_C4", "vector": [14, 2, 0.4265, 0.0036, 2, 0.58, 0.0833, 424, 3, 1, 0, 0, 870, 10, 2], "semantic": {"name": "path_info", "arg_names": [], "import_names": [], "rhs_call_name": "force_unicode", "annotation": ""}, "snippet": " path_info = force_unicode(environ.get('PATH_INFO', u'/'))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98854:If_L120_C8", "label": "if", "type": "if", "loc": [120, 128], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98854:FunctionDef_L117_C4", "vector": [4, 2, 0.4444, 0.0323, 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 path_info or path_info == script_name:\n # Sometimes PATH_INFO exists, but is empty (e.g. accessing\n # the SCRIPT_NAME URL without a trailing slash). We really need to\n # operate as if they'd requested '/'. Not amazingly nice to force\n # the path like this, but should be harmless.\n #\n # (The comparison of path_info to script_name is to work around an\n # apparent bug in flup 1.0.1. Se Django ticket #8490)."}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98854:Assign_L128_C12", "label": "path_info =", "type": "assigned_variable", "loc": [128, 128], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98854:If_L120_C8", "vector": [14, 3, 0.4588, 0.0036, 3, 0.18, 0.0, 424, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "path_info", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " path_info = u'/'"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98854:Assign_L129_C8", "label": "self.environ =", "type": "assigned_variable", "loc": [129, 129], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98854:FunctionDef_L117_C4", "vector": [14, 2, 0.4624, 0.0036, 2, 0.58, 0.25, 50, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "self.environ", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.environ = environ"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98854:Assign_L130_C8", "label": "self.path_info =", "type": "assigned_variable", "loc": [130, 130], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98854:FunctionDef_L117_C4", "vector": [14, 2, 0.4659, 0.0036, 2, 0.58, 0.3333, 442, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "self.path_info", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.path_info = path_info"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98854:Assign_L131_C8", "label": "self.path =", "type": "assigned_variable", "loc": [131, 131], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98854:FunctionDef_L117_C4", "vector": [14, 2, 0.4695, 0.0036, 2, 0.58, 0.4167, 425, 4, 0, 0, 0, 0, 0, 0], "semantic": {"name": "self.path", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.path = '%s%s' % (script_name, path_info)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98854:Assign_L132_C8", "label": "self.META =", "type": "assigned_variable", "loc": [132, 132], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98854:FunctionDef_L117_C4", "vector": [14, 2, 0.4731, 0.0036, 2, 0.58, 0.5, 949, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "self.META", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.META = environ"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98854:Assign_L133_C8", "label": "assign", "type": "assigned_variable", "loc": [133, 133], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98854:FunctionDef_L117_C4", "vector": [14, 2, 0.4767, 0.0036, 2, 0.58, 0.5833, 0, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.META['PATH_INFO'] = path_info"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98854:Assign_L134_C8", "label": "assign", "type": "assigned_variable", "loc": [134, 134], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98854:FunctionDef_L117_C4", "vector": [14, 2, 0.4803, 0.0036, 2, 0.58, 0.6667, 0, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.META['SCRIPT_NAME'] = script_name"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98854:Assign_L135_C8", "label": "self.method = upper()", "type": "assigned_variable", "loc": [135, 135], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98854:FunctionDef_L117_C4", "vector": [14, 2, 0.4839, 0.0036, 2, 0.58, 0.75, 432, 3, 0, 0, 0, 347, 10, 1], "semantic": {"name": "self.method", "arg_names": [], "import_names": [], "rhs_call_name": "upper", "annotation": ""}, "snippet": " self.method = environ['REQUEST_METHOD'].upper()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98854:Assign_L136_C8", "label": "self._post_parse_error =", "type": "assigned_variable", "loc": [136, 136], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98854:FunctionDef_L117_C4", "vector": [14, 2, 0.4875, 0.0036, 2, 0.58, 0.8333, 977, 1, 0, 0, 0, 0, 4, 0], "semantic": {"name": "self._post_parse_error", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self._post_parse_error = False"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98854:If_L137_C8", "label": "if", "type": "if", "loc": [137, 156], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98854:FunctionDef_L117_C4", "vector": [4, 2, 0.5251, 0.0717, 2, 0.58, 0.9167, 0, 0, 0, 0, 0, 0, 0, 5], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if type(socket._fileobject) is type and isinstance(self.environ['wsgi.input'], socket._fileobject):\n # Under development server 'wsgi.input' is an instance of\n # socket._fileobject which hangs indefinitely on reading bytes past\n # available count. To prevent this it's wrapped in LimitedStream\n # that doesn't read past Content-Length bytes.\n #\n # This is not done for other kinds of inputs (like flup's FastCGI\n # streams) beacuse they don't suffer from this problem and we can"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98854:Try_L150_C12", "label": "try", "type": "try", "loc": [150, 153], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98854:If_L137_C8", "vector": [7, 3, 0.543, 0.0143, 3, 0.02, 0.0, 0, 0, 1, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " try:\n content_length = int(self.environ.get('CONTENT_LENGTH', 0))\n except (ValueError, TypeError):\n content_length = 0"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98854:Assign_L151_C16", "label": "content_length = int()", "type": "assigned_variable", "loc": [151, 151], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98854:Try_L150_C12", "vector": [14, 4, 0.5412, 0.0036, 4, 0.2, 0.0, 179, 3, 1, 0, 0, 901, 10, 2], "semantic": {"name": "content_length", "arg_names": [], "import_names": [], "rhs_call_name": "int", "annotation": ""}, "snippet": " content_length = int(self.environ.get('CONTENT_LENGTH', 0))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98854:Assign_L153_C16", "label": "content_length =", "type": "assigned_variable", "loc": [153, 153], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98854:Try_L150_C12", "vector": [14, 4, 0.5484, 0.0036, 4, 0.2, 0.0, 179, 1, 0, 0, 0, 0, 1, 0], "semantic": {"name": "content_length", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " content_length = 0"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98854:Assign_L154_C12", "label": "self._stream = LimitedStream()", "type": "assigned_variable", "loc": [154, 154], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98854:If_L137_C8", "vector": [14, 3, 0.552, 0.0036, 3, 0.02, 0.5, 214, 3, 2, 0, 0, 876, 10, 1], "semantic": {"name": "self._stream", "arg_names": [], "import_names": [], "rhs_call_name": "LimitedStream", "annotation": ""}, "snippet": " self._stream = LimitedStream(self.environ['wsgi.input'], content_length)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98854:Assign_L156_C12", "label": "self._stream =", "type": "assigned_variable", "loc": [156, 156], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98854:If_L137_C8", "vector": [14, 3, 0.5591, 0.0036, 3, 0.02, 1.0, 214, 6, 0, 0, 0, 0, 0, 0], "semantic": {"name": "self._stream", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self._stream = self.environ['wsgi.input']"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98854:Assign_L157_C8", "label": "self._read_started =", "type": "assigned_variable", "loc": [157, 157], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98854:FunctionDef_L117_C4", "vector": [14, 2, 0.5627, 0.0036, 2, 0.58, 1.0, 430, 1, 0, 0, 0, 0, 4, 0], "semantic": {"name": "self._read_started", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self._read_started = False"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98854:FunctionDef_L159_C4", "label": "__repr__", "type": "function", "loc": [159, 182], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98854:ClassDef_L116_C0", "vector": [2, 1, 0.6111, 0.086, 1, 0.3, 0.0625, 204, 0, 1, 1, 0, 0, 0, 4], "semantic": {"name": "__repr__", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def __repr__(self):\n # Since this is called as part of error handling, we need to be very\n # robust against potentially malformed input.\n try:\n get = pformat(self.GET)\n except:\n get = '<could not parse>'\n if self._post_parse_error:"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98854:Try_L162_C8", "label": "try", "type": "try", "loc": [162, 165], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98854:FunctionDef_L159_C4", "vector": [7, 2, 0.586, 0.0143, 2, 0.95, 0.0, 0, 0, 1, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " try:\n get = pformat(self.GET)\n except:\n get = '<could not parse>'"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98854:Assign_L163_C12", "label": "get = pformat()", "type": "assigned_variable", "loc": [163, 163], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98854:Try_L162_C8", "vector": [14, 3, 0.5842, 0.0036, 3, 0.91, 0.0, 607, 3, 1, 0, 0, 479, 10, 1], "semantic": {"name": "get", "arg_names": [], "import_names": [], "rhs_call_name": "pformat", "annotation": ""}, "snippet": " get = pformat(self.GET)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98854:Assign_L165_C12", "label": "get =", "type": "assigned_variable", "loc": [165, 165], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98854:Try_L162_C8", "vector": [14, 3, 0.5914, 0.0036, 3, 0.91, 0.0, 607, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "get", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " get = '<could not parse>'"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98854:If_L166_C8", "label": "if", "type": "if", "loc": [166, 172], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98854:FunctionDef_L159_C4", "vector": [4, 2, 0.6057, 0.0251, 2, 0.95, 0.25, 0, 7, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if self._post_parse_error:\n post = '<could not parse>'\n else:\n try:\n post = pformat(self.POST)\n except:\n post = '<could not parse>'"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98854:Assign_L167_C12", "label": "post =", "type": "assigned_variable", "loc": [167, 167], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98854:If_L166_C8", "vector": [14, 3, 0.5986, 0.0036, 3, 0.26, 0.0, 304, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "post", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " post = '<could not parse>'"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98854:Try_L169_C12", "label": "try", "type": "try", "loc": [169, 172], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98854:If_L166_C8", "vector": [7, 3, 0.6111, 0.0143, 3, 0.26, 1.0, 0, 0, 1, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " try:\n post = pformat(self.POST)\n except:\n post = '<could not parse>'"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98854:Assign_L170_C16", "label": "post = pformat()", "type": "assigned_variable", "loc": [170, 170], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98854:Try_L169_C12", "vector": [14, 4, 0.6093, 0.0036, 4, 0.92, 0.0, 304, 3, 1, 0, 0, 479, 10, 1], "semantic": {"name": "post", "arg_names": [], "import_names": [], "rhs_call_name": "pformat", "annotation": ""}, "snippet": " post = pformat(self.POST)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98854:Assign_L172_C16", "label": "post =", "type": "assigned_variable", "loc": [172, 172], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98854:Try_L169_C12", "vector": [14, 4, 0.6165, 0.0036, 4, 0.92, 0.0, 304, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "post", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " post = '<could not parse>'"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98854:Try_L173_C8", "label": "try", "type": "try", "loc": [173, 176], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98854:FunctionDef_L159_C4", "vector": [7, 2, 0.6254, 0.0143, 2, 0.95, 0.5, 0, 0, 1, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " try:\n cookies = pformat(self.COOKIES)\n except:\n cookies = '<could not parse>'"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98854:Assign_L174_C12", "label": "cookies = pformat()", "type": "assigned_variable", "loc": [174, 174], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98854:Try_L173_C8", "vector": [14, 3, 0.6237, 0.0036, 3, 0.42, 0.0, 711, 3, 1, 0, 0, 479, 10, 1], "semantic": {"name": "cookies", "arg_names": [], "import_names": [], "rhs_call_name": "pformat", "annotation": ""}, "snippet": " cookies = pformat(self.COOKIES)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98854:Assign_L176_C12", "label": "cookies =", "type": "assigned_variable", "loc": [176, 176], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98854:Try_L173_C8", "vector": [14, 3, 0.6308, 0.0036, 3, 0.42, 0.0, 711, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "cookies", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " cookies = '<could not parse>'"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98854:Try_L177_C8", "label": "try", "type": "try", "loc": [177, 180], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98854:FunctionDef_L159_C4", "vector": [7, 2, 0.6398, 0.0143, 2, 0.95, 0.75, 0, 0, 1, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " try:\n meta = pformat(self.META)\n except:\n meta = '<could not parse>'"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98854:Assign_L178_C12", "label": "meta = pformat()", "type": "assigned_variable", "loc": [178, 178], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98854:Try_L177_C8", "vector": [14, 3, 0.638, 0.0036, 3, 0.69, 0.0, 329, 3, 1, 0, 0, 479, 10, 1], "semantic": {"name": "meta", "arg_names": [], "import_names": [], "rhs_call_name": "pformat", "annotation": ""}, "snippet": " meta = pformat(self.META)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98854:Assign_L180_C12", "label": "meta =", "type": "assigned_variable", "loc": [180, 180], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98854:Try_L177_C8", "vector": [14, 3, 0.6452, 0.0036, 3, 0.69, 0.0, 329, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "meta", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " meta = '<could not parse>'"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98854:Return_L181_C8", "label": "return", "type": "return", "loc": [181, 182], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98854:FunctionDef_L159_C4", "vector": [13, 2, 0.6505, 0.0072, 2, 0.95, 1.0, 0, 4, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return '<WSGIRequest\\nGET:%s,\\nPOST:%s,\\nCOOKIES:%s,\\nMETA:%s>' % \\\n (get, post, cookies, meta)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98854:FunctionDef_L184_C4", "label": "get_full_path", "type": "function", "loc": [184, 187], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98854:ClassDef_L116_C0", "vector": [2, 1, 0.6649, 0.0143, 1, 0.3, 0.125, 451, 0, 1, 1, 0, 0, 0, 3], "semantic": {"name": "get_full_path", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def get_full_path(self):\n # RFC 3986 requires query string arguments to be in the ASCII range.\n # Rather than crash if this doesn't happen, we encode defensively.\n return '%s%s' % (self.path, self.environ.get('QUERY_STRING', '') and ('?' + iri_to_uri(self.environ.get('QUERY_STRING', ''))) or '')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98854:Return_L187_C8", "label": "return", "type": "return", "loc": [187, 187], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98854:FunctionDef_L184_C4", "vector": [13, 2, 0.6703, 0.0036, 2, 0.53, 0.0, 0, 4, 0, 0, 0, 0, 0, 3], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return '%s%s' % (self.path, self.environ.get('QUERY_STRING', '') and ('?' + iri_to_uri(self.environ.get('QUERY_STRING', ''))) or '')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98854:FunctionDef_L189_C4", "label": "is_secure", "type": "function", "loc": [189, 191], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98854:ClassDef_L116_C0", "vector": [2, 1, 0.681, 0.0108, 1, 0.3, 0.1875, 797, 0, 1, 1, 0, 0, 0, 0], "semantic": {"name": "is_secure", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def is_secure(self):\n return 'wsgi.url_scheme' in self.environ \\\n and self.environ['wsgi.url_scheme'] == 'https'"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98854:Return_L190_C8", "label": "return", "type": "return", "loc": [190, 191], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98854:FunctionDef_L189_C4", "vector": [13, 2, 0.6828, 0.0072, 2, 0.41, 0.0, 0, 0, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return 'wsgi.url_scheme' in self.environ \\\n and self.environ['wsgi.url_scheme'] == 'https'"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98854:FunctionDef_L193_C4", "label": "_get_request", "type": "function", "loc": [193, 196], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98854:ClassDef_L116_C0", "vector": [2, 1, 0.6971, 0.0143, 1, 0.3, 0.25, 216, 0, 1, 1, 0, 0, 0, 2], "semantic": {"name": "_get_request", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def _get_request(self):\n if not hasattr(self, '_request'):\n self._request = datastructures.MergeDict(self.POST, self.GET)\n return self._request"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98854:If_L194_C8", "label": "if", "type": "if", "loc": [194, 195], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98854:FunctionDef_L193_C4", "vector": [4, 2, 0.6971, 0.0072, 2, 0.6, 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, '_request'):\n self._request = datastructures.MergeDict(self.POST, self.GET)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98854:Assign_L195_C12", "label": "self._request = MergeDict()", "type": "assigned_variable", "loc": [195, 195], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98854:If_L194_C8", "vector": [14, 3, 0.6989, 0.0036, 3, 0.6, 0.0, 149, 3, 2, 0, 0, 14, 10, 1], "semantic": {"name": "self._request", "arg_names": [], "import_names": [], "rhs_call_name": "MergeDict", "annotation": ""}, "snippet": " self._request = datastructures.MergeDict(self.POST, self.GET)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98854:Return_L196_C8", "label": "return", "type": "return", "loc": [196, 196], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98854:FunctionDef_L193_C4", "vector": [13, 2, 0.7025, 0.0036, 2, 0.6, 1.0, 0, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return self._request"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98854:FunctionDef_L198_C4", "label": "_get_get", "type": "function", "loc": [198, 202], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98854:ClassDef_L116_C0", "vector": [2, 1, 0.7168, 0.0179, 1, 0.3, 0.3125, 656, 0, 1, 1, 0, 0, 0, 3], "semantic": {"name": "_get_get", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def _get_get(self):\n if not hasattr(self, '_get'):\n # The WSGI spec says 'QUERY_STRING' may be absent.\n self._get = http.QueryDict(self.environ.get('QUERY_STRING', ''), encoding=self._encoding)\n return self._get"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98854:If_L199_C8", "label": "if", "type": "if", "loc": [199, 201], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98854:FunctionDef_L198_C4", "vector": [4, 2, 0.7168, 0.0108, 2, 0.47, 0.0, 0, 0, 0, 0, 0, 0, 0, 3], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if not hasattr(self, '_get'):\n # The WSGI spec says 'QUERY_STRING' may be absent.\n self._get = http.QueryDict(self.environ.get('QUERY_STRING', ''), encoding=self._encoding)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98854:Assign_L201_C12", "label": "self._get = QueryDict()", "type": "assigned_variable", "loc": [201, 201], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98854:If_L199_C8", "vector": [14, 3, 0.7204, 0.0036, 3, 0.05, 0.0, 338, 3, 2, 0, 0, 457, 10, 2], "semantic": {"name": "self._get", "arg_names": [], "import_names": [], "rhs_call_name": "QueryDict", "annotation": ""}, "snippet": " self._get = http.QueryDict(self.environ.get('QUERY_STRING', ''), encoding=self._encoding)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98854:Return_L202_C8", "label": "return", "type": "return", "loc": [202, 202], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98854:FunctionDef_L198_C4", "vector": [13, 2, 0.724, 0.0036, 2, 0.47, 1.0, 0, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return self._get"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98854:FunctionDef_L204_C4", "label": "_set_get", "type": "function", "loc": [204, 205], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98854:ClassDef_L116_C0", "vector": [2, 1, 0.733, 0.0072, 1, 0.3, 0.375, 197, 0, 2, 0, 0, 0, 0, 0], "semantic": {"name": "_set_get", "arg_names": ["self", "get"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def _set_get(self, get):\n self._get = get"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98854:Assign_L205_C8", "label": "self._get =", "type": "assigned_variable", "loc": [205, 205], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98854:FunctionDef_L204_C4", "vector": [14, 2, 0.7348, 0.0036, 2, 0.89, 0.0, 338, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "self._get", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self._get = get"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98854:FunctionDef_L207_C4", "label": "_get_post", "type": "function", "loc": [207, 210], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98854:ClassDef_L116_C0", "vector": [2, 1, 0.7473, 0.0143, 1, 0.3, 0.4375, 847, 0, 1, 1, 0, 0, 0, 2], "semantic": {"name": "_get_post", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def _get_post(self):\n if not hasattr(self, '_post'):\n self._load_post_and_files()\n return self._post"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98854:If_L208_C8", "label": "if", "type": "if", "loc": [208, 209], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98854:FunctionDef_L207_C4", "vector": [4, 2, 0.7473, 0.0072, 2, 0.62, 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, '_post'):\n self._load_post_and_files()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98854:Expr_L209_C12", "label": "_load_post_and_files()", "type": "expression", "loc": [209, 209], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98854:If_L208_C8", "vector": [8, 3, 0.7491, 0.0036, 3, 0.91, 0.0, 153, 3, 0, 0, 0, 0, 0, 1], "semantic": {"name": "_load_post_and_files", "arg_names": [], "import_names": [], "rhs_call_name": "_load_post_and_files", "annotation": ""}, "snippet": " self._load_post_and_files()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98854:Return_L210_C8", "label": "return", "type": "return", "loc": [210, 210], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98854:FunctionDef_L207_C4", "vector": [13, 2, 0.7527, 0.0036, 2, 0.62, 1.0, 0, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return self._post"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98854:FunctionDef_L212_C4", "label": "_set_post", "type": "function", "loc": [212, 213], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98854:ClassDef_L116_C0", "vector": [2, 1, 0.7616, 0.0072, 1, 0.3, 0.5, 591, 0, 2, 0, 0, 0, 0, 0], "semantic": {"name": "_set_post", "arg_names": ["self", "post"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def _set_post(self, post):\n self._post = post"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98854:Assign_L213_C8", "label": "self._post =", "type": "assigned_variable", "loc": [213, 213], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98854:FunctionDef_L212_C4", "vector": [14, 2, 0.7634, 0.0036, 2, 0.52, 0.0, 963, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "self._post", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self._post = post"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98854:FunctionDef_L215_C4", "label": "_get_cookies", "type": "function", "loc": [215, 218], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98854:ClassDef_L116_C0", "vector": [2, 1, 0.776, 0.0143, 1, 0.3, 0.5625, 532, 0, 1, 1, 0, 0, 0, 3], "semantic": {"name": "_get_cookies", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def _get_cookies(self):\n if not hasattr(self, '_cookies'):\n self._cookies = http.parse_cookie(self.environ.get('HTTP_COOKIE', ''))\n return self._cookies"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98854:If_L216_C8", "label": "if", "type": "if", "loc": [216, 217], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98854:FunctionDef_L215_C4", "vector": [4, 2, 0.776, 0.0072, 2, 0.89, 0.0, 0, 0, 0, 0, 0, 0, 0, 3], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if not hasattr(self, '_cookies'):\n self._cookies = http.parse_cookie(self.environ.get('HTTP_COOKIE', ''))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98854:Assign_L217_C12", "label": "self._cookies = parse_cookie()", "type": "assigned_variable", "loc": [217, 217], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98854:If_L216_C8", "vector": [14, 3, 0.7778, 0.0036, 3, 0.35, 0.0, 598, 3, 1, 0, 0, 682, 10, 2], "semantic": {"name": "self._cookies", "arg_names": [], "import_names": [], "rhs_call_name": "parse_cookie", "annotation": ""}, "snippet": " self._cookies = http.parse_cookie(self.environ.get('HTTP_COOKIE', ''))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98854:Return_L218_C8", "label": "return", "type": "return", "loc": [218, 218], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98854:FunctionDef_L215_C4", "vector": [13, 2, 0.7814, 0.0036, 2, 0.89, 1.0, 0, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return self._cookies"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98854:FunctionDef_L220_C4", "label": "_set_cookies", "type": "function", "loc": [220, 221], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98854:ClassDef_L116_C0", "vector": [2, 1, 0.7903, 0.0072, 1, 0.3, 0.625, 492, 0, 2, 0, 0, 0, 0, 0], "semantic": {"name": "_set_cookies", "arg_names": ["self", "cookies"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def _set_cookies(self, cookies):\n self._cookies = cookies"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98854:Assign_L221_C8", "label": "self._cookies =", "type": "assigned_variable", "loc": [221, 221], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98854:FunctionDef_L220_C4", "vector": [14, 2, 0.7921, 0.0036, 2, 0.55, 0.0, 598, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "self._cookies", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self._cookies = cookies"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98854:FunctionDef_L223_C4", "label": "_get_files", "type": "function", "loc": [223, 226], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98854:ClassDef_L116_C0", "vector": [2, 1, 0.8047, 0.0143, 1, 0.3, 0.6875, 567, 0, 1, 1, 0, 0, 0, 2], "semantic": {"name": "_get_files", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def _get_files(self):\n if not hasattr(self, '_files'):\n self._load_post_and_files()\n return self._files"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98854:If_L224_C8", "label": "if", "type": "if", "loc": [224, 225], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98854:FunctionDef_L223_C4", "vector": [4, 2, 0.8047, 0.0072, 2, 0.03, 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, '_files'):\n self._load_post_and_files()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98854:Expr_L225_C12", "label": "_load_post_and_files()", "type": "expression", "loc": [225, 225], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98854:If_L224_C8", "vector": [8, 3, 0.8065, 0.0036, 3, 0.67, 0.0, 153, 3, 0, 0, 0, 0, 0, 1], "semantic": {"name": "_load_post_and_files", "arg_names": [], "import_names": [], "rhs_call_name": "_load_post_and_files", "annotation": ""}, "snippet": " self._load_post_and_files()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98854:Return_L226_C8", "label": "return", "type": "return", "loc": [226, 226], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98854:FunctionDef_L223_C4", "vector": [13, 2, 0.81, 0.0036, 2, 0.03, 1.0, 0, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return self._files"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98854:Assign_L228_C4", "label": "GET = property()", "type": "assigned_variable", "loc": [228, 228], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98854:ClassDef_L116_C0", "vector": [14, 1, 0.8172, 0.0036, 1, 0.3, 0.75, 547, 3, 2, 0, 0, 244, 10, 1], "semantic": {"name": "GET", "arg_names": [], "import_names": [], "rhs_call_name": "property", "annotation": ""}, "snippet": " GET = property(_get_get, _set_get)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98854:Assign_L229_C4", "label": "POST = property()", "type": "assigned_variable", "loc": [229, 229], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98854:ClassDef_L116_C0", "vector": [14, 1, 0.8208, 0.0036, 1, 0.3, 0.8125, 41, 3, 2, 0, 0, 244, 10, 1], "semantic": {"name": "POST", "arg_names": [], "import_names": [], "rhs_call_name": "property", "annotation": ""}, "snippet": " POST = property(_get_post, _set_post)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98854:Assign_L230_C4", "label": "COOKIES = property()", "type": "assigned_variable", "loc": [230, 230], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98854:ClassDef_L116_C0", "vector": [14, 1, 0.8244, 0.0036, 1, 0.3, 0.875, 266, 3, 2, 0, 0, 244, 10, 1], "semantic": {"name": "COOKIES", "arg_names": [], "import_names": [], "rhs_call_name": "property", "annotation": ""}, "snippet": " COOKIES = property(_get_cookies, _set_cookies)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98854:Assign_L231_C4", "label": "FILES = property()", "type": "assigned_variable", "loc": [231, 231], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98854:ClassDef_L116_C0", "vector": [14, 1, 0.828, 0.0036, 1, 0.3, 0.9375, 870, 3, 1, 0, 0, 244, 10, 1], "semantic": {"name": "FILES", "arg_names": [], "import_names": [], "rhs_call_name": "property", "annotation": ""}, "snippet": " FILES = property(_get_files)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98854:Assign_L232_C4", "label": "REQUEST = property()", "type": "assigned_variable", "loc": [232, 232], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98854:ClassDef_L116_C0", "vector": [14, 1, 0.8315, 0.0036, 1, 0.3, 1.0, 991, 3, 1, 0, 0, 244, 10, 1], "semantic": {"name": "REQUEST", "arg_names": [], "import_names": [], "rhs_call_name": "property", "annotation": ""}, "snippet": " REQUEST = property(_get_request)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98854:ClassDef_L234_C0", "label": "WSGIHandler", "type": "class", "loc": [234, 278], "level": 0, "parent": null, "vector": [3, 0, 0.9176, 0.1613, 0, 0.66, 1.0, 465, 0, 1, 0, 0, 636, 0, 21], "semantic": {"name": "WSGIHandler", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class WSGIHandler(base.BaseHandler):\n initLock = Lock()\n request_class = WSGIRequest\n\n def __call__(self, environ, start_response):\n from django.conf import settings\n\n # Set up middleware if needed. We couldn't do this earlier, because"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98854:Assign_L235_C4", "label": "initLock = Lock()", "type": "assigned_variable", "loc": [235, 235], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98854:ClassDef_L234_C0", "vector": [14, 1, 0.8423, 0.0036, 1, 0.16, 0.0, 11, 3, 0, 0, 0, 843, 10, 1], "semantic": {"name": "initLock", "arg_names": [], "import_names": [], "rhs_call_name": "Lock", "annotation": ""}, "snippet": " initLock = Lock()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98854:Assign_L236_C4", "label": "request_class =", "type": "assigned_variable", "loc": [236, 236], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98854:ClassDef_L234_C0", "vector": [14, 1, 0.8459, 0.0036, 1, 0.16, 0.5, 605, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "request_class", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " request_class = WSGIRequest"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98854:FunctionDef_L238_C4", "label": "__call__", "type": "function", "loc": [238, 278], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98854:ClassDef_L234_C0", "vector": [2, 1, 0.9247, 0.147, 1, 0.16, 1.0, 319, 0, 3, 1, 0, 0, 0, 20], "semantic": {"name": "__call__", "arg_names": ["self", "environ", "start_response"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def __call__(self, environ, start_response):\n from django.conf import settings\n\n # Set up middleware if needed. We couldn't do this earlier, because\n # settings weren't available.\n if self._request_middleware is None:\n self.initLock.acquire()\n # Check that middleware is still uninitialised."}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98854:ImportFrom_L239_C8", "label": "from django.conf import settings", "type": "import", "loc": [239, 239], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98854:FunctionDef_L238_C4", "vector": [1, 2, 0.8566, 0.0036, 2, 0.07, 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_98854:If_L243_C8", "label": "if", "type": "if", "loc": [243, 248], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98854:FunctionDef_L238_C4", "vector": [4, 2, 0.8799, 0.0215, 2, 0.07, 0.1, 0, 0, 0, 0, 0, 0, 0, 3], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if self._request_middleware is None:\n self.initLock.acquire()\n # Check that middleware is still uninitialised.\n if self._request_middleware is None:\n self.load_middleware()\n self.initLock.release()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98854:Expr_L244_C12", "label": "acquire()", "type": "expression", "loc": [244, 244], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98854:If_L243_C8", "vector": [8, 3, 0.8746, 0.0036, 3, 0.05, 0.0, 229, 3, 0, 0, 0, 0, 0, 1], "semantic": {"name": "acquire", "arg_names": [], "import_names": [], "rhs_call_name": "acquire", "annotation": ""}, "snippet": " self.initLock.acquire()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98854:If_L246_C12", "label": "if", "type": "if", "loc": [246, 247], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98854:If_L243_C8", "vector": [4, 3, 0.8835, 0.0072, 3, 0.05, 0.5, 0, 0, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if self._request_middleware is None:\n self.load_middleware()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98854:Expr_L247_C16", "label": "load_middleware()", "type": "expression", "loc": [247, 247], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98854:If_L246_C12", "vector": [8, 4, 0.8853, 0.0036, 4, 0.12, 0.0, 421, 3, 0, 0, 0, 0, 0, 1], "semantic": {"name": "load_middleware", "arg_names": [], "import_names": [], "rhs_call_name": "load_middleware", "annotation": ""}, "snippet": " self.load_middleware()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98854:Expr_L248_C12", "label": "release()", "type": "expression", "loc": [248, 248], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98854:If_L243_C8", "vector": [8, 3, 0.8889, 0.0036, 3, 0.05, 1.0, 784, 3, 0, 0, 0, 0, 0, 1], "semantic": {"name": "release", "arg_names": [], "import_names": [], "rhs_call_name": "release", "annotation": ""}, "snippet": " self.initLock.release()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98854:Expr_L250_C8", "label": "set_script_prefix()", "type": "expression", "loc": [250, 250], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98854:FunctionDef_L238_C4", "vector": [8, 2, 0.8961, 0.0036, 2, 0.07, 0.2, 926, 3, 1, 0, 0, 0, 0, 2], "semantic": {"name": "set_script_prefix", "arg_names": [], "import_names": [], "rhs_call_name": "set_script_prefix", "annotation": ""}, "snippet": " set_script_prefix(base.get_script_name(environ))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98854:Expr_L251_C8", "label": "send()", "type": "expression", "loc": [251, 251], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98854:FunctionDef_L238_C4", "vector": [8, 2, 0.8996, 0.0036, 2, 0.07, 0.3, 826, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "send", "arg_names": [], "import_names": [], "rhs_call_name": "send", "annotation": ""}, "snippet": " signals.request_started.send(sender=self.__class__)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98854:Try_L252_C8", "label": "try", "type": "try", "loc": [252, 267], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98854:FunctionDef_L238_C4", "vector": [7, 2, 0.9301, 0.0573, 2, 0.07, 0.4, 0, 0, 0, 0, 0, 0, 0, 6], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " try:\n try:\n request = self.request_class(environ)\n except UnicodeDecodeError:\n logger.warning('Bad Request (UnicodeDecodeError): %s' % request.path,\n exc_info=sys.exc_info(),\n extra={\n 'status_code': 400,"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98854:Try_L253_C12", "label": "try", "type": "try", "loc": [253, 265], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98854:Try_L252_C8", "vector": [7, 3, 0.9283, 0.0466, 3, 0.58, 0.0, 0, 0, 1, 0, 0, 0, 0, 5], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " try:\n request = self.request_class(environ)\n except UnicodeDecodeError:\n logger.warning('Bad Request (UnicodeDecodeError): %s' % request.path,\n exc_info=sys.exc_info(),\n extra={\n 'status_code': 400,\n 'request': request"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98854:Assign_L254_C16", "label": "request = request_class()", "type": "assigned_variable", "loc": [254, 254], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98854:Try_L253_C12", "vector": [14, 4, 0.9104, 0.0036, 4, 0.57, 0.0, 50, 3, 1, 0, 0, 605, 10, 1], "semantic": {"name": "request", "arg_names": [], "import_names": [], "rhs_call_name": "request_class", "annotation": ""}, "snippet": " request = self.request_class(environ)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98854:Expr_L256_C16", "label": "warning()", "type": "expression", "loc": [256, 262], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98854:Try_L253_C12", "vector": [8, 4, 0.9283, 0.0251, 4, 0.57, 0.0, 320, 3, 3, 0, 0, 0, 0, 2], "semantic": {"name": "warning", "arg_names": [], "import_names": [], "rhs_call_name": "warning", "annotation": ""}, "snippet": " logger.warning('Bad Request (UnicodeDecodeError): %s' % request.path,\n exc_info=sys.exc_info(),\n extra={\n 'status_code': 400,\n 'request': request\n }\n )"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98854:Assign_L263_C16", "label": "response = HttpResponseBadRequest()", "type": "assigned_variable", "loc": [263, 263], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98854:Try_L253_C12", "vector": [14, 4, 0.9427, 0.0036, 4, 0.57, 1.0, 511, 3, 0, 0, 0, 989, 10, 1], "semantic": {"name": "response", "arg_names": [], "import_names": [], "rhs_call_name": "HttpResponseBadRequest", "annotation": ""}, "snippet": " response = http.HttpResponseBadRequest()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98854:Assign_L265_C16", "label": "response = get_response()", "type": "assigned_variable", "loc": [265, 265], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98854:Try_L253_C12", "vector": [14, 4, 0.9498, 0.0036, 4, 0.57, 1.0, 511, 3, 1, 0, 0, 819, 10, 1], "semantic": {"name": "response", "arg_names": [], "import_names": [], "rhs_call_name": "get_response", "annotation": ""}, "snippet": " response = self.get_response(request)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98854:Expr_L267_C12", "label": "send()", "type": "expression", "loc": [267, 267], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98854:Try_L252_C8", "vector": [8, 3, 0.957, 0.0036, 3, 0.58, 1.0, 826, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "send", "arg_names": [], "import_names": [], "rhs_call_name": "send", "annotation": ""}, "snippet": " signals.request_finished.send(sender=self.__class__)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98854:Try_L269_C8", "label": "try", "type": "try", "loc": [269, 272], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98854:FunctionDef_L238_C4", "vector": [7, 2, 0.9695, 0.0143, 2, 0.07, 0.5, 0, 0, 1, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " try:\n status_text = STATUS_CODE_TEXT[response.status_code]\n except KeyError:\n status_text = 'UNKNOWN STATUS CODE'"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98854:Assign_L270_C12", "label": "status_text =", "type": "assigned_variable", "loc": [270, 270], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98854:Try_L269_C8", "vector": [14, 3, 0.9677, 0.0036, 3, 0.02, 0.0, 873, 6, 0, 0, 0, 0, 0, 0], "semantic": {"name": "status_text", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " status_text = STATUS_CODE_TEXT[response.status_code]"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98854:Assign_L272_C12", "label": "status_text =", "type": "assigned_variable", "loc": [272, 272], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98854:Try_L269_C8", "vector": [14, 3, 0.9749, 0.0036, 3, 0.02, 0.0, 873, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "status_text", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " status_text = 'UNKNOWN STATUS CODE'"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98854:Assign_L273_C8", "label": "status =", "type": "assigned_variable", "loc": [273, 273], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98854:FunctionDef_L238_C4", "vector": [14, 2, 0.9785, 0.0036, 2, 0.07, 0.6, 699, 4, 0, 0, 0, 0, 0, 0], "semantic": {"name": "status", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " status = '%s %s' % (response.status_code, status_text)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98854:Assign_L274_C8", "label": "response_headers =", "type": "assigned_variable", "loc": [274, 274], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98854:FunctionDef_L238_C4", "vector": [14, 2, 0.9821, 0.0036, 2, 0.07, 0.7, 740, 5, 0, 0, 0, 0, 0, 3], "semantic": {"name": "response_headers", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " response_headers = [(str(k), str(v)) for k, v in response.items()]"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98854:For_L275_C8", "label": "for c", "type": "for", "loc": [275, 276], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98854:FunctionDef_L238_C4", "vector": [6, 2, 0.9875, 0.0072, 2, 0.07, 0.8, 411, 3, 0, 0, 0, 0, 0, 4], "semantic": {"name": "c", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for c in response.cookies.values():\n response_headers.append(('Set-Cookie', str(c.output(header=''))))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98854:Expr_L276_C12", "label": "append()", "type": "expression", "loc": [276, 276], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98854:For_L275_C8", "vector": [8, 3, 0.9892, 0.0036, 3, 0.65, 0.0, 243, 3, 1, 0, 0, 0, 0, 3], "semantic": {"name": "append", "arg_names": [], "import_names": [], "rhs_call_name": "append", "annotation": ""}, "snippet": " response_headers.append(('Set-Cookie', str(c.output(header=''))))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98854:Expr_L277_C8", "label": "start_response()", "type": "expression", "loc": [277, 277], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98854:FunctionDef_L238_C4", "vector": [8, 2, 0.9928, 0.0036, 2, 0.07, 0.9, 638, 3, 2, 0, 0, 0, 0, 1], "semantic": {"name": "start_response", "arg_names": [], "import_names": [], "rhs_call_name": "start_response", "annotation": ""}, "snippet": " start_response(status, response_headers)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98854:Return_L278_C8", "label": "return", "type": "return", "loc": [278, 278], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98854:FunctionDef_L238_C4", "vector": [13, 2, 0.9964, 0.0036, 2, 0.07, 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_98854:Try_L4_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98854:ImportFrom_L5_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98854:Try_L4_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98854:ImportFrom_L7_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98854:ClassDef_L66_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98854:Expr_L67_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98854:ClassDef_L66_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98854:FunctionDef_L71_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98854:FunctionDef_L71_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98854:Assign_L72_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98854:FunctionDef_L71_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98854:Assign_L73_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98854:FunctionDef_L71_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98854:Assign_L74_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98854:FunctionDef_L71_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98854:Assign_L75_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98854:ClassDef_L66_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98854:FunctionDef_L77_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98854:FunctionDef_L77_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98854:If_L78_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98854:If_L78_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98854:Assign_L79_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98854:FunctionDef_L77_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98854:If_L80_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98854:If_L80_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98854:Return_L81_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98854:FunctionDef_L77_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98854:Assign_L82_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98854:FunctionDef_L77_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98854:Return_L84_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98854:ClassDef_L66_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98854:FunctionDef_L86_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98854:FunctionDef_L86_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98854:If_L87_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98854:If_L87_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98854:Assign_L88_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98854:If_L87_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98854:Assign_L89_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98854:If_L87_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98854:If_L90_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98854:If_L90_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98854:Assign_L91_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98854:If_L90_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98854:Assign_L92_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98854:If_L90_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98854:Assign_L94_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98854:If_L90_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98854:Assign_L95_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98854:FunctionDef_L86_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98854:Return_L96_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98854:ClassDef_L66_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98854:FunctionDef_L98_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98854:FunctionDef_L98_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98854:While_L99_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98854:While_L99_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98854:If_L101_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98854:If_L101_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98854:Assign_L102_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98854:If_L101_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98854:Assign_L104_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98854:While_L99_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98854:If_L105_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98854:FunctionDef_L98_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98854:Assign_L108_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98854:FunctionDef_L98_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98854:If_L109_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98854:If_L109_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98854:Assign_L110_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98854:If_L109_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98854:Assign_L112_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98854:FunctionDef_L98_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98854:Assign_L113_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98854:FunctionDef_L98_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98854:Return_L114_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98854:ClassDef_L116_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98854:FunctionDef_L117_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98854:FunctionDef_L117_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98854:Assign_L118_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98854:FunctionDef_L117_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98854:Assign_L119_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98854:FunctionDef_L117_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98854:If_L120_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98854:If_L120_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98854:Assign_L128_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98854:FunctionDef_L117_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98854:Assign_L129_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98854:FunctionDef_L117_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98854:Assign_L130_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98854:FunctionDef_L117_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98854:Assign_L131_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98854:FunctionDef_L117_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98854:Assign_L132_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98854:FunctionDef_L117_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98854:Assign_L133_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98854:FunctionDef_L117_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98854:Assign_L134_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98854:FunctionDef_L117_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98854:Assign_L135_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98854:FunctionDef_L117_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98854:Assign_L136_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98854:FunctionDef_L117_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98854:If_L137_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98854:If_L137_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98854:Try_L150_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98854:Try_L150_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98854:Assign_L151_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98854:Try_L150_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98854:Assign_L153_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98854:If_L137_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98854:Assign_L154_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98854:If_L137_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98854:Assign_L156_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98854:FunctionDef_L117_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98854:Assign_L157_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98854:ClassDef_L116_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98854:FunctionDef_L159_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98854:FunctionDef_L159_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98854:Try_L162_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98854:Try_L162_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98854:Assign_L163_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98854:Try_L162_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98854:Assign_L165_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98854:FunctionDef_L159_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98854:If_L166_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98854:If_L166_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98854:Assign_L167_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98854:If_L166_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98854:Try_L169_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98854:Try_L169_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98854:Assign_L170_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98854:Try_L169_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98854:Assign_L172_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98854:FunctionDef_L159_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98854:Try_L173_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98854:Try_L173_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98854:Assign_L174_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98854:Try_L173_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98854:Assign_L176_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98854:FunctionDef_L159_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98854:Try_L177_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98854:Try_L177_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98854:Assign_L178_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98854:Try_L177_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98854:Assign_L180_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98854:FunctionDef_L159_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98854:Return_L181_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98854:ClassDef_L116_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98854:FunctionDef_L184_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98854:FunctionDef_L184_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98854:Return_L187_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98854:ClassDef_L116_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98854:FunctionDef_L189_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98854:FunctionDef_L189_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98854:Return_L190_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98854:ClassDef_L116_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98854:FunctionDef_L193_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98854:FunctionDef_L193_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98854:If_L194_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98854:If_L194_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98854:Assign_L195_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98854:FunctionDef_L193_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98854:Return_L196_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98854:ClassDef_L116_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98854:FunctionDef_L198_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98854:FunctionDef_L198_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98854:If_L199_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98854:If_L199_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98854:Assign_L201_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98854:FunctionDef_L198_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98854:Return_L202_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98854:ClassDef_L116_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98854:FunctionDef_L204_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98854:FunctionDef_L204_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98854:Assign_L205_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98854:ClassDef_L116_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98854:FunctionDef_L207_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98854:FunctionDef_L207_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98854:If_L208_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98854:If_L208_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98854:Expr_L209_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98854:FunctionDef_L207_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98854:Return_L210_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98854:ClassDef_L116_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98854:FunctionDef_L212_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98854:FunctionDef_L212_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98854:Assign_L213_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98854:ClassDef_L116_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98854:FunctionDef_L215_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98854:FunctionDef_L215_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98854:If_L216_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98854:If_L216_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98854:Assign_L217_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98854:FunctionDef_L215_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98854:Return_L218_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98854:ClassDef_L116_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98854:FunctionDef_L220_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98854:FunctionDef_L220_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98854:Assign_L221_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98854:ClassDef_L116_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98854:FunctionDef_L223_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98854:FunctionDef_L223_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98854:If_L224_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98854:If_L224_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98854:Expr_L225_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98854:FunctionDef_L223_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98854:Return_L226_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98854:ClassDef_L116_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98854:Assign_L228_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98854:ClassDef_L116_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98854:Assign_L229_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98854:ClassDef_L116_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98854:Assign_L230_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98854:ClassDef_L116_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98854:Assign_L231_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98854:ClassDef_L116_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98854:Assign_L232_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98854:ClassDef_L234_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98854:Assign_L235_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98854:ClassDef_L234_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98854:Assign_L236_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98854:ClassDef_L234_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98854:FunctionDef_L238_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98854:FunctionDef_L238_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98854:ImportFrom_L239_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98854:FunctionDef_L238_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98854:If_L243_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98854:If_L243_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98854:Expr_L244_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98854:If_L243_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98854:If_L246_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98854:If_L246_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98854:Expr_L247_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98854:If_L243_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98854:Expr_L248_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98854:FunctionDef_L238_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98854:Expr_L250_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98854:FunctionDef_L238_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98854:Expr_L251_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98854:FunctionDef_L238_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98854:Try_L252_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98854:Try_L252_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98854:Try_L253_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98854:Try_L253_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98854:Assign_L254_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98854:Try_L253_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98854:Expr_L256_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98854:Try_L253_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98854:Assign_L263_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98854:Try_L253_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98854:Assign_L265_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98854:Try_L252_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98854:Expr_L267_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98854:FunctionDef_L238_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98854:Try_L269_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98854:Try_L269_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98854:Assign_L270_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98854:Try_L269_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98854:Assign_L272_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98854:FunctionDef_L238_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98854:Assign_L273_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98854:FunctionDef_L238_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98854:Assign_L274_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98854:FunctionDef_L238_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98854:For_L275_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98854:For_L275_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98854:Expr_L276_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98854:FunctionDef_L238_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98854:Expr_L277_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98854:FunctionDef_L238_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98854:Return_L278_C8"}]
from django.dispatch import Signal request_started = Signal() request_finished = Signal() got_request_exception = Signal(providing_args=["request"])
ajibawa-2023/Python-Code-Large/train/row_98856
4
5
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_98856:ImportFrom_L1_C0", "label": "from django.dispatch import Signal", "type": "import", "loc": [1, 1], "level": 0, "parent": null, "vector": [1, 0, 0.2, 0.2, 0, 0.66, 0.0, 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_98856:Assign_L3_C0", "label": "request_started = Signal()", "type": "assigned_variable", "loc": [3, 3], "level": 0, "parent": null, "vector": [14, 0, 0.6, 0.2, 0, 0.66, 0.3333, 176, 3, 0, 0, 0, 592, 10, 1], "semantic": {"name": "request_started", "arg_names": [], "import_names": [], "rhs_call_name": "Signal", "annotation": ""}, "snippet": "request_started = Signal()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98856:Assign_L4_C0", "label": "request_finished = Signal()", "type": "assigned_variable", "loc": [4, 4], "level": 0, "parent": null, "vector": [14, 0, 0.8, 0.2, 0, 0.66, 0.6667, 448, 3, 0, 0, 0, 592, 10, 1], "semantic": {"name": "request_finished", "arg_names": [], "import_names": [], "rhs_call_name": "Signal", "annotation": ""}, "snippet": "request_finished = Signal()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98856:Assign_L5_C0", "label": "got_request_exception = Signal()", "type": "assigned_variable", "loc": [5, 5], "level": 0, "parent": null, "vector": [14, 0, 1.0, 0.2, 0, 0.66, 1.0, 287, 3, 1, 0, 0, 592, 10, 1], "semantic": {"name": "got_request_exception", "arg_names": [], "import_names": [], "rhs_call_name": "Signal", "annotation": ""}, "snippet": "got_request_exception = Signal(providing_args=[\"request\"])"}]
[]
from math import ceil class InvalidPage(Exception): pass class PageNotAnInteger(InvalidPage): pass class EmptyPage(InvalidPage): pass class Paginator(object): def __init__(self, object_list, per_page, orphans=0, allow_empty_first_page=True): self.object_list = object_list self.per_page = per_page self.orphans = orphans self.allow_empty_first_page = allow_empty_first_page self._num_pages = self._count = None def validate_number(self, number): "Validates the given 1-based page number." try: number = int(number) except ValueError: raise PageNotAnInteger('That page number is not an integer') if number < 1: raise EmptyPage('That page number is less than 1') if number > self.num_pages: if number == 1 and self.allow_empty_first_page: pass else: raise EmptyPage('That page contains no results') return number def page(self, number): "Returns a Page object for the given 1-based page number." number = self.validate_number(number) bottom = (number - 1) * self.per_page top = bottom + self.per_page if top + self.orphans >= self.count: top = self.count return Page(self.object_list[bottom:top], number, self) def _get_count(self): "Returns the total number of objects, across all pages." if self._count is None: try: self._count = self.object_list.count() except (AttributeError, TypeError): # AttributeError if object_list has no count() method. # TypeError if object_list.count() requires arguments # (i.e. is of type list). self._count = len(self.object_list) return self._count count = property(_get_count) def _get_num_pages(self): "Returns the total number of pages." if self._num_pages is None: if self.count == 0 and not self.allow_empty_first_page: self._num_pages = 0 else: hits = max(1, self.count - self.orphans) self._num_pages = int(ceil(hits / float(self.per_page))) return self._num_pages num_pages = property(_get_num_pages) def _get_page_range(self): """ Returns a 1-based range of pages for iterating through within a template for loop. """ return range(1, self.num_pages + 1) page_range = property(_get_page_range) QuerySetPaginator = Paginator # For backwards-compatibility. class Page(object): def __init__(self, object_list, number, paginator): self.object_list = object_list self.number = number self.paginator = paginator def __repr__(self): return '<Page %s of %s>' % (self.number, self.paginator.num_pages) def has_next(self): return self.number < self.paginator.num_pages def has_previous(self): return self.number > 1 def has_other_pages(self): return self.has_previous() or self.has_next() def next_page_number(self): return self.number + 1 def previous_page_number(self): return self.number - 1 def start_index(self): """ Returns the 1-based index of the first object on this page, relative to total objects in the paginator. """ # Special case, return zero if no items. if self.paginator.count == 0: return 0 return (self.paginator.per_page * (self.number - 1)) + 1 def end_index(self): """ Returns the 1-based index of the last object on this page, relative to total objects found (hits). """ # Special case for the last page because there can be orphans. if self.number == self.paginator.num_pages: return self.paginator.count return self.number * self.paginator.per_page
ajibawa-2023/Python-Code-Large/train/row_98857
76
120
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_98857:ImportFrom_L1_C0", "label": "from math import ceil", "type": "import", "loc": [1, 1], "level": 0, "parent": null, "vector": [1, 0, 0.0083, 0.0083, 0, 0.66, 0.0, 526, 0, 1, 0, 0, 526, 0, 0], "semantic": {"name": "math", "arg_names": [], "import_names": ["ceil"], "rhs_call_name": "", "annotation": ""}, "snippet": "from math import ceil"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98857:ClassDef_L3_C0", "label": "InvalidPage", "type": "class", "loc": [3, 4], "level": 0, "parent": null, "vector": [3, 0, 0.0292, 0.0167, 0, 0.66, 0.1667, 933, 0, 0, 0, 0, 645, 0, 0], "semantic": {"name": "InvalidPage", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class InvalidPage(Exception):\n pass"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98857:ClassDef_L6_C0", "label": "PageNotAnInteger", "type": "class", "loc": [6, 7], "level": 0, "parent": null, "vector": [3, 0, 0.0542, 0.0167, 0, 0.66, 0.3333, 471, 0, 0, 0, 0, 933, 0, 0], "semantic": {"name": "PageNotAnInteger", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class PageNotAnInteger(InvalidPage):\n pass"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98857:ClassDef_L9_C0", "label": "EmptyPage", "type": "class", "loc": [9, 10], "level": 0, "parent": null, "vector": [3, 0, 0.0792, 0.0167, 0, 0.66, 0.5, 829, 0, 0, 0, 0, 933, 0, 0], "semantic": {"name": "EmptyPage", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class EmptyPage(InvalidPage):\n pass"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98857:ClassDef_L12_C0", "label": "Paginator", "type": "class", "loc": [12, 74], "level": 0, "parent": null, "vector": [3, 0, 0.3583, 0.525, 0, 0.66, 0.6667, 148, 0, 6, 0, 0, 186, 0, 16], "semantic": {"name": "Paginator", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class Paginator(object):\n def __init__(self, object_list, per_page, orphans=0, allow_empty_first_page=True):\n self.object_list = object_list\n self.per_page = per_page\n self.orphans = orphans\n self.allow_empty_first_page = allow_empty_first_page\n self._num_pages = self._count = None\n"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98857:FunctionDef_L13_C4", "label": "__init__", "type": "function", "loc": [13, 18], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98857:ClassDef_L12_C0", "vector": [2, 1, 0.1292, 0.05, 1, 0.35, 0.0, 555, 0, 5, 0, 0, 0, 0, 0], "semantic": {"name": "__init__", "arg_names": ["self", "object_list", "per_page", "orphans", "allow_empty_first_page"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def __init__(self, object_list, per_page, orphans=0, allow_empty_first_page=True):\n self.object_list = object_list\n self.per_page = per_page\n self.orphans = orphans\n self.allow_empty_first_page = allow_empty_first_page\n self._num_pages = self._count = None"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98857:Assign_L14_C8", "label": "self.object_list =", "type": "assigned_variable", "loc": [14, 14], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98857:FunctionDef_L13_C4", "vector": [14, 2, 0.1167, 0.0083, 2, 0.24, 0.0, 569, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "self.object_list", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.object_list = object_list"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98857:Assign_L15_C8", "label": "self.per_page =", "type": "assigned_variable", "loc": [15, 15], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98857:FunctionDef_L13_C4", "vector": [14, 2, 0.125, 0.0083, 2, 0.24, 0.25, 290, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "self.per_page", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.per_page = per_page"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98857:Assign_L16_C8", "label": "self.orphans =", "type": "assigned_variable", "loc": [16, 16], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98857:FunctionDef_L13_C4", "vector": [14, 2, 0.1333, 0.0083, 2, 0.24, 0.5, 398, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "self.orphans", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.orphans = orphans"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98857:Assign_L17_C8", "label": "self.allow_empty_first_page =", "type": "assigned_variable", "loc": [17, 17], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98857:FunctionDef_L13_C4", "vector": [14, 2, 0.1417, 0.0083, 2, 0.24, 0.75, 898, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "self.allow_empty_first_page", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.allow_empty_first_page = allow_empty_first_page"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98857:Assign_L18_C8", "label": "self._num_pages =", "type": "assigned_variable", "loc": [18, 18], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98857:FunctionDef_L13_C4", "vector": [14, 2, 0.15, 0.0083, 2, 0.24, 1.0, 663, 1, 0, 0, 0, 0, 9, 0], "semantic": {"name": "self._num_pages", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self._num_pages = self._count = None"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98857:FunctionDef_L20_C4", "label": "validate_number", "type": "function", "loc": [20, 33], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98857:ClassDef_L12_C0", "vector": [2, 1, 0.2208, 0.1167, 1, 0.35, 0.125, 375, 0, 2, 1, 0, 0, 0, 4], "semantic": {"name": "validate_number", "arg_names": ["self", "number"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def validate_number(self, number):\n \"Validates the given 1-based page number.\"\n try:\n number = int(number)\n except ValueError:\n raise PageNotAnInteger('That page number is not an integer')\n if number < 1:\n raise EmptyPage('That page number is less than 1')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98857:Expr_L21_C8", "label": "expression", "type": "expression", "loc": [21, 21], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98857:FunctionDef_L20_C4", "vector": [8, 2, 0.175, 0.0083, 2, 0.54, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"Validates the given 1-based page number.\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98857:Try_L22_C8", "label": "try", "type": "try", "loc": [22, 25], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98857:FunctionDef_L20_C4", "vector": [7, 2, 0.1958, 0.0333, 2, 0.54, 0.25, 0, 0, 1, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " try:\n number = int(number)\n except ValueError:\n raise PageNotAnInteger('That page number is not an integer')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98857:Assign_L23_C12", "label": "number = int()", "type": "assigned_variable", "loc": [23, 23], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98857:Try_L22_C8", "vector": [14, 3, 0.1917, 0.0083, 3, 0.92, 0.0, 408, 3, 1, 0, 0, 901, 10, 1], "semantic": {"name": "number", "arg_names": [], "import_names": [], "rhs_call_name": "int", "annotation": ""}, "snippet": " number = int(number)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98857:If_L26_C8", "label": "if", "type": "if", "loc": [26, 27], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98857:FunctionDef_L20_C4", "vector": [4, 2, 0.2208, 0.0167, 2, 0.54, 0.5, 0, 0, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if number < 1:\n raise EmptyPage('That page number is less than 1')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98857:If_L28_C8", "label": "if", "type": "if", "loc": [28, 32], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98857:FunctionDef_L20_C4", "vector": [4, 2, 0.25, 0.0417, 2, 0.54, 0.75, 0, 0, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if number > self.num_pages:\n if number == 1 and self.allow_empty_first_page:\n pass\n else:\n raise EmptyPage('That page contains no results')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98857:If_L29_C12", "label": "if", "type": "if", "loc": [29, 32], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98857:If_L28_C8", "vector": [4, 3, 0.2542, 0.0333, 3, 0.83, 0.0, 0, 0, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if number == 1 and self.allow_empty_first_page:\n pass\n else:\n raise EmptyPage('That page contains no results')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98857:Return_L33_C8", "label": "return", "type": "return", "loc": [33, 33], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98857:FunctionDef_L20_C4", "vector": [13, 2, 0.275, 0.0083, 2, 0.54, 1.0, 0, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return number"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98857:FunctionDef_L35_C4", "label": "page", "type": "function", "loc": [35, 42], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98857:ClassDef_L12_C0", "vector": [2, 1, 0.3208, 0.0667, 1, 0.35, 0.25, 623, 0, 2, 1, 0, 0, 0, 2], "semantic": {"name": "page", "arg_names": ["self", "number"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def page(self, number):\n \"Returns a Page object for the given 1-based page number.\"\n number = self.validate_number(number)\n bottom = (number - 1) * self.per_page\n top = bottom + self.per_page\n if top + self.orphans >= self.count:\n top = self.count\n return Page(self.object_list[bottom:top], number, self)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98857:Expr_L36_C8", "label": "expression", "type": "expression", "loc": [36, 36], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98857:FunctionDef_L35_C4", "vector": [8, 2, 0.3, 0.0083, 2, 0.8, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"Returns a Page object for the given 1-based page number.\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98857:Assign_L37_C8", "label": "number = validate_number()", "type": "assigned_variable", "loc": [37, 37], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98857:FunctionDef_L35_C4", "vector": [14, 2, 0.3083, 0.0083, 2, 0.8, 0.2, 408, 3, 1, 0, 0, 375, 10, 1], "semantic": {"name": "number", "arg_names": [], "import_names": [], "rhs_call_name": "validate_number", "annotation": ""}, "snippet": " number = self.validate_number(number)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98857:Assign_L38_C8", "label": "bottom =", "type": "assigned_variable", "loc": [38, 38], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98857:FunctionDef_L35_C4", "vector": [14, 2, 0.3167, 0.0083, 2, 0.8, 0.4, 391, 4, 0, 0, 0, 0, 0, 0], "semantic": {"name": "bottom", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " bottom = (number - 1) * self.per_page"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98857:Assign_L39_C8", "label": "top =", "type": "assigned_variable", "loc": [39, 39], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98857:FunctionDef_L35_C4", "vector": [14, 2, 0.325, 0.0083, 2, 0.8, 0.6, 208, 4, 0, 0, 0, 0, 0, 0], "semantic": {"name": "top", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " top = bottom + self.per_page"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98857:If_L40_C8", "label": "if", "type": "if", "loc": [40, 41], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98857:FunctionDef_L35_C4", "vector": [4, 2, 0.3375, 0.0167, 2, 0.8, 0.8, 0, 0, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if top + self.orphans >= self.count:\n top = self.count"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98857:Assign_L41_C12", "label": "top =", "type": "assigned_variable", "loc": [41, 41], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98857:If_L40_C8", "vector": [14, 3, 0.3417, 0.0083, 3, 0.65, 0.0, 208, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "top", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " top = self.count"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98857:Return_L42_C8", "label": "return", "type": "return", "loc": [42, 42], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98857:FunctionDef_L35_C4", "vector": [13, 2, 0.35, 0.0083, 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 Page(self.object_list[bottom:top], number, self)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98857:FunctionDef_L44_C4", "label": "_get_count", "type": "function", "loc": [44, 54], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98857:ClassDef_L12_C0", "vector": [2, 1, 0.4083, 0.0917, 1, 0.35, 0.375, 77, 0, 1, 1, 0, 0, 0, 2], "semantic": {"name": "_get_count", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def _get_count(self):\n \"Returns the total number of objects, across all pages.\"\n if self._count is None:\n try:\n self._count = self.object_list.count()\n except (AttributeError, TypeError):\n # AttributeError if object_list has no count() method.\n # TypeError if object_list.count() requires arguments"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98857:Expr_L45_C8", "label": "expression", "type": "expression", "loc": [45, 45], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98857:FunctionDef_L44_C4", "vector": [8, 2, 0.375, 0.0083, 2, 0.0, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"Returns the total number of objects, across all pages.\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98857:If_L46_C8", "label": "if", "type": "if", "loc": [46, 53], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98857:FunctionDef_L44_C4", "vector": [4, 2, 0.4125, 0.0667, 2, 0.0, 0.5, 0, 0, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if self._count is None:\n try:\n self._count = self.object_list.count()\n except (AttributeError, TypeError):\n # AttributeError if object_list has no count() method.\n # TypeError if object_list.count() requires arguments\n # (i.e. is of type list).\n self._count = len(self.object_list)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98857:Try_L47_C12", "label": "try", "type": "try", "loc": [47, 53], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98857:If_L46_C8", "vector": [7, 3, 0.4167, 0.0583, 3, 0.11, 0.0, 0, 0, 1, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " try:\n self._count = self.object_list.count()\n except (AttributeError, TypeError):\n # AttributeError if object_list has no count() method.\n # TypeError if object_list.count() requires arguments\n # (i.e. is of type list).\n self._count = len(self.object_list)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98857:Assign_L48_C16", "label": "self._count = count()", "type": "assigned_variable", "loc": [48, 48], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98857:Try_L47_C12", "vector": [14, 4, 0.4, 0.0083, 4, 0.16, 0.0, 611, 3, 0, 0, 0, 778, 10, 1], "semantic": {"name": "self._count", "arg_names": [], "import_names": [], "rhs_call_name": "count", "annotation": ""}, "snippet": " self._count = self.object_list.count()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98857:Assign_L53_C16", "label": "self._count = len()", "type": "assigned_variable", "loc": [53, 53], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98857:Try_L47_C12", "vector": [14, 4, 0.4417, 0.0083, 4, 0.16, 0.0, 611, 3, 1, 0, 0, 890, 10, 1], "semantic": {"name": "self._count", "arg_names": [], "import_names": [], "rhs_call_name": "len", "annotation": ""}, "snippet": " self._count = len(self.object_list)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98857:Return_L54_C8", "label": "return", "type": "return", "loc": [54, 54], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98857:FunctionDef_L44_C4", "vector": [13, 2, 0.45, 0.0083, 2, 0.0, 1.0, 0, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return self._count"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98857:Assign_L55_C4", "label": "count = property()", "type": "assigned_variable", "loc": [55, 55], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98857:ClassDef_L12_C0", "vector": [14, 1, 0.4583, 0.0083, 1, 0.35, 0.5, 778, 3, 1, 0, 0, 244, 10, 1], "semantic": {"name": "count", "arg_names": [], "import_names": [], "rhs_call_name": "property", "annotation": ""}, "snippet": " count = property(_get_count)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98857:FunctionDef_L57_C4", "label": "_get_num_pages", "type": "function", "loc": [57, 65], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98857:ClassDef_L12_C0", "vector": [2, 1, 0.5083, 0.075, 1, 0.35, 0.625, 136, 0, 1, 1, 0, 0, 0, 4], "semantic": {"name": "_get_num_pages", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def _get_num_pages(self):\n \"Returns the total number of pages.\"\n if self._num_pages is None:\n if self.count == 0 and not self.allow_empty_first_page:\n self._num_pages = 0\n else:\n hits = max(1, self.count - self.orphans)\n self._num_pages = int(ceil(hits / float(self.per_page)))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98857:Expr_L58_C8", "label": "expression", "type": "expression", "loc": [58, 58], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98857:FunctionDef_L57_C4", "vector": [8, 2, 0.4833, 0.0083, 2, 0.97, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"Returns the total number of pages.\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98857:If_L59_C8", "label": "if", "type": "if", "loc": [59, 64], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98857:FunctionDef_L57_C4", "vector": [4, 2, 0.5125, 0.05, 2, 0.97, 0.5, 0, 0, 0, 0, 0, 0, 0, 4], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if self._num_pages is None:\n if self.count == 0 and not self.allow_empty_first_page:\n self._num_pages = 0\n else:\n hits = max(1, self.count - self.orphans)\n self._num_pages = int(ceil(hits / float(self.per_page)))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98857:If_L60_C12", "label": "if", "type": "if", "loc": [60, 64], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98857:If_L59_C8", "vector": [4, 3, 0.5167, 0.0417, 3, 0.59, 0.0, 0, 0, 0, 0, 0, 0, 0, 4], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if self.count == 0 and not self.allow_empty_first_page:\n self._num_pages = 0\n else:\n hits = max(1, self.count - self.orphans)\n self._num_pages = int(ceil(hits / float(self.per_page)))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98857:Assign_L61_C16", "label": "self._num_pages =", "type": "assigned_variable", "loc": [61, 61], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98857:If_L60_C12", "vector": [14, 4, 0.5083, 0.0083, 4, 0.06, 0.0, 663, 1, 0, 0, 0, 0, 1, 0], "semantic": {"name": "self._num_pages", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self._num_pages = 0"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98857:Assign_L63_C16", "label": "hits = max()", "type": "assigned_variable", "loc": [63, 63], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98857:If_L60_C12", "vector": [14, 4, 0.525, 0.0083, 4, 0.06, 0.5, 299, 3, 2, 0, 0, 442, 10, 1], "semantic": {"name": "hits", "arg_names": [], "import_names": [], "rhs_call_name": "max", "annotation": ""}, "snippet": " hits = max(1, self.count - self.orphans)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98857:Assign_L64_C16", "label": "self._num_pages = int()", "type": "assigned_variable", "loc": [64, 64], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98857:If_L60_C12", "vector": [14, 4, 0.5333, 0.0083, 4, 0.06, 1.0, 663, 3, 1, 0, 0, 901, 10, 3], "semantic": {"name": "self._num_pages", "arg_names": [], "import_names": [], "rhs_call_name": "int", "annotation": ""}, "snippet": " self._num_pages = int(ceil(hits / float(self.per_page)))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98857:Return_L65_C8", "label": "return", "type": "return", "loc": [65, 65], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98857:FunctionDef_L57_C4", "vector": [13, 2, 0.5417, 0.0083, 2, 0.97, 1.0, 0, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return self._num_pages"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98857:Assign_L66_C4", "label": "num_pages = property()", "type": "assigned_variable", "loc": [66, 66], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98857:ClassDef_L12_C0", "vector": [14, 1, 0.55, 0.0083, 1, 0.35, 0.75, 477, 3, 1, 0, 0, 244, 10, 1], "semantic": {"name": "num_pages", "arg_names": [], "import_names": [], "rhs_call_name": "property", "annotation": ""}, "snippet": " num_pages = property(_get_num_pages)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98857:FunctionDef_L68_C4", "label": "_get_page_range", "type": "function", "loc": [68, 73], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98857:ClassDef_L12_C0", "vector": [2, 1, 0.5875, 0.05, 1, 0.35, 0.875, 900, 0, 1, 1, 0, 0, 0, 1], "semantic": {"name": "_get_page_range", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def _get_page_range(self):\n \"\"\"\n Returns a 1-based range of pages for iterating through within\n a template for loop.\n \"\"\"\n return range(1, self.num_pages + 1)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98857:Expr_L69_C8", "label": "expression", "type": "expression", "loc": [69, 72], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98857:FunctionDef_L68_C4", "vector": [8, 2, 0.5875, 0.0333, 2, 0.55, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"\n Returns a 1-based range of pages for iterating through within\n a template for loop.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98857:Return_L73_C8", "label": "return", "type": "return", "loc": [73, 73], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98857:FunctionDef_L68_C4", "vector": [13, 2, 0.6083, 0.0083, 2, 0.55, 1.0, 0, 3, 0, 0, 0, 0, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return range(1, self.num_pages + 1)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98857:Assign_L74_C4", "label": "page_range = property()", "type": "assigned_variable", "loc": [74, 74], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98857:ClassDef_L12_C0", "vector": [14, 1, 0.6167, 0.0083, 1, 0.35, 1.0, 809, 3, 1, 0, 0, 244, 10, 1], "semantic": {"name": "page_range", "arg_names": [], "import_names": [], "rhs_call_name": "property", "annotation": ""}, "snippet": " page_range = property(_get_page_range)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98857:Assign_L76_C0", "label": "QuerySetPaginator =", "type": "assigned_variable", "loc": [76, 76], "level": 0, "parent": null, "vector": [14, 0, 0.6333, 0.0083, 0, 0.66, 0.8333, 735, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "QuerySetPaginator", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "QuerySetPaginator = Paginator # For backwards-compatibility."}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98857:ClassDef_L78_C0", "label": "Page", "type": "class", "loc": [78, 120], "level": 0, "parent": null, "vector": [3, 0, 0.825, 0.3583, 0, 0.66, 1.0, 703, 0, 9, 0, 0, 186, 0, 2], "semantic": {"name": "Page", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class Page(object):\n def __init__(self, object_list, number, paginator):\n self.object_list = object_list\n self.number = number\n self.paginator = paginator\n\n def __repr__(self):\n return '<Page %s of %s>' % (self.number, self.paginator.num_pages)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98857:FunctionDef_L79_C4", "label": "__init__", "type": "function", "loc": [79, 82], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98857:ClassDef_L78_C0", "vector": [2, 1, 0.6708, 0.0333, 1, 0.82, 0.0, 555, 0, 4, 0, 0, 0, 0, 0], "semantic": {"name": "__init__", "arg_names": ["self", "object_list", "number", "paginator"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def __init__(self, object_list, number, paginator):\n self.object_list = object_list\n self.number = number\n self.paginator = paginator"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98857:Assign_L80_C8", "label": "self.object_list =", "type": "assigned_variable", "loc": [80, 80], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98857:FunctionDef_L79_C4", "vector": [14, 2, 0.6667, 0.0083, 2, 0.3, 0.0, 569, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "self.object_list", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.object_list = object_list"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98857:Assign_L81_C8", "label": "self.number =", "type": "assigned_variable", "loc": [81, 81], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98857:FunctionDef_L79_C4", "vector": [14, 2, 0.675, 0.0083, 2, 0.3, 0.5, 343, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "self.number", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.number = number"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98857:Assign_L82_C8", "label": "self.paginator =", "type": "assigned_variable", "loc": [82, 82], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98857:FunctionDef_L79_C4", "vector": [14, 2, 0.6833, 0.0083, 2, 0.3, 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_98857:FunctionDef_L84_C4", "label": "__repr__", "type": "function", "loc": [84, 85], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98857:ClassDef_L78_C0", "vector": [2, 1, 0.7042, 0.0167, 1, 0.82, 0.125, 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 '<Page %s of %s>' % (self.number, self.paginator.num_pages)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98857:Return_L85_C8", "label": "return", "type": "return", "loc": [85, 85], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98857:FunctionDef_L84_C4", "vector": [13, 2, 0.7083, 0.0083, 2, 0.38, 0.0, 0, 4, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return '<Page %s of %s>' % (self.number, self.paginator.num_pages)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98857:FunctionDef_L87_C4", "label": "has_next", "type": "function", "loc": [87, 88], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98857:ClassDef_L78_C0", "vector": [2, 1, 0.7292, 0.0167, 1, 0.82, 0.25, 46, 0, 1, 1, 0, 0, 0, 0], "semantic": {"name": "has_next", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def has_next(self):\n return self.number < self.paginator.num_pages"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98857:Return_L88_C8", "label": "return", "type": "return", "loc": [88, 88], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98857:FunctionDef_L87_C4", "vector": [13, 2, 0.7333, 0.0083, 2, 0.6, 0.0, 0, 0, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return self.number < self.paginator.num_pages"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98857:FunctionDef_L90_C4", "label": "has_previous", "type": "function", "loc": [90, 91], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98857:ClassDef_L78_C0", "vector": [2, 1, 0.7542, 0.0167, 1, 0.82, 0.375, 835, 0, 1, 1, 0, 0, 0, 0], "semantic": {"name": "has_previous", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def has_previous(self):\n return self.number > 1"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98857:Return_L91_C8", "label": "return", "type": "return", "loc": [91, 91], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98857:FunctionDef_L90_C4", "vector": [13, 2, 0.7583, 0.0083, 2, 0.68, 0.0, 0, 0, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return self.number > 1"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98857:FunctionDef_L93_C4", "label": "has_other_pages", "type": "function", "loc": [93, 94], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98857:ClassDef_L78_C0", "vector": [2, 1, 0.7792, 0.0167, 1, 0.82, 0.5, 156, 0, 1, 1, 0, 0, 0, 2], "semantic": {"name": "has_other_pages", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def has_other_pages(self):\n return self.has_previous() or self.has_next()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98857:Return_L94_C8", "label": "return", "type": "return", "loc": [94, 94], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98857:FunctionDef_L93_C4", "vector": [13, 2, 0.7833, 0.0083, 2, 0.7, 0.0, 0, 0, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return self.has_previous() or self.has_next()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98857:FunctionDef_L96_C4", "label": "next_page_number", "type": "function", "loc": [96, 97], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98857:ClassDef_L78_C0", "vector": [2, 1, 0.8042, 0.0167, 1, 0.82, 0.625, 319, 0, 1, 1, 0, 0, 0, 0], "semantic": {"name": "next_page_number", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def next_page_number(self):\n return self.number + 1"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98857:Return_L97_C8", "label": "return", "type": "return", "loc": [97, 97], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98857:FunctionDef_L96_C4", "vector": [13, 2, 0.8083, 0.0083, 2, 0.76, 0.0, 0, 4, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return self.number + 1"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98857:FunctionDef_L99_C4", "label": "previous_page_number", "type": "function", "loc": [99, 100], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98857:ClassDef_L78_C0", "vector": [2, 1, 0.8292, 0.0167, 1, 0.82, 0.75, 843, 0, 1, 1, 0, 0, 0, 0], "semantic": {"name": "previous_page_number", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def previous_page_number(self):\n return self.number - 1"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98857:Return_L100_C8", "label": "return", "type": "return", "loc": [100, 100], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98857:FunctionDef_L99_C4", "vector": [13, 2, 0.8333, 0.0083, 2, 0.76, 0.0, 0, 4, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return self.number - 1"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98857:FunctionDef_L102_C4", "label": "start_index", "type": "function", "loc": [102, 110], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98857:ClassDef_L78_C0", "vector": [2, 1, 0.8833, 0.075, 1, 0.82, 0.875, 553, 0, 1, 1, 0, 0, 0, 0], "semantic": {"name": "start_index", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def start_index(self):\n \"\"\"\n Returns the 1-based index of the first object on this page,\n relative to total objects in the paginator.\n \"\"\"\n # Special case, return zero if no items.\n if self.paginator.count == 0:\n return 0"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98857:Expr_L103_C8", "label": "expression", "type": "expression", "loc": [103, 106], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98857:FunctionDef_L102_C4", "vector": [8, 2, 0.8708, 0.0333, 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 1-based index of the first object on this page,\n relative to total objects in the paginator.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98857:If_L108_C8", "label": "if", "type": "if", "loc": [108, 109], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98857:FunctionDef_L102_C4", "vector": [4, 2, 0.9042, 0.0167, 2, 0.4, 0.5, 0, 0, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if self.paginator.count == 0:\n return 0"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98857:Return_L109_C12", "label": "return", "type": "return", "loc": [109, 109], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98857:If_L108_C8", "vector": [13, 3, 0.9083, 0.0083, 3, 0.96, 0.0, 0, 1, 0, 0, 0, 0, 1, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return 0"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98857:Return_L110_C8", "label": "return", "type": "return", "loc": [110, 110], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98857:FunctionDef_L102_C4", "vector": [13, 2, 0.9167, 0.0083, 2, 0.4, 1.0, 0, 4, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return (self.paginator.per_page * (self.number - 1)) + 1"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98857:FunctionDef_L112_C4", "label": "end_index", "type": "function", "loc": [112, 120], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98857:ClassDef_L78_C0", "vector": [2, 1, 0.9667, 0.075, 1, 0.82, 1.0, 48, 0, 1, 1, 0, 0, 0, 0], "semantic": {"name": "end_index", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def end_index(self):\n \"\"\"\n Returns the 1-based index of the last object on this page,\n relative to total objects found (hits).\n \"\"\"\n # Special case for the last page because there can be orphans.\n if self.number == self.paginator.num_pages:\n return self.paginator.count"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98857:Expr_L113_C8", "label": "expression", "type": "expression", "loc": [113, 116], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98857:FunctionDef_L112_C4", "vector": [8, 2, 0.9542, 0.0333, 2, 0.25, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"\n Returns the 1-based index of the last object on this page,\n relative to total objects found (hits).\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98857:If_L118_C8", "label": "if", "type": "if", "loc": [118, 119], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98857:FunctionDef_L112_C4", "vector": [4, 2, 0.9875, 0.0167, 2, 0.25, 0.5, 0, 0, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if self.number == self.paginator.num_pages:\n return self.paginator.count"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98857:Return_L119_C12", "label": "return", "type": "return", "loc": [119, 119], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98857:If_L118_C8", "vector": [13, 3, 0.9917, 0.0083, 3, 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.paginator.count"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98857:Return_L120_C8", "label": "return", "type": "return", "loc": [120, 120], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98857:FunctionDef_L112_C4", "vector": [13, 2, 1.0, 0.0083, 2, 0.25, 1.0, 0, 4, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return self.number * self.paginator.per_page"}]
[{"f": "ajibawa-2023/Python-Code-Large/train/row_98857:ClassDef_L12_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98857:FunctionDef_L13_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98857:FunctionDef_L13_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98857:Assign_L14_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98857:FunctionDef_L13_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98857:Assign_L15_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98857:FunctionDef_L13_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98857:Assign_L16_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98857:FunctionDef_L13_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98857:Assign_L17_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98857:FunctionDef_L13_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98857:Assign_L18_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98857:ClassDef_L12_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98857:FunctionDef_L20_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98857:FunctionDef_L20_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98857:Expr_L21_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98857:FunctionDef_L20_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98857:Try_L22_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98857:Try_L22_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98857:Assign_L23_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98857:FunctionDef_L20_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98857:If_L26_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98857:FunctionDef_L20_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98857:If_L28_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98857:If_L28_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98857:If_L29_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98857:FunctionDef_L20_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98857:Return_L33_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98857:ClassDef_L12_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98857:FunctionDef_L35_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98857:FunctionDef_L35_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98857:Expr_L36_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98857:FunctionDef_L35_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98857:Assign_L37_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98857:FunctionDef_L35_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98857:Assign_L38_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98857:FunctionDef_L35_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98857:Assign_L39_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98857:FunctionDef_L35_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98857:If_L40_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98857:If_L40_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98857:Assign_L41_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98857:FunctionDef_L35_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98857:Return_L42_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98857:ClassDef_L12_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98857:FunctionDef_L44_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98857:FunctionDef_L44_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98857:Expr_L45_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98857:FunctionDef_L44_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98857:If_L46_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98857:If_L46_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98857:Try_L47_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98857:Try_L47_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98857:Assign_L48_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98857:Try_L47_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98857:Assign_L53_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98857:FunctionDef_L44_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98857:Return_L54_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98857:ClassDef_L12_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98857:Assign_L55_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98857:ClassDef_L12_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98857:FunctionDef_L57_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98857:FunctionDef_L57_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98857:Expr_L58_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98857:FunctionDef_L57_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98857:If_L59_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98857:If_L59_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98857:If_L60_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98857:If_L60_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98857:Assign_L61_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98857:If_L60_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98857:Assign_L63_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98857:If_L60_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98857:Assign_L64_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98857:FunctionDef_L57_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98857:Return_L65_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98857:ClassDef_L12_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98857:Assign_L66_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98857:ClassDef_L12_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98857:FunctionDef_L68_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98857:FunctionDef_L68_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98857:Expr_L69_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98857:FunctionDef_L68_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98857:Return_L73_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98857:ClassDef_L12_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98857:Assign_L74_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98857:ClassDef_L78_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98857:FunctionDef_L79_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98857:FunctionDef_L79_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98857:Assign_L80_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98857:FunctionDef_L79_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98857:Assign_L81_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98857:FunctionDef_L79_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98857:Assign_L82_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98857:ClassDef_L78_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98857:FunctionDef_L84_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98857:FunctionDef_L84_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98857:Return_L85_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98857:ClassDef_L78_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98857:FunctionDef_L87_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98857:FunctionDef_L87_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98857:Return_L88_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98857:ClassDef_L78_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98857:FunctionDef_L90_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98857:FunctionDef_L90_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98857:Return_L91_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98857:ClassDef_L78_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98857:FunctionDef_L93_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98857:FunctionDef_L93_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98857:Return_L94_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98857:ClassDef_L78_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98857:FunctionDef_L96_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98857:FunctionDef_L96_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98857:Return_L97_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98857:ClassDef_L78_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98857:FunctionDef_L99_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98857:FunctionDef_L99_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98857:Return_L100_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98857:ClassDef_L78_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98857:FunctionDef_L102_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98857:FunctionDef_L102_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98857:Expr_L103_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98857:FunctionDef_L102_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98857:If_L108_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98857:If_L108_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98857:Return_L109_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98857:FunctionDef_L102_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98857:Return_L110_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98857:ClassDef_L78_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98857:FunctionDef_L112_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98857:FunctionDef_L112_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98857:Expr_L113_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98857:FunctionDef_L112_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98857:If_L118_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98857:If_L118_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98857:Return_L119_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98857:FunctionDef_L112_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98857:Return_L120_C8"}]
""" Pages in Django can are served up with custom HTTP headers containing useful information about those pages -- namely, the content type and object ID. This module contains utility functions for retrieving and doing interesting things with these special "X-Headers" (so called because the HTTP spec demands that custom headers are prefixed with "X-"). Next time you're at slashdot.org, watch out for X-Fry and X-Bender. :) """ def populate_xheaders(request, response, model, object_id): """ Adds the "X-Object-Type" and "X-Object-Id" headers to the given HttpResponse according to the given model and object_id -- but only if the given HttpRequest object has an IP address within the INTERNAL_IPS setting or if the request is from a logged in staff member. """ from django.conf import settings if (request.META.get('REMOTE_ADDR') in settings.INTERNAL_IPS or (hasattr(request, 'user') and request.user.is_active and request.user.is_staff)): response['X-Object-Type'] = "%s.%s" % (model._meta.app_label, model._meta.object_name.lower()) response['X-Object-Id'] = str(object_id)
ajibawa-2023/Python-Code-Large/train/row_98860
7
24
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_98860:Expr_L1_C0", "label": "expression", "type": "expression", "loc": [1, 10], "level": 0, "parent": null, "vector": [8, 0, 0.2292, 0.4167, 0, 0.66, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "\"\"\"\nPages in Django can are served up with custom HTTP headers containing useful\ninformation about those pages -- namely, the content type and object ID.\n\nThis module contains utility functions for retrieving and doing interesting\nthings with these special \"X-Headers\" (so called because the HTTP spec demands\nthat custom headers are prefixed with \"X-\").\n"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98860:FunctionDef_L12_C0", "label": "populate_xheaders", "type": "function", "loc": [12, 24], "level": 0, "parent": null, "vector": [2, 0, 0.75, 0.5417, 0, 0.66, 1.0, 146, 0, 4, 0, 0, 0, 0, 4], "semantic": {"name": "populate_xheaders", "arg_names": ["request", "response", "model", "object_id"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "def populate_xheaders(request, response, model, object_id):\n \"\"\"\n Adds the \"X-Object-Type\" and \"X-Object-Id\" headers to the given\n HttpResponse according to the given model and object_id -- but only if the\n given HttpRequest object has an IP address within the INTERNAL_IPS setting\n or if the request is from a logged in staff member.\n \"\"\"\n from django.conf import settings"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98860:Expr_L13_C4", "label": "expression", "type": "expression", "loc": [13, 18], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98860:FunctionDef_L12_C0", "vector": [8, 1, 0.6458, 0.25, 1, 0.0, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"\n Adds the \"X-Object-Type\" and \"X-Object-Id\" headers to the given\n HttpResponse according to the given model and object_id -- but only if the\n given HttpRequest object has an IP address within the INTERNAL_IPS setting\n or if the request is from a logged in staff member.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98860:ImportFrom_L19_C4", "label": "from django.conf import settings", "type": "import", "loc": [19, 19], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98860:FunctionDef_L12_C0", "vector": [1, 1, 0.7917, 0.0417, 1, 0.0, 0.5, 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_98860:If_L20_C4", "label": "if", "type": "if", "loc": [20, 24], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98860:FunctionDef_L12_C0", "vector": [4, 1, 0.9167, 0.2083, 1, 0.0, 1.0, 0, 0, 0, 0, 0, 0, 0, 4], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if (request.META.get('REMOTE_ADDR') in settings.INTERNAL_IPS\n or (hasattr(request, 'user') and request.user.is_active\n and request.user.is_staff)):\n response['X-Object-Type'] = \"%s.%s\" % (model._meta.app_label, model._meta.object_name.lower())\n response['X-Object-Id'] = str(object_id)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98860:Assign_L23_C8", "label": "assign", "type": "assigned_variable", "loc": [23, 23], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98860:If_L20_C4", "vector": [14, 2, 0.9583, 0.0417, 2, 0.23, 0.0, 0, 4, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " response['X-Object-Type'] = \"%s.%s\" % (model._meta.app_label, model._meta.object_name.lower())"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98860:Assign_L24_C8", "label": " = str()", "type": "assigned_variable", "loc": [24, 24], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98860:If_L20_C4", "vector": [14, 2, 1.0, 0.0417, 2, 0.23, 1.0, 0, 3, 1, 0, 0, 52, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "str", "annotation": ""}, "snippet": " response['X-Object-Id'] = str(object_id)"}]
[{"f": "ajibawa-2023/Python-Code-Large/train/row_98860:FunctionDef_L12_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98860:Expr_L13_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98860:FunctionDef_L12_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98860:ImportFrom_L19_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98860:FunctionDef_L12_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98860:If_L20_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98860:If_L20_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98860:Assign_L23_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98860:If_L20_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98860:Assign_L24_C8"}]
""" Global Django exception and warning classes. """ class DjangoRuntimeWarning(RuntimeWarning): pass class ObjectDoesNotExist(Exception): "The requested object does not exist" silent_variable_failure = True class MultipleObjectsReturned(Exception): "The query returned multiple objects when only one was expected." pass class SuspiciousOperation(Exception): "The user did something suspicious" pass class PermissionDenied(Exception): "The user did not have permission to do that" pass class ViewDoesNotExist(Exception): "The requested view does not exist" pass class MiddlewareNotUsed(Exception): "This middleware is not used in this server configuration" pass class ImproperlyConfigured(Exception): "Django is somehow improperly configured" pass class FieldError(Exception): """Some kind of problem with a model field.""" pass NON_FIELD_ERRORS = '__all__' class ValidationError(Exception): """An error while validating data.""" def __init__(self, message, code=None, params=None): import operator from django.utils.encoding import force_unicode """ ValidationError can be passed any object that can be printed (usually a string), a list of objects or a dictionary. """ if isinstance(message, dict): self.message_dict = message # Reduce each list of messages into a single list. message = reduce(operator.add, message.values()) if isinstance(message, list): self.messages = [force_unicode(msg) for msg in message] else: self.code = code self.params = params message = force_unicode(message) self.messages = [message] def __str__(self): # This is needed because, without a __str__(), printing an exception # instance would result in this: # AttributeError: ValidationError instance has no attribute 'args' # See http://www.python.org/doc/current/tut/node10.html#handling if hasattr(self, 'message_dict'): return repr(self.message_dict) return repr(self.messages) def __repr__(self): if hasattr(self, 'message_dict'): return 'ValidationError(%s)' % repr(self.message_dict) return 'ValidationError(%s)' % repr(self.messages) def update_error_dict(self, error_dict): if hasattr(self, 'message_dict'): if error_dict: for k, v in self.message_dict.items(): error_dict.setdefault(k, []).extend(v) else: error_dict = self.message_dict else: error_dict[NON_FIELD_ERRORS] = self.messages return error_dict
ajibawa-2023/Python-Code-Large/train/row_98862
51
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_98862: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": "\"\"\"\nGlobal Django exception and warning classes.\n\"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98862:ClassDef_L5_C0", "label": "DjangoRuntimeWarning", "type": "class", "loc": [5, 6], "level": 0, "parent": null, "vector": [3, 0, 0.0632, 0.023, 0, 0.66, 0.0909, 653, 0, 0, 0, 0, 973, 0, 0], "semantic": {"name": "DjangoRuntimeWarning", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class DjangoRuntimeWarning(RuntimeWarning):\n pass"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98862:ClassDef_L8_C0", "label": "ObjectDoesNotExist", "type": "class", "loc": [8, 10], "level": 0, "parent": null, "vector": [3, 0, 0.1034, 0.0345, 0, 0.66, 0.1818, 443, 0, 0, 0, 0, 645, 0, 0], "semantic": {"name": "ObjectDoesNotExist", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class ObjectDoesNotExist(Exception):\n \"The requested object does not exist\"\n silent_variable_failure = True"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98862:Expr_L9_C4", "label": "expression", "type": "expression", "loc": [9, 9], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98862:ClassDef_L8_C0", "vector": [8, 1, 0.1034, 0.0115, 1, 0.87, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"The requested object does not exist\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98862:Assign_L10_C4", "label": "silent_variable_failure =", "type": "assigned_variable", "loc": [10, 10], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98862:ClassDef_L8_C0", "vector": [14, 1, 0.1149, 0.0115, 1, 0.87, 1.0, 884, 1, 0, 0, 0, 0, 4, 0], "semantic": {"name": "silent_variable_failure", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " silent_variable_failure = True"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98862:ClassDef_L12_C0", "label": "MultipleObjectsReturned", "type": "class", "loc": [12, 14], "level": 0, "parent": null, "vector": [3, 0, 0.1494, 0.0345, 0, 0.66, 0.2727, 749, 0, 0, 0, 0, 645, 0, 0], "semantic": {"name": "MultipleObjectsReturned", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class MultipleObjectsReturned(Exception):\n \"The query returned multiple objects when only one was expected.\"\n pass"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98862:Expr_L13_C4", "label": "expression", "type": "expression", "loc": [13, 13], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98862:ClassDef_L12_C0", "vector": [8, 1, 0.1494, 0.0115, 1, 0.76, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"The query returned multiple objects when only one was expected.\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98862:ClassDef_L16_C0", "label": "SuspiciousOperation", "type": "class", "loc": [16, 18], "level": 0, "parent": null, "vector": [3, 0, 0.1954, 0.0345, 0, 0.66, 0.3636, 345, 0, 0, 0, 0, 645, 0, 0], "semantic": {"name": "SuspiciousOperation", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class SuspiciousOperation(Exception):\n \"The user did something suspicious\"\n pass"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98862:Expr_L17_C4", "label": "expression", "type": "expression", "loc": [17, 17], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98862:ClassDef_L16_C0", "vector": [8, 1, 0.1954, 0.0115, 1, 0.86, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"The user did something suspicious\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98862:ClassDef_L20_C0", "label": "PermissionDenied", "type": "class", "loc": [20, 22], "level": 0, "parent": null, "vector": [3, 0, 0.2414, 0.0345, 0, 0.66, 0.4545, 984, 0, 0, 0, 0, 645, 0, 0], "semantic": {"name": "PermissionDenied", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class PermissionDenied(Exception):\n \"The user did not have permission to do that\"\n pass"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98862:Expr_L21_C4", "label": "expression", "type": "expression", "loc": [21, 21], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98862:ClassDef_L20_C0", "vector": [8, 1, 0.2414, 0.0115, 1, 0.59, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"The user did not have permission to do that\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98862:ClassDef_L24_C0", "label": "ViewDoesNotExist", "type": "class", "loc": [24, 26], "level": 0, "parent": null, "vector": [3, 0, 0.2874, 0.0345, 0, 0.66, 0.5455, 824, 0, 0, 0, 0, 645, 0, 0], "semantic": {"name": "ViewDoesNotExist", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class ViewDoesNotExist(Exception):\n \"The requested view does not exist\"\n pass"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98862:Expr_L25_C4", "label": "expression", "type": "expression", "loc": [25, 25], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98862:ClassDef_L24_C0", "vector": [8, 1, 0.2874, 0.0115, 1, 0.63, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"The requested view does not exist\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98862:ClassDef_L28_C0", "label": "MiddlewareNotUsed", "type": "class", "loc": [28, 30], "level": 0, "parent": null, "vector": [3, 0, 0.3333, 0.0345, 0, 0.66, 0.6364, 250, 0, 0, 0, 0, 645, 0, 0], "semantic": {"name": "MiddlewareNotUsed", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class MiddlewareNotUsed(Exception):\n \"This middleware is not used in this server configuration\"\n pass"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98862:Expr_L29_C4", "label": "expression", "type": "expression", "loc": [29, 29], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98862:ClassDef_L28_C0", "vector": [8, 1, 0.3333, 0.0115, 1, 0.96, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"This middleware is not used in this server configuration\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98862:ClassDef_L32_C0", "label": "ImproperlyConfigured", "type": "class", "loc": [32, 34], "level": 0, "parent": null, "vector": [3, 0, 0.3793, 0.0345, 0, 0.66, 0.7273, 246, 0, 0, 0, 0, 645, 0, 0], "semantic": {"name": "ImproperlyConfigured", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class ImproperlyConfigured(Exception):\n \"Django is somehow improperly configured\"\n pass"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98862:Expr_L33_C4", "label": "expression", "type": "expression", "loc": [33, 33], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98862:ClassDef_L32_C0", "vector": [8, 1, 0.3793, 0.0115, 1, 0.11, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"Django is somehow improperly configured\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98862:ClassDef_L36_C0", "label": "FieldError", "type": "class", "loc": [36, 38], "level": 0, "parent": null, "vector": [3, 0, 0.4253, 0.0345, 0, 0.66, 0.8182, 257, 0, 0, 0, 0, 645, 0, 0], "semantic": {"name": "FieldError", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class FieldError(Exception):\n \"\"\"Some kind of problem with a model field.\"\"\"\n pass"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98862:Expr_L37_C4", "label": "expression", "type": "expression", "loc": [37, 37], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98862:ClassDef_L36_C0", "vector": [8, 1, 0.4253, 0.0115, 1, 0.31, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"Some kind of problem with a model field.\"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98862:Assign_L40_C0", "label": "NON_FIELD_ERRORS =", "type": "assigned_variable", "loc": [40, 40], "level": 0, "parent": null, "vector": [14, 0, 0.4598, 0.0115, 0, 0.66, 0.9091, 305, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "NON_FIELD_ERRORS", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "NON_FIELD_ERRORS = '__all__'"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98862:ClassDef_L41_C0", "label": "ValidationError", "type": "class", "loc": [41, 86], "level": 0, "parent": null, "vector": [3, 0, 0.7299, 0.5287, 0, 0.66, 1.0, 60, 0, 4, 0, 0, 645, 0, 16], "semantic": {"name": "ValidationError", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class ValidationError(Exception):\n \"\"\"An error while validating data.\"\"\"\n def __init__(self, message, code=None, params=None):\n import operator\n from django.utils.encoding import force_unicode\n \"\"\"\n ValidationError can be passed any object that can be printed (usually\n a string), a list of objects or a dictionary."}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98862:Expr_L42_C4", "label": "expression", "type": "expression", "loc": [42, 42], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98862:ClassDef_L41_C0", "vector": [8, 1, 0.4828, 0.0115, 1, 0.33, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"An error while validating data.\"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98862:FunctionDef_L43_C4", "label": "__init__", "type": "function", "loc": [43, 61], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98862:ClassDef_L41_C0", "vector": [2, 1, 0.5977, 0.2184, 1, 0.33, 0.25, 555, 0, 4, 0, 0, 0, 0, 6], "semantic": {"name": "__init__", "arg_names": ["self", "message", "code", "params"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def __init__(self, message, code=None, params=None):\n import operator\n from django.utils.encoding import force_unicode\n \"\"\"\n ValidationError can be passed any object that can be printed (usually\n a string), a list of objects or a dictionary.\n \"\"\"\n if isinstance(message, dict):"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98862:Import_L44_C8", "label": "operator import operator", "type": "import", "loc": [44, 44], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98862:FunctionDef_L43_C4", "vector": [1, 2, 0.5057, 0.0115, 2, 0.77, 0.0, 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_98862:ImportFrom_L45_C8", "label": "from django.utils.encoding import force_unicode", "type": "import", "loc": [45, 45], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98862:FunctionDef_L43_C4", "vector": [1, 2, 0.5172, 0.0115, 2, 0.77, 0.25, 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_98862:Expr_L46_C8", "label": "expression", "type": "expression", "loc": [46, 49], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98862:FunctionDef_L43_C4", "vector": [8, 2, 0.546, 0.046, 2, 0.77, 0.5, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"\n ValidationError can be passed any object that can be printed (usually\n a string), a list of objects or a dictionary.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98862:If_L50_C8", "label": "if", "type": "if", "loc": [50, 53], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98862:FunctionDef_L43_C4", "vector": [4, 2, 0.592, 0.046, 2, 0.77, 0.75, 0, 3, 0, 0, 0, 0, 0, 3], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if isinstance(message, dict):\n self.message_dict = message\n # Reduce each list of messages into a single list.\n message = reduce(operator.add, message.values())"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98862:Assign_L51_C12", "label": "self.message_dict =", "type": "assigned_variable", "loc": [51, 51], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98862:If_L50_C8", "vector": [14, 3, 0.5862, 0.0115, 3, 0.08, 0.0, 143, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "self.message_dict", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.message_dict = message"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98862:Assign_L53_C12", "label": "message = reduce()", "type": "assigned_variable", "loc": [53, 53], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98862:If_L50_C8", "vector": [14, 3, 0.6092, 0.0115, 3, 0.08, 1.0, 635, 3, 2, 0, 0, 622, 10, 2], "semantic": {"name": "message", "arg_names": [], "import_names": [], "rhs_call_name": "reduce", "annotation": ""}, "snippet": " message = reduce(operator.add, message.values())"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98862:If_L55_C8", "label": "if", "type": "if", "loc": [55, 61], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98862:FunctionDef_L43_C4", "vector": [4, 2, 0.6667, 0.0805, 2, 0.77, 1.0, 0, 3, 0, 0, 0, 0, 0, 3], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if isinstance(message, list):\n self.messages = [force_unicode(msg) for msg in message]\n else:\n self.code = code\n self.params = params\n message = force_unicode(message)\n self.messages = [message]"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98862:Assign_L56_C12", "label": "self.messages =", "type": "assigned_variable", "loc": [56, 56], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98862:If_L55_C8", "vector": [14, 3, 0.6437, 0.0115, 3, 0.18, 0.0, 44, 5, 0, 0, 0, 0, 0, 1], "semantic": {"name": "self.messages", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.messages = [force_unicode(msg) for msg in message]"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98862:Assign_L58_C12", "label": "self.code =", "type": "assigned_variable", "loc": [58, 58], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98862:If_L55_C8", "vector": [14, 3, 0.6667, 0.0115, 3, 0.18, 0.25, 296, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "self.code", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.code = code"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98862:Assign_L59_C12", "label": "self.params =", "type": "assigned_variable", "loc": [59, 59], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98862:If_L55_C8", "vector": [14, 3, 0.6782, 0.0115, 3, 0.18, 0.5, 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_98862:Assign_L60_C12", "label": "message = force_unicode()", "type": "assigned_variable", "loc": [60, 60], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98862:If_L55_C8", "vector": [14, 3, 0.6897, 0.0115, 3, 0.18, 0.75, 635, 3, 1, 0, 0, 870, 10, 1], "semantic": {"name": "message", "arg_names": [], "import_names": [], "rhs_call_name": "force_unicode", "annotation": ""}, "snippet": " message = force_unicode(message)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98862:Assign_L61_C12", "label": "self.messages =", "type": "assigned_variable", "loc": [61, 61], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98862:If_L55_C8", "vector": [14, 3, 0.7011, 0.0115, 3, 0.18, 1.0, 44, 0, 0, 0, 0, 0, 5, 0], "semantic": {"name": "self.messages", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.messages = [message]"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98862:FunctionDef_L63_C4", "label": "__str__", "type": "function", "loc": [63, 70], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98862:ClassDef_L41_C0", "vector": [2, 1, 0.7644, 0.092, 1, 0.33, 0.5, 527, 0, 1, 1, 0, 0, 0, 3], "semantic": {"name": "__str__", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def __str__(self):\n # This is needed because, without a __str__(), printing an exception\n # instance would result in this:\n # AttributeError: ValidationError instance has no attribute 'args'\n # See http://www.python.org/doc/current/tut/node10.html#handling\n if hasattr(self, 'message_dict'):\n return repr(self.message_dict)\n return repr(self.messages)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98862:If_L68_C8", "label": "if", "type": "if", "loc": [68, 69], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98862:FunctionDef_L63_C4", "vector": [4, 2, 0.7874, 0.023, 2, 0.9, 0.0, 0, 3, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if hasattr(self, 'message_dict'):\n return repr(self.message_dict)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98862:Return_L69_C12", "label": "return", "type": "return", "loc": [69, 69], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98862:If_L68_C8", "vector": [13, 3, 0.7931, 0.0115, 3, 0.03, 0.0, 0, 3, 0, 0, 0, 0, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return repr(self.message_dict)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98862:Return_L70_C8", "label": "return", "type": "return", "loc": [70, 70], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98862:FunctionDef_L63_C4", "vector": [13, 2, 0.8046, 0.0115, 2, 0.9, 1.0, 0, 3, 0, 0, 0, 0, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return repr(self.messages)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98862:FunctionDef_L72_C4", "label": "__repr__", "type": "function", "loc": [72, 75], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98862:ClassDef_L41_C0", "vector": [2, 1, 0.8448, 0.046, 1, 0.33, 0.75, 204, 0, 1, 1, 0, 0, 0, 3], "semantic": {"name": "__repr__", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def __repr__(self):\n if hasattr(self, 'message_dict'):\n return 'ValidationError(%s)' % repr(self.message_dict)\n return 'ValidationError(%s)' % repr(self.messages)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98862:If_L73_C8", "label": "if", "type": "if", "loc": [73, 74], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98862:FunctionDef_L72_C4", "vector": [4, 2, 0.8448, 0.023, 2, 0.61, 0.0, 0, 3, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if hasattr(self, 'message_dict'):\n return 'ValidationError(%s)' % repr(self.message_dict)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98862:Return_L74_C12", "label": "return", "type": "return", "loc": [74, 74], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98862:If_L73_C8", "vector": [13, 3, 0.8506, 0.0115, 3, 0.82, 0.0, 0, 4, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return 'ValidationError(%s)' % repr(self.message_dict)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98862:Return_L75_C8", "label": "return", "type": "return", "loc": [75, 75], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98862:FunctionDef_L72_C4", "vector": [13, 2, 0.8621, 0.0115, 2, 0.61, 1.0, 0, 4, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return 'ValidationError(%s)' % repr(self.messages)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98862:FunctionDef_L77_C4", "label": "update_error_dict", "type": "function", "loc": [77, 86], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98862:ClassDef_L41_C0", "vector": [2, 1, 0.9368, 0.1149, 1, 0.33, 1.0, 825, 0, 2, 1, 0, 0, 0, 4], "semantic": {"name": "update_error_dict", "arg_names": ["self", "error_dict"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def update_error_dict(self, error_dict):\n if hasattr(self, 'message_dict'):\n if error_dict:\n for k, v in self.message_dict.items():\n error_dict.setdefault(k, []).extend(v)\n else:\n error_dict = self.message_dict\n else:"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98862:If_L78_C8", "label": "if", "type": "if", "loc": [78, 85], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98862:FunctionDef_L77_C4", "vector": [4, 2, 0.9368, 0.092, 2, 0.22, 0.0, 0, 3, 0, 0, 0, 0, 0, 4], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if hasattr(self, 'message_dict'):\n if error_dict:\n for k, v in self.message_dict.items():\n error_dict.setdefault(k, []).extend(v)\n else:\n error_dict = self.message_dict\n else:\n error_dict[NON_FIELD_ERRORS] = self.messages"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98862:If_L79_C12", "label": "if", "type": "if", "loc": [79, 83], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98862:If_L78_C8", "vector": [4, 3, 0.931, 0.0575, 3, 0.9, 0.0, 0, 2, 0, 0, 0, 0, 0, 3], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if error_dict:\n for k, v in self.message_dict.items():\n error_dict.setdefault(k, []).extend(v)\n else:\n error_dict = self.message_dict"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98862:For_L80_C16", "label": "for k, v", "type": "for", "loc": [80, 81], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98862:If_L79_C12", "vector": [6, 4, 0.9253, 0.023, 4, 0.85, 0.0, 867, 3, 0, 0, 0, 0, 0, 3], "semantic": {"name": "k, v", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for k, v in self.message_dict.items():\n error_dict.setdefault(k, []).extend(v)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98862:Expr_L81_C20", "label": "extend()", "type": "expression", "loc": [81, 81], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98862:For_L80_C16", "vector": [8, 5, 0.931, 0.0115, 5, 0.1, 0.0, 660, 3, 1, 0, 0, 0, 0, 2], "semantic": {"name": "extend", "arg_names": [], "import_names": [], "rhs_call_name": "extend", "annotation": ""}, "snippet": " error_dict.setdefault(k, []).extend(v)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98862:Assign_L83_C16", "label": "error_dict =", "type": "assigned_variable", "loc": [83, 83], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98862:If_L79_C12", "vector": [14, 4, 0.954, 0.0115, 4, 0.85, 1.0, 626, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "error_dict", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " error_dict = self.message_dict"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98862:Assign_L85_C12", "label": "assign", "type": "assigned_variable", "loc": [85, 85], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98862:If_L78_C8", "vector": [14, 3, 0.977, 0.0115, 3, 0.9, 1.0, 0, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " error_dict[NON_FIELD_ERRORS] = self.messages"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98862:Return_L86_C8", "label": "return", "type": "return", "loc": [86, 86], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98862:FunctionDef_L77_C4", "vector": [13, 2, 0.9885, 0.0115, 2, 0.22, 1.0, 0, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return error_dict"}]
[{"f": "ajibawa-2023/Python-Code-Large/train/row_98862:ClassDef_L8_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98862:Expr_L9_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98862:ClassDef_L8_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98862:Assign_L10_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98862:ClassDef_L12_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98862:Expr_L13_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98862:ClassDef_L16_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98862:Expr_L17_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98862:ClassDef_L20_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98862:Expr_L21_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98862:ClassDef_L24_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98862:Expr_L25_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98862:ClassDef_L28_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98862:Expr_L29_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98862:ClassDef_L32_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98862:Expr_L33_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98862:ClassDef_L36_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98862:Expr_L37_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98862:ClassDef_L41_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98862:Expr_L42_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98862:ClassDef_L41_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98862:FunctionDef_L43_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98862:FunctionDef_L43_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98862:Import_L44_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98862:FunctionDef_L43_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98862:ImportFrom_L45_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98862:FunctionDef_L43_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98862:Expr_L46_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98862:FunctionDef_L43_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98862:If_L50_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98862:If_L50_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98862:Assign_L51_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98862:If_L50_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98862:Assign_L53_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98862:FunctionDef_L43_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98862:If_L55_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98862:If_L55_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98862:Assign_L56_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98862:If_L55_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98862:Assign_L58_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98862:If_L55_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98862:Assign_L59_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98862:If_L55_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98862:Assign_L60_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98862:If_L55_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98862:Assign_L61_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98862:ClassDef_L41_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98862:FunctionDef_L63_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98862:FunctionDef_L63_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98862:If_L68_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98862:If_L68_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98862:Return_L69_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98862:FunctionDef_L63_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98862:Return_L70_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98862:ClassDef_L41_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98862:FunctionDef_L72_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98862:FunctionDef_L72_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98862:If_L73_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98862:If_L73_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98862:Return_L74_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98862:FunctionDef_L72_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98862:Return_L75_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98862:ClassDef_L41_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98862:FunctionDef_L77_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98862:FunctionDef_L77_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98862:If_L78_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98862:If_L78_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98862:If_L79_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98862:If_L79_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98862:For_L80_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98862:For_L80_C16", "t": "ajibawa-2023/Python-Code-Large/train/row_98862:Expr_L81_C20"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98862:If_L79_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98862:Assign_L83_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98862:If_L78_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98862:Assign_L85_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98862:FunctionDef_L77_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98862:Return_L86_C8"}]
from optparse import make_option from django.core.management.base import AppCommand from django.core.management.sql import sql_all from django.db import connections, DEFAULT_DB_ALIAS class Command(AppCommand): help = "Prints the CREATE TABLE, custom SQL and CREATE INDEX SQL statements for the given model module name(s)." option_list = AppCommand.option_list + ( make_option('--database', action='store', dest='database', default=DEFAULT_DB_ALIAS, help='Nominates a database to print the ' 'SQL for. Defaults to the "default" database.'), ) output_transaction = True def handle_app(self, app, **options): return u'\n'.join(sql_all(app, self.style, connections[options.get('database', DEFAULT_DB_ALIAS)])).encode('utf-8')
ajibawa-2023/Python-Code-Large/train/row_98863
10
19
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_98863:ImportFrom_L1_C0", "label": "from optparse import make_option", "type": "import", "loc": [1, 1], "level": 0, "parent": null, "vector": [1, 0, 0.0526, 0.0526, 0, 0.66, 0.0, 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_98863:ImportFrom_L3_C0", "label": "from django.core.management.base import AppCommand", "type": "import", "loc": [3, 3], "level": 0, "parent": null, "vector": [1, 0, 0.1579, 0.0526, 0, 0.66, 0.25, 931, 0, 1, 0, 0, 931, 0, 0], "semantic": {"name": "django.core.management.base", "arg_names": [], "import_names": ["AppCommand"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.core.management.base import AppCommand"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98863:ImportFrom_L4_C0", "label": "from django.core.management.sql import sql_all", "type": "import", "loc": [4, 4], "level": 0, "parent": null, "vector": [1, 0, 0.2105, 0.0526, 0, 0.66, 0.5, 576, 0, 1, 0, 0, 576, 0, 0], "semantic": {"name": "django.core.management.sql", "arg_names": [], "import_names": ["sql_all"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.core.management.sql import sql_all"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98863:ImportFrom_L5_C0", "label": "from django.db import connections, DEFAULT_DB_ALIAS", "type": "import", "loc": [5, 5], "level": 0, "parent": null, "vector": [1, 0, 0.2632, 0.0526, 0, 0.66, 0.75, 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_98863:ClassDef_L7_C0", "label": "Command", "type": "class", "loc": [7, 19], "level": 0, "parent": null, "vector": [3, 0, 0.6842, 0.6842, 0, 0.66, 1.0, 73, 0, 1, 0, 0, 369, 0, 5], "semantic": {"name": "Command", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class Command(AppCommand):\n help = \"Prints the CREATE TABLE, custom SQL and CREATE INDEX SQL statements for the given model module name(s).\"\n\n option_list = AppCommand.option_list + (\n make_option('--database', action='store', dest='database',\n default=DEFAULT_DB_ALIAS, help='Nominates a database to print the '\n 'SQL for. Defaults to the \"default\" database.'),\n )"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98863:Assign_L8_C4", "label": "help =", "type": "assigned_variable", "loc": [8, 8], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98863:ClassDef_L7_C0", "vector": [14, 1, 0.4211, 0.0526, 1, 0.41, 0.0, 868, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "help", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " help = \"Prints the CREATE TABLE, custom SQL and CREATE INDEX SQL statements for the given model module name(s).\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98863:Assign_L10_C4", "label": "option_list =", "type": "assigned_variable", "loc": [10, 14], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98863:ClassDef_L7_C0", "vector": [14, 1, 0.6316, 0.2632, 1, 0.41, 0.3333, 318, 4, 0, 0, 0, 0, 0, 1], "semantic": {"name": "option_list", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " option_list = AppCommand.option_list + (\n make_option('--database', action='store', dest='database',\n default=DEFAULT_DB_ALIAS, help='Nominates a database to print the '\n 'SQL for. Defaults to the \"default\" database.'),\n )"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98863:Assign_L16_C4", "label": "output_transaction =", "type": "assigned_variable", "loc": [16, 16], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98863:ClassDef_L7_C0", "vector": [14, 1, 0.8421, 0.0526, 1, 0.41, 0.6667, 987, 1, 0, 0, 0, 0, 4, 0], "semantic": {"name": "output_transaction", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " output_transaction = True"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98863:FunctionDef_L18_C4", "label": "handle_app", "type": "function", "loc": [18, 19], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98863:ClassDef_L7_C0", "vector": [2, 1, 0.9737, 0.1053, 1, 0.41, 1.0, 665, 0, 3, 1, 0, 0, 0, 4], "semantic": {"name": "handle_app", "arg_names": ["self", "app", "options"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def handle_app(self, app, **options):\n return u'\\n'.join(sql_all(app, self.style, connections[options.get('database', DEFAULT_DB_ALIAS)])).encode('utf-8')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98863:Return_L19_C8", "label": "return", "type": "return", "loc": [19, 19], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98863:FunctionDef_L18_C4", "vector": [13, 2, 1.0, 0.0526, 2, 0.29, 0.0, 0, 3, 0, 0, 0, 0, 10, 4], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return u'\\n'.join(sql_all(app, self.style, connections[options.get('database', DEFAULT_DB_ALIAS)])).encode('utf-8')"}]
[{"f": "ajibawa-2023/Python-Code-Large/train/row_98863:ClassDef_L7_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98863:Assign_L8_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98863:ClassDef_L7_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98863:Assign_L10_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98863:ClassDef_L7_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98863:Assign_L16_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98863:ClassDef_L7_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98863:FunctionDef_L18_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98863:FunctionDef_L18_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98863:Return_L19_C8"}]
import os from django.core.management.base import NoArgsCommand from optparse import make_option class Command(NoArgsCommand): option_list = NoArgsCommand.option_list + ( make_option('--plain', action='store_true', dest='plain', help='Tells Django to use plain Python, not IPython.'), ) help = "Runs a Python interactive interpreter. Tries to use IPython, if it's available." requires_model_validation = False def handle_noargs(self, **options): # XXX: (Temporary) workaround for ticket #1796: force early loading of all # models from installed apps. from django.db.models.loading import get_models loaded_models = get_models() use_plain = options.get('plain', False) try: if use_plain: # Don't bother loading IPython, because the user wants plain Python. raise ImportError import IPython # Explicitly pass an empty list as arguments, because otherwise IPython # would use sys.argv from this script. shell = IPython.Shell.IPShell(argv=[]) shell.mainloop() except ImportError: import code # Set up a dictionary to serve as the environment for the shell, so # that tab completion works on objects that are imported at runtime. # See ticket 5082. imported_objects = {} try: # Try activating rlcompleter, because it's handy. import readline except ImportError: pass else: # We don't have to wrap the following import in a 'try', because # we already know 'readline' was imported successfully. import rlcompleter readline.set_completer(rlcompleter.Completer(imported_objects).complete) readline.parse_and_bind("tab:complete") # We want to honor both $PYTHONSTARTUP and .pythonrc.py, so follow system # conventions and get $PYTHONSTARTUP first then import user. if not use_plain: pythonrc = os.environ.get("PYTHONSTARTUP") if pythonrc and os.path.isfile(pythonrc): try: execfile(pythonrc) except NameError: pass # This will import .pythonrc.py as a side-effect import user code.interact(local=imported_objects)
ajibawa-2023/Python-Code-Large/train/row_98865
30
59
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_98865:Import_L1_C0", "label": "os import os", "type": "import", "loc": [1, 1], "level": 0, "parent": null, "vector": [1, 0, 0.0169, 0.0169, 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_98865:ImportFrom_L2_C0", "label": "from django.core.management.base import NoArgsCommand", "type": "import", "loc": [2, 2], "level": 0, "parent": null, "vector": [1, 0, 0.0339, 0.0169, 0, 0.66, 0.3333, 931, 0, 1, 0, 0, 931, 0, 0], "semantic": {"name": "django.core.management.base", "arg_names": [], "import_names": ["NoArgsCommand"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.core.management.base import NoArgsCommand"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98865:ImportFrom_L3_C0", "label": "from optparse import make_option", "type": "import", "loc": [3, 3], "level": 0, "parent": null, "vector": [1, 0, 0.0508, 0.0169, 0, 0.66, 0.6667, 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_98865:ClassDef_L5_C0", "label": "Command", "type": "class", "loc": [5, 59], "level": 0, "parent": null, "vector": [3, 0, 0.5424, 0.9322, 0, 0.66, 1.0, 73, 0, 1, 0, 0, 795, 0, 12], "semantic": {"name": "Command", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class Command(NoArgsCommand):\n option_list = NoArgsCommand.option_list + (\n make_option('--plain', action='store_true', dest='plain',\n help='Tells Django to use plain Python, not IPython.'),\n )\n help = \"Runs a Python interactive interpreter. Tries to use IPython, if it's available.\"\n\n requires_model_validation = False"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98865:Assign_L6_C4", "label": "option_list =", "type": "assigned_variable", "loc": [6, 9], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98865:ClassDef_L5_C0", "vector": [14, 1, 0.1271, 0.0678, 1, 0.75, 0.0, 318, 4, 0, 0, 0, 0, 0, 1], "semantic": {"name": "option_list", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " option_list = NoArgsCommand.option_list + (\n make_option('--plain', action='store_true', dest='plain',\n help='Tells Django to use plain Python, not IPython.'),\n )"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98865:Assign_L10_C4", "label": "help =", "type": "assigned_variable", "loc": [10, 10], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98865:ClassDef_L5_C0", "vector": [14, 1, 0.1695, 0.0169, 1, 0.75, 0.3333, 868, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "help", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " help = \"Runs a Python interactive interpreter. Tries to use IPython, if it's available.\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98865:Assign_L12_C4", "label": "requires_model_validation =", "type": "assigned_variable", "loc": [12, 12], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98865:ClassDef_L5_C0", "vector": [14, 1, 0.2034, 0.0169, 1, 0.75, 0.6667, 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_98865:FunctionDef_L14_C4", "label": "handle_noargs", "type": "function", "loc": [14, 59], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98865:ClassDef_L5_C0", "vector": [2, 1, 0.6186, 0.7797, 1, 0.75, 1.0, 28, 0, 2, 0, 0, 0, 0, 11], "semantic": {"name": "handle_noargs", "arg_names": ["self", "options"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def handle_noargs(self, **options):\n # XXX: (Temporary) workaround for ticket #1796: force early loading of all\n # models from installed apps.\n from django.db.models.loading import get_models\n loaded_models = get_models()\n\n use_plain = options.get('plain', False)\n"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98865:ImportFrom_L17_C8", "label": "from django.db.models.loading import get_models", "type": "import", "loc": [17, 17], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98865:FunctionDef_L14_C4", "vector": [1, 2, 0.2881, 0.0169, 2, 0.37, 0.0, 343, 0, 1, 0, 0, 343, 0, 0], "semantic": {"name": "django.db.models.loading", "arg_names": [], "import_names": ["get_models"], "rhs_call_name": "", "annotation": ""}, "snippet": " from django.db.models.loading import get_models"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98865:Assign_L18_C8", "label": "loaded_models = get_models()", "type": "assigned_variable", "loc": [18, 18], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98865:FunctionDef_L14_C4", "vector": [14, 2, 0.3051, 0.0169, 2, 0.37, 0.3333, 105, 3, 0, 0, 0, 404, 10, 1], "semantic": {"name": "loaded_models", "arg_names": [], "import_names": [], "rhs_call_name": "get_models", "annotation": ""}, "snippet": " loaded_models = get_models()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98865:Assign_L20_C8", "label": "use_plain = get()", "type": "assigned_variable", "loc": [20, 20], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98865:FunctionDef_L14_C4", "vector": [14, 2, 0.339, 0.0169, 2, 0.37, 0.6667, 361, 3, 2, 0, 0, 607, 10, 1], "semantic": {"name": "use_plain", "arg_names": [], "import_names": [], "rhs_call_name": "get", "annotation": ""}, "snippet": " use_plain = options.get('plain', False)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98865:Try_L22_C8", "label": "try", "type": "try", "loc": [22, 59], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98865:FunctionDef_L14_C4", "vector": [7, 2, 0.6864, 0.6441, 2, 0.37, 1.0, 0, 0, 1, 0, 0, 0, 0, 9], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " try:\n if use_plain:\n # Don't bother loading IPython, because the user wants plain Python.\n raise ImportError\n import IPython\n # Explicitly pass an empty list as arguments, because otherwise IPython\n # would use sys.argv from this script.\n shell = IPython.Shell.IPShell(argv=[])"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98865:If_L23_C12", "label": "if", "type": "if", "loc": [23, 25], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98865:Try_L22_C8", "vector": [4, 3, 0.4068, 0.0508, 3, 0.24, 0.0, 0, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if use_plain:\n # Don't bother loading IPython, because the user wants plain Python.\n raise ImportError"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98865:Import_L26_C12", "label": "IPython import IPython", "type": "import", "loc": [26, 26], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98865:Try_L22_C8", "vector": [1, 3, 0.4407, 0.0169, 3, 0.24, 0.3333, 12, 0, 1, 0, 0, 12, 0, 0], "semantic": {"name": "IPython", "arg_names": [], "import_names": ["IPython"], "rhs_call_name": "", "annotation": ""}, "snippet": " import IPython"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98865:Assign_L29_C12", "label": "shell = IPShell()", "type": "assigned_variable", "loc": [29, 29], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98865:Try_L22_C8", "vector": [14, 3, 0.4915, 0.0169, 3, 0.24, 0.6667, 192, 3, 1, 0, 0, 189, 10, 1], "semantic": {"name": "shell", "arg_names": [], "import_names": [], "rhs_call_name": "IPShell", "annotation": ""}, "snippet": " shell = IPython.Shell.IPShell(argv=[])"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98865:Expr_L30_C12", "label": "mainloop()", "type": "expression", "loc": [30, 30], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98865:Try_L22_C8", "vector": [8, 3, 0.5085, 0.0169, 3, 0.24, 1.0, 192, 3, 0, 0, 0, 0, 0, 1], "semantic": {"name": "mainloop", "arg_names": [], "import_names": [], "rhs_call_name": "mainloop", "annotation": ""}, "snippet": " shell.mainloop()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98865:Import_L32_C12", "label": "code import code", "type": "import", "loc": [32, 32], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98865:Try_L22_C8", "vector": [1, 3, 0.5424, 0.0169, 3, 0.24, 0.0, 44, 0, 1, 0, 0, 44, 0, 0], "semantic": {"name": "code", "arg_names": [], "import_names": ["code"], "rhs_call_name": "", "annotation": ""}, "snippet": " import code"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98865:Assign_L36_C12", "label": "imported_objects =", "type": "assigned_variable", "loc": [36, 36], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98865:Try_L22_C8", "vector": [14, 3, 0.6102, 0.0169, 3, 0.24, 0.25, 578, 0, 0, 0, 0, 0, 6, 0], "semantic": {"name": "imported_objects", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " imported_objects = {}"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98865:Try_L37_C12", "label": "try", "type": "try", "loc": [37, 46], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98865:Try_L22_C8", "vector": [7, 3, 0.7034, 0.1695, 3, 0.24, 0.5, 0, 0, 1, 0, 0, 0, 0, 3], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " try: # Try activating rlcompleter, because it's handy.\n import readline\n except ImportError:\n pass\n else:\n # We don't have to wrap the following import in a 'try', because\n # we already know 'readline' was imported successfully.\n import rlcompleter"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98865:Import_L38_C16", "label": "readline import readline", "type": "import", "loc": [38, 38], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98865:Try_L37_C12", "vector": [1, 4, 0.6441, 0.0169, 4, 0.14, 0.0, 303, 0, 1, 0, 0, 303, 0, 0], "semantic": {"name": "readline", "arg_names": [], "import_names": ["readline"], "rhs_call_name": "", "annotation": ""}, "snippet": " import readline"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98865:Import_L44_C16", "label": "rlcompleter import rlcompleter", "type": "import", "loc": [44, 44], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98865:Try_L37_C12", "vector": [1, 4, 0.7458, 0.0169, 4, 0.14, 0.3333, 9, 0, 1, 0, 0, 9, 0, 0], "semantic": {"name": "rlcompleter", "arg_names": [], "import_names": ["rlcompleter"], "rhs_call_name": "", "annotation": ""}, "snippet": " import rlcompleter"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98865:Expr_L45_C16", "label": "set_completer()", "type": "expression", "loc": [45, 45], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98865:Try_L37_C12", "vector": [8, 4, 0.7627, 0.0169, 4, 0.14, 0.6667, 697, 3, 1, 0, 0, 0, 0, 2], "semantic": {"name": "set_completer", "arg_names": [], "import_names": [], "rhs_call_name": "set_completer", "annotation": ""}, "snippet": " readline.set_completer(rlcompleter.Completer(imported_objects).complete)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98865:Expr_L46_C16", "label": "parse_and_bind()", "type": "expression", "loc": [46, 46], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98865:Try_L37_C12", "vector": [8, 4, 0.7797, 0.0169, 4, 0.14, 1.0, 690, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "parse_and_bind", "arg_names": [], "import_names": [], "rhs_call_name": "parse_and_bind", "annotation": ""}, "snippet": " readline.parse_and_bind(\"tab:complete\")"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98865:If_L50_C12", "label": "if", "type": "if", "loc": [50, 58], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98865:Try_L22_C8", "vector": [4, 3, 0.9153, 0.1525, 3, 0.24, 0.75, 0, 0, 0, 0, 0, 0, 0, 3], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if not use_plain: \n pythonrc = os.environ.get(\"PYTHONSTARTUP\") \n if pythonrc and os.path.isfile(pythonrc): \n try: \n execfile(pythonrc) \n except NameError: \n pass\n # This will import .pythonrc.py as a side-effect"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98865:Assign_L51_C16", "label": "pythonrc = get()", "type": "assigned_variable", "loc": [51, 51], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98865:If_L50_C12", "vector": [14, 4, 0.8644, 0.0169, 4, 0.03, 0.0, 908, 3, 1, 0, 0, 607, 10, 1], "semantic": {"name": "pythonrc", "arg_names": [], "import_names": [], "rhs_call_name": "get", "annotation": ""}, "snippet": " pythonrc = os.environ.get(\"PYTHONSTARTUP\") "}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98865:If_L52_C16", "label": "if", "type": "if", "loc": [52, 56], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98865:If_L50_C12", "vector": [4, 4, 0.9153, 0.0847, 4, 0.03, 0.5, 0, 0, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if pythonrc and os.path.isfile(pythonrc): \n try: \n execfile(pythonrc) \n except NameError: \n pass"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98865:Try_L53_C20", "label": "try", "type": "try", "loc": [53, 56], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98865:If_L52_C16", "vector": [7, 5, 0.9237, 0.0678, 5, 0.88, 0.0, 0, 0, 1, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " try: \n execfile(pythonrc) \n except NameError: \n pass"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98865:Expr_L54_C24", "label": "execfile()", "type": "expression", "loc": [54, 54], "level": 6, "parent": "ajibawa-2023/Python-Code-Large/train/row_98865:Try_L53_C20", "vector": [8, 6, 0.9153, 0.0169, 6, 0.33, 0.0, 750, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "execfile", "arg_names": [], "import_names": [], "rhs_call_name": "execfile", "annotation": ""}, "snippet": " execfile(pythonrc) "}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98865:Import_L58_C16", "label": "user import user", "type": "import", "loc": [58, 58], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98865:If_L50_C12", "vector": [1, 4, 0.9831, 0.0169, 4, 0.03, 1.0, 503, 0, 1, 0, 0, 503, 0, 0], "semantic": {"name": "user", "arg_names": [], "import_names": ["user"], "rhs_call_name": "", "annotation": ""}, "snippet": " import user"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98865:Expr_L59_C12", "label": "interact()", "type": "expression", "loc": [59, 59], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98865:Try_L22_C8", "vector": [8, 3, 1.0, 0.0169, 3, 0.24, 1.0, 629, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "interact", "arg_names": [], "import_names": [], "rhs_call_name": "interact", "annotation": ""}, "snippet": " code.interact(local=imported_objects)"}]
[{"f": "ajibawa-2023/Python-Code-Large/train/row_98865:ClassDef_L5_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98865:Assign_L6_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98865:ClassDef_L5_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98865:Assign_L10_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98865:ClassDef_L5_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98865:Assign_L12_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98865:ClassDef_L5_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98865:FunctionDef_L14_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98865:FunctionDef_L14_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98865:ImportFrom_L17_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98865:FunctionDef_L14_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98865:Assign_L18_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98865:FunctionDef_L14_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98865:Assign_L20_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98865:FunctionDef_L14_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98865:Try_L22_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98865:Try_L22_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98865:If_L23_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98865:Try_L22_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98865:Import_L26_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98865:Try_L22_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98865:Assign_L29_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98865:Try_L22_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98865:Expr_L30_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98865:Try_L22_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98865:Import_L32_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98865:Try_L22_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98865:Assign_L36_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98865:Try_L22_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98865:Try_L37_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98865:Try_L37_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98865:Import_L38_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98865:Try_L37_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98865:Import_L44_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98865:Try_L37_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98865:Expr_L45_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98865:Try_L37_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98865:Expr_L46_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98865:Try_L22_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98865:If_L50_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98865:If_L50_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98865:Assign_L51_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98865:If_L50_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98865:If_L52_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98865:If_L52_C16", "t": "ajibawa-2023/Python-Code-Large/train/row_98865:Try_L53_C20"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98865:Try_L53_C20", "t": "ajibawa-2023/Python-Code-Large/train/row_98865:Expr_L54_C24"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98865:If_L50_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98865:Import_L58_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98865:Try_L22_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98865:Expr_L59_C12"}]
import codecs import os import sys from optparse import make_option from django.core.management.base import BaseCommand, CommandError def has_bom(fn): f = open(fn, 'r') sample = f.read(4) return sample[:3] == '\xef\xbb\xbf' or \ sample.startswith(codecs.BOM_UTF16_LE) or \ sample.startswith(codecs.BOM_UTF16_BE) def compile_messages(stderr, locale=None): basedirs = [os.path.join('conf', 'locale'), 'locale'] if os.environ.get('DJANGO_SETTINGS_MODULE'): from django.conf import settings basedirs.extend(settings.LOCALE_PATHS) # Gather existing directories. basedirs = set(map(os.path.abspath, filter(os.path.isdir, basedirs))) if not basedirs: raise CommandError("This script should be run from the Django SVN tree or your project or app tree, or with the settings module specified.") for basedir in basedirs: if locale: basedir = os.path.join(basedir, locale, 'LC_MESSAGES') for dirpath, dirnames, filenames in os.walk(basedir): for f in filenames: if f.endswith('.po'): stderr.write('processing file %s in %s\n' % (f, dirpath)) fn = os.path.join(dirpath, f) if has_bom(fn): raise CommandError("The %s file has a BOM (Byte Order Mark). Django only supports .po files encoded in UTF-8 and without any BOM." % fn) pf = os.path.splitext(fn)[0] # Store the names of the .mo and .po files in an environment # variable, rather than doing a string replacement into the # command, so that we can take advantage of shell quoting, to # quote any malicious characters/escaping. # See http://cyberelk.net/tim/articles/cmdline/ar01s02.html os.environ['djangocompilemo'] = pf + '.mo' os.environ['djangocompilepo'] = pf + '.po' if sys.platform == 'win32': # Different shell-variable syntax cmd = 'msgfmt --check-format -o "%djangocompilemo%" "%djangocompilepo%"' else: cmd = 'msgfmt --check-format -o "$djangocompilemo" "$djangocompilepo"' os.system(cmd) class Command(BaseCommand): option_list = BaseCommand.option_list + ( make_option('--locale', '-l', dest='locale', help='The locale to process. Default is to process all.'), ) help = 'Compiles .po files to .mo files for use with builtin gettext support.' requires_model_validation = False can_import_settings = False def handle(self, **options): locale = options.get('locale') compile_messages(self.stderr, locale=locale)
ajibawa-2023/Python-Code-Large/train/row_98866
40
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_98866:Import_L1_C0", "label": "codecs import codecs", "type": "import", "loc": [1, 1], "level": 0, "parent": null, "vector": [1, 0, 0.0159, 0.0159, 0, 0.66, 0.0, 220, 0, 1, 0, 0, 220, 0, 0], "semantic": {"name": "codecs", "arg_names": [], "import_names": ["codecs"], "rhs_call_name": "", "annotation": ""}, "snippet": "import codecs"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98866:Import_L2_C0", "label": "os import os", "type": "import", "loc": [2, 2], "level": 0, "parent": null, "vector": [1, 0, 0.0317, 0.0159, 0, 0.66, 0.1429, 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_98866:Import_L3_C0", "label": "sys import sys", "type": "import", "loc": [3, 3], "level": 0, "parent": null, "vector": [1, 0, 0.0476, 0.0159, 0, 0.66, 0.2857, 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_98866:ImportFrom_L4_C0", "label": "from optparse import make_option", "type": "import", "loc": [4, 4], "level": 0, "parent": null, "vector": [1, 0, 0.0635, 0.0159, 0, 0.66, 0.4286, 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_98866:ImportFrom_L5_C0", "label": "from django.core.management.base import BaseCommand, CommandError", "type": "import", "loc": [5, 5], "level": 0, "parent": null, "vector": [1, 0, 0.0794, 0.0159, 0, 0.66, 0.5714, 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_98866:FunctionDef_L7_C0", "label": "has_bom", "type": "function", "loc": [7, 12], "level": 0, "parent": null, "vector": [2, 0, 0.1508, 0.0952, 0, 0.66, 0.7143, 58, 0, 1, 1, 0, 0, 0, 4], "semantic": {"name": "has_bom", "arg_names": ["fn"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "def has_bom(fn):\n f = open(fn, 'r')\n sample = f.read(4)\n return sample[:3] == '\\xef\\xbb\\xbf' or \\\n sample.startswith(codecs.BOM_UTF16_LE) or \\\n sample.startswith(codecs.BOM_UTF16_BE)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98866:Assign_L8_C4", "label": "f = open()", "type": "assigned_variable", "loc": [8, 8], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98866:FunctionDef_L7_C0", "vector": [14, 1, 0.127, 0.0159, 1, 0.31, 0.0, 899, 3, 2, 0, 0, 693, 10, 1], "semantic": {"name": "f", "arg_names": [], "import_names": [], "rhs_call_name": "open", "annotation": ""}, "snippet": " f = open(fn, 'r')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98866:Assign_L9_C4", "label": "sample = read()", "type": "assigned_variable", "loc": [9, 9], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98866:FunctionDef_L7_C0", "vector": [14, 1, 0.1429, 0.0159, 1, 0.31, 0.5, 513, 3, 1, 0, 0, 453, 10, 1], "semantic": {"name": "sample", "arg_names": [], "import_names": [], "rhs_call_name": "read", "annotation": ""}, "snippet": " sample = f.read(4)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98866:Return_L10_C4", "label": "return", "type": "return", "loc": [10, 12], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98866:FunctionDef_L7_C0", "vector": [13, 1, 0.1746, 0.0476, 1, 0.31, 1.0, 0, 0, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return sample[:3] == '\\xef\\xbb\\xbf' or \\\n sample.startswith(codecs.BOM_UTF16_LE) or \\\n sample.startswith(codecs.BOM_UTF16_BE)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98866:FunctionDef_L14_C0", "label": "compile_messages", "type": "function", "loc": [14, 48], "level": 0, "parent": null, "vector": [2, 0, 0.4921, 0.5556, 0, 0.66, 0.8571, 217, 0, 2, 0, 0, 0, 0, 16], "semantic": {"name": "compile_messages", "arg_names": ["stderr", "locale"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "def compile_messages(stderr, locale=None):\n basedirs = [os.path.join('conf', 'locale'), 'locale']\n if os.environ.get('DJANGO_SETTINGS_MODULE'):\n from django.conf import settings\n basedirs.extend(settings.LOCALE_PATHS)\n\n # Gather existing directories.\n basedirs = set(map(os.path.abspath, filter(os.path.isdir, basedirs)))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98866:Assign_L15_C4", "label": "basedirs =", "type": "assigned_variable", "loc": [15, 15], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98866:FunctionDef_L14_C0", "vector": [14, 1, 0.2381, 0.0159, 1, 0.02, 0.0, 149, 0, 0, 0, 0, 0, 5, 1], "semantic": {"name": "basedirs", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " basedirs = [os.path.join('conf', 'locale'), 'locale']"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98866:If_L16_C4", "label": "if", "type": "if", "loc": [16, 18], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98866:FunctionDef_L14_C0", "vector": [4, 1, 0.2698, 0.0476, 1, 0.02, 0.25, 0, 3, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if os.environ.get('DJANGO_SETTINGS_MODULE'):\n from django.conf import settings\n basedirs.extend(settings.LOCALE_PATHS)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98866:ImportFrom_L17_C8", "label": "from django.conf import settings", "type": "import", "loc": [17, 17], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98866:If_L16_C4", "vector": [1, 2, 0.2698, 0.0159, 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_98866:Expr_L18_C8", "label": "extend()", "type": "expression", "loc": [18, 18], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98866:If_L16_C4", "vector": [8, 2, 0.2857, 0.0159, 2, 0.14, 1.0, 660, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "extend", "arg_names": [], "import_names": [], "rhs_call_name": "extend", "annotation": ""}, "snippet": " basedirs.extend(settings.LOCALE_PATHS)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98866:Assign_L21_C4", "label": "basedirs = set()", "type": "assigned_variable", "loc": [21, 21], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98866:FunctionDef_L14_C0", "vector": [14, 1, 0.3333, 0.0159, 1, 0.02, 0.5, 149, 3, 1, 0, 0, 21, 10, 3], "semantic": {"name": "basedirs", "arg_names": [], "import_names": [], "rhs_call_name": "set", "annotation": ""}, "snippet": " basedirs = set(map(os.path.abspath, filter(os.path.isdir, basedirs)))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98866:If_L23_C4", "label": "if", "type": "if", "loc": [23, 24], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98866:FunctionDef_L14_C0", "vector": [4, 1, 0.373, 0.0317, 1, 0.02, 0.75, 0, 0, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if not basedirs:\n raise CommandError(\"This script should be run from the Django SVN tree or your project or app tree, or with the settings module specified.\")"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98866:For_L26_C4", "label": "for basedir", "type": "for", "loc": [26, 48], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98866:FunctionDef_L14_C0", "vector": [6, 1, 0.5873, 0.3651, 1, 0.02, 1.0, 241, 2, 0, 0, 0, 0, 0, 9], "semantic": {"name": "basedir", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for basedir in basedirs:\n if locale:\n basedir = os.path.join(basedir, locale, 'LC_MESSAGES')\n for dirpath, dirnames, filenames in os.walk(basedir):\n for f in filenames:\n if f.endswith('.po'):\n stderr.write('processing file %s in %s\\n' % (f, dirpath))\n fn = os.path.join(dirpath, f)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98866:If_L27_C8", "label": "if", "type": "if", "loc": [27, 28], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98866:For_L26_C4", "vector": [4, 2, 0.4365, 0.0317, 2, 0.1, 0.0, 0, 2, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if locale:\n basedir = os.path.join(basedir, locale, 'LC_MESSAGES')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98866:Assign_L28_C12", "label": "basedir = join()", "type": "assigned_variable", "loc": [28, 28], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98866:If_L27_C8", "vector": [14, 3, 0.4444, 0.0159, 3, 0.6, 0.0, 241, 3, 3, 0, 0, 933, 10, 1], "semantic": {"name": "basedir", "arg_names": [], "import_names": [], "rhs_call_name": "join", "annotation": ""}, "snippet": " basedir = os.path.join(basedir, locale, 'LC_MESSAGES')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98866:For_L29_C8", "label": "for dirpath, dirnames, filenames", "type": "for", "loc": [29, 48], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98866:For_L26_C4", "vector": [6, 2, 0.6111, 0.3175, 2, 0.1, 1.0, 200, 3, 0, 0, 0, 0, 0, 8], "semantic": {"name": "dirpath, dirnames, filenames", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for dirpath, dirnames, filenames in os.walk(basedir):\n for f in filenames:\n if f.endswith('.po'):\n stderr.write('processing file %s in %s\\n' % (f, dirpath))\n fn = os.path.join(dirpath, f)\n if has_bom(fn):\n raise CommandError(\"The %s file has a BOM (Byte Order Mark). Django only supports .po files encoded in UTF-8 and without any BOM.\" % fn)\n pf = os.path.splitext(fn)[0]"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98866:For_L30_C12", "label": "for f", "type": "for", "loc": [30, 48], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98866:For_L29_C8", "vector": [6, 3, 0.619, 0.3016, 3, 0.68, 0.0, 899, 2, 0, 0, 0, 0, 0, 7], "semantic": {"name": "f", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for f in filenames:\n if f.endswith('.po'):\n stderr.write('processing file %s in %s\\n' % (f, dirpath))\n fn = os.path.join(dirpath, f)\n if has_bom(fn):\n raise CommandError(\"The %s file has a BOM (Byte Order Mark). Django only supports .po files encoded in UTF-8 and without any BOM.\" % fn)\n pf = os.path.splitext(fn)[0]\n # Store the names of the .mo and .po files in an environment"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98866:If_L31_C16", "label": "if", "type": "if", "loc": [31, 48], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98866:For_L30_C12", "vector": [4, 4, 0.627, 0.2857, 4, 0.92, 0.0, 0, 3, 0, 0, 0, 0, 0, 7], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if f.endswith('.po'):\n stderr.write('processing file %s in %s\\n' % (f, dirpath))\n fn = os.path.join(dirpath, f)\n if has_bom(fn):\n raise CommandError(\"The %s file has a BOM (Byte Order Mark). Django only supports .po files encoded in UTF-8 and without any BOM.\" % fn)\n pf = os.path.splitext(fn)[0]\n # Store the names of the .mo and .po files in an environment\n # variable, rather than doing a string replacement into the"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98866:Expr_L32_C20", "label": "write()", "type": "expression", "loc": [32, 32], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98866:If_L31_C16", "vector": [8, 5, 0.5079, 0.0159, 5, 0.0, 0.0, 837, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "write", "arg_names": [], "import_names": [], "rhs_call_name": "write", "annotation": ""}, "snippet": " stderr.write('processing file %s in %s\\n' % (f, dirpath))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98866:Assign_L33_C20", "label": "fn = join()", "type": "assigned_variable", "loc": [33, 33], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98866:If_L31_C16", "vector": [14, 5, 0.5238, 0.0159, 5, 0.0, 0.1429, 59, 3, 2, 0, 0, 933, 10, 1], "semantic": {"name": "fn", "arg_names": [], "import_names": [], "rhs_call_name": "join", "annotation": ""}, "snippet": " fn = os.path.join(dirpath, f)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98866:If_L34_C20", "label": "if", "type": "if", "loc": [34, 35], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98866:If_L31_C16", "vector": [4, 5, 0.5476, 0.0317, 5, 0.0, 0.2857, 0, 3, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if has_bom(fn):\n raise CommandError(\"The %s file has a BOM (Byte Order Mark). Django only supports .po files encoded in UTF-8 and without any BOM.\" % fn)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98866:Assign_L36_C20", "label": "pf =", "type": "assigned_variable", "loc": [36, 36], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98866:If_L31_C16", "vector": [14, 5, 0.5714, 0.0159, 5, 0.0, 0.4286, 158, 6, 0, 0, 0, 0, 0, 1], "semantic": {"name": "pf", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " pf = os.path.splitext(fn)[0]"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98866:Assign_L42_C20", "label": "assign", "type": "assigned_variable", "loc": [42, 42], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98866:If_L31_C16", "vector": [14, 5, 0.6667, 0.0159, 5, 0.0, 0.5714, 0, 4, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " os.environ['djangocompilemo'] = pf + '.mo'"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98866:Assign_L43_C20", "label": "assign", "type": "assigned_variable", "loc": [43, 43], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98866:If_L31_C16", "vector": [14, 5, 0.6825, 0.0159, 5, 0.0, 0.7143, 0, 4, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " os.environ['djangocompilepo'] = pf + '.po'"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98866:If_L44_C20", "label": "if", "type": "if", "loc": [44, 47], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98866:If_L31_C16", "vector": [4, 5, 0.7222, 0.0635, 5, 0.0, 0.8571, 0, 0, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if sys.platform == 'win32': # Different shell-variable syntax\n cmd = 'msgfmt --check-format -o \"%djangocompilemo%\" \"%djangocompilepo%\"'\n else:\n cmd = 'msgfmt --check-format -o \"$djangocompilemo\" \"$djangocompilepo\"'"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98866:Assign_L45_C24", "label": "cmd =", "type": "assigned_variable", "loc": [45, 45], "level": 6, "parent": "ajibawa-2023/Python-Code-Large/train/row_98866:If_L44_C20", "vector": [14, 6, 0.7143, 0.0159, 6, 0.4, 0.0, 604, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "cmd", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " cmd = 'msgfmt --check-format -o \"%djangocompilemo%\" \"%djangocompilepo%\"'"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98866:Assign_L47_C24", "label": "cmd =", "type": "assigned_variable", "loc": [47, 47], "level": 6, "parent": "ajibawa-2023/Python-Code-Large/train/row_98866:If_L44_C20", "vector": [14, 6, 0.746, 0.0159, 6, 0.4, 1.0, 604, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "cmd", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " cmd = 'msgfmt --check-format -o \"$djangocompilemo\" \"$djangocompilepo\"'"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98866:Expr_L48_C20", "label": "system()", "type": "expression", "loc": [48, 48], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98866:If_L31_C16", "vector": [8, 5, 0.7619, 0.0159, 5, 0.0, 1.0, 856, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "system", "arg_names": [], "import_names": [], "rhs_call_name": "system", "annotation": ""}, "snippet": " os.system(cmd)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98866:ClassDef_L51_C0", "label": "Command", "type": "class", "loc": [51, 63], "level": 0, "parent": null, "vector": [3, 0, 0.9048, 0.2063, 0, 0.66, 1.0, 73, 0, 1, 0, 0, 564, 0, 3], "semantic": {"name": "Command", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class Command(BaseCommand):\n option_list = BaseCommand.option_list + (\n make_option('--locale', '-l', dest='locale',\n help='The locale to process. Default is to process all.'),\n )\n help = 'Compiles .po files to .mo files for use with builtin gettext support.'\n\n requires_model_validation = False"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98866:Assign_L52_C4", "label": "option_list =", "type": "assigned_variable", "loc": [52, 55], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98866:ClassDef_L51_C0", "vector": [14, 1, 0.8492, 0.0635, 1, 0.96, 0.0, 318, 4, 0, 0, 0, 0, 0, 1], "semantic": {"name": "option_list", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " option_list = BaseCommand.option_list + (\n make_option('--locale', '-l', dest='locale',\n help='The locale to process. Default is to process all.'),\n )"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98866:Assign_L56_C4", "label": "help =", "type": "assigned_variable", "loc": [56, 56], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98866:ClassDef_L51_C0", "vector": [14, 1, 0.8889, 0.0159, 1, 0.96, 0.25, 868, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "help", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " help = 'Compiles .po files to .mo files for use with builtin gettext support.'"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98866:Assign_L58_C4", "label": "requires_model_validation =", "type": "assigned_variable", "loc": [58, 58], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98866:ClassDef_L51_C0", "vector": [14, 1, 0.9206, 0.0159, 1, 0.96, 0.5, 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_98866:Assign_L59_C4", "label": "can_import_settings =", "type": "assigned_variable", "loc": [59, 59], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98866:ClassDef_L51_C0", "vector": [14, 1, 0.9365, 0.0159, 1, 0.96, 0.75, 447, 1, 0, 0, 0, 0, 4, 0], "semantic": {"name": "can_import_settings", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " can_import_settings = False"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98866:FunctionDef_L61_C4", "label": "handle", "type": "function", "loc": [61, 63], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98866:ClassDef_L51_C0", "vector": [2, 1, 0.9841, 0.0476, 1, 0.96, 1.0, 346, 0, 2, 0, 0, 0, 0, 2], "semantic": {"name": "handle", "arg_names": ["self", "options"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def handle(self, **options):\n locale = options.get('locale')\n compile_messages(self.stderr, locale=locale)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98866:Assign_L62_C8", "label": "locale = get()", "type": "assigned_variable", "loc": [62, 62], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98866:FunctionDef_L61_C4", "vector": [14, 2, 0.9841, 0.0159, 2, 0.32, 0.0, 884, 3, 1, 0, 0, 607, 10, 1], "semantic": {"name": "locale", "arg_names": [], "import_names": [], "rhs_call_name": "get", "annotation": ""}, "snippet": " locale = options.get('locale')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98866:Expr_L63_C8", "label": "compile_messages()", "type": "expression", "loc": [63, 63], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98866:FunctionDef_L61_C4", "vector": [8, 2, 1.0, 0.0159, 2, 0.32, 1.0, 217, 3, 2, 0, 0, 0, 0, 1], "semantic": {"name": "compile_messages", "arg_names": [], "import_names": [], "rhs_call_name": "compile_messages", "annotation": ""}, "snippet": " compile_messages(self.stderr, locale=locale)"}]
[{"f": "ajibawa-2023/Python-Code-Large/train/row_98866:FunctionDef_L7_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98866:Assign_L8_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98866:FunctionDef_L7_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98866:Assign_L9_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98866:FunctionDef_L7_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98866:Return_L10_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98866:FunctionDef_L14_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98866:Assign_L15_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98866:FunctionDef_L14_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98866:If_L16_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98866:If_L16_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98866:ImportFrom_L17_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98866:If_L16_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98866:Expr_L18_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98866:FunctionDef_L14_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98866:Assign_L21_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98866:FunctionDef_L14_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98866:If_L23_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98866:FunctionDef_L14_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98866:For_L26_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98866:For_L26_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98866:If_L27_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98866:If_L27_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98866:Assign_L28_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98866:For_L26_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98866:For_L29_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98866:For_L29_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98866:For_L30_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98866:For_L30_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98866:If_L31_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98866:If_L31_C16", "t": "ajibawa-2023/Python-Code-Large/train/row_98866:Expr_L32_C20"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98866:If_L31_C16", "t": "ajibawa-2023/Python-Code-Large/train/row_98866:Assign_L33_C20"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98866:If_L31_C16", "t": "ajibawa-2023/Python-Code-Large/train/row_98866:If_L34_C20"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98866:If_L31_C16", "t": "ajibawa-2023/Python-Code-Large/train/row_98866:Assign_L36_C20"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98866:If_L31_C16", "t": "ajibawa-2023/Python-Code-Large/train/row_98866:Assign_L42_C20"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98866:If_L31_C16", "t": "ajibawa-2023/Python-Code-Large/train/row_98866:Assign_L43_C20"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98866:If_L31_C16", "t": "ajibawa-2023/Python-Code-Large/train/row_98866:If_L44_C20"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98866:If_L44_C20", "t": "ajibawa-2023/Python-Code-Large/train/row_98866:Assign_L45_C24"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98866:If_L44_C20", "t": "ajibawa-2023/Python-Code-Large/train/row_98866:Assign_L47_C24"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98866:If_L31_C16", "t": "ajibawa-2023/Python-Code-Large/train/row_98866:Expr_L48_C20"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98866:ClassDef_L51_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98866:Assign_L52_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98866:ClassDef_L51_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98866:Assign_L56_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98866:ClassDef_L51_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98866:Assign_L58_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98866:ClassDef_L51_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98866:Assign_L59_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98866:ClassDef_L51_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98866:FunctionDef_L61_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98866:FunctionDef_L61_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98866:Assign_L62_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98866:FunctionDef_L61_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98866:Expr_L63_C8"}]
from django.core.management.base import NoArgsCommand def module_to_dict(module, omittable=lambda k: k.startswith('_')): "Converts a module namespace to a Python dictionary. Used by get_settings_diff." return dict([(k, repr(v)) for k, v in module.__dict__.items() if not omittable(k)]) class Command(NoArgsCommand): help = """Displays differences between the current settings.py and Django's default settings. Settings that don't appear in the defaults are followed by "###".""" requires_model_validation = False def handle_noargs(self, **options): # Inspired by Postfix's "postconf -n". from django.conf import settings, global_settings # Because settings are imported lazily, we need to explicitly load them. settings._setup() user_settings = module_to_dict(settings._wrapped) default_settings = module_to_dict(global_settings) output = [] keys = user_settings.keys() keys.sort() for key in keys: if key not in default_settings: output.append("%s = %s ###" % (key, user_settings[key])) elif user_settings[key] != default_settings[key]: output.append("%s = %s" % (key, user_settings[key])) return '\n'.join(output)
ajibawa-2023/Python-Code-Large/train/row_98867
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_98867:ImportFrom_L1_C0", "label": "from django.core.management.base import NoArgsCommand", "type": "import", "loc": [1, 1], "level": 0, "parent": null, "vector": [1, 0, 0.0312, 0.0312, 0, 0.66, 0.0, 931, 0, 1, 0, 0, 931, 0, 0], "semantic": {"name": "django.core.management.base", "arg_names": [], "import_names": ["NoArgsCommand"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.core.management.base import NoArgsCommand"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98867:FunctionDef_L3_C0", "label": "module_to_dict", "type": "function", "loc": [3, 5], "level": 0, "parent": null, "vector": [2, 0, 0.125, 0.0938, 0, 0.66, 0.5, 736, 0, 2, 1, 0, 0, 0, 5], "semantic": {"name": "module_to_dict", "arg_names": ["module", "omittable"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "def module_to_dict(module, omittable=lambda k: k.startswith('_')):\n \"Converts a module namespace to a Python dictionary. Used by get_settings_diff.\"\n return dict([(k, repr(v)) for k, v in module.__dict__.items() if not omittable(k)])"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98867:Expr_L4_C4", "label": "expression", "type": "expression", "loc": [4, 4], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98867:FunctionDef_L3_C0", "vector": [8, 1, 0.125, 0.0312, 1, 0.22, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"Converts a module namespace to a Python dictionary. Used by get_settings_diff.\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98867:Return_L5_C4", "label": "return", "type": "return", "loc": [5, 5], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98867:FunctionDef_L3_C0", "vector": [13, 1, 0.1562, 0.0312, 1, 0.22, 1.0, 0, 3, 0, 0, 0, 0, 10, 4], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return dict([(k, repr(v)) for k, v in module.__dict__.items() if not omittable(k)])"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98867:ClassDef_L7_C0", "label": "Command", "type": "class", "loc": [7, 32], "level": 0, "parent": null, "vector": [3, 0, 0.6094, 0.8125, 0, 0.66, 1.0, 73, 0, 1, 0, 0, 795, 0, 8], "semantic": {"name": "Command", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class Command(NoArgsCommand):\n help = \"\"\"Displays differences between the current settings.py and Django's\n default settings. Settings that don't appear in the defaults are\n followed by \"###\".\"\"\"\n\n requires_model_validation = False\n\n def handle_noargs(self, **options):"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98867:Assign_L8_C4", "label": "help =", "type": "assigned_variable", "loc": [8, 10], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98867:ClassDef_L7_C0", "vector": [14, 1, 0.2812, 0.0938, 1, 0.14, 0.0, 868, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "help", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " help = \"\"\"Displays differences between the current settings.py and Django's\n default settings. Settings that don't appear in the defaults are\n followed by \"###\".\"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98867:Assign_L12_C4", "label": "requires_model_validation =", "type": "assigned_variable", "loc": [12, 12], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98867:ClassDef_L7_C0", "vector": [14, 1, 0.375, 0.0312, 1, 0.14, 0.5, 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_98867:FunctionDef_L14_C4", "label": "handle_noargs", "type": "function", "loc": [14, 32], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98867:ClassDef_L7_C0", "vector": [2, 1, 0.7188, 0.5938, 1, 0.14, 1.0, 28, 0, 2, 1, 0, 0, 0, 8], "semantic": {"name": "handle_noargs", "arg_names": ["self", "options"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def handle_noargs(self, **options):\n # Inspired by Postfix's \"postconf -n\".\n from django.conf import settings, global_settings\n\n # Because settings are imported lazily, we need to explicitly load them.\n settings._setup()\n\n user_settings = module_to_dict(settings._wrapped)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98867:ImportFrom_L16_C8", "label": "from django.conf import settings, global_settings", "type": "import", "loc": [16, 16], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98867:FunctionDef_L14_C4", "vector": [1, 2, 0.5, 0.0312, 2, 0.29, 0.0, 128, 0, 2, 0, 0, 128, 0, 0], "semantic": {"name": "django.conf", "arg_names": [], "import_names": ["settings", "global_settings"], "rhs_call_name": "", "annotation": ""}, "snippet": " from django.conf import settings, global_settings"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98867:Expr_L19_C8", "label": "_setup()", "type": "expression", "loc": [19, 19], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98867:FunctionDef_L14_C4", "vector": [8, 2, 0.5938, 0.0312, 2, 0.29, 0.125, 518, 3, 0, 0, 0, 0, 0, 1], "semantic": {"name": "_setup", "arg_names": [], "import_names": [], "rhs_call_name": "_setup", "annotation": ""}, "snippet": " settings._setup()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98867:Assign_L21_C8", "label": "user_settings = module_to_dict()", "type": "assigned_variable", "loc": [21, 21], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98867:FunctionDef_L14_C4", "vector": [14, 2, 0.6562, 0.0312, 2, 0.29, 0.25, 669, 3, 1, 0, 0, 736, 10, 1], "semantic": {"name": "user_settings", "arg_names": [], "import_names": [], "rhs_call_name": "module_to_dict", "annotation": ""}, "snippet": " user_settings = module_to_dict(settings._wrapped)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98867:Assign_L22_C8", "label": "default_settings = module_to_dict()", "type": "assigned_variable", "loc": [22, 22], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98867:FunctionDef_L14_C4", "vector": [14, 2, 0.6875, 0.0312, 2, 0.29, 0.375, 808, 3, 1, 0, 0, 736, 10, 1], "semantic": {"name": "default_settings", "arg_names": [], "import_names": [], "rhs_call_name": "module_to_dict", "annotation": ""}, "snippet": " default_settings = module_to_dict(global_settings)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98867:Assign_L24_C8", "label": "output =", "type": "assigned_variable", "loc": [24, 24], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98867:FunctionDef_L14_C4", "vector": [14, 2, 0.75, 0.0312, 2, 0.29, 0.5, 886, 0, 0, 0, 0, 0, 5, 0], "semantic": {"name": "output", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " output = []"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98867:Assign_L25_C8", "label": "keys = keys()", "type": "assigned_variable", "loc": [25, 25], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98867:FunctionDef_L14_C4", "vector": [14, 2, 0.7812, 0.0312, 2, 0.29, 0.625, 204, 3, 0, 0, 0, 204, 10, 1], "semantic": {"name": "keys", "arg_names": [], "import_names": [], "rhs_call_name": "keys", "annotation": ""}, "snippet": " keys = user_settings.keys()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98867:Expr_L26_C8", "label": "sort()", "type": "expression", "loc": [26, 26], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98867:FunctionDef_L14_C4", "vector": [8, 2, 0.8125, 0.0312, 2, 0.29, 0.75, 489, 3, 0, 0, 0, 0, 0, 1], "semantic": {"name": "sort", "arg_names": [], "import_names": [], "rhs_call_name": "sort", "annotation": ""}, "snippet": " keys.sort()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98867:For_L27_C8", "label": "for key", "type": "for", "loc": [27, 31], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98867:FunctionDef_L14_C4", "vector": [6, 2, 0.9062, 0.1562, 2, 0.29, 0.875, 230, 2, 0, 0, 0, 0, 0, 2], "semantic": {"name": "key", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for key in keys:\n if key not in default_settings:\n output.append(\"%s = %s ###\" % (key, user_settings[key]))\n elif user_settings[key] != default_settings[key]:\n output.append(\"%s = %s\" % (key, user_settings[key]))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98867:If_L28_C12", "label": "if", "type": "if", "loc": [28, 31], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98867:For_L27_C8", "vector": [4, 3, 0.9219, 0.125, 3, 0.57, 0.0, 0, 0, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if key not in default_settings:\n output.append(\"%s = %s ###\" % (key, user_settings[key]))\n elif user_settings[key] != default_settings[key]:\n output.append(\"%s = %s\" % (key, user_settings[key]))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98867:Expr_L29_C16", "label": "append()", "type": "expression", "loc": [29, 29], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98867:If_L28_C12", "vector": [8, 4, 0.9062, 0.0312, 4, 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": " output.append(\"%s = %s ###\" % (key, user_settings[key]))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98867:If_L30_C12", "label": "if", "type": "if", "loc": [30, 31], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98867:If_L28_C12", "vector": [4, 4, 0.9531, 0.0625, 4, 0.16, 1.0, 0, 0, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " elif user_settings[key] != default_settings[key]:\n output.append(\"%s = %s\" % (key, user_settings[key]))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98867:Expr_L31_C16", "label": "append()", "type": "expression", "loc": [31, 31], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98867:If_L30_C12", "vector": [8, 5, 0.9688, 0.0312, 5, 0.62, 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(\"%s = %s\" % (key, user_settings[key]))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98867:Return_L32_C8", "label": "return", "type": "return", "loc": [32, 32], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98867:FunctionDef_L14_C4", "vector": [13, 2, 1.0, 0.0312, 2, 0.29, 1.0, 0, 3, 0, 0, 0, 0, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return '\\n'.join(output)"}]
[{"f": "ajibawa-2023/Python-Code-Large/train/row_98867:FunctionDef_L3_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98867:Expr_L4_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98867:FunctionDef_L3_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98867:Return_L5_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98867:ClassDef_L7_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98867:Assign_L8_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98867:ClassDef_L7_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98867:Assign_L12_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98867:ClassDef_L7_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98867:FunctionDef_L14_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98867:FunctionDef_L14_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98867:ImportFrom_L16_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98867:FunctionDef_L14_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98867:Expr_L19_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98867:FunctionDef_L14_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98867:Assign_L21_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98867:FunctionDef_L14_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98867:Assign_L22_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98867:FunctionDef_L14_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98867:Assign_L24_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98867:FunctionDef_L14_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98867:Assign_L25_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98867:FunctionDef_L14_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98867:Expr_L26_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98867:FunctionDef_L14_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98867:For_L27_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98867:For_L27_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98867:If_L28_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98867:If_L28_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98867:Expr_L29_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98867:If_L28_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98867:If_L30_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98867:If_L30_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98867:Expr_L31_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98867:FunctionDef_L14_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98867:Return_L32_C8"}]
import keyword from optparse import make_option from django.core.management.base import NoArgsCommand, CommandError from django.db import connections, DEFAULT_DB_ALIAS class Command(NoArgsCommand): help = "Introspects the database tables in the given database and outputs a Django model module." option_list = NoArgsCommand.option_list + ( make_option('--database', action='store', dest='database', default=DEFAULT_DB_ALIAS, help='Nominates a database to ' 'introspect. Defaults to using the "default" database.'), ) requires_model_validation = False db_module = 'django.db' def handle_noargs(self, **options): try: for line in self.handle_inspection(options): print line except NotImplementedError: raise CommandError("Database inspection isn't supported for the currently selected database backend.") def handle_inspection(self, options): connection = connections[options.get('database', DEFAULT_DB_ALIAS)] table2model = lambda table_name: table_name.title().replace('_', '').replace(' ', '').replace('-', '') cursor = connection.cursor() yield "# This is an auto-generated Django model module." yield "# You'll have to do the following manually to clean this up:" yield "# * Rearrange models' order" yield "# * Make sure each model has one field with primary_key=True" yield "# Feel free to rename the models, but don't rename db_table values or field names." yield "#" yield "# Also note: You'll have to insert the output of 'django-admin.py sqlcustom [appname]'" yield "# into your database." yield '' yield 'from %s import models' % self.db_module yield '' for table_name in connection.introspection.get_table_list(cursor): yield 'class %s(models.Model):' % table2model(table_name) try: relations = connection.introspection.get_relations(cursor, table_name) except NotImplementedError: relations = {} try: indexes = connection.introspection.get_indexes(cursor, table_name) except NotImplementedError: indexes = {} for i, row in enumerate(connection.introspection.get_table_description(cursor, table_name)): column_name = row[0] att_name = column_name.lower() comment_notes = [] # Holds Field notes, to be displayed in a Python comment. extra_params = {} # Holds Field parameters such as 'db_column'. # If the column name can't be used verbatim as a Python # attribute, set the "db_column" for this Field. if ' ' in att_name or '-' in att_name or keyword.iskeyword(att_name) or column_name != att_name: extra_params['db_column'] = column_name # Modify the field name to make it Python-compatible. if ' ' in att_name: att_name = att_name.replace(' ', '_') comment_notes.append('Field renamed to remove spaces.') if '-' in att_name: att_name = att_name.replace('-', '_') comment_notes.append('Field renamed to remove dashes.') if keyword.iskeyword(att_name): att_name += '_field' comment_notes.append('Field renamed because it was a Python reserved word.') if column_name != att_name: comment_notes.append('Field name made lowercase.') if i in relations: rel_to = relations[i][1] == table_name and "'self'" or table2model(relations[i][1]) field_type = 'ForeignKey(%s' % rel_to if att_name.endswith('_id'): att_name = att_name[:-3] else: extra_params['db_column'] = column_name else: # Calling `get_field_type` to get the field type string and any # additional paramters and notes. field_type, field_params, field_notes = self.get_field_type(connection, table_name, row) extra_params.update(field_params) comment_notes.extend(field_notes) # Add primary_key and unique, if necessary. if column_name in indexes: if indexes[column_name]['primary_key']: extra_params['primary_key'] = True elif indexes[column_name]['unique']: extra_params['unique'] = True field_type += '(' # Don't output 'id = meta.AutoField(primary_key=True)', because # that's assumed if it doesn't exist. if att_name == 'id' and field_type == 'AutoField(' and extra_params == {'primary_key': True}: continue # Add 'null' and 'blank', if the 'null_ok' flag was present in the # table description. if row[6]: # If it's NULL... extra_params['blank'] = True if not field_type in ('TextField(', 'CharField('): extra_params['null'] = True field_desc = '%s = models.%s' % (att_name, field_type) if extra_params: if not field_desc.endswith('('): field_desc += ', ' field_desc += ', '.join(['%s=%r' % (k, v) for k, v in extra_params.items()]) field_desc += ')' if comment_notes: field_desc += ' # ' + ' '.join(comment_notes) yield ' %s' % field_desc for meta_line in self.get_meta(table_name): yield meta_line def get_field_type(self, connection, table_name, row): """ Given the database connection, the table name, and the cursor row description, this routine will return the given field type name, as well as any additional keyword parameters and notes for the field. """ field_params = {} field_notes = [] try: field_type = connection.introspection.get_field_type(row[1], row) except KeyError: field_type = 'TextField' field_notes.append('This field type is a guess.') # This is a hook for DATA_TYPES_REVERSE to return a tuple of # (field_type, field_params_dict). if type(field_type) is tuple: field_type, new_params = field_type field_params.update(new_params) # Add max_length for all CharFields. if field_type == 'CharField' and row[3]: field_params['max_length'] = row[3] if field_type == 'DecimalField': field_params['max_digits'] = row[4] field_params['decimal_places'] = row[5] return field_type, field_params, field_notes def get_meta(self, table_name): """ Return a sequence comprising the lines of code necessary to construct the inner Meta class for the model corresponding to the given database table name. """ return [' class Meta:', ' db_table = %r' % table_name, '']
ajibawa-2023/Python-Code-Large/train/row_98868
99
164
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_98868:Import_L1_C0", "label": "keyword import keyword", "type": "import", "loc": [1, 1], "level": 0, "parent": null, "vector": [1, 0, 0.0061, 0.0061, 0, 0.66, 0.0, 454, 0, 1, 0, 0, 454, 0, 0], "semantic": {"name": "keyword", "arg_names": [], "import_names": ["keyword"], "rhs_call_name": "", "annotation": ""}, "snippet": "import keyword"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98868:ImportFrom_L2_C0", "label": "from optparse import make_option", "type": "import", "loc": [2, 2], "level": 0, "parent": null, "vector": [1, 0, 0.0122, 0.0061, 0, 0.66, 0.25, 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_98868:ImportFrom_L4_C0", "label": "from django.core.management.base import NoArgsCommand, CommandError", "type": "import", "loc": [4, 4], "level": 0, "parent": null, "vector": [1, 0, 0.0244, 0.0061, 0, 0.66, 0.5, 931, 0, 2, 0, 0, 931, 0, 0], "semantic": {"name": "django.core.management.base", "arg_names": [], "import_names": ["NoArgsCommand", "CommandError"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.core.management.base import NoArgsCommand, CommandError"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98868:ImportFrom_L5_C0", "label": "from django.db import connections, DEFAULT_DB_ALIAS", "type": "import", "loc": [5, 5], "level": 0, "parent": null, "vector": [1, 0, 0.0305, 0.0061, 0, 0.66, 0.75, 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_98868:ClassDef_L7_C0", "label": "Command", "type": "class", "loc": [7, 164], "level": 0, "parent": null, "vector": [3, 0, 0.5213, 0.9634, 0, 0.66, 1.0, 73, 0, 4, 0, 0, 795, 0, 39], "semantic": {"name": "Command", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class Command(NoArgsCommand):\n help = \"Introspects the database tables in the given database and outputs a Django model module.\"\n\n option_list = NoArgsCommand.option_list + (\n make_option('--database', action='store', dest='database',\n default=DEFAULT_DB_ALIAS, help='Nominates a database to '\n 'introspect. Defaults to using the \"default\" database.'),\n )"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98868:Assign_L8_C4", "label": "help =", "type": "assigned_variable", "loc": [8, 8], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98868:ClassDef_L7_C0", "vector": [14, 1, 0.0488, 0.0061, 1, 0.25, 0.0, 868, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "help", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " help = \"Introspects the database tables in the given database and outputs a Django model module.\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98868:Assign_L10_C4", "label": "option_list =", "type": "assigned_variable", "loc": [10, 14], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98868:ClassDef_L7_C0", "vector": [14, 1, 0.0732, 0.0305, 1, 0.25, 0.1429, 318, 4, 0, 0, 0, 0, 0, 1], "semantic": {"name": "option_list", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " option_list = NoArgsCommand.option_list + (\n make_option('--database', action='store', dest='database',\n default=DEFAULT_DB_ALIAS, help='Nominates a database to '\n 'introspect. Defaults to using the \"default\" database.'),\n )"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98868:Assign_L16_C4", "label": "requires_model_validation =", "type": "assigned_variable", "loc": [16, 16], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98868:ClassDef_L7_C0", "vector": [14, 1, 0.0976, 0.0061, 1, 0.25, 0.2857, 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_98868:Assign_L18_C4", "label": "db_module =", "type": "assigned_variable", "loc": [18, 18], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98868:ClassDef_L7_C0", "vector": [14, 1, 0.1098, 0.0061, 1, 0.25, 0.4286, 406, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "db_module", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " db_module = 'django.db'"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98868:FunctionDef_L20_C4", "label": "handle_noargs", "type": "function", "loc": [20, 25], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98868:ClassDef_L7_C0", "vector": [2, 1, 0.1372, 0.0366, 1, 0.25, 0.5714, 28, 0, 2, 0, 0, 0, 0, 3], "semantic": {"name": "handle_noargs", "arg_names": ["self", "options"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def handle_noargs(self, **options):\n try:\n for line in self.handle_inspection(options):\n print(line)\n except NotImplementedError:\n raise CommandError(\"Database inspection isn't supported for the currently selected database backend.\")"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98868:Try_L21_C8", "label": "try", "type": "try", "loc": [21, 25], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98868:FunctionDef_L20_C4", "vector": [7, 2, 0.1402, 0.0305, 2, 0.01, 0.0, 0, 0, 1, 0, 0, 0, 0, 3], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " try:\n for line in self.handle_inspection(options):\n print(line)\n except NotImplementedError:\n raise CommandError(\"Database inspection isn't supported for the currently selected database backend.\")"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98868:For_L22_C12", "label": "for line", "type": "for", "loc": [22, 23], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98868:Try_L21_C8", "vector": [6, 3, 0.1372, 0.0122, 3, 0.5, 0.0, 373, 3, 0, 0, 0, 0, 0, 2], "semantic": {"name": "line", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for line in self.handle_inspection(options):\n print(line)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98868:Expr_L23_C16", "label": "print()", "type": "expression", "loc": [23, 23], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98868:For_L22_C12", "vector": [8, 4, 0.1402, 0.0061, 4, 0.6, 0.0, 535, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "print", "arg_names": [], "import_names": [], "rhs_call_name": "print", "annotation": ""}, "snippet": " print(line)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98868:FunctionDef_L27_C4", "label": "handle_inspection", "type": "function", "loc": [27, 123], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98868:ClassDef_L7_C0", "vector": [2, 1, 0.4573, 0.5915, 1, 0.25, 0.7143, 576, 0, 2, 0, 0, 0, 0, 31], "semantic": {"name": "handle_inspection", "arg_names": ["self", "options"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def handle_inspection(self, options):\n connection = connections[options.get('database', DEFAULT_DB_ALIAS)]\n\n table2model = lambda table_name: table_name.title().replace('_', '').replace(' ', '').replace('-', '')\n\n cursor = connection.cursor()\n yield \"# This is an auto-generated Django model module.\"\n yield \"# You'll have to do the following manually to clean this up:\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98868:Assign_L28_C8", "label": "connection =", "type": "assigned_variable", "loc": [28, 28], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98868:FunctionDef_L27_C4", "vector": [14, 2, 0.1707, 0.0061, 2, 0.44, 0.0, 351, 6, 0, 0, 0, 0, 0, 1], "semantic": {"name": "connection", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " connection = connections[options.get('database', DEFAULT_DB_ALIAS)]"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98868:Assign_L30_C8", "label": "table2model =", "type": "assigned_variable", "loc": [30, 30], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98868:FunctionDef_L27_C4", "vector": [14, 2, 0.1829, 0.0061, 2, 0.44, 0.0714, 574, 9, 0, 0, 0, 0, 0, 4], "semantic": {"name": "table2model", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " table2model = lambda table_name: table_name.title().replace('_', '').replace(' ', '').replace('-', '')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98868:Assign_L32_C8", "label": "cursor = cursor()", "type": "assigned_variable", "loc": [32, 32], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98868:FunctionDef_L27_C4", "vector": [14, 2, 0.1951, 0.0061, 2, 0.44, 0.1429, 231, 3, 0, 0, 0, 231, 10, 1], "semantic": {"name": "cursor", "arg_names": [], "import_names": [], "rhs_call_name": "cursor", "annotation": ""}, "snippet": " cursor = connection.cursor()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98868:Expr_L33_C8", "label": "expression", "type": "expression", "loc": [33, 33], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98868:FunctionDef_L27_C4", "vector": [8, 2, 0.2012, 0.0061, 2, 0.44, 0.2143, 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.\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98868:Expr_L34_C8", "label": "expression", "type": "expression", "loc": [34, 34], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98868:FunctionDef_L27_C4", "vector": [8, 2, 0.2073, 0.0061, 2, 0.44, 0.2857, 0, 0, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " yield \"# You'll have to do the following manually to clean this up:\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98868:Expr_L35_C8", "label": "expression", "type": "expression", "loc": [35, 35], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98868:FunctionDef_L27_C4", "vector": [8, 2, 0.2134, 0.0061, 2, 0.44, 0.3571, 0, 0, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " yield \"# * Rearrange models' order\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98868:Expr_L36_C8", "label": "expression", "type": "expression", "loc": [36, 36], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98868:FunctionDef_L27_C4", "vector": [8, 2, 0.2195, 0.0061, 2, 0.44, 0.4286, 0, 0, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " yield \"# * Make sure each model has one field with primary_key=True\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98868:Expr_L37_C8", "label": "expression", "type": "expression", "loc": [37, 37], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98868:FunctionDef_L27_C4", "vector": [8, 2, 0.2256, 0.0061, 2, 0.44, 0.5, 0, 0, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " yield \"# Feel free to rename the models, but don't rename db_table values or field names.\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98868:Expr_L38_C8", "label": "expression", "type": "expression", "loc": [38, 38], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98868:FunctionDef_L27_C4", "vector": [8, 2, 0.2317, 0.0061, 2, 0.44, 0.5714, 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_98868:Expr_L39_C8", "label": "expression", "type": "expression", "loc": [39, 39], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98868:FunctionDef_L27_C4", "vector": [8, 2, 0.2378, 0.0061, 2, 0.44, 0.6429, 0, 0, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " yield \"# Also note: You'll have to insert the output of 'django-admin.py sqlcustom [appname]'\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98868:Expr_L40_C8", "label": "expression", "type": "expression", "loc": [40, 40], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98868:FunctionDef_L27_C4", "vector": [8, 2, 0.2439, 0.0061, 2, 0.44, 0.7143, 0, 0, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " yield \"# into your database.\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98868:Expr_L41_C8", "label": "expression", "type": "expression", "loc": [41, 41], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98868:FunctionDef_L27_C4", "vector": [8, 2, 0.25, 0.0061, 2, 0.44, 0.7857, 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_98868:Expr_L42_C8", "label": "expression", "type": "expression", "loc": [42, 42], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98868:FunctionDef_L27_C4", "vector": [8, 2, 0.2561, 0.0061, 2, 0.44, 0.8571, 0, 0, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " yield 'from %s import models' % self.db_module"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98868:Expr_L43_C8", "label": "expression", "type": "expression", "loc": [43, 43], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98868:FunctionDef_L27_C4", "vector": [8, 2, 0.2622, 0.0061, 2, 0.44, 0.9286, 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_98868:For_L44_C8", "label": "for table_name", "type": "for", "loc": [44, 123], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98868:FunctionDef_L27_C4", "vector": [6, 2, 0.5091, 0.4878, 2, 0.44, 1.0, 894, 3, 0, 0, 0, 0, 0, 25], "semantic": {"name": "table_name", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for table_name in connection.introspection.get_table_list(cursor):\n yield 'class %s(models.Model):' % table2model(table_name)\n try:\n relations = connection.introspection.get_relations(cursor, table_name)\n except NotImplementedError:\n relations = {}\n try:\n indexes = connection.introspection.get_indexes(cursor, table_name)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98868:Expr_L45_C12", "label": "expression", "type": "expression", "loc": [45, 45], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98868:For_L44_C8", "vector": [8, 3, 0.2744, 0.0061, 3, 0.77, 0.0, 0, 0, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " yield 'class %s(models.Model):' % table2model(table_name)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98868:Try_L46_C12", "label": "try", "type": "try", "loc": [46, 49], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98868:For_L44_C8", "vector": [7, 3, 0.2896, 0.0244, 3, 0.77, 0.25, 0, 0, 1, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " try:\n relations = connection.introspection.get_relations(cursor, table_name)\n except NotImplementedError:\n relations = {}"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98868:Assign_L47_C16", "label": "relations = get_relations()", "type": "assigned_variable", "loc": [47, 47], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98868:Try_L46_C12", "vector": [14, 4, 0.2866, 0.0061, 4, 0.39, 0.0, 900, 3, 2, 0, 0, 814, 10, 1], "semantic": {"name": "relations", "arg_names": [], "import_names": [], "rhs_call_name": "get_relations", "annotation": ""}, "snippet": " relations = connection.introspection.get_relations(cursor, table_name)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98868:Assign_L49_C16", "label": "relations =", "type": "assigned_variable", "loc": [49, 49], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98868:Try_L46_C12", "vector": [14, 4, 0.2988, 0.0061, 4, 0.39, 0.0, 900, 0, 0, 0, 0, 0, 6, 0], "semantic": {"name": "relations", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " relations = {}"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98868:Try_L50_C12", "label": "try", "type": "try", "loc": [50, 53], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98868:For_L44_C8", "vector": [7, 3, 0.314, 0.0244, 3, 0.77, 0.5, 0, 0, 1, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " try:\n indexes = connection.introspection.get_indexes(cursor, table_name)\n except NotImplementedError:\n indexes = {}"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98868:Assign_L51_C16", "label": "indexes = get_indexes()", "type": "assigned_variable", "loc": [51, 51], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98868:Try_L50_C12", "vector": [14, 4, 0.311, 0.0061, 4, 0.8, 0.0, 600, 3, 2, 0, 0, 808, 10, 1], "semantic": {"name": "indexes", "arg_names": [], "import_names": [], "rhs_call_name": "get_indexes", "annotation": ""}, "snippet": " indexes = connection.introspection.get_indexes(cursor, table_name)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98868:Assign_L53_C16", "label": "indexes =", "type": "assigned_variable", "loc": [53, 53], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98868:Try_L50_C12", "vector": [14, 4, 0.3232, 0.0061, 4, 0.8, 0.0, 600, 0, 0, 0, 0, 0, 6, 0], "semantic": {"name": "indexes", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " indexes = {}"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98868:For_L54_C12", "label": "for i, row", "type": "for", "loc": [54, 121], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98868:For_L44_C8", "vector": [6, 3, 0.5335, 0.4146, 3, 0.77, 0.75, 243, 3, 0, 0, 0, 0, 0, 20], "semantic": {"name": "i, row", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for i, row in enumerate(connection.introspection.get_table_description(cursor, table_name)):\n column_name = row[0]\n att_name = column_name.lower()\n comment_notes = [] # Holds Field notes, to be displayed in a Python comment.\n extra_params = {} # Holds Field parameters such as 'db_column'.\n\n # If the column name can't be used verbatim as a Python\n # attribute, set the \"db_column\" for this Field."}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98868:Assign_L55_C16", "label": "column_name =", "type": "assigned_variable", "loc": [55, 55], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98868:For_L54_C12", "vector": [14, 4, 0.3354, 0.0061, 4, 0.45, 0.0, 118, 6, 0, 0, 0, 0, 0, 0], "semantic": {"name": "column_name", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " column_name = row[0]"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98868:Assign_L56_C16", "label": "att_name = lower()", "type": "assigned_variable", "loc": [56, 56], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98868:For_L54_C12", "vector": [14, 4, 0.3415, 0.0061, 4, 0.45, 0.0667, 774, 3, 0, 0, 0, 432, 10, 1], "semantic": {"name": "att_name", "arg_names": [], "import_names": [], "rhs_call_name": "lower", "annotation": ""}, "snippet": " att_name = column_name.lower()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98868:Assign_L57_C16", "label": "comment_notes =", "type": "assigned_variable", "loc": [57, 57], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98868:For_L54_C12", "vector": [14, 4, 0.3476, 0.0061, 4, 0.45, 0.1333, 809, 0, 0, 0, 0, 0, 5, 0], "semantic": {"name": "comment_notes", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " comment_notes = [] # Holds Field notes, to be displayed in a Python comment."}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98868:Assign_L58_C16", "label": "extra_params =", "type": "assigned_variable", "loc": [58, 58], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98868:For_L54_C12", "vector": [14, 4, 0.3537, 0.0061, 4, 0.45, 0.2, 778, 0, 0, 0, 0, 0, 6, 0], "semantic": {"name": "extra_params", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " extra_params = {} # Holds Field parameters such as 'db_column'."}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98868:If_L62_C16", "label": "if", "type": "if", "loc": [62, 63], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98868:For_L54_C12", "vector": [4, 4, 0.3811, 0.0122, 4, 0.45, 0.2667, 0, 0, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if ' ' in att_name or '-' in att_name or keyword.iskeyword(att_name) or column_name != att_name:\n extra_params['db_column'] = column_name"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98868:Assign_L63_C20", "label": "assign", "type": "assigned_variable", "loc": [63, 63], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98868:If_L62_C16", "vector": [14, 5, 0.3841, 0.0061, 5, 0.25, 0.0, 0, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " extra_params['db_column'] = column_name"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98868:If_L66_C16", "label": "if", "type": "if", "loc": [66, 68], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98868:For_L54_C12", "vector": [4, 4, 0.4085, 0.0183, 4, 0.45, 0.3333, 0, 0, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if ' ' in att_name:\n att_name = att_name.replace(' ', '_')\n comment_notes.append('Field renamed to remove spaces.')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98868:Assign_L67_C20", "label": "att_name = replace()", "type": "assigned_variable", "loc": [67, 67], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98868:If_L66_C16", "vector": [14, 5, 0.4085, 0.0061, 5, 0.74, 0.0, 774, 3, 2, 0, 0, 293, 10, 1], "semantic": {"name": "att_name", "arg_names": [], "import_names": [], "rhs_call_name": "replace", "annotation": ""}, "snippet": " att_name = att_name.replace(' ', '_')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98868:Expr_L68_C20", "label": "append()", "type": "expression", "loc": [68, 68], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98868:If_L66_C16", "vector": [8, 5, 0.4146, 0.0061, 5, 0.74, 1.0, 243, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "append", "arg_names": [], "import_names": [], "rhs_call_name": "append", "annotation": ""}, "snippet": " comment_notes.append('Field renamed to remove spaces.')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98868:If_L69_C16", "label": "if", "type": "if", "loc": [69, 71], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98868:For_L54_C12", "vector": [4, 4, 0.4268, 0.0183, 4, 0.45, 0.4, 0, 0, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if '-' in att_name:\n att_name = att_name.replace('-', '_')\n comment_notes.append('Field renamed to remove dashes.')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98868:Assign_L70_C20", "label": "att_name = replace()", "type": "assigned_variable", "loc": [70, 70], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98868:If_L69_C16", "vector": [14, 5, 0.4268, 0.0061, 5, 0.66, 0.0, 774, 3, 2, 0, 0, 293, 10, 1], "semantic": {"name": "att_name", "arg_names": [], "import_names": [], "rhs_call_name": "replace", "annotation": ""}, "snippet": " att_name = att_name.replace('-', '_')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98868:Expr_L71_C20", "label": "append()", "type": "expression", "loc": [71, 71], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98868:If_L69_C16", "vector": [8, 5, 0.4329, 0.0061, 5, 0.66, 1.0, 243, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "append", "arg_names": [], "import_names": [], "rhs_call_name": "append", "annotation": ""}, "snippet": " comment_notes.append('Field renamed to remove dashes.')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98868:If_L72_C16", "label": "if", "type": "if", "loc": [72, 74], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98868:For_L54_C12", "vector": [4, 4, 0.4451, 0.0183, 4, 0.45, 0.4667, 0, 3, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if keyword.iskeyword(att_name):\n att_name += '_field'\n comment_notes.append('Field renamed because it was a Python reserved word.')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98868:Expr_L74_C20", "label": "append()", "type": "expression", "loc": [74, 74], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98868:If_L72_C16", "vector": [8, 5, 0.4512, 0.0061, 5, 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": " comment_notes.append('Field renamed because it was a Python reserved word.')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98868:If_L75_C16", "label": "if", "type": "if", "loc": [75, 76], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98868:For_L54_C12", "vector": [4, 4, 0.4604, 0.0122, 4, 0.45, 0.5333, 0, 0, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if column_name != att_name:\n comment_notes.append('Field name made lowercase.')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98868:Expr_L76_C20", "label": "append()", "type": "expression", "loc": [76, 76], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98868:If_L75_C16", "vector": [8, 5, 0.4634, 0.0061, 5, 0.36, 0.0, 243, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "append", "arg_names": [], "import_names": [], "rhs_call_name": "append", "annotation": ""}, "snippet": " comment_notes.append('Field name made lowercase.')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98868:If_L78_C16", "label": "if", "type": "if", "loc": [78, 99], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98868:For_L54_C12", "vector": [4, 4, 0.5396, 0.1341, 4, 0.45, 0.6, 0, 0, 0, 0, 0, 0, 0, 5], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if i in relations:\n rel_to = relations[i][1] == table_name and \"'self'\" or table2model(relations[i][1])\n field_type = 'ForeignKey(%s' % rel_to\n if att_name.endswith('_id'):\n att_name = att_name[:-3]\n else:\n extra_params['db_column'] = column_name\n else:"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98868:Assign_L79_C20", "label": "rel_to =", "type": "assigned_variable", "loc": [79, 79], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98868:If_L78_C16", "vector": [14, 5, 0.4817, 0.0061, 5, 0.19, 0.0, 213, 0, 0, 0, 0, 0, 0, 1], "semantic": {"name": "rel_to", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " rel_to = relations[i][1] == table_name and \"'self'\" or table2model(relations[i][1])"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98868:Assign_L80_C20", "label": "field_type =", "type": "assigned_variable", "loc": [80, 80], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98868:If_L78_C16", "vector": [14, 5, 0.4878, 0.0061, 5, 0.19, 0.1667, 954, 4, 0, 0, 0, 0, 0, 0], "semantic": {"name": "field_type", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " field_type = 'ForeignKey(%s' % rel_to"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98868:If_L81_C20", "label": "if", "type": "if", "loc": [81, 84], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98868:If_L78_C16", "vector": [4, 5, 0.503, 0.0244, 5, 0.19, 0.3333, 0, 3, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if att_name.endswith('_id'):\n att_name = att_name[:-3]\n else:\n extra_params['db_column'] = column_name"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98868:Assign_L82_C24", "label": "att_name =", "type": "assigned_variable", "loc": [82, 82], "level": 6, "parent": "ajibawa-2023/Python-Code-Large/train/row_98868:If_L81_C20", "vector": [14, 6, 0.5, 0.0061, 6, 0.78, 0.0, 774, 6, 0, 0, 0, 0, 0, 0], "semantic": {"name": "att_name", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " att_name = att_name[:-3]"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98868:Assign_L84_C24", "label": "assign", "type": "assigned_variable", "loc": [84, 84], "level": 6, "parent": "ajibawa-2023/Python-Code-Large/train/row_98868:If_L81_C20", "vector": [14, 6, 0.5122, 0.0061, 6, 0.78, 1.0, 0, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " extra_params['db_column'] = column_name"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98868:Assign_L88_C20", "label": "field_type, field_params, field_notes = get_field_type()", "type": "assigned_variable", "loc": [88, 88], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98868:If_L78_C16", "vector": [14, 5, 0.5366, 0.0061, 5, 0.19, 0.5, 31, 3, 3, 0, 0, 691, 10, 1], "semantic": {"name": "field_type, field_params, field_notes", "arg_names": [], "import_names": [], "rhs_call_name": "get_field_type", "annotation": ""}, "snippet": " field_type, field_params, field_notes = self.get_field_type(connection, table_name, row)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98868:Expr_L89_C20", "label": "update()", "type": "expression", "loc": [89, 89], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98868:If_L78_C16", "vector": [8, 5, 0.5427, 0.0061, 5, 0.19, 0.6667, 637, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "update", "arg_names": [], "import_names": [], "rhs_call_name": "update", "annotation": ""}, "snippet": " extra_params.update(field_params)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98868:Expr_L90_C20", "label": "extend()", "type": "expression", "loc": [90, 90], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98868:If_L78_C16", "vector": [8, 5, 0.5488, 0.0061, 5, 0.19, 0.8333, 660, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "extend", "arg_names": [], "import_names": [], "rhs_call_name": "extend", "annotation": ""}, "snippet": " comment_notes.extend(field_notes)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98868:If_L93_C20", "label": "if", "type": "if", "loc": [93, 97], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98868:If_L78_C16", "vector": [4, 5, 0.5793, 0.0305, 5, 0.19, 1.0, 0, 0, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if column_name in indexes:\n if indexes[column_name]['primary_key']:\n extra_params['primary_key'] = True\n elif indexes[column_name]['unique']:\n extra_params['unique'] = True"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98868:If_L94_C24", "label": "if", "type": "if", "loc": [94, 97], "level": 6, "parent": "ajibawa-2023/Python-Code-Large/train/row_98868:If_L93_C20", "vector": [4, 6, 0.5823, 0.0244, 6, 0.61, 0.0, 0, 6, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if indexes[column_name]['primary_key']:\n extra_params['primary_key'] = True\n elif indexes[column_name]['unique']:\n extra_params['unique'] = True"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98868:Assign_L95_C28", "label": "assign", "type": "assigned_variable", "loc": [95, 95], "level": 7, "parent": "ajibawa-2023/Python-Code-Large/train/row_98868:If_L94_C24", "vector": [14, 7, 0.5793, 0.0061, 7, 0.74, 0.0, 0, 1, 0, 0, 0, 0, 4, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " extra_params['primary_key'] = True"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98868:If_L96_C24", "label": "if", "type": "if", "loc": [96, 97], "level": 7, "parent": "ajibawa-2023/Python-Code-Large/train/row_98868:If_L94_C24", "vector": [4, 7, 0.5884, 0.0122, 7, 0.74, 1.0, 0, 6, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " elif indexes[column_name]['unique']:\n extra_params['unique'] = True"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98868:Assign_L97_C28", "label": "assign", "type": "assigned_variable", "loc": [97, 97], "level": 8, "parent": "ajibawa-2023/Python-Code-Large/train/row_98868:If_L96_C24", "vector": [14, 8, 0.5915, 0.0061, 8, 0.35, 0.0, 0, 1, 0, 0, 0, 0, 4, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " extra_params['unique'] = True"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98868:If_L103_C16", "label": "if", "type": "if", "loc": [103, 104], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98868:For_L54_C12", "vector": [4, 4, 0.6311, 0.0122, 4, 0.45, 0.6667, 0, 0, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if att_name == 'id' and field_type == 'AutoField(' and extra_params == {'primary_key': True}:\n continue"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98868:If_L108_C16", "label": "if", "type": "if", "loc": [108, 111], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98868:For_L54_C12", "vector": [4, 4, 0.6677, 0.0244, 4, 0.45, 0.7333, 0, 6, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if row[6]: # If it's NULL...\n extra_params['blank'] = True\n if not field_type in ('TextField(', 'CharField('):\n extra_params['null'] = True"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98868:Assign_L109_C20", "label": "assign", "type": "assigned_variable", "loc": [109, 109], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98868:If_L108_C16", "vector": [14, 5, 0.6646, 0.0061, 5, 0.58, 0.0, 0, 1, 0, 0, 0, 0, 4, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " extra_params['blank'] = True"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98868:If_L110_C20", "label": "if", "type": "if", "loc": [110, 111], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98868:If_L108_C16", "vector": [4, 5, 0.6738, 0.0122, 5, 0.58, 1.0, 0, 0, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if not field_type in ('TextField(', 'CharField('):\n extra_params['null'] = True"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98868:Assign_L111_C24", "label": "assign", "type": "assigned_variable", "loc": [111, 111], "level": 6, "parent": "ajibawa-2023/Python-Code-Large/train/row_98868:If_L110_C20", "vector": [14, 6, 0.6768, 0.0061, 6, 0.49, 0.0, 0, 1, 0, 0, 0, 0, 4, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " extra_params['null'] = True"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98868:Assign_L113_C16", "label": "field_desc =", "type": "assigned_variable", "loc": [113, 113], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98868:For_L54_C12", "vector": [14, 4, 0.689, 0.0061, 4, 0.45, 0.8, 921, 4, 0, 0, 0, 0, 0, 0], "semantic": {"name": "field_desc", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " field_desc = '%s = models.%s' % (att_name, field_type)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98868:If_L114_C16", "label": "if", "type": "if", "loc": [114, 117], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98868:For_L54_C12", "vector": [4, 4, 0.7043, 0.0244, 4, 0.45, 0.8667, 0, 2, 0, 0, 0, 0, 0, 3], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if extra_params:\n if not field_desc.endswith('('):\n field_desc += ', '\n field_desc += ', '.join(['%s=%r' % (k, v) for k, v in extra_params.items()])"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98868:If_L115_C20", "label": "if", "type": "if", "loc": [115, 116], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98868:If_L114_C16", "vector": [4, 5, 0.7043, 0.0122, 5, 0.08, 0.0, 0, 0, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if not field_desc.endswith('('):\n field_desc += ', '"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98868:If_L119_C16", "label": "if", "type": "if", "loc": [119, 120], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98868:For_L54_C12", "vector": [4, 4, 0.7287, 0.0122, 4, 0.45, 0.9333, 0, 2, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if comment_notes:\n field_desc += ' # ' + ' '.join(comment_notes)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98868:Expr_L121_C16", "label": "expression", "type": "expression", "loc": [121, 121], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98868:For_L54_C12", "vector": [8, 4, 0.7378, 0.0061, 4, 0.45, 1.0, 0, 0, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " yield ' %s' % field_desc"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98868:For_L122_C12", "label": "for meta_line", "type": "for", "loc": [122, 123], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98868:For_L44_C8", "vector": [6, 3, 0.747, 0.0122, 3, 0.77, 1.0, 931, 3, 0, 0, 0, 0, 0, 1], "semantic": {"name": "meta_line", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for meta_line in self.get_meta(table_name):\n yield meta_line"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98868:Expr_L123_C16", "label": "expression", "type": "expression", "loc": [123, 123], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98868:For_L122_C12", "vector": [8, 4, 0.75, 0.0061, 4, 0.91, 0.0, 0, 0, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " yield meta_line"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98868:FunctionDef_L125_C4", "label": "get_field_type", "type": "function", "loc": [125, 154], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98868:ClassDef_L7_C0", "vector": [2, 1, 0.8506, 0.1829, 1, 0.25, 0.8571, 691, 0, 4, 1, 0, 0, 0, 4], "semantic": {"name": "get_field_type", "arg_names": ["self", "connection", "table_name", "row"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def get_field_type(self, connection, table_name, row):\n \"\"\"\n Given the database connection, the table name, and the cursor row\n description, this routine will return the given field type name, as\n well as any additional keyword parameters and notes for the field.\n \"\"\"\n field_params = {}\n field_notes = []"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98868:Expr_L126_C8", "label": "expression", "type": "expression", "loc": [126, 130], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98868:FunctionDef_L125_C4", "vector": [8, 2, 0.7805, 0.0305, 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 Given the database connection, the table name, and the cursor row\n description, this routine will return the given field type name, as\n well as any additional keyword parameters and notes for the field.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98868:Assign_L131_C8", "label": "field_params =", "type": "assigned_variable", "loc": [131, 131], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98868:FunctionDef_L125_C4", "vector": [14, 2, 0.7988, 0.0061, 2, 0.65, 0.1429, 388, 0, 0, 0, 0, 0, 6, 0], "semantic": {"name": "field_params", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " field_params = {}"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98868:Assign_L132_C8", "label": "field_notes =", "type": "assigned_variable", "loc": [132, 132], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98868:FunctionDef_L125_C4", "vector": [14, 2, 0.8049, 0.0061, 2, 0.65, 0.2857, 420, 0, 0, 0, 0, 0, 5, 0], "semantic": {"name": "field_notes", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " field_notes = []"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98868:Try_L134_C8", "label": "try", "type": "try", "loc": [134, 138], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98868:FunctionDef_L125_C4", "vector": [7, 2, 0.8293, 0.0305, 2, 0.65, 0.4286, 0, 0, 1, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " try:\n field_type = connection.introspection.get_field_type(row[1], row)\n except KeyError:\n field_type = 'TextField'\n field_notes.append('This field type is a guess.')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98868:Assign_L135_C12", "label": "field_type = get_field_type()", "type": "assigned_variable", "loc": [135, 135], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98868:Try_L134_C8", "vector": [14, 3, 0.8232, 0.0061, 3, 0.61, 0.0, 954, 3, 2, 0, 0, 691, 10, 1], "semantic": {"name": "field_type", "arg_names": [], "import_names": [], "rhs_call_name": "get_field_type", "annotation": ""}, "snippet": " field_type = connection.introspection.get_field_type(row[1], row)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98868:Assign_L137_C12", "label": "field_type =", "type": "assigned_variable", "loc": [137, 137], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98868:Try_L134_C8", "vector": [14, 3, 0.8354, 0.0061, 3, 0.61, 0.0, 954, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "field_type", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " field_type = 'TextField'"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98868:Expr_L138_C12", "label": "append()", "type": "expression", "loc": [138, 138], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98868:Try_L134_C8", "vector": [8, 3, 0.8415, 0.0061, 3, 0.61, 1.0, 243, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "append", "arg_names": [], "import_names": [], "rhs_call_name": "append", "annotation": ""}, "snippet": " field_notes.append('This field type is a guess.')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98868:If_L142_C8", "label": "if", "type": "if", "loc": [142, 144], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98868:FunctionDef_L125_C4", "vector": [4, 2, 0.872, 0.0183, 2, 0.65, 0.5714, 0, 0, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if type(field_type) is tuple:\n field_type, new_params = field_type\n field_params.update(new_params)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98868:Assign_L143_C12", "label": "field_type, new_params =", "type": "assigned_variable", "loc": [143, 143], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98868:If_L142_C8", "vector": [14, 3, 0.872, 0.0061, 3, 0.34, 0.0, 405, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "field_type, new_params", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " field_type, new_params = field_type"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98868:Expr_L144_C12", "label": "update()", "type": "expression", "loc": [144, 144], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98868:If_L142_C8", "vector": [8, 3, 0.878, 0.0061, 3, 0.34, 1.0, 637, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "update", "arg_names": [], "import_names": [], "rhs_call_name": "update", "annotation": ""}, "snippet": " field_params.update(new_params)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98868:If_L147_C8", "label": "if", "type": "if", "loc": [147, 148], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98868:FunctionDef_L125_C4", "vector": [4, 2, 0.8994, 0.0122, 2, 0.65, 0.7143, 0, 0, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if field_type == 'CharField' and row[3]:\n field_params['max_length'] = row[3]"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98868:Assign_L148_C12", "label": "assign", "type": "assigned_variable", "loc": [148, 148], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98868:If_L147_C8", "vector": [14, 3, 0.9024, 0.0061, 3, 0.4, 0.0, 0, 6, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " field_params['max_length'] = row[3]"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98868:If_L150_C8", "label": "if", "type": "if", "loc": [150, 152], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98868:FunctionDef_L125_C4", "vector": [4, 2, 0.9207, 0.0183, 2, 0.65, 0.8571, 0, 0, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if field_type == 'DecimalField':\n field_params['max_digits'] = row[4]\n field_params['decimal_places'] = row[5]"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98868:Assign_L151_C12", "label": "assign", "type": "assigned_variable", "loc": [151, 151], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98868:If_L150_C8", "vector": [14, 3, 0.9207, 0.0061, 3, 0.98, 0.0, 0, 6, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " field_params['max_digits'] = row[4]"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98868:Assign_L152_C12", "label": "assign", "type": "assigned_variable", "loc": [152, 152], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98868:If_L150_C8", "vector": [14, 3, 0.9268, 0.0061, 3, 0.98, 1.0, 0, 6, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " field_params['decimal_places'] = row[5]"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98868:Return_L154_C8", "label": "return", "type": "return", "loc": [154, 154], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98868:FunctionDef_L125_C4", "vector": [13, 2, 0.939, 0.0061, 2, 0.65, 1.0, 0, 0, 0, 0, 0, 0, 8, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return field_type, field_params, field_notes"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98868:FunctionDef_L156_C4", "label": "get_meta", "type": "function", "loc": [156, 164], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98868:ClassDef_L7_C0", "vector": [2, 1, 0.9756, 0.0549, 1, 0.25, 1.0, 671, 0, 2, 1, 0, 0, 0, 0], "semantic": {"name": "get_meta", "arg_names": ["self", "table_name"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def get_meta(self, table_name):\n \"\"\"\n Return a sequence comprising the lines of code necessary\n to construct the inner Meta class for the model corresponding\n to the given database table name.\n \"\"\"\n return [' class Meta:',\n ' db_table = %r' % table_name,"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98868:Expr_L157_C8", "label": "expression", "type": "expression", "loc": [157, 161], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98868:FunctionDef_L156_C4", "vector": [8, 2, 0.9695, 0.0305, 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 Return a sequence comprising the lines of code necessary\n to construct the inner Meta class for the model corresponding\n to the given database table name.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98868:Return_L162_C8", "label": "return", "type": "return", "loc": [162, 164], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98868:FunctionDef_L156_C4", "vector": [13, 2, 0.9939, 0.0183, 2, 0.64, 1.0, 0, 0, 0, 0, 0, 0, 5, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return [' class Meta:',\n ' db_table = %r' % table_name,\n '']"}]
[{"f": "ajibawa-2023/Python-Code-Large/train/row_98868:ClassDef_L7_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98868:Assign_L8_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98868:ClassDef_L7_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98868:Assign_L10_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98868:ClassDef_L7_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98868:Assign_L16_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98868:ClassDef_L7_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98868:Assign_L18_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98868:ClassDef_L7_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98868:FunctionDef_L20_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98868:FunctionDef_L20_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98868:Try_L21_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98868:Try_L21_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98868:For_L22_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98868:For_L22_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98868:Expr_L23_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98868:ClassDef_L7_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98868:FunctionDef_L27_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98868:FunctionDef_L27_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98868:Assign_L28_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98868:FunctionDef_L27_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98868:Assign_L30_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98868:FunctionDef_L27_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98868:Assign_L32_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98868:FunctionDef_L27_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98868:Expr_L33_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98868:FunctionDef_L27_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98868:Expr_L34_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98868:FunctionDef_L27_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98868:Expr_L35_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98868:FunctionDef_L27_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98868:Expr_L36_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98868:FunctionDef_L27_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98868:Expr_L37_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98868:FunctionDef_L27_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98868:Expr_L38_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98868:FunctionDef_L27_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98868:Expr_L39_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98868:FunctionDef_L27_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98868:Expr_L40_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98868:FunctionDef_L27_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98868:Expr_L41_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98868:FunctionDef_L27_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98868:Expr_L42_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98868:FunctionDef_L27_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98868:Expr_L43_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98868:FunctionDef_L27_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98868:For_L44_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98868:For_L44_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98868:Expr_L45_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98868:For_L44_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98868:Try_L46_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98868:Try_L46_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98868:Assign_L47_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98868:Try_L46_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98868:Assign_L49_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98868:For_L44_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98868:Try_L50_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98868:Try_L50_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98868:Assign_L51_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98868:Try_L50_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98868:Assign_L53_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98868:For_L44_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98868:For_L54_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98868:For_L54_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98868:Assign_L55_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98868:For_L54_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98868:Assign_L56_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98868:For_L54_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98868:Assign_L57_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98868:For_L54_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98868:Assign_L58_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98868:For_L54_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98868:If_L62_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98868:If_L62_C16", "t": "ajibawa-2023/Python-Code-Large/train/row_98868:Assign_L63_C20"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98868:For_L54_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98868:If_L66_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98868:If_L66_C16", "t": "ajibawa-2023/Python-Code-Large/train/row_98868:Assign_L67_C20"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98868:If_L66_C16", "t": "ajibawa-2023/Python-Code-Large/train/row_98868:Expr_L68_C20"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98868:For_L54_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98868:If_L69_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98868:If_L69_C16", "t": "ajibawa-2023/Python-Code-Large/train/row_98868:Assign_L70_C20"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98868:If_L69_C16", "t": "ajibawa-2023/Python-Code-Large/train/row_98868:Expr_L71_C20"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98868:For_L54_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98868:If_L72_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98868:If_L72_C16", "t": "ajibawa-2023/Python-Code-Large/train/row_98868:Expr_L74_C20"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98868:For_L54_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98868:If_L75_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98868:If_L75_C16", "t": "ajibawa-2023/Python-Code-Large/train/row_98868:Expr_L76_C20"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98868:For_L54_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98868:If_L78_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98868:If_L78_C16", "t": "ajibawa-2023/Python-Code-Large/train/row_98868:Assign_L79_C20"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98868:If_L78_C16", "t": "ajibawa-2023/Python-Code-Large/train/row_98868:Assign_L80_C20"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98868:If_L78_C16", "t": "ajibawa-2023/Python-Code-Large/train/row_98868:If_L81_C20"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98868:If_L81_C20", "t": "ajibawa-2023/Python-Code-Large/train/row_98868:Assign_L82_C24"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98868:If_L81_C20", "t": "ajibawa-2023/Python-Code-Large/train/row_98868:Assign_L84_C24"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98868:If_L78_C16", "t": "ajibawa-2023/Python-Code-Large/train/row_98868:Assign_L88_C20"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98868:If_L78_C16", "t": "ajibawa-2023/Python-Code-Large/train/row_98868:Expr_L89_C20"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98868:If_L78_C16", "t": "ajibawa-2023/Python-Code-Large/train/row_98868:Expr_L90_C20"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98868:If_L78_C16", "t": "ajibawa-2023/Python-Code-Large/train/row_98868:If_L93_C20"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98868:If_L93_C20", "t": "ajibawa-2023/Python-Code-Large/train/row_98868:If_L94_C24"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98868:If_L94_C24", "t": "ajibawa-2023/Python-Code-Large/train/row_98868:Assign_L95_C28"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98868:If_L94_C24", "t": "ajibawa-2023/Python-Code-Large/train/row_98868:If_L96_C24"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98868:If_L96_C24", "t": "ajibawa-2023/Python-Code-Large/train/row_98868:Assign_L97_C28"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98868:For_L54_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98868:If_L103_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98868:For_L54_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98868:If_L108_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98868:If_L108_C16", "t": "ajibawa-2023/Python-Code-Large/train/row_98868:Assign_L109_C20"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98868:If_L108_C16", "t": "ajibawa-2023/Python-Code-Large/train/row_98868:If_L110_C20"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98868:If_L110_C20", "t": "ajibawa-2023/Python-Code-Large/train/row_98868:Assign_L111_C24"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98868:For_L54_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98868:Assign_L113_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98868:For_L54_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98868:If_L114_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98868:If_L114_C16", "t": "ajibawa-2023/Python-Code-Large/train/row_98868:If_L115_C20"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98868:For_L54_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98868:If_L119_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98868:For_L54_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98868:Expr_L121_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98868:For_L44_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98868:For_L122_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98868:For_L122_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98868:Expr_L123_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98868:ClassDef_L7_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98868:FunctionDef_L125_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98868:FunctionDef_L125_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98868:Expr_L126_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98868:FunctionDef_L125_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98868:Assign_L131_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98868:FunctionDef_L125_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98868:Assign_L132_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98868:FunctionDef_L125_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98868:Try_L134_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98868:Try_L134_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98868:Assign_L135_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98868:Try_L134_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98868:Assign_L137_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98868:Try_L134_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98868:Expr_L138_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98868:FunctionDef_L125_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98868:If_L142_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98868:If_L142_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98868:Assign_L143_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98868:If_L142_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98868:Expr_L144_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98868:FunctionDef_L125_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98868:If_L147_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98868:If_L147_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98868:Assign_L148_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98868:FunctionDef_L125_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98868:If_L150_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98868:If_L150_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98868:Assign_L151_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98868:If_L150_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98868:Assign_L152_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98868:FunctionDef_L125_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98868:Return_L154_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98868:ClassDef_L7_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98868:FunctionDef_L156_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98868:FunctionDef_L156_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98868:Expr_L157_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98868:FunctionDef_L156_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98868:Return_L162_C8"}]
from optparse import make_option from django.core.management.base import AppCommand from django.core.management.sql import sql_reset from django.db import connections, DEFAULT_DB_ALIAS class Command(AppCommand): help = "Prints the DROP TABLE SQL, then the CREATE TABLE SQL, for the given app name(s)." option_list = AppCommand.option_list + ( make_option('--database', action='store', dest='database', default=DEFAULT_DB_ALIAS, help='Nominates a database to print the ' 'SQL for. Defaults to the "default" database.'), ) output_transaction = True def handle_app(self, app, **options): return u'\n'.join(sql_reset(app, self.style, connections[options.get('database', DEFAULT_DB_ALIAS)])).encode('utf-8')
ajibawa-2023/Python-Code-Large/train/row_98870
10
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_98870:ImportFrom_L1_C0", "label": "from optparse import make_option", "type": "import", "loc": [1, 1], "level": 0, "parent": null, "vector": [1, 0, 0.05, 0.05, 0, 0.66, 0.0, 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_98870:ImportFrom_L3_C0", "label": "from django.core.management.base import AppCommand", "type": "import", "loc": [3, 3], "level": 0, "parent": null, "vector": [1, 0, 0.15, 0.05, 0, 0.66, 0.25, 931, 0, 1, 0, 0, 931, 0, 0], "semantic": {"name": "django.core.management.base", "arg_names": [], "import_names": ["AppCommand"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.core.management.base import AppCommand"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98870:ImportFrom_L4_C0", "label": "from django.core.management.sql import sql_reset", "type": "import", "loc": [4, 4], "level": 0, "parent": null, "vector": [1, 0, 0.2, 0.05, 0, 0.66, 0.5, 576, 0, 1, 0, 0, 576, 0, 0], "semantic": {"name": "django.core.management.sql", "arg_names": [], "import_names": ["sql_reset"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.core.management.sql import sql_reset"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98870:ImportFrom_L5_C0", "label": "from django.db import connections, DEFAULT_DB_ALIAS", "type": "import", "loc": [5, 5], "level": 0, "parent": null, "vector": [1, 0, 0.25, 0.05, 0, 0.66, 0.75, 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_98870:ClassDef_L7_C0", "label": "Command", "type": "class", "loc": [7, 20], "level": 0, "parent": null, "vector": [3, 0, 0.675, 0.7, 0, 0.66, 1.0, 73, 0, 1, 0, 0, 369, 0, 5], "semantic": {"name": "Command", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class Command(AppCommand):\n help = \"Prints the DROP TABLE SQL, then the CREATE TABLE SQL, for the given app name(s).\"\n\n option_list = AppCommand.option_list + (\n make_option('--database', action='store', dest='database',\n default=DEFAULT_DB_ALIAS, help='Nominates a database to print the '\n 'SQL for. Defaults to the \"default\" database.'),\n"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98870:Assign_L8_C4", "label": "help =", "type": "assigned_variable", "loc": [8, 8], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98870:ClassDef_L7_C0", "vector": [14, 1, 0.4, 0.05, 1, 0.21, 0.0, 868, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "help", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " help = \"Prints the DROP TABLE SQL, then the CREATE TABLE SQL, for the given app name(s).\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98870:Assign_L10_C4", "label": "option_list =", "type": "assigned_variable", "loc": [10, 15], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98870:ClassDef_L7_C0", "vector": [14, 1, 0.625, 0.3, 1, 0.21, 0.3333, 318, 4, 0, 0, 0, 0, 0, 1], "semantic": {"name": "option_list", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " option_list = AppCommand.option_list + (\n make_option('--database', action='store', dest='database',\n default=DEFAULT_DB_ALIAS, help='Nominates a database to print the '\n 'SQL for. Defaults to the \"default\" database.'),\n\n )"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98870:Assign_L17_C4", "label": "output_transaction =", "type": "assigned_variable", "loc": [17, 17], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98870:ClassDef_L7_C0", "vector": [14, 1, 0.85, 0.05, 1, 0.21, 0.6667, 987, 1, 0, 0, 0, 0, 4, 0], "semantic": {"name": "output_transaction", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " output_transaction = True"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98870:FunctionDef_L19_C4", "label": "handle_app", "type": "function", "loc": [19, 20], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98870:ClassDef_L7_C0", "vector": [2, 1, 0.975, 0.1, 1, 0.21, 1.0, 665, 0, 3, 1, 0, 0, 0, 4], "semantic": {"name": "handle_app", "arg_names": ["self", "app", "options"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def handle_app(self, app, **options):\n return u'\\n'.join(sql_reset(app, self.style, connections[options.get('database', DEFAULT_DB_ALIAS)])).encode('utf-8')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98870:Return_L20_C8", "label": "return", "type": "return", "loc": [20, 20], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98870:FunctionDef_L19_C4", "vector": [13, 2, 1.0, 0.05, 2, 0.03, 0.0, 0, 3, 0, 0, 0, 0, 10, 4], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return u'\\n'.join(sql_reset(app, self.style, connections[options.get('database', DEFAULT_DB_ALIAS)])).encode('utf-8')"}]
[{"f": "ajibawa-2023/Python-Code-Large/train/row_98870:ClassDef_L7_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98870:Assign_L8_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98870:ClassDef_L7_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98870:Assign_L10_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98870:ClassDef_L7_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98870:Assign_L17_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98870:ClassDef_L7_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98870:FunctionDef_L19_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98870:FunctionDef_L19_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98870:Return_L20_C8"}]
from optparse import make_option from django.core.management.base import BaseCommand, CommandError from django.db import connections, DEFAULT_DB_ALIAS class Command(BaseCommand): help = ("Runs the command-line client for specified database, or the " "default database if none is provided.") option_list = BaseCommand.option_list + ( make_option('--database', action='store', dest='database', default=DEFAULT_DB_ALIAS, help='Nominates a database onto which to ' 'open a shell. Defaults to the "default" database.'), ) requires_model_validation = False def handle(self, **options): connection = connections[options.get('database', DEFAULT_DB_ALIAS)] try: connection.client.runshell() except OSError: # Note that we're assuming OSError means that the client program # isn't installed. There's a possibility OSError would be raised # for some other reason, in which case this error message would be # inaccurate. Still, this message catches the common case. raise CommandError('You appear not to have the %r program installed or on your path.' % \ connection.client.executable_name)
ajibawa-2023/Python-Code-Large/train/row_98871
11
28
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_98871:ImportFrom_L1_C0", "label": "from optparse import make_option", "type": "import", "loc": [1, 1], "level": 0, "parent": null, "vector": [1, 0, 0.0357, 0.0357, 0, 0.66, 0.0, 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_98871:ImportFrom_L3_C0", "label": "from django.core.management.base import BaseCommand, CommandError", "type": "import", "loc": [3, 3], "level": 0, "parent": null, "vector": [1, 0, 0.1071, 0.0357, 0, 0.66, 0.3333, 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_98871:ImportFrom_L4_C0", "label": "from django.db import connections, DEFAULT_DB_ALIAS", "type": "import", "loc": [4, 4], "level": 0, "parent": null, "vector": [1, 0, 0.1429, 0.0357, 0, 0.66, 0.6667, 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_98871:ClassDef_L6_C0", "label": "Command", "type": "class", "loc": [6, 28], "level": 0, "parent": null, "vector": [3, 0, 0.6071, 0.8214, 0, 0.66, 1.0, 73, 0, 1, 0, 0, 564, 0, 4], "semantic": {"name": "Command", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class Command(BaseCommand):\n help = (\"Runs the command-line client for specified database, or the \"\n \"default database if none is provided.\")\n\n option_list = BaseCommand.option_list + (\n make_option('--database', action='store', dest='database',\n default=DEFAULT_DB_ALIAS, help='Nominates a database onto which to '\n 'open a shell. Defaults to the \"default\" database.'),"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98871:Assign_L7_C4", "label": "help =", "type": "assigned_variable", "loc": [7, 8], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98871:ClassDef_L6_C0", "vector": [14, 1, 0.2679, 0.0714, 1, 0.46, 0.0, 868, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "help", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " help = (\"Runs the command-line client for specified database, or the \"\n \"default database if none is provided.\")"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98871:Assign_L10_C4", "label": "option_list =", "type": "assigned_variable", "loc": [10, 14], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98871:ClassDef_L6_C0", "vector": [14, 1, 0.4286, 0.1786, 1, 0.46, 0.3333, 318, 4, 0, 0, 0, 0, 0, 1], "semantic": {"name": "option_list", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " option_list = BaseCommand.option_list + (\n make_option('--database', action='store', dest='database',\n default=DEFAULT_DB_ALIAS, help='Nominates a database onto which to '\n 'open a shell. Defaults to the \"default\" database.'),\n )"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98871:Assign_L16_C4", "label": "requires_model_validation =", "type": "assigned_variable", "loc": [16, 16], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98871:ClassDef_L6_C0", "vector": [14, 1, 0.5714, 0.0357, 1, 0.46, 0.6667, 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_98871:FunctionDef_L18_C4", "label": "handle", "type": "function", "loc": [18, 28], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98871:ClassDef_L6_C0", "vector": [2, 1, 0.8214, 0.3929, 1, 0.46, 1.0, 346, 0, 2, 0, 0, 0, 0, 3], "semantic": {"name": "handle", "arg_names": ["self", "options"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def handle(self, **options):\n connection = connections[options.get('database', DEFAULT_DB_ALIAS)]\n try:\n connection.client.runshell()\n except OSError:\n # Note that we're assuming OSError means that the client program\n # isn't installed. There's a possibility OSError would be raised\n # for some other reason, in which case this error message would be"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98871:Assign_L19_C8", "label": "connection =", "type": "assigned_variable", "loc": [19, 19], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98871:FunctionDef_L18_C4", "vector": [14, 2, 0.6786, 0.0357, 2, 0.02, 0.0, 351, 6, 0, 0, 0, 0, 0, 1], "semantic": {"name": "connection", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " connection = connections[options.get('database', DEFAULT_DB_ALIAS)]"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98871:Try_L20_C8", "label": "try", "type": "try", "loc": [20, 28], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98871:FunctionDef_L18_C4", "vector": [7, 2, 0.8571, 0.3214, 2, 0.02, 1.0, 0, 0, 1, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " try:\n connection.client.runshell()\n except OSError:\n # Note that we're assuming OSError means that the client program\n # isn't installed. There's a possibility OSError would be raised\n # for some other reason, in which case this error message would be\n # inaccurate. Still, this message catches the common case.\n raise CommandError('You appear not to have the %r program installed or on your path.' % \\"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98871:Expr_L21_C12", "label": "runshell()", "type": "expression", "loc": [21, 21], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98871:Try_L20_C8", "vector": [8, 3, 0.75, 0.0357, 3, 0.37, 0.0, 795, 3, 0, 0, 0, 0, 0, 1], "semantic": {"name": "runshell", "arg_names": [], "import_names": [], "rhs_call_name": "runshell", "annotation": ""}, "snippet": " connection.client.runshell()"}]
[{"f": "ajibawa-2023/Python-Code-Large/train/row_98871:ClassDef_L6_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98871:Assign_L7_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98871:ClassDef_L6_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98871:Assign_L10_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98871:ClassDef_L6_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98871:Assign_L16_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98871:ClassDef_L6_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98871:FunctionDef_L18_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98871:FunctionDef_L18_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98871:Assign_L19_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98871:FunctionDef_L18_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98871:Try_L20_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98871:Try_L20_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98871:Expr_L21_C12"}]
from django.core.management.base import NoArgsCommand class Command(NoArgsCommand): help = "Validates all installed models." requires_model_validation = False def handle_noargs(self, **options): self.validate(display_num_errors=True)
ajibawa-2023/Python-Code-Large/train/row_98872
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_98872:ImportFrom_L1_C0", "label": "from django.core.management.base import NoArgsCommand", "type": "import", "loc": [1, 1], "level": 0, "parent": null, "vector": [1, 0, 0.1111, 0.1111, 0, 0.66, 0.0, 931, 0, 1, 0, 0, 931, 0, 0], "semantic": {"name": "django.core.management.base", "arg_names": [], "import_names": ["NoArgsCommand"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.core.management.base import NoArgsCommand"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98872:ClassDef_L3_C0", "label": "Command", "type": "class", "loc": [3, 9], "level": 0, "parent": null, "vector": [3, 0, 0.6667, 0.7778, 0, 0.66, 1.0, 73, 0, 1, 0, 0, 795, 0, 1], "semantic": {"name": "Command", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class Command(NoArgsCommand):\n help = \"Validates all installed models.\"\n\n requires_model_validation = False\n\n def handle_noargs(self, **options):\n self.validate(display_num_errors=True)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98872:Assign_L4_C4", "label": "help =", "type": "assigned_variable", "loc": [4, 4], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98872:ClassDef_L3_C0", "vector": [14, 1, 0.4444, 0.1111, 1, 0.24, 0.0, 868, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "help", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " help = \"Validates all installed models.\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98872:Assign_L6_C4", "label": "requires_model_validation =", "type": "assigned_variable", "loc": [6, 6], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98872:ClassDef_L3_C0", "vector": [14, 1, 0.6667, 0.1111, 1, 0.24, 0.5, 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_98872:FunctionDef_L8_C4", "label": "handle_noargs", "type": "function", "loc": [8, 9], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98872:ClassDef_L3_C0", "vector": [2, 1, 0.9444, 0.2222, 1, 0.24, 1.0, 28, 0, 2, 0, 0, 0, 0, 1], "semantic": {"name": "handle_noargs", "arg_names": ["self", "options"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def handle_noargs(self, **options):\n self.validate(display_num_errors=True)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98872:Expr_L9_C8", "label": "validate()", "type": "expression", "loc": [9, 9], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98872:FunctionDef_L8_C4", "vector": [8, 2, 1.0, 0.1111, 2, 0.7, 0.0, 628, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "validate", "arg_names": [], "import_names": [], "rhs_call_name": "validate", "annotation": ""}, "snippet": " self.validate(display_num_errors=True)"}]
[{"f": "ajibawa-2023/Python-Code-Large/train/row_98872:ClassDef_L3_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98872:Assign_L4_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98872:ClassDef_L3_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98872:Assign_L6_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98872:ClassDef_L3_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98872:FunctionDef_L8_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98872:FunctionDef_L8_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98872:Expr_L9_C8"}]
from django.core.management.base import BaseCommand class Command(BaseCommand): help = "Runs this project as a FastCGI application. Requires flup." args = '[various KEY=val options, use `runfcgi help` for help]' def handle(self, *args, **options): from django.conf import settings from django.utils import translation # Activate the current language, because it won't get activated later. try: translation.activate(settings.LANGUAGE_CODE) except AttributeError: pass from django.core.servers.fastcgi import runfastcgi runfastcgi(args) def usage(self, subcommand): from django.core.servers.fastcgi import FASTCGI_HELP return FASTCGI_HELP
ajibawa-2023/Python-Code-Large/train/row_98873
14
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_98873:ImportFrom_L1_C0", "label": "from django.core.management.base import BaseCommand", "type": "import", "loc": [1, 1], "level": 0, "parent": null, "vector": [1, 0, 0.05, 0.05, 0, 0.66, 0.0, 931, 0, 1, 0, 0, 931, 0, 0], "semantic": {"name": "django.core.management.base", "arg_names": [], "import_names": ["BaseCommand"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.core.management.base import BaseCommand"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98873:ClassDef_L3_C0", "label": "Command", "type": "class", "loc": [3, 20], "level": 0, "parent": null, "vector": [3, 0, 0.575, 0.9, 0, 0.66, 1.0, 73, 0, 2, 0, 0, 564, 0, 2], "semantic": {"name": "Command", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class Command(BaseCommand):\n help = \"Runs this project as a FastCGI application. Requires flup.\"\n args = '[various KEY=val options, use `runfcgi help` for help]'\n\n def handle(self, *args, **options):\n from django.conf import settings\n from django.utils import translation\n # Activate the current language, because it won't get activated later."}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98873:Assign_L4_C4", "label": "help =", "type": "assigned_variable", "loc": [4, 4], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98873:ClassDef_L3_C0", "vector": [14, 1, 0.2, 0.05, 1, 0.25, 0.0, 868, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "help", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " help = \"Runs this project as a FastCGI application. Requires flup.\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98873:Assign_L5_C4", "label": "args =", "type": "assigned_variable", "loc": [5, 5], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98873:ClassDef_L3_C0", "vector": [14, 1, 0.25, 0.05, 1, 0.25, 0.3333, 805, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "args", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " args = '[various KEY=val options, use `runfcgi help` for help]'"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98873:FunctionDef_L7_C4", "label": "handle", "type": "function", "loc": [7, 16], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98873:ClassDef_L3_C0", "vector": [2, 1, 0.575, 0.5, 1, 0.25, 0.6667, 346, 0, 3, 0, 0, 0, 0, 2], "semantic": {"name": "handle", "arg_names": ["self", "args", "options"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def handle(self, *args, **options):\n from django.conf import settings\n from django.utils import translation\n # Activate the current language, because it won't get activated later.\n try:\n translation.activate(settings.LANGUAGE_CODE)\n except AttributeError:\n pass"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98873:ImportFrom_L8_C8", "label": "from django.conf import settings", "type": "import", "loc": [8, 8], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98873:FunctionDef_L7_C4", "vector": [1, 2, 0.4, 0.05, 2, 0.26, 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_98873:ImportFrom_L9_C8", "label": "from django.utils import translation", "type": "import", "loc": [9, 9], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98873:FunctionDef_L7_C4", "vector": [1, 2, 0.45, 0.05, 2, 0.26, 0.25, 944, 0, 1, 0, 0, 944, 0, 0], "semantic": {"name": "django.utils", "arg_names": [], "import_names": ["translation"], "rhs_call_name": "", "annotation": ""}, "snippet": " from django.utils import translation"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98873:Try_L11_C8", "label": "try", "type": "try", "loc": [11, 14], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98873:FunctionDef_L7_C4", "vector": [7, 2, 0.625, 0.2, 2, 0.26, 0.5, 0, 0, 1, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " try:\n translation.activate(settings.LANGUAGE_CODE)\n except AttributeError:\n pass"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98873:Expr_L12_C12", "label": "activate()", "type": "expression", "loc": [12, 12], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98873:Try_L11_C8", "vector": [8, 3, 0.6, 0.05, 3, 0.73, 0.0, 177, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "activate", "arg_names": [], "import_names": [], "rhs_call_name": "activate", "annotation": ""}, "snippet": " translation.activate(settings.LANGUAGE_CODE)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98873:ImportFrom_L15_C8", "label": "from django.core.servers.fastcgi import runfastcgi", "type": "import", "loc": [15, 15], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98873:FunctionDef_L7_C4", "vector": [1, 2, 0.75, 0.05, 2, 0.26, 0.75, 438, 0, 1, 0, 0, 438, 0, 0], "semantic": {"name": "django.core.servers.fastcgi", "arg_names": [], "import_names": ["runfastcgi"], "rhs_call_name": "", "annotation": ""}, "snippet": " from django.core.servers.fastcgi import runfastcgi"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98873:Expr_L16_C8", "label": "runfastcgi()", "type": "expression", "loc": [16, 16], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98873:FunctionDef_L7_C4", "vector": [8, 2, 0.8, 0.05, 2, 0.26, 1.0, 509, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "runfastcgi", "arg_names": [], "import_names": [], "rhs_call_name": "runfastcgi", "annotation": ""}, "snippet": " runfastcgi(args)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98873:FunctionDef_L18_C4", "label": "usage", "type": "function", "loc": [18, 20], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98873:ClassDef_L3_C0", "vector": [2, 1, 0.95, 0.15, 1, 0.25, 1.0, 129, 0, 2, 1, 0, 0, 0, 0], "semantic": {"name": "usage", "arg_names": ["self", "subcommand"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def usage(self, subcommand):\n from django.core.servers.fastcgi import FASTCGI_HELP\n return FASTCGI_HELP"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98873:ImportFrom_L19_C8", "label": "from django.core.servers.fastcgi import FASTCGI_HELP", "type": "import", "loc": [19, 19], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98873:FunctionDef_L18_C4", "vector": [1, 2, 0.95, 0.05, 2, 0.86, 0.0, 438, 0, 1, 0, 0, 438, 0, 0], "semantic": {"name": "django.core.servers.fastcgi", "arg_names": [], "import_names": ["FASTCGI_HELP"], "rhs_call_name": "", "annotation": ""}, "snippet": " from django.core.servers.fastcgi import FASTCGI_HELP"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98873:Return_L20_C8", "label": "return", "type": "return", "loc": [20, 20], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98873:FunctionDef_L18_C4", "vector": [13, 2, 1.0, 0.05, 2, 0.86, 1.0, 0, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return FASTCGI_HELP"}]
[{"f": "ajibawa-2023/Python-Code-Large/train/row_98873:ClassDef_L3_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98873:Assign_L4_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98873:ClassDef_L3_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98873:Assign_L5_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98873:ClassDef_L3_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98873:FunctionDef_L7_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98873:FunctionDef_L7_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98873:ImportFrom_L8_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98873:FunctionDef_L7_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98873:ImportFrom_L9_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98873:FunctionDef_L7_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98873:Try_L11_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98873:Try_L11_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98873:Expr_L12_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98873:FunctionDef_L7_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98873:ImportFrom_L15_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98873:FunctionDef_L7_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98873:Expr_L16_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98873:ClassDef_L3_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98873:FunctionDef_L18_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98873:FunctionDef_L18_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98873:ImportFrom_L19_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98873:FunctionDef_L18_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98873:Return_L20_C8"}]
from optparse import make_option from django.core.management.base import AppCommand from django.core.management.sql import sql_indexes from django.db import connections, DEFAULT_DB_ALIAS class Command(AppCommand): help = "Prints the CREATE INDEX SQL statements for the given model module name(s)." option_list = AppCommand.option_list + ( make_option('--database', action='store', dest='database', default=DEFAULT_DB_ALIAS, help='Nominates a database to print the ' 'SQL for. Defaults to the "default" database.'), ) output_transaction = True def handle_app(self, app, **options): return u'\n'.join(sql_indexes(app, self.style, connections[options.get('database', DEFAULT_DB_ALIAS)])).encode('utf-8')
ajibawa-2023/Python-Code-Large/train/row_98874
10
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_98874:ImportFrom_L1_C0", "label": "from optparse import make_option", "type": "import", "loc": [1, 1], "level": 0, "parent": null, "vector": [1, 0, 0.05, 0.05, 0, 0.66, 0.0, 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_98874:ImportFrom_L3_C0", "label": "from django.core.management.base import AppCommand", "type": "import", "loc": [3, 3], "level": 0, "parent": null, "vector": [1, 0, 0.15, 0.05, 0, 0.66, 0.25, 931, 0, 1, 0, 0, 931, 0, 0], "semantic": {"name": "django.core.management.base", "arg_names": [], "import_names": ["AppCommand"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.core.management.base import AppCommand"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98874:ImportFrom_L4_C0", "label": "from django.core.management.sql import sql_indexes", "type": "import", "loc": [4, 4], "level": 0, "parent": null, "vector": [1, 0, 0.2, 0.05, 0, 0.66, 0.5, 576, 0, 1, 0, 0, 576, 0, 0], "semantic": {"name": "django.core.management.sql", "arg_names": [], "import_names": ["sql_indexes"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.core.management.sql import sql_indexes"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98874:ImportFrom_L5_C0", "label": "from django.db import connections, DEFAULT_DB_ALIAS", "type": "import", "loc": [5, 5], "level": 0, "parent": null, "vector": [1, 0, 0.25, 0.05, 0, 0.66, 0.75, 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_98874:ClassDef_L7_C0", "label": "Command", "type": "class", "loc": [7, 20], "level": 0, "parent": null, "vector": [3, 0, 0.675, 0.7, 0, 0.66, 1.0, 73, 0, 1, 0, 0, 369, 0, 5], "semantic": {"name": "Command", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class Command(AppCommand):\n help = \"Prints the CREATE INDEX SQL statements for the given model module name(s).\"\n\n option_list = AppCommand.option_list + (\n make_option('--database', action='store', dest='database',\n default=DEFAULT_DB_ALIAS, help='Nominates a database to print the '\n 'SQL for. Defaults to the \"default\" database.'),\n"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98874:Assign_L8_C4", "label": "help =", "type": "assigned_variable", "loc": [8, 8], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98874:ClassDef_L7_C0", "vector": [14, 1, 0.4, 0.05, 1, 0.96, 0.0, 868, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "help", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " help = \"Prints the CREATE INDEX SQL statements for the given model module name(s).\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98874:Assign_L10_C4", "label": "option_list =", "type": "assigned_variable", "loc": [10, 15], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98874:ClassDef_L7_C0", "vector": [14, 1, 0.625, 0.3, 1, 0.96, 0.3333, 318, 4, 0, 0, 0, 0, 0, 1], "semantic": {"name": "option_list", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " option_list = AppCommand.option_list + (\n make_option('--database', action='store', dest='database',\n default=DEFAULT_DB_ALIAS, help='Nominates a database to print the '\n 'SQL for. Defaults to the \"default\" database.'),\n\n )"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98874:Assign_L17_C4", "label": "output_transaction =", "type": "assigned_variable", "loc": [17, 17], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98874:ClassDef_L7_C0", "vector": [14, 1, 0.85, 0.05, 1, 0.96, 0.6667, 987, 1, 0, 0, 0, 0, 4, 0], "semantic": {"name": "output_transaction", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " output_transaction = True"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98874:FunctionDef_L19_C4", "label": "handle_app", "type": "function", "loc": [19, 20], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98874:ClassDef_L7_C0", "vector": [2, 1, 0.975, 0.1, 1, 0.96, 1.0, 665, 0, 3, 1, 0, 0, 0, 4], "semantic": {"name": "handle_app", "arg_names": ["self", "app", "options"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def handle_app(self, app, **options):\n return u'\\n'.join(sql_indexes(app, self.style, connections[options.get('database', DEFAULT_DB_ALIAS)])).encode('utf-8')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98874:Return_L20_C8", "label": "return", "type": "return", "loc": [20, 20], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98874:FunctionDef_L19_C4", "vector": [13, 2, 1.0, 0.05, 2, 0.77, 0.0, 0, 3, 0, 0, 0, 0, 10, 4], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return u'\\n'.join(sql_indexes(app, self.style, connections[options.get('database', DEFAULT_DB_ALIAS)])).encode('utf-8')"}]
[{"f": "ajibawa-2023/Python-Code-Large/train/row_98874:ClassDef_L7_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98874:Assign_L8_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98874:ClassDef_L7_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98874:Assign_L10_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98874:ClassDef_L7_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98874:Assign_L17_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98874:ClassDef_L7_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98874:FunctionDef_L19_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98874:FunctionDef_L19_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98874:Return_L20_C8"}]
from optparse import make_option from django.core.management.base import AppCommand from django.core.management.sql import sql_create from django.db import connections, DEFAULT_DB_ALIAS class Command(AppCommand): help = "Prints the CREATE TABLE SQL statements for the given app name(s)." option_list = AppCommand.option_list + ( make_option('--database', action='store', dest='database', default=DEFAULT_DB_ALIAS, help='Nominates a database to print the ' 'SQL for. Defaults to the "default" database.'), ) output_transaction = True def handle_app(self, app, **options): return u'\n'.join(sql_create(app, self.style, connections[options.get('database', DEFAULT_DB_ALIAS)])).encode('utf-8')
ajibawa-2023/Python-Code-Large/train/row_98877
10
19
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_98877:ImportFrom_L1_C0", "label": "from optparse import make_option", "type": "import", "loc": [1, 1], "level": 0, "parent": null, "vector": [1, 0, 0.0526, 0.0526, 0, 0.66, 0.0, 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_98877:ImportFrom_L3_C0", "label": "from django.core.management.base import AppCommand", "type": "import", "loc": [3, 3], "level": 0, "parent": null, "vector": [1, 0, 0.1579, 0.0526, 0, 0.66, 0.25, 931, 0, 1, 0, 0, 931, 0, 0], "semantic": {"name": "django.core.management.base", "arg_names": [], "import_names": ["AppCommand"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.core.management.base import AppCommand"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98877:ImportFrom_L4_C0", "label": "from django.core.management.sql import sql_create", "type": "import", "loc": [4, 4], "level": 0, "parent": null, "vector": [1, 0, 0.2105, 0.0526, 0, 0.66, 0.5, 576, 0, 1, 0, 0, 576, 0, 0], "semantic": {"name": "django.core.management.sql", "arg_names": [], "import_names": ["sql_create"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.core.management.sql import sql_create"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98877:ImportFrom_L5_C0", "label": "from django.db import connections, DEFAULT_DB_ALIAS", "type": "import", "loc": [5, 5], "level": 0, "parent": null, "vector": [1, 0, 0.2632, 0.0526, 0, 0.66, 0.75, 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_98877:ClassDef_L7_C0", "label": "Command", "type": "class", "loc": [7, 19], "level": 0, "parent": null, "vector": [3, 0, 0.6842, 0.6842, 0, 0.66, 1.0, 73, 0, 1, 0, 0, 369, 0, 5], "semantic": {"name": "Command", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class Command(AppCommand):\n help = \"Prints the CREATE TABLE SQL statements for the given app name(s).\"\n\n option_list = AppCommand.option_list + (\n make_option('--database', action='store', dest='database',\n default=DEFAULT_DB_ALIAS, help='Nominates a database to print the '\n 'SQL for. Defaults to the \"default\" database.'),\n )"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98877:Assign_L8_C4", "label": "help =", "type": "assigned_variable", "loc": [8, 8], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98877:ClassDef_L7_C0", "vector": [14, 1, 0.4211, 0.0526, 1, 0.06, 0.0, 868, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "help", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " help = \"Prints the CREATE TABLE SQL statements for the given app name(s).\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98877:Assign_L10_C4", "label": "option_list =", "type": "assigned_variable", "loc": [10, 14], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98877:ClassDef_L7_C0", "vector": [14, 1, 0.6316, 0.2632, 1, 0.06, 0.3333, 318, 4, 0, 0, 0, 0, 0, 1], "semantic": {"name": "option_list", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " option_list = AppCommand.option_list + (\n make_option('--database', action='store', dest='database',\n default=DEFAULT_DB_ALIAS, help='Nominates a database to print the '\n 'SQL for. Defaults to the \"default\" database.'),\n )"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98877:Assign_L16_C4", "label": "output_transaction =", "type": "assigned_variable", "loc": [16, 16], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98877:ClassDef_L7_C0", "vector": [14, 1, 0.8421, 0.0526, 1, 0.06, 0.6667, 987, 1, 0, 0, 0, 0, 4, 0], "semantic": {"name": "output_transaction", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " output_transaction = True"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98877:FunctionDef_L18_C4", "label": "handle_app", "type": "function", "loc": [18, 19], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98877:ClassDef_L7_C0", "vector": [2, 1, 0.9737, 0.1053, 1, 0.06, 1.0, 665, 0, 3, 1, 0, 0, 0, 4], "semantic": {"name": "handle_app", "arg_names": ["self", "app", "options"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def handle_app(self, app, **options):\n return u'\\n'.join(sql_create(app, self.style, connections[options.get('database', DEFAULT_DB_ALIAS)])).encode('utf-8')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98877:Return_L19_C8", "label": "return", "type": "return", "loc": [19, 19], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98877:FunctionDef_L18_C4", "vector": [13, 2, 1.0, 0.0526, 2, 0.14, 0.0, 0, 3, 0, 0, 0, 0, 10, 4], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return u'\\n'.join(sql_create(app, self.style, connections[options.get('database', DEFAULT_DB_ALIAS)])).encode('utf-8')"}]
[{"f": "ajibawa-2023/Python-Code-Large/train/row_98877:ClassDef_L7_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98877:Assign_L8_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98877:ClassDef_L7_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98877:Assign_L10_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98877:ClassDef_L7_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98877:Assign_L16_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98877:ClassDef_L7_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98877:FunctionDef_L18_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98877:FunctionDef_L18_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98877:Return_L19_C8"}]
from optparse import make_option from django.core.management.base import NoArgsCommand from django.core.management.sql import sql_flush from django.db import connections, DEFAULT_DB_ALIAS class Command(NoArgsCommand): help = "Returns a list of the SQL statements required to return all tables in the database to the state they were in just after they were installed." option_list = NoArgsCommand.option_list + ( make_option('--database', action='store', dest='database', default=DEFAULT_DB_ALIAS, help='Nominates a database to print the ' 'SQL for. Defaults to the "default" database.'), ) output_transaction = True def handle_noargs(self, **options): return u'\n'.join(sql_flush(self.style, connections[options.get('database', DEFAULT_DB_ALIAS)], only_django=True)).encode('utf-8')
ajibawa-2023/Python-Code-Large/train/row_98878
10
19
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_98878:ImportFrom_L1_C0", "label": "from optparse import make_option", "type": "import", "loc": [1, 1], "level": 0, "parent": null, "vector": [1, 0, 0.0526, 0.0526, 0, 0.66, 0.0, 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_98878:ImportFrom_L3_C0", "label": "from django.core.management.base import NoArgsCommand", "type": "import", "loc": [3, 3], "level": 0, "parent": null, "vector": [1, 0, 0.1579, 0.0526, 0, 0.66, 0.25, 931, 0, 1, 0, 0, 931, 0, 0], "semantic": {"name": "django.core.management.base", "arg_names": [], "import_names": ["NoArgsCommand"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.core.management.base import NoArgsCommand"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98878:ImportFrom_L4_C0", "label": "from django.core.management.sql import sql_flush", "type": "import", "loc": [4, 4], "level": 0, "parent": null, "vector": [1, 0, 0.2105, 0.0526, 0, 0.66, 0.5, 576, 0, 1, 0, 0, 576, 0, 0], "semantic": {"name": "django.core.management.sql", "arg_names": [], "import_names": ["sql_flush"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.core.management.sql import sql_flush"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98878:ImportFrom_L5_C0", "label": "from django.db import connections, DEFAULT_DB_ALIAS", "type": "import", "loc": [5, 5], "level": 0, "parent": null, "vector": [1, 0, 0.2632, 0.0526, 0, 0.66, 0.75, 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_98878:ClassDef_L7_C0", "label": "Command", "type": "class", "loc": [7, 19], "level": 0, "parent": null, "vector": [3, 0, 0.6842, 0.6842, 0, 0.66, 1.0, 73, 0, 1, 0, 0, 795, 0, 5], "semantic": {"name": "Command", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class Command(NoArgsCommand):\n help = \"Returns a list of the SQL statements required to return all tables in the database to the state they were in just after they were installed.\"\n\n option_list = NoArgsCommand.option_list + (\n make_option('--database', action='store', dest='database',\n default=DEFAULT_DB_ALIAS, help='Nominates a database to print the '\n 'SQL for. Defaults to the \"default\" database.'),\n )"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98878:Assign_L8_C4", "label": "help =", "type": "assigned_variable", "loc": [8, 8], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98878:ClassDef_L7_C0", "vector": [14, 1, 0.4211, 0.0526, 1, 0.38, 0.0, 868, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "help", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " help = \"Returns a list of the SQL statements required to return all tables in the database to the state they were in just after they were installed.\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98878:Assign_L10_C4", "label": "option_list =", "type": "assigned_variable", "loc": [10, 14], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98878:ClassDef_L7_C0", "vector": [14, 1, 0.6316, 0.2632, 1, 0.38, 0.3333, 318, 4, 0, 0, 0, 0, 0, 1], "semantic": {"name": "option_list", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " option_list = NoArgsCommand.option_list + (\n make_option('--database', action='store', dest='database',\n default=DEFAULT_DB_ALIAS, help='Nominates a database to print the '\n 'SQL for. Defaults to the \"default\" database.'),\n )"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98878:Assign_L16_C4", "label": "output_transaction =", "type": "assigned_variable", "loc": [16, 16], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98878:ClassDef_L7_C0", "vector": [14, 1, 0.8421, 0.0526, 1, 0.38, 0.6667, 987, 1, 0, 0, 0, 0, 4, 0], "semantic": {"name": "output_transaction", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " output_transaction = True"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98878:FunctionDef_L18_C4", "label": "handle_noargs", "type": "function", "loc": [18, 19], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98878:ClassDef_L7_C0", "vector": [2, 1, 0.9737, 0.1053, 1, 0.38, 1.0, 28, 0, 2, 1, 0, 0, 0, 4], "semantic": {"name": "handle_noargs", "arg_names": ["self", "options"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def handle_noargs(self, **options):\n return u'\\n'.join(sql_flush(self.style, connections[options.get('database', DEFAULT_DB_ALIAS)], only_django=True)).encode('utf-8')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98878:Return_L19_C8", "label": "return", "type": "return", "loc": [19, 19], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98878:FunctionDef_L18_C4", "vector": [13, 2, 1.0, 0.0526, 2, 0.43, 0.0, 0, 3, 0, 0, 0, 0, 10, 4], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return u'\\n'.join(sql_flush(self.style, connections[options.get('database', DEFAULT_DB_ALIAS)], only_django=True)).encode('utf-8')"}]
[{"f": "ajibawa-2023/Python-Code-Large/train/row_98878:ClassDef_L7_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98878:Assign_L8_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98878:ClassDef_L7_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98878:Assign_L10_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98878:ClassDef_L7_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98878:Assign_L16_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98878:ClassDef_L7_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98878:FunctionDef_L18_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98878:FunctionDef_L18_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98878:Return_L19_C8"}]
from optparse import make_option from django.core.management.base import AppCommand from django.db import connections, models, DEFAULT_DB_ALIAS class Command(AppCommand): help = 'Prints the SQL statements for resetting sequences for the given app name(s).' option_list = AppCommand.option_list + ( make_option('--database', action='store', dest='database', default=DEFAULT_DB_ALIAS, help='Nominates a database to print the ' 'SQL for. Defaults to the "default" database.'), ) output_transaction = True def handle_app(self, app, **options): connection = connections[options.get('database', DEFAULT_DB_ALIAS)] return u'\n'.join(connection.ops.sequence_reset_sql(self.style, models.get_models(app, include_auto_created=True))).encode('utf-8')
ajibawa-2023/Python-Code-Large/train/row_98879
10
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_98879:ImportFrom_L1_C0", "label": "from optparse import make_option", "type": "import", "loc": [1, 1], "level": 0, "parent": null, "vector": [1, 0, 0.05, 0.05, 0, 0.66, 0.0, 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_98879:ImportFrom_L3_C0", "label": "from django.core.management.base import AppCommand", "type": "import", "loc": [3, 3], "level": 0, "parent": null, "vector": [1, 0, 0.15, 0.05, 0, 0.66, 0.3333, 931, 0, 1, 0, 0, 931, 0, 0], "semantic": {"name": "django.core.management.base", "arg_names": [], "import_names": ["AppCommand"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.core.management.base import AppCommand"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98879:ImportFrom_L4_C0", "label": "from django.db import connections, models, DEFAULT_DB_ALIAS", "type": "import", "loc": [4, 4], "level": 0, "parent": null, "vector": [1, 0, 0.2, 0.05, 0, 0.66, 0.6667, 40, 0, 3, 0, 0, 40, 0, 0], "semantic": {"name": "django.db", "arg_names": [], "import_names": ["connections", "models", "DEFAULT_DB_ALIAS"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.db import connections, models, DEFAULT_DB_ALIAS"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98879:ClassDef_L6_C0", "label": "Command", "type": "class", "loc": [6, 20], "level": 0, "parent": null, "vector": [3, 0, 0.65, 0.75, 0, 0.66, 1.0, 73, 0, 1, 0, 0, 369, 0, 6], "semantic": {"name": "Command", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class Command(AppCommand):\n help = 'Prints the SQL statements for resetting sequences for the given app name(s).'\n\n option_list = AppCommand.option_list + (\n make_option('--database', action='store', dest='database',\n default=DEFAULT_DB_ALIAS, help='Nominates a database to print the '\n 'SQL for. Defaults to the \"default\" database.'),\n"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98879:Assign_L7_C4", "label": "help =", "type": "assigned_variable", "loc": [7, 7], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98879:ClassDef_L6_C0", "vector": [14, 1, 0.35, 0.05, 1, 0.0, 0.0, 868, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "help", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " help = 'Prints the SQL statements for resetting sequences for the given app name(s).'"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98879:Assign_L9_C4", "label": "option_list =", "type": "assigned_variable", "loc": [9, 14], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98879:ClassDef_L6_C0", "vector": [14, 1, 0.575, 0.3, 1, 0.0, 0.3333, 318, 4, 0, 0, 0, 0, 0, 1], "semantic": {"name": "option_list", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " option_list = AppCommand.option_list + (\n make_option('--database', action='store', dest='database',\n default=DEFAULT_DB_ALIAS, help='Nominates a database to print the '\n 'SQL for. Defaults to the \"default\" database.'),\n\n )"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98879:Assign_L16_C4", "label": "output_transaction =", "type": "assigned_variable", "loc": [16, 16], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98879:ClassDef_L6_C0", "vector": [14, 1, 0.8, 0.05, 1, 0.0, 0.6667, 987, 1, 0, 0, 0, 0, 4, 0], "semantic": {"name": "output_transaction", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " output_transaction = True"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98879:FunctionDef_L18_C4", "label": "handle_app", "type": "function", "loc": [18, 20], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98879:ClassDef_L6_C0", "vector": [2, 1, 0.95, 0.15, 1, 0.0, 1.0, 665, 0, 3, 1, 0, 0, 0, 5], "semantic": {"name": "handle_app", "arg_names": ["self", "app", "options"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def handle_app(self, app, **options):\n connection = connections[options.get('database', DEFAULT_DB_ALIAS)]\n return u'\\n'.join(connection.ops.sequence_reset_sql(self.style, models.get_models(app, include_auto_created=True))).encode('utf-8')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98879:Assign_L19_C8", "label": "connection =", "type": "assigned_variable", "loc": [19, 19], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98879:FunctionDef_L18_C4", "vector": [14, 2, 0.95, 0.05, 2, 0.19, 0.0, 351, 6, 0, 0, 0, 0, 0, 1], "semantic": {"name": "connection", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " connection = connections[options.get('database', DEFAULT_DB_ALIAS)]"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98879:Return_L20_C8", "label": "return", "type": "return", "loc": [20, 20], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98879:FunctionDef_L18_C4", "vector": [13, 2, 1.0, 0.05, 2, 0.19, 1.0, 0, 3, 0, 0, 0, 0, 10, 4], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return u'\\n'.join(connection.ops.sequence_reset_sql(self.style, models.get_models(app, include_auto_created=True))).encode('utf-8')"}]
[{"f": "ajibawa-2023/Python-Code-Large/train/row_98879:ClassDef_L6_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98879:Assign_L7_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98879:ClassDef_L6_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98879:Assign_L9_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98879:ClassDef_L6_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98879:Assign_L16_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98879:ClassDef_L6_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98879:FunctionDef_L18_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98879:FunctionDef_L18_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98879:Assign_L19_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98879:FunctionDef_L18_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98879:Return_L20_C8"}]
from django.core.management.base import BaseCommand from optparse import make_option import sys class Command(BaseCommand): option_list = BaseCommand.option_list + ( make_option('--noinput', action='store_false', dest='interactive', default=True, help='Tells Django to NOT prompt the user for input of any kind.'), make_option('--failfast', action='store_true', dest='failfast', default=False, help='Tells Django to stop running the test suite after first failed test.') ) help = 'Runs the test suite for the specified applications, or the entire site if no apps are specified.' args = '[appname ...]' requires_model_validation = False def handle(self, *test_labels, **options): from django.conf import settings from django.test.utils import get_runner verbosity = int(options.get('verbosity', 1)) interactive = options.get('interactive', True) failfast = options.get('failfast', False) TestRunner = get_runner(settings) if hasattr(TestRunner, 'func_name'): # Pre 1.2 test runners were just functions, # and did not support the 'failfast' option. import warnings warnings.warn( 'Function-based test runners are deprecated. Test runners should be classes with a run_tests() method.', DeprecationWarning ) failures = TestRunner(test_labels, verbosity=verbosity, interactive=interactive) else: test_runner = TestRunner(verbosity=verbosity, interactive=interactive, failfast=failfast) failures = test_runner.run_tests(test_labels) if failures: sys.exit(bool(failures))
ajibawa-2023/Python-Code-Large/train/row_98880
23
40
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_98880:ImportFrom_L1_C0", "label": "from django.core.management.base import BaseCommand", "type": "import", "loc": [1, 1], "level": 0, "parent": null, "vector": [1, 0, 0.025, 0.025, 0, 0.66, 0.0, 931, 0, 1, 0, 0, 931, 0, 0], "semantic": {"name": "django.core.management.base", "arg_names": [], "import_names": ["BaseCommand"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.core.management.base import BaseCommand"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98880:ImportFrom_L2_C0", "label": "from optparse import make_option", "type": "import", "loc": [2, 2], "level": 0, "parent": null, "vector": [1, 0, 0.05, 0.025, 0, 0.66, 0.3333, 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_98880:Import_L3_C0", "label": "sys import sys", "type": "import", "loc": [3, 3], "level": 0, "parent": null, "vector": [1, 0, 0.075, 0.025, 0, 0.66, 0.6667, 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_98880:ClassDef_L5_C0", "label": "Command", "type": "class", "loc": [5, 40], "level": 0, "parent": null, "vector": [3, 0, 0.5625, 0.9, 0, 0.66, 1.0, 73, 0, 1, 0, 0, 564, 0, 14], "semantic": {"name": "Command", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class Command(BaseCommand):\n option_list = BaseCommand.option_list + (\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 make_option('--failfast', action='store_true', dest='failfast', default=False,\n help='Tells Django to stop running the test suite after first failed test.')\n )\n help = 'Runs the test suite for the specified applications, or the entire site if no apps are specified.'"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98880:Assign_L6_C4", "label": "option_list =", "type": "assigned_variable", "loc": [6, 11], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98880:ClassDef_L5_C0", "vector": [14, 1, 0.2125, 0.15, 1, 0.46, 0.0, 318, 4, 0, 0, 0, 0, 0, 2], "semantic": {"name": "option_list", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " option_list = BaseCommand.option_list + (\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 make_option('--failfast', action='store_true', dest='failfast', default=False,\n help='Tells Django to stop running the test suite after first failed test.')\n )"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98880:Assign_L12_C4", "label": "help =", "type": "assigned_variable", "loc": [12, 12], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98880:ClassDef_L5_C0", "vector": [14, 1, 0.3, 0.025, 1, 0.46, 0.25, 868, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "help", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " help = 'Runs the test suite for the specified applications, or the entire site if no apps are specified.'"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98880:Assign_L13_C4", "label": "args =", "type": "assigned_variable", "loc": [13, 13], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98880:ClassDef_L5_C0", "vector": [14, 1, 0.325, 0.025, 1, 0.46, 0.5, 805, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "args", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " args = '[appname ...]'"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98880:Assign_L15_C4", "label": "requires_model_validation =", "type": "assigned_variable", "loc": [15, 15], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98880:ClassDef_L5_C0", "vector": [14, 1, 0.375, 0.025, 1, 0.46, 0.75, 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_98880:FunctionDef_L17_C4", "label": "handle", "type": "function", "loc": [17, 40], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98880:ClassDef_L5_C0", "vector": [2, 1, 0.7125, 0.6, 1, 0.46, 1.0, 346, 0, 3, 0, 0, 0, 0, 12], "semantic": {"name": "handle", "arg_names": ["self", "test_labels", "options"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def handle(self, *test_labels, **options):\n from django.conf import settings\n from django.test.utils import get_runner\n\n verbosity = int(options.get('verbosity', 1))\n interactive = options.get('interactive', True)\n failfast = options.get('failfast', False)\n TestRunner = get_runner(settings)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98880:ImportFrom_L18_C8", "label": "from django.conf import settings", "type": "import", "loc": [18, 18], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98880:FunctionDef_L17_C4", "vector": [1, 2, 0.45, 0.025, 2, 0.74, 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_98880:ImportFrom_L19_C8", "label": "from django.test.utils import get_runner", "type": "import", "loc": [19, 19], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98880:FunctionDef_L17_C4", "vector": [1, 2, 0.475, 0.025, 2, 0.74, 0.1429, 768, 0, 1, 0, 0, 768, 0, 0], "semantic": {"name": "django.test.utils", "arg_names": [], "import_names": ["get_runner"], "rhs_call_name": "", "annotation": ""}, "snippet": " from django.test.utils import get_runner"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98880:Assign_L21_C8", "label": "verbosity = int()", "type": "assigned_variable", "loc": [21, 21], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98880:FunctionDef_L17_C4", "vector": [14, 2, 0.525, 0.025, 2, 0.74, 0.2857, 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_98880:Assign_L22_C8", "label": "interactive = get()", "type": "assigned_variable", "loc": [22, 22], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98880:FunctionDef_L17_C4", "vector": [14, 2, 0.55, 0.025, 2, 0.74, 0.4286, 348, 3, 2, 0, 0, 607, 10, 1], "semantic": {"name": "interactive", "arg_names": [], "import_names": [], "rhs_call_name": "get", "annotation": ""}, "snippet": " interactive = options.get('interactive', True)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98880:Assign_L23_C8", "label": "failfast = get()", "type": "assigned_variable", "loc": [23, 23], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98880:FunctionDef_L17_C4", "vector": [14, 2, 0.575, 0.025, 2, 0.74, 0.5714, 443, 3, 2, 0, 0, 607, 10, 1], "semantic": {"name": "failfast", "arg_names": [], "import_names": [], "rhs_call_name": "get", "annotation": ""}, "snippet": " failfast = options.get('failfast', False)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98880:Assign_L24_C8", "label": "TestRunner = get_runner()", "type": "assigned_variable", "loc": [24, 24], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98880:FunctionDef_L17_C4", "vector": [14, 2, 0.6, 0.025, 2, 0.74, 0.7143, 509, 3, 1, 0, 0, 122, 10, 1], "semantic": {"name": "TestRunner", "arg_names": [], "import_names": [], "rhs_call_name": "get_runner", "annotation": ""}, "snippet": " TestRunner = get_runner(settings)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98880:If_L26_C8", "label": "if", "type": "if", "loc": [26, 37], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98880:FunctionDef_L17_C4", "vector": [4, 2, 0.7875, 0.3, 2, 0.74, 0.8571, 0, 3, 0, 0, 0, 0, 0, 5], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if hasattr(TestRunner, 'func_name'):\n # Pre 1.2 test runners were just functions,\n # and did not support the 'failfast' option.\n import warnings\n warnings.warn(\n 'Function-based test runners are deprecated. Test runners should be classes with a run_tests() method.',\n DeprecationWarning\n )"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98880:Import_L29_C12", "label": "warnings import warnings", "type": "import", "loc": [29, 29], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98880:If_L26_C8", "vector": [1, 3, 0.725, 0.025, 3, 0.68, 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_98880:Expr_L30_C12", "label": "warn()", "type": "expression", "loc": [30, 33], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98880:If_L26_C8", "vector": [8, 3, 0.7875, 0.1, 3, 0.68, 0.25, 960, 3, 2, 0, 0, 0, 0, 1], "semantic": {"name": "warn", "arg_names": [], "import_names": [], "rhs_call_name": "warn", "annotation": ""}, "snippet": " warnings.warn(\n 'Function-based test runners are deprecated. Test runners should be classes with a run_tests() method.',\n DeprecationWarning\n )"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98880:Assign_L34_C12", "label": "failures = TestRunner()", "type": "assigned_variable", "loc": [34, 34], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98880:If_L26_C8", "vector": [14, 3, 0.85, 0.025, 3, 0.68, 0.5, 276, 3, 3, 0, 0, 509, 10, 1], "semantic": {"name": "failures", "arg_names": [], "import_names": [], "rhs_call_name": "TestRunner", "annotation": ""}, "snippet": " failures = TestRunner(test_labels, verbosity=verbosity, interactive=interactive)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98880:Assign_L36_C12", "label": "test_runner = TestRunner()", "type": "assigned_variable", "loc": [36, 36], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98880:If_L26_C8", "vector": [14, 3, 0.9, 0.025, 3, 0.68, 0.75, 530, 3, 3, 0, 0, 509, 10, 1], "semantic": {"name": "test_runner", "arg_names": [], "import_names": [], "rhs_call_name": "TestRunner", "annotation": ""}, "snippet": " test_runner = TestRunner(verbosity=verbosity, interactive=interactive, failfast=failfast)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98880:Assign_L37_C12", "label": "failures = run_tests()", "type": "assigned_variable", "loc": [37, 37], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98880:If_L26_C8", "vector": [14, 3, 0.925, 0.025, 3, 0.68, 1.0, 276, 3, 1, 0, 0, 630, 10, 1], "semantic": {"name": "failures", "arg_names": [], "import_names": [], "rhs_call_name": "run_tests", "annotation": ""}, "snippet": " failures = test_runner.run_tests(test_labels)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98880:If_L39_C8", "label": "if", "type": "if", "loc": [39, 40], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98880:FunctionDef_L17_C4", "vector": [4, 2, 0.9875, 0.05, 2, 0.74, 1.0, 0, 2, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if failures:\n sys.exit(bool(failures))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98880:Expr_L40_C12", "label": "exit()", "type": "expression", "loc": [40, 40], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98880:If_L39_C8", "vector": [8, 3, 1.0, 0.025, 3, 0.36, 0.0, 436, 3, 1, 0, 0, 0, 0, 2], "semantic": {"name": "exit", "arg_names": [], "import_names": [], "rhs_call_name": "exit", "annotation": ""}, "snippet": " sys.exit(bool(failures))"}]
[{"f": "ajibawa-2023/Python-Code-Large/train/row_98880:ClassDef_L5_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98880:Assign_L6_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98880:ClassDef_L5_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98880:Assign_L12_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98880:ClassDef_L5_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98880:Assign_L13_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98880:ClassDef_L5_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98880:Assign_L15_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98880:ClassDef_L5_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98880:FunctionDef_L17_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98880:FunctionDef_L17_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98880:ImportFrom_L18_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98880:FunctionDef_L17_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98880:ImportFrom_L19_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98880:FunctionDef_L17_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98880:Assign_L21_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98880:FunctionDef_L17_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98880:Assign_L22_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98880:FunctionDef_L17_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98880:Assign_L23_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98880:FunctionDef_L17_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98880:Assign_L24_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98880:FunctionDef_L17_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98880:If_L26_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98880:If_L26_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98880:Import_L29_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98880:If_L26_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98880:Expr_L30_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98880:If_L26_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98880:Assign_L34_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98880:If_L26_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98880:Assign_L36_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98880:If_L26_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98880:Assign_L37_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98880:FunctionDef_L17_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98880:If_L39_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98880:If_L39_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98880:Expr_L40_C12"}]
from optparse import make_option from django.core.management.base import LabelCommand from django.db import connections, transaction, models, DEFAULT_DB_ALIAS class Command(LabelCommand): help = "Creates the table needed to use the SQL cache backend." args = "<tablename>" label = 'tablename' option_list = LabelCommand.option_list + ( make_option('--database', action='store', dest='database', default=DEFAULT_DB_ALIAS, help='Nominates a database onto ' 'which the cache table will be installed. ' 'Defaults to the "default" database.'), ) requires_model_validation = False def handle_label(self, tablename, **options): alias = options.get('database', DEFAULT_DB_ALIAS) connection = connections[alias] fields = ( # "key" is a reserved word in MySQL, so use "cache_key" instead. models.CharField(name='cache_key', max_length=255, unique=True, primary_key=True), models.TextField(name='value'), models.DateTimeField(name='expires', db_index=True), ) table_output = [] index_output = [] qn = connection.ops.quote_name for f in fields: field_output = [qn(f.name), f.db_type(connection=connection)] field_output.append("%sNULL" % (not f.null and "NOT " or "")) if f.primary_key: field_output.append("PRIMARY KEY") elif f.unique: field_output.append("UNIQUE") if f.db_index: unique = f.unique and "UNIQUE " or "" index_output.append("CREATE %sINDEX %s ON %s (%s);" % \ (unique, qn('%s_%s' % (tablename, f.name)), qn(tablename), qn(f.name))) table_output.append(" ".join(field_output)) full_statement = ["CREATE TABLE %s (" % qn(tablename)] for i, line in enumerate(table_output): full_statement.append(' %s%s' % (line, i < len(table_output)-1 and ',' or '')) full_statement.append(');') curs = connection.cursor() curs.execute("\n".join(full_statement)) for statement in index_output: curs.execute(statement) transaction.commit_unless_managed(using=alias)
ajibawa-2023/Python-Code-Large/train/row_98882
36
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_98882:ImportFrom_L1_C0", "label": "from optparse import make_option", "type": "import", "loc": [1, 1], "level": 0, "parent": null, "vector": [1, 0, 0.0189, 0.0189, 0, 0.66, 0.0, 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_98882:ImportFrom_L3_C0", "label": "from django.core.management.base import LabelCommand", "type": "import", "loc": [3, 3], "level": 0, "parent": null, "vector": [1, 0, 0.0566, 0.0189, 0, 0.66, 0.3333, 931, 0, 1, 0, 0, 931, 0, 0], "semantic": {"name": "django.core.management.base", "arg_names": [], "import_names": ["LabelCommand"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.core.management.base import LabelCommand"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98882:ImportFrom_L4_C0", "label": "from django.db import connections, transaction, models\u2026", "type": "import", "loc": [4, 4], "level": 0, "parent": null, "vector": [1, 0, 0.0755, 0.0189, 0, 0.66, 0.6667, 40, 0, 4, 0, 0, 40, 0, 0], "semantic": {"name": "django.db", "arg_names": [], "import_names": ["connections", "transaction", "models", "DEFAULT_DB_ALIAS"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.db import connections, transaction, models, DEFAULT_DB_ALIAS"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98882:ClassDef_L6_C0", "label": "Command", "type": "class", "loc": [6, 53], "level": 0, "parent": null, "vector": [3, 0, 0.5566, 0.9057, 0, 0.66, 1.0, 73, 0, 1, 0, 0, 263, 0, 26], "semantic": {"name": "Command", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class Command(LabelCommand):\n help = \"Creates the table needed to use the SQL cache backend.\"\n args = \"<tablename>\"\n label = 'tablename'\n\n option_list = LabelCommand.option_list + (\n make_option('--database', action='store', dest='database',\n default=DEFAULT_DB_ALIAS, help='Nominates a database onto '"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98882:Assign_L7_C4", "label": "help =", "type": "assigned_variable", "loc": [7, 7], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98882:ClassDef_L6_C0", "vector": [14, 1, 0.1321, 0.0189, 1, 0.45, 0.0, 868, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "help", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " help = \"Creates the table needed to use the SQL cache backend.\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98882:Assign_L8_C4", "label": "args =", "type": "assigned_variable", "loc": [8, 8], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98882:ClassDef_L6_C0", "vector": [14, 1, 0.1509, 0.0189, 1, 0.45, 0.2, 805, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "args", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " args = \"<tablename>\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98882:Assign_L9_C4", "label": "label =", "type": "assigned_variable", "loc": [9, 9], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98882:ClassDef_L6_C0", "vector": [14, 1, 0.1698, 0.0189, 1, 0.45, 0.4, 811, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "label", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " label = 'tablename'"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98882:Assign_L11_C4", "label": "option_list =", "type": "assigned_variable", "loc": [11, 16], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98882:ClassDef_L6_C0", "vector": [14, 1, 0.2547, 0.1132, 1, 0.45, 0.6, 318, 4, 0, 0, 0, 0, 0, 1], "semantic": {"name": "option_list", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " option_list = LabelCommand.option_list + (\n make_option('--database', action='store', dest='database',\n default=DEFAULT_DB_ALIAS, help='Nominates a database onto '\n 'which the cache table will be installed. '\n 'Defaults to the \"default\" database.'),\n )"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98882:Assign_L18_C4", "label": "requires_model_validation =", "type": "assigned_variable", "loc": [18, 18], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98882:ClassDef_L6_C0", "vector": [14, 1, 0.3396, 0.0189, 1, 0.45, 0.8, 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_98882:FunctionDef_L20_C4", "label": "handle_label", "type": "function", "loc": [20, 53], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98882:ClassDef_L6_C0", "vector": [2, 1, 0.6887, 0.6415, 1, 0.45, 1.0, 229, 0, 3, 0, 0, 0, 0, 25], "semantic": {"name": "handle_label", "arg_names": ["self", "tablename", "options"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def handle_label(self, tablename, **options):\n alias = options.get('database', DEFAULT_DB_ALIAS)\n connection = connections[alias]\n fields = (\n # \"key\" is a reserved word in MySQL, so use \"cache_key\" instead.\n models.CharField(name='cache_key', max_length=255, unique=True, primary_key=True),\n models.TextField(name='value'),\n models.DateTimeField(name='expires', db_index=True),"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98882:Assign_L21_C8", "label": "alias = get()", "type": "assigned_variable", "loc": [21, 21], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98882:FunctionDef_L20_C4", "vector": [14, 2, 0.3962, 0.0189, 2, 0.95, 0.0, 657, 3, 2, 0, 0, 607, 10, 1], "semantic": {"name": "alias", "arg_names": [], "import_names": [], "rhs_call_name": "get", "annotation": ""}, "snippet": " alias = options.get('database', DEFAULT_DB_ALIAS)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98882:Assign_L22_C8", "label": "connection =", "type": "assigned_variable", "loc": [22, 22], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98882:FunctionDef_L20_C4", "vector": [14, 2, 0.4151, 0.0189, 2, 0.95, 0.0769, 351, 6, 0, 0, 0, 0, 0, 0], "semantic": {"name": "connection", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " connection = connections[alias]"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98882:Assign_L23_C8", "label": "fields =", "type": "assigned_variable", "loc": [23, 28], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98882:FunctionDef_L20_C4", "vector": [14, 2, 0.4811, 0.1132, 2, 0.95, 0.1538, 358, 0, 0, 0, 0, 0, 8, 3], "semantic": {"name": "fields", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " fields = (\n # \"key\" is a reserved word in MySQL, so use \"cache_key\" instead.\n models.CharField(name='cache_key', max_length=255, unique=True, primary_key=True),\n models.TextField(name='value'),\n models.DateTimeField(name='expires', db_index=True),\n )"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98882:Assign_L29_C8", "label": "table_output =", "type": "assigned_variable", "loc": [29, 29], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98882:FunctionDef_L20_C4", "vector": [14, 2, 0.5472, 0.0189, 2, 0.95, 0.2308, 565, 0, 0, 0, 0, 0, 5, 0], "semantic": {"name": "table_output", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " table_output = []"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98882:Assign_L30_C8", "label": "index_output =", "type": "assigned_variable", "loc": [30, 30], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98882:FunctionDef_L20_C4", "vector": [14, 2, 0.566, 0.0189, 2, 0.95, 0.3077, 762, 0, 0, 0, 0, 0, 5, 0], "semantic": {"name": "index_output", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " index_output = []"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98882:Assign_L31_C8", "label": "qn =", "type": "assigned_variable", "loc": [31, 31], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98882:FunctionDef_L20_C4", "vector": [14, 2, 0.5849, 0.0189, 2, 0.95, 0.3846, 514, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "qn", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " qn = connection.ops.quote_name"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98882:For_L32_C8", "label": "for f", "type": "for", "loc": [32, 44], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98882:FunctionDef_L20_C4", "vector": [6, 2, 0.717, 0.2453, 2, 0.95, 0.4615, 899, 2, 0, 0, 0, 0, 0, 11], "semantic": {"name": "f", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for f in fields:\n field_output = [qn(f.name), f.db_type(connection=connection)]\n field_output.append(\"%sNULL\" % (not f.null and \"NOT \" or \"\"))\n if f.primary_key:\n field_output.append(\"PRIMARY KEY\")\n elif f.unique:\n field_output.append(\"UNIQUE\")\n if f.db_index:"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98882:Assign_L33_C12", "label": "field_output =", "type": "assigned_variable", "loc": [33, 33], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98882:For_L32_C8", "vector": [14, 3, 0.6226, 0.0189, 3, 0.27, 0.0, 318, 0, 0, 0, 0, 0, 5, 2], "semantic": {"name": "field_output", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " field_output = [qn(f.name), f.db_type(connection=connection)]"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98882:Expr_L34_C12", "label": "append()", "type": "expression", "loc": [34, 34], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98882:For_L32_C8", "vector": [8, 3, 0.6415, 0.0189, 3, 0.27, 0.25, 243, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "append", "arg_names": [], "import_names": [], "rhs_call_name": "append", "annotation": ""}, "snippet": " field_output.append(\"%sNULL\" % (not f.null and \"NOT \" or \"\"))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98882:If_L35_C12", "label": "if", "type": "if", "loc": [35, 38], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98882:For_L32_C8", "vector": [4, 3, 0.6887, 0.0755, 3, 0.27, 0.5, 0, 7, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if f.primary_key:\n field_output.append(\"PRIMARY KEY\")\n elif f.unique:\n field_output.append(\"UNIQUE\")"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98882:Expr_L36_C16", "label": "append()", "type": "expression", "loc": [36, 36], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98882:If_L35_C12", "vector": [8, 4, 0.6792, 0.0189, 4, 0.56, 0.0, 243, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "append", "arg_names": [], "import_names": [], "rhs_call_name": "append", "annotation": ""}, "snippet": " field_output.append(\"PRIMARY KEY\")"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98882:If_L37_C12", "label": "if", "type": "if", "loc": [37, 38], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98882:If_L35_C12", "vector": [4, 4, 0.7075, 0.0377, 4, 0.56, 1.0, 0, 7, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " elif f.unique:\n field_output.append(\"UNIQUE\")"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98882:Expr_L38_C16", "label": "append()", "type": "expression", "loc": [38, 38], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98882:If_L37_C12", "vector": [8, 5, 0.717, 0.0189, 5, 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": " field_output.append(\"UNIQUE\")"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98882:If_L39_C12", "label": "if", "type": "if", "loc": [39, 43], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98882:For_L32_C8", "vector": [4, 3, 0.7736, 0.0943, 3, 0.27, 0.75, 0, 7, 0, 0, 0, 0, 0, 4], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if f.db_index:\n unique = f.unique and \"UNIQUE \" or \"\"\n index_output.append(\"CREATE %sINDEX %s ON %s (%s);\" % \\\n (unique, qn('%s_%s' % (tablename, f.name)), qn(tablename),\n qn(f.name)))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98882:Assign_L40_C16", "label": "unique =", "type": "assigned_variable", "loc": [40, 40], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98882:If_L39_C12", "vector": [14, 4, 0.7547, 0.0189, 4, 0.49, 0.0, 691, 0, 0, 0, 0, 0, 0, 0], "semantic": {"name": "unique", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " unique = f.unique and \"UNIQUE \" or \"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98882:Expr_L41_C16", "label": "append()", "type": "expression", "loc": [41, 43], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98882:If_L39_C12", "vector": [8, 4, 0.7925, 0.0566, 4, 0.49, 1.0, 243, 3, 1, 0, 0, 0, 0, 4], "semantic": {"name": "append", "arg_names": [], "import_names": [], "rhs_call_name": "append", "annotation": ""}, "snippet": " index_output.append(\"CREATE %sINDEX %s ON %s (%s);\" % \\\n (unique, qn('%s_%s' % (tablename, f.name)), qn(tablename),\n qn(f.name)))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98882:Expr_L44_C12", "label": "append()", "type": "expression", "loc": [44, 44], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98882:For_L32_C8", "vector": [8, 3, 0.8302, 0.0189, 3, 0.27, 1.0, 243, 3, 1, 0, 0, 0, 0, 2], "semantic": {"name": "append", "arg_names": [], "import_names": [], "rhs_call_name": "append", "annotation": ""}, "snippet": " table_output.append(\" \".join(field_output))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98882:Assign_L45_C8", "label": "full_statement =", "type": "assigned_variable", "loc": [45, 45], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98882:FunctionDef_L20_C4", "vector": [14, 2, 0.8491, 0.0189, 2, 0.95, 0.5385, 177, 0, 0, 0, 0, 0, 5, 1], "semantic": {"name": "full_statement", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " full_statement = [\"CREATE TABLE %s (\" % qn(tablename)]"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98882:For_L46_C8", "label": "for i, line", "type": "for", "loc": [46, 47], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98882:FunctionDef_L20_C4", "vector": [6, 2, 0.8774, 0.0377, 2, 0.95, 0.6154, 54, 3, 0, 0, 0, 0, 0, 3], "semantic": {"name": "i, line", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for i, line in enumerate(table_output):\n full_statement.append(' %s%s' % (line, i < len(table_output)-1 and ',' or ''))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98882:Expr_L47_C12", "label": "append()", "type": "expression", "loc": [47, 47], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98882:For_L46_C8", "vector": [8, 3, 0.8868, 0.0189, 3, 0.09, 0.0, 243, 3, 1, 0, 0, 0, 0, 2], "semantic": {"name": "append", "arg_names": [], "import_names": [], "rhs_call_name": "append", "annotation": ""}, "snippet": " full_statement.append(' %s%s' % (line, i < len(table_output)-1 and ',' or ''))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98882:Expr_L48_C8", "label": "append()", "type": "expression", "loc": [48, 48], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98882:FunctionDef_L20_C4", "vector": [8, 2, 0.9057, 0.0189, 2, 0.95, 0.6923, 243, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "append", "arg_names": [], "import_names": [], "rhs_call_name": "append", "annotation": ""}, "snippet": " full_statement.append(');')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98882:Assign_L49_C8", "label": "curs = cursor()", "type": "assigned_variable", "loc": [49, 49], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98882:FunctionDef_L20_C4", "vector": [14, 2, 0.9245, 0.0189, 2, 0.95, 0.7692, 480, 3, 0, 0, 0, 231, 10, 1], "semantic": {"name": "curs", "arg_names": [], "import_names": [], "rhs_call_name": "cursor", "annotation": ""}, "snippet": " curs = connection.cursor()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98882:Expr_L50_C8", "label": "execute()", "type": "expression", "loc": [50, 50], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98882:FunctionDef_L20_C4", "vector": [8, 2, 0.9434, 0.0189, 2, 0.95, 0.8462, 569, 3, 1, 0, 0, 0, 0, 2], "semantic": {"name": "execute", "arg_names": [], "import_names": [], "rhs_call_name": "execute", "annotation": ""}, "snippet": " curs.execute(\"\\n\".join(full_statement))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98882:For_L51_C8", "label": "for statement", "type": "for", "loc": [51, 52], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98882:FunctionDef_L20_C4", "vector": [6, 2, 0.9717, 0.0377, 2, 0.95, 0.9231, 92, 2, 0, 0, 0, 0, 0, 1], "semantic": {"name": "statement", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for statement in index_output:\n curs.execute(statement)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98882:Expr_L52_C12", "label": "execute()", "type": "expression", "loc": [52, 52], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98882:For_L51_C8", "vector": [8, 3, 0.9811, 0.0189, 3, 0.96, 0.0, 569, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "execute", "arg_names": [], "import_names": [], "rhs_call_name": "execute", "annotation": ""}, "snippet": " curs.execute(statement)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98882:Expr_L53_C8", "label": "commit_unless_managed()", "type": "expression", "loc": [53, 53], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98882:FunctionDef_L20_C4", "vector": [8, 2, 1.0, 0.0189, 2, 0.95, 1.0, 431, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "commit_unless_managed", "arg_names": [], "import_names": [], "rhs_call_name": "commit_unless_managed", "annotation": ""}, "snippet": " transaction.commit_unless_managed(using=alias)"}]
[{"f": "ajibawa-2023/Python-Code-Large/train/row_98882:ClassDef_L6_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98882:Assign_L7_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98882:ClassDef_L6_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98882:Assign_L8_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98882:ClassDef_L6_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98882:Assign_L9_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98882:ClassDef_L6_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98882:Assign_L11_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98882:ClassDef_L6_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98882:Assign_L18_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98882:ClassDef_L6_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98882:FunctionDef_L20_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98882:FunctionDef_L20_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98882:Assign_L21_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98882:FunctionDef_L20_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98882:Assign_L22_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98882:FunctionDef_L20_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98882:Assign_L23_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98882:FunctionDef_L20_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98882:Assign_L29_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98882:FunctionDef_L20_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98882:Assign_L30_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98882:FunctionDef_L20_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98882:Assign_L31_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98882:FunctionDef_L20_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98882:For_L32_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98882:For_L32_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98882:Assign_L33_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98882:For_L32_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98882:Expr_L34_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98882:For_L32_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98882:If_L35_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98882:If_L35_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98882:Expr_L36_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98882:If_L35_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98882:If_L37_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98882:If_L37_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98882:Expr_L38_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98882:For_L32_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98882:If_L39_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98882:If_L39_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98882:Assign_L40_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98882:If_L39_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98882:Expr_L41_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98882:For_L32_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98882:Expr_L44_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98882:FunctionDef_L20_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98882:Assign_L45_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98882:FunctionDef_L20_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98882:For_L46_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98882:For_L46_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98882:Expr_L47_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98882:FunctionDef_L20_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98882:Expr_L48_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98882:FunctionDef_L20_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98882:Assign_L49_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98882:FunctionDef_L20_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98882:Expr_L50_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98882:FunctionDef_L20_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98882:For_L51_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98882:For_L51_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98882:Expr_L52_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98882:FunctionDef_L20_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98882:Expr_L53_C8"}]
from django.core.management.base import copy_helper, CommandError, LabelCommand from django.utils.importlib import import_module import os import re from random import choice class Command(LabelCommand): help = "Creates a Django project directory structure for the given project name in the current directory." args = "[projectname]" label = 'project name' requires_model_validation = False # Can't import settings during this command, because they haven't # necessarily been created. can_import_settings = False def handle_label(self, project_name, **options): # Determine the project_name a bit naively -- by looking at the name of # the parent directory. directory = os.getcwd() # Check that the project_name cannot be imported. try: import_module(project_name) except ImportError: pass else: raise CommandError("%r conflicts with the name of an existing Python module and cannot be used as a project name. Please try another name." % project_name) copy_helper(self.style, 'project', project_name, directory) # Create a random SECRET_KEY hash, and put it in the main settings. main_settings_file = os.path.join(directory, project_name, 'settings.py') settings_contents = open(main_settings_file, 'r').read() fp = open(main_settings_file, 'w') secret_key = ''.join([choice('abcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*(-_=+)') for i in range(50)]) settings_contents = re.sub(r"(?<=SECRET_KEY = ')'", secret_key + "'", settings_contents) fp.write(settings_contents) fp.close()
ajibawa-2023/Python-Code-Large/train/row_98883
23
39
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_98883:ImportFrom_L1_C0", "label": "from django.core.management.base import copy_helper, CommandError, LabelCommand", "type": "import", "loc": [1, 1], "level": 0, "parent": null, "vector": [1, 0, 0.0256, 0.0256, 0, 0.66, 0.0, 931, 0, 3, 0, 0, 931, 0, 0], "semantic": {"name": "django.core.management.base", "arg_names": [], "import_names": ["copy_helper", "CommandError", "LabelCommand"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.core.management.base import copy_helper, CommandError, LabelCommand"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98883:ImportFrom_L2_C0", "label": "from django.utils.importlib import import_module", "type": "import", "loc": [2, 2], "level": 0, "parent": null, "vector": [1, 0, 0.0513, 0.0256, 0, 0.66, 0.2, 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_98883:Import_L3_C0", "label": "os import os", "type": "import", "loc": [3, 3], "level": 0, "parent": null, "vector": [1, 0, 0.0769, 0.0256, 0, 0.66, 0.4, 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_98883:Import_L4_C0", "label": "re import re", "type": "import", "loc": [4, 4], "level": 0, "parent": null, "vector": [1, 0, 0.1026, 0.0256, 0, 0.66, 0.6, 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_98883:ImportFrom_L5_C0", "label": "from random import choice", "type": "import", "loc": [5, 5], "level": 0, "parent": null, "vector": [1, 0, 0.1282, 0.0256, 0, 0.66, 0.8, 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_98883:ClassDef_L7_C0", "label": "Command", "type": "class", "loc": [7, 39], "level": 0, "parent": null, "vector": [3, 0, 0.5897, 0.8462, 0, 0.66, 1.0, 73, 0, 1, 0, 0, 263, 0, 14], "semantic": {"name": "Command", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class Command(LabelCommand):\n help = \"Creates a Django project directory structure for the given project name in the current directory.\"\n args = \"[projectname]\"\n label = 'project name'\n\n requires_model_validation = False\n # Can't import settings during this command, because they haven't\n # necessarily been created."}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98883:Assign_L8_C4", "label": "help =", "type": "assigned_variable", "loc": [8, 8], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98883:ClassDef_L7_C0", "vector": [14, 1, 0.2051, 0.0256, 1, 0.93, 0.0, 868, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "help", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " help = \"Creates a Django project directory structure for the given project name in the current directory.\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98883:Assign_L9_C4", "label": "args =", "type": "assigned_variable", "loc": [9, 9], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98883:ClassDef_L7_C0", "vector": [14, 1, 0.2308, 0.0256, 1, 0.93, 0.2, 805, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "args", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " args = \"[projectname]\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98883:Assign_L10_C4", "label": "label =", "type": "assigned_variable", "loc": [10, 10], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98883:ClassDef_L7_C0", "vector": [14, 1, 0.2564, 0.0256, 1, 0.93, 0.4, 811, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "label", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " label = 'project name'"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98883:Assign_L12_C4", "label": "requires_model_validation =", "type": "assigned_variable", "loc": [12, 12], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98883:ClassDef_L7_C0", "vector": [14, 1, 0.3077, 0.0256, 1, 0.93, 0.6, 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_98883:Assign_L15_C4", "label": "can_import_settings =", "type": "assigned_variable", "loc": [15, 15], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98883:ClassDef_L7_C0", "vector": [14, 1, 0.3846, 0.0256, 1, 0.93, 0.8, 447, 1, 0, 0, 0, 0, 4, 0], "semantic": {"name": "can_import_settings", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " can_import_settings = False"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98883:FunctionDef_L17_C4", "label": "handle_label", "type": "function", "loc": [17, 39], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98883:ClassDef_L7_C0", "vector": [2, 1, 0.7179, 0.5897, 1, 0.93, 1.0, 229, 0, 3, 0, 0, 0, 0, 14], "semantic": {"name": "handle_label", "arg_names": ["self", "project_name", "options"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def handle_label(self, project_name, **options):\n # Determine the project_name a bit naively -- by looking at the name of\n # the parent directory.\n directory = os.getcwd()\n\n # Check that the project_name cannot be imported.\n try:\n import_module(project_name)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98883:Assign_L20_C8", "label": "directory = getcwd()", "type": "assigned_variable", "loc": [20, 20], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98883:FunctionDef_L17_C4", "vector": [14, 2, 0.5128, 0.0256, 2, 0.77, 0.0, 229, 3, 0, 0, 0, 320, 10, 1], "semantic": {"name": "directory", "arg_names": [], "import_names": [], "rhs_call_name": "getcwd", "annotation": ""}, "snippet": " directory = os.getcwd()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98883:Try_L23_C8", "label": "try", "type": "try", "loc": [23, 28], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98883:FunctionDef_L17_C4", "vector": [7, 2, 0.6538, 0.1538, 2, 0.77, 0.1111, 0, 0, 1, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " try:\n import_module(project_name)\n except ImportError:\n pass\n else:\n raise CommandError(\"%r conflicts with the name of an existing Python module and cannot be used as a project name. Please try another name.\" % project_name)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98883:Expr_L24_C12", "label": "import_module()", "type": "expression", "loc": [24, 24], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98883:Try_L23_C8", "vector": [8, 3, 0.6154, 0.0256, 3, 0.72, 0.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(project_name)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98883:Expr_L30_C8", "label": "copy_helper()", "type": "expression", "loc": [30, 30], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98883:FunctionDef_L17_C4", "vector": [8, 2, 0.7692, 0.0256, 2, 0.77, 0.2222, 930, 3, 4, 0, 0, 0, 0, 1], "semantic": {"name": "copy_helper", "arg_names": [], "import_names": [], "rhs_call_name": "copy_helper", "annotation": ""}, "snippet": " copy_helper(self.style, 'project', project_name, directory)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98883:Assign_L33_C8", "label": "main_settings_file = join()", "type": "assigned_variable", "loc": [33, 33], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98883:FunctionDef_L17_C4", "vector": [14, 2, 0.8462, 0.0256, 2, 0.77, 0.3333, 625, 3, 3, 0, 0, 933, 10, 1], "semantic": {"name": "main_settings_file", "arg_names": [], "import_names": [], "rhs_call_name": "join", "annotation": ""}, "snippet": " main_settings_file = os.path.join(directory, project_name, 'settings.py')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98883:Assign_L34_C8", "label": "settings_contents = read()", "type": "assigned_variable", "loc": [34, 34], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98883:FunctionDef_L17_C4", "vector": [14, 2, 0.8718, 0.0256, 2, 0.77, 0.4444, 909, 3, 0, 0, 0, 453, 10, 2], "semantic": {"name": "settings_contents", "arg_names": [], "import_names": [], "rhs_call_name": "read", "annotation": ""}, "snippet": " settings_contents = open(main_settings_file, 'r').read()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98883:Assign_L35_C8", "label": "fp = open()", "type": "assigned_variable", "loc": [35, 35], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98883:FunctionDef_L17_C4", "vector": [14, 2, 0.8974, 0.0256, 2, 0.77, 0.5556, 392, 3, 2, 0, 0, 693, 10, 1], "semantic": {"name": "fp", "arg_names": [], "import_names": [], "rhs_call_name": "open", "annotation": ""}, "snippet": " fp = open(main_settings_file, 'w')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98883:Assign_L36_C8", "label": "secret_key = join()", "type": "assigned_variable", "loc": [36, 36], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98883:FunctionDef_L17_C4", "vector": [14, 2, 0.9231, 0.0256, 2, 0.77, 0.6667, 516, 3, 1, 0, 0, 933, 10, 3], "semantic": {"name": "secret_key", "arg_names": [], "import_names": [], "rhs_call_name": "join", "annotation": ""}, "snippet": " secret_key = ''.join([choice('abcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*(-_=+)') for i in range(50)])"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98883:Assign_L37_C8", "label": "settings_contents = sub()", "type": "assigned_variable", "loc": [37, 37], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98883:FunctionDef_L17_C4", "vector": [14, 2, 0.9487, 0.0256, 2, 0.77, 0.7778, 909, 3, 3, 0, 0, 819, 10, 1], "semantic": {"name": "settings_contents", "arg_names": [], "import_names": [], "rhs_call_name": "sub", "annotation": ""}, "snippet": " settings_contents = re.sub(r\"(?<=SECRET_KEY = ')'\", secret_key + \"'\", settings_contents)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98883:Expr_L38_C8", "label": "write()", "type": "expression", "loc": [38, 38], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98883:FunctionDef_L17_C4", "vector": [8, 2, 0.9744, 0.0256, 2, 0.77, 0.8889, 837, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "write", "arg_names": [], "import_names": [], "rhs_call_name": "write", "annotation": ""}, "snippet": " fp.write(settings_contents)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98883:Expr_L39_C8", "label": "close()", "type": "expression", "loc": [39, 39], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98883:FunctionDef_L17_C4", "vector": [8, 2, 1.0, 0.0256, 2, 0.77, 1.0, 77, 3, 0, 0, 0, 0, 0, 1], "semantic": {"name": "close", "arg_names": [], "import_names": [], "rhs_call_name": "close", "annotation": ""}, "snippet": " fp.close()"}]
[{"f": "ajibawa-2023/Python-Code-Large/train/row_98883:ClassDef_L7_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98883:Assign_L8_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98883:ClassDef_L7_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98883:Assign_L9_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98883:ClassDef_L7_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98883:Assign_L10_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98883:ClassDef_L7_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98883:Assign_L12_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98883:ClassDef_L7_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98883:Assign_L15_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98883:ClassDef_L7_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98883:FunctionDef_L17_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98883:FunctionDef_L17_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98883:Assign_L20_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98883:FunctionDef_L17_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98883:Try_L23_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98883:Try_L23_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98883:Expr_L24_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98883:FunctionDef_L17_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98883:Expr_L30_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98883:FunctionDef_L17_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98883:Assign_L33_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98883:FunctionDef_L17_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98883:Assign_L34_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98883:FunctionDef_L17_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98883:Assign_L35_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98883:FunctionDef_L17_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98883:Assign_L36_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98883:FunctionDef_L17_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98883:Assign_L37_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98883:FunctionDef_L17_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98883:Expr_L38_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98883:FunctionDef_L17_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98883:Expr_L39_C8"}]
import os from django.core.management.base import copy_helper, CommandError, LabelCommand from django.utils.importlib import import_module class Command(LabelCommand): help = "Creates a Django app directory structure for the given app name in the current directory." args = "[appname]" label = 'application name' requires_model_validation = False # Can't import settings during this command, because they haven't # necessarily been created. can_import_settings = False def handle_label(self, app_name, directory=None, **options): if directory is None: directory = os.getcwd() # Determine the project_name by using the basename of directory, # which should be the full path of the project directory (or the # current directory if no directory was passed). project_name = os.path.basename(directory) if app_name == project_name: raise CommandError("You cannot create an app with the same name" " (%r) as your project." % app_name) # Check that the app_name cannot be imported. try: import_module(app_name) except ImportError: pass else: raise CommandError("%r conflicts with the name of an existing Python module and cannot be used as an app name. Please try another name." % app_name) copy_helper(self.style, 'app', app_name, directory, project_name) class ProjectCommand(Command): help = ("Creates a Django app directory structure for the given app name" " in this project's directory.") def __init__(self, project_directory): super(ProjectCommand, self).__init__() self.project_directory = project_directory def handle_label(self, app_name, **options): super(ProjectCommand, self).handle_label(app_name, self.project_directory, **options)
ajibawa-2023/Python-Code-Large/train/row_98884
24
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_98884:Import_L1_C0", "label": "os import os", "type": "import", "loc": [1, 1], "level": 0, "parent": null, "vector": [1, 0, 0.0213, 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_98884:ImportFrom_L3_C0", "label": "from django.core.management.base import copy_helper, CommandError, LabelCommand", "type": "import", "loc": [3, 3], "level": 0, "parent": null, "vector": [1, 0, 0.0638, 0.0213, 0, 0.66, 0.25, 931, 0, 3, 0, 0, 931, 0, 0], "semantic": {"name": "django.core.management.base", "arg_names": [], "import_names": ["copy_helper", "CommandError", "LabelCommand"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.core.management.base import copy_helper, CommandError, LabelCommand"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98884:ImportFrom_L4_C0", "label": "from django.utils.importlib import import_module", "type": "import", "loc": [4, 4], "level": 0, "parent": null, "vector": [1, 0, 0.0851, 0.0213, 0, 0.66, 0.5, 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_98884:ClassDef_L6_C0", "label": "Command", "type": "class", "loc": [6, 36], "level": 0, "parent": null, "vector": [3, 0, 0.4468, 0.6596, 0, 0.66, 0.75, 73, 0, 1, 0, 0, 263, 0, 6], "semantic": {"name": "Command", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class Command(LabelCommand):\n help = \"Creates a Django app directory structure for the given app name in the current directory.\"\n args = \"[appname]\"\n label = 'application name'\n\n requires_model_validation = False\n # Can't import settings during this command, because they haven't\n # necessarily been created."}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98884:Assign_L7_C4", "label": "help =", "type": "assigned_variable", "loc": [7, 7], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98884:ClassDef_L6_C0", "vector": [14, 1, 0.1489, 0.0213, 1, 0.59, 0.0, 868, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "help", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " help = \"Creates a Django app directory structure for the given app name in the current directory.\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98884:Assign_L8_C4", "label": "args =", "type": "assigned_variable", "loc": [8, 8], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98884:ClassDef_L6_C0", "vector": [14, 1, 0.1702, 0.0213, 1, 0.59, 0.2, 805, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "args", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " args = \"[appname]\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98884:Assign_L9_C4", "label": "label =", "type": "assigned_variable", "loc": [9, 9], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98884:ClassDef_L6_C0", "vector": [14, 1, 0.1915, 0.0213, 1, 0.59, 0.4, 811, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "label", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " label = 'application name'"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98884:Assign_L11_C4", "label": "requires_model_validation =", "type": "assigned_variable", "loc": [11, 11], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98884:ClassDef_L6_C0", "vector": [14, 1, 0.234, 0.0213, 1, 0.59, 0.6, 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_98884:Assign_L14_C4", "label": "can_import_settings =", "type": "assigned_variable", "loc": [14, 14], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98884:ClassDef_L6_C0", "vector": [14, 1, 0.2979, 0.0213, 1, 0.59, 0.8, 447, 1, 0, 0, 0, 0, 4, 0], "semantic": {"name": "can_import_settings", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " can_import_settings = False"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98884:FunctionDef_L16_C4", "label": "handle_label", "type": "function", "loc": [16, 36], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98884:ClassDef_L6_C0", "vector": [2, 1, 0.5532, 0.4468, 1, 0.59, 1.0, 229, 0, 4, 0, 0, 0, 0, 6], "semantic": {"name": "handle_label", "arg_names": ["self", "app_name", "directory", "options"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def handle_label(self, app_name, directory=None, **options):\n if directory is None:\n directory = os.getcwd()\n\n # Determine the project_name by using the basename of directory,\n # which should be the full path of the project directory (or the\n # current directory if no directory was passed).\n project_name = os.path.basename(directory)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98884:If_L17_C8", "label": "if", "type": "if", "loc": [17, 18], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98884:FunctionDef_L16_C4", "vector": [4, 2, 0.3723, 0.0426, 2, 0.73, 0.0, 0, 0, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if directory is None:\n directory = os.getcwd()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98884:Assign_L18_C12", "label": "directory = getcwd()", "type": "assigned_variable", "loc": [18, 18], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98884:If_L17_C8", "vector": [14, 3, 0.383, 0.0213, 3, 0.05, 0.0, 229, 3, 0, 0, 0, 320, 10, 1], "semantic": {"name": "directory", "arg_names": [], "import_names": [], "rhs_call_name": "getcwd", "annotation": ""}, "snippet": " directory = os.getcwd()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98884:Assign_L23_C8", "label": "project_name = basename()", "type": "assigned_variable", "loc": [23, 23], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98884:FunctionDef_L16_C4", "vector": [14, 2, 0.4894, 0.0213, 2, 0.73, 0.25, 786, 3, 1, 0, 0, 164, 10, 1], "semantic": {"name": "project_name", "arg_names": [], "import_names": [], "rhs_call_name": "basename", "annotation": ""}, "snippet": " project_name = os.path.basename(directory)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98884:If_L24_C8", "label": "if", "type": "if", "loc": [24, 26], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98884:FunctionDef_L16_C4", "vector": [4, 2, 0.5319, 0.0638, 2, 0.73, 0.5, 0, 0, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if app_name == project_name:\n raise CommandError(\"You cannot create an app with the same name\"\n \" (%r) as your project.\" % app_name)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98884:Try_L29_C8", "label": "try", "type": "try", "loc": [29, 34], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98884:FunctionDef_L16_C4", "vector": [7, 2, 0.6702, 0.1277, 2, 0.73, 0.75, 0, 0, 1, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " try:\n import_module(app_name)\n except ImportError:\n pass\n else:\n raise CommandError(\"%r conflicts with the name of an existing Python module and cannot be used as an app name. Please try another name.\" % app_name)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98884:Expr_L30_C12", "label": "import_module()", "type": "expression", "loc": [30, 30], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98884:Try_L29_C8", "vector": [8, 3, 0.6383, 0.0213, 3, 0.92, 0.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(app_name)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98884:Expr_L36_C8", "label": "copy_helper()", "type": "expression", "loc": [36, 36], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98884:FunctionDef_L16_C4", "vector": [8, 2, 0.766, 0.0213, 2, 0.73, 1.0, 930, 3, 5, 0, 0, 0, 0, 1], "semantic": {"name": "copy_helper", "arg_names": [], "import_names": [], "rhs_call_name": "copy_helper", "annotation": ""}, "snippet": " copy_helper(self.style, 'app', app_name, directory, project_name)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98884:ClassDef_L38_C0", "label": "ProjectCommand", "type": "class", "loc": [38, 47], "level": 0, "parent": null, "vector": [3, 0, 0.9043, 0.2128, 0, 0.66, 1.0, 844, 0, 2, 0, 0, 73, 0, 4], "semantic": {"name": "ProjectCommand", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class ProjectCommand(Command):\n help = (\"Creates a Django app directory structure for the given app name\"\n \" in this project's directory.\")\n\n def __init__(self, project_directory):\n super(ProjectCommand, self).__init__()\n self.project_directory = project_directory\n"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98884:Assign_L39_C4", "label": "help =", "type": "assigned_variable", "loc": [39, 40], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98884:ClassDef_L38_C0", "vector": [14, 1, 0.8404, 0.0426, 1, 0.97, 0.0, 868, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "help", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " help = (\"Creates a Django app directory structure for the given app name\"\n \" in this project's directory.\")"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98884:FunctionDef_L42_C4", "label": "__init__", "type": "function", "loc": [42, 44], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98884:ClassDef_L38_C0", "vector": [2, 1, 0.9149, 0.0638, 1, 0.97, 0.5, 555, 0, 2, 0, 0, 0, 0, 2], "semantic": {"name": "__init__", "arg_names": ["self", "project_directory"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def __init__(self, project_directory):\n super(ProjectCommand, self).__init__()\n self.project_directory = project_directory"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98884:Expr_L43_C8", "label": "__init__()", "type": "expression", "loc": [43, 43], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98884:FunctionDef_L42_C4", "vector": [8, 2, 0.9149, 0.0213, 2, 0.22, 0.0, 555, 3, 0, 0, 0, 0, 0, 2], "semantic": {"name": "__init__", "arg_names": [], "import_names": [], "rhs_call_name": "__init__", "annotation": ""}, "snippet": " super(ProjectCommand, self).__init__()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98884:Assign_L44_C8", "label": "self.project_directory =", "type": "assigned_variable", "loc": [44, 44], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98884:FunctionDef_L42_C4", "vector": [14, 2, 0.9362, 0.0213, 2, 0.22, 1.0, 81, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "self.project_directory", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.project_directory = project_directory"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98884:FunctionDef_L46_C4", "label": "handle_label", "type": "function", "loc": [46, 47], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98884:ClassDef_L38_C0", "vector": [2, 1, 0.9894, 0.0426, 1, 0.97, 1.0, 229, 0, 3, 0, 0, 0, 0, 2], "semantic": {"name": "handle_label", "arg_names": ["self", "app_name", "options"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def handle_label(self, app_name, **options):\n super(ProjectCommand, self).handle_label(app_name, self.project_directory, **options)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98884:Expr_L47_C8", "label": "handle_label()", "type": "expression", "loc": [47, 47], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98884:FunctionDef_L46_C4", "vector": [8, 2, 1.0, 0.0213, 2, 0.65, 0.0, 229, 3, 3, 0, 0, 0, 0, 2], "semantic": {"name": "handle_label", "arg_names": [], "import_names": [], "rhs_call_name": "handle_label", "annotation": ""}, "snippet": " super(ProjectCommand, self).handle_label(app_name, self.project_directory, **options)"}]
[{"f": "ajibawa-2023/Python-Code-Large/train/row_98884:ClassDef_L6_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98884:Assign_L7_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98884:ClassDef_L6_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98884:Assign_L8_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98884:ClassDef_L6_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98884:Assign_L9_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98884:ClassDef_L6_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98884:Assign_L11_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98884:ClassDef_L6_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98884:Assign_L14_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98884:ClassDef_L6_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98884:FunctionDef_L16_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98884:FunctionDef_L16_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98884:If_L17_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98884:If_L17_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98884:Assign_L18_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98884:FunctionDef_L16_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98884:Assign_L23_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98884:FunctionDef_L16_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98884:If_L24_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98884:FunctionDef_L16_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98884:Try_L29_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98884:Try_L29_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98884:Expr_L30_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98884:FunctionDef_L16_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98884:Expr_L36_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98884:ClassDef_L38_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98884:Assign_L39_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98884:ClassDef_L38_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98884:FunctionDef_L42_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98884:FunctionDef_L42_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98884:Expr_L43_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98884:FunctionDef_L42_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98884:Assign_L44_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98884:ClassDef_L38_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98884:FunctionDef_L46_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98884:FunctionDef_L46_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98884:Expr_L47_C8"}]
from optparse import make_option from django.core.management.base import AppCommand from django.core.management.sql import sql_delete from django.db import connections, DEFAULT_DB_ALIAS class Command(AppCommand): help = "Prints the DROP TABLE SQL statements for the given app name(s)." option_list = AppCommand.option_list + ( make_option('--database', action='store', dest='database', default=DEFAULT_DB_ALIAS, help='Nominates a database to print the ' 'SQL for. Defaults to the "default" database.'), ) output_transaction = True def handle_app(self, app, **options): return u'\n'.join(sql_delete(app, self.style, connections[options.get('database', DEFAULT_DB_ALIAS)])).encode('utf-8')
ajibawa-2023/Python-Code-Large/train/row_98885
10
19
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_98885:ImportFrom_L1_C0", "label": "from optparse import make_option", "type": "import", "loc": [1, 1], "level": 0, "parent": null, "vector": [1, 0, 0.0526, 0.0526, 0, 0.66, 0.0, 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_98885:ImportFrom_L3_C0", "label": "from django.core.management.base import AppCommand", "type": "import", "loc": [3, 3], "level": 0, "parent": null, "vector": [1, 0, 0.1579, 0.0526, 0, 0.66, 0.25, 931, 0, 1, 0, 0, 931, 0, 0], "semantic": {"name": "django.core.management.base", "arg_names": [], "import_names": ["AppCommand"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.core.management.base import AppCommand"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98885:ImportFrom_L4_C0", "label": "from django.core.management.sql import sql_delete", "type": "import", "loc": [4, 4], "level": 0, "parent": null, "vector": [1, 0, 0.2105, 0.0526, 0, 0.66, 0.5, 576, 0, 1, 0, 0, 576, 0, 0], "semantic": {"name": "django.core.management.sql", "arg_names": [], "import_names": ["sql_delete"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.core.management.sql import sql_delete"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98885:ImportFrom_L5_C0", "label": "from django.db import connections, DEFAULT_DB_ALIAS", "type": "import", "loc": [5, 5], "level": 0, "parent": null, "vector": [1, 0, 0.2632, 0.0526, 0, 0.66, 0.75, 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_98885:ClassDef_L7_C0", "label": "Command", "type": "class", "loc": [7, 19], "level": 0, "parent": null, "vector": [3, 0, 0.6842, 0.6842, 0, 0.66, 1.0, 73, 0, 1, 0, 0, 369, 0, 5], "semantic": {"name": "Command", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class Command(AppCommand):\n help = \"Prints the DROP TABLE SQL statements for the given app name(s).\"\n\n option_list = AppCommand.option_list + (\n make_option('--database', action='store', dest='database',\n default=DEFAULT_DB_ALIAS, help='Nominates a database to print the '\n 'SQL for. Defaults to the \"default\" database.'),\n )"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98885:Assign_L8_C4", "label": "help =", "type": "assigned_variable", "loc": [8, 8], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98885:ClassDef_L7_C0", "vector": [14, 1, 0.4211, 0.0526, 1, 0.87, 0.0, 868, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "help", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " help = \"Prints the DROP TABLE SQL statements for the given app name(s).\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98885:Assign_L10_C4", "label": "option_list =", "type": "assigned_variable", "loc": [10, 14], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98885:ClassDef_L7_C0", "vector": [14, 1, 0.6316, 0.2632, 1, 0.87, 0.3333, 318, 4, 0, 0, 0, 0, 0, 1], "semantic": {"name": "option_list", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " option_list = AppCommand.option_list + (\n make_option('--database', action='store', dest='database',\n default=DEFAULT_DB_ALIAS, help='Nominates a database to print the '\n 'SQL for. Defaults to the \"default\" database.'),\n )"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98885:Assign_L16_C4", "label": "output_transaction =", "type": "assigned_variable", "loc": [16, 16], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98885:ClassDef_L7_C0", "vector": [14, 1, 0.8421, 0.0526, 1, 0.87, 0.6667, 987, 1, 0, 0, 0, 0, 4, 0], "semantic": {"name": "output_transaction", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " output_transaction = True"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98885:FunctionDef_L18_C4", "label": "handle_app", "type": "function", "loc": [18, 19], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98885:ClassDef_L7_C0", "vector": [2, 1, 0.9737, 0.1053, 1, 0.87, 1.0, 665, 0, 3, 1, 0, 0, 0, 4], "semantic": {"name": "handle_app", "arg_names": ["self", "app", "options"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def handle_app(self, app, **options):\n return u'\\n'.join(sql_delete(app, self.style, connections[options.get('database', DEFAULT_DB_ALIAS)])).encode('utf-8')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98885:Return_L19_C8", "label": "return", "type": "return", "loc": [19, 19], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98885:FunctionDef_L18_C4", "vector": [13, 2, 1.0, 0.0526, 2, 0.68, 0.0, 0, 3, 0, 0, 0, 0, 10, 4], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return u'\\n'.join(sql_delete(app, self.style, connections[options.get('database', DEFAULT_DB_ALIAS)])).encode('utf-8')"}]
[{"f": "ajibawa-2023/Python-Code-Large/train/row_98885:ClassDef_L7_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98885:Assign_L8_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98885:ClassDef_L7_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98885:Assign_L10_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98885:ClassDef_L7_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98885:Assign_L16_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98885:ClassDef_L7_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98885:FunctionDef_L18_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98885:FunctionDef_L18_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98885:Return_L19_C8"}]
from django.core.management.base import BaseCommand from optparse import make_option class Command(BaseCommand): option_list = BaseCommand.option_list + ( make_option('--noinput', action='store_false', dest='interactive', default=True, help='Tells Django to NOT prompt the user for input of any kind.'), make_option('--addrport', action='store', dest='addrport', type='string', default='', help='port number or ipaddr:port to run the server on'), ) help = 'Runs a development server with data from the given fixture(s).' args = '[fixture ...]' requires_model_validation = False def handle(self, *fixture_labels, **options): from django.core.management import call_command from django.db import connection verbosity = int(options.get('verbosity', 1)) interactive = options.get('interactive', True) addrport = options.get('addrport') # Create a test database. db_name = connection.creation.create_test_db(verbosity=verbosity, autoclobber=not interactive) # Import the fixture data into the test database. call_command('loaddata', *fixture_labels, **{'verbosity': verbosity}) # Run the development server. Turn off auto-reloading because it causes # a strange error -- it causes this handle() method to be called # multiple times. shutdown_message = '\nServer stopped.\nNote that the test database, %r, has not been deleted. You can explore it on your own.' % db_name call_command('runserver', addrport=addrport, shutdown_message=shutdown_message, use_reloader=False)
ajibawa-2023/Python-Code-Large/train/row_98886
17
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_98886:ImportFrom_L1_C0", "label": "from django.core.management.base import BaseCommand", "type": "import", "loc": [1, 1], "level": 0, "parent": null, "vector": [1, 0, 0.0278, 0.0278, 0, 0.66, 0.0, 931, 0, 1, 0, 0, 931, 0, 0], "semantic": {"name": "django.core.management.base", "arg_names": [], "import_names": ["BaseCommand"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.core.management.base import BaseCommand"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98886:ImportFrom_L3_C0", "label": "from optparse import make_option", "type": "import", "loc": [3, 3], "level": 0, "parent": null, "vector": [1, 0, 0.0833, 0.0278, 0, 0.66, 0.5, 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_98886:ClassDef_L5_C0", "label": "Command", "type": "class", "loc": [5, 36], "level": 0, "parent": null, "vector": [3, 0, 0.5694, 0.8889, 0, 0.66, 1.0, 73, 0, 1, 0, 0, 564, 0, 9], "semantic": {"name": "Command", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class Command(BaseCommand):\n option_list = BaseCommand.option_list + (\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 make_option('--addrport', action='store', dest='addrport',\n type='string', default='',\n help='port number or ipaddr:port to run the server on'),\n )"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98886:Assign_L6_C4", "label": "option_list =", "type": "assigned_variable", "loc": [6, 12], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98886:ClassDef_L5_C0", "vector": [14, 1, 0.25, 0.1944, 1, 0.88, 0.0, 318, 4, 0, 0, 0, 0, 0, 2], "semantic": {"name": "option_list", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " option_list = BaseCommand.option_list + (\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 make_option('--addrport', action='store', dest='addrport',\n type='string', default='',\n help='port number or ipaddr:port to run the server on'),\n )"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98886:Assign_L13_C4", "label": "help =", "type": "assigned_variable", "loc": [13, 13], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98886:ClassDef_L5_C0", "vector": [14, 1, 0.3611, 0.0278, 1, 0.88, 0.25, 868, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "help", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " help = 'Runs a development server with data from the given fixture(s).'"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98886:Assign_L14_C4", "label": "args =", "type": "assigned_variable", "loc": [14, 14], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98886:ClassDef_L5_C0", "vector": [14, 1, 0.3889, 0.0278, 1, 0.88, 0.5, 805, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "args", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " args = '[fixture ...]'"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98886:Assign_L16_C4", "label": "requires_model_validation =", "type": "assigned_variable", "loc": [16, 16], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98886:ClassDef_L5_C0", "vector": [14, 1, 0.4444, 0.0278, 1, 0.88, 0.75, 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_98886:FunctionDef_L18_C4", "label": "handle", "type": "function", "loc": [18, 36], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98886:ClassDef_L5_C0", "vector": [2, 1, 0.75, 0.5278, 1, 0.88, 1.0, 346, 0, 3, 0, 0, 0, 0, 7], "semantic": {"name": "handle", "arg_names": ["self", "fixture_labels", "options"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def handle(self, *fixture_labels, **options):\n from django.core.management import call_command\n from django.db import connection\n\n verbosity = int(options.get('verbosity', 1))\n interactive = options.get('interactive', True)\n addrport = options.get('addrport')\n"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98886:ImportFrom_L19_C8", "label": "from django.core.management import call_command", "type": "import", "loc": [19, 19], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98886:FunctionDef_L18_C4", "vector": [1, 2, 0.5278, 0.0278, 2, 0.58, 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_98886:ImportFrom_L20_C8", "label": "from django.db import connection", "type": "import", "loc": [20, 20], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98886:FunctionDef_L18_C4", "vector": [1, 2, 0.5556, 0.0278, 2, 0.58, 0.125, 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_98886:Assign_L22_C8", "label": "verbosity = int()", "type": "assigned_variable", "loc": [22, 22], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98886:FunctionDef_L18_C4", "vector": [14, 2, 0.6111, 0.0278, 2, 0.58, 0.25, 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_98886:Assign_L23_C8", "label": "interactive = get()", "type": "assigned_variable", "loc": [23, 23], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98886:FunctionDef_L18_C4", "vector": [14, 2, 0.6389, 0.0278, 2, 0.58, 0.375, 348, 3, 2, 0, 0, 607, 10, 1], "semantic": {"name": "interactive", "arg_names": [], "import_names": [], "rhs_call_name": "get", "annotation": ""}, "snippet": " interactive = options.get('interactive', True)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98886:Assign_L24_C8", "label": "addrport = get()", "type": "assigned_variable", "loc": [24, 24], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98886:FunctionDef_L18_C4", "vector": [14, 2, 0.6667, 0.0278, 2, 0.58, 0.5, 591, 3, 1, 0, 0, 607, 10, 1], "semantic": {"name": "addrport", "arg_names": [], "import_names": [], "rhs_call_name": "get", "annotation": ""}, "snippet": " addrport = options.get('addrport')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98886:Assign_L27_C8", "label": "db_name = create_test_db()", "type": "assigned_variable", "loc": [27, 27], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98886:FunctionDef_L18_C4", "vector": [14, 2, 0.75, 0.0278, 2, 0.58, 0.625, 382, 3, 2, 0, 0, 217, 10, 1], "semantic": {"name": "db_name", "arg_names": [], "import_names": [], "rhs_call_name": "create_test_db", "annotation": ""}, "snippet": " db_name = connection.creation.create_test_db(verbosity=verbosity, autoclobber=not interactive)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98886:Expr_L30_C8", "label": "call_command()", "type": "expression", "loc": [30, 30], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98886:FunctionDef_L18_C4", "vector": [8, 2, 0.8333, 0.0278, 2, 0.58, 0.75, 587, 3, 3, 0, 0, 0, 0, 1], "semantic": {"name": "call_command", "arg_names": [], "import_names": [], "rhs_call_name": "call_command", "annotation": ""}, "snippet": " call_command('loaddata', *fixture_labels, **{'verbosity': verbosity})"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98886:Assign_L35_C8", "label": "shutdown_message =", "type": "assigned_variable", "loc": [35, 35], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98886:FunctionDef_L18_C4", "vector": [14, 2, 0.9722, 0.0278, 2, 0.58, 0.875, 690, 4, 0, 0, 0, 0, 0, 0], "semantic": {"name": "shutdown_message", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " shutdown_message = '\\nServer stopped.\\nNote that the test database, %r, has not been deleted. You can explore it on your own.' % db_name"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98886:Expr_L36_C8", "label": "call_command()", "type": "expression", "loc": [36, 36], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98886:FunctionDef_L18_C4", "vector": [8, 2, 1.0, 0.0278, 2, 0.58, 1.0, 587, 3, 4, 0, 0, 0, 0, 1], "semantic": {"name": "call_command", "arg_names": [], "import_names": [], "rhs_call_name": "call_command", "annotation": ""}, "snippet": " call_command('runserver', addrport=addrport, shutdown_message=shutdown_message, use_reloader=False)"}]
[{"f": "ajibawa-2023/Python-Code-Large/train/row_98886:ClassDef_L5_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98886:Assign_L6_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98886:ClassDef_L5_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98886:Assign_L13_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98886:ClassDef_L5_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98886:Assign_L14_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98886:ClassDef_L5_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98886:Assign_L16_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98886:ClassDef_L5_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98886:FunctionDef_L18_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98886:FunctionDef_L18_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98886:ImportFrom_L19_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98886:FunctionDef_L18_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98886:ImportFrom_L20_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98886:FunctionDef_L18_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98886:Assign_L22_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98886:FunctionDef_L18_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98886:Assign_L23_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98886:FunctionDef_L18_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98886:Assign_L24_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98886:FunctionDef_L18_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98886:Assign_L27_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98886:FunctionDef_L18_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98886:Expr_L30_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98886:FunctionDef_L18_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98886:Assign_L35_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98886:FunctionDef_L18_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98886:Expr_L36_C8"}]
from optparse import make_option from django.core.management.base import AppCommand from django.core.management.sql import sql_custom from django.db import connections, DEFAULT_DB_ALIAS class Command(AppCommand): help = "Prints the custom table modifying SQL statements for the given app name(s)." option_list = AppCommand.option_list + ( make_option('--database', action='store', dest='database', default=DEFAULT_DB_ALIAS, help='Nominates a database to print the ' 'SQL for. Defaults to the "default" database.'), ) output_transaction = True def handle_app(self, app, **options): return u'\n'.join(sql_custom(app, self.style, connections[options.get('database', DEFAULT_DB_ALIAS)])).encode('utf-8')
ajibawa-2023/Python-Code-Large/train/row_98887
10
19
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_98887:ImportFrom_L1_C0", "label": "from optparse import make_option", "type": "import", "loc": [1, 1], "level": 0, "parent": null, "vector": [1, 0, 0.0526, 0.0526, 0, 0.66, 0.0, 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_98887:ImportFrom_L3_C0", "label": "from django.core.management.base import AppCommand", "type": "import", "loc": [3, 3], "level": 0, "parent": null, "vector": [1, 0, 0.1579, 0.0526, 0, 0.66, 0.25, 931, 0, 1, 0, 0, 931, 0, 0], "semantic": {"name": "django.core.management.base", "arg_names": [], "import_names": ["AppCommand"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.core.management.base import AppCommand"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98887:ImportFrom_L4_C0", "label": "from django.core.management.sql import sql_custom", "type": "import", "loc": [4, 4], "level": 0, "parent": null, "vector": [1, 0, 0.2105, 0.0526, 0, 0.66, 0.5, 576, 0, 1, 0, 0, 576, 0, 0], "semantic": {"name": "django.core.management.sql", "arg_names": [], "import_names": ["sql_custom"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.core.management.sql import sql_custom"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98887:ImportFrom_L5_C0", "label": "from django.db import connections, DEFAULT_DB_ALIAS", "type": "import", "loc": [5, 5], "level": 0, "parent": null, "vector": [1, 0, 0.2632, 0.0526, 0, 0.66, 0.75, 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_98887:ClassDef_L7_C0", "label": "Command", "type": "class", "loc": [7, 19], "level": 0, "parent": null, "vector": [3, 0, 0.6842, 0.6842, 0, 0.66, 1.0, 73, 0, 1, 0, 0, 369, 0, 5], "semantic": {"name": "Command", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class Command(AppCommand):\n help = \"Prints the custom table modifying SQL statements for the given app name(s).\"\n\n option_list = AppCommand.option_list + (\n make_option('--database', action='store', dest='database',\n default=DEFAULT_DB_ALIAS, help='Nominates a database to print the '\n 'SQL for. Defaults to the \"default\" database.'),\n )"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98887:Assign_L8_C4", "label": "help =", "type": "assigned_variable", "loc": [8, 8], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98887:ClassDef_L7_C0", "vector": [14, 1, 0.4211, 0.0526, 1, 0.38, 0.0, 868, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "help", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " help = \"Prints the custom table modifying SQL statements for the given app name(s).\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98887:Assign_L10_C4", "label": "option_list =", "type": "assigned_variable", "loc": [10, 14], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98887:ClassDef_L7_C0", "vector": [14, 1, 0.6316, 0.2632, 1, 0.38, 0.3333, 318, 4, 0, 0, 0, 0, 0, 1], "semantic": {"name": "option_list", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " option_list = AppCommand.option_list + (\n make_option('--database', action='store', dest='database',\n default=DEFAULT_DB_ALIAS, help='Nominates a database to print the '\n 'SQL for. Defaults to the \"default\" database.'),\n )"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98887:Assign_L16_C4", "label": "output_transaction =", "type": "assigned_variable", "loc": [16, 16], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98887:ClassDef_L7_C0", "vector": [14, 1, 0.8421, 0.0526, 1, 0.38, 0.6667, 987, 1, 0, 0, 0, 0, 4, 0], "semantic": {"name": "output_transaction", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " output_transaction = True"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98887:FunctionDef_L18_C4", "label": "handle_app", "type": "function", "loc": [18, 19], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98887:ClassDef_L7_C0", "vector": [2, 1, 0.9737, 0.1053, 1, 0.38, 1.0, 665, 0, 3, 1, 0, 0, 0, 4], "semantic": {"name": "handle_app", "arg_names": ["self", "app", "options"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def handle_app(self, app, **options):\n return u'\\n'.join(sql_custom(app, self.style, connections[options.get('database', DEFAULT_DB_ALIAS)])).encode('utf-8')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98887:Return_L19_C8", "label": "return", "type": "return", "loc": [19, 19], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98887:FunctionDef_L18_C4", "vector": [13, 2, 1.0, 0.0526, 2, 0.19, 0.0, 0, 3, 0, 0, 0, 0, 10, 4], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return u'\\n'.join(sql_custom(app, self.style, connections[options.get('database', DEFAULT_DB_ALIAS)])).encode('utf-8')"}]
[{"f": "ajibawa-2023/Python-Code-Large/train/row_98887:ClassDef_L7_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98887:Assign_L8_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98887:ClassDef_L7_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98887:Assign_L10_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98887:ClassDef_L7_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98887:Assign_L16_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98887:ClassDef_L7_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98887:FunctionDef_L18_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98887:FunctionDef_L18_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98887:Return_L19_C8"}]
from django.core.management.base import AppCommand, CommandError class Command(AppCommand): help = "RENAMED: see 'sqlcustom'" def handle(self, *apps, **options): raise CommandError("This command has been renamed. Use the 'sqlcustom' command instead.")
ajibawa-2023/Python-Code-Large/train/row_98889
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_98889:ImportFrom_L1_C0", "label": "from django.core.management.base import AppCommand, CommandError", "type": "import", "loc": [1, 1], "level": 0, "parent": null, "vector": [1, 0, 0.1429, 0.1429, 0, 0.66, 0.0, 931, 0, 2, 0, 0, 931, 0, 0], "semantic": {"name": "django.core.management.base", "arg_names": [], "import_names": ["AppCommand", "CommandError"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.core.management.base import AppCommand, CommandError"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98889:ClassDef_L3_C0", "label": "Command", "type": "class", "loc": [3, 7], "level": 0, "parent": null, "vector": [3, 0, 0.7143, 0.7143, 0, 0.66, 1.0, 73, 0, 1, 0, 0, 369, 0, 1], "semantic": {"name": "Command", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class Command(AppCommand):\n help = \"RENAMED: see 'sqlcustom'\"\n\n def handle(self, *apps, **options):\n raise CommandError(\"This command has been renamed. Use the 'sqlcustom' command instead.\")"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98889:Assign_L4_C4", "label": "help =", "type": "assigned_variable", "loc": [4, 4], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98889:ClassDef_L3_C0", "vector": [14, 1, 0.5714, 0.1429, 1, 0.62, 0.0, 868, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "help", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " help = \"RENAMED: see 'sqlcustom'\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98889:FunctionDef_L6_C4", "label": "handle", "type": "function", "loc": [6, 7], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98889:ClassDef_L3_C0", "vector": [2, 1, 0.9286, 0.2857, 1, 0.62, 1.0, 346, 0, 3, 0, 0, 0, 0, 1], "semantic": {"name": "handle", "arg_names": ["self", "apps", "options"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def handle(self, *apps, **options):\n raise CommandError(\"This command has been renamed. Use the 'sqlcustom' command instead.\")"}]
[{"f": "ajibawa-2023/Python-Code-Large/train/row_98889:ClassDef_L3_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98889:Assign_L4_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98889:ClassDef_L3_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98889:FunctionDef_L6_C4"}]
from optparse import make_option import os import sys from django.core.management.base import BaseCommand, CommandError from django.core.handlers.wsgi import WSGIHandler from django.core.servers.basehttp import AdminMediaHandler, run, WSGIServerException from django.utils import autoreload class BaseRunserverCommand(BaseCommand): option_list = BaseCommand.option_list + ( make_option('--noreload', action='store_false', dest='use_reloader', default=True, help='Tells Django to NOT use the auto-reloader.'), ) help = "Starts a lightweight Web server for development." args = '[optional port number, or ipaddr:port]' # Validation is called explicitly each time the server is reloaded. requires_model_validation = False def get_handler(self, *args, **options): """ Returns the default WSGI handler for the runner. """ return WSGIHandler() def handle(self, addrport='', *args, **options): if args: raise CommandError('Usage is runserver %s' % self.args) if not addrport: self.addr = '' self.port = '8000' else: try: self.addr, self.port = addrport.split(':') except ValueError: self.addr, self.port = '', addrport if not self.addr: self.addr = '127.0.0.1' if not self.port.isdigit(): raise CommandError("%r is not a valid port number." % self.port) self.run(*args, **options) def run(self, *args, **options): """ Runs the server, using the autoreloader if needed """ use_reloader = options.get('use_reloader', True) if use_reloader: autoreload.main(self.inner_run, args, options) else: self.inner_run(*args, **options) def inner_run(self, *args, **options): from django.conf import settings from django.utils import translation shutdown_message = options.get('shutdown_message', '') quit_command = (sys.platform == 'win32') and 'CTRL-BREAK' or 'CONTROL-C' self.stdout.write("Validating models...\n\n") self.validate(display_num_errors=True) self.stdout.write(( "Django version %(version)s, using settings %(settings)r\n" "Development server is running at http://%(addr)s:%(port)s/\n" "Quit the server with %(quit_command)s.\n" ) % { "version": self.get_version(), "settings": settings.SETTINGS_MODULE, "addr": self.addr, "port": self.port, "quit_command": quit_command, }) # django.core.management.base forces the locale to en-us. We should # set it up correctly for the first request (particularly important # in the "--noreload" case). translation.activate(settings.LANGUAGE_CODE) try: handler = self.get_handler(*args, **options) run(self.addr, int(self.port), handler) except WSGIServerException, e: # Use helpful error messages instead of ugly tracebacks. ERRORS = { 13: "You don't have permission to access that port.", 98: "That port is already in use.", 99: "That IP address can't be assigned-to.", } try: error_text = ERRORS[e.args[0].args[0]] except (AttributeError, KeyError): error_text = str(e) sys.stderr.write(self.style.ERROR("Error: %s" % error_text) + '\n') # Need to use an OS exit because sys.exit doesn't work in a thread os._exit(1) except KeyboardInterrupt: if shutdown_message: self.stdout.write("%s\n" % shutdown_message) sys.exit(0) class Command(BaseRunserverCommand): option_list = BaseRunserverCommand.option_list + ( make_option('--adminmedia', dest='admin_media_path', default='', help='Specifies the directory from which to serve admin media.'), ) def get_handler(self, *args, **options): """ Serves admin media like old-school (deprecation pending). """ handler = super(Command, self).get_handler(*args, **options) return AdminMediaHandler(handler, options.get('admin_media_path', ''))
ajibawa-2023/Python-Code-Large/train/row_98890
60
114
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_98890:ImportFrom_L1_C0", "label": "from optparse import make_option", "type": "import", "loc": [1, 1], "level": 0, "parent": null, "vector": [1, 0, 0.0088, 0.0088, 0, 0.66, 0.0, 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_98890:Import_L2_C0", "label": "os import os", "type": "import", "loc": [2, 2], "level": 0, "parent": null, "vector": [1, 0, 0.0175, 0.0088, 0, 0.66, 0.125, 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_98890:Import_L3_C0", "label": "sys import sys", "type": "import", "loc": [3, 3], "level": 0, "parent": null, "vector": [1, 0, 0.0263, 0.0088, 0, 0.66, 0.25, 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_98890:ImportFrom_L5_C0", "label": "from django.core.management.base import BaseCommand, CommandError", "type": "import", "loc": [5, 5], "level": 0, "parent": null, "vector": [1, 0, 0.0439, 0.0088, 0, 0.66, 0.375, 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_98890:ImportFrom_L6_C0", "label": "from django.core.handlers.wsgi import WSGIHandler", "type": "import", "loc": [6, 6], "level": 0, "parent": null, "vector": [1, 0, 0.0526, 0.0088, 0, 0.66, 0.5, 643, 0, 1, 0, 0, 643, 0, 0], "semantic": {"name": "django.core.handlers.wsgi", "arg_names": [], "import_names": ["WSGIHandler"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.core.handlers.wsgi import WSGIHandler"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98890:ImportFrom_L7_C0", "label": "from django.core.servers.basehttp import AdminMediaHandler, run, WSGIServerException", "type": "import", "loc": [7, 7], "level": 0, "parent": null, "vector": [1, 0, 0.0614, 0.0088, 0, 0.66, 0.625, 900, 0, 3, 0, 0, 900, 0, 0], "semantic": {"name": "django.core.servers.basehttp", "arg_names": [], "import_names": ["AdminMediaHandler", "run", "WSGIServerException"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.core.servers.basehttp import AdminMediaHandler, run, WSGIServerException"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98890:ImportFrom_L8_C0", "label": "from django.utils import autoreload", "type": "import", "loc": [8, 8], "level": 0, "parent": null, "vector": [1, 0, 0.0702, 0.0088, 0, 0.66, 0.75, 944, 0, 1, 0, 0, 944, 0, 0], "semantic": {"name": "django.utils", "arg_names": [], "import_names": ["autoreload"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.utils import autoreload"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98890:ClassDef_L10_C0", "label": "BaseRunserverCommand", "type": "class", "loc": [10, 101], "level": 0, "parent": null, "vector": [3, 0, 0.4868, 0.807, 0, 0.66, 0.875, 672, 0, 4, 0, 0, 564, 0, 25], "semantic": {"name": "BaseRunserverCommand", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class BaseRunserverCommand(BaseCommand):\n option_list = BaseCommand.option_list + (\n make_option('--noreload', action='store_false', dest='use_reloader', default=True,\n help='Tells Django to NOT use the auto-reloader.'),\n )\n help = \"Starts a lightweight Web server for development.\"\n args = '[optional port number, or ipaddr:port]'\n"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98890:Assign_L11_C4", "label": "option_list =", "type": "assigned_variable", "loc": [11, 14], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98890:ClassDef_L10_C0", "vector": [14, 1, 0.1096, 0.0351, 1, 0.46, 0.0, 318, 4, 0, 0, 0, 0, 0, 1], "semantic": {"name": "option_list", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " option_list = BaseCommand.option_list + (\n make_option('--noreload', action='store_false', dest='use_reloader', default=True,\n help='Tells Django to NOT use the auto-reloader.'),\n )"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98890:Assign_L15_C4", "label": "help =", "type": "assigned_variable", "loc": [15, 15], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98890:ClassDef_L10_C0", "vector": [14, 1, 0.1316, 0.0088, 1, 0.46, 0.1429, 868, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "help", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " help = \"Starts a lightweight Web server for development.\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98890:Assign_L16_C4", "label": "args =", "type": "assigned_variable", "loc": [16, 16], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98890:ClassDef_L10_C0", "vector": [14, 1, 0.1404, 0.0088, 1, 0.46, 0.2857, 805, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "args", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " args = '[optional port number, or ipaddr:port]'"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98890:Assign_L19_C4", "label": "requires_model_validation =", "type": "assigned_variable", "loc": [19, 19], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98890:ClassDef_L10_C0", "vector": [14, 1, 0.1667, 0.0088, 1, 0.46, 0.4286, 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_98890:FunctionDef_L21_C4", "label": "get_handler", "type": "function", "loc": [21, 25], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98890:ClassDef_L10_C0", "vector": [2, 1, 0.2018, 0.0439, 1, 0.46, 0.5714, 636, 0, 3, 1, 0, 0, 0, 1], "semantic": {"name": "get_handler", "arg_names": ["self", "args", "options"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def get_handler(self, *args, **options):\n \"\"\"\n Returns the default WSGI handler for the runner.\n \"\"\"\n return WSGIHandler()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98890:Expr_L22_C8", "label": "expression", "type": "expression", "loc": [22, 24], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98890:FunctionDef_L21_C4", "vector": [8, 2, 0.2018, 0.0263, 2, 0.25, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"\n Returns the default WSGI handler for the runner.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98890:Return_L25_C8", "label": "return", "type": "return", "loc": [25, 25], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98890:FunctionDef_L21_C4", "vector": [13, 2, 0.2193, 0.0088, 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 WSGIHandler()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98890:FunctionDef_L27_C4", "label": "handle", "type": "function", "loc": [27, 44], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98890:ClassDef_L10_C0", "vector": [2, 1, 0.3114, 0.1579, 1, 0.46, 0.7143, 346, 0, 4, 0, 0, 0, 0, 5], "semantic": {"name": "handle", "arg_names": ["self", "addrport", "args", "options"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def handle(self, addrport='', *args, **options):\n if args:\n raise CommandError('Usage is runserver %s' % self.args)\n if not addrport:\n self.addr = ''\n self.port = '8000'\n else:\n try:"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98890:If_L28_C8", "label": "if", "type": "if", "loc": [28, 29], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98890:FunctionDef_L27_C4", "vector": [4, 2, 0.25, 0.0175, 2, 0.38, 0.0, 0, 2, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if args:\n raise CommandError('Usage is runserver %s' % self.args)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98890:If_L30_C8", "label": "if", "type": "if", "loc": [30, 37], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98890:FunctionDef_L27_C4", "vector": [4, 2, 0.2939, 0.0702, 2, 0.38, 0.25, 0, 0, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if not addrport:\n self.addr = ''\n self.port = '8000'\n else:\n try:\n self.addr, self.port = addrport.split(':')\n except ValueError:\n self.addr, self.port = '', addrport"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98890:Assign_L31_C12", "label": "self.addr =", "type": "assigned_variable", "loc": [31, 31], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98890:If_L30_C8", "vector": [14, 3, 0.2719, 0.0088, 3, 0.48, 0.0, 895, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "self.addr", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.addr = ''"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98890:Assign_L32_C12", "label": "self.port =", "type": "assigned_variable", "loc": [32, 32], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98890:If_L30_C8", "vector": [14, 3, 0.2807, 0.0088, 3, 0.48, 0.5, 435, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "self.port", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.port = '8000'"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98890:Try_L34_C12", "label": "try", "type": "try", "loc": [34, 37], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98890:If_L30_C8", "vector": [7, 3, 0.3114, 0.0351, 3, 0.48, 1.0, 0, 0, 1, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " try:\n self.addr, self.port = addrport.split(':')\n except ValueError:\n self.addr, self.port = '', addrport"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98890:Assign_L35_C16", "label": " = split()", "type": "assigned_variable", "loc": [35, 35], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98890:Try_L34_C12", "vector": [14, 4, 0.307, 0.0088, 4, 0.48, 0.0, 0, 3, 1, 0, 0, 908, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "split", "annotation": ""}, "snippet": " self.addr, self.port = addrport.split(':')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98890:Assign_L37_C16", "label": "assign", "type": "assigned_variable", "loc": [37, 37], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98890:Try_L34_C12", "vector": [14, 4, 0.3246, 0.0088, 4, 0.48, 0.0, 0, 0, 0, 0, 0, 0, 8, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.addr, self.port = '', addrport"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98890:If_L38_C8", "label": "if", "type": "if", "loc": [38, 39], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98890:FunctionDef_L27_C4", "vector": [4, 2, 0.3377, 0.0175, 2, 0.38, 0.5, 0, 0, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if not self.addr:\n self.addr = '127.0.0.1'"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98890:Assign_L39_C12", "label": "self.addr =", "type": "assigned_variable", "loc": [39, 39], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98890:If_L38_C8", "vector": [14, 3, 0.3421, 0.0088, 3, 0.12, 0.0, 895, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "self.addr", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.addr = '127.0.0.1'"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98890:If_L41_C8", "label": "if", "type": "if", "loc": [41, 42], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98890:FunctionDef_L27_C4", "vector": [4, 2, 0.364, 0.0175, 2, 0.38, 0.75, 0, 0, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if not self.port.isdigit():\n raise CommandError(\"%r is not a valid port number.\" % self.port)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98890:Expr_L44_C8", "label": "run()", "type": "expression", "loc": [44, 44], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98890:FunctionDef_L27_C4", "vector": [8, 2, 0.386, 0.0088, 2, 0.38, 1.0, 679, 3, 2, 0, 0, 0, 0, 1], "semantic": {"name": "run", "arg_names": [], "import_names": [], "rhs_call_name": "run", "annotation": ""}, "snippet": " self.run(*args, **options)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98890:FunctionDef_L46_C4", "label": "run", "type": "function", "loc": [46, 55], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98890:ClassDef_L10_C0", "vector": [2, 1, 0.443, 0.0877, 1, 0.46, 0.8571, 679, 0, 3, 0, 0, 0, 0, 3], "semantic": {"name": "run", "arg_names": ["self", "args", "options"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def run(self, *args, **options):\n \"\"\"\n Runs the server, using the autoreloader if needed\n \"\"\"\n use_reloader = options.get('use_reloader', True)\n\n if use_reloader:\n autoreload.main(self.inner_run, args, options)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98890:Expr_L47_C8", "label": "expression", "type": "expression", "loc": [47, 49], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98890:FunctionDef_L46_C4", "vector": [8, 2, 0.4211, 0.0263, 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 Runs the server, using the autoreloader if needed\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98890:Assign_L50_C8", "label": "use_reloader = get()", "type": "assigned_variable", "loc": [50, 50], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98890:FunctionDef_L46_C4", "vector": [14, 2, 0.4386, 0.0088, 2, 0.31, 0.5, 778, 3, 2, 0, 0, 607, 10, 1], "semantic": {"name": "use_reloader", "arg_names": [], "import_names": [], "rhs_call_name": "get", "annotation": ""}, "snippet": " use_reloader = options.get('use_reloader', True)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98890:If_L52_C8", "label": "if", "type": "if", "loc": [52, 55], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98890:FunctionDef_L46_C4", "vector": [4, 2, 0.4693, 0.0351, 2, 0.31, 1.0, 0, 2, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if use_reloader:\n autoreload.main(self.inner_run, args, options)\n else:\n self.inner_run(*args, **options)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98890:Expr_L53_C12", "label": "main()", "type": "expression", "loc": [53, 53], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98890:If_L52_C8", "vector": [8, 3, 0.4649, 0.0088, 3, 0.77, 0.0, 624, 3, 3, 0, 0, 0, 0, 1], "semantic": {"name": "main", "arg_names": [], "import_names": [], "rhs_call_name": "main", "annotation": ""}, "snippet": " autoreload.main(self.inner_run, args, options)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98890:Expr_L55_C12", "label": "inner_run()", "type": "expression", "loc": [55, 55], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98890:If_L52_C8", "vector": [8, 3, 0.4825, 0.0088, 3, 0.77, 1.0, 802, 3, 2, 0, 0, 0, 0, 1], "semantic": {"name": "inner_run", "arg_names": [], "import_names": [], "rhs_call_name": "inner_run", "annotation": ""}, "snippet": " self.inner_run(*args, **options)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98890:FunctionDef_L57_C4", "label": "inner_run", "type": "function", "loc": [57, 101], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98890:ClassDef_L10_C0", "vector": [2, 1, 0.693, 0.3947, 1, 0.46, 1.0, 802, 0, 3, 0, 0, 0, 0, 15], "semantic": {"name": "inner_run", "arg_names": ["self", "args", "options"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def inner_run(self, *args, **options):\n from django.conf import settings\n from django.utils import translation\n\n shutdown_message = options.get('shutdown_message', '')\n quit_command = (sys.platform == 'win32') and 'CTRL-BREAK' or 'CONTROL-C'\n\n self.stdout.write(\"Validating models...\\n\\n\")"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98890:ImportFrom_L58_C8", "label": "from django.conf import settings", "type": "import", "loc": [58, 58], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98890:FunctionDef_L57_C4", "vector": [1, 2, 0.5088, 0.0088, 2, 0.62, 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_98890:ImportFrom_L59_C8", "label": "from django.utils import translation", "type": "import", "loc": [59, 59], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98890:FunctionDef_L57_C4", "vector": [1, 2, 0.5175, 0.0088, 2, 0.62, 0.125, 944, 0, 1, 0, 0, 944, 0, 0], "semantic": {"name": "django.utils", "arg_names": [], "import_names": ["translation"], "rhs_call_name": "", "annotation": ""}, "snippet": " from django.utils import translation"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98890:Assign_L61_C8", "label": "shutdown_message = get()", "type": "assigned_variable", "loc": [61, 61], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98890:FunctionDef_L57_C4", "vector": [14, 2, 0.5351, 0.0088, 2, 0.62, 0.25, 690, 3, 2, 0, 0, 607, 10, 1], "semantic": {"name": "shutdown_message", "arg_names": [], "import_names": [], "rhs_call_name": "get", "annotation": ""}, "snippet": " shutdown_message = options.get('shutdown_message', '')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98890:Assign_L62_C8", "label": "quit_command =", "type": "assigned_variable", "loc": [62, 62], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98890:FunctionDef_L57_C4", "vector": [14, 2, 0.5439, 0.0088, 2, 0.62, 0.375, 764, 0, 0, 0, 0, 0, 0, 0], "semantic": {"name": "quit_command", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " quit_command = (sys.platform == 'win32') and 'CTRL-BREAK' or 'CONTROL-C'"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98890:Expr_L64_C8", "label": "write()", "type": "expression", "loc": [64, 64], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98890:FunctionDef_L57_C4", "vector": [8, 2, 0.5614, 0.0088, 2, 0.62, 0.5, 837, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "write", "arg_names": [], "import_names": [], "rhs_call_name": "write", "annotation": ""}, "snippet": " self.stdout.write(\"Validating models...\\n\\n\")"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98890:Expr_L65_C8", "label": "validate()", "type": "expression", "loc": [65, 65], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98890:FunctionDef_L57_C4", "vector": [8, 2, 0.5702, 0.0088, 2, 0.62, 0.625, 628, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "validate", "arg_names": [], "import_names": [], "rhs_call_name": "validate", "annotation": ""}, "snippet": " self.validate(display_num_errors=True)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98890:Expr_L66_C8", "label": "write()", "type": "expression", "loc": [66, 76], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98890:FunctionDef_L57_C4", "vector": [8, 2, 0.6228, 0.0965, 2, 0.62, 0.75, 837, 3, 1, 0, 0, 0, 0, 2], "semantic": {"name": "write", "arg_names": [], "import_names": [], "rhs_call_name": "write", "annotation": ""}, "snippet": " self.stdout.write((\n \"Django version %(version)s, using settings %(settings)r\\n\"\n \"Development server is running at http://%(addr)s:%(port)s/\\n\"\n \"Quit the server with %(quit_command)s.\\n\"\n ) % {\n \"version\": self.get_version(),\n \"settings\": settings.SETTINGS_MODULE,\n \"addr\": self.addr,"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98890:Expr_L80_C8", "label": "activate()", "type": "expression", "loc": [80, 80], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98890:FunctionDef_L57_C4", "vector": [8, 2, 0.7018, 0.0088, 2, 0.62, 0.875, 177, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "activate", "arg_names": [], "import_names": [], "rhs_call_name": "activate", "annotation": ""}, "snippet": " translation.activate(settings.LANGUAGE_CODE)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98890:Try_L82_C8", "label": "try", "type": "try", "loc": [82, 101], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98890:FunctionDef_L57_C4", "vector": [7, 2, 0.8026, 0.1754, 2, 0.62, 1.0, 0, 0, 1, 0, 0, 0, 0, 9], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " try:\n handler = self.get_handler(*args, **options)\n run(self.addr, int(self.port), handler)\n # Use helpful error messages instead of ugly tracebacks.\n ERRORS = {\n 13: \"You don't have permission to access that port.\",\n 98: \"That port is already in use.\",\n 99: \"That IP address can't be assigned-to.\","}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98890:Assign_L83_C12", "label": "handler = get_handler()", "type": "assigned_variable", "loc": [83, 83], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98890:Try_L82_C8", "vector": [14, 3, 0.7281, 0.0088, 3, 0.51, 0.0, 388, 3, 2, 0, 0, 636, 10, 1], "semantic": {"name": "handler", "arg_names": [], "import_names": [], "rhs_call_name": "get_handler", "annotation": ""}, "snippet": " handler = self.get_handler(*args, **options)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98890:Expr_L84_C12", "label": "run()", "type": "expression", "loc": [84, 84], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98890:Try_L82_C8", "vector": [8, 3, 0.7368, 0.0088, 3, 0.51, 0.2, 679, 3, 3, 0, 0, 0, 0, 2], "semantic": {"name": "run", "arg_names": [], "import_names": [], "rhs_call_name": "run", "annotation": ""}, "snippet": " run(self.addr, int(self.port), handler)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98890:Assign_L86_C12", "label": "ERRORS =", "type": "assigned_variable", "loc": [86, 90], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98890:Try_L82_C8", "vector": [14, 3, 0.7719, 0.0439, 3, 0.51, 0.4, 871, 0, 0, 0, 0, 0, 6, 0], "semantic": {"name": "ERRORS", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " ERRORS = {\n 13: \"You don't have permission to access that port.\",\n 98: \"That port is already in use.\",\n 99: \"That IP address can't be assigned-to.\",\n }"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98890:Try_L91_C12", "label": "try", "type": "try", "loc": [91, 94], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98890:Try_L82_C8", "vector": [7, 3, 0.8114, 0.0351, 3, 0.51, 0.6, 0, 0, 1, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " try:\n error_text = ERRORS[e.args[0].args[0]]\n except (AttributeError, KeyError):\n error_text = str(e)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98890:Assign_L92_C16", "label": "error_text =", "type": "assigned_variable", "loc": [92, 92], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98890:Try_L91_C12", "vector": [14, 4, 0.807, 0.0088, 4, 0.31, 0.0, 155, 6, 0, 0, 0, 0, 0, 0], "semantic": {"name": "error_text", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " error_text = ERRORS[e.args[0].args[0]]"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98890:Assign_L94_C16", "label": "error_text = str()", "type": "assigned_variable", "loc": [94, 94], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98890:Try_L91_C12", "vector": [14, 4, 0.8246, 0.0088, 4, 0.31, 0.0, 155, 3, 1, 0, 0, 52, 10, 1], "semantic": {"name": "error_text", "arg_names": [], "import_names": [], "rhs_call_name": "str", "annotation": ""}, "snippet": " error_text = str(e)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98890:Expr_L95_C12", "label": "write()", "type": "expression", "loc": [95, 95], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98890:Try_L82_C8", "vector": [8, 3, 0.8333, 0.0088, 3, 0.51, 0.8, 837, 3, 1, 0, 0, 0, 0, 2], "semantic": {"name": "write", "arg_names": [], "import_names": [], "rhs_call_name": "write", "annotation": ""}, "snippet": " sys.stderr.write(self.style.ERROR(\"Error: %s\" % error_text) + '\\n')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98890:Expr_L97_C12", "label": "_exit()", "type": "expression", "loc": [97, 97], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98890:Try_L82_C8", "vector": [8, 3, 0.8509, 0.0088, 3, 0.51, 1.0, 87, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "_exit", "arg_names": [], "import_names": [], "rhs_call_name": "_exit", "annotation": ""}, "snippet": " os._exit(1)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98890:If_L99_C12", "label": "if", "type": "if", "loc": [99, 100], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98890:Try_L82_C8", "vector": [4, 3, 0.8728, 0.0175, 3, 0.51, 0.0, 0, 2, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if shutdown_message:\n self.stdout.write(\"%s\\n\" % shutdown_message)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98890:Expr_L100_C16", "label": "write()", "type": "expression", "loc": [100, 100], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98890:If_L99_C12", "vector": [8, 4, 0.8772, 0.0088, 4, 0.14, 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(\"%s\\n\" % shutdown_message)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98890:Expr_L101_C12", "label": "exit()", "type": "expression", "loc": [101, 101], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98890:Try_L82_C8", "vector": [8, 3, 0.886, 0.0088, 3, 0.51, 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(0)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98890:ClassDef_L103_C0", "label": "Command", "type": "class", "loc": [103, 114], "level": 0, "parent": null, "vector": [3, 0, 0.9518, 0.1053, 0, 0.66, 1.0, 73, 0, 1, 0, 0, 672, 0, 5], "semantic": {"name": "Command", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class Command(BaseRunserverCommand):\n option_list = BaseRunserverCommand.option_list + (\n make_option('--adminmedia', dest='admin_media_path', default='',\n help='Specifies the directory from which to serve admin media.'),\n )\n\n def get_handler(self, *args, **options):\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98890:Assign_L104_C4", "label": "option_list =", "type": "assigned_variable", "loc": [104, 107], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98890:ClassDef_L103_C0", "vector": [14, 1, 0.9254, 0.0351, 1, 0.89, 0.0, 318, 4, 0, 0, 0, 0, 0, 1], "semantic": {"name": "option_list", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " option_list = BaseRunserverCommand.option_list + (\n make_option('--adminmedia', dest='admin_media_path', default='',\n help='Specifies the directory from which to serve admin media.'),\n )"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98890:FunctionDef_L109_C4", "label": "get_handler", "type": "function", "loc": [109, 114], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98890:ClassDef_L103_C0", "vector": [2, 1, 0.9781, 0.0526, 1, 0.89, 1.0, 636, 0, 3, 1, 0, 0, 0, 4], "semantic": {"name": "get_handler", "arg_names": ["self", "args", "options"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def get_handler(self, *args, **options):\n \"\"\"\n Serves admin media like old-school (deprecation pending).\n \"\"\"\n handler = super(Command, self).get_handler(*args, **options)\n return AdminMediaHandler(handler, options.get('admin_media_path', ''))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98890:Expr_L110_C8", "label": "expression", "type": "expression", "loc": [110, 112], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98890:FunctionDef_L109_C4", "vector": [8, 2, 0.9737, 0.0263, 2, 0.33, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"\n Serves admin media like old-school (deprecation pending).\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98890:Assign_L113_C8", "label": "handler = get_handler()", "type": "assigned_variable", "loc": [113, 113], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98890:FunctionDef_L109_C4", "vector": [14, 2, 0.9912, 0.0088, 2, 0.33, 0.5, 388, 3, 2, 0, 0, 636, 10, 2], "semantic": {"name": "handler", "arg_names": [], "import_names": [], "rhs_call_name": "get_handler", "annotation": ""}, "snippet": " handler = super(Command, self).get_handler(*args, **options)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98890:Return_L114_C8", "label": "return", "type": "return", "loc": [114, 114], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98890:FunctionDef_L109_C4", "vector": [13, 2, 1.0, 0.0088, 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 AdminMediaHandler(handler, options.get('admin_media_path', ''))"}]
[{"f": "ajibawa-2023/Python-Code-Large/train/row_98890:ClassDef_L10_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98890:Assign_L11_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98890:ClassDef_L10_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98890:Assign_L15_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98890:ClassDef_L10_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98890:Assign_L16_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98890:ClassDef_L10_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98890:Assign_L19_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98890:ClassDef_L10_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98890:FunctionDef_L21_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98890:FunctionDef_L21_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98890:Expr_L22_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98890:FunctionDef_L21_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98890:Return_L25_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98890:ClassDef_L10_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98890:FunctionDef_L27_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98890:FunctionDef_L27_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98890:If_L28_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98890:FunctionDef_L27_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98890:If_L30_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98890:If_L30_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98890:Assign_L31_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98890:If_L30_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98890:Assign_L32_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98890:If_L30_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98890:Try_L34_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98890:Try_L34_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98890:Assign_L35_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98890:Try_L34_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98890:Assign_L37_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98890:FunctionDef_L27_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98890:If_L38_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98890:If_L38_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98890:Assign_L39_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98890:FunctionDef_L27_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98890:If_L41_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98890:FunctionDef_L27_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98890:Expr_L44_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98890:ClassDef_L10_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98890:FunctionDef_L46_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98890:FunctionDef_L46_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98890:Expr_L47_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98890:FunctionDef_L46_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98890:Assign_L50_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98890:FunctionDef_L46_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98890:If_L52_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98890:If_L52_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98890:Expr_L53_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98890:If_L52_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98890:Expr_L55_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98890:ClassDef_L10_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98890:FunctionDef_L57_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98890:FunctionDef_L57_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98890:ImportFrom_L58_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98890:FunctionDef_L57_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98890:ImportFrom_L59_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98890:FunctionDef_L57_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98890:Assign_L61_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98890:FunctionDef_L57_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98890:Assign_L62_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98890:FunctionDef_L57_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98890:Expr_L64_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98890:FunctionDef_L57_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98890:Expr_L65_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98890:FunctionDef_L57_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98890:Expr_L66_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98890:FunctionDef_L57_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98890:Expr_L80_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98890:FunctionDef_L57_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98890:Try_L82_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98890:Try_L82_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98890:Assign_L83_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98890:Try_L82_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98890:Expr_L84_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98890:Try_L82_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98890:Assign_L86_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98890:Try_L82_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98890:Try_L91_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98890:Try_L91_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98890:Assign_L92_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98890:Try_L91_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98890:Assign_L94_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98890:Try_L82_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98890:Expr_L95_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98890:Try_L82_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98890:Expr_L97_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98890:Try_L82_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98890:If_L99_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98890:If_L99_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98890:Expr_L100_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98890:Try_L82_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98890:Expr_L101_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98890:ClassDef_L103_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98890:Assign_L104_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98890:ClassDef_L103_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98890:FunctionDef_L109_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98890:FunctionDef_L109_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98890:Expr_L110_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98890:FunctionDef_L109_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98890:Assign_L113_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98890:FunctionDef_L109_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98890:Return_L114_C8"}]
import datetime from django.core.management.base import NoArgsCommand class Command(NoArgsCommand): help = "Can be run as a cronjob or directly to clean out old data from the database (only expired sessions at the moment)." def handle_noargs(self, **options): from django.db import transaction from django.contrib.sessions.models import Session Session.objects.filter(expire_date__lt=datetime.datetime.now()).delete() transaction.commit_unless_managed()
ajibawa-2023/Python-Code-Large/train/row_98891
9
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_98891:Import_L1_C0", "label": "datetime import datetime", "type": "import", "loc": [1, 1], "level": 0, "parent": null, "vector": [1, 0, 0.0909, 0.0909, 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_98891:ImportFrom_L2_C0", "label": "from django.core.management.base import NoArgsCommand", "type": "import", "loc": [2, 2], "level": 0, "parent": null, "vector": [1, 0, 0.1818, 0.0909, 0, 0.66, 0.5, 931, 0, 1, 0, 0, 931, 0, 0], "semantic": {"name": "django.core.management.base", "arg_names": [], "import_names": ["NoArgsCommand"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.core.management.base import NoArgsCommand"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98891:ClassDef_L4_C0", "label": "Command", "type": "class", "loc": [4, 11], "level": 0, "parent": null, "vector": [3, 0, 0.6818, 0.7273, 0, 0.66, 1.0, 73, 0, 1, 0, 0, 795, 0, 4], "semantic": {"name": "Command", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class Command(NoArgsCommand):\n help = \"Can be run as a cronjob or directly to clean out old data from the database (only expired sessions at the moment).\"\n\n def handle_noargs(self, **options):\n from django.db import transaction\n from django.contrib.sessions.models import Session\n Session.objects.filter(expire_date__lt=datetime.datetime.now()).delete()\n transaction.commit_unless_managed()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98891:Assign_L5_C4", "label": "help =", "type": "assigned_variable", "loc": [5, 5], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98891:ClassDef_L4_C0", "vector": [14, 1, 0.4545, 0.0909, 1, 0.46, 0.0, 868, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "help", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " help = \"Can be run as a cronjob or directly to clean out old data from the database (only expired sessions at the moment).\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98891:FunctionDef_L7_C4", "label": "handle_noargs", "type": "function", "loc": [7, 11], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98891:ClassDef_L4_C0", "vector": [2, 1, 0.8182, 0.4545, 1, 0.46, 1.0, 28, 0, 2, 0, 0, 0, 0, 4], "semantic": {"name": "handle_noargs", "arg_names": ["self", "options"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def handle_noargs(self, **options):\n from django.db import transaction\n from django.contrib.sessions.models import Session\n Session.objects.filter(expire_date__lt=datetime.datetime.now()).delete()\n transaction.commit_unless_managed()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98891:ImportFrom_L8_C8", "label": "from django.db import transaction", "type": "import", "loc": [8, 8], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98891:FunctionDef_L7_C4", "vector": [1, 2, 0.7273, 0.0909, 2, 0.45, 0.0, 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_98891:ImportFrom_L9_C8", "label": "from django.contrib.sessions.models import Session", "type": "import", "loc": [9, 9], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98891:FunctionDef_L7_C4", "vector": [1, 2, 0.8182, 0.0909, 2, 0.45, 0.3333, 800, 0, 1, 0, 0, 800, 0, 0], "semantic": {"name": "django.contrib.sessions.models", "arg_names": [], "import_names": ["Session"], "rhs_call_name": "", "annotation": ""}, "snippet": " from django.contrib.sessions.models import Session"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98891:Expr_L10_C8", "label": "delete()", "type": "expression", "loc": [10, 10], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98891:FunctionDef_L7_C4", "vector": [8, 2, 0.9091, 0.0909, 2, 0.45, 0.6667, 266, 3, 0, 0, 0, 0, 0, 3], "semantic": {"name": "delete", "arg_names": [], "import_names": [], "rhs_call_name": "delete", "annotation": ""}, "snippet": " Session.objects.filter(expire_date__lt=datetime.datetime.now()).delete()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98891:Expr_L11_C8", "label": "commit_unless_managed()", "type": "expression", "loc": [11, 11], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98891:FunctionDef_L7_C4", "vector": [8, 2, 1.0, 0.0909, 2, 0.45, 1.0, 431, 3, 0, 0, 0, 0, 0, 1], "semantic": {"name": "commit_unless_managed", "arg_names": [], "import_names": [], "rhs_call_name": "commit_unless_managed", "annotation": ""}, "snippet": " transaction.commit_unless_managed()"}]
[{"f": "ajibawa-2023/Python-Code-Large/train/row_98891:ClassDef_L4_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98891:Assign_L5_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98891:ClassDef_L4_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98891:FunctionDef_L7_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98891:FunctionDef_L7_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98891:ImportFrom_L8_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98891:FunctionDef_L7_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98891:ImportFrom_L9_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98891:FunctionDef_L7_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98891:Expr_L10_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98891:FunctionDef_L7_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98891:Expr_L11_C8"}]
import os import re from django.conf import settings from django.core.management.base import CommandError from django.db import models from django.db.models import get_models def sql_create(app, style, connection): "Returns a list of the CREATE TABLE SQL statements for the given app." if connection.settings_dict['ENGINE'] == 'django.db.backends.dummy': # This must be the "dummy" database backend, which means the user # hasn't set ENGINE for the databse. raise CommandError("Django doesn't know which syntax to use for your SQL statements,\n" + "because you haven't specified the ENGINE setting for the database.\n" + "Edit your settings file and change DATBASES['default']['ENGINE'] to something like\n" + "'django.db.backends.postgresql' or 'django.db.backends.mysql'.") # Get installed models, so we generate REFERENCES right. # We trim models from the current app so that the sqlreset command does not # generate invalid SQL (leaving models out of known_models is harmless, so # we can be conservative). app_models = models.get_models(app, include_auto_created=True) final_output = [] tables = connection.introspection.table_names() known_models = set([model for model in connection.introspection.installed_models(tables) if model not in app_models]) pending_references = {} for model in app_models: output, references = connection.creation.sql_create_model(model, style, known_models) final_output.extend(output) for refto, refs in references.items(): pending_references.setdefault(refto, []).extend(refs) if refto in known_models: final_output.extend(connection.creation.sql_for_pending_references(refto, style, pending_references)) final_output.extend(connection.creation.sql_for_pending_references(model, style, pending_references)) # Keep track of the fact that we've created the table for this model. known_models.add(model) # Handle references to tables that are from other apps # but don't exist physically. not_installed_models = set(pending_references.keys()) if not_installed_models: alter_sql = [] for model in not_installed_models: alter_sql.extend(['-- ' + sql for sql in connection.creation.sql_for_pending_references(model, style, pending_references)]) if alter_sql: final_output.append('-- The following references should be added but depend on non-existent tables:') final_output.extend(alter_sql) return final_output def sql_delete(app, style, connection): "Returns a list of the DROP TABLE SQL statements for the given app." # This should work even if a connection isn't available try: cursor = connection.cursor() except: cursor = None # Figure out which tables already exist if cursor: table_names = connection.introspection.get_table_list(cursor) else: table_names = [] output = [] # Output DROP TABLE statements for standard application tables. to_delete = set() references_to_delete = {} app_models = models.get_models(app, include_auto_created=True) for model in app_models: if cursor and connection.introspection.table_name_converter(model._meta.db_table) in table_names: # The table exists, so it needs to be dropped opts = model._meta for f in opts.local_fields: if f.rel and f.rel.to not in to_delete: references_to_delete.setdefault(f.rel.to, []).append( (model, f) ) to_delete.add(model) for model in app_models: if connection.introspection.table_name_converter(model._meta.db_table) in table_names: output.extend(connection.creation.sql_destroy_model(model, references_to_delete, style)) # Close database connection explicitly, in case this output is being piped # directly into a database client, to avoid locking issues. if cursor: cursor.close() connection.close() return output[::-1] # Reverse it, to deal with table dependencies. def sql_reset(app, style, connection): "Returns a list of the DROP TABLE SQL, then the CREATE TABLE SQL, for the given module." return sql_delete(app, style, connection) + sql_all(app, style, connection) def sql_flush(style, connection, only_django=False): """ Returns a list of the SQL statements used to flush the database. If only_django is True, then only table names that have associated Django models and are in INSTALLED_APPS will be included. """ if only_django: tables = connection.introspection.django_table_names(only_existing=True) else: tables = connection.introspection.table_names() statements = connection.ops.sql_flush( style, tables, connection.introspection.sequence_list() ) return statements def sql_custom(app, style, connection): "Returns a list of the custom table modifying SQL statements for the given app." output = [] app_models = get_models(app) app_dir = os.path.normpath(os.path.join(os.path.dirname(app.__file__), 'sql')) for model in app_models: output.extend(custom_sql_for_model(model, style, connection)) return output def sql_indexes(app, style, connection): "Returns a list of the CREATE INDEX SQL statements for all models in the given app." output = [] for model in models.get_models(app): output.extend(connection.creation.sql_indexes_for_model(model, style)) return output def sql_all(app, style, connection): "Returns a list of CREATE TABLE SQL, initial-data inserts, and CREATE INDEX SQL for the given module." return sql_create(app, style, connection) + sql_custom(app, style, connection) + sql_indexes(app, style, connection) def custom_sql_for_model(model, style, connection): opts = model._meta app_dir = os.path.normpath(os.path.join(os.path.dirname(models.get_app(model._meta.app_label).__file__), 'sql')) output = [] # Post-creation SQL should come before any initial SQL data is loaded. # However, this should not be done for models that are unmanaged or # for fields that are part of a parent model (via model inheritance). if opts.managed: post_sql_fields = [f for f in opts.local_fields if hasattr(f, 'post_create_sql')] for f in post_sql_fields: output.extend(f.post_create_sql(style, model._meta.db_table)) # Some backends can't execute more than one SQL statement at a time, # so split into separate statements. statements = re.compile(r";[ \t]*$", re.M) # Find custom SQL, if it's available. backend_name = connection.settings_dict['ENGINE'].split('.')[-1] sql_files = [os.path.join(app_dir, "%s.%s.sql" % (opts.object_name.lower(), backend_name)), os.path.join(app_dir, "%s.sql" % opts.object_name.lower())] for sql_file in sql_files: if os.path.exists(sql_file): fp = open(sql_file, 'U') for statement in statements.split(fp.read().decode(settings.FILE_CHARSET)): # Remove any comments from the file statement = re.sub(ur"--.*([\n\Z]|$)", "", statement) if statement.strip(): output.append(statement + u";") fp.close() return output def emit_post_sync_signal(created_models, verbosity, interactive, db): # Emit the post_sync signal for every application. for app in models.get_apps(): app_name = app.__name__.split('.')[-2] if verbosity >= 2: print "Running post-sync handlers for application", app_name models.signals.post_syncdb.send(sender=app, app=app, created_models=created_models, verbosity=verbosity, interactive=interactive, db=db)
ajibawa-2023/Python-Code-Large/train/row_98892
110
183
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_98892:Import_L1_C0", "label": "os import os", "type": "import", "loc": [1, 1], "level": 0, "parent": null, "vector": [1, 0, 0.0055, 0.0055, 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_98892:Import_L2_C0", "label": "re import re", "type": "import", "loc": [2, 2], "level": 0, "parent": null, "vector": [1, 0, 0.0109, 0.0055, 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_98892:ImportFrom_L4_C0", "label": "from django.conf import settings", "type": "import", "loc": [4, 4], "level": 0, "parent": null, "vector": [1, 0, 0.0219, 0.0055, 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_98892:ImportFrom_L5_C0", "label": "from django.core.management.base import CommandError", "type": "import", "loc": [5, 5], "level": 0, "parent": null, "vector": [1, 0, 0.0273, 0.0055, 0, 0.66, 0.2143, 931, 0, 1, 0, 0, 931, 0, 0], "semantic": {"name": "django.core.management.base", "arg_names": [], "import_names": ["CommandError"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.core.management.base import CommandError"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98892:ImportFrom_L6_C0", "label": "from django.db import models", "type": "import", "loc": [6, 6], "level": 0, "parent": null, "vector": [1, 0, 0.0328, 0.0055, 0, 0.66, 0.2857, 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_98892:ImportFrom_L7_C0", "label": "from django.db.models import get_models", "type": "import", "loc": [7, 7], "level": 0, "parent": null, "vector": [1, 0, 0.0383, 0.0055, 0, 0.66, 0.3571, 680, 0, 1, 0, 0, 680, 0, 0], "semantic": {"name": "django.db.models", "arg_names": [], "import_names": ["get_models"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.db.models import get_models"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98892:FunctionDef_L9_C0", "label": "sql_create", "type": "function", "loc": [9, 53], "level": 0, "parent": null, "vector": [2, 0, 0.1694, 0.2459, 0, 0.66, 0.4286, 647, 0, 3, 1, 0, 0, 0, 21], "semantic": {"name": "sql_create", "arg_names": ["app", "style", "connection"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "def sql_create(app, style, connection):\n \"Returns a list of the CREATE TABLE SQL statements for the given app.\"\n\n if connection.settings_dict['ENGINE'] == 'django.db.backends.dummy':\n # This must be the \"dummy\" database backend, which means the user\n # hasn't set ENGINE for the databse.\n raise CommandError(\"Django doesn't know which syntax to use for your SQL statements,\\n\" +\n \"because you haven't specified the ENGINE setting for the database.\\n\" +"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98892:Expr_L10_C4", "label": "expression", "type": "expression", "loc": [10, 10], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98892:FunctionDef_L9_C0", "vector": [8, 1, 0.0546, 0.0055, 1, 0.52, 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 the CREATE TABLE SQL statements for the given app.\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98892:If_L12_C4", "label": "if", "type": "if", "loc": [12, 18], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98892:FunctionDef_L9_C0", "vector": [4, 1, 0.082, 0.0383, 1, 0.52, 0.1, 0, 0, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if connection.settings_dict['ENGINE'] == 'django.db.backends.dummy':\n # This must be the \"dummy\" database backend, which means the user\n # hasn't set ENGINE for the databse.\n raise CommandError(\"Django doesn't know which syntax to use for your SQL statements,\\n\" +\n \"because you haven't specified the ENGINE setting for the database.\\n\" +\n \"Edit your settings file and change DATBASES['default']['ENGINE'] to something like\\n\" +\n \"'django.db.backends.postgresql' or 'django.db.backends.mysql'.\")"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98892:Assign_L24_C4", "label": "app_models = get_models()", "type": "assigned_variable", "loc": [24, 24], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98892:FunctionDef_L9_C0", "vector": [14, 1, 0.1311, 0.0055, 1, 0.52, 0.2, 621, 3, 2, 0, 0, 404, 10, 1], "semantic": {"name": "app_models", "arg_names": [], "import_names": [], "rhs_call_name": "get_models", "annotation": ""}, "snippet": " app_models = models.get_models(app, include_auto_created=True)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98892:Assign_L25_C4", "label": "final_output =", "type": "assigned_variable", "loc": [25, 25], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98892:FunctionDef_L9_C0", "vector": [14, 1, 0.1366, 0.0055, 1, 0.52, 0.3, 329, 0, 0, 0, 0, 0, 5, 0], "semantic": {"name": "final_output", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " final_output = []"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98892:Assign_L26_C4", "label": "tables = table_names()", "type": "assigned_variable", "loc": [26, 26], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98892:FunctionDef_L9_C0", "vector": [14, 1, 0.1421, 0.0055, 1, 0.52, 0.4, 475, 3, 0, 0, 0, 480, 10, 1], "semantic": {"name": "tables", "arg_names": [], "import_names": [], "rhs_call_name": "table_names", "annotation": ""}, "snippet": " tables = connection.introspection.table_names()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98892:Assign_L27_C4", "label": "known_models = set()", "type": "assigned_variable", "loc": [27, 27], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98892:FunctionDef_L9_C0", "vector": [14, 1, 0.1475, 0.0055, 1, 0.52, 0.5, 297, 3, 1, 0, 0, 21, 10, 2], "semantic": {"name": "known_models", "arg_names": [], "import_names": [], "rhs_call_name": "set", "annotation": ""}, "snippet": " known_models = set([model for model in connection.introspection.installed_models(tables) if model not in app_models])"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98892:Assign_L28_C4", "label": "pending_references =", "type": "assigned_variable", "loc": [28, 28], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98892:FunctionDef_L9_C0", "vector": [14, 1, 0.153, 0.0055, 1, 0.52, 0.6, 225, 0, 0, 0, 0, 0, 6, 0], "semantic": {"name": "pending_references", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " pending_references = {}"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98892:For_L30_C4", "label": "for model", "type": "for", "loc": [30, 39], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98892:FunctionDef_L9_C0", "vector": [6, 1, 0.1885, 0.0546, 1, 0.52, 0.7, 722, 2, 0, 0, 0, 0, 0, 10], "semantic": {"name": "model", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for model in app_models:\n output, references = connection.creation.sql_create_model(model, style, known_models)\n final_output.extend(output)\n for refto, refs in references.items():\n pending_references.setdefault(refto, []).extend(refs)\n if refto in known_models:\n final_output.extend(connection.creation.sql_for_pending_references(refto, style, pending_references))\n final_output.extend(connection.creation.sql_for_pending_references(model, style, pending_references))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98892:Assign_L31_C8", "label": "output, references = sql_create_model()", "type": "assigned_variable", "loc": [31, 31], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98892:For_L30_C4", "vector": [14, 2, 0.1694, 0.0055, 2, 0.49, 0.0, 403, 3, 3, 0, 0, 237, 10, 1], "semantic": {"name": "output, references", "arg_names": [], "import_names": [], "rhs_call_name": "sql_create_model", "annotation": ""}, "snippet": " output, references = connection.creation.sql_create_model(model, style, known_models)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98892:Expr_L32_C8", "label": "extend()", "type": "expression", "loc": [32, 32], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98892:For_L30_C4", "vector": [8, 2, 0.1749, 0.0055, 2, 0.49, 0.25, 660, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "extend", "arg_names": [], "import_names": [], "rhs_call_name": "extend", "annotation": ""}, "snippet": " final_output.extend(output)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98892:For_L33_C8", "label": "for refto, refs", "type": "for", "loc": [33, 36], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98892:For_L30_C4", "vector": [6, 2, 0.1885, 0.0219, 2, 0.49, 0.5, 63, 3, 0, 0, 0, 0, 0, 5], "semantic": {"name": "refto, refs", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for refto, refs in references.items():\n pending_references.setdefault(refto, []).extend(refs)\n if refto in known_models:\n final_output.extend(connection.creation.sql_for_pending_references(refto, style, pending_references))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98892:Expr_L34_C12", "label": "extend()", "type": "expression", "loc": [34, 34], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98892:For_L33_C8", "vector": [8, 3, 0.1858, 0.0055, 3, 0.08, 0.0, 660, 3, 1, 0, 0, 0, 0, 2], "semantic": {"name": "extend", "arg_names": [], "import_names": [], "rhs_call_name": "extend", "annotation": ""}, "snippet": " pending_references.setdefault(refto, []).extend(refs)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98892:If_L35_C12", "label": "if", "type": "if", "loc": [35, 36], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98892:For_L33_C8", "vector": [4, 3, 0.194, 0.0109, 3, 0.08, 1.0, 0, 0, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if refto in known_models:\n final_output.extend(connection.creation.sql_for_pending_references(refto, style, pending_references))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98892:Expr_L36_C16", "label": "extend()", "type": "expression", "loc": [36, 36], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98892:If_L35_C12", "vector": [8, 4, 0.1967, 0.0055, 4, 0.18, 0.0, 660, 3, 1, 0, 0, 0, 0, 2], "semantic": {"name": "extend", "arg_names": [], "import_names": [], "rhs_call_name": "extend", "annotation": ""}, "snippet": " final_output.extend(connection.creation.sql_for_pending_references(refto, style, pending_references))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98892:Expr_L37_C8", "label": "extend()", "type": "expression", "loc": [37, 37], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98892:For_L30_C4", "vector": [8, 2, 0.2022, 0.0055, 2, 0.49, 0.75, 660, 3, 1, 0, 0, 0, 0, 2], "semantic": {"name": "extend", "arg_names": [], "import_names": [], "rhs_call_name": "extend", "annotation": ""}, "snippet": " final_output.extend(connection.creation.sql_for_pending_references(model, style, pending_references))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98892:Expr_L39_C8", "label": "add()", "type": "expression", "loc": [39, 39], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98892:For_L30_C4", "vector": [8, 2, 0.2131, 0.0055, 2, 0.49, 1.0, 241, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "add", "arg_names": [], "import_names": [], "rhs_call_name": "add", "annotation": ""}, "snippet": " known_models.add(model)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98892:Assign_L43_C4", "label": "not_installed_models = set()", "type": "assigned_variable", "loc": [43, 43], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98892:FunctionDef_L9_C0", "vector": [14, 1, 0.235, 0.0055, 1, 0.52, 0.8, 114, 3, 1, 0, 0, 21, 10, 2], "semantic": {"name": "not_installed_models", "arg_names": [], "import_names": [], "rhs_call_name": "set", "annotation": ""}, "snippet": " not_installed_models = set(pending_references.keys())"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98892:If_L44_C4", "label": "if", "type": "if", "loc": [44, 51], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98892:FunctionDef_L9_C0", "vector": [4, 1, 0.2596, 0.0437, 1, 0.52, 0.9, 0, 2, 0, 0, 0, 0, 0, 4], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if not_installed_models:\n alter_sql = []\n for model in not_installed_models:\n alter_sql.extend(['-- ' + sql for sql in\n connection.creation.sql_for_pending_references(model, style, pending_references)])\n if alter_sql:\n final_output.append('-- The following references should be added but depend on non-existent tables:')\n final_output.extend(alter_sql)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98892:Assign_L45_C8", "label": "alter_sql =", "type": "assigned_variable", "loc": [45, 45], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98892:If_L44_C4", "vector": [14, 2, 0.2459, 0.0055, 2, 0.3, 0.0, 542, 0, 0, 0, 0, 0, 5, 0], "semantic": {"name": "alter_sql", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " alter_sql = []"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98892:For_L46_C8", "label": "for model", "type": "for", "loc": [46, 48], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98892:If_L44_C4", "vector": [6, 2, 0.2568, 0.0164, 2, 0.3, 0.5, 722, 2, 0, 0, 0, 0, 0, 2], "semantic": {"name": "model", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for model in not_installed_models:\n alter_sql.extend(['-- ' + sql for sql in\n connection.creation.sql_for_pending_references(model, style, pending_references)])"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98892:Expr_L47_C12", "label": "extend()", "type": "expression", "loc": [47, 48], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98892:For_L46_C8", "vector": [8, 3, 0.2596, 0.0109, 3, 0.99, 0.0, 660, 3, 1, 0, 0, 0, 0, 2], "semantic": {"name": "extend", "arg_names": [], "import_names": [], "rhs_call_name": "extend", "annotation": ""}, "snippet": " alter_sql.extend(['-- ' + sql for sql in\n connection.creation.sql_for_pending_references(model, style, pending_references)])"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98892:If_L49_C8", "label": "if", "type": "if", "loc": [49, 51], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98892:If_L44_C4", "vector": [4, 2, 0.2732, 0.0164, 2, 0.3, 1.0, 0, 2, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if alter_sql:\n final_output.append('-- The following references should be added but depend on non-existent tables:')\n final_output.extend(alter_sql)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98892:Expr_L50_C12", "label": "append()", "type": "expression", "loc": [50, 50], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98892:If_L49_C8", "vector": [8, 3, 0.2732, 0.0055, 3, 0.99, 0.0, 243, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "append", "arg_names": [], "import_names": [], "rhs_call_name": "append", "annotation": ""}, "snippet": " final_output.append('-- The following references should be added but depend on non-existent tables:')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98892:Expr_L51_C12", "label": "extend()", "type": "expression", "loc": [51, 51], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98892:If_L49_C8", "vector": [8, 3, 0.2787, 0.0055, 3, 0.99, 1.0, 660, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "extend", "arg_names": [], "import_names": [], "rhs_call_name": "extend", "annotation": ""}, "snippet": " final_output.extend(alter_sql)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98892:Return_L53_C4", "label": "return", "type": "return", "loc": [53, 53], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98892:FunctionDef_L9_C0", "vector": [13, 1, 0.2896, 0.0055, 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 final_output"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98892:FunctionDef_L55_C0", "label": "sql_delete", "type": "function", "loc": [55, 97], "level": 0, "parent": null, "vector": [2, 0, 0.4153, 0.235, 0, 0.66, 0.5, 157, 0, 3, 1, 0, 0, 0, 13], "semantic": {"name": "sql_delete", "arg_names": ["app", "style", "connection"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "def sql_delete(app, style, connection):\n \"Returns a list of the DROP TABLE SQL statements for the given app.\"\n\n # This should work even if a connection isn't available\n try:\n cursor = connection.cursor()\n except:\n cursor = None"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98892:Expr_L56_C4", "label": "expression", "type": "expression", "loc": [56, 56], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98892:FunctionDef_L55_C0", "vector": [8, 1, 0.306, 0.0055, 1, 0.15, 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 the DROP TABLE SQL statements for the given app.\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98892:Try_L59_C4", "label": "try", "type": "try", "loc": [59, 62], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98892:FunctionDef_L55_C0", "vector": [7, 1, 0.3306, 0.0219, 1, 0.15, 0.1, 0, 0, 1, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " try:\n cursor = connection.cursor()\n except:\n cursor = None"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98892:Assign_L60_C8", "label": "cursor = cursor()", "type": "assigned_variable", "loc": [60, 60], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98892:Try_L59_C4", "vector": [14, 2, 0.3279, 0.0055, 2, 0.13, 0.0, 231, 3, 0, 0, 0, 231, 10, 1], "semantic": {"name": "cursor", "arg_names": [], "import_names": [], "rhs_call_name": "cursor", "annotation": ""}, "snippet": " cursor = connection.cursor()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98892:Assign_L62_C8", "label": "cursor =", "type": "assigned_variable", "loc": [62, 62], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98892:Try_L59_C4", "vector": [14, 2, 0.3388, 0.0055, 2, 0.13, 0.0, 231, 1, 0, 0, 0, 0, 9, 0], "semantic": {"name": "cursor", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " cursor = None"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98892:If_L65_C4", "label": "if", "type": "if", "loc": [65, 68], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98892:FunctionDef_L55_C0", "vector": [4, 1, 0.3634, 0.0219, 1, 0.15, 0.2, 0, 2, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if cursor:\n table_names = connection.introspection.get_table_list(cursor)\n else:\n table_names = []"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98892:Assign_L66_C8", "label": "table_names = get_table_list()", "type": "assigned_variable", "loc": [66, 66], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98892:If_L65_C4", "vector": [14, 2, 0.3607, 0.0055, 2, 0.09, 0.0, 480, 3, 1, 0, 0, 878, 10, 1], "semantic": {"name": "table_names", "arg_names": [], "import_names": [], "rhs_call_name": "get_table_list", "annotation": ""}, "snippet": " table_names = connection.introspection.get_table_list(cursor)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98892:Assign_L68_C8", "label": "table_names =", "type": "assigned_variable", "loc": [68, 68], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98892:If_L65_C4", "vector": [14, 2, 0.3716, 0.0055, 2, 0.09, 1.0, 480, 0, 0, 0, 0, 0, 5, 0], "semantic": {"name": "table_names", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " table_names = []"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98892:Assign_L70_C4", "label": "output =", "type": "assigned_variable", "loc": [70, 70], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98892:FunctionDef_L55_C0", "vector": [14, 1, 0.3825, 0.0055, 1, 0.15, 0.3, 886, 0, 0, 0, 0, 0, 5, 0], "semantic": {"name": "output", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " output = []"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98892:Assign_L73_C4", "label": "to_delete = set()", "type": "assigned_variable", "loc": [73, 73], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98892:FunctionDef_L55_C0", "vector": [14, 1, 0.3989, 0.0055, 1, 0.15, 0.4, 510, 3, 0, 0, 0, 21, 10, 1], "semantic": {"name": "to_delete", "arg_names": [], "import_names": [], "rhs_call_name": "set", "annotation": ""}, "snippet": " to_delete = set()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98892:Assign_L75_C4", "label": "references_to_delete =", "type": "assigned_variable", "loc": [75, 75], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98892:FunctionDef_L55_C0", "vector": [14, 1, 0.4098, 0.0055, 1, 0.15, 0.5, 73, 0, 0, 0, 0, 0, 6, 0], "semantic": {"name": "references_to_delete", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " references_to_delete = {}"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98892:Assign_L76_C4", "label": "app_models = get_models()", "type": "assigned_variable", "loc": [76, 76], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98892:FunctionDef_L55_C0", "vector": [14, 1, 0.4153, 0.0055, 1, 0.15, 0.6, 621, 3, 2, 0, 0, 404, 10, 1], "semantic": {"name": "app_models", "arg_names": [], "import_names": [], "rhs_call_name": "get_models", "annotation": ""}, "snippet": " app_models = models.get_models(app, include_auto_created=True)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98892:For_L77_C4", "label": "for model", "type": "for", "loc": [77, 85], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98892:FunctionDef_L55_C0", "vector": [6, 1, 0.4426, 0.0492, 1, 0.15, 0.7, 722, 2, 0, 0, 0, 0, 0, 4], "semantic": {"name": "model", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for model in app_models:\n if cursor and connection.introspection.table_name_converter(model._meta.db_table) in table_names:\n # The table exists, so it needs to be dropped\n opts = model._meta\n for f in opts.local_fields:\n if f.rel and f.rel.to not in to_delete:\n references_to_delete.setdefault(f.rel.to, []).append( (model, f) )\n"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98892:If_L78_C8", "label": "if", "type": "if", "loc": [78, 85], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98892:For_L77_C4", "vector": [4, 2, 0.4454, 0.0437, 2, 0.42, 0.0, 0, 0, 0, 0, 0, 0, 0, 4], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if cursor and connection.introspection.table_name_converter(model._meta.db_table) in table_names:\n # The table exists, so it needs to be dropped\n opts = model._meta\n for f in opts.local_fields:\n if f.rel and f.rel.to not in to_delete:\n references_to_delete.setdefault(f.rel.to, []).append( (model, f) )\n\n to_delete.add(model)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98892:Assign_L80_C12", "label": "opts =", "type": "assigned_variable", "loc": [80, 80], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98892:If_L78_C8", "vector": [14, 3, 0.4372, 0.0055, 3, 0.03, 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_98892:For_L81_C12", "label": "for f", "type": "for", "loc": [81, 83], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98892:If_L78_C8", "vector": [6, 3, 0.4481, 0.0164, 3, 0.03, 0.5, 899, 7, 0, 0, 0, 0, 0, 2], "semantic": {"name": "f", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for f in opts.local_fields:\n if f.rel and f.rel.to not in to_delete:\n references_to_delete.setdefault(f.rel.to, []).append( (model, f) )"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98892:If_L82_C16", "label": "if", "type": "if", "loc": [82, 83], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98892:For_L81_C12", "vector": [4, 4, 0.4508, 0.0109, 4, 0.41, 0.0, 0, 0, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if f.rel and f.rel.to not in to_delete:\n references_to_delete.setdefault(f.rel.to, []).append( (model, f) )"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98892:Expr_L83_C20", "label": "append()", "type": "expression", "loc": [83, 83], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98892:If_L82_C16", "vector": [8, 5, 0.4536, 0.0055, 5, 0.59, 0.0, 243, 3, 1, 0, 0, 0, 0, 2], "semantic": {"name": "append", "arg_names": [], "import_names": [], "rhs_call_name": "append", "annotation": ""}, "snippet": " references_to_delete.setdefault(f.rel.to, []).append( (model, f) )"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98892:Expr_L85_C12", "label": "add()", "type": "expression", "loc": [85, 85], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98892:If_L78_C8", "vector": [8, 3, 0.4645, 0.0055, 3, 0.03, 1.0, 241, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "add", "arg_names": [], "import_names": [], "rhs_call_name": "add", "annotation": ""}, "snippet": " to_delete.add(model)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98892:For_L87_C4", "label": "for model", "type": "for", "loc": [87, 89], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98892:FunctionDef_L55_C0", "vector": [6, 1, 0.4809, 0.0164, 1, 0.15, 0.8, 722, 2, 0, 0, 0, 0, 0, 3], "semantic": {"name": "model", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for model in app_models:\n if connection.introspection.table_name_converter(model._meta.db_table) in table_names:\n output.extend(connection.creation.sql_destroy_model(model, references_to_delete, style))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98892:If_L88_C8", "label": "if", "type": "if", "loc": [88, 89], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98892:For_L87_C4", "vector": [4, 2, 0.4836, 0.0109, 2, 0.4, 0.0, 0, 0, 0, 0, 0, 0, 0, 3], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if connection.introspection.table_name_converter(model._meta.db_table) in table_names:\n output.extend(connection.creation.sql_destroy_model(model, references_to_delete, style))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98892:Expr_L89_C12", "label": "extend()", "type": "expression", "loc": [89, 89], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98892:If_L88_C8", "vector": [8, 3, 0.4863, 0.0055, 3, 0.72, 0.0, 660, 3, 1, 0, 0, 0, 0, 2], "semantic": {"name": "extend", "arg_names": [], "import_names": [], "rhs_call_name": "extend", "annotation": ""}, "snippet": " output.extend(connection.creation.sql_destroy_model(model, references_to_delete, style))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98892:If_L93_C4", "label": "if", "type": "if", "loc": [93, 95], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98892:FunctionDef_L55_C0", "vector": [4, 1, 0.5137, 0.0164, 1, 0.15, 0.9, 0, 2, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if cursor:\n cursor.close()\n connection.close()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98892:Expr_L94_C8", "label": "close()", "type": "expression", "loc": [94, 94], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98892:If_L93_C4", "vector": [8, 2, 0.5137, 0.0055, 2, 0.82, 0.0, 77, 3, 0, 0, 0, 0, 0, 1], "semantic": {"name": "close", "arg_names": [], "import_names": [], "rhs_call_name": "close", "annotation": ""}, "snippet": " cursor.close()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98892:Expr_L95_C8", "label": "close()", "type": "expression", "loc": [95, 95], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98892:If_L93_C4", "vector": [8, 2, 0.5191, 0.0055, 2, 0.82, 1.0, 77, 3, 0, 0, 0, 0, 0, 1], "semantic": {"name": "close", "arg_names": [], "import_names": [], "rhs_call_name": "close", "annotation": ""}, "snippet": " connection.close()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98892:Return_L97_C4", "label": "return", "type": "return", "loc": [97, 97], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98892:FunctionDef_L55_C0", "vector": [13, 1, 0.5301, 0.0055, 1, 0.15, 1.0, 0, 6, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return output[::-1] # Reverse it, to deal with table dependencies."}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98892:FunctionDef_L99_C0", "label": "sql_reset", "type": "function", "loc": [99, 101], "level": 0, "parent": null, "vector": [2, 0, 0.5464, 0.0164, 0, 0.66, 0.5714, 190, 0, 3, 1, 0, 0, 0, 2], "semantic": {"name": "sql_reset", "arg_names": ["app", "style", "connection"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "def sql_reset(app, style, connection):\n \"Returns a list of the DROP TABLE SQL, then the CREATE TABLE SQL, for the given module.\"\n return sql_delete(app, style, connection) + sql_all(app, style, connection)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98892:Expr_L100_C4", "label": "expression", "type": "expression", "loc": [100, 100], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98892:FunctionDef_L99_C0", "vector": [8, 1, 0.5464, 0.0055, 1, 0.64, 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 the DROP TABLE SQL, then the CREATE TABLE SQL, for the given module.\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98892:Return_L101_C4", "label": "return", "type": "return", "loc": [101, 101], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98892:FunctionDef_L99_C0", "vector": [13, 1, 0.5519, 0.0055, 1, 0.64, 1.0, 0, 4, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return sql_delete(app, style, connection) + sql_all(app, style, connection)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98892:FunctionDef_L103_C0", "label": "sql_flush", "type": "function", "loc": [103, 117], "level": 0, "parent": null, "vector": [2, 0, 0.6011, 0.082, 0, 0.66, 0.6429, 914, 0, 3, 1, 0, 0, 0, 4], "semantic": {"name": "sql_flush", "arg_names": ["style", "connection", "only_django"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "def sql_flush(style, connection, only_django=False):\n \"\"\"\n Returns a list of the SQL statements used to flush the database.\n\n If only_django is True, then only table names that have associated Django\n models and are in INSTALLED_APPS will be included.\n \"\"\"\n if only_django:"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98892:Expr_L104_C4", "label": "expression", "type": "expression", "loc": [104, 109], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98892:FunctionDef_L103_C0", "vector": [8, 1, 0.582, 0.0328, 1, 0.86, 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 the SQL statements used to flush the database.\n\n If only_django is True, then only table names that have associated Django\n models and are in INSTALLED_APPS will be included.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98892:If_L110_C4", "label": "if", "type": "if", "loc": [110, 113], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98892:FunctionDef_L103_C0", "vector": [4, 1, 0.6093, 0.0219, 1, 0.86, 0.3333, 0, 2, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if only_django:\n tables = connection.introspection.django_table_names(only_existing=True)\n else:\n tables = connection.introspection.table_names()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98892:Assign_L111_C8", "label": "tables = django_table_names()", "type": "assigned_variable", "loc": [111, 111], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98892:If_L110_C4", "vector": [14, 2, 0.6066, 0.0055, 2, 0.18, 0.0, 475, 3, 1, 0, 0, 189, 10, 1], "semantic": {"name": "tables", "arg_names": [], "import_names": [], "rhs_call_name": "django_table_names", "annotation": ""}, "snippet": " tables = connection.introspection.django_table_names(only_existing=True)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98892:Assign_L113_C8", "label": "tables = table_names()", "type": "assigned_variable", "loc": [113, 113], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98892:If_L110_C4", "vector": [14, 2, 0.6175, 0.0055, 2, 0.18, 1.0, 475, 3, 0, 0, 0, 480, 10, 1], "semantic": {"name": "tables", "arg_names": [], "import_names": [], "rhs_call_name": "table_names", "annotation": ""}, "snippet": " tables = connection.introspection.table_names()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98892:Assign_L114_C4", "label": "statements = sql_flush()", "type": "assigned_variable", "loc": [114, 116], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98892:FunctionDef_L103_C0", "vector": [14, 1, 0.6284, 0.0164, 1, 0.86, 0.6667, 609, 3, 3, 0, 0, 914, 10, 2], "semantic": {"name": "statements", "arg_names": [], "import_names": [], "rhs_call_name": "sql_flush", "annotation": ""}, "snippet": " statements = connection.ops.sql_flush(\n style, tables, connection.introspection.sequence_list()\n )"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98892:Return_L117_C4", "label": "return", "type": "return", "loc": [117, 117], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98892:FunctionDef_L103_C0", "vector": [13, 1, 0.6393, 0.0055, 1, 0.86, 1.0, 0, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return statements"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98892:FunctionDef_L119_C0", "label": "sql_custom", "type": "function", "loc": [119, 129], "level": 0, "parent": null, "vector": [2, 0, 0.6776, 0.0601, 0, 0.66, 0.7143, 156, 0, 3, 1, 0, 0, 0, 6], "semantic": {"name": "sql_custom", "arg_names": ["app", "style", "connection"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "def sql_custom(app, style, connection):\n \"Returns a list of the custom table modifying SQL statements for the given app.\"\n output = []\n\n app_models = get_models(app)\n app_dir = os.path.normpath(os.path.join(os.path.dirname(app.__file__), 'sql'))\n\n for model in app_models:"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98892:Expr_L120_C4", "label": "expression", "type": "expression", "loc": [120, 120], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98892:FunctionDef_L119_C0", "vector": [8, 1, 0.6557, 0.0055, 1, 0.19, 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 the custom table modifying SQL statements for the given app.\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98892:Assign_L121_C4", "label": "output =", "type": "assigned_variable", "loc": [121, 121], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98892:FunctionDef_L119_C0", "vector": [14, 1, 0.6612, 0.0055, 1, 0.19, 0.2, 886, 0, 0, 0, 0, 0, 5, 0], "semantic": {"name": "output", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " output = []"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98892:Assign_L123_C4", "label": "app_models = get_models()", "type": "assigned_variable", "loc": [123, 123], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98892:FunctionDef_L119_C0", "vector": [14, 1, 0.6721, 0.0055, 1, 0.19, 0.4, 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_98892:Assign_L124_C4", "label": "app_dir = normpath()", "type": "assigned_variable", "loc": [124, 124], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98892:FunctionDef_L119_C0", "vector": [14, 1, 0.6776, 0.0055, 1, 0.19, 0.6, 750, 3, 1, 0, 0, 638, 10, 3], "semantic": {"name": "app_dir", "arg_names": [], "import_names": [], "rhs_call_name": "normpath", "annotation": ""}, "snippet": " app_dir = os.path.normpath(os.path.join(os.path.dirname(app.__file__), 'sql'))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98892:For_L126_C4", "label": "for model", "type": "for", "loc": [126, 127], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98892:FunctionDef_L119_C0", "vector": [6, 1, 0.6913, 0.0109, 1, 0.19, 0.8, 722, 2, 0, 0, 0, 0, 0, 2], "semantic": {"name": "model", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for model in app_models:\n output.extend(custom_sql_for_model(model, style, connection))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98892:Expr_L127_C8", "label": "extend()", "type": "expression", "loc": [127, 127], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98892:For_L126_C4", "vector": [8, 2, 0.694, 0.0055, 2, 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": " output.extend(custom_sql_for_model(model, style, connection))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98892:Return_L129_C4", "label": "return", "type": "return", "loc": [129, 129], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98892:FunctionDef_L119_C0", "vector": [13, 1, 0.7049, 0.0055, 1, 0.19, 1.0, 0, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return output"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98892:FunctionDef_L131_C0", "label": "sql_indexes", "type": "function", "loc": [131, 136], "level": 0, "parent": null, "vector": [2, 0, 0.7295, 0.0328, 0, 0.66, 0.7857, 805, 0, 3, 1, 0, 0, 0, 3], "semantic": {"name": "sql_indexes", "arg_names": ["app", "style", "connection"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "def sql_indexes(app, style, connection):\n \"Returns a list of the CREATE INDEX SQL statements for all models in the given app.\"\n output = []\n for model in models.get_models(app):\n output.extend(connection.creation.sql_indexes_for_model(model, style))\n return output"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98892:Expr_L132_C4", "label": "expression", "type": "expression", "loc": [132, 132], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98892:FunctionDef_L131_C0", "vector": [8, 1, 0.7213, 0.0055, 1, 0.87, 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 the CREATE INDEX SQL statements for all models in the given app.\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98892:Assign_L133_C4", "label": "output =", "type": "assigned_variable", "loc": [133, 133], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98892:FunctionDef_L131_C0", "vector": [14, 1, 0.7268, 0.0055, 1, 0.87, 0.3333, 886, 0, 0, 0, 0, 0, 5, 0], "semantic": {"name": "output", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " output = []"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98892:For_L134_C4", "label": "for model", "type": "for", "loc": [134, 135], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98892:FunctionDef_L131_C0", "vector": [6, 1, 0.735, 0.0109, 1, 0.87, 0.6667, 722, 3, 0, 0, 0, 0, 0, 3], "semantic": {"name": "model", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for model in models.get_models(app):\n output.extend(connection.creation.sql_indexes_for_model(model, style))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98892:Expr_L135_C8", "label": "extend()", "type": "expression", "loc": [135, 135], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98892:For_L134_C4", "vector": [8, 2, 0.7377, 0.0055, 2, 0.64, 0.0, 660, 3, 1, 0, 0, 0, 0, 2], "semantic": {"name": "extend", "arg_names": [], "import_names": [], "rhs_call_name": "extend", "annotation": ""}, "snippet": " output.extend(connection.creation.sql_indexes_for_model(model, style))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98892:Return_L136_C4", "label": "return", "type": "return", "loc": [136, 136], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98892:FunctionDef_L131_C0", "vector": [13, 1, 0.7432, 0.0055, 1, 0.87, 1.0, 0, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return output"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98892:FunctionDef_L138_C0", "label": "sql_all", "type": "function", "loc": [138, 140], "level": 0, "parent": null, "vector": [2, 0, 0.7596, 0.0164, 0, 0.66, 0.8571, 836, 0, 3, 1, 0, 0, 0, 3], "semantic": {"name": "sql_all", "arg_names": ["app", "style", "connection"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "def sql_all(app, style, connection):\n \"Returns a list of CREATE TABLE SQL, initial-data inserts, and CREATE INDEX SQL for the given module.\"\n return sql_create(app, style, connection) + sql_custom(app, style, connection) + sql_indexes(app, style, connection)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98892:Expr_L139_C4", "label": "expression", "type": "expression", "loc": [139, 139], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98892:FunctionDef_L138_C0", "vector": [8, 1, 0.7596, 0.0055, 1, 0.2, 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 CREATE TABLE SQL, initial-data inserts, and CREATE INDEX SQL for the given module.\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98892:Return_L140_C4", "label": "return", "type": "return", "loc": [140, 140], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98892:FunctionDef_L138_C0", "vector": [13, 1, 0.765, 0.0055, 1, 0.2, 1.0, 0, 4, 0, 0, 0, 0, 0, 3], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return sql_create(app, style, connection) + sql_custom(app, style, connection) + sql_indexes(app, style, connection)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98892:FunctionDef_L142_C0", "label": "custom_sql_for_model", "type": "function", "loc": [142, 172], "level": 0, "parent": null, "vector": [2, 0, 0.8579, 0.1694, 0, 0.66, 0.9286, 668, 0, 3, 1, 0, 0, 0, 21], "semantic": {"name": "custom_sql_for_model", "arg_names": ["model", "style", "connection"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "def custom_sql_for_model(model, style, connection):\n opts = model._meta\n app_dir = os.path.normpath(os.path.join(os.path.dirname(models.get_app(model._meta.app_label).__file__), 'sql'))\n output = []\n\n # Post-creation SQL should come before any initial SQL data is loaded.\n # However, this should not be done for models that are unmanaged or\n # for fields that are part of a parent model (via model inheritance)."}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98892:Assign_L143_C4", "label": "opts =", "type": "assigned_variable", "loc": [143, 143], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98892:FunctionDef_L142_C0", "vector": [14, 1, 0.7814, 0.0055, 1, 0.34, 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_98892:Assign_L144_C4", "label": "app_dir = normpath()", "type": "assigned_variable", "loc": [144, 144], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98892:FunctionDef_L142_C0", "vector": [14, 1, 0.7869, 0.0055, 1, 0.34, 0.125, 750, 3, 1, 0, 0, 638, 10, 4], "semantic": {"name": "app_dir", "arg_names": [], "import_names": [], "rhs_call_name": "normpath", "annotation": ""}, "snippet": " app_dir = os.path.normpath(os.path.join(os.path.dirname(models.get_app(model._meta.app_label).__file__), 'sql'))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98892:Assign_L145_C4", "label": "output =", "type": "assigned_variable", "loc": [145, 145], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98892:FunctionDef_L142_C0", "vector": [14, 1, 0.7923, 0.0055, 1, 0.34, 0.25, 886, 0, 0, 0, 0, 0, 5, 0], "semantic": {"name": "output", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " output = []"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98892:If_L150_C4", "label": "if", "type": "if", "loc": [150, 153], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98892:FunctionDef_L142_C0", "vector": [4, 1, 0.8279, 0.0219, 1, 0.34, 0.375, 0, 7, 0, 0, 0, 0, 0, 3], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if opts.managed:\n post_sql_fields = [f for f in opts.local_fields if hasattr(f, 'post_create_sql')]\n for f in post_sql_fields:\n output.extend(f.post_create_sql(style, model._meta.db_table))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98892:Assign_L151_C8", "label": "post_sql_fields =", "type": "assigned_variable", "loc": [151, 151], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98892:If_L150_C4", "vector": [14, 2, 0.8251, 0.0055, 2, 0.3, 0.0, 949, 5, 0, 0, 0, 0, 0, 1], "semantic": {"name": "post_sql_fields", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " post_sql_fields = [f for f in opts.local_fields if hasattr(f, 'post_create_sql')]"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98892:For_L152_C8", "label": "for f", "type": "for", "loc": [152, 153], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98892:If_L150_C4", "vector": [6, 2, 0.8333, 0.0109, 2, 0.3, 1.0, 899, 2, 0, 0, 0, 0, 0, 2], "semantic": {"name": "f", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for f in post_sql_fields:\n output.extend(f.post_create_sql(style, model._meta.db_table))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98892:Expr_L153_C12", "label": "extend()", "type": "expression", "loc": [153, 153], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98892:For_L152_C8", "vector": [8, 3, 0.8361, 0.0055, 3, 0.25, 0.0, 660, 3, 1, 0, 0, 0, 0, 2], "semantic": {"name": "extend", "arg_names": [], "import_names": [], "rhs_call_name": "extend", "annotation": ""}, "snippet": " output.extend(f.post_create_sql(style, model._meta.db_table))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98892:Assign_L157_C4", "label": "statements = compile()", "type": "assigned_variable", "loc": [157, 157], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98892:FunctionDef_L142_C0", "vector": [14, 1, 0.8579, 0.0055, 1, 0.34, 0.5, 609, 3, 2, 0, 0, 821, 10, 1], "semantic": {"name": "statements", "arg_names": [], "import_names": [], "rhs_call_name": "compile", "annotation": ""}, "snippet": " statements = re.compile(r\";[ \\t]*$\", re.M)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98892:Assign_L160_C4", "label": "backend_name =", "type": "assigned_variable", "loc": [160, 160], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98892:FunctionDef_L142_C0", "vector": [14, 1, 0.8743, 0.0055, 1, 0.34, 0.625, 230, 6, 0, 0, 0, 0, 0, 1], "semantic": {"name": "backend_name", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " backend_name = connection.settings_dict['ENGINE'].split('.')[-1]"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98892:Assign_L161_C4", "label": "sql_files =", "type": "assigned_variable", "loc": [161, 162], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98892:FunctionDef_L142_C0", "vector": [14, 1, 0.8825, 0.0109, 1, 0.34, 0.75, 291, 0, 0, 0, 0, 0, 5, 4], "semantic": {"name": "sql_files", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " sql_files = [os.path.join(app_dir, \"%s.%s.sql\" % (opts.object_name.lower(), backend_name)),\n os.path.join(app_dir, \"%s.sql\" % opts.object_name.lower())]"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98892:For_L163_C4", "label": "for sql_file", "type": "for", "loc": [163, 170], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98892:FunctionDef_L142_C0", "vector": [6, 1, 0.9098, 0.0437, 1, 0.34, 0.875, 729, 2, 0, 0, 0, 0, 0, 8], "semantic": {"name": "sql_file", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for sql_file in sql_files:\n if os.path.exists(sql_file):\n fp = open(sql_file, 'U')\n for statement in statements.split(fp.read().decode(settings.FILE_CHARSET)):\n # Remove any comments from the file\n if statement.strip():\n output.append(statement + u\";\")\n fp.close()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98892:If_L164_C8", "label": "if", "type": "if", "loc": [164, 170], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98892:For_L163_C4", "vector": [4, 2, 0.9126, 0.0383, 2, 0.25, 0.0, 0, 3, 0, 0, 0, 0, 0, 8], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if os.path.exists(sql_file):\n fp = open(sql_file, 'U')\n for statement in statements.split(fp.read().decode(settings.FILE_CHARSET)):\n # Remove any comments from the file\n if statement.strip():\n output.append(statement + u\";\")\n fp.close()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98892:Assign_L165_C12", "label": "fp = open()", "type": "assigned_variable", "loc": [165, 165], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98892:If_L164_C8", "vector": [14, 3, 0.9016, 0.0055, 3, 0.01, 0.0, 392, 3, 2, 0, 0, 693, 10, 1], "semantic": {"name": "fp", "arg_names": [], "import_names": [], "rhs_call_name": "open", "annotation": ""}, "snippet": " fp = open(sql_file, 'U')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98892:For_L166_C12", "label": "for statement", "type": "for", "loc": [166, 169], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98892:If_L164_C8", "vector": [6, 3, 0.9153, 0.0219, 3, 0.01, 0.5, 92, 3, 0, 0, 0, 0, 0, 5], "semantic": {"name": "statement", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for statement in statements.split(fp.read().decode(settings.FILE_CHARSET)):\n # Remove any comments from the file\n if statement.strip():\n output.append(statement + u\";\")"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98892:If_L168_C16", "label": "if", "type": "if", "loc": [168, 169], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98892:For_L166_C12", "vector": [4, 4, 0.9208, 0.0109, 4, 0.97, 0.0, 0, 3, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if statement.strip():\n output.append(statement + u\";\")"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98892:Expr_L169_C20", "label": "append()", "type": "expression", "loc": [169, 169], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98892:If_L168_C16", "vector": [8, 5, 0.9235, 0.0055, 5, 0.22, 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(statement + u\";\")"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98892:Expr_L170_C12", "label": "close()", "type": "expression", "loc": [170, 170], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98892:If_L164_C8", "vector": [8, 3, 0.929, 0.0055, 3, 0.01, 1.0, 77, 3, 0, 0, 0, 0, 0, 1], "semantic": {"name": "close", "arg_names": [], "import_names": [], "rhs_call_name": "close", "annotation": ""}, "snippet": " fp.close()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98892:Return_L172_C4", "label": "return", "type": "return", "loc": [172, 172], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98892:FunctionDef_L142_C0", "vector": [13, 1, 0.9399, 0.0055, 1, 0.34, 1.0, 0, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return output"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98892:FunctionDef_L175_C0", "label": "emit_post_sync_signal", "type": "function", "loc": [175, 183], "level": 0, "parent": null, "vector": [2, 0, 0.9781, 0.0492, 0, 0.66, 1.0, 817, 0, 4, 0, 0, 0, 0, 4], "semantic": {"name": "emit_post_sync_signal", "arg_names": ["created_models", "verbosity", "interactive", "db"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "def emit_post_sync_signal(created_models, verbosity, interactive, db):\n # Emit the post_sync signal for every application.\n for app in models.get_apps():\n app_name = app.__name__.split('.')[-2]\n if verbosity >= 2:\n print(\"Running post-sync handlers for application\", app_name)\n models.signals.post_syncdb.send(sender=app, app=app,\n created_models=created_models, verbosity=verbosity,"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98892:For_L177_C4", "label": "for app", "type": "for", "loc": [177, 183], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98892:FunctionDef_L175_C0", "vector": [6, 1, 0.9836, 0.0383, 1, 0.79, 0.0, 494, 3, 0, 0, 0, 0, 0, 4], "semantic": {"name": "app", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for app in models.get_apps():\n app_name = app.__name__.split('.')[-2]\n if verbosity >= 2:\n print(\"Running post-sync handlers for application\", app_name)\n models.signals.post_syncdb.send(sender=app, app=app,\n created_models=created_models, verbosity=verbosity,\n interactive=interactive, db=db)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98892:Assign_L178_C8", "label": "app_name =", "type": "assigned_variable", "loc": [178, 178], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98892:For_L177_C4", "vector": [14, 2, 0.9727, 0.0055, 2, 0.17, 0.0, 443, 6, 0, 0, 0, 0, 0, 1], "semantic": {"name": "app_name", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " app_name = app.__name__.split('.')[-2]"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98892:If_L179_C8", "label": "if", "type": "if", "loc": [179, 180], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98892:For_L177_C4", "vector": [4, 2, 0.9809, 0.0109, 2, 0.17, 0.5, 0, 0, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if verbosity >= 2:\n print(\"Running post-sync handlers for application\", app_name)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98892:Expr_L180_C12", "label": "print()", "type": "expression", "loc": [180, 180], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98892:If_L179_C8", "vector": [8, 3, 0.9836, 0.0055, 3, 0.83, 0.0, 535, 3, 2, 0, 0, 0, 0, 1], "semantic": {"name": "print", "arg_names": [], "import_names": [], "rhs_call_name": "print", "annotation": ""}, "snippet": " print(\"Running post-sync handlers for application\", app_name)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98892:Expr_L181_C8", "label": "send()", "type": "expression", "loc": [181, 183], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98892:For_L177_C4", "vector": [8, 2, 0.9945, 0.0164, 2, 0.17, 1.0, 826, 3, 6, 0, 0, 0, 0, 1], "semantic": {"name": "send", "arg_names": [], "import_names": [], "rhs_call_name": "send", "annotation": ""}, "snippet": " models.signals.post_syncdb.send(sender=app, app=app,\n created_models=created_models, verbosity=verbosity,\n interactive=interactive, db=db)"}]
[{"f": "ajibawa-2023/Python-Code-Large/train/row_98892:FunctionDef_L9_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98892:Expr_L10_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98892:FunctionDef_L9_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98892:If_L12_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98892:FunctionDef_L9_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98892:Assign_L24_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98892:FunctionDef_L9_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98892:Assign_L25_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98892:FunctionDef_L9_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98892:Assign_L26_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98892:FunctionDef_L9_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98892:Assign_L27_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98892:FunctionDef_L9_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98892:Assign_L28_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98892:FunctionDef_L9_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98892:For_L30_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98892:For_L30_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98892:Assign_L31_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98892:For_L30_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98892:Expr_L32_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98892:For_L30_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98892:For_L33_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98892:For_L33_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98892:Expr_L34_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98892:For_L33_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98892:If_L35_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98892:If_L35_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98892:Expr_L36_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98892:For_L30_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98892:Expr_L37_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98892:For_L30_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98892:Expr_L39_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98892:FunctionDef_L9_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98892:Assign_L43_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98892:FunctionDef_L9_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98892:If_L44_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98892:If_L44_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98892:Assign_L45_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98892:If_L44_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98892:For_L46_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98892:For_L46_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98892:Expr_L47_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98892:If_L44_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98892:If_L49_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98892:If_L49_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98892:Expr_L50_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98892:If_L49_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98892:Expr_L51_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98892:FunctionDef_L9_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98892:Return_L53_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98892:FunctionDef_L55_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98892:Expr_L56_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98892:FunctionDef_L55_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98892:Try_L59_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98892:Try_L59_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98892:Assign_L60_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98892:Try_L59_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98892:Assign_L62_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98892:FunctionDef_L55_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98892:If_L65_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98892:If_L65_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98892:Assign_L66_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98892:If_L65_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98892:Assign_L68_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98892:FunctionDef_L55_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98892:Assign_L70_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98892:FunctionDef_L55_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98892:Assign_L73_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98892:FunctionDef_L55_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98892:Assign_L75_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98892:FunctionDef_L55_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98892:Assign_L76_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98892:FunctionDef_L55_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98892:For_L77_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98892:For_L77_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98892:If_L78_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98892:If_L78_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98892:Assign_L80_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98892:If_L78_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98892:For_L81_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98892:For_L81_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98892:If_L82_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98892:If_L82_C16", "t": "ajibawa-2023/Python-Code-Large/train/row_98892:Expr_L83_C20"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98892:If_L78_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98892:Expr_L85_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98892:FunctionDef_L55_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98892:For_L87_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98892:For_L87_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98892:If_L88_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98892:If_L88_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98892:Expr_L89_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98892:FunctionDef_L55_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98892:If_L93_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98892:If_L93_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98892:Expr_L94_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98892:If_L93_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98892:Expr_L95_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98892:FunctionDef_L55_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98892:Return_L97_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98892:FunctionDef_L99_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98892:Expr_L100_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98892:FunctionDef_L99_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98892:Return_L101_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98892:FunctionDef_L103_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98892:Expr_L104_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98892:FunctionDef_L103_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98892:If_L110_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98892:If_L110_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98892:Assign_L111_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98892:If_L110_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98892:Assign_L113_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98892:FunctionDef_L103_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98892:Assign_L114_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98892:FunctionDef_L103_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98892:Return_L117_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98892:FunctionDef_L119_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98892:Expr_L120_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98892:FunctionDef_L119_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98892:Assign_L121_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98892:FunctionDef_L119_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98892:Assign_L123_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98892:FunctionDef_L119_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98892:Assign_L124_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98892:FunctionDef_L119_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98892:For_L126_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98892:For_L126_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98892:Expr_L127_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98892:FunctionDef_L119_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98892:Return_L129_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98892:FunctionDef_L131_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98892:Expr_L132_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98892:FunctionDef_L131_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98892:Assign_L133_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98892:FunctionDef_L131_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98892:For_L134_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98892:For_L134_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98892:Expr_L135_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98892:FunctionDef_L131_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98892:Return_L136_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98892:FunctionDef_L138_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98892:Expr_L139_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98892:FunctionDef_L138_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98892:Return_L140_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98892:FunctionDef_L142_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98892:Assign_L143_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98892:FunctionDef_L142_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98892:Assign_L144_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98892:FunctionDef_L142_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98892:Assign_L145_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98892:FunctionDef_L142_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98892:If_L150_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98892:If_L150_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98892:Assign_L151_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98892:If_L150_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98892:For_L152_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98892:For_L152_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98892:Expr_L153_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98892:FunctionDef_L142_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98892:Assign_L157_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98892:FunctionDef_L142_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98892:Assign_L160_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98892:FunctionDef_L142_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98892:Assign_L161_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98892:FunctionDef_L142_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98892:For_L163_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98892:For_L163_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98892:If_L164_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98892:If_L164_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98892:Assign_L165_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98892:If_L164_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98892:For_L166_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98892:For_L166_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98892:If_L168_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98892:If_L168_C16", "t": "ajibawa-2023/Python-Code-Large/train/row_98892:Expr_L169_C20"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98892:If_L164_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98892:Expr_L170_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98892:FunctionDef_L142_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98892:Return_L172_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98892:FunctionDef_L175_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98892:For_L177_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98892:For_L177_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98892:Assign_L178_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98892:For_L177_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98892:If_L179_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98892:If_L179_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98892:Expr_L180_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98892:For_L177_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98892:Expr_L181_C8"}]
""" Sets up the terminal color scheme. """ import os import sys from django.utils import termcolors def supports_color(): """ Returns True if the running system's terminal supports color, and False otherwise. """ unsupported_platform = (sys.platform in ('win32', 'Pocket PC')) # isatty is not always implemented, #6223. is_a_tty = hasattr(sys.stdout, 'isatty') and sys.stdout.isatty() if unsupported_platform or not is_a_tty: return False return True def color_style(): """Returns a Style object with the Django color scheme.""" if not supports_color(): style = no_style() else: DJANGO_COLORS = os.environ.get('DJANGO_COLORS', '') color_settings = termcolors.parse_color_setting(DJANGO_COLORS) if color_settings: class dummy: pass style = dummy() # The nocolor palette has all available roles. # Use that pallete as the basis for populating # the palette as defined in the environment. for role in termcolors.PALETTES[termcolors.NOCOLOR_PALETTE]: format = color_settings.get(role,{}) setattr(style, role, termcolors.make_style(**format)) # For backwards compatibility, # set style for ERROR_OUTPUT == ERROR style.ERROR_OUTPUT = style.ERROR else: style = no_style() return style def no_style(): """Returns a Style object that has no colors.""" class dummy: def __getattr__(self, attr): return lambda x: x return dummy()
ajibawa-2023/Python-Code-Large/train/row_98893
32
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_98893:Expr_L1_C0", "label": "expression", "type": "expression", "loc": [1, 3], "level": 0, "parent": null, "vector": [8, 0, 0.04, 0.06, 0, 0.66, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "\"\"\"\nSets up the terminal color scheme.\n\"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98893:Import_L5_C0", "label": "os import os", "type": "import", "loc": [5, 5], "level": 0, "parent": null, "vector": [1, 0, 0.1, 0.02, 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_98893:Import_L6_C0", "label": "sys import sys", "type": "import", "loc": [6, 6], "level": 0, "parent": null, "vector": [1, 0, 0.12, 0.02, 0, 0.66, 0.3333, 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_98893:ImportFrom_L8_C0", "label": "from django.utils import termcolors", "type": "import", "loc": [8, 8], "level": 0, "parent": null, "vector": [1, 0, 0.16, 0.02, 0, 0.66, 0.5, 944, 0, 1, 0, 0, 944, 0, 0], "semantic": {"name": "django.utils", "arg_names": [], "import_names": ["termcolors"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.utils import termcolors"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98893:FunctionDef_L10_C0", "label": "supports_color", "type": "function", "loc": [10, 20], "level": 0, "parent": null, "vector": [2, 0, 0.3, 0.22, 0, 0.66, 0.6667, 395, 0, 0, 1, 0, 0, 0, 2], "semantic": {"name": "supports_color", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "def supports_color():\n \"\"\"\n Returns True if the running system's terminal supports color, and False\n otherwise.\n \"\"\"\n unsupported_platform = (sys.platform in ('win32', 'Pocket PC'))\n # isatty is not always implemented, #6223.\n is_a_tty = hasattr(sys.stdout, 'isatty') and sys.stdout.isatty()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98893:Expr_L11_C4", "label": "expression", "type": "expression", "loc": [11, 14], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98893:FunctionDef_L10_C0", "vector": [8, 1, 0.25, 0.08, 1, 0.53, 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 running system's terminal supports color, and False\n otherwise.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98893:Assign_L15_C4", "label": "unsupported_platform =", "type": "assigned_variable", "loc": [15, 15], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98893:FunctionDef_L10_C0", "vector": [14, 1, 0.3, 0.02, 1, 0.53, 0.25, 736, 0, 0, 0, 0, 0, 0, 0], "semantic": {"name": "unsupported_platform", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " unsupported_platform = (sys.platform in ('win32', 'Pocket PC'))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98893:Assign_L17_C4", "label": "is_a_tty =", "type": "assigned_variable", "loc": [17, 17], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98893:FunctionDef_L10_C0", "vector": [14, 1, 0.34, 0.02, 1, 0.53, 0.5, 844, 0, 0, 0, 0, 0, 0, 2], "semantic": {"name": "is_a_tty", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " is_a_tty = hasattr(sys.stdout, 'isatty') and sys.stdout.isatty()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98893:If_L18_C4", "label": "if", "type": "if", "loc": [18, 19], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98893:FunctionDef_L10_C0", "vector": [4, 1, 0.37, 0.04, 1, 0.53, 0.75, 0, 0, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if unsupported_platform or not is_a_tty:\n return False"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98893:Return_L19_C8", "label": "return", "type": "return", "loc": [19, 19], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98893:If_L18_C4", "vector": [13, 2, 0.38, 0.02, 2, 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_98893:Return_L20_C4", "label": "return", "type": "return", "loc": [20, 20], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98893:FunctionDef_L10_C0", "vector": [13, 1, 0.4, 0.02, 1, 0.53, 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_98893:FunctionDef_L22_C0", "label": "color_style", "type": "function", "loc": [22, 43], "level": 0, "parent": null, "vector": [2, 0, 0.65, 0.44, 0, 0.66, 0.8333, 836, 0, 0, 1, 0, 0, 0, 9], "semantic": {"name": "color_style", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "def color_style():\n \"\"\"Returns a Style object with the Django color scheme.\"\"\"\n if not supports_color():\n style = no_style()\n else:\n DJANGO_COLORS = os.environ.get('DJANGO_COLORS', '')\n color_settings = termcolors.parse_color_setting(DJANGO_COLORS)\n if color_settings:"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98893:Expr_L23_C4", "label": "expression", "type": "expression", "loc": [23, 23], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98893:FunctionDef_L22_C0", "vector": [8, 1, 0.46, 0.02, 1, 0.59, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"Returns a Style object with the Django color scheme.\"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98893:If_L24_C4", "label": "if", "type": "if", "loc": [24, 42], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98893:FunctionDef_L22_C0", "vector": [4, 1, 0.66, 0.38, 1, 0.59, 0.5, 0, 0, 0, 0, 0, 0, 0, 9], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if not supports_color():\n style = no_style()\n else:\n DJANGO_COLORS = os.environ.get('DJANGO_COLORS', '')\n color_settings = termcolors.parse_color_setting(DJANGO_COLORS)\n if color_settings:\n class dummy: pass\n style = dummy()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98893:Assign_L25_C8", "label": "style = no_style()", "type": "assigned_variable", "loc": [25, 25], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98893:If_L24_C4", "vector": [14, 2, 0.5, 0.02, 2, 0.13, 0.0, 3, 3, 0, 0, 0, 32, 10, 1], "semantic": {"name": "style", "arg_names": [], "import_names": [], "rhs_call_name": "no_style", "annotation": ""}, "snippet": " style = no_style()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98893:Assign_L27_C8", "label": "DJANGO_COLORS = get()", "type": "assigned_variable", "loc": [27, 27], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98893:If_L24_C4", "vector": [14, 2, 0.54, 0.02, 2, 0.13, 0.3333, 16, 3, 2, 0, 0, 607, 10, 1], "semantic": {"name": "DJANGO_COLORS", "arg_names": [], "import_names": [], "rhs_call_name": "get", "annotation": ""}, "snippet": " DJANGO_COLORS = os.environ.get('DJANGO_COLORS', '')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98893:Assign_L28_C8", "label": "color_settings = parse_color_setting()", "type": "assigned_variable", "loc": [28, 28], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98893:If_L24_C4", "vector": [14, 2, 0.56, 0.02, 2, 0.13, 0.6667, 833, 3, 1, 0, 0, 715, 10, 1], "semantic": {"name": "color_settings", "arg_names": [], "import_names": [], "rhs_call_name": "parse_color_setting", "annotation": ""}, "snippet": " color_settings = termcolors.parse_color_setting(DJANGO_COLORS)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98893:If_L29_C8", "label": "if", "type": "if", "loc": [29, 42], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98893:If_L24_C4", "vector": [4, 2, 0.71, 0.28, 2, 0.13, 1.0, 0, 2, 0, 0, 0, 0, 0, 5], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if color_settings:\n class dummy: pass\n style = dummy()\n # The nocolor palette has all available roles.\n # Use that pallete as the basis for populating\n # the palette as defined in the environment.\n for role in termcolors.PALETTES[termcolors.NOCOLOR_PALETTE]:\n format = color_settings.get(role,{})"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98893:ClassDef_L30_C12", "label": "dummy", "type": "class", "loc": [30, 30], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98893:If_L29_C8", "vector": [3, 3, 0.6, 0.02, 3, 0.31, 0.0, 974, 0, 0, 0, 0, 0, 0, 0], "semantic": {"name": "dummy", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " class dummy: pass"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98893:Assign_L31_C12", "label": "style = dummy()", "type": "assigned_variable", "loc": [31, 31], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98893:If_L29_C8", "vector": [14, 3, 0.62, 0.02, 3, 0.31, 0.25, 3, 3, 0, 0, 0, 974, 10, 1], "semantic": {"name": "style", "arg_names": [], "import_names": [], "rhs_call_name": "dummy", "annotation": ""}, "snippet": " style = dummy()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98893:For_L35_C12", "label": "for role", "type": "for", "loc": [35, 37], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98893:If_L29_C8", "vector": [6, 3, 0.72, 0.06, 3, 0.31, 0.5, 580, 6, 0, 0, 0, 0, 0, 3], "semantic": {"name": "role", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for role in termcolors.PALETTES[termcolors.NOCOLOR_PALETTE]:\n format = color_settings.get(role,{})\n setattr(style, role, termcolors.make_style(**format))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98893:Assign_L36_C16", "label": "format = get()", "type": "assigned_variable", "loc": [36, 36], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98893:For_L35_C12", "vector": [14, 4, 0.72, 0.02, 4, 0.55, 0.0, 293, 3, 2, 0, 0, 607, 10, 1], "semantic": {"name": "format", "arg_names": [], "import_names": [], "rhs_call_name": "get", "annotation": ""}, "snippet": " format = color_settings.get(role,{})"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98893:Expr_L37_C16", "label": "setattr()", "type": "expression", "loc": [37, 37], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98893:For_L35_C12", "vector": [8, 4, 0.74, 0.02, 4, 0.55, 1.0, 501, 3, 3, 0, 0, 0, 0, 2], "semantic": {"name": "setattr", "arg_names": [], "import_names": [], "rhs_call_name": "setattr", "annotation": ""}, "snippet": " setattr(style, role, termcolors.make_style(**format))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98893:Assign_L40_C12", "label": "style.ERROR_OUTPUT =", "type": "assigned_variable", "loc": [40, 40], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98893:If_L29_C8", "vector": [14, 3, 0.8, 0.02, 3, 0.31, 0.75, 676, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "style.ERROR_OUTPUT", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " style.ERROR_OUTPUT = style.ERROR"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98893:Assign_L42_C12", "label": "style = no_style()", "type": "assigned_variable", "loc": [42, 42], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98893:If_L29_C8", "vector": [14, 3, 0.84, 0.02, 3, 0.31, 1.0, 3, 3, 0, 0, 0, 32, 10, 1], "semantic": {"name": "style", "arg_names": [], "import_names": [], "rhs_call_name": "no_style", "annotation": ""}, "snippet": " style = no_style()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98893:Return_L43_C4", "label": "return", "type": "return", "loc": [43, 43], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98893:FunctionDef_L22_C0", "vector": [13, 1, 0.86, 0.02, 1, 0.59, 1.0, 0, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return style"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98893:FunctionDef_L45_C0", "label": "no_style", "type": "function", "loc": [45, 50], "level": 0, "parent": null, "vector": [2, 0, 0.95, 0.12, 0, 0.66, 1.0, 32, 0, 0, 1, 0, 0, 0, 1], "semantic": {"name": "no_style", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "def no_style():\n \"\"\"Returns a Style object that has no colors.\"\"\"\n class dummy:\n def __getattr__(self, attr):\n return lambda x: x\n return dummy()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98893:Expr_L46_C4", "label": "expression", "type": "expression", "loc": [46, 46], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98893:FunctionDef_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": " \"\"\"Returns a Style object that has no colors.\"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98893:ClassDef_L47_C4", "label": "dummy", "type": "class", "loc": [47, 49], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98893:FunctionDef_L45_C0", "vector": [3, 1, 0.96, 0.06, 1, 0.98, 0.5, 974, 0, 1, 0, 0, 0, 0, 0], "semantic": {"name": "dummy", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " class dummy:\n def __getattr__(self, attr):\n return lambda x: x"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98893:FunctionDef_L48_C8", "label": "__getattr__", "type": "function", "loc": [48, 49], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98893:ClassDef_L47_C4", "vector": [2, 2, 0.97, 0.04, 2, 0.09, 0.0, 210, 0, 2, 1, 0, 0, 0, 0], "semantic": {"name": "__getattr__", "arg_names": ["self", "attr"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def __getattr__(self, attr):\n return lambda x: x"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98893:Return_L49_C12", "label": "return", "type": "return", "loc": [49, 49], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98893:FunctionDef_L48_C8", "vector": [13, 3, 0.98, 0.02, 3, 0.54, 0.0, 0, 9, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return lambda x: x"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98893:Return_L50_C4", "label": "return", "type": "return", "loc": [50, 50], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98893:FunctionDef_L45_C0", "vector": [13, 1, 1.0, 0.02, 1, 0.98, 1.0, 0, 3, 0, 0, 0, 0, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return dummy()"}]
[{"f": "ajibawa-2023/Python-Code-Large/train/row_98893:FunctionDef_L10_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98893:Expr_L11_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98893:FunctionDef_L10_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98893:Assign_L15_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98893:FunctionDef_L10_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98893:Assign_L17_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98893:FunctionDef_L10_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98893:If_L18_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98893:If_L18_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98893:Return_L19_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98893:FunctionDef_L10_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98893:Return_L20_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98893:FunctionDef_L22_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98893:Expr_L23_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98893:FunctionDef_L22_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98893:If_L24_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98893:If_L24_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98893:Assign_L25_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98893:If_L24_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98893:Assign_L27_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98893:If_L24_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98893:Assign_L28_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98893:If_L24_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98893:If_L29_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98893:If_L29_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98893:ClassDef_L30_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98893:If_L29_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98893:Assign_L31_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98893:If_L29_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98893:For_L35_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98893:For_L35_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98893:Assign_L36_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98893:For_L35_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98893:Expr_L37_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98893:If_L29_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98893:Assign_L40_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98893:If_L29_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98893:Assign_L42_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98893:FunctionDef_L22_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98893:Return_L43_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98893:FunctionDef_L45_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98893:Expr_L46_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98893:FunctionDef_L45_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98893:ClassDef_L47_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98893:ClassDef_L47_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98893:FunctionDef_L48_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98893:FunctionDef_L48_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98893:Return_L49_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98893:FunctionDef_L45_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98893:Return_L50_C4"}]
import sys from django.core.management.color import color_style from django.utils.itercompat import is_iterable class ModelErrorCollection: def __init__(self, outfile=sys.stdout): self.errors = [] self.outfile = outfile self.style = color_style() def add(self, context, error): self.errors.append((context, error)) self.outfile.write(self.style.ERROR("%s: %s\n" % (context, error))) def get_validation_errors(outfile, app=None): """ Validates all models that are part of the specified app. If no app name is provided, validates all models of all installed apps. Writes errors, if any, to outfile. Returns number of errors. """ from django.conf import settings from django.db import models, connection from django.db.models.loading import get_app_errors from django.db.models.fields.related import RelatedObject from django.db.models.deletion import SET_NULL, SET_DEFAULT e = ModelErrorCollection(outfile) for (app_name, error) in get_app_errors().items(): e.add(app_name, error) for cls in models.get_models(app): opts = cls._meta # Do field-specific validation. for f in opts.local_fields: if f.name == 'id' and not f.primary_key and opts.pk.name == 'id': e.add(opts, '"%s": You can\'t use "id" as a field name, because each model automatically gets an "id" field if none of the fields have primary_key=True. You need to either remove/rename your "id" field or add primary_key=True to a field.' % f.name) if f.name.endswith('_'): e.add(opts, '"%s": Field names cannot end with underscores, because this would lead to ambiguous queryset filters.' % f.name) if isinstance(f, models.CharField): try: max_length = int(f.max_length) if max_length <= 0: e.add(opts, '"%s": CharFields require a "max_length" attribute that is a positive integer.' % f.name) except (ValueError, TypeError): e.add(opts, '"%s": CharFields require a "max_length" attribute that is a positive integer.' % f.name) if isinstance(f, models.DecimalField): decimalp_msg ='"%s": DecimalFields require a "decimal_places" attribute that is a non-negative integer.' try: decimal_places = int(f.decimal_places) if decimal_places < 0: e.add(opts, decimalp_msg % f.name) except (ValueError, TypeError): e.add(opts, decimalp_msg % f.name) mdigits_msg = '"%s": DecimalFields require a "max_digits" attribute that is a positive integer.' try: max_digits = int(f.max_digits) if max_digits <= 0: e.add(opts, mdigits_msg % f.name) except (ValueError, TypeError): e.add(opts, mdigits_msg % f.name) if isinstance(f, models.FileField) and not f.upload_to: e.add(opts, '"%s": FileFields require an "upload_to" attribute.' % f.name) if isinstance(f, models.ImageField): # Try to import PIL in either of the two ways it can end up installed. try: from PIL import Image except ImportError: try: import Image except ImportError: e.add(opts, '"%s": To use ImageFields, you need to install the Python Imaging Library. Get it at http://www.pythonware.com/products/pil/ .' % f.name) if isinstance(f, models.BooleanField) and getattr(f, 'null', False): e.add(opts, '"%s": BooleanFields do not accept null values. Use a NullBooleanField instead.' % f.name) if f.choices: if isinstance(f.choices, basestring) or not is_iterable(f.choices): e.add(opts, '"%s": "choices" should be iterable (e.g., a tuple or list).' % f.name) else: for c in f.choices: if not isinstance(c, (list, tuple)) or len(c) != 2: e.add(opts, '"%s": "choices" should be a sequence of two-tuples.' % f.name) if f.db_index not in (None, True, False): e.add(opts, '"%s": "db_index" should be either None, True or False.' % f.name) # Perform any backend-specific field validation. connection.validation.validate_field(e, opts, f) # Check if the on_delete behavior is sane if f.rel and hasattr(f.rel, 'on_delete'): if f.rel.on_delete == SET_NULL and not f.null: e.add(opts, "'%s' specifies on_delete=SET_NULL, but cannot be null." % f.name) elif f.rel.on_delete == SET_DEFAULT and not f.has_default(): e.add(opts, "'%s' specifies on_delete=SET_DEFAULT, but has no default value." % f.name) # Check to see if the related field will clash with any existing # fields, m2m fields, m2m related objects or related objects if f.rel: if f.rel.to not in models.get_models(): e.add(opts, "'%s' has a relation with model %s, which has either not been installed or is abstract." % (f.name, f.rel.to)) # it is a string and we could not find the model it refers to # so skip the next section if isinstance(f.rel.to, (str, unicode)): continue # Make sure the related field specified by a ForeignKey is unique if not f.rel.to._meta.get_field(f.rel.field_name).unique: e.add(opts, "Field '%s' under model '%s' must have a unique=True constraint." % (f.rel.field_name, f.rel.to.__name__)) rel_opts = f.rel.to._meta rel_name = RelatedObject(f.rel.to, cls, f).get_accessor_name() rel_query_name = f.related_query_name() if not f.rel.is_hidden(): for r in rel_opts.fields: if r.name == rel_name: e.add(opts, "Accessor for field '%s' clashes with field '%s.%s'. Add a related_name argument to the definition for '%s'." % (f.name, rel_opts.object_name, r.name, f.name)) if r.name == rel_query_name: e.add(opts, "Reverse query name for field '%s' clashes with field '%s.%s'. Add a related_name argument to the definition for '%s'." % (f.name, rel_opts.object_name, r.name, f.name)) for r in rel_opts.local_many_to_many: if r.name == rel_name: e.add(opts, "Accessor for field '%s' clashes with m2m field '%s.%s'. Add a related_name argument to the definition for '%s'." % (f.name, rel_opts.object_name, r.name, f.name)) if r.name == rel_query_name: e.add(opts, "Reverse query name for field '%s' clashes with m2m field '%s.%s'. Add a related_name argument to the definition for '%s'." % (f.name, rel_opts.object_name, r.name, f.name)) for r in rel_opts.get_all_related_many_to_many_objects(): if r.get_accessor_name() == rel_name: e.add(opts, "Accessor for field '%s' clashes with related m2m field '%s.%s'. Add a related_name argument to the definition for '%s'." % (f.name, rel_opts.object_name, r.get_accessor_name(), f.name)) if r.get_accessor_name() == rel_query_name: e.add(opts, "Reverse query name for field '%s' clashes with related m2m field '%s.%s'. Add a related_name argument to the definition for '%s'." % (f.name, rel_opts.object_name, r.get_accessor_name(), f.name)) for r in rel_opts.get_all_related_objects(): if r.field is not f: if r.get_accessor_name() == rel_name: e.add(opts, "Accessor for field '%s' clashes with related field '%s.%s'. Add a related_name argument to the definition for '%s'." % (f.name, rel_opts.object_name, r.get_accessor_name(), f.name)) if r.get_accessor_name() == rel_query_name: e.add(opts, "Reverse query name for field '%s' clashes with related field '%s.%s'. Add a related_name argument to the definition for '%s'." % (f.name, rel_opts.object_name, r.get_accessor_name(), f.name)) seen_intermediary_signatures = [] for i, f in enumerate(opts.local_many_to_many): # Check to see if the related m2m field will clash with any # existing fields, m2m fields, m2m related objects or related # objects if f.rel.to not in models.get_models(): e.add(opts, "'%s' has an m2m relation with model %s, which has either not been installed or is abstract." % (f.name, f.rel.to)) # it is a string and we could not find the model it refers to # so skip the next section if isinstance(f.rel.to, (str, unicode)): continue # Check that the field is not set to unique. ManyToManyFields do not support unique. if f.unique: e.add(opts, "ManyToManyFields cannot be unique. Remove the unique argument on '%s'." % f.name) if f.rel.through is not None and not isinstance(f.rel.through, basestring): from_model, to_model = cls, f.rel.to if from_model == to_model and f.rel.symmetrical and not f.rel.through._meta.auto_created: e.add(opts, "Many-to-many fields with intermediate tables cannot be symmetrical.") seen_from, seen_to, seen_self = False, False, 0 for inter_field in f.rel.through._meta.fields: rel_to = getattr(inter_field.rel, 'to', None) if from_model == to_model: # relation to self if rel_to == from_model: seen_self += 1 if seen_self > 2: e.add(opts, "Intermediary model %s has more than " "two foreign keys to %s, which is ambiguous " "and is not permitted." % ( f.rel.through._meta.object_name, from_model._meta.object_name ) ) else: if rel_to == from_model: if seen_from: e.add(opts, "Intermediary model %s has more " "than one foreign key to %s, which is " "ambiguous and is not permitted." % ( f.rel.through._meta.object_name, from_model._meta.object_name ) ) else: seen_from = True elif rel_to == to_model: if seen_to: e.add(opts, "Intermediary model %s has more " "than one foreign key to %s, which is " "ambiguous and is not permitted." % ( f.rel.through._meta.object_name, rel_to._meta.object_name ) ) else: seen_to = True if f.rel.through not in models.get_models(include_auto_created=True): e.add(opts, "'%s' specifies an m2m relation through model " "%s, which has not been installed." % (f.name, f.rel.through) ) signature = (f.rel.to, cls, f.rel.through) if signature in seen_intermediary_signatures: e.add(opts, "The model %s has two manually-defined m2m " "relations through the model %s, which is not " "permitted. Please consider using an extra field on " "your intermediary model instead." % ( cls._meta.object_name, f.rel.through._meta.object_name ) ) else: seen_intermediary_signatures.append(signature) if not f.rel.through._meta.auto_created: seen_related_fk, seen_this_fk = False, False for field in f.rel.through._meta.fields: if field.rel: if not seen_related_fk and field.rel.to == f.rel.to: seen_related_fk = True elif field.rel.to == cls: seen_this_fk = True if not seen_related_fk or not seen_this_fk: e.add(opts, "'%s' is a manually-defined m2m relation " "through model %s, which does not have foreign keys " "to %s and %s" % (f.name, f.rel.through._meta.object_name, f.rel.to._meta.object_name, cls._meta.object_name) ) elif isinstance(f.rel.through, basestring): e.add(opts, "'%s' specifies an m2m relation through model %s, " "which has not been installed" % (f.name, f.rel.through) ) rel_opts = f.rel.to._meta rel_name = RelatedObject(f.rel.to, cls, f).get_accessor_name() rel_query_name = f.related_query_name() # If rel_name is none, there is no reverse accessor (this only # occurs for symmetrical m2m relations to self). If this is the # case, there are no clashes to check for this field, as there are # no reverse descriptors for this field. if rel_name is not None: for r in rel_opts.fields: if r.name == rel_name: e.add(opts, "Accessor for m2m field '%s' clashes with field '%s.%s'. Add a related_name argument to the definition for '%s'." % (f.name, rel_opts.object_name, r.name, f.name)) if r.name == rel_query_name: e.add(opts, "Reverse query name for m2m field '%s' clashes with field '%s.%s'. Add a related_name argument to the definition for '%s'." % (f.name, rel_opts.object_name, r.name, f.name)) for r in rel_opts.local_many_to_many: if r.name == rel_name: e.add(opts, "Accessor for m2m field '%s' clashes with m2m field '%s.%s'. Add a related_name argument to the definition for '%s'." % (f.name, rel_opts.object_name, r.name, f.name)) if r.name == rel_query_name: e.add(opts, "Reverse query name for m2m field '%s' clashes with m2m field '%s.%s'. Add a related_name argument to the definition for '%s'." % (f.name, rel_opts.object_name, r.name, f.name)) for r in rel_opts.get_all_related_many_to_many_objects(): if r.field is not f: if r.get_accessor_name() == rel_name: e.add(opts, "Accessor for m2m field '%s' clashes with related m2m field '%s.%s'. Add a related_name argument to the definition for '%s'." % (f.name, rel_opts.object_name, r.get_accessor_name(), f.name)) if r.get_accessor_name() == rel_query_name: e.add(opts, "Reverse query name for m2m field '%s' clashes with related m2m field '%s.%s'. Add a related_name argument to the definition for '%s'." % (f.name, rel_opts.object_name, r.get_accessor_name(), f.name)) for r in rel_opts.get_all_related_objects(): if r.get_accessor_name() == rel_name: e.add(opts, "Accessor for m2m field '%s' clashes with related field '%s.%s'. Add a related_name argument to the definition for '%s'." % (f.name, rel_opts.object_name, r.get_accessor_name(), f.name)) if r.get_accessor_name() == rel_query_name: e.add(opts, "Reverse query name for m2m field '%s' clashes with related field '%s.%s'. Add a related_name argument to the definition for '%s'." % (f.name, rel_opts.object_name, r.get_accessor_name(), f.name)) # Check ordering attribute. if opts.ordering: for field_name in opts.ordering: if field_name == '?': continue if field_name.startswith('-'): field_name = field_name[1:] if opts.order_with_respect_to and field_name == '_order': continue # Skip ordering in the format field1__field2 (FIXME: checking # this format would be nice, but it's a little fiddly). if '__' in field_name: continue try: opts.get_field(field_name, many_to_many=False) except models.FieldDoesNotExist: e.add(opts, '"ordering" refers to "%s", a field that doesn\'t exist.' % field_name) # Check unique_together. for ut in opts.unique_together: for field_name in ut: try: f = opts.get_field(field_name, many_to_many=True) except models.FieldDoesNotExist: e.add(opts, '"unique_together" refers to %s, a field that doesn\'t exist. Check your syntax.' % field_name) else: if isinstance(f.rel, models.ManyToManyRel): e.add(opts, '"unique_together" refers to %s. ManyToManyFields are not supported in unique_together.' % f.name) if f not in opts.local_fields: e.add(opts, '"unique_together" refers to %s. This is not in the same model as the unique_together statement.' % f.name) return len(e.errors)
ajibawa-2023/Python-Code-Large/train/row_98894
191
288
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_98894:Import_L1_C0", "label": "sys import sys", "type": "import", "loc": [1, 1], "level": 0, "parent": null, "vector": [1, 0, 0.0035, 0.0035, 0, 0.66, 0.0, 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_98894:ImportFrom_L2_C0", "label": "from django.core.management.color import color_style", "type": "import", "loc": [2, 2], "level": 0, "parent": null, "vector": [1, 0, 0.0069, 0.0035, 0, 0.66, 0.25, 526, 0, 1, 0, 0, 526, 0, 0], "semantic": {"name": "django.core.management.color", "arg_names": [], "import_names": ["color_style"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.core.management.color import color_style"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98894:ImportFrom_L3_C0", "label": "from django.utils.itercompat import is_iterable", "type": "import", "loc": [3, 3], "level": 0, "parent": null, "vector": [1, 0, 0.0104, 0.0035, 0, 0.66, 0.5, 358, 0, 1, 0, 0, 358, 0, 0], "semantic": {"name": "django.utils.itercompat", "arg_names": [], "import_names": ["is_iterable"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.utils.itercompat import is_iterable"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98894:ClassDef_L5_C0", "label": "ModelErrorCollection", "type": "class", "loc": [5, 13], "level": 0, "parent": null, "vector": [3, 0, 0.0312, 0.0312, 0, 0.66, 0.75, 326, 0, 2, 0, 0, 0, 0, 4], "semantic": {"name": "ModelErrorCollection", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class ModelErrorCollection:\n def __init__(self, outfile=sys.stdout):\n self.errors = []\n self.outfile = outfile\n self.style = color_style()\n\n def add(self, context, error):\n self.errors.append((context, error))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98894:FunctionDef_L6_C4", "label": "__init__", "type": "function", "loc": [6, 9], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98894:ClassDef_L5_C0", "vector": [2, 1, 0.026, 0.0139, 1, 0.57, 0.0, 555, 0, 2, 0, 0, 0, 0, 1], "semantic": {"name": "__init__", "arg_names": ["self", "outfile"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def __init__(self, outfile=sys.stdout):\n self.errors = []\n self.outfile = outfile\n self.style = color_style()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98894:Assign_L7_C8", "label": "self.errors =", "type": "assigned_variable", "loc": [7, 7], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98894:FunctionDef_L6_C4", "vector": [14, 2, 0.0243, 0.0035, 2, 0.99, 0.0, 165, 0, 0, 0, 0, 0, 5, 0], "semantic": {"name": "self.errors", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.errors = []"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98894:Assign_L8_C8", "label": "self.outfile =", "type": "assigned_variable", "loc": [8, 8], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98894:FunctionDef_L6_C4", "vector": [14, 2, 0.0278, 0.0035, 2, 0.99, 0.5, 579, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "self.outfile", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.outfile = outfile"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98894:Assign_L9_C8", "label": "self.style = color_style()", "type": "assigned_variable", "loc": [9, 9], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98894:FunctionDef_L6_C4", "vector": [14, 2, 0.0312, 0.0035, 2, 0.99, 1.0, 288, 3, 0, 0, 0, 836, 10, 1], "semantic": {"name": "self.style", "arg_names": [], "import_names": [], "rhs_call_name": "color_style", "annotation": ""}, "snippet": " self.style = color_style()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98894:FunctionDef_L11_C4", "label": "add", "type": "function", "loc": [11, 13], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98894:ClassDef_L5_C0", "vector": [2, 1, 0.0417, 0.0104, 1, 0.57, 1.0, 241, 0, 3, 0, 0, 0, 0, 3], "semantic": {"name": "add", "arg_names": ["self", "context", "error"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def add(self, context, error):\n self.errors.append((context, error))\n self.outfile.write(self.style.ERROR(\"%s: %s\\n\" % (context, error)))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98894:Expr_L12_C8", "label": "append()", "type": "expression", "loc": [12, 12], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98894:FunctionDef_L11_C4", "vector": [8, 2, 0.0417, 0.0035, 2, 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": " self.errors.append((context, error))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98894:Expr_L13_C8", "label": "write()", "type": "expression", "loc": [13, 13], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98894:FunctionDef_L11_C4", "vector": [8, 2, 0.0451, 0.0035, 2, 0.9, 1.0, 837, 3, 1, 0, 0, 0, 0, 2], "semantic": {"name": "write", "arg_names": [], "import_names": [], "rhs_call_name": "write", "annotation": ""}, "snippet": " self.outfile.write(self.style.ERROR(\"%s: %s\\n\" % (context, error)))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98894:FunctionDef_L15_C0", "label": "get_validation_errors", "type": "function", "loc": [15, 288], "level": 0, "parent": null, "vector": [2, 0, 0.526, 0.9514, 0, 0.66, 1.0, 642, 0, 2, 1, 0, 0, 0, 99], "semantic": {"name": "get_validation_errors", "arg_names": ["outfile", "app"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "def get_validation_errors(outfile, app=None):\n \"\"\"\n Validates all models that are part of the specified app. If no app name is provided,\n validates all models of all installed apps. Writes errors, if any, to outfile.\n Returns number of errors.\n \"\"\"\n from django.conf import settings\n from django.db import models, connection"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98894:Expr_L16_C4", "label": "expression", "type": "expression", "loc": [16, 20], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98894:FunctionDef_L15_C0", "vector": [8, 1, 0.0625, 0.0174, 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 Validates all models that are part of the specified app. If no app name is provided,\n validates all models of all installed apps. Writes errors, if any, to outfile.\n Returns number of errors.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98894:ImportFrom_L21_C4", "label": "from django.conf import settings", "type": "import", "loc": [21, 21], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98894:FunctionDef_L15_C0", "vector": [1, 1, 0.0729, 0.0035, 1, 0.23, 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_98894:ImportFrom_L22_C4", "label": "from django.db import models, connection", "type": "import", "loc": [22, 22], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98894:FunctionDef_L15_C0", "vector": [1, 1, 0.0764, 0.0035, 1, 0.23, 0.2222, 40, 0, 2, 0, 0, 40, 0, 0], "semantic": {"name": "django.db", "arg_names": [], "import_names": ["models", "connection"], "rhs_call_name": "", "annotation": ""}, "snippet": " from django.db import models, connection"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98894:ImportFrom_L23_C4", "label": "from django.db.models.loading import get_app_errors", "type": "import", "loc": [23, 23], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98894:FunctionDef_L15_C0", "vector": [1, 1, 0.0799, 0.0035, 1, 0.23, 0.3333, 343, 0, 1, 0, 0, 343, 0, 0], "semantic": {"name": "django.db.models.loading", "arg_names": [], "import_names": ["get_app_errors"], "rhs_call_name": "", "annotation": ""}, "snippet": " from django.db.models.loading import get_app_errors"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98894:ImportFrom_L24_C4", "label": "from django.db.models.fields.related import RelatedObject", "type": "import", "loc": [24, 24], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98894:FunctionDef_L15_C0", "vector": [1, 1, 0.0833, 0.0035, 1, 0.23, 0.4444, 410, 0, 1, 0, 0, 410, 0, 0], "semantic": {"name": "django.db.models.fields.related", "arg_names": [], "import_names": ["RelatedObject"], "rhs_call_name": "", "annotation": ""}, "snippet": " from django.db.models.fields.related import RelatedObject"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98894:ImportFrom_L25_C4", "label": "from django.db.models.deletion import SET_NULL, SET_DEFAULT", "type": "import", "loc": [25, 25], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98894:FunctionDef_L15_C0", "vector": [1, 1, 0.0868, 0.0035, 1, 0.23, 0.5556, 229, 0, 2, 0, 0, 229, 0, 0], "semantic": {"name": "django.db.models.deletion", "arg_names": [], "import_names": ["SET_NULL", "SET_DEFAULT"], "rhs_call_name": "", "annotation": ""}, "snippet": " from django.db.models.deletion import SET_NULL, SET_DEFAULT"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98894:Assign_L27_C4", "label": "e = ModelErrorCollection()", "type": "assigned_variable", "loc": [27, 27], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98894:FunctionDef_L15_C0", "vector": [14, 1, 0.0938, 0.0035, 1, 0.23, 0.6667, 175, 3, 1, 0, 0, 326, 10, 1], "semantic": {"name": "e", "arg_names": [], "import_names": [], "rhs_call_name": "ModelErrorCollection", "annotation": ""}, "snippet": " e = ModelErrorCollection(outfile)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98894:For_L29_C4", "label": "for app_name, error", "type": "for", "loc": [29, 30], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98894:FunctionDef_L15_C0", "vector": [6, 1, 0.1024, 0.0069, 1, 0.23, 0.7778, 553, 3, 0, 0, 0, 0, 0, 3], "semantic": {"name": "app_name, error", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for (app_name, error) in get_app_errors().items():\n e.add(app_name, error)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98894:Expr_L30_C8", "label": "add()", "type": "expression", "loc": [30, 30], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98894:For_L29_C4", "vector": [8, 2, 0.1042, 0.0035, 2, 0.85, 0.0, 241, 3, 2, 0, 0, 0, 0, 1], "semantic": {"name": "add", "arg_names": [], "import_names": [], "rhs_call_name": "add", "annotation": ""}, "snippet": " e.add(app_name, error)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98894:For_L32_C4", "label": "for cls", "type": "for", "loc": [32, 286], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98894:FunctionDef_L15_C0", "vector": [6, 1, 0.5521, 0.8854, 1, 0.23, 0.8889, 594, 3, 0, 0, 0, 0, 0, 99], "semantic": {"name": "cls", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for cls in models.get_models(app):\n opts = cls._meta\n\n # Do field-specific validation.\n for f in opts.local_fields:\n if f.name == 'id' and not f.primary_key and opts.pk.name == 'id':\n e.add(opts, '\"%s\": You can\\'t use \"id\" as a field name, because each model automatically gets an \"id\" field if none of the fields have primary_key=True. You need to either remove/rename your \"id\" field or add primary_key=True to a field.' % f.name)\n if f.name.endswith('_'):"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98894:Assign_L33_C8", "label": "opts =", "type": "assigned_variable", "loc": [33, 33], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98894:For_L32_C4", "vector": [14, 2, 0.1146, 0.0035, 2, 0.26, 0.0, 631, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "opts", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " opts = cls._meta"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98894:For_L36_C8", "label": "for f", "type": "for", "loc": [36, 134], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98894:For_L32_C4", "vector": [6, 2, 0.2951, 0.3438, 2, 0.26, 0.2, 899, 7, 0, 0, 0, 0, 0, 60], "semantic": {"name": "f", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for f in opts.local_fields:\n if f.name == 'id' and not f.primary_key and opts.pk.name == 'id':\n e.add(opts, '\"%s\": You can\\'t use \"id\" as a field name, because each model automatically gets an \"id\" field if none of the fields have primary_key=True. You need to either remove/rename your \"id\" field or add primary_key=True to a field.' % f.name)\n if f.name.endswith('_'):\n e.add(opts, '\"%s\": Field names cannot end with underscores, because this would lead to ambiguous queryset filters.' % f.name)\n if isinstance(f, models.CharField):\n try:\n max_length = int(f.max_length)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L37_C12", "label": "if", "type": "if", "loc": [37, 38], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98894:For_L36_C8", "vector": [4, 3, 0.1302, 0.0069, 3, 0.77, 0.0, 0, 0, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if f.name == 'id' and not f.primary_key and opts.pk.name == 'id':\n e.add(opts, '\"%s\": You can\\'t use \"id\" as a field name, because each model automatically gets an \"id\" field if none of the fields have primary_key=True. You need to either remove/rename your \"id\" field or add primary_key=True to a field.' % f.name)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98894:Expr_L38_C16", "label": "add()", "type": "expression", "loc": [38, 38], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L37_C12", "vector": [8, 4, 0.1319, 0.0035, 4, 0.65, 0.0, 241, 3, 2, 0, 0, 0, 0, 1], "semantic": {"name": "add", "arg_names": [], "import_names": [], "rhs_call_name": "add", "annotation": ""}, "snippet": " e.add(opts, '\"%s\": You can\\'t use \"id\" as a field name, because each model automatically gets an \"id\" field if none of the fields have primary_key=True. You need to either remove/rename your \"id\" field or add primary_key=True to a field.' % f.name)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L39_C12", "label": "if", "type": "if", "loc": [39, 40], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98894:For_L36_C8", "vector": [4, 3, 0.1372, 0.0069, 3, 0.77, 0.0909, 0, 3, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if f.name.endswith('_'):\n e.add(opts, '\"%s\": Field names cannot end with underscores, because this would lead to ambiguous queryset filters.' % f.name)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98894:Expr_L40_C16", "label": "add()", "type": "expression", "loc": [40, 40], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L39_C12", "vector": [8, 4, 0.1389, 0.0035, 4, 0.83, 0.0, 241, 3, 2, 0, 0, 0, 0, 1], "semantic": {"name": "add", "arg_names": [], "import_names": [], "rhs_call_name": "add", "annotation": ""}, "snippet": " e.add(opts, '\"%s\": Field names cannot end with underscores, because this would lead to ambiguous queryset filters.' % f.name)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L41_C12", "label": "if", "type": "if", "loc": [41, 47], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98894:For_L36_C8", "vector": [4, 3, 0.1528, 0.0243, 3, 0.77, 0.1818, 0, 3, 0, 0, 0, 0, 0, 4], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if isinstance(f, models.CharField):\n try:\n max_length = int(f.max_length)\n if max_length <= 0:\n e.add(opts, '\"%s\": CharFields require a \"max_length\" attribute that is a positive integer.' % f.name)\n except (ValueError, TypeError):\n e.add(opts, '\"%s\": CharFields require a \"max_length\" attribute that is a positive integer.' % f.name)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98894:Try_L42_C16", "label": "try", "type": "try", "loc": [42, 47], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L41_C12", "vector": [7, 4, 0.1545, 0.0208, 4, 0.9, 0.0, 0, 0, 1, 0, 0, 0, 0, 3], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " try:\n max_length = int(f.max_length)\n if max_length <= 0:\n e.add(opts, '\"%s\": CharFields require a \"max_length\" attribute that is a positive integer.' % f.name)\n except (ValueError, TypeError):\n e.add(opts, '\"%s\": CharFields require a \"max_length\" attribute that is a positive integer.' % f.name)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98894:Assign_L43_C20", "label": "max_length = int()", "type": "assigned_variable", "loc": [43, 43], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98894:Try_L42_C16", "vector": [14, 5, 0.1493, 0.0035, 5, 0.58, 0.0, 214, 3, 1, 0, 0, 901, 10, 1], "semantic": {"name": "max_length", "arg_names": [], "import_names": [], "rhs_call_name": "int", "annotation": ""}, "snippet": " max_length = int(f.max_length)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L44_C20", "label": "if", "type": "if", "loc": [44, 45], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98894:Try_L42_C16", "vector": [4, 5, 0.1545, 0.0069, 5, 0.58, 1.0, 0, 0, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if max_length <= 0:\n e.add(opts, '\"%s\": CharFields require a \"max_length\" attribute that is a positive integer.' % f.name)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98894:Expr_L45_C24", "label": "add()", "type": "expression", "loc": [45, 45], "level": 6, "parent": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L44_C20", "vector": [8, 6, 0.1562, 0.0035, 6, 0.64, 0.0, 241, 3, 2, 0, 0, 0, 0, 1], "semantic": {"name": "add", "arg_names": [], "import_names": [], "rhs_call_name": "add", "annotation": ""}, "snippet": " e.add(opts, '\"%s\": CharFields require a \"max_length\" attribute that is a positive integer.' % f.name)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98894:Expr_L47_C20", "label": "add()", "type": "expression", "loc": [47, 47], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98894:Try_L42_C16", "vector": [8, 5, 0.1632, 0.0035, 5, 0.58, 0.0, 241, 3, 2, 0, 0, 0, 0, 1], "semantic": {"name": "add", "arg_names": [], "import_names": [], "rhs_call_name": "add", "annotation": ""}, "snippet": " e.add(opts, '\"%s\": CharFields require a \"max_length\" attribute that is a positive integer.' % f.name)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L48_C12", "label": "if", "type": "if", "loc": [48, 62], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98894:For_L36_C8", "vector": [4, 3, 0.191, 0.0521, 3, 0.77, 0.2727, 0, 3, 0, 0, 0, 0, 0, 7], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if isinstance(f, models.DecimalField):\n decimalp_msg ='\"%s\": DecimalFields require a \"decimal_places\" attribute that is a non-negative integer.'\n try:\n decimal_places = int(f.decimal_places)\n if decimal_places < 0:\n e.add(opts, decimalp_msg % f.name)\n except (ValueError, TypeError):\n e.add(opts, decimalp_msg % f.name)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98894:Assign_L49_C16", "label": "decimalp_msg =", "type": "assigned_variable", "loc": [49, 49], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L48_C12", "vector": [14, 4, 0.1701, 0.0035, 4, 0.49, 0.0, 713, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "decimalp_msg", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " decimalp_msg ='\"%s\": DecimalFields require a \"decimal_places\" attribute that is a non-negative integer.'"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98894:Try_L50_C16", "label": "try", "type": "try", "loc": [50, 55], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L48_C12", "vector": [7, 4, 0.1823, 0.0208, 4, 0.49, 0.3333, 0, 0, 1, 0, 0, 0, 0, 3], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " try:\n decimal_places = int(f.decimal_places)\n if decimal_places < 0:\n e.add(opts, decimalp_msg % f.name)\n except (ValueError, TypeError):\n e.add(opts, decimalp_msg % f.name)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98894:Assign_L51_C20", "label": "decimal_places = int()", "type": "assigned_variable", "loc": [51, 51], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98894:Try_L50_C16", "vector": [14, 5, 0.1771, 0.0035, 5, 0.86, 0.0, 199, 3, 1, 0, 0, 901, 10, 1], "semantic": {"name": "decimal_places", "arg_names": [], "import_names": [], "rhs_call_name": "int", "annotation": ""}, "snippet": " decimal_places = int(f.decimal_places)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L52_C20", "label": "if", "type": "if", "loc": [52, 53], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98894:Try_L50_C16", "vector": [4, 5, 0.1823, 0.0069, 5, 0.86, 1.0, 0, 0, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if decimal_places < 0:\n e.add(opts, decimalp_msg % f.name)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98894:Expr_L53_C24", "label": "add()", "type": "expression", "loc": [53, 53], "level": 6, "parent": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L52_C20", "vector": [8, 6, 0.184, 0.0035, 6, 0.52, 0.0, 241, 3, 2, 0, 0, 0, 0, 1], "semantic": {"name": "add", "arg_names": [], "import_names": [], "rhs_call_name": "add", "annotation": ""}, "snippet": " e.add(opts, decimalp_msg % f.name)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98894:Expr_L55_C20", "label": "add()", "type": "expression", "loc": [55, 55], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98894:Try_L50_C16", "vector": [8, 5, 0.191, 0.0035, 5, 0.86, 0.0, 241, 3, 2, 0, 0, 0, 0, 1], "semantic": {"name": "add", "arg_names": [], "import_names": [], "rhs_call_name": "add", "annotation": ""}, "snippet": " e.add(opts, decimalp_msg % f.name)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98894:Assign_L56_C16", "label": "mdigits_msg =", "type": "assigned_variable", "loc": [56, 56], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L48_C12", "vector": [14, 4, 0.1944, 0.0035, 4, 0.49, 0.6667, 513, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "mdigits_msg", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " mdigits_msg = '\"%s\": DecimalFields require a \"max_digits\" attribute that is a positive integer.'"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98894:Try_L57_C16", "label": "try", "type": "try", "loc": [57, 62], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L48_C12", "vector": [7, 4, 0.2066, 0.0208, 4, 0.49, 1.0, 0, 0, 1, 0, 0, 0, 0, 3], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " try:\n max_digits = int(f.max_digits)\n if max_digits <= 0:\n e.add(opts, mdigits_msg % f.name)\n except (ValueError, TypeError):\n e.add(opts, mdigits_msg % f.name)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98894:Assign_L58_C20", "label": "max_digits = int()", "type": "assigned_variable", "loc": [58, 58], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98894:Try_L57_C16", "vector": [14, 5, 0.2014, 0.0035, 5, 0.31, 0.0, 23, 3, 1, 0, 0, 901, 10, 1], "semantic": {"name": "max_digits", "arg_names": [], "import_names": [], "rhs_call_name": "int", "annotation": ""}, "snippet": " max_digits = int(f.max_digits)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L59_C20", "label": "if", "type": "if", "loc": [59, 60], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98894:Try_L57_C16", "vector": [4, 5, 0.2066, 0.0069, 5, 0.31, 1.0, 0, 0, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if max_digits <= 0:\n e.add(opts, mdigits_msg % f.name)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98894:Expr_L60_C24", "label": "add()", "type": "expression", "loc": [60, 60], "level": 6, "parent": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L59_C20", "vector": [8, 6, 0.2083, 0.0035, 6, 0.21, 0.0, 241, 3, 2, 0, 0, 0, 0, 1], "semantic": {"name": "add", "arg_names": [], "import_names": [], "rhs_call_name": "add", "annotation": ""}, "snippet": " e.add(opts, mdigits_msg % f.name)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98894:Expr_L62_C20", "label": "add()", "type": "expression", "loc": [62, 62], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98894:Try_L57_C16", "vector": [8, 5, 0.2153, 0.0035, 5, 0.31, 0.0, 241, 3, 2, 0, 0, 0, 0, 1], "semantic": {"name": "add", "arg_names": [], "import_names": [], "rhs_call_name": "add", "annotation": ""}, "snippet": " e.add(opts, mdigits_msg % f.name)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L63_C12", "label": "if", "type": "if", "loc": [63, 64], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98894:For_L36_C8", "vector": [4, 3, 0.2205, 0.0069, 3, 0.77, 0.3636, 0, 0, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if isinstance(f, models.FileField) and not f.upload_to:\n e.add(opts, '\"%s\": FileFields require an \"upload_to\" attribute.' % f.name)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98894:Expr_L64_C16", "label": "add()", "type": "expression", "loc": [64, 64], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L63_C12", "vector": [8, 4, 0.2222, 0.0035, 4, 0.29, 0.0, 241, 3, 2, 0, 0, 0, 0, 1], "semantic": {"name": "add", "arg_names": [], "import_names": [], "rhs_call_name": "add", "annotation": ""}, "snippet": " e.add(opts, '\"%s\": FileFields require an \"upload_to\" attribute.' % f.name)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L65_C12", "label": "if", "type": "if", "loc": [65, 73], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98894:For_L36_C8", "vector": [4, 3, 0.2396, 0.0312, 3, 0.77, 0.4545, 0, 3, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if isinstance(f, models.ImageField):\n # Try to import PIL in either of the two ways it can end up installed.\n try:\n from PIL import Image\n except ImportError:\n try:\n import Image\n except ImportError:"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98894:Try_L67_C16", "label": "try", "type": "try", "loc": [67, 73], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L65_C12", "vector": [7, 4, 0.2431, 0.0243, 4, 0.27, 0.0, 0, 0, 1, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " try:\n from PIL import Image\n except ImportError:\n try:\n import Image\n except ImportError:\n e.add(opts, '\"%s\": To use ImageFields, you need to install the Python Imaging Library. Get it at http://www.pythonware.com/products/pil/ .' % f.name)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98894:ImportFrom_L68_C20", "label": "from PIL import Image", "type": "import", "loc": [68, 68], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98894:Try_L67_C16", "vector": [1, 5, 0.2361, 0.0035, 5, 0.28, 0.0, 556, 0, 1, 0, 0, 556, 0, 0], "semantic": {"name": "PIL", "arg_names": [], "import_names": ["Image"], "rhs_call_name": "", "annotation": ""}, "snippet": " from PIL import Image"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98894:Try_L70_C20", "label": "try", "type": "try", "loc": [70, 73], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98894:Try_L67_C16", "vector": [7, 5, 0.2483, 0.0139, 5, 0.28, 0.0, 0, 0, 1, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " try:\n import Image\n except ImportError:\n e.add(opts, '\"%s\": To use ImageFields, you need to install the Python Imaging Library. Get it at http://www.pythonware.com/products/pil/ .' % f.name)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98894:Import_L71_C24", "label": "Image import Image", "type": "import", "loc": [71, 71], "level": 6, "parent": "ajibawa-2023/Python-Code-Large/train/row_98894:Try_L70_C20", "vector": [1, 6, 0.2465, 0.0035, 6, 0.57, 0.0, 721, 0, 1, 0, 0, 721, 0, 0], "semantic": {"name": "Image", "arg_names": [], "import_names": ["Image"], "rhs_call_name": "", "annotation": ""}, "snippet": " import Image"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98894:Expr_L73_C24", "label": "add()", "type": "expression", "loc": [73, 73], "level": 6, "parent": "ajibawa-2023/Python-Code-Large/train/row_98894:Try_L70_C20", "vector": [8, 6, 0.2535, 0.0035, 6, 0.57, 0.0, 241, 3, 2, 0, 0, 0, 0, 1], "semantic": {"name": "add", "arg_names": [], "import_names": [], "rhs_call_name": "add", "annotation": ""}, "snippet": " e.add(opts, '\"%s\": To use ImageFields, you need to install the Python Imaging Library. Get it at http://www.pythonware.com/products/pil/ .' % f.name)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L74_C12", "label": "if", "type": "if", "loc": [74, 75], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98894:For_L36_C8", "vector": [4, 3, 0.2587, 0.0069, 3, 0.77, 0.5455, 0, 0, 0, 0, 0, 0, 0, 3], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if isinstance(f, models.BooleanField) and getattr(f, 'null', False):\n e.add(opts, '\"%s\": BooleanFields do not accept null values. Use a NullBooleanField instead.' % f.name)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98894:Expr_L75_C16", "label": "add()", "type": "expression", "loc": [75, 75], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L74_C12", "vector": [8, 4, 0.2604, 0.0035, 4, 0.8, 0.0, 241, 3, 2, 0, 0, 0, 0, 1], "semantic": {"name": "add", "arg_names": [], "import_names": [], "rhs_call_name": "add", "annotation": ""}, "snippet": " e.add(opts, '\"%s\": BooleanFields do not accept null values. Use a NullBooleanField instead.' % f.name)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L76_C12", "label": "if", "type": "if", "loc": [76, 82], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98894:For_L36_C8", "vector": [4, 3, 0.2743, 0.0243, 3, 0.77, 0.6364, 0, 7, 0, 0, 0, 0, 0, 6], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if f.choices:\n if isinstance(f.choices, basestring) or not is_iterable(f.choices):\n e.add(opts, '\"%s\": \"choices\" should be iterable (e.g., a tuple or list).' % f.name)\n else:\n for c in f.choices:\n if not isinstance(c, (list, tuple)) or len(c) != 2:\n e.add(opts, '\"%s\": \"choices\" should be a sequence of two-tuples.' % f.name)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L77_C16", "label": "if", "type": "if", "loc": [77, 82], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L76_C12", "vector": [4, 4, 0.276, 0.0208, 4, 0.53, 0.0, 0, 0, 0, 0, 0, 0, 0, 6], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if isinstance(f.choices, basestring) or not is_iterable(f.choices):\n e.add(opts, '\"%s\": \"choices\" should be iterable (e.g., a tuple or list).' % f.name)\n else:\n for c in f.choices:\n if not isinstance(c, (list, tuple)) or len(c) != 2:\n e.add(opts, '\"%s\": \"choices\" should be a sequence of two-tuples.' % f.name)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98894:Expr_L78_C20", "label": "add()", "type": "expression", "loc": [78, 78], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L77_C16", "vector": [8, 5, 0.2708, 0.0035, 5, 0.56, 0.0, 241, 3, 2, 0, 0, 0, 0, 1], "semantic": {"name": "add", "arg_names": [], "import_names": [], "rhs_call_name": "add", "annotation": ""}, "snippet": " e.add(opts, '\"%s\": \"choices\" should be iterable (e.g., a tuple or list).' % f.name)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98894:For_L80_C20", "label": "for c", "type": "for", "loc": [80, 82], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L77_C16", "vector": [6, 5, 0.2812, 0.0104, 5, 0.56, 1.0, 411, 7, 0, 0, 0, 0, 0, 3], "semantic": {"name": "c", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for c in f.choices:\n if not isinstance(c, (list, tuple)) or len(c) != 2:\n e.add(opts, '\"%s\": \"choices\" should be a sequence of two-tuples.' % f.name)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L81_C24", "label": "if", "type": "if", "loc": [81, 82], "level": 6, "parent": "ajibawa-2023/Python-Code-Large/train/row_98894:For_L80_C20", "vector": [4, 6, 0.283, 0.0069, 6, 0.9, 0.0, 0, 0, 0, 0, 0, 0, 0, 3], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if not isinstance(c, (list, tuple)) or len(c) != 2:\n e.add(opts, '\"%s\": \"choices\" should be a sequence of two-tuples.' % f.name)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98894:Expr_L82_C28", "label": "add()", "type": "expression", "loc": [82, 82], "level": 7, "parent": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L81_C24", "vector": [8, 7, 0.2847, 0.0035, 7, 0.63, 0.0, 241, 3, 2, 0, 0, 0, 0, 1], "semantic": {"name": "add", "arg_names": [], "import_names": [], "rhs_call_name": "add", "annotation": ""}, "snippet": " e.add(opts, '\"%s\": \"choices\" should be a sequence of two-tuples.' % f.name)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L83_C12", "label": "if", "type": "if", "loc": [83, 84], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98894:For_L36_C8", "vector": [4, 3, 0.2899, 0.0069, 3, 0.77, 0.7273, 0, 0, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if f.db_index not in (None, True, False):\n e.add(opts, '\"%s\": \"db_index\" should be either None, True or False.' % f.name)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98894:Expr_L84_C16", "label": "add()", "type": "expression", "loc": [84, 84], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L83_C12", "vector": [8, 4, 0.2917, 0.0035, 4, 0.58, 0.0, 241, 3, 2, 0, 0, 0, 0, 1], "semantic": {"name": "add", "arg_names": [], "import_names": [], "rhs_call_name": "add", "annotation": ""}, "snippet": " e.add(opts, '\"%s\": \"db_index\" should be either None, True or False.' % f.name)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98894:Expr_L87_C12", "label": "validate_field()", "type": "expression", "loc": [87, 87], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98894:For_L36_C8", "vector": [8, 3, 0.3021, 0.0035, 3, 0.77, 0.8182, 162, 3, 3, 0, 0, 0, 0, 1], "semantic": {"name": "validate_field", "arg_names": [], "import_names": [], "rhs_call_name": "validate_field", "annotation": ""}, "snippet": " connection.validation.validate_field(e, opts, f)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L90_C12", "label": "if", "type": "if", "loc": [90, 94], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98894:For_L36_C8", "vector": [4, 3, 0.3194, 0.0174, 3, 0.77, 0.9091, 0, 0, 0, 0, 0, 0, 0, 4], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if f.rel and hasattr(f.rel, 'on_delete'):\n if f.rel.on_delete == SET_NULL and not f.null:\n e.add(opts, \"'%s' specifies on_delete=SET_NULL, but cannot be null.\" % f.name)\n elif f.rel.on_delete == SET_DEFAULT and not f.has_default():\n e.add(opts, \"'%s' specifies on_delete=SET_DEFAULT, but has no default value.\" % f.name)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L91_C16", "label": "if", "type": "if", "loc": [91, 94], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L90_C12", "vector": [4, 4, 0.3212, 0.0139, 4, 0.66, 0.0, 0, 0, 0, 0, 0, 0, 0, 3], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if f.rel.on_delete == SET_NULL and not f.null:\n e.add(opts, \"'%s' specifies on_delete=SET_NULL, but cannot be null.\" % f.name)\n elif f.rel.on_delete == SET_DEFAULT and not f.has_default():\n e.add(opts, \"'%s' specifies on_delete=SET_DEFAULT, but has no default value.\" % f.name)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98894:Expr_L92_C20", "label": "add()", "type": "expression", "loc": [92, 92], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L91_C16", "vector": [8, 5, 0.3194, 0.0035, 5, 0.9, 0.0, 241, 3, 2, 0, 0, 0, 0, 1], "semantic": {"name": "add", "arg_names": [], "import_names": [], "rhs_call_name": "add", "annotation": ""}, "snippet": " e.add(opts, \"'%s' specifies on_delete=SET_NULL, but cannot be null.\" % f.name)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L93_C16", "label": "if", "type": "if", "loc": [93, 94], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L91_C16", "vector": [4, 5, 0.3247, 0.0069, 5, 0.9, 1.0, 0, 0, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " elif f.rel.on_delete == SET_DEFAULT and not f.has_default():\n e.add(opts, \"'%s' specifies on_delete=SET_DEFAULT, but has no default value.\" % f.name)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98894:Expr_L94_C20", "label": "add()", "type": "expression", "loc": [94, 94], "level": 6, "parent": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L93_C16", "vector": [8, 6, 0.3264, 0.0035, 6, 0.64, 0.0, 241, 3, 2, 0, 0, 0, 0, 1], "semantic": {"name": "add", "arg_names": [], "import_names": [], "rhs_call_name": "add", "annotation": ""}, "snippet": " e.add(opts, \"'%s' specifies on_delete=SET_DEFAULT, but has no default value.\" % f.name)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L98_C12", "label": "if", "type": "if", "loc": [98, 134], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98894:For_L36_C8", "vector": [4, 3, 0.4028, 0.1285, 3, 0.77, 1.0, 0, 7, 0, 0, 0, 0, 0, 27], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if f.rel:\n if f.rel.to not in models.get_models():\n e.add(opts, \"'%s' has a relation with model %s, which has either not been installed or is abstract.\" % (f.name, f.rel.to))\n # it is a string and we could not find the model it refers to\n # so skip the next section\n if isinstance(f.rel.to, (str, unicode)):\n continue\n"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L99_C16", "label": "if", "type": "if", "loc": [99, 100], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L98_C12", "vector": [4, 4, 0.3455, 0.0069, 4, 0.45, 0.0, 0, 0, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if f.rel.to not in models.get_models():\n e.add(opts, \"'%s' has a relation with model %s, which has either not been installed or is abstract.\" % (f.name, f.rel.to))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98894:Expr_L100_C20", "label": "add()", "type": "expression", "loc": [100, 100], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L99_C16", "vector": [8, 5, 0.3472, 0.0035, 5, 0.25, 0.0, 241, 3, 2, 0, 0, 0, 0, 1], "semantic": {"name": "add", "arg_names": [], "import_names": [], "rhs_call_name": "add", "annotation": ""}, "snippet": " e.add(opts, \"'%s' has a relation with model %s, which has either not been installed or is abstract.\" % (f.name, f.rel.to))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L103_C16", "label": "if", "type": "if", "loc": [103, 104], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L98_C12", "vector": [4, 4, 0.3594, 0.0069, 4, 0.45, 0.1667, 0, 3, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if isinstance(f.rel.to, (str, unicode)):\n continue"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L107_C16", "label": "if", "type": "if", "loc": [107, 108], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L98_C12", "vector": [4, 4, 0.3733, 0.0069, 4, 0.45, 0.3333, 0, 0, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if not f.rel.to._meta.get_field(f.rel.field_name).unique:\n e.add(opts, \"Field '%s' under model '%s' must have a unique=True constraint.\" % (f.rel.field_name, f.rel.to.__name__))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98894:Expr_L108_C20", "label": "add()", "type": "expression", "loc": [108, 108], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L107_C16", "vector": [8, 5, 0.375, 0.0035, 5, 0.49, 0.0, 241, 3, 2, 0, 0, 0, 0, 1], "semantic": {"name": "add", "arg_names": [], "import_names": [], "rhs_call_name": "add", "annotation": ""}, "snippet": " e.add(opts, \"Field '%s' under model '%s' must have a unique=True constraint.\" % (f.rel.field_name, f.rel.to.__name__))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98894:Assign_L110_C16", "label": "rel_opts =", "type": "assigned_variable", "loc": [110, 110], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L98_C12", "vector": [14, 4, 0.3819, 0.0035, 4, 0.45, 0.5, 178, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "rel_opts", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " rel_opts = f.rel.to._meta"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98894:Assign_L111_C16", "label": "rel_name = get_accessor_name()", "type": "assigned_variable", "loc": [111, 111], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L98_C12", "vector": [14, 4, 0.3854, 0.0035, 4, 0.45, 0.6667, 705, 3, 0, 0, 0, 315, 10, 2], "semantic": {"name": "rel_name", "arg_names": [], "import_names": [], "rhs_call_name": "get_accessor_name", "annotation": ""}, "snippet": " rel_name = RelatedObject(f.rel.to, cls, f).get_accessor_name()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98894:Assign_L112_C16", "label": "rel_query_name = related_query_name()", "type": "assigned_variable", "loc": [112, 112], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L98_C12", "vector": [14, 4, 0.3889, 0.0035, 4, 0.45, 0.8333, 908, 3, 0, 0, 0, 121, 10, 1], "semantic": {"name": "rel_query_name", "arg_names": [], "import_names": [], "rhs_call_name": "related_query_name", "annotation": ""}, "snippet": " rel_query_name = f.related_query_name()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L113_C16", "label": "if", "type": "if", "loc": [113, 134], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L98_C12", "vector": [4, 4, 0.4288, 0.0764, 4, 0.45, 1.0, 0, 0, 0, 0, 0, 0, 0, 19], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if not f.rel.is_hidden():\n for r in rel_opts.fields:\n if r.name == rel_name:\n e.add(opts, \"Accessor for field '%s' clashes with field '%s.%s'. Add a related_name argument to the definition for '%s'.\" % (f.name, rel_opts.object_name, r.name, f.name))\n if r.name == rel_query_name:\n e.add(opts, \"Reverse query name for field '%s' clashes with field '%s.%s'. Add a related_name argument to the definition for '%s'.\" % (f.name, rel_opts.object_name, r.name, f.name))\n for r in rel_opts.local_many_to_many:\n if r.name == rel_name:"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98894:For_L114_C20", "label": "for r", "type": "for", "loc": [114, 118], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L113_C16", "vector": [6, 5, 0.4028, 0.0174, 5, 0.57, 0.0, 436, 7, 0, 0, 0, 0, 0, 2], "semantic": {"name": "r", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for r in rel_opts.fields:\n if r.name == rel_name:\n e.add(opts, \"Accessor for field '%s' clashes with field '%s.%s'. Add a related_name argument to the definition for '%s'.\" % (f.name, rel_opts.object_name, r.name, f.name))\n if r.name == rel_query_name:\n e.add(opts, \"Reverse query name for field '%s' clashes with field '%s.%s'. Add a related_name argument to the definition for '%s'.\" % (f.name, rel_opts.object_name, r.name, f.name))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L115_C24", "label": "if", "type": "if", "loc": [115, 116], "level": 6, "parent": "ajibawa-2023/Python-Code-Large/train/row_98894:For_L114_C20", "vector": [4, 6, 0.401, 0.0069, 6, 0.89, 0.0, 0, 0, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if r.name == rel_name:\n e.add(opts, \"Accessor for field '%s' clashes with field '%s.%s'. Add a related_name argument to the definition for '%s'.\" % (f.name, rel_opts.object_name, r.name, f.name))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98894:Expr_L116_C28", "label": "add()", "type": "expression", "loc": [116, 116], "level": 7, "parent": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L115_C24", "vector": [8, 7, 0.4028, 0.0035, 7, 0.62, 0.0, 241, 3, 2, 0, 0, 0, 0, 1], "semantic": {"name": "add", "arg_names": [], "import_names": [], "rhs_call_name": "add", "annotation": ""}, "snippet": " e.add(opts, \"Accessor for field '%s' clashes with field '%s.%s'. Add a related_name argument to the definition for '%s'.\" % (f.name, rel_opts.object_name, r.name, f.name))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L117_C24", "label": "if", "type": "if", "loc": [117, 118], "level": 6, "parent": "ajibawa-2023/Python-Code-Large/train/row_98894:For_L114_C20", "vector": [4, 6, 0.408, 0.0069, 6, 0.89, 1.0, 0, 0, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if r.name == rel_query_name:\n e.add(opts, \"Reverse query name for field '%s' clashes with field '%s.%s'. Add a related_name argument to the definition for '%s'.\" % (f.name, rel_opts.object_name, r.name, f.name))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98894:Expr_L118_C28", "label": "add()", "type": "expression", "loc": [118, 118], "level": 7, "parent": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L117_C24", "vector": [8, 7, 0.4097, 0.0035, 7, 0.69, 0.0, 241, 3, 2, 0, 0, 0, 0, 1], "semantic": {"name": "add", "arg_names": [], "import_names": [], "rhs_call_name": "add", "annotation": ""}, "snippet": " e.add(opts, \"Reverse query name for field '%s' clashes with field '%s.%s'. Add a related_name argument to the definition for '%s'.\" % (f.name, rel_opts.object_name, r.name, f.name))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98894:For_L119_C20", "label": "for r", "type": "for", "loc": [119, 123], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L113_C16", "vector": [6, 5, 0.4201, 0.0174, 5, 0.57, 0.3333, 436, 7, 0, 0, 0, 0, 0, 2], "semantic": {"name": "r", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for r in rel_opts.local_many_to_many:\n if r.name == rel_name:\n e.add(opts, \"Accessor for field '%s' clashes with m2m field '%s.%s'. Add a related_name argument to the definition for '%s'.\" % (f.name, rel_opts.object_name, r.name, f.name))\n if r.name == rel_query_name:\n e.add(opts, \"Reverse query name for field '%s' clashes with m2m field '%s.%s'. Add a related_name argument to the definition for '%s'.\" % (f.name, rel_opts.object_name, r.name, f.name))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L120_C24", "label": "if", "type": "if", "loc": [120, 121], "level": 6, "parent": "ajibawa-2023/Python-Code-Large/train/row_98894:For_L119_C20", "vector": [4, 6, 0.4184, 0.0069, 6, 0.5, 0.0, 0, 0, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if r.name == rel_name:\n e.add(opts, \"Accessor for field '%s' clashes with m2m field '%s.%s'. Add a related_name argument to the definition for '%s'.\" % (f.name, rel_opts.object_name, r.name, f.name))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98894:Expr_L121_C28", "label": "add()", "type": "expression", "loc": [121, 121], "level": 7, "parent": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L120_C24", "vector": [8, 7, 0.4201, 0.0035, 7, 0.78, 0.0, 241, 3, 2, 0, 0, 0, 0, 1], "semantic": {"name": "add", "arg_names": [], "import_names": [], "rhs_call_name": "add", "annotation": ""}, "snippet": " e.add(opts, \"Accessor for field '%s' clashes with m2m field '%s.%s'. Add a related_name argument to the definition for '%s'.\" % (f.name, rel_opts.object_name, r.name, f.name))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L122_C24", "label": "if", "type": "if", "loc": [122, 123], "level": 6, "parent": "ajibawa-2023/Python-Code-Large/train/row_98894:For_L119_C20", "vector": [4, 6, 0.4253, 0.0069, 6, 0.5, 1.0, 0, 0, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if r.name == rel_query_name:\n e.add(opts, \"Reverse query name for field '%s' clashes with m2m field '%s.%s'. Add a related_name argument to the definition for '%s'.\" % (f.name, rel_opts.object_name, r.name, f.name))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98894:Expr_L123_C28", "label": "add()", "type": "expression", "loc": [123, 123], "level": 7, "parent": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L122_C24", "vector": [8, 7, 0.4271, 0.0035, 7, 0.85, 0.0, 241, 3, 2, 0, 0, 0, 0, 1], "semantic": {"name": "add", "arg_names": [], "import_names": [], "rhs_call_name": "add", "annotation": ""}, "snippet": " e.add(opts, \"Reverse query name for field '%s' clashes with m2m field '%s.%s'. Add a related_name argument to the definition for '%s'.\" % (f.name, rel_opts.object_name, r.name, f.name))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98894:For_L124_C20", "label": "for r", "type": "for", "loc": [124, 128], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L113_C16", "vector": [6, 5, 0.4375, 0.0174, 5, 0.57, 0.6667, 436, 3, 0, 0, 0, 0, 0, 7], "semantic": {"name": "r", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for r in rel_opts.get_all_related_many_to_many_objects():\n if r.get_accessor_name() == rel_name:\n e.add(opts, \"Accessor for field '%s' clashes with related m2m field '%s.%s'. Add a related_name argument to the definition for '%s'.\" % (f.name, rel_opts.object_name, r.get_accessor_name(), f.name))\n if r.get_accessor_name() == rel_query_name:\n e.add(opts, \"Reverse query name for field '%s' clashes with related m2m field '%s.%s'. Add a related_name argument to the definition for '%s'.\" % (f.name, rel_opts.object_name, r.get_accessor_name(), f.name))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L125_C24", "label": "if", "type": "if", "loc": [125, 126], "level": 6, "parent": "ajibawa-2023/Python-Code-Large/train/row_98894:For_L124_C20", "vector": [4, 6, 0.4358, 0.0069, 6, 0.77, 0.0, 0, 0, 0, 0, 0, 0, 0, 3], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if r.get_accessor_name() == rel_name:\n e.add(opts, \"Accessor for field '%s' clashes with related m2m field '%s.%s'. Add a related_name argument to the definition for '%s'.\" % (f.name, rel_opts.object_name, r.get_accessor_name(), f.name))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98894:Expr_L126_C28", "label": "add()", "type": "expression", "loc": [126, 126], "level": 7, "parent": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L125_C24", "vector": [8, 7, 0.4375, 0.0035, 7, 0.53, 0.0, 241, 3, 2, 0, 0, 0, 0, 2], "semantic": {"name": "add", "arg_names": [], "import_names": [], "rhs_call_name": "add", "annotation": ""}, "snippet": " e.add(opts, \"Accessor for field '%s' clashes with related m2m field '%s.%s'. Add a related_name argument to the definition for '%s'.\" % (f.name, rel_opts.object_name, r.get_accessor_name(), f.name))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L127_C24", "label": "if", "type": "if", "loc": [127, 128], "level": 6, "parent": "ajibawa-2023/Python-Code-Large/train/row_98894:For_L124_C20", "vector": [4, 6, 0.4427, 0.0069, 6, 0.77, 1.0, 0, 0, 0, 0, 0, 0, 0, 3], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if r.get_accessor_name() == rel_query_name:\n e.add(opts, \"Reverse query name for field '%s' clashes with related m2m field '%s.%s'. Add a related_name argument to the definition for '%s'.\" % (f.name, rel_opts.object_name, r.get_accessor_name(), f.name))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98894:Expr_L128_C28", "label": "add()", "type": "expression", "loc": [128, 128], "level": 7, "parent": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L127_C24", "vector": [8, 7, 0.4444, 0.0035, 7, 0.73, 0.0, 241, 3, 2, 0, 0, 0, 0, 2], "semantic": {"name": "add", "arg_names": [], "import_names": [], "rhs_call_name": "add", "annotation": ""}, "snippet": " e.add(opts, \"Reverse query name for field '%s' clashes with related m2m field '%s.%s'. Add a related_name argument to the definition for '%s'.\" % (f.name, rel_opts.object_name, r.get_accessor_name(), f.name))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98894:For_L129_C20", "label": "for r", "type": "for", "loc": [129, 134], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L113_C16", "vector": [6, 5, 0.4566, 0.0208, 5, 0.57, 1.0, 436, 3, 0, 0, 0, 0, 0, 7], "semantic": {"name": "r", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for r in rel_opts.get_all_related_objects():\n if r.field is not f:\n if r.get_accessor_name() == rel_name:\n e.add(opts, \"Accessor for field '%s' clashes with related field '%s.%s'. Add a related_name argument to the definition for '%s'.\" % (f.name, rel_opts.object_name, r.get_accessor_name(), f.name))\n if r.get_accessor_name() == rel_query_name:\n e.add(opts, \"Reverse query name for field '%s' clashes with related field '%s.%s'. Add a related_name argument to the definition for '%s'.\" % (f.name, rel_opts.object_name, r.get_accessor_name(), f.name))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L130_C24", "label": "if", "type": "if", "loc": [130, 134], "level": 6, "parent": "ajibawa-2023/Python-Code-Large/train/row_98894:For_L129_C20", "vector": [4, 6, 0.4583, 0.0174, 6, 0.14, 0.0, 0, 0, 0, 0, 0, 0, 0, 6], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if r.field is not f:\n if r.get_accessor_name() == rel_name:\n e.add(opts, \"Accessor for field '%s' clashes with related field '%s.%s'. Add a related_name argument to the definition for '%s'.\" % (f.name, rel_opts.object_name, r.get_accessor_name(), f.name))\n if r.get_accessor_name() == rel_query_name:\n e.add(opts, \"Reverse query name for field '%s' clashes with related field '%s.%s'. Add a related_name argument to the definition for '%s'.\" % (f.name, rel_opts.object_name, r.get_accessor_name(), f.name))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L131_C28", "label": "if", "type": "if", "loc": [131, 132], "level": 7, "parent": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L130_C24", "vector": [4, 7, 0.4566, 0.0069, 7, 0.46, 0.0, 0, 0, 0, 0, 0, 0, 0, 3], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if r.get_accessor_name() == rel_name:\n e.add(opts, \"Accessor for field '%s' clashes with related field '%s.%s'. Add a related_name argument to the definition for '%s'.\" % (f.name, rel_opts.object_name, r.get_accessor_name(), f.name))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98894:Expr_L132_C32", "label": "add()", "type": "expression", "loc": [132, 132], "level": 8, "parent": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L131_C28", "vector": [8, 8, 0.4583, 0.0035, 8, 0.87, 0.0, 241, 3, 2, 0, 0, 0, 0, 2], "semantic": {"name": "add", "arg_names": [], "import_names": [], "rhs_call_name": "add", "annotation": ""}, "snippet": " e.add(opts, \"Accessor for field '%s' clashes with related field '%s.%s'. Add a related_name argument to the definition for '%s'.\" % (f.name, rel_opts.object_name, r.get_accessor_name(), f.name))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L133_C28", "label": "if", "type": "if", "loc": [133, 134], "level": 7, "parent": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L130_C24", "vector": [4, 7, 0.4635, 0.0069, 7, 0.46, 1.0, 0, 0, 0, 0, 0, 0, 0, 3], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if r.get_accessor_name() == rel_query_name:\n e.add(opts, \"Reverse query name for field '%s' clashes with related field '%s.%s'. Add a related_name argument to the definition for '%s'.\" % (f.name, rel_opts.object_name, r.get_accessor_name(), f.name))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98894:Expr_L134_C32", "label": "add()", "type": "expression", "loc": [134, 134], "level": 8, "parent": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L133_C28", "vector": [8, 8, 0.4653, 0.0035, 8, 0.29, 0.0, 241, 3, 2, 0, 0, 0, 0, 2], "semantic": {"name": "add", "arg_names": [], "import_names": [], "rhs_call_name": "add", "annotation": ""}, "snippet": " e.add(opts, \"Reverse query name for field '%s' clashes with related field '%s.%s'. Add a related_name argument to the definition for '%s'.\" % (f.name, rel_opts.object_name, r.get_accessor_name(), f.name))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98894:Assign_L136_C8", "label": "seen_intermediary_signatures =", "type": "assigned_variable", "loc": [136, 136], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98894:For_L32_C4", "vector": [14, 2, 0.4722, 0.0035, 2, 0.26, 0.4, 694, 0, 0, 0, 0, 0, 5, 0], "semantic": {"name": "seen_intermediary_signatures", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " seen_intermediary_signatures = []"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98894:For_L137_C8", "label": "for i, f", "type": "for", "loc": [137, 256], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98894:For_L32_C4", "vector": [6, 2, 0.6823, 0.4167, 2, 0.26, 0.6, 291, 3, 0, 0, 0, 0, 0, 39], "semantic": {"name": "i, f", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for i, f in enumerate(opts.local_many_to_many):\n # Check to see if the related m2m field will clash with any\n # existing fields, m2m fields, m2m related objects or related\n # objects\n if f.rel.to not in models.get_models():\n e.add(opts, \"'%s' has an m2m relation with model %s, which has either not been installed or is abstract.\" % (f.name, f.rel.to))\n # it is a string and we could not find the model it refers to\n # so skip the next section"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L141_C12", "label": "if", "type": "if", "loc": [141, 146], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98894:For_L137_C8", "vector": [4, 3, 0.4983, 0.0208, 3, 0.98, 0.0, 0, 0, 0, 0, 0, 0, 0, 3], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if f.rel.to not in models.get_models():\n e.add(opts, \"'%s' has an m2m relation with model %s, which has either not been installed or is abstract.\" % (f.name, f.rel.to))\n # it is a string and we could not find the model it refers to\n # so skip the next section\n if isinstance(f.rel.to, (str, unicode)):\n continue"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98894:Expr_L142_C16", "label": "add()", "type": "expression", "loc": [142, 142], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L141_C12", "vector": [8, 4, 0.4931, 0.0035, 4, 0.0, 0.0, 241, 3, 2, 0, 0, 0, 0, 1], "semantic": {"name": "add", "arg_names": [], "import_names": [], "rhs_call_name": "add", "annotation": ""}, "snippet": " e.add(opts, \"'%s' has an m2m relation with model %s, which has either not been installed or is abstract.\" % (f.name, f.rel.to))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L145_C16", "label": "if", "type": "if", "loc": [145, 146], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L141_C12", "vector": [4, 4, 0.5052, 0.0069, 4, 0.0, 1.0, 0, 3, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if isinstance(f.rel.to, (str, unicode)):\n continue"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L149_C12", "label": "if", "type": "if", "loc": [149, 150], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98894:For_L137_C8", "vector": [4, 3, 0.5191, 0.0069, 3, 0.98, 0.1667, 0, 7, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if f.unique:\n e.add(opts, \"ManyToManyFields cannot be unique. Remove the unique argument on '%s'.\" % f.name)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98894:Expr_L150_C16", "label": "add()", "type": "expression", "loc": [150, 150], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L149_C12", "vector": [8, 4, 0.5208, 0.0035, 4, 0.14, 0.0, 241, 3, 2, 0, 0, 0, 0, 1], "semantic": {"name": "add", "arg_names": [], "import_names": [], "rhs_call_name": "add", "annotation": ""}, "snippet": " e.add(opts, \"ManyToManyFields cannot be unique. Remove the unique argument on '%s'.\" % f.name)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L152_C12", "label": "if", "type": "if", "loc": [152, 226], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98894:For_L137_C8", "vector": [4, 3, 0.6562, 0.2604, 3, 0.98, 0.3333, 0, 0, 0, 0, 0, 0, 0, 13], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if f.rel.through is not None and not isinstance(f.rel.through, basestring):\n from_model, to_model = cls, f.rel.to\n if from_model == to_model and f.rel.symmetrical and not f.rel.through._meta.auto_created:\n e.add(opts, \"Many-to-many fields with intermediate tables cannot be symmetrical.\")\n seen_from, seen_to, seen_self = False, False, 0\n for inter_field in f.rel.through._meta.fields:\n rel_to = getattr(inter_field.rel, 'to', None)\n if from_model == to_model: # relation to self"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98894:Assign_L153_C16", "label": "from_model, to_model =", "type": "assigned_variable", "loc": [153, 153], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L152_C12", "vector": [14, 4, 0.5312, 0.0035, 4, 0.03, 0.0, 806, 0, 0, 0, 0, 0, 8, 0], "semantic": {"name": "from_model, to_model", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " from_model, to_model = cls, f.rel.to"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L154_C16", "label": "if", "type": "if", "loc": [154, 155], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L152_C12", "vector": [4, 4, 0.5365, 0.0069, 4, 0.03, 0.125, 0, 0, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if from_model == to_model and f.rel.symmetrical and not f.rel.through._meta.auto_created:\n e.add(opts, \"Many-to-many fields with intermediate tables cannot be symmetrical.\")"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98894:Expr_L155_C20", "label": "add()", "type": "expression", "loc": [155, 155], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L154_C16", "vector": [8, 5, 0.5382, 0.0035, 5, 0.45, 0.0, 241, 3, 2, 0, 0, 0, 0, 1], "semantic": {"name": "add", "arg_names": [], "import_names": [], "rhs_call_name": "add", "annotation": ""}, "snippet": " e.add(opts, \"Many-to-many fields with intermediate tables cannot be symmetrical.\")"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98894:Assign_L156_C16", "label": "seen_from, seen_to, seen_self =", "type": "assigned_variable", "loc": [156, 156], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L152_C12", "vector": [14, 4, 0.5417, 0.0035, 4, 0.03, 0.25, 545, 0, 0, 0, 0, 0, 8, 0], "semantic": {"name": "seen_from, seen_to, seen_self", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " seen_from, seen_to, seen_self = False, False, 0"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98894:For_L157_C16", "label": "for inter_field", "type": "for", "loc": [157, 192], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L152_C12", "vector": [6, 4, 0.6059, 0.125, 4, 0.03, 0.375, 541, 7, 0, 0, 0, 0, 0, 4], "semantic": {"name": "inter_field", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for inter_field in f.rel.through._meta.fields:\n rel_to = getattr(inter_field.rel, 'to', None)\n if from_model == to_model: # relation to self\n if rel_to == from_model:\n seen_self += 1\n if seen_self > 2:\n e.add(opts, \"Intermediary model %s has more than \"\n \"two foreign keys to %s, which is ambiguous \""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98894:Assign_L158_C20", "label": "rel_to = getattr()", "type": "assigned_variable", "loc": [158, 158], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98894:For_L157_C16", "vector": [14, 5, 0.5486, 0.0035, 5, 0.27, 0.0, 213, 3, 3, 0, 0, 121, 10, 1], "semantic": {"name": "rel_to", "arg_names": [], "import_names": [], "rhs_call_name": "getattr", "annotation": ""}, "snippet": " rel_to = getattr(inter_field.rel, 'to', None)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L159_C20", "label": "if", "type": "if", "loc": [159, 192], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98894:For_L157_C16", "vector": [4, 5, 0.6094, 0.1181, 5, 0.27, 1.0, 0, 0, 0, 0, 0, 0, 0, 3], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if from_model == to_model: # relation to self\n if rel_to == from_model:\n seen_self += 1\n if seen_self > 2:\n e.add(opts, \"Intermediary model %s has more than \"\n \"two foreign keys to %s, which is ambiguous \"\n \"and is not permitted.\" % (\n f.rel.through._meta.object_name,"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L160_C24", "label": "if", "type": "if", "loc": [160, 161], "level": 6, "parent": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L159_C20", "vector": [4, 6, 0.5573, 0.0069, 6, 0.21, 0.0, 0, 0, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if rel_to == from_model:\n seen_self += 1"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L162_C24", "label": "if", "type": "if", "loc": [162, 169], "level": 6, "parent": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L159_C20", "vector": [4, 6, 0.5747, 0.0278, 6, 0.21, 0.5, 0, 0, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if seen_self > 2:\n e.add(opts, \"Intermediary model %s has more than \"\n \"two foreign keys to %s, which is ambiguous \"\n \"and is not permitted.\" % (\n f.rel.through._meta.object_name,\n from_model._meta.object_name\n )\n )"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98894:Expr_L163_C28", "label": "add()", "type": "expression", "loc": [163, 169], "level": 7, "parent": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L162_C24", "vector": [8, 7, 0.5764, 0.0243, 7, 0.49, 0.0, 241, 3, 2, 0, 0, 0, 0, 1], "semantic": {"name": "add", "arg_names": [], "import_names": [], "rhs_call_name": "add", "annotation": ""}, "snippet": " e.add(opts, \"Intermediary model %s has more than \"\n \"two foreign keys to %s, which is ambiguous \"\n \"and is not permitted.\" % (\n f.rel.through._meta.object_name,\n from_model._meta.object_name\n )\n )"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L171_C24", "label": "if", "type": "if", "loc": [171, 192], "level": 6, "parent": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L159_C20", "vector": [4, 6, 0.6302, 0.0764, 6, 0.21, 1.0, 0, 0, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if rel_to == from_model:\n if seen_from:\n e.add(opts, \"Intermediary model %s has more \"\n \"than one foreign key to %s, which is \"\n \"ambiguous and is not permitted.\" % (\n f.rel.through._meta.object_name,\n from_model._meta.object_name\n )"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L172_C28", "label": "if", "type": "if", "loc": [172, 181], "level": 7, "parent": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L171_C24", "vector": [4, 7, 0.6128, 0.0347, 7, 0.37, 0.0, 0, 2, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if seen_from:\n e.add(opts, \"Intermediary model %s has more \"\n \"than one foreign key to %s, which is \"\n \"ambiguous and is not permitted.\" % (\n f.rel.through._meta.object_name,\n from_model._meta.object_name\n )\n )"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98894:Expr_L173_C32", "label": "add()", "type": "expression", "loc": [173, 179], "level": 8, "parent": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L172_C28", "vector": [8, 8, 0.6111, 0.0243, 8, 0.44, 0.0, 241, 3, 2, 0, 0, 0, 0, 1], "semantic": {"name": "add", "arg_names": [], "import_names": [], "rhs_call_name": "add", "annotation": ""}, "snippet": " e.add(opts, \"Intermediary model %s has more \"\n \"than one foreign key to %s, which is \"\n \"ambiguous and is not permitted.\" % (\n f.rel.through._meta.object_name,\n from_model._meta.object_name\n )\n )"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98894:Assign_L181_C32", "label": "seen_from =", "type": "assigned_variable", "loc": [181, 181], "level": 8, "parent": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L172_C28", "vector": [14, 8, 0.6285, 0.0035, 8, 0.44, 1.0, 726, 1, 0, 0, 0, 0, 4, 0], "semantic": {"name": "seen_from", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " seen_from = True"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L182_C24", "label": "if", "type": "if", "loc": [182, 192], "level": 7, "parent": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L171_C24", "vector": [4, 7, 0.6493, 0.0382, 7, 0.37, 1.0, 0, 0, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " elif rel_to == to_model:\n if seen_to:\n e.add(opts, \"Intermediary model %s has more \"\n \"than one foreign key to %s, which is \"\n \"ambiguous and is not permitted.\" % (\n f.rel.through._meta.object_name,\n rel_to._meta.object_name\n )"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L183_C28", "label": "if", "type": "if", "loc": [183, 192], "level": 8, "parent": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L182_C24", "vector": [4, 8, 0.651, 0.0347, 8, 0.47, 0.0, 0, 2, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if seen_to:\n e.add(opts, \"Intermediary model %s has more \"\n \"than one foreign key to %s, which is \"\n \"ambiguous and is not permitted.\" % (\n f.rel.through._meta.object_name,\n rel_to._meta.object_name\n )\n )"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98894:Expr_L184_C32", "label": "add()", "type": "expression", "loc": [184, 190], "level": 9, "parent": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L183_C28", "vector": [8, 9, 0.6493, 0.0243, 9, 0.56, 0.0, 241, 3, 2, 0, 0, 0, 0, 1], "semantic": {"name": "add", "arg_names": [], "import_names": [], "rhs_call_name": "add", "annotation": ""}, "snippet": " e.add(opts, \"Intermediary model %s has more \"\n \"than one foreign key to %s, which is \"\n \"ambiguous and is not permitted.\" % (\n f.rel.through._meta.object_name,\n rel_to._meta.object_name\n )\n )"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98894:Assign_L192_C32", "label": "seen_to =", "type": "assigned_variable", "loc": [192, 192], "level": 9, "parent": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L183_C28", "vector": [14, 9, 0.6667, 0.0035, 9, 0.56, 1.0, 880, 1, 0, 0, 0, 0, 4, 0], "semantic": {"name": "seen_to", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " seen_to = True"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L193_C16", "label": "if", "type": "if", "loc": [193, 196], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L152_C12", "vector": [4, 4, 0.6753, 0.0139, 4, 0.03, 0.5, 0, 0, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if f.rel.through not in models.get_models(include_auto_created=True):\n e.add(opts, \"'%s' specifies an m2m relation through model \"\n \"%s, which has not been installed.\" % (f.name, f.rel.through)\n )"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98894:Expr_L194_C20", "label": "add()", "type": "expression", "loc": [194, 196], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L193_C16", "vector": [8, 5, 0.6771, 0.0104, 5, 0.02, 0.0, 241, 3, 2, 0, 0, 0, 0, 1], "semantic": {"name": "add", "arg_names": [], "import_names": [], "rhs_call_name": "add", "annotation": ""}, "snippet": " e.add(opts, \"'%s' specifies an m2m relation through model \"\n \"%s, which has not been installed.\" % (f.name, f.rel.through)\n )"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98894:Assign_L197_C16", "label": "signature =", "type": "assigned_variable", "loc": [197, 197], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L152_C12", "vector": [14, 4, 0.684, 0.0035, 4, 0.03, 0.625, 932, 0, 0, 0, 0, 0, 8, 0], "semantic": {"name": "signature", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " signature = (f.rel.to, cls, f.rel.through)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L198_C16", "label": "if", "type": "if", "loc": [198, 208], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L152_C12", "vector": [4, 4, 0.7049, 0.0382, 4, 0.03, 0.75, 0, 0, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if signature in seen_intermediary_signatures:\n e.add(opts, \"The model %s has two manually-defined m2m \"\n \"relations through the model %s, which is not \"\n \"permitted. Please consider using an extra field on \"\n \"your intermediary model instead.\" % (\n cls._meta.object_name,\n f.rel.through._meta.object_name\n )"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98894:Expr_L199_C20", "label": "add()", "type": "expression", "loc": [199, 206], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L198_C16", "vector": [8, 5, 0.7031, 0.0278, 5, 0.54, 0.0, 241, 3, 2, 0, 0, 0, 0, 1], "semantic": {"name": "add", "arg_names": [], "import_names": [], "rhs_call_name": "add", "annotation": ""}, "snippet": " e.add(opts, \"The model %s has two manually-defined m2m \"\n \"relations through the model %s, which is not \"\n \"permitted. Please consider using an extra field on \"\n \"your intermediary model instead.\" % (\n cls._meta.object_name,\n f.rel.through._meta.object_name\n )\n )"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98894:Expr_L208_C20", "label": "append()", "type": "expression", "loc": [208, 208], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L198_C16", "vector": [8, 5, 0.7222, 0.0035, 5, 0.54, 1.0, 243, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "append", "arg_names": [], "import_names": [], "rhs_call_name": "append", "annotation": ""}, "snippet": " seen_intermediary_signatures.append(signature)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L209_C16", "label": "if", "type": "if", "loc": [209, 222], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L152_C12", "vector": [4, 4, 0.7483, 0.0486, 4, 0.03, 0.875, 0, 0, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if not f.rel.through._meta.auto_created:\n seen_related_fk, seen_this_fk = False, False\n for field in f.rel.through._meta.fields:\n if field.rel:\n if not seen_related_fk and field.rel.to == f.rel.to:\n seen_related_fk = True\n elif field.rel.to == cls:\n seen_this_fk = True"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98894:Assign_L210_C20", "label": "seen_related_fk, seen_this_fk =", "type": "assigned_variable", "loc": [210, 210], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L209_C16", "vector": [14, 5, 0.7292, 0.0035, 5, 0.75, 0.0, 953, 0, 0, 0, 0, 0, 8, 0], "semantic": {"name": "seen_related_fk, seen_this_fk", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " seen_related_fk, seen_this_fk = False, False"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98894:For_L211_C20", "label": "for field", "type": "for", "loc": [211, 216], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L209_C16", "vector": [6, 5, 0.7413, 0.0208, 5, 0.75, 0.5, 480, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "field", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for field in f.rel.through._meta.fields:\n if field.rel:\n if not seen_related_fk and field.rel.to == f.rel.to:\n seen_related_fk = True\n elif field.rel.to == cls:\n seen_this_fk = True"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L212_C24", "label": "if", "type": "if", "loc": [212, 216], "level": 6, "parent": "ajibawa-2023/Python-Code-Large/train/row_98894:For_L211_C20", "vector": [4, 6, 0.7431, 0.0174, 6, 0.95, 0.0, 0, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if field.rel:\n if not seen_related_fk and field.rel.to == f.rel.to:\n seen_related_fk = True\n elif field.rel.to == cls:\n seen_this_fk = True"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L213_C28", "label": "if", "type": "if", "loc": [213, 216], "level": 7, "parent": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L212_C24", "vector": [4, 7, 0.7448, 0.0139, 7, 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 seen_related_fk and field.rel.to == f.rel.to:\n seen_related_fk = True\n elif field.rel.to == cls:\n seen_this_fk = True"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98894:Assign_L214_C32", "label": "seen_related_fk =", "type": "assigned_variable", "loc": [214, 214], "level": 8, "parent": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L213_C28", "vector": [14, 8, 0.7431, 0.0035, 8, 0.63, 0.0, 577, 1, 0, 0, 0, 0, 4, 0], "semantic": {"name": "seen_related_fk", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " seen_related_fk = True"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L215_C28", "label": "if", "type": "if", "loc": [215, 216], "level": 8, "parent": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L213_C28", "vector": [4, 8, 0.7483, 0.0069, 8, 0.63, 1.0, 0, 0, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " elif field.rel.to == cls:\n seen_this_fk = True"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98894:Assign_L216_C32", "label": "seen_this_fk =", "type": "assigned_variable", "loc": [216, 216], "level": 9, "parent": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L215_C28", "vector": [14, 9, 0.75, 0.0035, 9, 0.03, 0.0, 520, 1, 0, 0, 0, 0, 4, 0], "semantic": {"name": "seen_this_fk", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " seen_this_fk = True"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L217_C20", "label": "if", "type": "if", "loc": [217, 222], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L209_C16", "vector": [4, 5, 0.7622, 0.0208, 5, 0.75, 1.0, 0, 0, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if not seen_related_fk or not seen_this_fk:\n e.add(opts, \"'%s' is a manually-defined m2m relation \"\n \"through model %s, which does not have foreign keys \"\n \"to %s and %s\" % (f.name, f.rel.through._meta.object_name,\n f.rel.to._meta.object_name, cls._meta.object_name)\n )"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98894:Expr_L218_C24", "label": "add()", "type": "expression", "loc": [218, 222], "level": 6, "parent": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L217_C20", "vector": [8, 6, 0.7639, 0.0174, 6, 0.27, 0.0, 241, 3, 2, 0, 0, 0, 0, 1], "semantic": {"name": "add", "arg_names": [], "import_names": [], "rhs_call_name": "add", "annotation": ""}, "snippet": " e.add(opts, \"'%s' is a manually-defined m2m relation \"\n \"through model %s, which does not have foreign keys \"\n \"to %s and %s\" % (f.name, f.rel.through._meta.object_name,\n f.rel.to._meta.object_name, cls._meta.object_name)\n )"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L223_C12", "label": "if", "type": "if", "loc": [223, 226], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L152_C12", "vector": [4, 4, 0.7795, 0.0139, 4, 0.03, 1.0, 0, 3, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " elif isinstance(f.rel.through, basestring):\n e.add(opts, \"'%s' specifies an m2m relation through model %s, \"\n \"which has not been installed\" % (f.name, f.rel.through)\n )"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98894:Expr_L224_C16", "label": "add()", "type": "expression", "loc": [224, 226], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L223_C12", "vector": [8, 5, 0.7812, 0.0104, 5, 0.38, 0.0, 241, 3, 2, 0, 0, 0, 0, 1], "semantic": {"name": "add", "arg_names": [], "import_names": [], "rhs_call_name": "add", "annotation": ""}, "snippet": " e.add(opts, \"'%s' specifies an m2m relation through model %s, \"\n \"which has not been installed\" % (f.name, f.rel.through)\n )"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98894:Assign_L228_C12", "label": "rel_opts =", "type": "assigned_variable", "loc": [228, 228], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98894:For_L137_C8", "vector": [14, 3, 0.7917, 0.0035, 3, 0.98, 0.5, 178, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "rel_opts", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " rel_opts = f.rel.to._meta"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98894:Assign_L229_C12", "label": "rel_name = get_accessor_name()", "type": "assigned_variable", "loc": [229, 229], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98894:For_L137_C8", "vector": [14, 3, 0.7951, 0.0035, 3, 0.98, 0.6667, 705, 3, 0, 0, 0, 315, 10, 2], "semantic": {"name": "rel_name", "arg_names": [], "import_names": [], "rhs_call_name": "get_accessor_name", "annotation": ""}, "snippet": " rel_name = RelatedObject(f.rel.to, cls, f).get_accessor_name()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98894:Assign_L230_C12", "label": "rel_query_name = related_query_name()", "type": "assigned_variable", "loc": [230, 230], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98894:For_L137_C8", "vector": [14, 3, 0.7986, 0.0035, 3, 0.98, 0.8333, 908, 3, 0, 0, 0, 121, 10, 1], "semantic": {"name": "rel_query_name", "arg_names": [], "import_names": [], "rhs_call_name": "related_query_name", "annotation": ""}, "snippet": " rel_query_name = f.related_query_name()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L235_C12", "label": "if", "type": "if", "loc": [235, 256], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98894:For_L137_C8", "vector": [4, 3, 0.8524, 0.0764, 3, 0.98, 1.0, 0, 0, 0, 0, 0, 0, 0, 18], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if rel_name is not None:\n for r in rel_opts.fields:\n if r.name == rel_name:\n e.add(opts, \"Accessor for m2m field '%s' clashes with field '%s.%s'. Add a related_name argument to the definition for '%s'.\" % (f.name, rel_opts.object_name, r.name, f.name))\n if r.name == rel_query_name:\n e.add(opts, \"Reverse query name for m2m field '%s' clashes with field '%s.%s'. Add a related_name argument to the definition for '%s'.\" % (f.name, rel_opts.object_name, r.name, f.name))\n for r in rel_opts.local_many_to_many:\n if r.name == rel_name:"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98894:For_L236_C16", "label": "for r", "type": "for", "loc": [236, 240], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L235_C12", "vector": [6, 4, 0.8264, 0.0174, 4, 0.97, 0.0, 436, 7, 0, 0, 0, 0, 0, 2], "semantic": {"name": "r", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for r in rel_opts.fields:\n if r.name == rel_name:\n e.add(opts, \"Accessor for m2m field '%s' clashes with field '%s.%s'. Add a related_name argument to the definition for '%s'.\" % (f.name, rel_opts.object_name, r.name, f.name))\n if r.name == rel_query_name:\n e.add(opts, \"Reverse query name for m2m field '%s' clashes with field '%s.%s'. Add a related_name argument to the definition for '%s'.\" % (f.name, rel_opts.object_name, r.name, f.name))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L237_C20", "label": "if", "type": "if", "loc": [237, 238], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98894:For_L236_C16", "vector": [4, 5, 0.8247, 0.0069, 5, 0.17, 0.0, 0, 0, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if r.name == rel_name:\n e.add(opts, \"Accessor for m2m field '%s' clashes with field '%s.%s'. Add a related_name argument to the definition for '%s'.\" % (f.name, rel_opts.object_name, r.name, f.name))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98894:Expr_L238_C24", "label": "add()", "type": "expression", "loc": [238, 238], "level": 6, "parent": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L237_C20", "vector": [8, 6, 0.8264, 0.0035, 6, 0.22, 0.0, 241, 3, 2, 0, 0, 0, 0, 1], "semantic": {"name": "add", "arg_names": [], "import_names": [], "rhs_call_name": "add", "annotation": ""}, "snippet": " e.add(opts, \"Accessor for m2m field '%s' clashes with field '%s.%s'. Add a related_name argument to the definition for '%s'.\" % (f.name, rel_opts.object_name, r.name, f.name))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L239_C20", "label": "if", "type": "if", "loc": [239, 240], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98894:For_L236_C16", "vector": [4, 5, 0.8316, 0.0069, 5, 0.17, 1.0, 0, 0, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if r.name == rel_query_name:\n e.add(opts, \"Reverse query name for m2m field '%s' clashes with field '%s.%s'. Add a related_name argument to the definition for '%s'.\" % (f.name, rel_opts.object_name, r.name, f.name))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98894:Expr_L240_C24", "label": "add()", "type": "expression", "loc": [240, 240], "level": 6, "parent": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L239_C20", "vector": [8, 6, 0.8333, 0.0035, 6, 0.15, 0.0, 241, 3, 2, 0, 0, 0, 0, 1], "semantic": {"name": "add", "arg_names": [], "import_names": [], "rhs_call_name": "add", "annotation": ""}, "snippet": " e.add(opts, \"Reverse query name for m2m field '%s' clashes with field '%s.%s'. Add a related_name argument to the definition for '%s'.\" % (f.name, rel_opts.object_name, r.name, f.name))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98894:For_L241_C16", "label": "for r", "type": "for", "loc": [241, 245], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L235_C12", "vector": [6, 4, 0.8438, 0.0174, 4, 0.97, 0.3333, 436, 7, 0, 0, 0, 0, 0, 2], "semantic": {"name": "r", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for r in rel_opts.local_many_to_many:\n if r.name == rel_name:\n e.add(opts, \"Accessor for m2m field '%s' clashes with m2m field '%s.%s'. Add a related_name argument to the definition for '%s'.\" % (f.name, rel_opts.object_name, r.name, f.name))\n if r.name == rel_query_name:\n e.add(opts, \"Reverse query name for m2m field '%s' clashes with m2m field '%s.%s'. Add a related_name argument to the definition for '%s'.\" % (f.name, rel_opts.object_name, r.name, f.name))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L242_C20", "label": "if", "type": "if", "loc": [242, 243], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98894:For_L241_C16", "vector": [4, 5, 0.842, 0.0069, 5, 0.59, 0.0, 0, 0, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if r.name == rel_name:\n e.add(opts, \"Accessor for m2m field '%s' clashes with m2m field '%s.%s'. Add a related_name argument to the definition for '%s'.\" % (f.name, rel_opts.object_name, r.name, f.name))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98894:Expr_L243_C24", "label": "add()", "type": "expression", "loc": [243, 243], "level": 6, "parent": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L242_C20", "vector": [8, 6, 0.8438, 0.0035, 6, 0.31, 0.0, 241, 3, 2, 0, 0, 0, 0, 1], "semantic": {"name": "add", "arg_names": [], "import_names": [], "rhs_call_name": "add", "annotation": ""}, "snippet": " e.add(opts, \"Accessor for m2m field '%s' clashes with m2m field '%s.%s'. Add a related_name argument to the definition for '%s'.\" % (f.name, rel_opts.object_name, r.name, f.name))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L244_C20", "label": "if", "type": "if", "loc": [244, 245], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98894:For_L241_C16", "vector": [4, 5, 0.849, 0.0069, 5, 0.59, 1.0, 0, 0, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if r.name == rel_query_name:\n e.add(opts, \"Reverse query name for m2m field '%s' clashes with m2m field '%s.%s'. Add a related_name argument to the definition for '%s'.\" % (f.name, rel_opts.object_name, r.name, f.name))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98894:Expr_L245_C24", "label": "add()", "type": "expression", "loc": [245, 245], "level": 6, "parent": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L244_C20", "vector": [8, 6, 0.8507, 0.0035, 6, 0.69, 0.0, 241, 3, 2, 0, 0, 0, 0, 1], "semantic": {"name": "add", "arg_names": [], "import_names": [], "rhs_call_name": "add", "annotation": ""}, "snippet": " e.add(opts, \"Reverse query name for m2m field '%s' clashes with m2m field '%s.%s'. Add a related_name argument to the definition for '%s'.\" % (f.name, rel_opts.object_name, r.name, f.name))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98894:For_L246_C16", "label": "for r", "type": "for", "loc": [246, 251], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L235_C12", "vector": [6, 4, 0.8628, 0.0208, 4, 0.97, 0.6667, 436, 3, 0, 0, 0, 0, 0, 7], "semantic": {"name": "r", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for r in rel_opts.get_all_related_many_to_many_objects():\n if r.field is not f:\n if r.get_accessor_name() == rel_name:\n e.add(opts, \"Accessor for m2m field '%s' clashes with related m2m field '%s.%s'. Add a related_name argument to the definition for '%s'.\" % (f.name, rel_opts.object_name, r.get_accessor_name(), f.name))\n if r.get_accessor_name() == rel_query_name:\n e.add(opts, \"Reverse query name for m2m field '%s' clashes with related m2m field '%s.%s'. Add a related_name argument to the definition for '%s'.\" % (f.name, rel_opts.object_name, r.get_accessor_name(), f.name))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L247_C20", "label": "if", "type": "if", "loc": [247, 251], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98894:For_L246_C16", "vector": [4, 5, 0.8646, 0.0174, 5, 0.57, 0.0, 0, 0, 0, 0, 0, 0, 0, 6], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if r.field is not f:\n if r.get_accessor_name() == rel_name:\n e.add(opts, \"Accessor for m2m field '%s' clashes with related m2m field '%s.%s'. Add a related_name argument to the definition for '%s'.\" % (f.name, rel_opts.object_name, r.get_accessor_name(), f.name))\n if r.get_accessor_name() == rel_query_name:\n e.add(opts, \"Reverse query name for m2m field '%s' clashes with related m2m field '%s.%s'. Add a related_name argument to the definition for '%s'.\" % (f.name, rel_opts.object_name, r.get_accessor_name(), f.name))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L248_C24", "label": "if", "type": "if", "loc": [248, 249], "level": 6, "parent": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L247_C20", "vector": [4, 6, 0.8628, 0.0069, 6, 0.73, 0.0, 0, 0, 0, 0, 0, 0, 0, 3], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if r.get_accessor_name() == rel_name:\n e.add(opts, \"Accessor for m2m field '%s' clashes with related m2m field '%s.%s'. Add a related_name argument to the definition for '%s'.\" % (f.name, rel_opts.object_name, r.get_accessor_name(), f.name))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98894:Expr_L249_C28", "label": "add()", "type": "expression", "loc": [249, 249], "level": 7, "parent": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L248_C24", "vector": [8, 7, 0.8646, 0.0035, 7, 0.4, 0.0, 241, 3, 2, 0, 0, 0, 0, 2], "semantic": {"name": "add", "arg_names": [], "import_names": [], "rhs_call_name": "add", "annotation": ""}, "snippet": " e.add(opts, \"Accessor for m2m field '%s' clashes with related m2m field '%s.%s'. Add a related_name argument to the definition for '%s'.\" % (f.name, rel_opts.object_name, r.get_accessor_name(), f.name))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L250_C24", "label": "if", "type": "if", "loc": [250, 251], "level": 6, "parent": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L247_C20", "vector": [4, 6, 0.8698, 0.0069, 6, 0.73, 1.0, 0, 0, 0, 0, 0, 0, 0, 3], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if r.get_accessor_name() == rel_query_name:\n e.add(opts, \"Reverse query name for m2m field '%s' clashes with related m2m field '%s.%s'. Add a related_name argument to the definition for '%s'.\" % (f.name, rel_opts.object_name, r.get_accessor_name(), f.name))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98894:Expr_L251_C28", "label": "add()", "type": "expression", "loc": [251, 251], "level": 7, "parent": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L250_C24", "vector": [8, 7, 0.8715, 0.0035, 7, 0.83, 0.0, 241, 3, 2, 0, 0, 0, 0, 2], "semantic": {"name": "add", "arg_names": [], "import_names": [], "rhs_call_name": "add", "annotation": ""}, "snippet": " e.add(opts, \"Reverse query name for m2m field '%s' clashes with related m2m field '%s.%s'. Add a related_name argument to the definition for '%s'.\" % (f.name, rel_opts.object_name, r.get_accessor_name(), f.name))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98894:For_L252_C16", "label": "for r", "type": "for", "loc": [252, 256], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L235_C12", "vector": [6, 4, 0.8819, 0.0174, 4, 0.97, 1.0, 436, 3, 0, 0, 0, 0, 0, 7], "semantic": {"name": "r", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for r in rel_opts.get_all_related_objects():\n if r.get_accessor_name() == rel_name:\n e.add(opts, \"Accessor for m2m field '%s' clashes with related field '%s.%s'. Add a related_name argument to the definition for '%s'.\" % (f.name, rel_opts.object_name, r.get_accessor_name(), f.name))\n if r.get_accessor_name() == rel_query_name:\n e.add(opts, \"Reverse query name for m2m field '%s' clashes with related field '%s.%s'. Add a related_name argument to the definition for '%s'.\" % (f.name, rel_opts.object_name, r.get_accessor_name(), f.name))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L253_C20", "label": "if", "type": "if", "loc": [253, 254], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98894:For_L252_C16", "vector": [4, 5, 0.8802, 0.0069, 5, 0.92, 0.0, 0, 0, 0, 0, 0, 0, 0, 3], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if r.get_accessor_name() == rel_name:\n e.add(opts, \"Accessor for m2m field '%s' clashes with related field '%s.%s'. Add a related_name argument to the definition for '%s'.\" % (f.name, rel_opts.object_name, r.get_accessor_name(), f.name))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98894:Expr_L254_C24", "label": "add()", "type": "expression", "loc": [254, 254], "level": 6, "parent": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L253_C20", "vector": [8, 6, 0.8819, 0.0035, 6, 0.14, 0.0, 241, 3, 2, 0, 0, 0, 0, 2], "semantic": {"name": "add", "arg_names": [], "import_names": [], "rhs_call_name": "add", "annotation": ""}, "snippet": " e.add(opts, \"Accessor for m2m field '%s' clashes with related field '%s.%s'. Add a related_name argument to the definition for '%s'.\" % (f.name, rel_opts.object_name, r.get_accessor_name(), f.name))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L255_C20", "label": "if", "type": "if", "loc": [255, 256], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98894:For_L252_C16", "vector": [4, 5, 0.8872, 0.0069, 5, 0.92, 1.0, 0, 0, 0, 0, 0, 0, 0, 3], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if r.get_accessor_name() == rel_query_name:\n e.add(opts, \"Reverse query name for m2m field '%s' clashes with related field '%s.%s'. Add a related_name argument to the definition for '%s'.\" % (f.name, rel_opts.object_name, r.get_accessor_name(), f.name))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98894:Expr_L256_C24", "label": "add()", "type": "expression", "loc": [256, 256], "level": 6, "parent": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L255_C20", "vector": [8, 6, 0.8889, 0.0035, 6, 0.99, 0.0, 241, 3, 2, 0, 0, 0, 0, 2], "semantic": {"name": "add", "arg_names": [], "import_names": [], "rhs_call_name": "add", "annotation": ""}, "snippet": " e.add(opts, \"Reverse query name for m2m field '%s' clashes with related field '%s.%s'. Add a related_name argument to the definition for '%s'.\" % (f.name, rel_opts.object_name, r.get_accessor_name(), f.name))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L259_C8", "label": "if", "type": "if", "loc": [259, 273], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98894:For_L32_C4", "vector": [4, 2, 0.9236, 0.0521, 2, 0.26, 0.8, 0, 7, 0, 0, 0, 0, 0, 3], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if opts.ordering:\n for field_name in opts.ordering:\n if field_name == '?': continue\n if field_name.startswith('-'):\n field_name = field_name[1:]\n if opts.order_with_respect_to and field_name == '_order':\n continue\n # Skip ordering in the format field1__field2 (FIXME: checking"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98894:For_L260_C12", "label": "for field_name", "type": "for", "loc": [260, 273], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L259_C8", "vector": [6, 3, 0.9253, 0.0486, 3, 0.24, 0.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 opts.ordering:\n if field_name == '?': continue\n if field_name.startswith('-'):\n field_name = field_name[1:]\n if opts.order_with_respect_to and field_name == '_order':\n continue\n # Skip ordering in the format field1__field2 (FIXME: checking\n # this format would be nice, but it's a little fiddly)."}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L261_C16", "label": "if", "type": "if", "loc": [261, 261], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98894:For_L260_C12", "vector": [4, 4, 0.9062, 0.0035, 4, 0.21, 0.0, 0, 0, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if field_name == '?': continue"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L262_C16", "label": "if", "type": "if", "loc": [262, 263], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98894:For_L260_C12", "vector": [4, 4, 0.9115, 0.0069, 4, 0.21, 0.25, 0, 3, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if field_name.startswith('-'):\n field_name = field_name[1:]"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98894:Assign_L263_C20", "label": "field_name =", "type": "assigned_variable", "loc": [263, 263], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L262_C16", "vector": [14, 5, 0.9132, 0.0035, 5, 0.95, 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[1:]"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L264_C16", "label": "if", "type": "if", "loc": [264, 265], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98894:For_L260_C12", "vector": [4, 4, 0.9184, 0.0069, 4, 0.21, 0.5, 0, 0, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if opts.order_with_respect_to and field_name == '_order':\n continue"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L268_C16", "label": "if", "type": "if", "loc": [268, 269], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98894:For_L260_C12", "vector": [4, 4, 0.9323, 0.0069, 4, 0.21, 0.75, 0, 0, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if '__' in field_name:\n continue"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98894:Try_L270_C16", "label": "try", "type": "try", "loc": [270, 273], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98894:For_L260_C12", "vector": [7, 4, 0.9427, 0.0139, 4, 0.21, 1.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_name, many_to_many=False)\n except models.FieldDoesNotExist:\n e.add(opts, '\"ordering\" refers to \"%s\", a field that doesn\\'t exist.' % field_name)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98894:Expr_L271_C20", "label": "get_field()", "type": "expression", "loc": [271, 271], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98894:Try_L270_C16", "vector": [8, 5, 0.941, 0.0035, 5, 0.07, 0.0, 389, 3, 2, 0, 0, 0, 0, 1], "semantic": {"name": "get_field", "arg_names": [], "import_names": [], "rhs_call_name": "get_field", "annotation": ""}, "snippet": " opts.get_field(field_name, many_to_many=False)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98894:Expr_L273_C20", "label": "add()", "type": "expression", "loc": [273, 273], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98894:Try_L270_C16", "vector": [8, 5, 0.9479, 0.0035, 5, 0.07, 0.0, 241, 3, 2, 0, 0, 0, 0, 1], "semantic": {"name": "add", "arg_names": [], "import_names": [], "rhs_call_name": "add", "annotation": ""}, "snippet": " e.add(opts, '\"ordering\" refers to \"%s\", a field that doesn\\'t exist.' % field_name)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98894:For_L276_C8", "label": "for ut", "type": "for", "loc": [276, 286], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98894:For_L32_C4", "vector": [6, 2, 0.9757, 0.0382, 2, 0.26, 1.0, 484, 7, 0, 0, 0, 0, 0, 5], "semantic": {"name": "ut", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for ut in opts.unique_together:\n for field_name in ut:\n try:\n f = opts.get_field(field_name, many_to_many=True)\n except models.FieldDoesNotExist:\n e.add(opts, '\"unique_together\" refers to %s, a field that doesn\\'t exist. Check your syntax.' % field_name)\n else:\n if isinstance(f.rel, models.ManyToManyRel):"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98894:For_L277_C12", "label": "for field_name", "type": "for", "loc": [277, 286], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98894:For_L276_C8", "vector": [6, 3, 0.9774, 0.0347, 3, 0.25, 0.0, 918, 2, 0, 0, 0, 0, 0, 5], "semantic": {"name": "field_name", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for field_name in ut:\n try:\n f = opts.get_field(field_name, many_to_many=True)\n except models.FieldDoesNotExist:\n e.add(opts, '\"unique_together\" refers to %s, a field that doesn\\'t exist. Check your syntax.' % field_name)\n else:\n if isinstance(f.rel, models.ManyToManyRel):\n e.add(opts, '\"unique_together\" refers to %s. ManyToManyFields are not supported in unique_together.' % f.name)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98894:Try_L278_C16", "label": "try", "type": "try", "loc": [278, 286], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98894:For_L277_C12", "vector": [7, 4, 0.9792, 0.0312, 4, 0.41, 0.0, 0, 0, 1, 0, 0, 0, 0, 5], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " try:\n f = opts.get_field(field_name, many_to_many=True)\n except models.FieldDoesNotExist:\n e.add(opts, '\"unique_together\" refers to %s, a field that doesn\\'t exist. Check your syntax.' % field_name)\n else:\n if isinstance(f.rel, models.ManyToManyRel):\n e.add(opts, '\"unique_together\" refers to %s. ManyToManyFields are not supported in unique_together.' % f.name)\n if f not in opts.local_fields:"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98894:Assign_L279_C20", "label": "f = get_field()", "type": "assigned_variable", "loc": [279, 279], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98894:Try_L278_C16", "vector": [14, 5, 0.9688, 0.0035, 5, 0.72, 0.0, 899, 3, 2, 0, 0, 389, 10, 1], "semantic": {"name": "f", "arg_names": [], "import_names": [], "rhs_call_name": "get_field", "annotation": ""}, "snippet": " f = opts.get_field(field_name, many_to_many=True)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98894:Expr_L281_C20", "label": "add()", "type": "expression", "loc": [281, 281], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98894:Try_L278_C16", "vector": [8, 5, 0.9757, 0.0035, 5, 0.72, 0.0, 241, 3, 2, 0, 0, 0, 0, 1], "semantic": {"name": "add", "arg_names": [], "import_names": [], "rhs_call_name": "add", "annotation": ""}, "snippet": " e.add(opts, '\"unique_together\" refers to %s, a field that doesn\\'t exist. Check your syntax.' % field_name)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L283_C20", "label": "if", "type": "if", "loc": [283, 284], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98894:Try_L278_C16", "vector": [4, 5, 0.9844, 0.0069, 5, 0.72, 0.5, 0, 3, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if isinstance(f.rel, models.ManyToManyRel):\n e.add(opts, '\"unique_together\" refers to %s. ManyToManyFields are not supported in unique_together.' % f.name)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98894:Expr_L284_C24", "label": "add()", "type": "expression", "loc": [284, 284], "level": 6, "parent": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L283_C20", "vector": [8, 6, 0.9861, 0.0035, 6, 0.96, 0.0, 241, 3, 2, 0, 0, 0, 0, 1], "semantic": {"name": "add", "arg_names": [], "import_names": [], "rhs_call_name": "add", "annotation": ""}, "snippet": " e.add(opts, '\"unique_together\" refers to %s. ManyToManyFields are not supported in unique_together.' % f.name)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L285_C20", "label": "if", "type": "if", "loc": [285, 286], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98894:Try_L278_C16", "vector": [4, 5, 0.9913, 0.0069, 5, 0.72, 1.0, 0, 0, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if f not in opts.local_fields:\n e.add(opts, '\"unique_together\" refers to %s. This is not in the same model as the unique_together statement.' % f.name)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98894:Expr_L286_C24", "label": "add()", "type": "expression", "loc": [286, 286], "level": 6, "parent": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L285_C20", "vector": [8, 6, 0.9931, 0.0035, 6, 0.75, 0.0, 241, 3, 2, 0, 0, 0, 0, 1], "semantic": {"name": "add", "arg_names": [], "import_names": [], "rhs_call_name": "add", "annotation": ""}, "snippet": " e.add(opts, '\"unique_together\" refers to %s. This is not in the same model as the unique_together statement.' % f.name)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98894:Return_L288_C4", "label": "return", "type": "return", "loc": [288, 288], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98894:FunctionDef_L15_C0", "vector": [13, 1, 1.0, 0.0035, 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 len(e.errors)"}]
[{"f": "ajibawa-2023/Python-Code-Large/train/row_98894:ClassDef_L5_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98894:FunctionDef_L6_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98894:FunctionDef_L6_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98894:Assign_L7_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98894:FunctionDef_L6_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98894:Assign_L8_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98894:FunctionDef_L6_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98894:Assign_L9_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98894:ClassDef_L5_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98894:FunctionDef_L11_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98894:FunctionDef_L11_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98894:Expr_L12_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98894:FunctionDef_L11_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98894:Expr_L13_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98894:FunctionDef_L15_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98894:Expr_L16_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98894:FunctionDef_L15_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98894:ImportFrom_L21_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98894:FunctionDef_L15_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98894:ImportFrom_L22_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98894:FunctionDef_L15_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98894:ImportFrom_L23_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98894:FunctionDef_L15_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98894:ImportFrom_L24_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98894:FunctionDef_L15_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98894:ImportFrom_L25_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98894:FunctionDef_L15_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98894:Assign_L27_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98894:FunctionDef_L15_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98894:For_L29_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98894:For_L29_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98894:Expr_L30_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98894:FunctionDef_L15_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98894:For_L32_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98894:For_L32_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98894:Assign_L33_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98894:For_L32_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98894:For_L36_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98894:For_L36_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L37_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L37_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98894:Expr_L38_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98894:For_L36_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L39_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L39_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98894:Expr_L40_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98894:For_L36_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L41_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L41_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98894:Try_L42_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98894:Try_L42_C16", "t": "ajibawa-2023/Python-Code-Large/train/row_98894:Assign_L43_C20"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98894:Try_L42_C16", "t": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L44_C20"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L44_C20", "t": "ajibawa-2023/Python-Code-Large/train/row_98894:Expr_L45_C24"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98894:Try_L42_C16", "t": "ajibawa-2023/Python-Code-Large/train/row_98894:Expr_L47_C20"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98894:For_L36_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L48_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L48_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98894:Assign_L49_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L48_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98894:Try_L50_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98894:Try_L50_C16", "t": "ajibawa-2023/Python-Code-Large/train/row_98894:Assign_L51_C20"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98894:Try_L50_C16", "t": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L52_C20"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L52_C20", "t": "ajibawa-2023/Python-Code-Large/train/row_98894:Expr_L53_C24"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98894:Try_L50_C16", "t": "ajibawa-2023/Python-Code-Large/train/row_98894:Expr_L55_C20"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L48_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98894:Assign_L56_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L48_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98894:Try_L57_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98894:Try_L57_C16", "t": "ajibawa-2023/Python-Code-Large/train/row_98894:Assign_L58_C20"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98894:Try_L57_C16", "t": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L59_C20"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L59_C20", "t": "ajibawa-2023/Python-Code-Large/train/row_98894:Expr_L60_C24"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98894:Try_L57_C16", "t": "ajibawa-2023/Python-Code-Large/train/row_98894:Expr_L62_C20"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98894:For_L36_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L63_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L63_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98894:Expr_L64_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98894:For_L36_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L65_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L65_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98894:Try_L67_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98894:Try_L67_C16", "t": "ajibawa-2023/Python-Code-Large/train/row_98894:ImportFrom_L68_C20"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98894:Try_L67_C16", "t": "ajibawa-2023/Python-Code-Large/train/row_98894:Try_L70_C20"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98894:Try_L70_C20", "t": "ajibawa-2023/Python-Code-Large/train/row_98894:Import_L71_C24"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98894:Try_L70_C20", "t": "ajibawa-2023/Python-Code-Large/train/row_98894:Expr_L73_C24"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98894:For_L36_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L74_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L74_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98894:Expr_L75_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98894:For_L36_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L76_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L76_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L77_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L77_C16", "t": "ajibawa-2023/Python-Code-Large/train/row_98894:Expr_L78_C20"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L77_C16", "t": "ajibawa-2023/Python-Code-Large/train/row_98894:For_L80_C20"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98894:For_L80_C20", "t": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L81_C24"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L81_C24", "t": "ajibawa-2023/Python-Code-Large/train/row_98894:Expr_L82_C28"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98894:For_L36_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L83_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L83_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98894:Expr_L84_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98894:For_L36_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98894:Expr_L87_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98894:For_L36_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L90_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L90_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L91_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L91_C16", "t": "ajibawa-2023/Python-Code-Large/train/row_98894:Expr_L92_C20"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L91_C16", "t": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L93_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L93_C16", "t": "ajibawa-2023/Python-Code-Large/train/row_98894:Expr_L94_C20"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98894:For_L36_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L98_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L98_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L99_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L99_C16", "t": "ajibawa-2023/Python-Code-Large/train/row_98894:Expr_L100_C20"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L98_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L103_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L98_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L107_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L107_C16", "t": "ajibawa-2023/Python-Code-Large/train/row_98894:Expr_L108_C20"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L98_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98894:Assign_L110_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L98_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98894:Assign_L111_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L98_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98894:Assign_L112_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L98_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L113_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L113_C16", "t": "ajibawa-2023/Python-Code-Large/train/row_98894:For_L114_C20"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98894:For_L114_C20", "t": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L115_C24"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L115_C24", "t": "ajibawa-2023/Python-Code-Large/train/row_98894:Expr_L116_C28"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98894:For_L114_C20", "t": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L117_C24"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L117_C24", "t": "ajibawa-2023/Python-Code-Large/train/row_98894:Expr_L118_C28"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L113_C16", "t": "ajibawa-2023/Python-Code-Large/train/row_98894:For_L119_C20"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98894:For_L119_C20", "t": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L120_C24"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L120_C24", "t": "ajibawa-2023/Python-Code-Large/train/row_98894:Expr_L121_C28"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98894:For_L119_C20", "t": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L122_C24"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L122_C24", "t": "ajibawa-2023/Python-Code-Large/train/row_98894:Expr_L123_C28"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L113_C16", "t": "ajibawa-2023/Python-Code-Large/train/row_98894:For_L124_C20"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98894:For_L124_C20", "t": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L125_C24"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L125_C24", "t": "ajibawa-2023/Python-Code-Large/train/row_98894:Expr_L126_C28"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98894:For_L124_C20", "t": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L127_C24"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L127_C24", "t": "ajibawa-2023/Python-Code-Large/train/row_98894:Expr_L128_C28"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L113_C16", "t": "ajibawa-2023/Python-Code-Large/train/row_98894:For_L129_C20"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98894:For_L129_C20", "t": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L130_C24"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L130_C24", "t": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L131_C28"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L131_C28", "t": "ajibawa-2023/Python-Code-Large/train/row_98894:Expr_L132_C32"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L130_C24", "t": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L133_C28"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L133_C28", "t": "ajibawa-2023/Python-Code-Large/train/row_98894:Expr_L134_C32"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98894:For_L32_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98894:Assign_L136_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98894:For_L32_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98894:For_L137_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98894:For_L137_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L141_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L141_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98894:Expr_L142_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L141_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L145_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98894:For_L137_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L149_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L149_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98894:Expr_L150_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98894:For_L137_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L152_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L152_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98894:Assign_L153_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L152_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L154_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L154_C16", "t": "ajibawa-2023/Python-Code-Large/train/row_98894:Expr_L155_C20"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L152_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98894:Assign_L156_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L152_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98894:For_L157_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98894:For_L157_C16", "t": "ajibawa-2023/Python-Code-Large/train/row_98894:Assign_L158_C20"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98894:For_L157_C16", "t": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L159_C20"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L159_C20", "t": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L160_C24"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L159_C20", "t": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L162_C24"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L162_C24", "t": "ajibawa-2023/Python-Code-Large/train/row_98894:Expr_L163_C28"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L159_C20", "t": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L171_C24"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L171_C24", "t": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L172_C28"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L172_C28", "t": "ajibawa-2023/Python-Code-Large/train/row_98894:Expr_L173_C32"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L172_C28", "t": "ajibawa-2023/Python-Code-Large/train/row_98894:Assign_L181_C32"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L171_C24", "t": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L182_C24"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L182_C24", "t": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L183_C28"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L183_C28", "t": "ajibawa-2023/Python-Code-Large/train/row_98894:Expr_L184_C32"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L183_C28", "t": "ajibawa-2023/Python-Code-Large/train/row_98894:Assign_L192_C32"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L152_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L193_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L193_C16", "t": "ajibawa-2023/Python-Code-Large/train/row_98894:Expr_L194_C20"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L152_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98894:Assign_L197_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L152_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L198_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L198_C16", "t": "ajibawa-2023/Python-Code-Large/train/row_98894:Expr_L199_C20"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L198_C16", "t": "ajibawa-2023/Python-Code-Large/train/row_98894:Expr_L208_C20"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L152_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L209_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L209_C16", "t": "ajibawa-2023/Python-Code-Large/train/row_98894:Assign_L210_C20"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L209_C16", "t": "ajibawa-2023/Python-Code-Large/train/row_98894:For_L211_C20"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98894:For_L211_C20", "t": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L212_C24"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L212_C24", "t": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L213_C28"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L213_C28", "t": "ajibawa-2023/Python-Code-Large/train/row_98894:Assign_L214_C32"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L213_C28", "t": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L215_C28"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L215_C28", "t": "ajibawa-2023/Python-Code-Large/train/row_98894:Assign_L216_C32"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L209_C16", "t": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L217_C20"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L217_C20", "t": "ajibawa-2023/Python-Code-Large/train/row_98894:Expr_L218_C24"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L152_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L223_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L223_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98894:Expr_L224_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98894:For_L137_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98894:Assign_L228_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98894:For_L137_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98894:Assign_L229_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98894:For_L137_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98894:Assign_L230_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98894:For_L137_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L235_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L235_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98894:For_L236_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98894:For_L236_C16", "t": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L237_C20"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L237_C20", "t": "ajibawa-2023/Python-Code-Large/train/row_98894:Expr_L238_C24"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98894:For_L236_C16", "t": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L239_C20"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L239_C20", "t": "ajibawa-2023/Python-Code-Large/train/row_98894:Expr_L240_C24"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L235_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98894:For_L241_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98894:For_L241_C16", "t": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L242_C20"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L242_C20", "t": "ajibawa-2023/Python-Code-Large/train/row_98894:Expr_L243_C24"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98894:For_L241_C16", "t": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L244_C20"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L244_C20", "t": "ajibawa-2023/Python-Code-Large/train/row_98894:Expr_L245_C24"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L235_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98894:For_L246_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98894:For_L246_C16", "t": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L247_C20"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L247_C20", "t": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L248_C24"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L248_C24", "t": "ajibawa-2023/Python-Code-Large/train/row_98894:Expr_L249_C28"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L247_C20", "t": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L250_C24"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L250_C24", "t": "ajibawa-2023/Python-Code-Large/train/row_98894:Expr_L251_C28"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L235_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98894:For_L252_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98894:For_L252_C16", "t": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L253_C20"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L253_C20", "t": "ajibawa-2023/Python-Code-Large/train/row_98894:Expr_L254_C24"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98894:For_L252_C16", "t": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L255_C20"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L255_C20", "t": "ajibawa-2023/Python-Code-Large/train/row_98894:Expr_L256_C24"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98894:For_L32_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L259_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L259_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98894:For_L260_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98894:For_L260_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L261_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98894:For_L260_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L262_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L262_C16", "t": "ajibawa-2023/Python-Code-Large/train/row_98894:Assign_L263_C20"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98894:For_L260_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L264_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98894:For_L260_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L268_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98894:For_L260_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98894:Try_L270_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98894:Try_L270_C16", "t": "ajibawa-2023/Python-Code-Large/train/row_98894:Expr_L271_C20"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98894:Try_L270_C16", "t": "ajibawa-2023/Python-Code-Large/train/row_98894:Expr_L273_C20"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98894:For_L32_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98894:For_L276_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98894:For_L276_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98894:For_L277_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98894:For_L277_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98894:Try_L278_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98894:Try_L278_C16", "t": "ajibawa-2023/Python-Code-Large/train/row_98894:Assign_L279_C20"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98894:Try_L278_C16", "t": "ajibawa-2023/Python-Code-Large/train/row_98894:Expr_L281_C20"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98894:Try_L278_C16", "t": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L283_C20"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L283_C20", "t": "ajibawa-2023/Python-Code-Large/train/row_98894:Expr_L284_C24"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98894:Try_L278_C16", "t": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L285_C20"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98894:If_L285_C20", "t": "ajibawa-2023/Python-Code-Large/train/row_98894:Expr_L286_C24"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98894:FunctionDef_L15_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98894:Return_L288_C4"}]
""" Utility functions for handling images. Requires PIL, as you might imagine. """ from django.core.files import File class ImageFile(File): """ A mixin for use alongside django.core.files.base.File, which provides additional features for dealing with images. """ def _get_width(self): return self._get_image_dimensions()[0] width = property(_get_width) def _get_height(self): return self._get_image_dimensions()[1] height = property(_get_height) def _get_image_dimensions(self): if not hasattr(self, '_dimensions_cache'): close = self.closed self.open() self._dimensions_cache = get_image_dimensions(self, close=close) return self._dimensions_cache def get_image_dimensions(file_or_path, close=False): """ Returns the (width, height) of an image, given an open file or a path. Set 'close' to True to close the file at the end if it is initially in an open state. """ # Try to import PIL in either of the two ways it can end up installed. try: from PIL import ImageFile as PILImageFile except ImportError: import ImageFile as PILImageFile p = PILImageFile.Parser() if hasattr(file_or_path, 'read'): file = file_or_path file_pos = file.tell() file.seek(0) else: file = open(file_or_path, 'rb') close = True try: while 1: data = file.read(1024) if not data: break p.feed(data) if p.image: return p.image.size return None finally: if close: file.close() else: file.seek(file_pos)
ajibawa-2023/Python-Code-Large/train/row_98899
39
62
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_98899:Expr_L1_C0", "label": "expression", "type": "expression", "loc": [1, 5], "level": 0, "parent": null, "vector": [8, 0, 0.0484, 0.0806, 0, 0.66, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "\"\"\"\nUtility functions for handling images.\n\nRequires PIL, as you might imagine.\n\"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98899:ImportFrom_L7_C0", "label": "from django.core.files import File", "type": "import", "loc": [7, 7], "level": 0, "parent": null, "vector": [1, 0, 0.1129, 0.0161, 0, 0.66, 0.3333, 659, 0, 1, 0, 0, 659, 0, 0], "semantic": {"name": "django.core.files", "arg_names": [], "import_names": ["File"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.core.files import File"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98899:ClassDef_L9_C0", "label": "ImageFile", "type": "class", "loc": [9, 27], "level": 0, "parent": null, "vector": [3, 0, 0.2903, 0.3065, 0, 0.66, 0.6667, 236, 0, 3, 0, 0, 491, 0, 7], "semantic": {"name": "ImageFile", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class ImageFile(File):\n \"\"\"\n A mixin for use alongside django.core.files.base.File, which provides\n additional features for dealing with images.\n \"\"\"\n def _get_width(self):\n return self._get_image_dimensions()[0]\n width = property(_get_width)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98899:Expr_L10_C4", "label": "expression", "type": "expression", "loc": [10, 13], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98899:ClassDef_L9_C0", "vector": [8, 1, 0.1855, 0.0645, 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 A mixin for use alongside django.core.files.base.File, which provides\n additional features for dealing with images.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98899:FunctionDef_L14_C4", "label": "_get_width", "type": "function", "loc": [14, 15], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98899:ClassDef_L9_C0", "vector": [2, 1, 0.2339, 0.0323, 1, 0.07, 0.2, 267, 0, 1, 1, 0, 0, 0, 1], "semantic": {"name": "_get_width", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def _get_width(self):\n return self._get_image_dimensions()[0]"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98899:Return_L15_C8", "label": "return", "type": "return", "loc": [15, 15], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98899:FunctionDef_L14_C4", "vector": [13, 2, 0.2419, 0.0161, 2, 0.82, 0.0, 0, 6, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return self._get_image_dimensions()[0]"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98899:Assign_L16_C4", "label": "width = property()", "type": "assigned_variable", "loc": [16, 16], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98899:ClassDef_L9_C0", "vector": [14, 1, 0.2581, 0.0161, 1, 0.07, 0.4, 989, 3, 1, 0, 0, 244, 10, 1], "semantic": {"name": "width", "arg_names": [], "import_names": [], "rhs_call_name": "property", "annotation": ""}, "snippet": " width = property(_get_width)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98899:FunctionDef_L18_C4", "label": "_get_height", "type": "function", "loc": [18, 19], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98899:ClassDef_L9_C0", "vector": [2, 1, 0.2984, 0.0323, 1, 0.07, 0.6, 210, 0, 1, 1, 0, 0, 0, 1], "semantic": {"name": "_get_height", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def _get_height(self):\n return self._get_image_dimensions()[1]"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98899:Return_L19_C8", "label": "return", "type": "return", "loc": [19, 19], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98899:FunctionDef_L18_C4", "vector": [13, 2, 0.3065, 0.0161, 2, 0.54, 0.0, 0, 6, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return self._get_image_dimensions()[1]"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98899:Assign_L20_C4", "label": "height = property()", "type": "assigned_variable", "loc": [20, 20], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98899:ClassDef_L9_C0", "vector": [14, 1, 0.3226, 0.0161, 1, 0.07, 0.8, 751, 3, 1, 0, 0, 244, 10, 1], "semantic": {"name": "height", "arg_names": [], "import_names": [], "rhs_call_name": "property", "annotation": ""}, "snippet": " height = property(_get_height)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98899:FunctionDef_L22_C4", "label": "_get_image_dimensions", "type": "function", "loc": [22, 27], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98899:ClassDef_L9_C0", "vector": [2, 1, 0.3952, 0.0968, 1, 0.07, 1.0, 828, 0, 1, 1, 0, 0, 0, 3], "semantic": {"name": "_get_image_dimensions", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def _get_image_dimensions(self):\n if not hasattr(self, '_dimensions_cache'):\n close = self.closed\n self.open()\n self._dimensions_cache = get_image_dimensions(self, close=close)\n return self._dimensions_cache"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98899:If_L23_C8", "label": "if", "type": "if", "loc": [23, 26], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98899:FunctionDef_L22_C4", "vector": [4, 2, 0.3952, 0.0645, 2, 0.33, 0.0, 0, 0, 0, 0, 0, 0, 0, 3], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if not hasattr(self, '_dimensions_cache'):\n close = self.closed\n self.open()\n self._dimensions_cache = get_image_dimensions(self, close=close)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98899:Assign_L24_C12", "label": "close =", "type": "assigned_variable", "loc": [24, 24], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98899:If_L23_C8", "vector": [14, 3, 0.3871, 0.0161, 3, 0.32, 0.0, 77, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "close", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " close = self.closed"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98899:Expr_L25_C12", "label": "open()", "type": "expression", "loc": [25, 25], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98899:If_L23_C8", "vector": [8, 3, 0.4032, 0.0161, 3, 0.32, 0.5, 693, 3, 0, 0, 0, 0, 0, 1], "semantic": {"name": "open", "arg_names": [], "import_names": [], "rhs_call_name": "open", "annotation": ""}, "snippet": " self.open()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98899:Assign_L26_C12", "label": "self._dimensions_cache = get_image_dimensions()", "type": "assigned_variable", "loc": [26, 26], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98899:If_L23_C8", "vector": [14, 3, 0.4194, 0.0161, 3, 0.32, 1.0, 458, 3, 2, 0, 0, 530, 10, 1], "semantic": {"name": "self._dimensions_cache", "arg_names": [], "import_names": [], "rhs_call_name": "get_image_dimensions", "annotation": ""}, "snippet": " self._dimensions_cache = get_image_dimensions(self, close=close)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98899:Return_L27_C8", "label": "return", "type": "return", "loc": [27, 27], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98899:FunctionDef_L22_C4", "vector": [13, 2, 0.4355, 0.0161, 2, 0.33, 1.0, 0, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return self._dimensions_cache"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98899:FunctionDef_L29_C0", "label": "get_image_dimensions", "type": "function", "loc": [29, 62], "level": 0, "parent": null, "vector": [2, 0, 0.7339, 0.5484, 0, 0.66, 1.0, 530, 0, 2, 1, 0, 0, 0, 9], "semantic": {"name": "get_image_dimensions", "arg_names": ["file_or_path", "close"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "def get_image_dimensions(file_or_path, close=False):\n \"\"\"\n Returns the (width, height) of an image, given an open file or a path. Set\n 'close' to True to close the file at the end if it is initially in an open\n state.\n \"\"\"\n # Try to import PIL in either of the two ways it can end up installed.\n try:"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98899:Expr_L30_C4", "label": "expression", "type": "expression", "loc": [30, 34], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98899:FunctionDef_L29_C0", "vector": [8, 1, 0.5161, 0.0806, 1, 0.94, 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, height) of an image, given an open file or a path. Set\n 'close' to True to close the file at the end if it is initially in an open\n state.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98899:Try_L36_C4", "label": "try", "type": "try", "loc": [36, 39], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98899:FunctionDef_L29_C0", "vector": [7, 1, 0.6048, 0.0645, 1, 0.94, 0.25, 0, 0, 1, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " try:\n from PIL import ImageFile as PILImageFile\n except ImportError:\n import ImageFile as PILImageFile"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98899:ImportFrom_L37_C8", "label": "from PIL import PILImageFile", "type": "import", "loc": [37, 37], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98899:Try_L36_C4", "vector": [1, 2, 0.5968, 0.0161, 2, 0.99, 0.0, 556, 0, 1, 0, 0, 556, 0, 0], "semantic": {"name": "PIL", "arg_names": [], "import_names": ["PILImageFile"], "rhs_call_name": "", "annotation": ""}, "snippet": " from PIL import ImageFile as PILImageFile"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98899:Import_L39_C8", "label": "ImageFile import PILImageFile", "type": "import", "loc": [39, 39], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98899:Try_L36_C4", "vector": [1, 2, 0.629, 0.0161, 2, 0.99, 0.0, 236, 0, 1, 0, 0, 236, 0, 0], "semantic": {"name": "ImageFile", "arg_names": [], "import_names": ["PILImageFile"], "rhs_call_name": "", "annotation": ""}, "snippet": " import ImageFile as PILImageFile"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98899:Assign_L41_C4", "label": "p = Parser()", "type": "assigned_variable", "loc": [41, 41], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98899:FunctionDef_L29_C0", "vector": [14, 1, 0.6613, 0.0161, 1, 0.94, 0.5, 491, 3, 0, 0, 0, 717, 10, 1], "semantic": {"name": "p", "arg_names": [], "import_names": [], "rhs_call_name": "Parser", "annotation": ""}, "snippet": " p = PILImageFile.Parser()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98899:If_L42_C4", "label": "if", "type": "if", "loc": [42, 48], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98899:FunctionDef_L29_C0", "vector": [4, 1, 0.7258, 0.1129, 1, 0.94, 0.75, 0, 3, 0, 0, 0, 0, 0, 4], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if hasattr(file_or_path, 'read'):\n file = file_or_path\n file_pos = file.tell()\n file.seek(0)\n else:\n file = open(file_or_path, 'rb')\n close = True"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98899:Assign_L43_C8", "label": "file =", "type": "assigned_variable", "loc": [43, 43], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98899:If_L42_C4", "vector": [14, 2, 0.6935, 0.0161, 2, 0.08, 0.0, 107, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "file", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " file = file_or_path"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98899:Assign_L44_C8", "label": "file_pos = tell()", "type": "assigned_variable", "loc": [44, 44], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98899:If_L42_C4", "vector": [14, 2, 0.7097, 0.0161, 2, 0.08, 0.25, 542, 3, 0, 0, 0, 759, 10, 1], "semantic": {"name": "file_pos", "arg_names": [], "import_names": [], "rhs_call_name": "tell", "annotation": ""}, "snippet": " file_pos = file.tell()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98899:Expr_L45_C8", "label": "seek()", "type": "expression", "loc": [45, 45], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98899:If_L42_C4", "vector": [8, 2, 0.7258, 0.0161, 2, 0.08, 0.5, 66, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "seek", "arg_names": [], "import_names": [], "rhs_call_name": "seek", "annotation": ""}, "snippet": " file.seek(0)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98899:Assign_L47_C8", "label": "file = open()", "type": "assigned_variable", "loc": [47, 47], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98899:If_L42_C4", "vector": [14, 2, 0.7581, 0.0161, 2, 0.08, 0.75, 107, 3, 2, 0, 0, 693, 10, 1], "semantic": {"name": "file", "arg_names": [], "import_names": [], "rhs_call_name": "open", "annotation": ""}, "snippet": " file = open(file_or_path, 'rb')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98899:Assign_L48_C8", "label": "close =", "type": "assigned_variable", "loc": [48, 48], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98899:If_L42_C4", "vector": [14, 2, 0.7742, 0.0161, 2, 0.08, 1.0, 77, 1, 0, 0, 0, 0, 4, 0], "semantic": {"name": "close", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " close = True"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98899:Try_L49_C4", "label": "try", "type": "try", "loc": [49, 62], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98899:FunctionDef_L29_C0", "vector": [7, 1, 0.8952, 0.2258, 1, 0.94, 1.0, 0, 0, 0, 0, 0, 0, 0, 4], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " try:\n while 1:\n data = file.read(1024)\n if not data:\n break\n p.feed(data)\n if p.image:\n return p.image.size"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98899:While_L50_C8", "label": "while", "type": "while", "loc": [50, 56], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98899:Try_L49_C4", "vector": [5, 2, 0.8548, 0.1129, 2, 0.33, 0.0, 0, 1, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " while 1:\n data = file.read(1024)\n if not data:\n break\n p.feed(data)\n if p.image:\n return p.image.size"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98899:Assign_L51_C12", "label": "data = read()", "type": "assigned_variable", "loc": [51, 51], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98899:While_L50_C8", "vector": [14, 3, 0.8226, 0.0161, 3, 0.9, 0.0, 929, 3, 1, 0, 0, 453, 10, 1], "semantic": {"name": "data", "arg_names": [], "import_names": [], "rhs_call_name": "read", "annotation": ""}, "snippet": " data = file.read(1024)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98899:If_L52_C12", "label": "if", "type": "if", "loc": [52, 53], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98899:While_L50_C8", "vector": [4, 3, 0.8468, 0.0323, 3, 0.9, 0.3333, 0, 0, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if not data:\n break"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98899:Expr_L54_C12", "label": "feed()", "type": "expression", "loc": [54, 54], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98899:While_L50_C8", "vector": [8, 3, 0.871, 0.0161, 3, 0.9, 0.6667, 87, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "feed", "arg_names": [], "import_names": [], "rhs_call_name": "feed", "annotation": ""}, "snippet": " p.feed(data)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98899:If_L55_C12", "label": "if", "type": "if", "loc": [55, 56], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98899:While_L50_C8", "vector": [4, 3, 0.8952, 0.0323, 3, 0.9, 1.0, 0, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if p.image:\n return p.image.size"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98899:Return_L56_C16", "label": "return", "type": "return", "loc": [56, 56], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98899:If_L55_C12", "vector": [13, 4, 0.9032, 0.0161, 4, 0.65, 0.0, 0, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return p.image.size"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98899:Return_L57_C8", "label": "return", "type": "return", "loc": [57, 57], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98899:Try_L49_C4", "vector": [13, 2, 0.9194, 0.0161, 2, 0.33, 0.5, 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_98899:If_L59_C8", "label": "if", "type": "if", "loc": [59, 62], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98899:Try_L49_C4", "vector": [4, 2, 0.9758, 0.0645, 2, 0.33, 1.0, 0, 2, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if close:\n file.close()\n else:\n file.seek(file_pos)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98899:Expr_L60_C12", "label": "close()", "type": "expression", "loc": [60, 60], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98899:If_L59_C8", "vector": [8, 3, 0.9677, 0.0161, 3, 0.9, 0.0, 77, 3, 0, 0, 0, 0, 0, 1], "semantic": {"name": "close", "arg_names": [], "import_names": [], "rhs_call_name": "close", "annotation": ""}, "snippet": " file.close()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98899:Expr_L62_C12", "label": "seek()", "type": "expression", "loc": [62, 62], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98899:If_L59_C8", "vector": [8, 3, 1.0, 0.0161, 3, 0.9, 1.0, 66, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "seek", "arg_names": [], "import_names": [], "rhs_call_name": "seek", "annotation": ""}, "snippet": " file.seek(file_pos)"}]
[{"f": "ajibawa-2023/Python-Code-Large/train/row_98899:ClassDef_L9_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98899:Expr_L10_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98899:ClassDef_L9_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98899:FunctionDef_L14_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98899:FunctionDef_L14_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98899:Return_L15_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98899:ClassDef_L9_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98899:Assign_L16_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98899:ClassDef_L9_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98899:FunctionDef_L18_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98899:FunctionDef_L18_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98899:Return_L19_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98899:ClassDef_L9_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98899:Assign_L20_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98899:ClassDef_L9_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98899:FunctionDef_L22_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98899:FunctionDef_L22_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98899:If_L23_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98899:If_L23_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98899:Assign_L24_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98899:If_L23_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98899:Expr_L25_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98899:If_L23_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98899:Assign_L26_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98899:FunctionDef_L22_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98899:Return_L27_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98899:FunctionDef_L29_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98899:Expr_L30_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98899:FunctionDef_L29_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98899:Try_L36_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98899:Try_L36_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98899:ImportFrom_L37_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98899:Try_L36_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98899:Import_L39_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98899:FunctionDef_L29_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98899:Assign_L41_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98899:FunctionDef_L29_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98899:If_L42_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98899:If_L42_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98899:Assign_L43_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98899:If_L42_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98899:Assign_L44_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98899:If_L42_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98899:Expr_L45_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98899:If_L42_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98899:Assign_L47_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98899:If_L42_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98899:Assign_L48_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98899:FunctionDef_L29_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98899:Try_L49_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98899:Try_L49_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98899:While_L50_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98899:While_L50_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98899:Assign_L51_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98899:While_L50_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98899:If_L52_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98899:While_L50_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98899:Expr_L54_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98899:While_L50_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98899:If_L55_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98899:If_L55_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98899:Return_L56_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98899:Try_L49_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98899:Return_L57_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98899:Try_L49_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98899:If_L59_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98899:If_L59_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98899:Expr_L60_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98899:If_L59_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98899:Expr_L62_C12"}]
""" The temp module provides a NamedTemporaryFile that can be re-opened on any platform. Most platforms use the standard Python tempfile.TemporaryFile class, but MS Windows users are given a custom class. This is needed because in Windows NT, the default implementation of NamedTemporaryFile uses the O_TEMPORARY flag, and thus cannot be reopened [1]. 1: http://mail.python.org/pipermail/python-list/2005-December/359474.html """ import os import tempfile from django.core.files.utils import FileProxyMixin __all__ = ('NamedTemporaryFile', 'gettempdir',) if os.name == 'nt': class TemporaryFile(FileProxyMixin): """ Temporary file object constructor that works in Windows and supports reopening of the temporary file in windows. """ def __init__(self, mode='w+b', bufsize=-1, suffix='', prefix='', dir=None): fd, name = tempfile.mkstemp(suffix=suffix, prefix=prefix, dir=dir) self.name = name self.file = os.fdopen(fd, mode, bufsize) self.close_called = False # Because close can be called during shutdown # we need to cache os.unlink and access it # as self.unlink only unlink = os.unlink def close(self): if not self.close_called: self.close_called = True try: self.file.close() except (OSError, IOError): pass try: self.unlink(self.name) except (OSError): pass def __del__(self): self.close() NamedTemporaryFile = TemporaryFile else: NamedTemporaryFile = tempfile.NamedTemporaryFile gettempdir = tempfile.gettempdir
ajibawa-2023/Python-Code-Large/train/row_98901
26
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_98901:Expr_L1_C0", "label": "expression", "type": "expression", "loc": [1, 10], "level": 0, "parent": null, "vector": [8, 0, 0.0982, 0.1786, 0, 0.66, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "\"\"\"\nThe temp module provides a NamedTemporaryFile that can be re-opened on any\nplatform. Most platforms use the standard Python tempfile.TemporaryFile class,\nbut MS Windows users are given a custom class.\n\nThis is needed because in Windows NT, the default implementation of\nNamedTemporaryFile uses the O_TEMPORARY flag, and thus cannot be reopened [1].\n"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98901:Import_L12_C0", "label": "os import os", "type": "import", "loc": [12, 12], "level": 0, "parent": null, "vector": [1, 0, 0.2143, 0.0179, 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_98901:Import_L13_C0", "label": "tempfile import tempfile", "type": "import", "loc": [13, 13], "level": 0, "parent": null, "vector": [1, 0, 0.2321, 0.0179, 0, 0.66, 0.3333, 516, 0, 1, 0, 0, 516, 0, 0], "semantic": {"name": "tempfile", "arg_names": [], "import_names": ["tempfile"], "rhs_call_name": "", "annotation": ""}, "snippet": "import tempfile"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98901:ImportFrom_L14_C0", "label": "from django.core.files.utils import FileProxyMixin", "type": "import", "loc": [14, 14], "level": 0, "parent": null, "vector": [1, 0, 0.25, 0.0179, 0, 0.66, 0.5, 261, 0, 1, 0, 0, 261, 0, 0], "semantic": {"name": "django.core.files.utils", "arg_names": [], "import_names": ["FileProxyMixin"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.core.files.utils import FileProxyMixin"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98901:Assign_L16_C0", "label": "__all__ =", "type": "assigned_variable", "loc": [16, 16], "level": 0, "parent": null, "vector": [14, 0, 0.2857, 0.0179, 0, 0.66, 0.6667, 272, 0, 0, 0, 0, 0, 8, 0], "semantic": {"name": "__all__", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "__all__ = ('NamedTemporaryFile', 'gettempdir',)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98901:If_L18_C0", "label": "if", "type": "if", "loc": [18, 54], "level": 0, "parent": null, "vector": [4, 0, 0.6429, 0.6607, 0, 0.66, 0.8333, 0, 0, 0, 0, 0, 0, 0, 5], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "if os.name == 'nt':\n class TemporaryFile(FileProxyMixin):\n \"\"\"\n Temporary file object constructor that works in Windows and supports\n reopening of the temporary file in windows.\n \"\"\"\n def __init__(self, mode='w+b', bufsize=-1, suffix='', prefix='',\n dir=None):"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98901:ClassDef_L19_C4", "label": "TemporaryFile", "type": "class", "loc": [19, 50], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98901:If_L18_C0", "vector": [3, 1, 0.6161, 0.5714, 1, 0.38, 0.0, 549, 0, 3, 0, 0, 369, 0, 5], "semantic": {"name": "TemporaryFile", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " class TemporaryFile(FileProxyMixin):\n \"\"\"\n Temporary file object constructor that works in Windows and supports\n reopening of the temporary file in windows.\n \"\"\"\n def __init__(self, mode='w+b', bufsize=-1, suffix='', prefix='',\n dir=None):\n fd, name = tempfile.mkstemp(suffix=suffix, prefix=prefix,"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98901:Expr_L20_C8", "label": "expression", "type": "expression", "loc": [20, 23], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98901:ClassDef_L19_C4", "vector": [8, 2, 0.3839, 0.0714, 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 Temporary file object constructor that works in Windows and supports\n reopening of the temporary file in windows.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98901:FunctionDef_L24_C8", "label": "__init__", "type": "function", "loc": [24, 30], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98901:ClassDef_L19_C4", "vector": [2, 2, 0.4821, 0.125, 2, 0.99, 0.25, 555, 0, 6, 0, 0, 0, 0, 2], "semantic": {"name": "__init__", "arg_names": ["self", "mode", "bufsize", "suffix", "prefix", "dir"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def __init__(self, mode='w+b', bufsize=-1, suffix='', prefix='',\n dir=None):\n fd, name = tempfile.mkstemp(suffix=suffix, prefix=prefix,\n dir=dir)\n self.name = name\n self.file = os.fdopen(fd, mode, bufsize)\n self.close_called = False"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98901:Assign_L26_C12", "label": "fd, name = mkstemp()", "type": "assigned_variable", "loc": [26, 27], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98901:FunctionDef_L24_C8", "vector": [14, 3, 0.4732, 0.0357, 3, 0.99, 0.0, 392, 3, 3, 0, 0, 708, 10, 1], "semantic": {"name": "fd, name", "arg_names": [], "import_names": [], "rhs_call_name": "mkstemp", "annotation": ""}, "snippet": " fd, name = tempfile.mkstemp(suffix=suffix, prefix=prefix,\n dir=dir)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98901:Assign_L28_C12", "label": "self.name =", "type": "assigned_variable", "loc": [28, 28], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98901:FunctionDef_L24_C8", "vector": [14, 3, 0.5, 0.0179, 3, 0.99, 0.3333, 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_98901:Assign_L29_C12", "label": "self.file = fdopen()", "type": "assigned_variable", "loc": [29, 29], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98901:FunctionDef_L24_C8", "vector": [14, 3, 0.5179, 0.0179, 3, 0.99, 0.6667, 678, 3, 3, 0, 0, 783, 10, 1], "semantic": {"name": "self.file", "arg_names": [], "import_names": [], "rhs_call_name": "fdopen", "annotation": ""}, "snippet": " self.file = os.fdopen(fd, mode, bufsize)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98901:Assign_L30_C12", "label": "self.close_called =", "type": "assigned_variable", "loc": [30, 30], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98901:FunctionDef_L24_C8", "vector": [14, 3, 0.5357, 0.0179, 3, 0.99, 1.0, 684, 1, 0, 0, 0, 0, 4, 0], "semantic": {"name": "self.close_called", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.close_called = False"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98901:Assign_L35_C8", "label": "unlink =", "type": "assigned_variable", "loc": [35, 35], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98901:ClassDef_L19_C4", "vector": [14, 2, 0.625, 0.0179, 2, 0.99, 0.5, 701, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "unlink", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " unlink = os.unlink"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98901:FunctionDef_L37_C8", "label": "close", "type": "function", "loc": [37, 47], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98901:ClassDef_L19_C4", "vector": [2, 2, 0.75, 0.1964, 2, 0.99, 0.75, 77, 0, 1, 0, 0, 0, 0, 2], "semantic": {"name": "close", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def close(self):\n if not self.close_called:\n self.close_called = True\n try:\n self.file.close()\n except (OSError, IOError):\n pass\n try:"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98901:If_L38_C12", "label": "if", "type": "if", "loc": [38, 47], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98901:FunctionDef_L37_C8", "vector": [4, 3, 0.7589, 0.1786, 3, 0.52, 0.0, 0, 0, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if not self.close_called:\n self.close_called = True\n try:\n self.file.close()\n except (OSError, IOError):\n pass\n try:\n self.unlink(self.name)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98901:Assign_L39_C16", "label": "self.close_called =", "type": "assigned_variable", "loc": [39, 39], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98901:If_L38_C12", "vector": [14, 4, 0.6964, 0.0179, 4, 0.85, 0.0, 684, 1, 0, 0, 0, 0, 4, 0], "semantic": {"name": "self.close_called", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.close_called = True"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98901:Try_L40_C16", "label": "try", "type": "try", "loc": [40, 43], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98901:If_L38_C12", "vector": [7, 4, 0.7411, 0.0714, 4, 0.85, 0.5, 0, 0, 1, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " try:\n self.file.close()\n except (OSError, IOError):\n pass"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98901:Expr_L41_C20", "label": "close()", "type": "expression", "loc": [41, 41], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98901:Try_L40_C16", "vector": [8, 5, 0.7321, 0.0179, 5, 0.85, 0.0, 77, 3, 0, 0, 0, 0, 0, 1], "semantic": {"name": "close", "arg_names": [], "import_names": [], "rhs_call_name": "close", "annotation": ""}, "snippet": " self.file.close()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98901:Try_L44_C16", "label": "try", "type": "try", "loc": [44, 47], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98901:If_L38_C12", "vector": [7, 4, 0.8125, 0.0714, 4, 0.85, 1.0, 0, 0, 1, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " try:\n self.unlink(self.name)\n except (OSError):\n pass"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98901:Expr_L45_C20", "label": "unlink()", "type": "expression", "loc": [45, 45], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98901:Try_L44_C16", "vector": [8, 5, 0.8036, 0.0179, 5, 0.58, 0.0, 701, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "unlink", "arg_names": [], "import_names": [], "rhs_call_name": "unlink", "annotation": ""}, "snippet": " self.unlink(self.name)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98901:FunctionDef_L49_C8", "label": "__del__", "type": "function", "loc": [49, 50], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98901:ClassDef_L19_C4", "vector": [2, 2, 0.8839, 0.0357, 2, 0.99, 1.0, 258, 0, 1, 0, 0, 0, 0, 1], "semantic": {"name": "__del__", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def __del__(self):\n self.close()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98901:Expr_L50_C12", "label": "close()", "type": "expression", "loc": [50, 50], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98901:FunctionDef_L49_C8", "vector": [8, 3, 0.8929, 0.0179, 3, 0.33, 0.0, 77, 3, 0, 0, 0, 0, 0, 1], "semantic": {"name": "close", "arg_names": [], "import_names": [], "rhs_call_name": "close", "annotation": ""}, "snippet": " self.close()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98901:Assign_L52_C4", "label": "NamedTemporaryFile =", "type": "assigned_variable", "loc": [52, 52], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98901:If_L18_C0", "vector": [14, 1, 0.9286, 0.0179, 1, 0.38, 0.5, 349, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "NamedTemporaryFile", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " NamedTemporaryFile = TemporaryFile"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98901:Assign_L54_C4", "label": "NamedTemporaryFile =", "type": "assigned_variable", "loc": [54, 54], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98901:If_L18_C0", "vector": [14, 1, 0.9643, 0.0179, 1, 0.38, 1.0, 349, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "NamedTemporaryFile", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " NamedTemporaryFile = tempfile.NamedTemporaryFile"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98901:Assign_L56_C0", "label": "gettempdir =", "type": "assigned_variable", "loc": [56, 56], "level": 0, "parent": null, "vector": [14, 0, 1.0, 0.0179, 0, 0.66, 1.0, 435, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "gettempdir", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "gettempdir = tempfile.gettempdir"}]
[{"f": "ajibawa-2023/Python-Code-Large/train/row_98901:If_L18_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98901:ClassDef_L19_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98901:ClassDef_L19_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98901:Expr_L20_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98901:ClassDef_L19_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98901:FunctionDef_L24_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98901:FunctionDef_L24_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98901:Assign_L26_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98901:FunctionDef_L24_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98901:Assign_L28_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98901:FunctionDef_L24_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98901:Assign_L29_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98901:FunctionDef_L24_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98901:Assign_L30_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98901:ClassDef_L19_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98901:Assign_L35_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98901:ClassDef_L19_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98901:FunctionDef_L37_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98901:FunctionDef_L37_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98901:If_L38_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98901:If_L38_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98901:Assign_L39_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98901:If_L38_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98901:Try_L40_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98901:Try_L40_C16", "t": "ajibawa-2023/Python-Code-Large/train/row_98901:Expr_L41_C20"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98901:If_L38_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98901:Try_L44_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98901:Try_L44_C16", "t": "ajibawa-2023/Python-Code-Large/train/row_98901:Expr_L45_C20"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98901:ClassDef_L19_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98901:FunctionDef_L49_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98901:FunctionDef_L49_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98901:Expr_L50_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98901:If_L18_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98901:Assign_L52_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98901:If_L18_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98901:Assign_L54_C4"}]
class FileProxyMixin(object): """ A mixin class used to forward file methods to an underlaying file object. The internal file object has to be called "file":: class FileProxy(FileProxyMixin): def __init__(self, file): self.file = file """ encoding = property(lambda self: self.file.encoding) fileno = property(lambda self: self.file.fileno) flush = property(lambda self: self.file.flush) isatty = property(lambda self: self.file.isatty) newlines = property(lambda self: self.file.newlines) read = property(lambda self: self.file.read) readinto = property(lambda self: self.file.readinto) readline = property(lambda self: self.file.readline) readlines = property(lambda self: self.file.readlines) seek = property(lambda self: self.file.seek) softspace = property(lambda self: self.file.softspace) tell = property(lambda self: self.file.tell) truncate = property(lambda self: self.file.truncate) write = property(lambda self: self.file.write) writelines = property(lambda self: self.file.writelines) xreadlines = property(lambda self: self.file.xreadlines) def __iter__(self): return iter(self.file)
ajibawa-2023/Python-Code-Large/train/row_98902
20
29
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_98902:ClassDef_L1_C0", "label": "FileProxyMixin", "type": "class", "loc": [1, 29], "level": 0, "parent": null, "vector": [3, 0, 0.5172, 1.0, 0, 0.66, 0.0, 369, 0, 1, 0, 0, 186, 0, 17], "semantic": {"name": "FileProxyMixin", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class FileProxyMixin(object):\n \"\"\"\n A mixin class used to forward file methods to an underlaying file\n object. The internal file object has to be called \"file\"::\n\n class FileProxy(FileProxyMixin):\n def __init__(self, file):\n self.file = file"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98902:Expr_L2_C4", "label": "expression", "type": "expression", "loc": [2, 9], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98902:ClassDef_L1_C0", "vector": [8, 1, 0.1897, 0.2759, 1, 0.69, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"\n A mixin class used to forward file methods to an underlaying file\n object. The internal file object has to be called \"file\"::\n\n class FileProxy(FileProxyMixin):\n def __init__(self, file):\n self.file = file\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98902:Assign_L11_C4", "label": "encoding = property()", "type": "assigned_variable", "loc": [11, 11], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98902:ClassDef_L1_C0", "vector": [14, 1, 0.3793, 0.0345, 1, 0.69, 0.0588, 325, 3, 1, 0, 0, 244, 10, 1], "semantic": {"name": "encoding", "arg_names": [], "import_names": [], "rhs_call_name": "property", "annotation": ""}, "snippet": " encoding = property(lambda self: self.file.encoding)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98902:Assign_L12_C4", "label": "fileno = property()", "type": "assigned_variable", "loc": [12, 12], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98902:ClassDef_L1_C0", "vector": [14, 1, 0.4138, 0.0345, 1, 0.69, 0.1176, 15, 3, 1, 0, 0, 244, 10, 1], "semantic": {"name": "fileno", "arg_names": [], "import_names": [], "rhs_call_name": "property", "annotation": ""}, "snippet": " fileno = property(lambda self: self.file.fileno)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98902:Assign_L13_C4", "label": "flush = property()", "type": "assigned_variable", "loc": [13, 13], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98902:ClassDef_L1_C0", "vector": [14, 1, 0.4483, 0.0345, 1, 0.69, 0.1765, 439, 3, 1, 0, 0, 244, 10, 1], "semantic": {"name": "flush", "arg_names": [], "import_names": [], "rhs_call_name": "property", "annotation": ""}, "snippet": " flush = property(lambda self: self.file.flush)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98902:Assign_L14_C4", "label": "isatty = property()", "type": "assigned_variable", "loc": [14, 14], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98902:ClassDef_L1_C0", "vector": [14, 1, 0.4828, 0.0345, 1, 0.69, 0.2353, 341, 3, 1, 0, 0, 244, 10, 1], "semantic": {"name": "isatty", "arg_names": [], "import_names": [], "rhs_call_name": "property", "annotation": ""}, "snippet": " isatty = property(lambda self: self.file.isatty)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98902:Assign_L15_C4", "label": "newlines = property()", "type": "assigned_variable", "loc": [15, 15], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98902:ClassDef_L1_C0", "vector": [14, 1, 0.5172, 0.0345, 1, 0.69, 0.2941, 73, 3, 1, 0, 0, 244, 10, 1], "semantic": {"name": "newlines", "arg_names": [], "import_names": [], "rhs_call_name": "property", "annotation": ""}, "snippet": " newlines = property(lambda self: self.file.newlines)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98902:Assign_L16_C4", "label": "read = property()", "type": "assigned_variable", "loc": [16, 16], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98902:ClassDef_L1_C0", "vector": [14, 1, 0.5517, 0.0345, 1, 0.69, 0.3529, 453, 3, 1, 0, 0, 244, 10, 1], "semantic": {"name": "read", "arg_names": [], "import_names": [], "rhs_call_name": "property", "annotation": ""}, "snippet": " read = property(lambda self: self.file.read)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98902:Assign_L17_C4", "label": "readinto = property()", "type": "assigned_variable", "loc": [17, 17], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98902:ClassDef_L1_C0", "vector": [14, 1, 0.5862, 0.0345, 1, 0.69, 0.4118, 48, 3, 1, 0, 0, 244, 10, 1], "semantic": {"name": "readinto", "arg_names": [], "import_names": [], "rhs_call_name": "property", "annotation": ""}, "snippet": " readinto = property(lambda self: self.file.readinto)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98902:Assign_L18_C4", "label": "readline = property()", "type": "assigned_variable", "loc": [18, 18], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98902:ClassDef_L1_C0", "vector": [14, 1, 0.6207, 0.0345, 1, 0.69, 0.4706, 303, 3, 1, 0, 0, 244, 10, 1], "semantic": {"name": "readline", "arg_names": [], "import_names": [], "rhs_call_name": "property", "annotation": ""}, "snippet": " readline = property(lambda self: self.file.readline)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98902:Assign_L19_C4", "label": "readlines = property()", "type": "assigned_variable", "loc": [19, 19], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98902:ClassDef_L1_C0", "vector": [14, 1, 0.6552, 0.0345, 1, 0.69, 0.5294, 841, 3, 1, 0, 0, 244, 10, 1], "semantic": {"name": "readlines", "arg_names": [], "import_names": [], "rhs_call_name": "property", "annotation": ""}, "snippet": " readlines = property(lambda self: self.file.readlines)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98902:Assign_L20_C4", "label": "seek = property()", "type": "assigned_variable", "loc": [20, 20], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98902:ClassDef_L1_C0", "vector": [14, 1, 0.6897, 0.0345, 1, 0.69, 0.5882, 66, 3, 1, 0, 0, 244, 10, 1], "semantic": {"name": "seek", "arg_names": [], "import_names": [], "rhs_call_name": "property", "annotation": ""}, "snippet": " seek = property(lambda self: self.file.seek)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98902:Assign_L21_C4", "label": "softspace = property()", "type": "assigned_variable", "loc": [21, 21], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98902:ClassDef_L1_C0", "vector": [14, 1, 0.7241, 0.0345, 1, 0.69, 0.6471, 90, 3, 1, 0, 0, 244, 10, 1], "semantic": {"name": "softspace", "arg_names": [], "import_names": [], "rhs_call_name": "property", "annotation": ""}, "snippet": " softspace = property(lambda self: self.file.softspace)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98902:Assign_L22_C4", "label": "tell = property()", "type": "assigned_variable", "loc": [22, 22], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98902:ClassDef_L1_C0", "vector": [14, 1, 0.7586, 0.0345, 1, 0.69, 0.7059, 759, 3, 1, 0, 0, 244, 10, 1], "semantic": {"name": "tell", "arg_names": [], "import_names": [], "rhs_call_name": "property", "annotation": ""}, "snippet": " tell = property(lambda self: self.file.tell)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98902:Assign_L23_C4", "label": "truncate = property()", "type": "assigned_variable", "loc": [23, 23], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98902:ClassDef_L1_C0", "vector": [14, 1, 0.7931, 0.0345, 1, 0.69, 0.7647, 39, 3, 1, 0, 0, 244, 10, 1], "semantic": {"name": "truncate", "arg_names": [], "import_names": [], "rhs_call_name": "property", "annotation": ""}, "snippet": " truncate = property(lambda self: self.file.truncate)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98902:Assign_L24_C4", "label": "write = property()", "type": "assigned_variable", "loc": [24, 24], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98902:ClassDef_L1_C0", "vector": [14, 1, 0.8276, 0.0345, 1, 0.69, 0.8235, 837, 3, 1, 0, 0, 244, 10, 1], "semantic": {"name": "write", "arg_names": [], "import_names": [], "rhs_call_name": "property", "annotation": ""}, "snippet": " write = property(lambda self: self.file.write)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98902:Assign_L25_C4", "label": "writelines = property()", "type": "assigned_variable", "loc": [25, 25], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98902:ClassDef_L1_C0", "vector": [14, 1, 0.8621, 0.0345, 1, 0.69, 0.8824, 290, 3, 1, 0, 0, 244, 10, 1], "semantic": {"name": "writelines", "arg_names": [], "import_names": [], "rhs_call_name": "property", "annotation": ""}, "snippet": " writelines = property(lambda self: self.file.writelines)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98902:Assign_L26_C4", "label": "xreadlines = property()", "type": "assigned_variable", "loc": [26, 26], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98902:ClassDef_L1_C0", "vector": [14, 1, 0.8966, 0.0345, 1, 0.69, 0.9412, 68, 3, 1, 0, 0, 244, 10, 1], "semantic": {"name": "xreadlines", "arg_names": [], "import_names": [], "rhs_call_name": "property", "annotation": ""}, "snippet": " xreadlines = property(lambda self: self.file.xreadlines)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98902:FunctionDef_L28_C4", "label": "__iter__", "type": "function", "loc": [28, 29], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98902:ClassDef_L1_C0", "vector": [2, 1, 0.9828, 0.069, 1, 0.69, 1.0, 891, 0, 1, 1, 0, 0, 0, 1], "semantic": {"name": "__iter__", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def __iter__(self):\n return iter(self.file)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98902:Return_L29_C8", "label": "return", "type": "return", "loc": [29, 29], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98902:FunctionDef_L28_C4", "vector": [13, 2, 1.0, 0.0345, 2, 0.16, 0.0, 0, 3, 0, 0, 0, 0, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return iter(self.file)"}]
[{"f": "ajibawa-2023/Python-Code-Large/train/row_98902:ClassDef_L1_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98902:Expr_L2_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98902:ClassDef_L1_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98902:Assign_L11_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98902:ClassDef_L1_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98902:Assign_L12_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98902:ClassDef_L1_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98902:Assign_L13_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98902:ClassDef_L1_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98902:Assign_L14_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98902:ClassDef_L1_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98902:Assign_L15_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98902:ClassDef_L1_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98902:Assign_L16_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98902:ClassDef_L1_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98902:Assign_L17_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98902:ClassDef_L1_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98902:Assign_L18_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98902:ClassDef_L1_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98902:Assign_L19_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98902:ClassDef_L1_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98902:Assign_L20_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98902:ClassDef_L1_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98902:Assign_L21_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98902:ClassDef_L1_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98902:Assign_L22_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98902:ClassDef_L1_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98902:Assign_L23_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98902:ClassDef_L1_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98902:Assign_L24_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98902:ClassDef_L1_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98902:Assign_L25_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98902:ClassDef_L1_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98902:Assign_L26_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98902:ClassDef_L1_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98902:FunctionDef_L28_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98902:FunctionDef_L28_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98902:Return_L29_C8"}]
import os try: from cStringIO import StringIO except ImportError: from StringIO import StringIO from django.utils.encoding import smart_str, smart_unicode from django.core.files.utils import FileProxyMixin class File(FileProxyMixin): DEFAULT_CHUNK_SIZE = 64 * 2**10 def __init__(self, file, name=None): self.file = file if name is None: name = getattr(file, 'name', None) self.name = name self.mode = getattr(file, 'mode', None) def __str__(self): return smart_str(self.name or '') def __unicode__(self): return smart_unicode(self.name or u'') def __repr__(self): return "<%s: %s>" % (self.__class__.__name__, self or "None") def __nonzero__(self): return bool(self.name) def __len__(self): return self.size def _get_size(self): if not hasattr(self, '_size'): if hasattr(self.file, 'size'): self._size = self.file.size elif os.path.exists(self.file.name): self._size = os.path.getsize(self.file.name) else: raise AttributeError("Unable to determine the file's size.") return self._size def _set_size(self, size): self._size = size size = property(_get_size, _set_size) def _get_closed(self): return not self.file or self.file.closed closed = property(_get_closed) def chunks(self, chunk_size=None): """ Read the file and yield chucks of ``chunk_size`` bytes (defaults to ``UploadedFile.DEFAULT_CHUNK_SIZE``). """ if not chunk_size: chunk_size = self.DEFAULT_CHUNK_SIZE if hasattr(self, 'seek'): self.seek(0) # Assume the pointer is at zero... counter = self.size while counter > 0: yield self.read(chunk_size) counter -= chunk_size def multiple_chunks(self, chunk_size=None): """ Returns ``True`` if you can expect multiple chunks. NB: If a particular file representation is in memory, subclasses should always return ``False`` -- there's no good reason to read from memory in chunks. """ if not chunk_size: chunk_size = self.DEFAULT_CHUNK_SIZE return self.size > chunk_size def __iter__(self): # Iterate over this file-like object by newlines buffer_ = None for chunk in self.chunks(): chunk_buffer = StringIO(chunk) for line in chunk_buffer: if buffer_: line = buffer_ + line buffer_ = None # If this is the end of a line, yield # otherwise, wait for the next round if line[-1] in ('\n', '\r'): yield line else: buffer_ = line if buffer_ is not None: yield buffer_ def open(self, mode=None): if not self.closed: self.seek(0) elif self.name and os.path.exists(self.name): self.file = open(self.name, mode or self.mode) else: raise ValueError("The file cannot be reopened.") def close(self): self.file.close() class ContentFile(File): """ A File-like object that takes just raw content, rather than an actual file. """ def __init__(self, content): content = content or '' super(ContentFile, self).__init__(StringIO(content)) self.size = len(content) def __str__(self): return 'Raw content' def __nonzero__(self): return True def open(self, mode=None): self.seek(0) def close(self): pass
ajibawa-2023/Python-Code-Large/train/row_98904
84
134
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_98904:Import_L1_C0", "label": "os import os", "type": "import", "loc": [1, 1], "level": 0, "parent": null, "vector": [1, 0, 0.0075, 0.0075, 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_98904:Try_L2_C0", "label": "try", "type": "try", "loc": [2, 5], "level": 0, "parent": null, "vector": [7, 0, 0.0261, 0.0299, 0, 0.66, 0.2, 0, 0, 1, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "try:\n from cStringIO import StringIO\nexcept ImportError:\n from StringIO import StringIO"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98904:ImportFrom_L3_C4", "label": "from cStringIO import StringIO", "type": "import", "loc": [3, 3], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98904:Try_L2_C0", "vector": [1, 1, 0.0224, 0.0075, 1, 0.38, 0.0, 764, 0, 1, 0, 0, 764, 0, 0], "semantic": {"name": "cStringIO", "arg_names": [], "import_names": ["StringIO"], "rhs_call_name": "", "annotation": ""}, "snippet": " from cStringIO import StringIO"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98904:ImportFrom_L5_C4", "label": "from StringIO import StringIO", "type": "import", "loc": [5, 5], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98904:Try_L2_C0", "vector": [1, 1, 0.0373, 0.0075, 1, 0.38, 0.0, 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_98904:ImportFrom_L7_C0", "label": "from django.utils.encoding import smart_str, smart_unicode", "type": "import", "loc": [7, 7], "level": 0, "parent": null, "vector": [1, 0, 0.0522, 0.0075, 0, 0.66, 0.4, 96, 0, 2, 0, 0, 96, 0, 0], "semantic": {"name": "django.utils.encoding", "arg_names": [], "import_names": ["smart_str", "smart_unicode"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.utils.encoding import smart_str, smart_unicode"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98904:ImportFrom_L8_C0", "label": "from django.core.files.utils import FileProxyMixin", "type": "import", "loc": [8, 8], "level": 0, "parent": null, "vector": [1, 0, 0.0597, 0.0075, 0, 0.66, 0.6, 261, 0, 1, 0, 0, 261, 0, 0], "semantic": {"name": "django.core.files.utils", "arg_names": [], "import_names": ["FileProxyMixin"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.core.files.utils import FileProxyMixin"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98904:ClassDef_L10_C0", "label": "File", "type": "class", "loc": [10, 113], "level": 0, "parent": null, "vector": [3, 0, 0.459, 0.7761, 0, 0.66, 0.8, 491, 0, 14, 0, 0, 369, 0, 22], "semantic": {"name": "File", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class File(FileProxyMixin):\n DEFAULT_CHUNK_SIZE = 64 * 2**10\n\n def __init__(self, file, name=None):\n self.file = file\n if name is None:\n name = getattr(file, 'name', None)\n self.name = name"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98904:Assign_L11_C4", "label": "DEFAULT_CHUNK_SIZE =", "type": "assigned_variable", "loc": [11, 11], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98904:ClassDef_L10_C0", "vector": [14, 1, 0.0821, 0.0075, 1, 0.4, 0.0, 308, 4, 0, 0, 0, 0, 0, 0], "semantic": {"name": "DEFAULT_CHUNK_SIZE", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " DEFAULT_CHUNK_SIZE = 64 * 2**10"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98904:FunctionDef_L13_C4", "label": "__init__", "type": "function", "loc": [13, 18], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98904:ClassDef_L10_C0", "vector": [2, 1, 0.1157, 0.0448, 1, 0.4, 0.0625, 555, 0, 3, 0, 0, 0, 0, 2], "semantic": {"name": "__init__", "arg_names": ["self", "file", "name"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def __init__(self, file, name=None):\n self.file = file\n if name is None:\n name = getattr(file, 'name', None)\n self.name = name\n self.mode = getattr(file, 'mode', None)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98904:Assign_L14_C8", "label": "self.file =", "type": "assigned_variable", "loc": [14, 14], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98904:FunctionDef_L13_C4", "vector": [14, 2, 0.1045, 0.0075, 2, 0.48, 0.0, 678, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "self.file", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self.file = file"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98904:If_L15_C8", "label": "if", "type": "if", "loc": [15, 16], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98904:FunctionDef_L13_C4", "vector": [4, 2, 0.1157, 0.0149, 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 name is None:\n name = getattr(file, 'name', None)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98904:Assign_L16_C12", "label": "name = getattr()", "type": "assigned_variable", "loc": [16, 16], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98904:If_L15_C8", "vector": [14, 3, 0.1194, 0.0075, 3, 0.79, 0.0, 57, 3, 3, 0, 0, 121, 10, 1], "semantic": {"name": "name", "arg_names": [], "import_names": [], "rhs_call_name": "getattr", "annotation": ""}, "snippet": " name = getattr(file, 'name', None)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98904:Assign_L17_C8", "label": "self.name =", "type": "assigned_variable", "loc": [17, 17], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98904:FunctionDef_L13_C4", "vector": [14, 2, 0.1269, 0.0075, 2, 0.48, 0.6667, 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_98904:Assign_L18_C8", "label": "self.mode = getattr()", "type": "assigned_variable", "loc": [18, 18], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98904:FunctionDef_L13_C4", "vector": [14, 2, 0.1343, 0.0075, 2, 0.48, 1.0, 474, 3, 3, 0, 0, 121, 10, 1], "semantic": {"name": "self.mode", "arg_names": [], "import_names": [], "rhs_call_name": "getattr", "annotation": ""}, "snippet": " self.mode = getattr(file, 'mode', None)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98904:FunctionDef_L20_C4", "label": "__str__", "type": "function", "loc": [20, 21], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98904:ClassDef_L10_C0", "vector": [2, 1, 0.153, 0.0149, 1, 0.4, 0.125, 527, 0, 1, 1, 0, 0, 0, 1], "semantic": {"name": "__str__", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def __str__(self):\n return smart_str(self.name or '')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98904:Return_L21_C8", "label": "return", "type": "return", "loc": [21, 21], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98904:FunctionDef_L20_C4", "vector": [13, 2, 0.1567, 0.0075, 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 smart_str(self.name or '')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98904:FunctionDef_L23_C4", "label": "__unicode__", "type": "function", "loc": [23, 24], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98904:ClassDef_L10_C0", "vector": [2, 1, 0.1754, 0.0149, 1, 0.4, 0.1875, 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 return smart_unicode(self.name or u'')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98904:Return_L24_C8", "label": "return", "type": "return", "loc": [24, 24], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98904:FunctionDef_L23_C4", "vector": [13, 2, 0.1791, 0.0075, 2, 0.72, 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.name or u'')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98904:FunctionDef_L26_C4", "label": "__repr__", "type": "function", "loc": [26, 27], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98904:ClassDef_L10_C0", "vector": [2, 1, 0.1978, 0.0149, 1, 0.4, 0.25, 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 \"<%s: %s>\" % (self.__class__.__name__, self or \"None\")"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98904:Return_L27_C8", "label": "return", "type": "return", "loc": [27, 27], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98904:FunctionDef_L26_C4", "vector": [13, 2, 0.2015, 0.0075, 2, 0.69, 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.__class__.__name__, self or \"None\")"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98904:FunctionDef_L29_C4", "label": "__nonzero__", "type": "function", "loc": [29, 30], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98904:ClassDef_L10_C0", "vector": [2, 1, 0.2201, 0.0149, 1, 0.4, 0.3125, 322, 0, 1, 1, 0, 0, 0, 1], "semantic": {"name": "__nonzero__", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def __nonzero__(self):\n return bool(self.name)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98904:Return_L30_C8", "label": "return", "type": "return", "loc": [30, 30], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98904:FunctionDef_L29_C4", "vector": [13, 2, 0.2239, 0.0075, 2, 0.4, 0.0, 0, 3, 0, 0, 0, 0, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return bool(self.name)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98904:FunctionDef_L32_C4", "label": "__len__", "type": "function", "loc": [32, 33], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98904:ClassDef_L10_C0", "vector": [2, 1, 0.2425, 0.0149, 1, 0.4, 0.375, 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 return self.size"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98904:Return_L33_C8", "label": "return", "type": "return", "loc": [33, 33], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98904:FunctionDef_L32_C4", "vector": [13, 2, 0.2463, 0.0075, 2, 0.38, 0.0, 0, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return self.size"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98904:FunctionDef_L35_C4", "label": "_get_size", "type": "function", "loc": [35, 43], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98904:ClassDef_L10_C0", "vector": [2, 1, 0.291, 0.0672, 1, 0.4, 0.4375, 61, 0, 1, 1, 0, 0, 0, 5], "semantic": {"name": "_get_size", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def _get_size(self):\n if not hasattr(self, '_size'):\n if hasattr(self.file, 'size'):\n self._size = self.file.size\n elif os.path.exists(self.file.name):\n self._size = os.path.getsize(self.file.name)\n else:\n raise AttributeError(\"Unable to determine the file's size.\")"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98904:If_L36_C8", "label": "if", "type": "if", "loc": [36, 42], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98904:FunctionDef_L35_C4", "vector": [4, 2, 0.291, 0.0522, 2, 0.84, 0.0, 0, 0, 0, 0, 0, 0, 0, 5], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if not hasattr(self, '_size'):\n if hasattr(self.file, 'size'):\n self._size = self.file.size\n elif os.path.exists(self.file.name):\n self._size = os.path.getsize(self.file.name)\n else:\n raise AttributeError(\"Unable to determine the file's size.\")"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98904:If_L37_C12", "label": "if", "type": "if", "loc": [37, 42], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98904:If_L36_C8", "vector": [4, 3, 0.2948, 0.0448, 3, 0.57, 0.0, 0, 3, 0, 0, 0, 0, 0, 4], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if hasattr(self.file, 'size'):\n self._size = self.file.size\n elif os.path.exists(self.file.name):\n self._size = os.path.getsize(self.file.name)\n else:\n raise AttributeError(\"Unable to determine the file's size.\")"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98904:Assign_L38_C16", "label": "self._size =", "type": "assigned_variable", "loc": [38, 38], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98904:If_L37_C12", "vector": [14, 4, 0.2836, 0.0075, 4, 0.94, 0.0, 692, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "self._size", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self._size = self.file.size"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98904:If_L39_C12", "label": "if", "type": "if", "loc": [39, 42], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98904:If_L37_C12", "vector": [4, 4, 0.3022, 0.0299, 4, 0.94, 1.0, 0, 3, 0, 0, 0, 0, 0, 3], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " elif os.path.exists(self.file.name):\n self._size = os.path.getsize(self.file.name)\n else:\n raise AttributeError(\"Unable to determine the file's size.\")"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98904:Assign_L40_C16", "label": "self._size = getsize()", "type": "assigned_variable", "loc": [40, 40], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98904:If_L39_C12", "vector": [14, 5, 0.2985, 0.0075, 5, 0.37, 0.0, 692, 3, 1, 0, 0, 554, 10, 1], "semantic": {"name": "self._size", "arg_names": [], "import_names": [], "rhs_call_name": "getsize", "annotation": ""}, "snippet": " self._size = os.path.getsize(self.file.name)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98904:Return_L43_C8", "label": "return", "type": "return", "loc": [43, 43], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98904:FunctionDef_L35_C4", "vector": [13, 2, 0.3209, 0.0075, 2, 0.84, 1.0, 0, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return self._size"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98904:FunctionDef_L45_C4", "label": "_set_size", "type": "function", "loc": [45, 46], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98904:ClassDef_L10_C0", "vector": [2, 1, 0.3396, 0.0149, 1, 0.4, 0.5, 387, 0, 2, 0, 0, 0, 0, 0], "semantic": {"name": "_set_size", "arg_names": ["self", "size"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def _set_size(self, size):\n self._size = size"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98904:Assign_L46_C8", "label": "self._size =", "type": "assigned_variable", "loc": [46, 46], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98904:FunctionDef_L45_C4", "vector": [14, 2, 0.3433, 0.0075, 2, 0.21, 0.0, 692, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "self._size", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " self._size = size"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98904:Assign_L48_C4", "label": "size = property()", "type": "assigned_variable", "loc": [48, 48], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98904:ClassDef_L10_C0", "vector": [14, 1, 0.3582, 0.0075, 1, 0.4, 0.5625, 714, 3, 2, 0, 0, 244, 10, 1], "semantic": {"name": "size", "arg_names": [], "import_names": [], "rhs_call_name": "property", "annotation": ""}, "snippet": " size = property(_get_size, _set_size)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98904:FunctionDef_L50_C4", "label": "_get_closed", "type": "function", "loc": [50, 51], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98904:ClassDef_L10_C0", "vector": [2, 1, 0.3769, 0.0149, 1, 0.4, 0.625, 324, 0, 1, 1, 0, 0, 0, 0], "semantic": {"name": "_get_closed", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def _get_closed(self):\n return not self.file or self.file.closed"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98904:Return_L51_C8", "label": "return", "type": "return", "loc": [51, 51], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98904:FunctionDef_L50_C4", "vector": [13, 2, 0.3806, 0.0075, 2, 0.17, 0.0, 0, 0, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return not self.file or self.file.closed"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98904:Assign_L52_C4", "label": "closed = property()", "type": "assigned_variable", "loc": [52, 52], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98904:ClassDef_L10_C0", "vector": [14, 1, 0.3881, 0.0075, 1, 0.4, 0.6875, 883, 3, 1, 0, 0, 244, 10, 1], "semantic": {"name": "closed", "arg_names": [], "import_names": [], "rhs_call_name": "property", "annotation": ""}, "snippet": " closed = property(_get_closed)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98904:FunctionDef_L54_C4", "label": "chunks", "type": "function", "loc": [54, 69], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98904:ClassDef_L10_C0", "vector": [2, 1, 0.459, 0.1194, 1, 0.4, 0.75, 284, 0, 2, 0, 0, 0, 0, 3], "semantic": {"name": "chunks", "arg_names": ["self", "chunk_size"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def chunks(self, chunk_size=None):\n \"\"\"\n Read the file and yield chucks of ``chunk_size`` bytes (defaults to\n ``UploadedFile.DEFAULT_CHUNK_SIZE``).\n \"\"\"\n if not chunk_size:\n chunk_size = self.DEFAULT_CHUNK_SIZE\n"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98904:Expr_L55_C8", "label": "expression", "type": "expression", "loc": [55, 58], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98904:FunctionDef_L54_C4", "vector": [8, 2, 0.4216, 0.0299, 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 Read the file and yield chucks of ``chunk_size`` bytes (defaults to\n ``UploadedFile.DEFAULT_CHUNK_SIZE``).\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98904:If_L59_C8", "label": "if", "type": "if", "loc": [59, 60], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98904:FunctionDef_L54_C4", "vector": [4, 2, 0.444, 0.0149, 2, 0.03, 0.25, 0, 0, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if not chunk_size:\n chunk_size = self.DEFAULT_CHUNK_SIZE"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98904:Assign_L60_C12", "label": "chunk_size =", "type": "assigned_variable", "loc": [60, 60], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98904:If_L59_C8", "vector": [14, 3, 0.4478, 0.0075, 3, 0.04, 0.0, 135, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "chunk_size", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " chunk_size = self.DEFAULT_CHUNK_SIZE"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98904:If_L62_C8", "label": "if", "type": "if", "loc": [62, 63], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98904:FunctionDef_L54_C4", "vector": [4, 2, 0.4664, 0.0149, 2, 0.03, 0.5, 0, 3, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if hasattr(self, 'seek'):\n self.seek(0)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98904:Expr_L63_C12", "label": "seek()", "type": "expression", "loc": [63, 63], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98904:If_L62_C8", "vector": [8, 3, 0.4701, 0.0075, 3, 0.25, 0.0, 66, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "seek", "arg_names": [], "import_names": [], "rhs_call_name": "seek", "annotation": ""}, "snippet": " self.seek(0)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98904:Assign_L65_C8", "label": "counter =", "type": "assigned_variable", "loc": [65, 65], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98904:FunctionDef_L54_C4", "vector": [14, 2, 0.4851, 0.0075, 2, 0.03, 0.75, 7, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "counter", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " counter = self.size"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98904:While_L67_C8", "label": "while", "type": "while", "loc": [67, 69], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98904:FunctionDef_L54_C4", "vector": [5, 2, 0.5075, 0.0224, 2, 0.03, 1.0, 0, 0, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " while counter > 0:\n yield self.read(chunk_size)\n counter -= chunk_size"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98904:Expr_L68_C12", "label": "expression", "type": "expression", "loc": [68, 68], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98904:While_L67_C8", "vector": [8, 3, 0.5075, 0.0075, 3, 0.97, 0.0, 0, 0, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " yield self.read(chunk_size)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98904:FunctionDef_L71_C4", "label": "multiple_chunks", "type": "function", "loc": [71, 81], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98904:ClassDef_L10_C0", "vector": [2, 1, 0.5672, 0.0821, 1, 0.4, 0.8125, 422, 0, 2, 1, 0, 0, 0, 0], "semantic": {"name": "multiple_chunks", "arg_names": ["self", "chunk_size"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def multiple_chunks(self, chunk_size=None):\n \"\"\"\n Returns ``True`` if you can expect multiple chunks.\n\n NB: If a particular file representation is in memory, subclasses should\n always return ``False`` -- there's no good reason to read from memory in\n chunks.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98904:Expr_L72_C8", "label": "expression", "type": "expression", "loc": [72, 78], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98904:FunctionDef_L71_C4", "vector": [8, 2, 0.5597, 0.0522, 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 you can expect multiple chunks.\n\n NB: If a particular file representation is in memory, subclasses should\n always return ``False`` -- there's no good reason to read from memory in\n chunks.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98904:If_L79_C8", "label": "if", "type": "if", "loc": [79, 80], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98904:FunctionDef_L71_C4", "vector": [4, 2, 0.5933, 0.0149, 2, 0.56, 0.5, 0, 0, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if not chunk_size:\n chunk_size = self.DEFAULT_CHUNK_SIZE"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98904:Assign_L80_C12", "label": "chunk_size =", "type": "assigned_variable", "loc": [80, 80], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98904:If_L79_C8", "vector": [14, 3, 0.597, 0.0075, 3, 0.89, 0.0, 135, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "chunk_size", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " chunk_size = self.DEFAULT_CHUNK_SIZE"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98904:Return_L81_C8", "label": "return", "type": "return", "loc": [81, 81], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98904:FunctionDef_L71_C4", "vector": [13, 2, 0.6045, 0.0075, 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 self.size > chunk_size"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98904:FunctionDef_L83_C4", "label": "__iter__", "type": "function", "loc": [83, 102], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98904:ClassDef_L10_C0", "vector": [2, 1, 0.6903, 0.1493, 1, 0.4, 0.875, 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 # Iterate over this file-like object by newlines\n buffer_ = None\n for chunk in self.chunks():\n chunk_buffer = StringIO(chunk)\n\n for line in chunk_buffer:\n if buffer_:"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98904:Assign_L85_C8", "label": "buffer_ =", "type": "assigned_variable", "loc": [85, 85], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98904:FunctionDef_L83_C4", "vector": [14, 2, 0.6343, 0.0075, 2, 0.56, 0.0, 850, 1, 0, 0, 0, 0, 9, 0], "semantic": {"name": "buffer_", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " buffer_ = None"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98904:For_L86_C8", "label": "for chunk", "type": "for", "loc": [86, 99], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98904:FunctionDef_L83_C4", "vector": [6, 2, 0.6903, 0.1045, 2, 0.56, 0.5, 637, 3, 0, 0, 0, 0, 0, 2], "semantic": {"name": "chunk", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for chunk in self.chunks():\n chunk_buffer = StringIO(chunk)\n\n for line in chunk_buffer:\n if buffer_:\n line = buffer_ + line\n buffer_ = None\n"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98904:Assign_L87_C12", "label": "chunk_buffer = StringIO()", "type": "assigned_variable", "loc": [87, 87], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98904:For_L86_C8", "vector": [14, 3, 0.6493, 0.0075, 3, 0.6, 0.0, 766, 3, 1, 0, 0, 609, 10, 1], "semantic": {"name": "chunk_buffer", "arg_names": [], "import_names": [], "rhs_call_name": "StringIO", "annotation": ""}, "snippet": " chunk_buffer = StringIO(chunk)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98904:For_L89_C12", "label": "for line", "type": "for", "loc": [89, 99], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98904:For_L86_C8", "vector": [6, 3, 0.7015, 0.0821, 3, 0.6, 1.0, 373, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "line", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " for line in chunk_buffer:\n if buffer_:\n line = buffer_ + line\n buffer_ = None\n\n # If this is the end of a line, yield\n # otherwise, wait for the next round\n if line[-1] in ('\\n', '\\r'):"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98904:If_L90_C16", "label": "if", "type": "if", "loc": [90, 92], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98904:For_L89_C12", "vector": [4, 4, 0.6791, 0.0224, 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 buffer_:\n line = buffer_ + line\n buffer_ = None"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98904:Assign_L91_C20", "label": "line =", "type": "assigned_variable", "loc": [91, 91], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98904:If_L90_C16", "vector": [14, 5, 0.6791, 0.0075, 5, 0.92, 0.0, 373, 4, 0, 0, 0, 0, 0, 0], "semantic": {"name": "line", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " line = buffer_ + line"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98904:Assign_L92_C20", "label": "buffer_ =", "type": "assigned_variable", "loc": [92, 92], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98904:If_L90_C16", "vector": [14, 5, 0.6866, 0.0075, 5, 0.92, 1.0, 850, 1, 0, 0, 0, 0, 9, 0], "semantic": {"name": "buffer_", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " buffer_ = None"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98904:If_L96_C16", "label": "if", "type": "if", "loc": [96, 99], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98904:For_L89_C12", "vector": [4, 4, 0.7276, 0.0299, 4, 0.54, 1.0, 0, 0, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if line[-1] in ('\\n', '\\r'):\n yield line\n else:\n buffer_ = line"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98904:Expr_L97_C20", "label": "expression", "type": "expression", "loc": [97, 97], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98904:If_L96_C16", "vector": [8, 5, 0.7239, 0.0075, 5, 0.13, 0.0, 0, 0, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " yield line"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98904:Assign_L99_C20", "label": "buffer_ =", "type": "assigned_variable", "loc": [99, 99], "level": 5, "parent": "ajibawa-2023/Python-Code-Large/train/row_98904:If_L96_C16", "vector": [14, 5, 0.7388, 0.0075, 5, 0.13, 1.0, 850, 2, 0, 0, 0, 0, 0, 0], "semantic": {"name": "buffer_", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " buffer_ = line"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98904:If_L101_C8", "label": "if", "type": "if", "loc": [101, 102], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98904:FunctionDef_L83_C4", "vector": [4, 2, 0.7575, 0.0149, 2, 0.56, 1.0, 0, 0, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if buffer_ is not None:\n yield buffer_"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98904:Expr_L102_C12", "label": "expression", "type": "expression", "loc": [102, 102], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98904:If_L101_C8", "vector": [8, 3, 0.7612, 0.0075, 3, 0.78, 0.0, 0, 0, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " yield buffer_"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98904:FunctionDef_L104_C4", "label": "open", "type": "function", "loc": [104, 110], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98904:ClassDef_L10_C0", "vector": [2, 1, 0.7985, 0.0522, 1, 0.4, 0.9375, 693, 0, 2, 0, 0, 0, 0, 4], "semantic": {"name": "open", "arg_names": ["self", "mode"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def open(self, mode=None):\n if not self.closed:\n self.seek(0)\n elif self.name and os.path.exists(self.name):\n self.file = open(self.name, mode or self.mode)\n else:\n raise ValueError(\"The file cannot be reopened.\")"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98904:If_L105_C8", "label": "if", "type": "if", "loc": [105, 110], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98904:FunctionDef_L104_C4", "vector": [4, 2, 0.8022, 0.0448, 2, 0.75, 0.0, 0, 0, 0, 0, 0, 0, 0, 4], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if not self.closed:\n self.seek(0)\n elif self.name and os.path.exists(self.name):\n self.file = open(self.name, mode or self.mode)\n else:\n raise ValueError(\"The file cannot be reopened.\")"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98904:Expr_L106_C12", "label": "seek()", "type": "expression", "loc": [106, 106], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98904:If_L105_C8", "vector": [8, 3, 0.791, 0.0075, 3, 0.26, 0.0, 66, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "seek", "arg_names": [], "import_names": [], "rhs_call_name": "seek", "annotation": ""}, "snippet": " self.seek(0)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98904:If_L107_C8", "label": "if", "type": "if", "loc": [107, 110], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98904:If_L105_C8", "vector": [4, 3, 0.8097, 0.0299, 3, 0.26, 1.0, 0, 0, 0, 0, 0, 0, 0, 3], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " elif self.name and os.path.exists(self.name):\n self.file = open(self.name, mode or self.mode)\n else:\n raise ValueError(\"The file cannot be reopened.\")"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98904:Assign_L108_C12", "label": "self.file = open()", "type": "assigned_variable", "loc": [108, 108], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98904:If_L107_C8", "vector": [14, 4, 0.806, 0.0075, 4, 0.8, 0.0, 678, 3, 2, 0, 0, 693, 10, 1], "semantic": {"name": "self.file", "arg_names": [], "import_names": [], "rhs_call_name": "open", "annotation": ""}, "snippet": " self.file = open(self.name, mode or self.mode)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98904:FunctionDef_L112_C4", "label": "close", "type": "function", "loc": [112, 113], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98904:ClassDef_L10_C0", "vector": [2, 1, 0.8396, 0.0149, 1, 0.4, 1.0, 77, 0, 1, 0, 0, 0, 0, 1], "semantic": {"name": "close", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def close(self):\n self.file.close()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98904:Expr_L113_C8", "label": "close()", "type": "expression", "loc": [113, 113], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98904:FunctionDef_L112_C4", "vector": [8, 2, 0.8433, 0.0075, 2, 0.35, 0.0, 77, 3, 0, 0, 0, 0, 0, 1], "semantic": {"name": "close", "arg_names": [], "import_names": [], "rhs_call_name": "close", "annotation": ""}, "snippet": " self.file.close()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98904:ClassDef_L115_C0", "label": "ContentFile", "type": "class", "loc": [115, 134], "level": 0, "parent": null, "vector": [3, 0, 0.9291, 0.1493, 0, 0.66, 1.0, 111, 0, 5, 0, 0, 491, 0, 5], "semantic": {"name": "ContentFile", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "class ContentFile(File):\n \"\"\"\n A File-like object that takes just raw content, rather than an actual file.\n \"\"\"\n def __init__(self, content):\n content = content or ''\n super(ContentFile, self).__init__(StringIO(content))\n self.size = len(content)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98904:Expr_L116_C4", "label": "expression", "type": "expression", "loc": [116, 118], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98904:ClassDef_L115_C0", "vector": [8, 1, 0.8731, 0.0224, 1, 0.57, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"\n A File-like object that takes just raw content, rather than an actual file.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98904:FunctionDef_L119_C4", "label": "__init__", "type": "function", "loc": [119, 122], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98904:ClassDef_L115_C0", "vector": [2, 1, 0.8993, 0.0299, 1, 0.57, 0.2, 555, 0, 2, 0, 0, 0, 0, 4], "semantic": {"name": "__init__", "arg_names": ["self", "content"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def __init__(self, content):\n content = content or ''\n super(ContentFile, self).__init__(StringIO(content))\n self.size = len(content)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98904:Assign_L120_C8", "label": "content =", "type": "assigned_variable", "loc": [120, 120], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98904:FunctionDef_L119_C4", "vector": [14, 2, 0.8955, 0.0075, 2, 0.18, 0.0, 273, 0, 0, 0, 0, 0, 0, 0], "semantic": {"name": "content", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " content = content or ''"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98904:Expr_L121_C8", "label": "__init__()", "type": "expression", "loc": [121, 121], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98904:FunctionDef_L119_C4", "vector": [8, 2, 0.903, 0.0075, 2, 0.18, 0.5, 555, 3, 1, 0, 0, 0, 0, 3], "semantic": {"name": "__init__", "arg_names": [], "import_names": [], "rhs_call_name": "__init__", "annotation": ""}, "snippet": " super(ContentFile, self).__init__(StringIO(content))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98904:Assign_L122_C8", "label": "self.size = len()", "type": "assigned_variable", "loc": [122, 122], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98904:FunctionDef_L119_C4", "vector": [14, 2, 0.9104, 0.0075, 2, 0.18, 1.0, 183, 3, 1, 0, 0, 890, 10, 1], "semantic": {"name": "self.size", "arg_names": [], "import_names": [], "rhs_call_name": "len", "annotation": ""}, "snippet": " self.size = len(content)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98904:FunctionDef_L124_C4", "label": "__str__", "type": "function", "loc": [124, 125], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98904:ClassDef_L115_C0", "vector": [2, 1, 0.9291, 0.0149, 1, 0.57, 0.4, 527, 0, 1, 1, 0, 0, 0, 0], "semantic": {"name": "__str__", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def __str__(self):\n return 'Raw content'"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98904:Return_L125_C8", "label": "return", "type": "return", "loc": [125, 125], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98904:FunctionDef_L124_C4", "vector": [13, 2, 0.9328, 0.0075, 2, 0.93, 0.0, 0, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return 'Raw content'"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98904:FunctionDef_L127_C4", "label": "__nonzero__", "type": "function", "loc": [127, 128], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98904:ClassDef_L115_C0", "vector": [2, 1, 0.9515, 0.0149, 1, 0.57, 0.6, 322, 0, 1, 1, 0, 0, 0, 0], "semantic": {"name": "__nonzero__", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def __nonzero__(self):\n return True"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98904:Return_L128_C8", "label": "return", "type": "return", "loc": [128, 128], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98904:FunctionDef_L127_C4", "vector": [13, 2, 0.9552, 0.0075, 2, 0.38, 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_98904:FunctionDef_L130_C4", "label": "open", "type": "function", "loc": [130, 131], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98904:ClassDef_L115_C0", "vector": [2, 1, 0.9739, 0.0149, 1, 0.57, 0.8, 693, 0, 2, 0, 0, 0, 0, 1], "semantic": {"name": "open", "arg_names": ["self", "mode"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def open(self, mode=None):\n self.seek(0)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98904:Expr_L131_C8", "label": "seek()", "type": "expression", "loc": [131, 131], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98904:FunctionDef_L130_C4", "vector": [8, 2, 0.9776, 0.0075, 2, 0.25, 0.0, 66, 3, 1, 0, 0, 0, 0, 1], "semantic": {"name": "seek", "arg_names": [], "import_names": [], "rhs_call_name": "seek", "annotation": ""}, "snippet": " self.seek(0)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98904:FunctionDef_L133_C4", "label": "close", "type": "function", "loc": [133, 134], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98904:ClassDef_L115_C0", "vector": [2, 1, 0.9963, 0.0149, 1, 0.57, 1.0, 77, 0, 1, 0, 0, 0, 0, 0], "semantic": {"name": "close", "arg_names": ["self"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def close(self):\n pass"}]
[{"f": "ajibawa-2023/Python-Code-Large/train/row_98904:Try_L2_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98904:ImportFrom_L3_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98904:Try_L2_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98904:ImportFrom_L5_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98904:ClassDef_L10_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98904:Assign_L11_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98904:ClassDef_L10_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98904:FunctionDef_L13_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98904:FunctionDef_L13_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98904:Assign_L14_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98904:FunctionDef_L13_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98904:If_L15_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98904:If_L15_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98904:Assign_L16_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98904:FunctionDef_L13_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98904:Assign_L17_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98904:FunctionDef_L13_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98904:Assign_L18_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98904:ClassDef_L10_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98904:FunctionDef_L20_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98904:FunctionDef_L20_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98904:Return_L21_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98904:ClassDef_L10_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98904:FunctionDef_L23_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98904:FunctionDef_L23_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98904:Return_L24_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98904:ClassDef_L10_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98904:FunctionDef_L26_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98904:FunctionDef_L26_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98904:Return_L27_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98904:ClassDef_L10_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98904:FunctionDef_L29_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98904:FunctionDef_L29_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98904:Return_L30_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98904:ClassDef_L10_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98904:FunctionDef_L32_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98904:FunctionDef_L32_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98904:Return_L33_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98904:ClassDef_L10_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98904:FunctionDef_L35_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98904:FunctionDef_L35_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98904:If_L36_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98904:If_L36_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98904:If_L37_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98904:If_L37_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98904:Assign_L38_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98904:If_L37_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98904:If_L39_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98904:If_L39_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98904:Assign_L40_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98904:FunctionDef_L35_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98904:Return_L43_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98904:ClassDef_L10_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98904:FunctionDef_L45_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98904:FunctionDef_L45_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98904:Assign_L46_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98904:ClassDef_L10_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98904:Assign_L48_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98904:ClassDef_L10_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98904:FunctionDef_L50_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98904:FunctionDef_L50_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98904:Return_L51_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98904:ClassDef_L10_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98904:Assign_L52_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98904:ClassDef_L10_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98904:FunctionDef_L54_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98904:FunctionDef_L54_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98904:Expr_L55_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98904:FunctionDef_L54_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98904:If_L59_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98904:If_L59_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98904:Assign_L60_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98904:FunctionDef_L54_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98904:If_L62_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98904:If_L62_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98904:Expr_L63_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98904:FunctionDef_L54_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98904:Assign_L65_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98904:FunctionDef_L54_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98904:While_L67_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98904:While_L67_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98904:Expr_L68_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98904:ClassDef_L10_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98904:FunctionDef_L71_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98904:FunctionDef_L71_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98904:Expr_L72_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98904:FunctionDef_L71_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98904:If_L79_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98904:If_L79_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98904:Assign_L80_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98904:FunctionDef_L71_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98904:Return_L81_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98904:ClassDef_L10_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98904:FunctionDef_L83_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98904:FunctionDef_L83_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98904:Assign_L85_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98904:FunctionDef_L83_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98904:For_L86_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98904:For_L86_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98904:Assign_L87_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98904:For_L86_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98904:For_L89_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98904:For_L89_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98904:If_L90_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98904:If_L90_C16", "t": "ajibawa-2023/Python-Code-Large/train/row_98904:Assign_L91_C20"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98904:If_L90_C16", "t": "ajibawa-2023/Python-Code-Large/train/row_98904:Assign_L92_C20"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98904:For_L89_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98904:If_L96_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98904:If_L96_C16", "t": "ajibawa-2023/Python-Code-Large/train/row_98904:Expr_L97_C20"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98904:If_L96_C16", "t": "ajibawa-2023/Python-Code-Large/train/row_98904:Assign_L99_C20"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98904:FunctionDef_L83_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98904:If_L101_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98904:If_L101_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98904:Expr_L102_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98904:ClassDef_L10_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98904:FunctionDef_L104_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98904:FunctionDef_L104_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98904:If_L105_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98904:If_L105_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98904:Expr_L106_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98904:If_L105_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98904:If_L107_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98904:If_L107_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98904:Assign_L108_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98904:ClassDef_L10_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98904:FunctionDef_L112_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98904:FunctionDef_L112_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98904:Expr_L113_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98904:ClassDef_L115_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98904:Expr_L116_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98904:ClassDef_L115_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98904:FunctionDef_L119_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98904:FunctionDef_L119_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98904:Assign_L120_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98904:FunctionDef_L119_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98904:Expr_L121_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98904:FunctionDef_L119_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98904:Assign_L122_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98904:ClassDef_L115_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98904:FunctionDef_L124_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98904:FunctionDef_L124_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98904:Return_L125_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98904:ClassDef_L115_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98904:FunctionDef_L127_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98904:FunctionDef_L127_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98904:Return_L128_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98904:ClassDef_L115_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98904:FunctionDef_L130_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98904:FunctionDef_L130_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98904:Expr_L131_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98904:ClassDef_L115_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98904:FunctionDef_L133_C4"}]
from django.core.files.base import File
ajibawa-2023/Python-Code-Large/train/row_98905
1
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"]
[{"id": "ajibawa-2023/Python-Code-Large/train/row_98905:ImportFrom_L1_C0", "label": "from django.core.files.base import File", "type": "import", "loc": [1, 1], "level": 0, "parent": null, "vector": [1, 0, 1.0, 1.0, 0, 0.66, 0.0, 293, 0, 1, 0, 0, 293, 0, 0], "semantic": {"name": "django.core.files.base", "arg_names": [], "import_names": ["File"], "rhs_call_name": "", "annotation": ""}, "snippet": "from django.core.files.base import File"}]
[]
""" Portable file locking utilities. Based partially on example by Jonathan Feignberg <jdf@pobox.com> in the Python Cookbook, licensed under the Python Software License. http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/65203 Example Usage:: >>> from django.core.files import locks >>> f = open('./file', 'wb') >>> locks.lock(f, locks.LOCK_EX) >>> f.write('Django') >>> f.close() """ __all__ = ('LOCK_EX','LOCK_SH','LOCK_NB','lock','unlock') system_type = None try: import win32con import win32file import pywintypes LOCK_EX = win32con.LOCKFILE_EXCLUSIVE_LOCK LOCK_SH = 0 LOCK_NB = win32con.LOCKFILE_FAIL_IMMEDIATELY __overlapped = pywintypes.OVERLAPPED() system_type = 'nt' except (ImportError, AttributeError): pass try: import fcntl LOCK_EX = fcntl.LOCK_EX LOCK_SH = fcntl.LOCK_SH LOCK_NB = fcntl.LOCK_NB system_type = 'posix' except (ImportError, AttributeError): pass def fd(f): """Get a filedescriptor from something which could be a file or an fd.""" return hasattr(f, 'fileno') and f.fileno() or f if system_type == 'nt': def lock(file, flags): hfile = win32file._get_osfhandle(fd(file)) win32file.LockFileEx(hfile, flags, 0, -0x10000, __overlapped) def unlock(file): hfile = win32file._get_osfhandle(fd(file)) win32file.UnlockFileEx(hfile, 0, -0x10000, __overlapped) elif system_type == 'posix': def lock(file, flags): fcntl.lockf(fd(file), flags) def unlock(file): fcntl.lockf(fd(file), fcntl.LOCK_UN) else: # File locking is not supported. LOCK_EX = LOCK_SH = LOCK_NB = None # Dummy functions that don't do anything. def lock(file, flags): pass def unlock(file): pass
ajibawa-2023/Python-Code-Large/train/row_98906
36
70
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_98906:Expr_L1_C0", "label": "expression", "type": "expression", "loc": [1, 16], "level": 0, "parent": null, "vector": [8, 0, 0.1214, 0.2286, 0, 0.66, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "\"\"\"\nPortable file locking utilities.\n\nBased partially on example by Jonathan Feignberg <jdf@pobox.com> in the Python\nCookbook, licensed under the Python Software License.\n\n http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/65203\n"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98906:Assign_L18_C0", "label": "__all__ =", "type": "assigned_variable", "loc": [18, 18], "level": 0, "parent": null, "vector": [14, 0, 0.2571, 0.0143, 0, 0.66, 0.1667, 272, 0, 0, 0, 0, 0, 8, 0], "semantic": {"name": "__all__", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "__all__ = ('LOCK_EX','LOCK_SH','LOCK_NB','lock','unlock')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98906:Assign_L20_C0", "label": "system_type =", "type": "assigned_variable", "loc": [20, 20], "level": 0, "parent": null, "vector": [14, 0, 0.2857, 0.0143, 0, 0.66, 0.3333, 362, 1, 0, 0, 0, 0, 9, 0], "semantic": {"name": "system_type", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "system_type = None"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98906:Try_L22_C0", "label": "try", "type": "try", "loc": [22, 32], "level": 0, "parent": null, "vector": [7, 0, 0.3857, 0.1571, 0, 0.66, 0.5, 0, 0, 1, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "try:\n import win32con\n import win32file\n import pywintypes\n LOCK_EX = win32con.LOCKFILE_EXCLUSIVE_LOCK\n LOCK_SH = 0\n LOCK_NB = win32con.LOCKFILE_FAIL_IMMEDIATELY\n __overlapped = pywintypes.OVERLAPPED()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98906:Import_L23_C4", "label": "win32con import win32con", "type": "import", "loc": [23, 23], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98906:Try_L22_C0", "vector": [1, 1, 0.3286, 0.0143, 1, 0.02, 0.0, 507, 0, 1, 0, 0, 507, 0, 0], "semantic": {"name": "win32con", "arg_names": [], "import_names": ["win32con"], "rhs_call_name": "", "annotation": ""}, "snippet": " import win32con"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98906:Import_L24_C4", "label": "win32file import win32file", "type": "import", "loc": [24, 24], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98906:Try_L22_C0", "vector": [1, 1, 0.3429, 0.0143, 1, 0.02, 0.1429, 815, 0, 1, 0, 0, 815, 0, 0], "semantic": {"name": "win32file", "arg_names": [], "import_names": ["win32file"], "rhs_call_name": "", "annotation": ""}, "snippet": " import win32file"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98906:Import_L25_C4", "label": "pywintypes import pywintypes", "type": "import", "loc": [25, 25], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98906:Try_L22_C0", "vector": [1, 1, 0.3571, 0.0143, 1, 0.02, 0.2857, 491, 0, 1, 0, 0, 491, 0, 0], "semantic": {"name": "pywintypes", "arg_names": [], "import_names": ["pywintypes"], "rhs_call_name": "", "annotation": ""}, "snippet": " import pywintypes"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98906:Assign_L26_C4", "label": "LOCK_EX =", "type": "assigned_variable", "loc": [26, 26], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98906:Try_L22_C0", "vector": [14, 1, 0.3714, 0.0143, 1, 0.02, 0.4286, 814, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "LOCK_EX", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " LOCK_EX = win32con.LOCKFILE_EXCLUSIVE_LOCK"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98906:Assign_L27_C4", "label": "LOCK_SH =", "type": "assigned_variable", "loc": [27, 27], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98906:Try_L22_C0", "vector": [14, 1, 0.3857, 0.0143, 1, 0.02, 0.5714, 980, 1, 0, 0, 0, 0, 1, 0], "semantic": {"name": "LOCK_SH", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " LOCK_SH = 0"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98906:Assign_L28_C4", "label": "LOCK_NB =", "type": "assigned_variable", "loc": [28, 28], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98906:Try_L22_C0", "vector": [14, 1, 0.4, 0.0143, 1, 0.02, 0.7143, 680, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "LOCK_NB", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " LOCK_NB = win32con.LOCKFILE_FAIL_IMMEDIATELY"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98906:Assign_L29_C4", "label": "__overlapped = OVERLAPPED()", "type": "assigned_variable", "loc": [29, 29], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98906:Try_L22_C0", "vector": [14, 1, 0.4143, 0.0143, 1, 0.02, 0.8571, 208, 3, 0, 0, 0, 678, 10, 1], "semantic": {"name": "__overlapped", "arg_names": [], "import_names": [], "rhs_call_name": "OVERLAPPED", "annotation": ""}, "snippet": " __overlapped = pywintypes.OVERLAPPED()"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98906:Assign_L30_C4", "label": "system_type =", "type": "assigned_variable", "loc": [30, 30], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98906:Try_L22_C0", "vector": [14, 1, 0.4286, 0.0143, 1, 0.02, 1.0, 362, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "system_type", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " system_type = 'nt'"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98906:Try_L34_C0", "label": "try", "type": "try", "loc": [34, 41], "level": 0, "parent": null, "vector": [7, 0, 0.5357, 0.1143, 0, 0.66, 0.6667, 0, 0, 1, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "try:\n import fcntl\n LOCK_EX = fcntl.LOCK_EX\n LOCK_SH = fcntl.LOCK_SH\n LOCK_NB = fcntl.LOCK_NB\n system_type = 'posix'\nexcept (ImportError, AttributeError):\n pass"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98906:Import_L35_C4", "label": "fcntl import fcntl", "type": "import", "loc": [35, 35], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98906:Try_L34_C0", "vector": [1, 1, 0.5, 0.0143, 1, 0.65, 0.0, 488, 0, 1, 0, 0, 488, 0, 0], "semantic": {"name": "fcntl", "arg_names": [], "import_names": ["fcntl"], "rhs_call_name": "", "annotation": ""}, "snippet": " import fcntl"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98906:Assign_L36_C4", "label": "LOCK_EX =", "type": "assigned_variable", "loc": [36, 36], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98906:Try_L34_C0", "vector": [14, 1, 0.5143, 0.0143, 1, 0.65, 0.25, 814, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "LOCK_EX", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " LOCK_EX = fcntl.LOCK_EX"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98906:Assign_L37_C4", "label": "LOCK_SH =", "type": "assigned_variable", "loc": [37, 37], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98906:Try_L34_C0", "vector": [14, 1, 0.5286, 0.0143, 1, 0.65, 0.5, 980, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "LOCK_SH", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " LOCK_SH = fcntl.LOCK_SH"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98906:Assign_L38_C4", "label": "LOCK_NB =", "type": "assigned_variable", "loc": [38, 38], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98906:Try_L34_C0", "vector": [14, 1, 0.5429, 0.0143, 1, 0.65, 0.75, 680, 7, 0, 0, 0, 0, 0, 0], "semantic": {"name": "LOCK_NB", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " LOCK_NB = fcntl.LOCK_NB"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98906:Assign_L39_C4", "label": "system_type =", "type": "assigned_variable", "loc": [39, 39], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98906:Try_L34_C0", "vector": [14, 1, 0.5571, 0.0143, 1, 0.65, 1.0, 362, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "system_type", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " system_type = 'posix'"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98906:FunctionDef_L43_C0", "label": "fd", "type": "function", "loc": [43, 45], "level": 0, "parent": null, "vector": [2, 0, 0.6286, 0.0429, 0, 0.66, 0.8333, 863, 0, 1, 1, 0, 0, 0, 2], "semantic": {"name": "fd", "arg_names": ["f"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "def fd(f):\n \"\"\"Get a filedescriptor from something which could be a file or an fd.\"\"\"\n return hasattr(f, 'fileno') and f.fileno() or f"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98906:Expr_L44_C4", "label": "expression", "type": "expression", "loc": [44, 44], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98906:FunctionDef_L43_C0", "vector": [8, 1, 0.6286, 0.0143, 1, 0.89, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"Get a filedescriptor from something which could be a file or an fd.\"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98906:Return_L45_C4", "label": "return", "type": "return", "loc": [45, 45], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98906:FunctionDef_L43_C0", "vector": [13, 1, 0.6429, 0.0143, 1, 0.89, 1.0, 0, 0, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " return hasattr(f, 'fileno') and f.fileno() or f"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98906:If_L47_C0", "label": "if", "type": "if", "loc": [47, 70], "level": 0, "parent": null, "vector": [4, 0, 0.8357, 0.3429, 0, 0.66, 1.0, 0, 0, 0, 0, 0, 0, 0, 10], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "if system_type == 'nt':\n def lock(file, flags):\n hfile = win32file._get_osfhandle(fd(file))\n win32file.LockFileEx(hfile, flags, 0, -0x10000, __overlapped)\n\n def unlock(file):\n hfile = win32file._get_osfhandle(fd(file))\n win32file.UnlockFileEx(hfile, 0, -0x10000, __overlapped)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98906:FunctionDef_L48_C4", "label": "lock", "type": "function", "loc": [48, 50], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98906:If_L47_C0", "vector": [2, 1, 0.7, 0.0429, 1, 0.78, 0.0, 104, 0, 2, 0, 0, 0, 0, 3], "semantic": {"name": "lock", "arg_names": ["file", "flags"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def lock(file, flags):\n hfile = win32file._get_osfhandle(fd(file))\n win32file.LockFileEx(hfile, flags, 0, -0x10000, __overlapped)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98906:Assign_L49_C8", "label": "hfile = _get_osfhandle()", "type": "assigned_variable", "loc": [49, 49], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98906:FunctionDef_L48_C4", "vector": [14, 2, 0.7, 0.0143, 2, 0.9, 0.0, 214, 3, 1, 0, 0, 190, 10, 2], "semantic": {"name": "hfile", "arg_names": [], "import_names": [], "rhs_call_name": "_get_osfhandle", "annotation": ""}, "snippet": " hfile = win32file._get_osfhandle(fd(file))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98906:Expr_L50_C8", "label": "LockFileEx()", "type": "expression", "loc": [50, 50], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98906:FunctionDef_L48_C4", "vector": [8, 2, 0.7143, 0.0143, 2, 0.9, 1.0, 13, 3, 5, 0, 0, 0, 0, 1], "semantic": {"name": "LockFileEx", "arg_names": [], "import_names": [], "rhs_call_name": "LockFileEx", "annotation": ""}, "snippet": " win32file.LockFileEx(hfile, flags, 0, -0x10000, __overlapped)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98906:FunctionDef_L52_C4", "label": "unlock", "type": "function", "loc": [52, 54], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98906:If_L47_C0", "vector": [2, 1, 0.7571, 0.0429, 1, 0.78, 0.5, 612, 0, 1, 0, 0, 0, 0, 3], "semantic": {"name": "unlock", "arg_names": ["file"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def unlock(file):\n hfile = win32file._get_osfhandle(fd(file))\n win32file.UnlockFileEx(hfile, 0, -0x10000, __overlapped)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98906:Assign_L53_C8", "label": "hfile = _get_osfhandle()", "type": "assigned_variable", "loc": [53, 53], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98906:FunctionDef_L52_C4", "vector": [14, 2, 0.7571, 0.0143, 2, 0.4, 0.0, 214, 3, 1, 0, 0, 190, 10, 2], "semantic": {"name": "hfile", "arg_names": [], "import_names": [], "rhs_call_name": "_get_osfhandle", "annotation": ""}, "snippet": " hfile = win32file._get_osfhandle(fd(file))"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98906:Expr_L54_C8", "label": "UnlockFileEx()", "type": "expression", "loc": [54, 54], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98906:FunctionDef_L52_C4", "vector": [8, 2, 0.7714, 0.0143, 2, 0.4, 1.0, 879, 3, 4, 0, 0, 0, 0, 1], "semantic": {"name": "UnlockFileEx", "arg_names": [], "import_names": [], "rhs_call_name": "UnlockFileEx", "annotation": ""}, "snippet": " win32file.UnlockFileEx(hfile, 0, -0x10000, __overlapped)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98906:If_L55_C0", "label": "if", "type": "if", "loc": [55, 70], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98906:If_L47_C0", "vector": [4, 1, 0.8929, 0.2286, 1, 0.78, 1.0, 0, 0, 0, 0, 0, 0, 0, 4], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "elif system_type == 'posix':\n def lock(file, flags):\n fcntl.lockf(fd(file), flags)\n\n def unlock(file):\n fcntl.lockf(fd(file), fcntl.LOCK_UN)\nelse:\n # File locking is not supported."}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98906:FunctionDef_L56_C4", "label": "lock", "type": "function", "loc": [56, 57], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98906:If_L55_C0", "vector": [2, 2, 0.8071, 0.0286, 2, 0.33, 0.0, 104, 0, 2, 0, 0, 0, 0, 2], "semantic": {"name": "lock", "arg_names": ["file", "flags"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def lock(file, flags):\n fcntl.lockf(fd(file), flags)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98906:Expr_L57_C8", "label": "lockf()", "type": "expression", "loc": [57, 57], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98906:FunctionDef_L56_C4", "vector": [8, 3, 0.8143, 0.0143, 3, 0.34, 0.0, 21, 3, 2, 0, 0, 0, 0, 2], "semantic": {"name": "lockf", "arg_names": [], "import_names": [], "rhs_call_name": "lockf", "annotation": ""}, "snippet": " fcntl.lockf(fd(file), flags)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98906:FunctionDef_L59_C4", "label": "unlock", "type": "function", "loc": [59, 60], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98906:If_L55_C0", "vector": [2, 2, 0.85, 0.0286, 2, 0.33, 0.25, 612, 0, 1, 0, 0, 0, 0, 2], "semantic": {"name": "unlock", "arg_names": ["file"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def unlock(file):\n fcntl.lockf(fd(file), fcntl.LOCK_UN)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98906:Expr_L60_C8", "label": "lockf()", "type": "expression", "loc": [60, 60], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98906:FunctionDef_L59_C4", "vector": [8, 3, 0.8571, 0.0143, 3, 0.46, 0.0, 21, 3, 2, 0, 0, 0, 0, 2], "semantic": {"name": "lockf", "arg_names": [], "import_names": [], "rhs_call_name": "lockf", "annotation": ""}, "snippet": " fcntl.lockf(fd(file), fcntl.LOCK_UN)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98906:Assign_L63_C4", "label": "LOCK_EX =", "type": "assigned_variable", "loc": [63, 63], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98906:If_L55_C0", "vector": [14, 2, 0.9, 0.0143, 2, 0.33, 0.5, 814, 1, 0, 0, 0, 0, 9, 0], "semantic": {"name": "LOCK_EX", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " LOCK_EX = LOCK_SH = LOCK_NB = None"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98906:FunctionDef_L66_C4", "label": "lock", "type": "function", "loc": [66, 67], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98906:If_L55_C0", "vector": [2, 2, 0.95, 0.0286, 2, 0.33, 0.75, 104, 0, 2, 0, 0, 0, 0, 0], "semantic": {"name": "lock", "arg_names": ["file", "flags"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def lock(file, flags):\n pass"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98906:FunctionDef_L69_C4", "label": "unlock", "type": "function", "loc": [69, 70], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98906:If_L55_C0", "vector": [2, 2, 0.9929, 0.0286, 2, 0.33, 1.0, 612, 0, 1, 0, 0, 0, 0, 0], "semantic": {"name": "unlock", "arg_names": ["file"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " def unlock(file):\n pass"}]
[{"f": "ajibawa-2023/Python-Code-Large/train/row_98906:Try_L22_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98906:Import_L23_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98906:Try_L22_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98906:Import_L24_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98906:Try_L22_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98906:Import_L25_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98906:Try_L22_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98906:Assign_L26_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98906:Try_L22_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98906:Assign_L27_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98906:Try_L22_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98906:Assign_L28_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98906:Try_L22_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98906:Assign_L29_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98906:Try_L22_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98906:Assign_L30_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98906:Try_L34_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98906:Import_L35_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98906:Try_L34_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98906:Assign_L36_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98906:Try_L34_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98906:Assign_L37_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98906:Try_L34_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98906:Assign_L38_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98906:Try_L34_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98906:Assign_L39_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98906:FunctionDef_L43_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98906:Expr_L44_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98906:FunctionDef_L43_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98906:Return_L45_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98906:If_L47_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98906:FunctionDef_L48_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98906:FunctionDef_L48_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98906:Assign_L49_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98906:FunctionDef_L48_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98906:Expr_L50_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98906:If_L47_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98906:FunctionDef_L52_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98906:FunctionDef_L52_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98906:Assign_L53_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98906:FunctionDef_L52_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98906:Expr_L54_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98906:If_L47_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98906:If_L55_C0"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98906:If_L55_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98906:FunctionDef_L56_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98906:FunctionDef_L56_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98906:Expr_L57_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98906:If_L55_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98906:FunctionDef_L59_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98906:FunctionDef_L59_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98906:Expr_L60_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98906:If_L55_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98906:Assign_L63_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98906:If_L55_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98906:FunctionDef_L66_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98906:If_L55_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98906:FunctionDef_L69_C4"}]
""" Functions that modify an HTTP request or response in some way. """ # This group of functions are run as part of the response handling, after # everything else, including all response middleware. Think of them as # "compulsory response middleware". Be careful about what goes here, because # it's a little fiddly to override this behavior, so they should be truly # universally applicable. def fix_location_header(request, response): """ Ensures that we always use an absolute URI in any location header in the response. This is required by RFC 2616, section 14.30. Code constructing response objects is free to insert relative paths, as this function converts them to absolute paths. """ if 'Location' in response and request.get_host(): response['Location'] = request.build_absolute_uri(response['Location']) return response def conditional_content_removal(request, response): """ Removes the content of responses for HEAD requests, 1xx, 204 and 304 responses. Ensures compliance with RFC 2616, section 4.3. """ if 100 <= response.status_code < 200 or response.status_code in (204, 304): response.content = '' response['Content-Length'] = 0 if request.method == 'HEAD': response.content = '' return response def fix_IE_for_attach(request, response): """ This function will prevent Django from serving a Content-Disposition header while expecting the browser to cache it (only when the browser is IE). This leads to IE not allowing the client to download. """ if 'MSIE' not in request.META.get('HTTP_USER_AGENT', '').upper(): return response offending_headers = ('no-cache', 'no-store') if response.has_header('Content-Disposition'): try: del response['Pragma'] except KeyError: pass if response.has_header('Cache-Control'): cache_control_values = [value.strip() for value in response['Cache-Control'].split(',') if value.strip().lower() not in offending_headers] if not len(cache_control_values): del response['Cache-Control'] else: response['Cache-Control'] = ', '.join(cache_control_values) return response def fix_IE_for_vary(request, response): """ This function will fix the bug reported at http://support.microsoft.com/kb/824847/en-us?spid=8722&sid=global by clearing the Vary header whenever the mime-type is not safe enough for Internet Explorer to handle. Poor thing. """ if 'MSIE' not in request.META.get('HTTP_USER_AGENT', '').upper(): return response # These mime-types that are decreed "Vary-safe" for IE: safe_mime_types = ('text/html', 'text/plain', 'text/sgml') # The first part of the Content-Type field will be the MIME type, # everything after ';', such as character-set, can be ignored. if response['Content-Type'].split(';')[0] not in safe_mime_types: try: del response['Vary'] except KeyError: pass return response
ajibawa-2023/Python-Code-Large/train/row_98908
34
84
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_98908:Expr_L1_C0", "label": "expression", "type": "expression", "loc": [1, 3], "level": 0, "parent": null, "vector": [8, 0, 0.0238, 0.0357, 0, 0.66, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "\"\"\"\nFunctions that modify an HTTP request or response in some way.\n\"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98908:FunctionDef_L11_C0", "label": "fix_location_header", "type": "function", "loc": [11, 21], "level": 0, "parent": null, "vector": [2, 0, 0.1905, 0.131, 0, 0.66, 0.25, 687, 0, 2, 1, 0, 0, 0, 2], "semantic": {"name": "fix_location_header", "arg_names": ["request", "response"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "def fix_location_header(request, response):\n \"\"\"\n Ensures that we always use an absolute URI in any location header in the\n response. This is required by RFC 2616, section 14.30.\n\n Code constructing response objects is free to insert relative paths, as\n this function converts them to absolute paths.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98908:Expr_L12_C4", "label": "expression", "type": "expression", "loc": [12, 18], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98908:FunctionDef_L11_C0", "vector": [8, 1, 0.1786, 0.0833, 1, 0.31, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"\n Ensures that we always use an absolute URI in any location header in the\n response. This is required by RFC 2616, section 14.30.\n\n Code constructing response objects is free to insert relative paths, as\n this function converts them to absolute paths.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98908:If_L19_C4", "label": "if", "type": "if", "loc": [19, 20], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98908:FunctionDef_L11_C0", "vector": [4, 1, 0.2321, 0.0238, 1, 0.31, 0.5, 0, 0, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if 'Location' in response and request.get_host():\n response['Location'] = request.build_absolute_uri(response['Location'])"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98908:Assign_L20_C8", "label": " = build_absolute_uri()", "type": "assigned_variable", "loc": [20, 20], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98908:If_L19_C4", "vector": [14, 2, 0.2381, 0.0119, 2, 0.33, 0.0, 0, 3, 1, 0, 0, 375, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "build_absolute_uri", "annotation": ""}, "snippet": " response['Location'] = request.build_absolute_uri(response['Location'])"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98908:Return_L21_C4", "label": "return", "type": "return", "loc": [21, 21], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98908:FunctionDef_L11_C0", "vector": [13, 1, 0.25, 0.0119, 1, 0.31, 1.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_98908:FunctionDef_L23_C0", "label": "conditional_content_removal", "type": "function", "loc": [23, 33], "level": 0, "parent": null, "vector": [2, 0, 0.3333, 0.131, 0, 0.66, 0.5, 679, 0, 2, 1, 0, 0, 0, 0], "semantic": {"name": "conditional_content_removal", "arg_names": ["request", "response"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "def conditional_content_removal(request, response):\n \"\"\"\n Removes the content of responses for HEAD requests, 1xx, 204 and 304\n responses. Ensures compliance with RFC 2616, section 4.3.\n \"\"\"\n if 100 <= response.status_code < 200 or response.status_code in (204, 304):\n response.content = ''\n response['Content-Length'] = 0"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98908:Expr_L24_C4", "label": "expression", "type": "expression", "loc": [24, 27], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98908:FunctionDef_L23_C0", "vector": [8, 1, 0.3036, 0.0476, 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 Removes the content of responses for HEAD requests, 1xx, 204 and 304\n responses. Ensures compliance with RFC 2616, section 4.3.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98908:If_L28_C4", "label": "if", "type": "if", "loc": [28, 30], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98908:FunctionDef_L23_C0", "vector": [4, 1, 0.3452, 0.0357, 1, 0.54, 0.3333, 0, 0, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if 100 <= response.status_code < 200 or response.status_code in (204, 304):\n response.content = ''\n response['Content-Length'] = 0"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98908:Assign_L29_C7", "label": "response.content =", "type": "assigned_variable", "loc": [29, 29], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98908:If_L28_C4", "vector": [14, 2, 0.3452, 0.0119, 2, 0.31, 0.0, 458, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "response.content", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " response.content = ''"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98908:Assign_L30_C7", "label": "assign", "type": "assigned_variable", "loc": [30, 30], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98908:If_L28_C4", "vector": [14, 2, 0.3571, 0.0119, 2, 0.31, 1.0, 0, 1, 0, 0, 0, 0, 1, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " response['Content-Length'] = 0"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98908:If_L31_C4", "label": "if", "type": "if", "loc": [31, 32], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98908:FunctionDef_L23_C0", "vector": [4, 1, 0.375, 0.0238, 1, 0.54, 0.6667, 0, 0, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if request.method == 'HEAD':\n response.content = ''"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98908:Assign_L32_C8", "label": "response.content =", "type": "assigned_variable", "loc": [32, 32], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98908:If_L31_C4", "vector": [14, 2, 0.381, 0.0119, 2, 0.94, 0.0, 458, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "response.content", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " response.content = ''"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98908:Return_L33_C4", "label": "return", "type": "return", "loc": [33, 33], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98908:FunctionDef_L23_C0", "vector": [13, 1, 0.3929, 0.0119, 1, 0.54, 1.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_98908:FunctionDef_L35_C0", "label": "fix_IE_for_attach", "type": "function", "loc": [35, 60], "level": 0, "parent": null, "vector": [2, 0, 0.5655, 0.3095, 0, 0.66, 0.75, 119, 0, 2, 1, 0, 0, 0, 10], "semantic": {"name": "fix_IE_for_attach", "arg_names": ["request", "response"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "def fix_IE_for_attach(request, response):\n \"\"\"\n This function will prevent Django from serving a Content-Disposition header\n while expecting the browser to cache it (only when the browser is IE). This\n leads to IE not allowing the client to download.\n \"\"\"\n if 'MSIE' not in request.META.get('HTTP_USER_AGENT', '').upper():\n return response"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98908:Expr_L36_C4", "label": "expression", "type": "expression", "loc": [36, 40], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98908:FunctionDef_L35_C0", "vector": [8, 1, 0.4524, 0.0595, 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 This function will prevent Django from serving a Content-Disposition header\n while expecting the browser to cache it (only when the browser is IE). This\n leads to IE not allowing the client to download.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98908:If_L41_C4", "label": "if", "type": "if", "loc": [41, 42], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98908:FunctionDef_L35_C0", "vector": [4, 1, 0.494, 0.0238, 1, 0.01, 0.25, 0, 0, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if 'MSIE' not in request.META.get('HTTP_USER_AGENT', '').upper():\n return response"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98908:Return_L42_C8", "label": "return", "type": "return", "loc": [42, 42], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98908:If_L41_C4", "vector": [13, 2, 0.5, 0.0119, 2, 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_98908:Assign_L44_C4", "label": "offending_headers =", "type": "assigned_variable", "loc": [44, 44], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98908:FunctionDef_L35_C0", "vector": [14, 1, 0.5238, 0.0119, 1, 0.01, 0.5, 929, 0, 0, 0, 0, 0, 8, 0], "semantic": {"name": "offending_headers", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " offending_headers = ('no-cache', 'no-store')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98908:If_L45_C4", "label": "if", "type": "if", "loc": [45, 58], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98908:FunctionDef_L35_C0", "vector": [4, 1, 0.6131, 0.1667, 1, 0.01, 0.75, 0, 3, 0, 0, 0, 0, 0, 8], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if response.has_header('Content-Disposition'):\n try:\n del response['Pragma']\n except KeyError:\n pass\n if response.has_header('Cache-Control'):\n cache_control_values = [value.strip() for value in\n response['Cache-Control'].split(',')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98908:Try_L46_C8", "label": "try", "type": "try", "loc": [46, 49], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98908:If_L45_C4", "vector": [7, 2, 0.5655, 0.0476, 2, 0.9, 0.0, 0, 0, 1, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " try:\n del response['Pragma']\n except KeyError:\n pass"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98908:If_L50_C8", "label": "if", "type": "if", "loc": [50, 58], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98908:If_L45_C4", "vector": [4, 2, 0.6429, 0.1071, 2, 0.9, 1.0, 0, 3, 0, 0, 0, 0, 0, 7], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if response.has_header('Cache-Control'):\n cache_control_values = [value.strip() for value in\n response['Cache-Control'].split(',')\n if value.strip().lower() not in offending_headers]\n\n if not len(cache_control_values):\n del response['Cache-Control']\n else:"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98908:Assign_L51_C12", "label": "cache_control_values =", "type": "assigned_variable", "loc": [51, 53], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98908:If_L50_C8", "vector": [14, 3, 0.619, 0.0357, 3, 0.57, 0.0, 306, 5, 0, 0, 0, 0, 0, 4], "semantic": {"name": "cache_control_values", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " cache_control_values = [value.strip() for value in\n response['Cache-Control'].split(',')\n if value.strip().lower() not in offending_headers]"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98908:If_L55_C12", "label": "if", "type": "if", "loc": [55, 58], "level": 3, "parent": "ajibawa-2023/Python-Code-Large/train/row_98908:If_L50_C8", "vector": [4, 3, 0.6726, 0.0476, 3, 0.57, 1.0, 0, 0, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if not len(cache_control_values):\n del response['Cache-Control']\n else:\n response['Cache-Control'] = ', '.join(cache_control_values)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98908:Assign_L58_C16", "label": " = join()", "type": "assigned_variable", "loc": [58, 58], "level": 4, "parent": "ajibawa-2023/Python-Code-Large/train/row_98908:If_L55_C12", "vector": [14, 4, 0.6905, 0.0119, 4, 0.41, 0.0, 0, 3, 1, 0, 0, 933, 10, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "join", "annotation": ""}, "snippet": " response['Cache-Control'] = ', '.join(cache_control_values)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98908:Return_L60_C4", "label": "return", "type": "return", "loc": [60, 60], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98908:FunctionDef_L35_C0", "vector": [13, 1, 0.7143, 0.0119, 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 response"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98908:FunctionDef_L62_C0", "label": "fix_IE_for_vary", "type": "function", "loc": [62, 83], "level": 0, "parent": null, "vector": [2, 0, 0.8631, 0.2619, 0, 0.66, 1.0, 520, 0, 2, 1, 0, 0, 0, 3], "semantic": {"name": "fix_IE_for_vary", "arg_names": ["request", "response"], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "def fix_IE_for_vary(request, response):\n \"\"\"\n This function will fix the bug reported at\n http://support.microsoft.com/kb/824847/en-us?spid=8722&sid=global\n by clearing the Vary header whenever the mime-type is not safe\n enough for Internet Explorer to handle. Poor thing.\n \"\"\"\n if 'MSIE' not in request.META.get('HTTP_USER_AGENT', '').upper():"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98908:Expr_L63_C4", "label": "expression", "type": "expression", "loc": [63, 68], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98908:FunctionDef_L62_C0", "vector": [8, 1, 0.7798, 0.0714, 1, 0.26, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " \"\"\"\n This function will fix the bug reported at\n http://support.microsoft.com/kb/824847/en-us?spid=8722&sid=global\n by clearing the Vary header whenever the mime-type is not safe\n enough for Internet Explorer to handle. Poor thing.\n \"\"\""}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98908:If_L69_C4", "label": "if", "type": "if", "loc": [69, 70], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98908:FunctionDef_L62_C0", "vector": [4, 1, 0.8274, 0.0238, 1, 0.26, 0.25, 0, 0, 0, 0, 0, 0, 0, 2], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if 'MSIE' not in request.META.get('HTTP_USER_AGENT', '').upper():\n return response"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98908:Return_L70_C8", "label": "return", "type": "return", "loc": [70, 70], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98908:If_L69_C4", "vector": [13, 2, 0.8333, 0.0119, 2, 0.25, 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_98908:Assign_L73_C4", "label": "safe_mime_types =", "type": "assigned_variable", "loc": [73, 73], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98908:FunctionDef_L62_C0", "vector": [14, 1, 0.869, 0.0119, 1, 0.26, 0.5, 958, 0, 0, 0, 0, 0, 8, 0], "semantic": {"name": "safe_mime_types", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " safe_mime_types = ('text/html', 'text/plain', 'text/sgml')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98908:If_L77_C4", "label": "if", "type": "if", "loc": [77, 81], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98908:FunctionDef_L62_C0", "vector": [4, 1, 0.9405, 0.0595, 1, 0.26, 0.75, 0, 0, 0, 0, 0, 0, 0, 1], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " if response['Content-Type'].split(';')[0] not in safe_mime_types:\n try:\n del response['Vary']\n except KeyError:\n pass"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98908:Try_L78_C8", "label": "try", "type": "try", "loc": [78, 81], "level": 2, "parent": "ajibawa-2023/Python-Code-Large/train/row_98908:If_L77_C4", "vector": [7, 2, 0.9464, 0.0476, 2, 0.48, 0.0, 0, 0, 1, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": " try:\n del response['Vary']\n except KeyError:\n pass"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98908:Return_L83_C4", "label": "return", "type": "return", "loc": [83, 83], "level": 1, "parent": "ajibawa-2023/Python-Code-Large/train/row_98908:FunctionDef_L62_C0", "vector": [13, 1, 0.9881, 0.0119, 1, 0.26, 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_98908:FunctionDef_L11_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98908:Expr_L12_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98908:FunctionDef_L11_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98908:If_L19_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98908:If_L19_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98908:Assign_L20_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98908:FunctionDef_L11_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98908:Return_L21_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98908:FunctionDef_L23_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98908:Expr_L24_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98908:FunctionDef_L23_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98908:If_L28_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98908:If_L28_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98908:Assign_L29_C7"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98908:If_L28_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98908:Assign_L30_C7"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98908:FunctionDef_L23_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98908:If_L31_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98908:If_L31_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98908:Assign_L32_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98908:FunctionDef_L23_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98908:Return_L33_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98908:FunctionDef_L35_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98908:Expr_L36_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98908:FunctionDef_L35_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98908:If_L41_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98908:If_L41_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98908:Return_L42_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98908:FunctionDef_L35_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98908:Assign_L44_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98908:FunctionDef_L35_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98908:If_L45_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98908:If_L45_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98908:Try_L46_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98908:If_L45_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98908:If_L50_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98908:If_L50_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98908:Assign_L51_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98908:If_L50_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_98908:If_L55_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98908:If_L55_C12", "t": "ajibawa-2023/Python-Code-Large/train/row_98908:Assign_L58_C16"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98908:FunctionDef_L35_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98908:Return_L60_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98908:FunctionDef_L62_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98908:Expr_L63_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98908:FunctionDef_L62_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98908:If_L69_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98908:If_L69_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98908:Return_L70_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98908:FunctionDef_L62_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98908:Assign_L73_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98908:FunctionDef_L62_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98908:If_L77_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98908:If_L77_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_98908:Try_L78_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_98908:FunctionDef_L62_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_98908:Return_L83_C4"}]
# -*- encoding: utf-8 -*- # This file is distributed under the same license as the Django package. # DATE_FORMAT = 'Y. F j.' TIME_FORMAT = 'G:i:s' # DATETIME_FORMAT = # YEAR_MONTH_FORMAT = MONTH_DAY_FORMAT = 'F j.' SHORT_DATE_FORMAT = 'Y.m.d.' # SHORT_DATETIME_FORMAT = # FIRST_DAY_OF_WEEK = # DATE_INPUT_FORMATS = # TIME_INPUT_FORMATS = # DATETIME_INPUT_FORMATS = DECIMAL_SEPARATOR = ',' THOUSAND_SEPARATOR = ' ' # NUMBER_GROUPING =
ajibawa-2023/Python-Code-Large/train/row_98910
6
18
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_98910:Assign_L5_C0", "label": "DATE_FORMAT =", "type": "assigned_variable", "loc": [5, 5], "level": 0, "parent": null, "vector": [14, 0, 0.2778, 0.0556, 0, 0.66, 0.0, 843, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "DATE_FORMAT", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "DATE_FORMAT = 'Y. F j.'"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98910:Assign_L6_C0", "label": "TIME_FORMAT =", "type": "assigned_variable", "loc": [6, 6], "level": 0, "parent": null, "vector": [14, 0, 0.3333, 0.0556, 0, 0.66, 0.2, 662, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "TIME_FORMAT", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "TIME_FORMAT = 'G:i:s'"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98910:Assign_L9_C0", "label": "MONTH_DAY_FORMAT =", "type": "assigned_variable", "loc": [9, 9], "level": 0, "parent": null, "vector": [14, 0, 0.5, 0.0556, 0, 0.66, 0.4, 609, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "MONTH_DAY_FORMAT", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "MONTH_DAY_FORMAT = 'F j.'"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98910:Assign_L10_C0", "label": "SHORT_DATE_FORMAT =", "type": "assigned_variable", "loc": [10, 10], "level": 0, "parent": null, "vector": [14, 0, 0.5556, 0.0556, 0, 0.66, 0.6, 881, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "SHORT_DATE_FORMAT", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "SHORT_DATE_FORMAT = 'Y.m.d.'"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98910:Assign_L16_C0", "label": "DECIMAL_SEPARATOR =", "type": "assigned_variable", "loc": [16, 16], "level": 0, "parent": null, "vector": [14, 0, 0.8889, 0.0556, 0, 0.66, 0.8, 357, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "DECIMAL_SEPARATOR", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "DECIMAL_SEPARATOR = ','"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98910:Assign_L17_C0", "label": "THOUSAND_SEPARATOR =", "type": "assigned_variable", "loc": [17, 17], "level": 0, "parent": null, "vector": [14, 0, 0.9444, 0.0556, 0, 0.66, 1.0, 316, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "THOUSAND_SEPARATOR", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "THOUSAND_SEPARATOR = '\u00a0'"}]
[]
# -*- encoding: utf-8 -*- # This file is distributed under the same license as the Django package. # DATE_FORMAT = 'j F Y' # '20 januari 2009' TIME_FORMAT = 'H:i' # '15:23' DATETIME_FORMAT = 'j F Y H:i' # '20 januari 2009 15:23' YEAR_MONTH_FORMAT = 'F Y' # 'januari 2009' MONTH_DAY_FORMAT = 'j F' # '20 januari' SHORT_DATE_FORMAT = 'j-n-Y' # '20-1-2009' SHORT_DATETIME_FORMAT = 'j-n-Y H:i' # '20-1-2009 15:23' FIRST_DAY_OF_WEEK = 1 # Monday (in Dutch 'maandag') DATE_INPUT_FORMATS = ( '%d-%m-%Y', '%d-%m-%y', '%Y-%m-%d', # '20-01-2009', '20-01-09', '2009-01-20' # '%d %b %Y', '%d %b %y', # '20 jan 2009', '20 jan 09' # '%d %B %Y', '%d %B %y', # '20 januari 2009', '20 januari 09' ) TIME_INPUT_FORMATS = ( '%H:%M:%S', # '15:23:35' '%H.%M:%S', # '15.23:35' '%H.%M', # '15.23' '%H:%M', # '15:23' ) DATETIME_INPUT_FORMATS = ( # With time in %H:%M:%S : '%d-%m-%Y %H:%M:%S', '%d-%m-%y %H:%M:%S', '%Y-%m-%d %H:%M:%S', # '20-01-2009 15:23:35', '20-01-09 15:23:35', '2009-01-20 15:23:35' # '%d %b %Y %H:%M:%S', '%d %b %y %H:%M:%S', # '20 jan 2009 15:23:35', '20 jan 09 15:23:35' # '%d %B %Y %H:%M:%S', '%d %B %y %H:%M:%S', # '20 januari 2009 15:23:35', '20 januari 2009 15:23:35' # With time in %H.%M:%S : '%d-%m-%Y %H.%M:%S', '%d-%m-%y %H.%M:%S', # '20-01-2009 15.23:35', '20-01-09 15.23:35' # '%d %b %Y %H.%M:%S', '%d %b %y %H.%M:%S', # '20 jan 2009 15.23:35', '20 jan 09 15.23:35' # '%d %B %Y %H.%M:%S', '%d %B %y %H.%M:%S', # '20 januari 2009 15.23:35', '20 januari 2009 15.23:35' # With time in %H:%M : '%d-%m-%Y %H:%M', '%d-%m-%y %H:%M', '%Y-%m-%d %H:%M', # '20-01-2009 15:23', '20-01-09 15:23', '2009-01-20 15:23' # '%d %b %Y %H:%M', '%d %b %y %H:%M', # '20 jan 2009 15:23', '20 jan 09 15:23' # '%d %B %Y %H:%M', '%d %B %y %H:%M', # '20 januari 2009 15:23', '20 januari 2009 15:23' # With time in %H.%M : '%d-%m-%Y %H.%M', '%d-%m-%y %H.%M', # '20-01-2009 15.23', '20-01-09 15.23' # '%d %b %Y %H.%M', '%d %b %y %H.%M', # '20 jan 2009 15.23', '20 jan 09 15.23' # '%d %B %Y %H.%M', '%d %B %y %H.%M', # '20 januari 2009 15.23', '20 januari 2009 15.23' # Without time : '%d-%m-%Y', '%d-%m-%y', '%Y-%m-%d', # '20-01-2009', '20-01-09', '2009-01-20' # '%d %b %Y', '%d %b %y', # '20 jan 2009', '20 jan 09' # '%d %B %Y', '%d %B %y', # '20 januari 2009', '20 januari 2009' ) DECIMAL_SEPARATOR = ',' THOUSAND_SEPARATOR = '.' NUMBER_GROUPING = 3
ajibawa-2023/Python-Code-Large/train/row_98911
14
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_98911:Assign_L5_C0", "label": "DATE_FORMAT =", "type": "assigned_variable", "loc": [5, 5], "level": 0, "parent": null, "vector": [14, 0, 0.1042, 0.0208, 0, 0.66, 0.0, 843, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "DATE_FORMAT", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "DATE_FORMAT = 'j F Y' # '20 januari 2009'"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98911:Assign_L6_C0", "label": "TIME_FORMAT =", "type": "assigned_variable", "loc": [6, 6], "level": 0, "parent": null, "vector": [14, 0, 0.125, 0.0208, 0, 0.66, 0.0769, 662, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "TIME_FORMAT", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "TIME_FORMAT = 'H:i' # '15:23'"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98911:Assign_L7_C0", "label": "DATETIME_FORMAT =", "type": "assigned_variable", "loc": [7, 7], "level": 0, "parent": null, "vector": [14, 0, 0.1458, 0.0208, 0, 0.66, 0.1538, 146, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "DATETIME_FORMAT", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "DATETIME_FORMAT = 'j F Y H:i' # '20 januari 2009 15:23'"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98911:Assign_L8_C0", "label": "YEAR_MONTH_FORMAT =", "type": "assigned_variable", "loc": [8, 8], "level": 0, "parent": null, "vector": [14, 0, 0.1667, 0.0208, 0, 0.66, 0.2308, 693, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "YEAR_MONTH_FORMAT", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "YEAR_MONTH_FORMAT = 'F Y' # 'januari 2009'"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98911:Assign_L9_C0", "label": "MONTH_DAY_FORMAT =", "type": "assigned_variable", "loc": [9, 9], "level": 0, "parent": null, "vector": [14, 0, 0.1875, 0.0208, 0, 0.66, 0.3077, 609, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "MONTH_DAY_FORMAT", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "MONTH_DAY_FORMAT = 'j F' # '20 januari'"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98911:Assign_L10_C0", "label": "SHORT_DATE_FORMAT =", "type": "assigned_variable", "loc": [10, 10], "level": 0, "parent": null, "vector": [14, 0, 0.2083, 0.0208, 0, 0.66, 0.3846, 881, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "SHORT_DATE_FORMAT", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "SHORT_DATE_FORMAT = 'j-n-Y' # '20-1-2009'"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98911:Assign_L11_C0", "label": "SHORT_DATETIME_FORMAT =", "type": "assigned_variable", "loc": [11, 11], "level": 0, "parent": null, "vector": [14, 0, 0.2292, 0.0208, 0, 0.66, 0.4615, 839, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "SHORT_DATETIME_FORMAT", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "SHORT_DATETIME_FORMAT = 'j-n-Y H:i' # '20-1-2009 15:23'"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98911:Assign_L12_C0", "label": "FIRST_DAY_OF_WEEK =", "type": "assigned_variable", "loc": [12, 12], "level": 0, "parent": null, "vector": [14, 0, 0.25, 0.0208, 0, 0.66, 0.5385, 317, 1, 0, 0, 0, 0, 1, 0], "semantic": {"name": "FIRST_DAY_OF_WEEK", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "FIRST_DAY_OF_WEEK = 1 # Monday (in Dutch 'maandag')"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98911:Assign_L13_C0", "label": "DATE_INPUT_FORMATS =", "type": "assigned_variable", "loc": [13, 17], "level": 0, "parent": null, "vector": [14, 0, 0.3125, 0.1042, 0, 0.66, 0.6154, 764, 0, 0, 0, 0, 0, 8, 0], "semantic": {"name": "DATE_INPUT_FORMATS", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "DATE_INPUT_FORMATS = (\n '%d-%m-%Y', '%d-%m-%y', '%Y-%m-%d', # '20-01-2009', '20-01-09', '2009-01-20'\n # '%d %b %Y', '%d %b %y', # '20 jan 2009', '20 jan 09'\n # '%d %B %Y', '%d %B %y', # '20 januari 2009', '20 januari 09'\n)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98911:Assign_L18_C0", "label": "TIME_INPUT_FORMATS =", "type": "assigned_variable", "loc": [18, 23], "level": 0, "parent": null, "vector": [14, 0, 0.4271, 0.125, 0, 0.66, 0.6923, 416, 0, 0, 0, 0, 0, 8, 0], "semantic": {"name": "TIME_INPUT_FORMATS", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "TIME_INPUT_FORMATS = (\n '%H:%M:%S', # '15:23:35'\n '%H.%M:%S', # '15.23:35'\n '%H.%M', # '15.23'\n '%H:%M', # '15:23'\n)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98911:Assign_L24_C0", "label": "DATETIME_INPUT_FORMATS =", "type": "assigned_variable", "loc": [24, 45], "level": 0, "parent": null, "vector": [14, 0, 0.7188, 0.4583, 0, 0.66, 0.7692, 531, 0, 0, 0, 0, 0, 8, 0], "semantic": {"name": "DATETIME_INPUT_FORMATS", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "DATETIME_INPUT_FORMATS = (\n # With time in %H:%M:%S :\n '%d-%m-%Y %H:%M:%S', '%d-%m-%y %H:%M:%S', '%Y-%m-%d %H:%M:%S', # '20-01-2009 15:23:35', '20-01-09 15:23:35', '2009-01-20 15:23:35'\n # '%d %b %Y %H:%M:%S', '%d %b %y %H:%M:%S', # '20 jan 2009 15:23:35', '20 jan 09 15:23:35'\n # '%d %B %Y %H:%M:%S', '%d %B %y %H:%M:%S', # '20 januari 2009 15:23:35', '20 januari 2009 15:23:35'\n # With time in %H.%M:%S :\n '%d-%m-%Y %H.%M:%S', '%d-%m-%y %H.%M:%S', # '20-01-2009 15.23:35', '20-01-09 15.23:35'\n # '%d %b %Y %H.%M:%S', '%d %b %y %H.%M:%S', # '20 jan 2009 15.23:35', '20 jan 09 15.23:35'"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98911:Assign_L46_C0", "label": "DECIMAL_SEPARATOR =", "type": "assigned_variable", "loc": [46, 46], "level": 0, "parent": null, "vector": [14, 0, 0.9583, 0.0208, 0, 0.66, 0.8462, 357, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "DECIMAL_SEPARATOR", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "DECIMAL_SEPARATOR = ','"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98911:Assign_L47_C0", "label": "THOUSAND_SEPARATOR =", "type": "assigned_variable", "loc": [47, 47], "level": 0, "parent": null, "vector": [14, 0, 0.9792, 0.0208, 0, 0.66, 0.9231, 316, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "THOUSAND_SEPARATOR", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "THOUSAND_SEPARATOR = '.'"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98911:Assign_L48_C0", "label": "NUMBER_GROUPING =", "type": "assigned_variable", "loc": [48, 48], "level": 0, "parent": null, "vector": [14, 0, 1.0, 0.0208, 0, 0.66, 1.0, 642, 1, 0, 0, 0, 0, 1, 0], "semantic": {"name": "NUMBER_GROUPING", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "NUMBER_GROUPING = 3"}]
[]
# -*- encoding: utf-8 -*- # This file is distributed under the same license as the Django package. # DATE_FORMAT = 'd F Y' TIME_FORMAT = 'H:i:s' # DATETIME_FORMAT = # YEAR_MONTH_FORMAT = # MONTH_DAY_FORMAT = SHORT_DATE_FORMAT = 'd.n.Y' # SHORT_DATETIME_FORMAT = # FIRST_DAY_OF_WEEK = # DATE_INPUT_FORMATS = # TIME_INPUT_FORMATS = # DATETIME_INPUT_FORMATS = DECIMAL_SEPARATOR = ',' THOUSAND_SEPARATOR = '.' # NUMBER_GROUPING =
ajibawa-2023/Python-Code-Large/train/row_98912
5
18
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_98912:Assign_L5_C0", "label": "DATE_FORMAT =", "type": "assigned_variable", "loc": [5, 5], "level": 0, "parent": null, "vector": [14, 0, 0.2778, 0.0556, 0, 0.66, 0.0, 843, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "DATE_FORMAT", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "DATE_FORMAT = 'd F Y'"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98912:Assign_L6_C0", "label": "TIME_FORMAT =", "type": "assigned_variable", "loc": [6, 6], "level": 0, "parent": null, "vector": [14, 0, 0.3333, 0.0556, 0, 0.66, 0.25, 662, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "TIME_FORMAT", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "TIME_FORMAT = 'H:i:s'"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98912:Assign_L10_C0", "label": "SHORT_DATE_FORMAT =", "type": "assigned_variable", "loc": [10, 10], "level": 0, "parent": null, "vector": [14, 0, 0.5556, 0.0556, 0, 0.66, 0.5, 881, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "SHORT_DATE_FORMAT", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "SHORT_DATE_FORMAT = 'd.n.Y'"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98912:Assign_L16_C0", "label": "DECIMAL_SEPARATOR =", "type": "assigned_variable", "loc": [16, 16], "level": 0, "parent": null, "vector": [14, 0, 0.8889, 0.0556, 0, 0.66, 0.75, 357, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "DECIMAL_SEPARATOR", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "DECIMAL_SEPARATOR = ','"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98912:Assign_L17_C0", "label": "THOUSAND_SEPARATOR =", "type": "assigned_variable", "loc": [17, 17], "level": 0, "parent": null, "vector": [14, 0, 0.9444, 0.0556, 0, 0.66, 1.0, 316, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "THOUSAND_SEPARATOR", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "THOUSAND_SEPARATOR = '.'"}]
[]
# -*- encoding: utf-8 -*- # This file is distributed under the same license as the Django package. # DATE_FORMAT = 'd F Y' # 25 Ottobre 2006 TIME_FORMAT = 'H:i:s' # 14:30:59 DATETIME_FORMAT = 'l d F Y H:i:s' # Mercoledì 25 Ottobre 2006 14:30:59 YEAR_MONTH_FORMAT = 'F Y' # Ottobre 2006 MONTH_DAY_FORMAT = 'j/F' # 10/2006 SHORT_DATE_FORMAT = 'd/M/Y' # 25/12/2009 SHORT_DATETIME_FORMAT = 'd/M/Y H:i:s' # 25/10/2009 14:30:59 FIRST_DAY_OF_WEEK = 1 # Lunedì DATE_INPUT_FORMATS = ( '%Y-%m-%d', '%Y/%m/%d', # '2008-10-25', '2008/10/25' '%d-%m-%Y', '%d/%m/%Y', # '25-10-2006', '25/10/2006' '%d-%m-%y', '%d/%m/%y', # '25-10-06', '25/10/06' ) TIME_INPUT_FORMATS = ( '%H:%M:%S', # '14:30:59' '%H:%M', # '14:30' ) DATETIME_INPUT_FORMATS = ( '%Y-%m-%d %H:%M:%S', # '2006-10-25 14:30:59' '%Y-%m-%d %H:%M', # '2006-10-25 14:30' '%Y-%m-%d', # '2006-10-25' '%d-%m-%Y %H:%M:%S', # '25-10-2006 14:30:59' '%d-%m-%Y %H:%M', # '25-10-2006 14:30' '%d-%m-%Y', # '25-10-2006' '%d-%m-%y %H:%M:%S', # '25-10-06 14:30:59' '%d-%m-%y %H:%M', # '25-10-06 14:30' '%d-%m-%y', # '25-10-06' '%d/%m/%Y %H:%M:%S', # '25/10/2006 14:30:59' '%d/%m/%Y %H:%M', # '25/10/2006 14:30' '%d/%m/%Y', # '25/10/2006' '%d/%m/%y %H:%M:%S', # '25/10/06 14:30:59' '%d/%m/%y %H:%M', # '25/10/06 14:30' '%d/%m/%y', # '25/10/06' ) DECIMAL_SEPARATOR = ',' THOUSAND_SEPARATOR = '.' NUMBER_GROUPING = 3
ajibawa-2023/Python-Code-Large/train/row_98913
14
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_98913:Assign_L5_C0", "label": "DATE_FORMAT =", "type": "assigned_variable", "loc": [5, 5], "level": 0, "parent": null, "vector": [14, 0, 0.122, 0.0244, 0, 0.66, 0.0, 843, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "DATE_FORMAT", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "DATE_FORMAT = 'd F Y' # 25 Ottobre 2006"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98913:Assign_L6_C0", "label": "TIME_FORMAT =", "type": "assigned_variable", "loc": [6, 6], "level": 0, "parent": null, "vector": [14, 0, 0.1463, 0.0244, 0, 0.66, 0.0769, 662, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "TIME_FORMAT", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "TIME_FORMAT = 'H:i:s' # 14:30:59"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98913:Assign_L7_C0", "label": "DATETIME_FORMAT =", "type": "assigned_variable", "loc": [7, 7], "level": 0, "parent": null, "vector": [14, 0, 0.1707, 0.0244, 0, 0.66, 0.1538, 146, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "DATETIME_FORMAT", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "DATETIME_FORMAT = 'l d F Y H:i:s' # Mercoled\u00ec 25 Ottobre 2006 14:30:59"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98913:Assign_L8_C0", "label": "YEAR_MONTH_FORMAT =", "type": "assigned_variable", "loc": [8, 8], "level": 0, "parent": null, "vector": [14, 0, 0.1951, 0.0244, 0, 0.66, 0.2308, 693, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "YEAR_MONTH_FORMAT", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "YEAR_MONTH_FORMAT = 'F Y' # Ottobre 2006"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98913:Assign_L9_C0", "label": "MONTH_DAY_FORMAT =", "type": "assigned_variable", "loc": [9, 9], "level": 0, "parent": null, "vector": [14, 0, 0.2195, 0.0244, 0, 0.66, 0.3077, 609, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "MONTH_DAY_FORMAT", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "MONTH_DAY_FORMAT = 'j/F' # 10/2006"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98913:Assign_L10_C0", "label": "SHORT_DATE_FORMAT =", "type": "assigned_variable", "loc": [10, 10], "level": 0, "parent": null, "vector": [14, 0, 0.2439, 0.0244, 0, 0.66, 0.3846, 881, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "SHORT_DATE_FORMAT", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "SHORT_DATE_FORMAT = 'd/M/Y' # 25/12/2009"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98913:Assign_L11_C0", "label": "SHORT_DATETIME_FORMAT =", "type": "assigned_variable", "loc": [11, 11], "level": 0, "parent": null, "vector": [14, 0, 0.2683, 0.0244, 0, 0.66, 0.4615, 839, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "SHORT_DATETIME_FORMAT", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "SHORT_DATETIME_FORMAT = 'd/M/Y H:i:s' # 25/10/2009 14:30:59"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98913:Assign_L12_C0", "label": "FIRST_DAY_OF_WEEK =", "type": "assigned_variable", "loc": [12, 12], "level": 0, "parent": null, "vector": [14, 0, 0.2927, 0.0244, 0, 0.66, 0.5385, 317, 1, 0, 0, 0, 0, 1, 0], "semantic": {"name": "FIRST_DAY_OF_WEEK", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "FIRST_DAY_OF_WEEK = 1 # Luned\u00ec"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98913:Assign_L13_C0", "label": "DATE_INPUT_FORMATS =", "type": "assigned_variable", "loc": [13, 17], "level": 0, "parent": null, "vector": [14, 0, 0.3659, 0.122, 0, 0.66, 0.6154, 764, 0, 0, 0, 0, 0, 8, 0], "semantic": {"name": "DATE_INPUT_FORMATS", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "DATE_INPUT_FORMATS = (\n '%Y-%m-%d', '%Y/%m/%d', # '2008-10-25', '2008/10/25'\n '%d-%m-%Y', '%d/%m/%Y', # '25-10-2006', '25/10/2006'\n '%d-%m-%y', '%d/%m/%y', # '25-10-06', '25/10/06'\n)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98913:Assign_L18_C0", "label": "TIME_INPUT_FORMATS =", "type": "assigned_variable", "loc": [18, 21], "level": 0, "parent": null, "vector": [14, 0, 0.4756, 0.0976, 0, 0.66, 0.6923, 416, 0, 0, 0, 0, 0, 8, 0], "semantic": {"name": "TIME_INPUT_FORMATS", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "TIME_INPUT_FORMATS = (\n '%H:%M:%S', # '14:30:59'\n '%H:%M', # '14:30'\n)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98913:Assign_L22_C0", "label": "DATETIME_INPUT_FORMATS =", "type": "assigned_variable", "loc": [22, 38], "level": 0, "parent": null, "vector": [14, 0, 0.7317, 0.4146, 0, 0.66, 0.7692, 531, 0, 0, 0, 0, 0, 8, 0], "semantic": {"name": "DATETIME_INPUT_FORMATS", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "DATETIME_INPUT_FORMATS = (\n '%Y-%m-%d %H:%M:%S', # '2006-10-25 14:30:59'\n '%Y-%m-%d %H:%M', # '2006-10-25 14:30'\n '%Y-%m-%d', # '2006-10-25'\n '%d-%m-%Y %H:%M:%S', # '25-10-2006 14:30:59'\n '%d-%m-%Y %H:%M', # '25-10-2006 14:30'\n '%d-%m-%Y', # '25-10-2006'\n '%d-%m-%y %H:%M:%S', # '25-10-06 14:30:59'"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98913:Assign_L39_C0", "label": "DECIMAL_SEPARATOR =", "type": "assigned_variable", "loc": [39, 39], "level": 0, "parent": null, "vector": [14, 0, 0.9512, 0.0244, 0, 0.66, 0.8462, 357, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "DECIMAL_SEPARATOR", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "DECIMAL_SEPARATOR = ','"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98913:Assign_L40_C0", "label": "THOUSAND_SEPARATOR =", "type": "assigned_variable", "loc": [40, 40], "level": 0, "parent": null, "vector": [14, 0, 0.9756, 0.0244, 0, 0.66, 0.9231, 316, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "THOUSAND_SEPARATOR", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "THOUSAND_SEPARATOR = '.'"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98913:Assign_L41_C0", "label": "NUMBER_GROUPING =", "type": "assigned_variable", "loc": [41, 41], "level": 0, "parent": null, "vector": [14, 0, 1.0, 0.0244, 0, 0.66, 1.0, 642, 1, 0, 0, 0, 0, 1, 0], "semantic": {"name": "NUMBER_GROUPING", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "NUMBER_GROUPING = 3"}]
[]
# -*- encoding: utf-8 -*- # This file is distributed under the same license as the Django package. # # DATE_FORMAT = # TIME_FORMAT = # DATETIME_FORMAT = # YEAR_MONTH_FORMAT = # MONTH_DAY_FORMAT = # SHORT_DATE_FORMAT = # SHORT_DATETIME_FORMAT = # FIRST_DAY_OF_WEEK = # DATE_INPUT_FORMATS = # TIME_INPUT_FORMATS = # DATETIME_INPUT_FORMATS = # DECIMAL_SEPARATOR = # THOUSAND_SEPARATOR = # NUMBER_GROUPING =
ajibawa-2023/Python-Code-Large/train/row_98914
0
18
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"]
[]
[]
# -*- encoding: utf-8 -*- # This file is distributed under the same license as the Django package. # DATE_FORMAT = 'd F Y' TIME_FORMAT = 'H:i:s' # DATETIME_FORMAT = # YEAR_MONTH_FORMAT = MONTH_DAY_FORMAT = 'j F' SHORT_DATE_FORMAT = 'd.m.Y' # SHORT_DATETIME_FORMAT = # FIRST_DAY_OF_WEEK = # DATE_INPUT_FORMATS = # TIME_INPUT_FORMATS = # DATETIME_INPUT_FORMATS = DECIMAL_SEPARATOR = ',' THOUSAND_SEPARATOR = ' ' # NUMBER_GROUPING =
ajibawa-2023/Python-Code-Large/train/row_98915
6
18
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_98915:Assign_L5_C0", "label": "DATE_FORMAT =", "type": "assigned_variable", "loc": [5, 5], "level": 0, "parent": null, "vector": [14, 0, 0.2778, 0.0556, 0, 0.66, 0.0, 843, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "DATE_FORMAT", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "DATE_FORMAT = 'd F Y'"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98915:Assign_L6_C0", "label": "TIME_FORMAT =", "type": "assigned_variable", "loc": [6, 6], "level": 0, "parent": null, "vector": [14, 0, 0.3333, 0.0556, 0, 0.66, 0.2, 662, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "TIME_FORMAT", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "TIME_FORMAT = 'H:i:s'"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98915:Assign_L9_C0", "label": "MONTH_DAY_FORMAT =", "type": "assigned_variable", "loc": [9, 9], "level": 0, "parent": null, "vector": [14, 0, 0.5, 0.0556, 0, 0.66, 0.4, 609, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "MONTH_DAY_FORMAT", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "MONTH_DAY_FORMAT = 'j F'"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98915:Assign_L10_C0", "label": "SHORT_DATE_FORMAT =", "type": "assigned_variable", "loc": [10, 10], "level": 0, "parent": null, "vector": [14, 0, 0.5556, 0.0556, 0, 0.66, 0.6, 881, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "SHORT_DATE_FORMAT", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "SHORT_DATE_FORMAT = 'd.m.Y'"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98915:Assign_L16_C0", "label": "DECIMAL_SEPARATOR =", "type": "assigned_variable", "loc": [16, 16], "level": 0, "parent": null, "vector": [14, 0, 0.8889, 0.0556, 0, 0.66, 0.8, 357, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "DECIMAL_SEPARATOR", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "DECIMAL_SEPARATOR = ','"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98915:Assign_L17_C0", "label": "THOUSAND_SEPARATOR =", "type": "assigned_variable", "loc": [17, 17], "level": 0, "parent": null, "vector": [14, 0, 0.9444, 0.0556, 0, 0.66, 1.0, 316, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "THOUSAND_SEPARATOR", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "THOUSAND_SEPARATOR = '\u00a0'"}]
[]
# -*- encoding: utf-8 -*- # This file is distributed under the same license as the Django package. # DATE_FORMAT = 'j. F Y' TIME_FORMAT = 'G:i:s' DATETIME_FORMAT = 'j. F Y G:i:s' YEAR_MONTH_FORMAT = 'F Y' MONTH_DAY_FORMAT = 'j. F' SHORT_DATE_FORMAT = 'd.m.Y' SHORT_DATETIME_FORMAT = 'd.m.Y G:i:s' FIRST_DAY_OF_WEEK = 1 # Monday DATE_INPUT_FORMATS = ( '%d.%m.%Y', '%d.%m.%y', # '25.10.2006', '25.10.06' '%Y-%m-%d', '%y-%m-%d', # '2006-10-25', '06-10-25' # '%d. %B %Y', '%d. %b. %Y', # '25. October 2006', '25. Oct. 2006' ) TIME_INPUT_FORMATS = ( '%H:%M:%S', # '14:30:59' '%H:%M', # '14:30' ) DATETIME_INPUT_FORMATS = ( '%d.%m.%Y %H:%M:%S', # '25.10.2006 14:30:59' '%d.%m.%Y %H:%M', # '25.10.2006 14:30' '%d.%m.%Y', # '25.10.2006' '%Y-%m-%d %H:%M:%S', # '2006-10-25 14:30:59' '%Y-%m-%d %H:%M', # '2006-10-25 14:30' '%Y-%m-%d', # '2006-10-25' ) DECIMAL_SEPARATOR = ',' THOUSAND_SEPARATOR = ' ' NUMBER_GROUPING = 3
ajibawa-2023/Python-Code-Large/train/row_98916
14
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_98916:Assign_L5_C0", "label": "DATE_FORMAT =", "type": "assigned_variable", "loc": [5, 5], "level": 0, "parent": null, "vector": [14, 0, 0.1562, 0.0312, 0, 0.66, 0.0, 843, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "DATE_FORMAT", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "DATE_FORMAT = 'j. F Y'"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98916:Assign_L6_C0", "label": "TIME_FORMAT =", "type": "assigned_variable", "loc": [6, 6], "level": 0, "parent": null, "vector": [14, 0, 0.1875, 0.0312, 0, 0.66, 0.0769, 662, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "TIME_FORMAT", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "TIME_FORMAT = 'G:i:s'"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98916:Assign_L7_C0", "label": "DATETIME_FORMAT =", "type": "assigned_variable", "loc": [7, 7], "level": 0, "parent": null, "vector": [14, 0, 0.2188, 0.0312, 0, 0.66, 0.1538, 146, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "DATETIME_FORMAT", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "DATETIME_FORMAT = 'j. F Y G:i:s'"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98916:Assign_L8_C0", "label": "YEAR_MONTH_FORMAT =", "type": "assigned_variable", "loc": [8, 8], "level": 0, "parent": null, "vector": [14, 0, 0.25, 0.0312, 0, 0.66, 0.2308, 693, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "YEAR_MONTH_FORMAT", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "YEAR_MONTH_FORMAT = 'F Y'"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98916:Assign_L9_C0", "label": "MONTH_DAY_FORMAT =", "type": "assigned_variable", "loc": [9, 9], "level": 0, "parent": null, "vector": [14, 0, 0.2812, 0.0312, 0, 0.66, 0.3077, 609, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "MONTH_DAY_FORMAT", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "MONTH_DAY_FORMAT = 'j. F'"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98916:Assign_L10_C0", "label": "SHORT_DATE_FORMAT =", "type": "assigned_variable", "loc": [10, 10], "level": 0, "parent": null, "vector": [14, 0, 0.3125, 0.0312, 0, 0.66, 0.3846, 881, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "SHORT_DATE_FORMAT", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "SHORT_DATE_FORMAT = 'd.m.Y'"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98916:Assign_L11_C0", "label": "SHORT_DATETIME_FORMAT =", "type": "assigned_variable", "loc": [11, 11], "level": 0, "parent": null, "vector": [14, 0, 0.3438, 0.0312, 0, 0.66, 0.4615, 839, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "SHORT_DATETIME_FORMAT", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "SHORT_DATETIME_FORMAT = 'd.m.Y G:i:s'"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98916:Assign_L12_C0", "label": "FIRST_DAY_OF_WEEK =", "type": "assigned_variable", "loc": [12, 12], "level": 0, "parent": null, "vector": [14, 0, 0.375, 0.0312, 0, 0.66, 0.5385, 317, 1, 0, 0, 0, 0, 1, 0], "semantic": {"name": "FIRST_DAY_OF_WEEK", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "FIRST_DAY_OF_WEEK = 1 # Monday"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98916:Assign_L13_C0", "label": "DATE_INPUT_FORMATS =", "type": "assigned_variable", "loc": [13, 17], "level": 0, "parent": null, "vector": [14, 0, 0.4688, 0.1562, 0, 0.66, 0.6154, 764, 0, 0, 0, 0, 0, 8, 0], "semantic": {"name": "DATE_INPUT_FORMATS", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "DATE_INPUT_FORMATS = (\n '%d.%m.%Y', '%d.%m.%y', # '25.10.2006', '25.10.06'\n '%Y-%m-%d', '%y-%m-%d', # '2006-10-25', '06-10-25'\n # '%d. %B %Y', '%d. %b. %Y', # '25. October 2006', '25. Oct. 2006'\n)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98916:Assign_L18_C0", "label": "TIME_INPUT_FORMATS =", "type": "assigned_variable", "loc": [18, 21], "level": 0, "parent": null, "vector": [14, 0, 0.6094, 0.125, 0, 0.66, 0.6923, 416, 0, 0, 0, 0, 0, 8, 0], "semantic": {"name": "TIME_INPUT_FORMATS", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "TIME_INPUT_FORMATS = (\n '%H:%M:%S', # '14:30:59'\n '%H:%M', # '14:30'\n)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98916:Assign_L22_C0", "label": "DATETIME_INPUT_FORMATS =", "type": "assigned_variable", "loc": [22, 29], "level": 0, "parent": null, "vector": [14, 0, 0.7969, 0.25, 0, 0.66, 0.7692, 531, 0, 0, 0, 0, 0, 8, 0], "semantic": {"name": "DATETIME_INPUT_FORMATS", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "DATETIME_INPUT_FORMATS = (\n '%d.%m.%Y %H:%M:%S', # '25.10.2006 14:30:59'\n '%d.%m.%Y %H:%M', # '25.10.2006 14:30'\n '%d.%m.%Y', # '25.10.2006'\n '%Y-%m-%d %H:%M:%S', # '2006-10-25 14:30:59'\n '%Y-%m-%d %H:%M', # '2006-10-25 14:30'\n '%Y-%m-%d', # '2006-10-25'\n)"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98916:Assign_L30_C0", "label": "DECIMAL_SEPARATOR =", "type": "assigned_variable", "loc": [30, 30], "level": 0, "parent": null, "vector": [14, 0, 0.9375, 0.0312, 0, 0.66, 0.8462, 357, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "DECIMAL_SEPARATOR", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "DECIMAL_SEPARATOR = ','"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98916:Assign_L31_C0", "label": "THOUSAND_SEPARATOR =", "type": "assigned_variable", "loc": [31, 31], "level": 0, "parent": null, "vector": [14, 0, 0.9688, 0.0312, 0, 0.66, 0.9231, 316, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "THOUSAND_SEPARATOR", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "THOUSAND_SEPARATOR = ' '"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98916:Assign_L32_C0", "label": "NUMBER_GROUPING =", "type": "assigned_variable", "loc": [32, 32], "level": 0, "parent": null, "vector": [14, 0, 1.0, 0.0312, 0, 0.66, 1.0, 642, 1, 0, 0, 0, 0, 1, 0], "semantic": {"name": "NUMBER_GROUPING", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "NUMBER_GROUPING = 3"}]
[]
# -*- encoding: utf-8 -*- # This file is distributed under the same license as the Django package. # DATE_FORMAT = 'j F Y' TIME_FORMAT = 'G:i:s' # DATETIME_FORMAT = # YEAR_MONTH_FORMAT = MONTH_DAY_FORMAT = 'j F' SHORT_DATE_FORMAT = 'd.m.Y' # SHORT_DATETIME_FORMAT = # FIRST_DAY_OF_WEEK = # DATE_INPUT_FORMATS = # TIME_INPUT_FORMATS = # DATETIME_INPUT_FORMATS = DECIMAL_SEPARATOR = ',' THOUSAND_SEPARATOR = ' ' # NUMBER_GROUPING =
ajibawa-2023/Python-Code-Large/train/row_98917
6
18
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_98917:Assign_L5_C0", "label": "DATE_FORMAT =", "type": "assigned_variable", "loc": [5, 5], "level": 0, "parent": null, "vector": [14, 0, 0.2778, 0.0556, 0, 0.66, 0.0, 843, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "DATE_FORMAT", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "DATE_FORMAT = 'j F Y'"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98917:Assign_L6_C0", "label": "TIME_FORMAT =", "type": "assigned_variable", "loc": [6, 6], "level": 0, "parent": null, "vector": [14, 0, 0.3333, 0.0556, 0, 0.66, 0.2, 662, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "TIME_FORMAT", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "TIME_FORMAT = 'G:i:s'"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98917:Assign_L9_C0", "label": "MONTH_DAY_FORMAT =", "type": "assigned_variable", "loc": [9, 9], "level": 0, "parent": null, "vector": [14, 0, 0.5, 0.0556, 0, 0.66, 0.4, 609, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "MONTH_DAY_FORMAT", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "MONTH_DAY_FORMAT = 'j F'"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98917:Assign_L10_C0", "label": "SHORT_DATE_FORMAT =", "type": "assigned_variable", "loc": [10, 10], "level": 0, "parent": null, "vector": [14, 0, 0.5556, 0.0556, 0, 0.66, 0.6, 881, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "SHORT_DATE_FORMAT", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "SHORT_DATE_FORMAT = 'd.m.Y'"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98917:Assign_L16_C0", "label": "DECIMAL_SEPARATOR =", "type": "assigned_variable", "loc": [16, 16], "level": 0, "parent": null, "vector": [14, 0, 0.8889, 0.0556, 0, 0.66, 0.8, 357, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "DECIMAL_SEPARATOR", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "DECIMAL_SEPARATOR = ','"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98917:Assign_L17_C0", "label": "THOUSAND_SEPARATOR =", "type": "assigned_variable", "loc": [17, 17], "level": 0, "parent": null, "vector": [14, 0, 0.9444, 0.0556, 0, 0.66, 1.0, 316, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "THOUSAND_SEPARATOR", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "THOUSAND_SEPARATOR = '\u00a0'"}]
[]
# -*- encoding: utf-8 -*- # This file is distributed under the same license as the Django package. # # DATE_FORMAT = # TIME_FORMAT = # DATETIME_FORMAT = # YEAR_MONTH_FORMAT = # MONTH_DAY_FORMAT = # SHORT_DATE_FORMAT = # SHORT_DATETIME_FORMAT = # FIRST_DAY_OF_WEEK = # DATE_INPUT_FORMATS = # TIME_INPUT_FORMATS = # DATETIME_INPUT_FORMATS = # DECIMAL_SEPARATOR = # THOUSAND_SEPARATOR = # NUMBER_GROUPING =
ajibawa-2023/Python-Code-Large/train/row_98918
0
18
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"]
[]
[]
# -*- encoding: utf-8 -*- # This file is distributed under the same license as the Django package. # DATE_FORMAT = 'd F Y' TIME_FORMAT = 'g:i:s A' # DATETIME_FORMAT = # YEAR_MONTH_FORMAT = # MONTH_DAY_FORMAT = SHORT_DATE_FORMAT = 'j M Y' # SHORT_DATETIME_FORMAT = # FIRST_DAY_OF_WEEK = # DATE_INPUT_FORMATS = # TIME_INPUT_FORMATS = # DATETIME_INPUT_FORMATS = # DECIMAL_SEPARATOR = # THOUSAND_SEPARATOR = # NUMBER_GROUPING =
ajibawa-2023/Python-Code-Large/train/row_98919
3
18
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_98919:Assign_L5_C0", "label": "DATE_FORMAT =", "type": "assigned_variable", "loc": [5, 5], "level": 0, "parent": null, "vector": [14, 0, 0.2778, 0.0556, 0, 0.66, 0.0, 843, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "DATE_FORMAT", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "DATE_FORMAT = 'd F Y'"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98919:Assign_L6_C0", "label": "TIME_FORMAT =", "type": "assigned_variable", "loc": [6, 6], "level": 0, "parent": null, "vector": [14, 0, 0.3333, 0.0556, 0, 0.66, 0.5, 662, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "TIME_FORMAT", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "TIME_FORMAT = 'g:i:s A'"}, {"id": "ajibawa-2023/Python-Code-Large/train/row_98919:Assign_L10_C0", "label": "SHORT_DATE_FORMAT =", "type": "assigned_variable", "loc": [10, 10], "level": 0, "parent": null, "vector": [14, 0, 0.5556, 0.0556, 0, 0.66, 1.0, 881, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "SHORT_DATE_FORMAT", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotation": ""}, "snippet": "SHORT_DATE_FORMAT = 'j M Y'"}]
[]