lines
sequencelengths
1
383
raw_lines
sequencelengths
1
383
label
sequencelengths
1
383
type
sequencelengths
1
383
[ "def FUNC_77(VAR_233, VAR_234, VAR_235):...\n", "VAR_17 = os.path.basename(VAR_233)\n", "VAR_293 = '%s.%s' % (VAR_17, VAR_234)\n", "VAR_293 = os.path.join(VAR_235, VAR_293)\n", "VAR_212 = 1\n", "VAR_17 = VAR_293[:-(len(VAR_234) + 1)]\n", "while os.path.exists(VAR_293):\n", "VAR_293 = '%s_(%d).%s' % (VAR_17, VAR_212, VAR_234)\n", "return VAR_293\n", "VAR_212 += 1\n" ]
[ "def makeImageName(originalName, extension, folder_name):...\n", "name = os.path.basename(originalName)\n", "imgName = '%s.%s' % (name, extension)\n", "imgName = os.path.join(folder_name, imgName)\n", "i = 1\n", "name = imgName[:-(len(extension) + 1)]\n", "while os.path.exists(imgName):\n", "imgName = '%s_(%d).%s' % (name, i, extension)\n", "return imgName\n", "i += 1\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Condition", "Assign'", "Return'", "AugAssign'" ]
[ "def FUNC_116(VAR_129):...\n", "def FUNC_121(*VAR_79, **VAR_42):...\n", "if VAR_13.read_from_replica:\n", "FUNC_6()\n", "VAR_225 = VAR_129(*VAR_79, **get_newargs(fn, kwargs))\n", "if VAR_1 and hasattr(VAR_1, 'primary_db'):\n", "return VAR_225\n", "VAR_1.db.close()\n", "VAR_1.db = VAR_1.primary_db\n" ]
[ "def innfn(fn):...\n", "def wrapper_fn(*args, **kwargs):...\n", "if conf.read_from_replica:\n", "connect_replica()\n", "retval = fn(*args, **get_newargs(fn, kwargs))\n", "if local and hasattr(local, 'primary_db'):\n", "return retval\n", "local.db.close()\n", "local.db = local.primary_db\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "FunctionDef'", "Condition", "Expr'", "Assign'", "Condition", "Return'", "Expr'", "Assign'" ]
[ "def FUNC_1(VAR_0, VAR_1):...\n", "return FUNC_0(VAR_0=request, VAR_1=pk, VAR_2='is_removed', VAR_3=True,\n VAR_5=_('The topic has been deleted'))\n" ]
[ "def delete(request, pk):...\n", "return _moderate(request=request, pk=pk, field_name='is_removed', to_value=\n True, message=_('The topic has been deleted'))\n" ]
[ 0, 0 ]
[ "FunctionDef'", "Return'" ]
[ "@app.route('/notes/new', methods=['GET', 'POST'])...\n", "VAR_9 = forms.NewNoteForm()\n", "VAR_8 = 'root directory'\n", "VAR_9.path.choices = [('', VAR_8)] + [(pathname, pathname) for pathname in\n data.get_dirs()]\n", "if VAR_9.validate_on_submit():\n", "VAR_7 = VAR_9.path.data\n", "VAR_7 = request.args.get('path', VAR_8).strip('/')\n", "VAR_10 = VAR_9.tags.data.split(',') if VAR_9.tags.data != '' else []\n", "VAR_9.path.data = VAR_7\n", "VAR_10 = [tag.strip() for tag in VAR_10]\n", "return render_template('/dataobjs/new.html', title='New Note', VAR_9=form)\n", "VAR_29 = DataObj(title=form.title.data, VAR_7=path, VAR_10=tags, type='note')\n", "VAR_30 = VAR_29.insert()\n", "if VAR_30:\n", "flash('Note Saved!', 'success')\n", "return redirect(f'/dataobj/{VAR_30}')\n" ]
[ "@app.route('/notes/new', methods=['GET', 'POST'])...\n", "form = forms.NewNoteForm()\n", "default_dir = 'root directory'\n", "form.path.choices = [('', default_dir)] + [(pathname, pathname) for\n pathname in data.get_dirs()]\n", "if form.validate_on_submit():\n", "path = form.path.data\n", "path = request.args.get('path', default_dir).strip('/')\n", "tags = form.tags.data.split(',') if form.tags.data != '' else []\n", "form.path.data = path\n", "tags = [tag.strip() for tag in tags]\n", "return render_template('/dataobjs/new.html', title='New Note', form=form)\n", "note = DataObj(title=form.title.data, path=path, tags=tags, type='note')\n", "note_id = note.insert()\n", "if note_id:\n", "flash('Note Saved!', 'success')\n", "return redirect(f'/dataobj/{note_id}')\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "Condition", "Assign'", "Assign'", "Assign'", "Condition", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Return'", "Assign'", "Assign'", "Condition", "Expr'", "Return'" ]
[ "def FUNC_57(VAR_17, VAR_18=None, VAR_10=None, VAR_19=None):...\n", "VAR_10 = VAR_10 or [db.Books.sort]\n", "VAR_65 = None\n", "VAR_16 = get_cc_columns(filter_config_custom_read=True)\n", "calibre_db.session.connection().connection.connection.create_function('lower',\n 1, db.lcase)\n", "VAR_21 = calibre_db.session.query(db.Books).outerjoin(db.books_series_link,\n db.Books.id == db.books_series_link.c.book).outerjoin(db.Series).filter(\n calibre_db.common_filters(True))\n", "VAR_41 = dict()\n", "VAR_92 = ['tag', 'serie', 'shelf', 'language', 'extension']\n", "for VAR_113 in VAR_92:\n", "VAR_41['include_' + VAR_113] = VAR_17.get('include_' + VAR_113)\n", "VAR_36 = VAR_17.get('author_name')\n", "VAR_41['exclude_' + VAR_113] = VAR_17.get('exclude_' + VAR_113)\n", "VAR_37 = VAR_17.get('book_title')\n", "VAR_38 = VAR_17.get('publisher')\n", "VAR_39 = VAR_17.get('publishstart')\n", "VAR_40 = VAR_17.get('publishend')\n", "VAR_25 = VAR_17.get('ratinghigh')\n", "VAR_24 = VAR_17.get('ratinglow')\n", "VAR_93 = VAR_17.get('comment')\n", "VAR_26 = VAR_17.get('read_status')\n", "if VAR_36:\n", "VAR_36 = VAR_36.strip().lower().replace(',', '|')\n", "if VAR_37:\n", "VAR_37 = VAR_37.strip().lower()\n", "if VAR_38:\n", "VAR_38 = VAR_38.strip().lower()\n", "VAR_35 = []\n", "VAR_94 = False\n", "for c in VAR_16:\n", "if c.datatype == 'datetime':\n", "if any(VAR_41.values()\n", "VAR_131 = VAR_17.get('custom_column_' + str(c.id) + '_start')\n", "if VAR_17.get('custom_column_' + str(c.id)):\n", "VAR_35, VAR_39, VAR_40 = FUNC_56(VAR_35, VAR_36, VAR_37, VAR_38, VAR_39,\n VAR_40, VAR_41, VAR_24, VAR_25, VAR_26)\n", "VAR_21 = VAR_21.order_by(*VAR_10).all()\n", "VAR_132 = VAR_17.get('custom_column_' + str(c.id) + '_end')\n", "VAR_35.extend([u'{}: {}'.format(c.name, VAR_17.get('custom_column_' + str(c\n .id)))])\n", "VAR_21 = VAR_21.filter()\n", "VAR_91['query'] = json.dumps(VAR_17)\n", "if VAR_131:\n", "VAR_94 = True\n", "if VAR_36:\n", "ub.store_ids(VAR_21)\n", "VAR_35.extend([u'{} >= {}'.format(c.name, format_date(datetime.strptime(\n VAR_131, '%Y-%m-%d'), format='medium', locale=get_locale()))])\n", "if VAR_132:\n", "VAR_21 = VAR_21.filter(db.Books.authors.any(func.lower(db.Authors.name).\n ilike('%' + VAR_36 + '%')))\n", "if VAR_37:\n", "VAR_77 = len(VAR_21)\n", "VAR_94 = True\n", "VAR_35.extend([u'{} <= {}'.format(c.name, format_date(datetime.strptime(\n VAR_132, '%Y-%m-%d').date(), format='medium', locale=get_locale()))])\n", "VAR_21 = VAR_21.filter(func.lower(db.Books.title).ilike('%' + VAR_37 + '%'))\n", "if VAR_39:\n", "if VAR_18 != None and VAR_19 != None:\n", "VAR_94 = True\n", "VAR_21 = VAR_21.filter(func.datetime(db.Books.pubdate) > func.datetime(VAR_39))\n", "if VAR_40:\n", "VAR_18 = int(VAR_18)\n", "VAR_18 = 0\n", "VAR_21 = VAR_21.filter(func.datetime(db.Books.pubdate) < func.datetime(VAR_40))\n", "VAR_21 = FUNC_51(VAR_21, VAR_26)\n", "VAR_114 = VAR_18 + int(VAR_19)\n", "VAR_114 = VAR_77\n", "if VAR_38:\n", "VAR_65 = Pagination(VAR_18 / int(VAR_19) + 1, VAR_19, VAR_77)\n", "return render_title_template('search.html', adv_searchterm=searchterm,\n VAR_65=pagination, VAR_63=q[offset:limit_all], VAR_77=result_count,\n VAR_149=_(u'Advanced Search'), VAR_9='advsearch')\n", "VAR_21 = VAR_21.filter(db.Books.publishers.any(func.lower(db.Publishers.\n name).ilike('%' + VAR_38 + '%')))\n", "VAR_21 = FUNC_53(VAR_21, VAR_41['include_tag'], VAR_41['exclude_tag'])\n", "VAR_21 = FUNC_54(VAR_21, VAR_41['include_serie'], VAR_41['exclude_serie'])\n", "VAR_21 = FUNC_55(VAR_21, VAR_41['include_shelf'], VAR_41['exclude_shelf'])\n", "VAR_21 = FUNC_52(VAR_21, VAR_41['include_extension'], VAR_41[\n 'exclude_extension'])\n", "VAR_21 = FUNC_49(VAR_21, VAR_41['include_language'], VAR_41['exclude_language']\n )\n", "VAR_21 = FUNC_50(VAR_21, VAR_24, VAR_25)\n", "if VAR_93:\n", "VAR_21 = VAR_21.filter(db.Books.comments.any(func.lower(db.Comments.text).\n ilike('%' + VAR_93 + '%')))\n", "VAR_21 = FUNC_48(VAR_16, VAR_17, VAR_21)\n", "VAR_3.debug_or_exception(ex)\n", "flash(_('Error on search for custom columns, please restart Calibre-Web'),\n category='error')\n" ]
[ "def render_adv_search_results(term, offset=None, order=None, limit=None):...\n", "order = order or [db.Books.sort]\n", "pagination = None\n", "cc = get_cc_columns(filter_config_custom_read=True)\n", "calibre_db.session.connection().connection.connection.create_function('lower',\n 1, db.lcase)\n", "q = calibre_db.session.query(db.Books).outerjoin(db.books_series_link, db.\n Books.id == db.books_series_link.c.book).outerjoin(db.Series).filter(\n calibre_db.common_filters(True))\n", "tags = dict()\n", "elements = ['tag', 'serie', 'shelf', 'language', 'extension']\n", "for element in elements:\n", "tags['include_' + element] = term.get('include_' + element)\n", "author_name = term.get('author_name')\n", "tags['exclude_' + element] = term.get('exclude_' + element)\n", "book_title = term.get('book_title')\n", "publisher = term.get('publisher')\n", "pub_start = term.get('publishstart')\n", "pub_end = term.get('publishend')\n", "rating_low = term.get('ratinghigh')\n", "rating_high = term.get('ratinglow')\n", "description = term.get('comment')\n", "read_status = term.get('read_status')\n", "if author_name:\n", "author_name = author_name.strip().lower().replace(',', '|')\n", "if book_title:\n", "book_title = book_title.strip().lower()\n", "if publisher:\n", "publisher = publisher.strip().lower()\n", "searchterm = []\n", "cc_present = False\n", "for c in cc:\n", "if c.datatype == 'datetime':\n", "if any(tags.values()\n", "column_start = term.get('custom_column_' + str(c.id) + '_start')\n", "if term.get('custom_column_' + str(c.id)):\n", "searchterm, pub_start, pub_end = extend_search_term(searchterm, author_name,\n book_title, publisher, pub_start, pub_end, tags, rating_high,\n rating_low, read_status)\n", "q = q.order_by(*order).all()\n", "column_end = term.get('custom_column_' + str(c.id) + '_end')\n", "searchterm.extend([u'{}: {}'.format(c.name, term.get('custom_column_' + str\n (c.id)))])\n", "q = q.filter()\n", "flask_session['query'] = json.dumps(term)\n", "if column_start:\n", "cc_present = True\n", "if author_name:\n", "ub.store_ids(q)\n", "searchterm.extend([u'{} >= {}'.format(c.name, format_date(datetime.strptime\n (column_start, '%Y-%m-%d'), format='medium', locale=get_locale()))])\n", "if column_end:\n", "q = q.filter(db.Books.authors.any(func.lower(db.Authors.name).ilike('%' +\n author_name + '%')))\n", "if book_title:\n", "result_count = len(q)\n", "cc_present = True\n", "searchterm.extend([u'{} <= {}'.format(c.name, format_date(datetime.strptime\n (column_end, '%Y-%m-%d').date(), format='medium', locale=get_locale()))])\n", "q = q.filter(func.lower(db.Books.title).ilike('%' + book_title + '%'))\n", "if pub_start:\n", "if offset != None and limit != None:\n", "cc_present = True\n", "q = q.filter(func.datetime(db.Books.pubdate) > func.datetime(pub_start))\n", "if pub_end:\n", "offset = int(offset)\n", "offset = 0\n", "q = q.filter(func.datetime(db.Books.pubdate) < func.datetime(pub_end))\n", "q = adv_search_read_status(q, read_status)\n", "limit_all = offset + int(limit)\n", "limit_all = result_count\n", "if publisher:\n", "pagination = Pagination(offset / int(limit) + 1, limit, result_count)\n", "return render_title_template('search.html', adv_searchterm=searchterm,\n pagination=pagination, entries=q[offset:limit_all], result_count=\n result_count, title=_(u'Advanced Search'), page='advsearch')\n", "q = q.filter(db.Books.publishers.any(func.lower(db.Publishers.name).ilike(\n '%' + publisher + '%')))\n", "q = adv_search_tag(q, tags['include_tag'], tags['exclude_tag'])\n", "q = adv_search_serie(q, tags['include_serie'], tags['exclude_serie'])\n", "q = adv_search_shelf(q, tags['include_shelf'], tags['exclude_shelf'])\n", "q = adv_search_extension(q, tags['include_extension'], tags[\n 'exclude_extension'])\n", "q = adv_search_language(q, tags['include_language'], tags['exclude_language'])\n", "q = adv_search_ratings(q, rating_high, rating_low)\n", "if description:\n", "q = q.filter(db.Books.comments.any(func.lower(db.Comments.text).ilike('%' +\n description + '%')))\n", "q = adv_search_custom_columns(cc, term, q)\n", "log.debug_or_exception(ex)\n", "flash(_('Error on search for custom columns, please restart Calibre-Web'),\n category='error')\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Assign'", "Assign'", "Expr'", "Assign'", "Assign'", "Assign'", "For", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Condition", "Assign'", "Condition", "Assign'", "Condition", "Assign'", "Assign'", "Assign'", "For", "Condition", "Condition", "Assign'", "Condition", "Assign'", "Assign'", "Assign'", "Expr'", "Assign'", "Assign'", "Condition", "Assign'", "Condition", "Expr'", "Expr'", "Condition", "Assign'", "Condition", "Assign'", "Assign'", "Expr'", "Assign'", "Condition", "Condition", "Assign'", "Assign'", "Condition", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Condition", "Assign'", "Return'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Condition", "Assign'", "Assign'", "Expr'", "Expr'" ]
[ "def FUNC_7(VAR_20):...\n", "\"\"\"docstring\"\"\"\n", "for regex in (VAR_8, VAR_9, VAR_10):\n", "VAR_33 = regex.match(VAR_20)\n", "VAR_34 = int(VAR_33.group('year'))\n", "six.reraise(ValueError, ValueError('%r is not a valid date' % VAR_20), sys.\n exc_info()[2])\n", "if VAR_33 is not None:\n", "if VAR_34 < 100:\n", "if VAR_34 < 70:\n", "VAR_35 = VAR_1.index(VAR_33.group('mon').lower()) + 1\n", "VAR_34 += 2000\n", "VAR_34 += 1900\n", "VAR_36 = int(VAR_33.group('day'))\n", "VAR_37 = int(VAR_33.group('hour'))\n", "VAR_38 = int(VAR_33.group('min'))\n", "VAR_39 = int(VAR_33.group('sec'))\n", "VAR_40 = datetime.datetime(VAR_34, VAR_35, VAR_36, VAR_37, VAR_38, VAR_39)\n", "return calendar.timegm(VAR_40.utctimetuple())\n" ]
[ "def parse_http_date(date):...\n", "\"\"\"docstring\"\"\"\n", "for regex in (RFC1123_DATE, RFC850_DATE, ASCTIME_DATE):\n", "m = regex.match(date)\n", "year = int(m.group('year'))\n", "six.reraise(ValueError, ValueError('%r is not a valid date' % date), sys.\n exc_info()[2])\n", "if m is not None:\n", "if year < 100:\n", "if year < 70:\n", "month = MONTHS.index(m.group('mon').lower()) + 1\n", "year += 2000\n", "year += 1900\n", "day = int(m.group('day'))\n", "hour = int(m.group('hour'))\n", "min = int(m.group('min'))\n", "sec = int(m.group('sec'))\n", "result = datetime.datetime(year, month, day, hour, min, sec)\n", "return calendar.timegm(result.utctimetuple())\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "For", "Assign'", "Assign'", "Expr'", "Condition", "Condition", "Condition", "Assign'", "AugAssign'", "AugAssign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Return'" ]
[ "import unittest\n", "from chameleon.exc import ExpressionError\n", "import zope.component.testing\n", "from AccessControl import SecurityManager\n", "from AccessControl.SecurityManagement import noSecurityManager\n", "from Acquisition import Implicit\n", "from Products.PageTemplates.interfaces import IUnicodeEncodingConflictResolver\n", "from Products.PageTemplates.PageTemplate import PageTemplate\n", "from Products.PageTemplates.tests import util\n", "from Products.PageTemplates.unicodeconflictresolver import DefaultUnicodeEncodingConflictResolver\n", "from Products.PageTemplates.unicodeconflictresolver import PreferredCharsetResolver\n", "from zExceptions import NotFound\n", "from zope.component import provideUtility\n", "from zope.traversing.adapters import DefaultTraversable\n", "from .util import useChameleonEngine\n", "\"\"\"\n Stub out the existing security policy for unit testing purposes.\n \"\"\"\n", "def FUNC_0(self, VAR_0=None, VAR_1=None, VAR_2=None, VAR_3=None, VAR_4=None,...\n", "return 1\n" ]
[ "import unittest\n", "from chameleon.exc import ExpressionError\n", "import zope.component.testing\n", "from AccessControl import SecurityManager\n", "from AccessControl.SecurityManagement import noSecurityManager\n", "from Acquisition import Implicit\n", "from Products.PageTemplates.interfaces import IUnicodeEncodingConflictResolver\n", "from Products.PageTemplates.PageTemplate import PageTemplate\n", "from Products.PageTemplates.tests import util\n", "from Products.PageTemplates.unicodeconflictresolver import DefaultUnicodeEncodingConflictResolver\n", "from Products.PageTemplates.unicodeconflictresolver import PreferredCharsetResolver\n", "from zExceptions import NotFound\n", "from zope.component import provideUtility\n", "from zope.traversing.adapters import DefaultTraversable\n", "from .util import useChameleonEngine\n", "\"\"\"\n Stub out the existing security policy for unit testing purposes.\n \"\"\"\n", "def validate(self, accessed=None, container=None, name=None, value=None,...\n", "return 1\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "Import'", "ImportFrom'", "Import'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "Expr'", "Condition", "Return'" ]
[ "def FUNC_9(self):...\n", "VAR_15 = self._makeOne()\n", "VAR_16 = CLASS_1()\n", "VAR_17 = CLASS_0(__ac_name='foo', __ac_password='b:ar', RESPONSE=response)\n", "self.assertEqual(len(VAR_16.cookies), 0)\n", "self.assertEqual(VAR_15.extractCredentials(VAR_17), {'login': 'foo',\n 'password': 'b:ar', 'remote_host': '', 'remote_address': ''})\n", "self.assertEqual(len(VAR_16.cookies), 0)\n" ]
[ "def test_extractCredentials_with_form_creds(self):...\n", "helper = self._makeOne()\n", "response = FauxCookieResponse()\n", "request = FauxSettableRequest(__ac_name='foo', __ac_password='b:ar',\n RESPONSE=response)\n", "self.assertEqual(len(response.cookies), 0)\n", "self.assertEqual(helper.extractCredentials(request), {'login': 'foo',\n 'password': 'b:ar', 'remote_host': '', 'remote_address': ''})\n", "self.assertEqual(len(response.cookies), 0)\n" ]
[ 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Assign'", "Assign'", "Expr'", "Expr'", "Expr'" ]
[ "def FUNC_163(VAR_10):...\n", "self.soap_procedures[VAR_148 or VAR_10.__name__\n ] = VAR_10, VAR_188, VAR_11, VAR_189, VAR_190\n", "return VAR_10\n" ]
[ "def _soap(f):...\n", "self.soap_procedures[name or f.__name__\n ] = f, returns, args, doc, response_element_name\n", "return f\n" ]
[ 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Return'" ]
[ "def FUNC_3(VAR_4, VAR_5):...\n", "\"\"\"docstring\"\"\"\n", "return VAR_4.signature_def[VAR_5].outputs\n" ]
[ "def _get_outputs_tensor_info_from_meta_graph_def(meta_graph_def,...\n", "\"\"\"docstring\"\"\"\n", "return meta_graph_def.signature_def[signature_def_key].outputs\n" ]
[ 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Return'" ]
[ "@log_function...\n", "VAR_2 = FUNC_1('/query/%s', VAR_13)\n", "VAR_19 = await self.client.get_json(VAR_5=destination, VAR_2=path, VAR_3=\n args, VAR_14=retry_on_dns_fail, VAR_8=10000, VAR_15=ignore_backoff)\n", "return VAR_19\n" ]
[ "@log_function...\n", "path = _create_v1_path('/query/%s', query_type)\n", "content = await self.client.get_json(destination=destination, path=path,\n args=args, retry_on_dns_fail=retry_on_dns_fail, timeout=10000,\n ignore_backoff=ignore_backoff)\n", "return content\n" ]
[ 0, 0, 0, 0 ]
[ "Condition", "Assign'", "Assign'", "Return'" ]
[ "def FUNC_12(self):...\n", "\"\"\"docstring\"\"\"\n", "from frappe.desk.form.load import get_attachments\n", "for attach_item in get_attachments(self.doctype, self.amended_from):\n", "VAR_82 = frappe.get_doc({'doctype': 'File', 'file_url': attach_item.\n file_url, 'file_name': attach_item.file_name, 'attached_to_name': self.\n name, 'attached_to_doctype': self.doctype, 'folder': 'Home/Attachments'})\n", "VAR_82.save()\n" ]
[ "def copy_attachments_from_amended_from(self):...\n", "\"\"\"docstring\"\"\"\n", "from frappe.desk.form.load import get_attachments\n", "for attach_item in get_attachments(self.doctype, self.amended_from):\n", "_file = frappe.get_doc({'doctype': 'File', 'file_url': attach_item.file_url,\n 'file_name': attach_item.file_name, 'attached_to_name': self.name,\n 'attached_to_doctype': self.doctype, 'folder': 'Home/Attachments'})\n", "_file.save()\n" ]
[ 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "ImportFrom'", "For", "Assign'", "Expr'" ]
[ "@VAR_2.route('/publisher')...\n", "if VAR_87.get_view_property('publisher', 'dir') == 'desc':\n", "VAR_10 = db.Publishers.name.desc()\n", "VAR_10 = db.Publishers.name.asc()\n", "VAR_109 = 0\n", "VAR_109 = 1\n", "if VAR_87.check_visibility(constants.SIDEBAR_PUBLISHER):\n", "VAR_63 = calibre_db.session.query(db.Publishers, func.count(\n 'books_publishers_link.book').label('count')).join(db.books_publishers_link\n ).join(db.Books).filter(calibre_db.common_filters()).group_by(text(\n 'books_publishers_link.publisher')).order_by(VAR_10).all()\n", "abort(404)\n", "VAR_107 = calibre_db.session.query(func.upper(func.substr(db.Publishers.\n name, 1, 1)).label('char')).join(db.books_publishers_link).join(db.Books\n ).filter(calibre_db.common_filters()).group_by(func.upper(func.substr(\n db.Publishers.name, 1, 1))).all()\n", "return render_title_template('list.html', VAR_63=entries, folder=\n 'web.books_list', VAR_107=charlist, VAR_150=_(u'Publishers'), VAR_9=\n 'publisherlist', VAR_8='publisher', VAR_10=order_no)\n" ]
[ "@web.route('/publisher')...\n", "if current_user.get_view_property('publisher', 'dir') == 'desc':\n", "order = db.Publishers.name.desc()\n", "order = db.Publishers.name.asc()\n", "order_no = 0\n", "order_no = 1\n", "if current_user.check_visibility(constants.SIDEBAR_PUBLISHER):\n", "entries = calibre_db.session.query(db.Publishers, func.count(\n 'books_publishers_link.book').label('count')).join(db.books_publishers_link\n ).join(db.Books).filter(calibre_db.common_filters()).group_by(text(\n 'books_publishers_link.publisher')).order_by(order).all()\n", "abort(404)\n", "charlist = calibre_db.session.query(func.upper(func.substr(db.Publishers.\n name, 1, 1)).label('char')).join(db.books_publishers_link).join(db.Books\n ).filter(calibre_db.common_filters()).group_by(func.upper(func.substr(\n db.Publishers.name, 1, 1))).all()\n", "return render_title_template('list.html', entries=entries, folder=\n 'web.books_list', charlist=charlist, title=_(u'Publishers'), page=\n 'publisherlist', data='publisher', order=order_no)\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "Condition", "Condition", "Assign'", "Assign'", "Assign'", "Assign'", "Condition", "Assign'", "Expr'", "Assign'", "Return'" ]
[ "def FUNC_1(VAR_4, VAR_5):...\n", "return json.dumps(FUNC_0(VAR_4, VAR_5)).encode('utf8')\n" ]
[ "def _make_edu_transaction_json(edu_type, content):...\n", "return json.dumps(_expect_edu_transaction(edu_type, content)).encode('utf8')\n" ]
[ 0, 0 ]
[ "FunctionDef'", "Return'" ]
[ "async def FUNC_17(self, VAR_23: Iterable[str], VAR_11: str, VAR_27: str,...\n", "VAR_5, VAR_1, VAR_28 = await self._make_and_verify_event(VAR_23, VAR_11,\n VAR_27, 'leave', VAR_25=content)\n", "VAR_1.internal_metadata.outlier = True\n", "VAR_1.internal_metadata.out_of_band_membership = True\n", "VAR_98 = list(VAR_23)\n", "VAR_98.remove(VAR_5)\n", "await self.federation_client.send_leave(VAR_98, VAR_1)\n", "VAR_98.insert(0, VAR_5)\n", "VAR_32 = await self.state_handler.compute_event_context(VAR_1)\n", "VAR_99 = await self.persist_events_and_notify(VAR_1.room_id, [(VAR_1, VAR_32)])\n", "return VAR_1, VAR_99\n" ]
[ "async def do_remotely_reject_invite(self, target_hosts: Iterable[str],...\n", "origin, event, room_version = await self._make_and_verify_event(target_hosts,\n room_id, user_id, 'leave', content=content)\n", "event.internal_metadata.outlier = True\n", "event.internal_metadata.out_of_band_membership = True\n", "host_list = list(target_hosts)\n", "host_list.remove(origin)\n", "await self.federation_client.send_leave(host_list, event)\n", "host_list.insert(0, origin)\n", "context = await self.state_handler.compute_event_context(event)\n", "stream_id = await self.persist_events_and_notify(event.room_id, [(event,\n context)])\n", "return event, stream_id\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "Condition", "Assign'", "Assign'", "Assign'", "Assign'", "Expr'", "Expr'", "Expr'", "Assign'", "Assign'", "Return'" ]
[ "def FUNC_7(self):...\n", "return 'https://example.com/fake/repo.git'\n" ]
[ "def get_repo_url(self):...\n", "return 'https://example.com/fake/repo.git'\n" ]
[ 0, 0 ]
[ "FunctionDef'", "Return'" ]
[ "def FUNC_5(VAR_20=None):...\n", "\"\"\"docstring\"\"\"\n", "VAR_29 = formatdate(VAR_20)\n", "return '%s-%s-%s GMT' % (VAR_29[:7], VAR_29[8:11], VAR_29[12:25])\n" ]
[ "def cookie_date(epoch_seconds=None):...\n", "\"\"\"docstring\"\"\"\n", "rfcdate = formatdate(epoch_seconds)\n", "return '%s-%s-%s GMT' % (rfcdate[:7], rfcdate[8:11], rfcdate[12:25])\n" ]
[ 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Assign'", "Return'" ]
[ "from __future__ import unicode_literals\n", "import base64\n", "import calendar\n", "import datetime\n", "import re\n", "import sys\n", "from urllib import parse as urllib_parse\n", "import urllib as urllib_parse\n", "from binascii import Error as BinasciiError\n", "import urlparse\n", "from email.utils import formatdate\n", "urllib_parse.urlparse = urlparse.urlparse\n", "from django.utils.datastructures import MultiValueDict\n", "from django.utils.encoding import force_str, force_text\n", "from django.utils.functional import allow_lazy\n", "from django.utils import six\n", "VAR_0 = re.compile('(?:W/)?\"((?:\\\\\\\\.|[^\"])*)\"')\n", "VAR_1 = 'jan feb mar apr may jun jul aug sep oct nov dec'.split()\n", "VAR_2 = '(?P<day>\\\\d{2})'\n", "VAR_3 = '(?P<day>[ \\\\d]\\\\d)'\n", "VAR_4 = '(?P<mon>\\\\w{3})'\n", "VAR_5 = '(?P<year>\\\\d{4})'\n", "VAR_6 = '(?P<year>\\\\d{2})'\n", "VAR_7 = '(?P<hour>\\\\d{2}):(?P<min>\\\\d{2}):(?P<sec>\\\\d{2})'\n", "VAR_8 = re.compile('^\\\\w{3}, %s %s %s %s GMT$' % (VAR_2, VAR_4, VAR_5, VAR_7))\n", "VAR_9 = re.compile('^\\\\w{6,9}, %s-%s-%s %s GMT$' % (VAR_2, VAR_4, VAR_6, VAR_7)\n )\n", "VAR_10 = re.compile('^\\\\w{3} %s %s %s %s$' % (VAR_4, VAR_3, VAR_7, VAR_5))\n", "def FUNC_0(VAR_11, VAR_12='/'):...\n", "\"\"\"docstring\"\"\"\n", "return force_text(urllib_parse.quote(force_str(VAR_11), force_str(VAR_12)))\n" ]
[ "from __future__ import unicode_literals\n", "import base64\n", "import calendar\n", "import datetime\n", "import re\n", "import sys\n", "from urllib import parse as urllib_parse\n", "import urllib as urllib_parse\n", "from binascii import Error as BinasciiError\n", "import urlparse\n", "from email.utils import formatdate\n", "urllib_parse.urlparse = urlparse.urlparse\n", "from django.utils.datastructures import MultiValueDict\n", "from django.utils.encoding import force_str, force_text\n", "from django.utils.functional import allow_lazy\n", "from django.utils import six\n", "ETAG_MATCH = re.compile('(?:W/)?\"((?:\\\\\\\\.|[^\"])*)\"')\n", "MONTHS = 'jan feb mar apr may jun jul aug sep oct nov dec'.split()\n", "__D = '(?P<day>\\\\d{2})'\n", "__D2 = '(?P<day>[ \\\\d]\\\\d)'\n", "__M = '(?P<mon>\\\\w{3})'\n", "__Y = '(?P<year>\\\\d{4})'\n", "__Y2 = '(?P<year>\\\\d{2})'\n", "__T = '(?P<hour>\\\\d{2}):(?P<min>\\\\d{2}):(?P<sec>\\\\d{2})'\n", "RFC1123_DATE = re.compile('^\\\\w{3}, %s %s %s %s GMT$' % (__D, __M, __Y, __T))\n", "RFC850_DATE = re.compile('^\\\\w{6,9}, %s-%s-%s %s GMT$' % (__D, __M, __Y2, __T))\n", "ASCTIME_DATE = re.compile('^\\\\w{3} %s %s %s %s$' % (__M, __D2, __T, __Y))\n", "def urlquote(url, safe='/'):...\n", "\"\"\"docstring\"\"\"\n", "return force_text(urllib_parse.quote(force_str(url), force_str(safe)))\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "ImportFrom'", "Import'", "Import'", "Import'", "Import'", "Import'", "ImportFrom'", "Import'", "ImportFrom'", "Import'", "ImportFrom'", "Assign'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "FunctionDef'", "Docstring", "Return'" ]
[ "@property...\n", "return storage.bucket.name\n" ]
[ "@property...\n", "return storage.bucket.name\n" ]
[ 0, 0 ]
[ "Condition", "Return'" ]
[ "def FUNC_50(VAR_62=None, VAR_9=None, VAR_109=0, VAR_110=None, VAR_111=False,...\n", "\"\"\"docstring\"\"\"\n", "import frappe.model.delete_doc\n", "frappe.model.delete_doc.delete_doc(VAR_62, VAR_9, VAR_109, VAR_110, VAR_111,\n VAR_92, VAR_19, VAR_112, VAR_113, VAR_114)\n" ]
[ "def delete_doc(doctype=None, name=None, force=0, ignore_doctypes=None,...\n", "\"\"\"docstring\"\"\"\n", "import frappe.model.delete_doc\n", "frappe.model.delete_doc.delete_doc(doctype, name, force, ignore_doctypes,\n for_reload, ignore_permissions, flags, ignore_on_trash, ignore_missing,\n delete_permanently)\n" ]
[ 0, 0, 0, 0 ]
[ "Condition", "Docstring", "Import'", "Expr'" ]
[ "def FUNC_34(self):...\n", "VAR_35 = self.hs.get_datastore()\n", "VAR_40 = self.hs.get_pagination_handler()\n", "VAR_41 = self.helper.send(self.room_id, 'message 1')['event_id']\n", "VAR_42 = self.get_success(VAR_35.get_topological_token_for_event(VAR_41))\n", "VAR_43 = self.get_success(VAR_42.to_string(VAR_35))\n", "VAR_44 = self.helper.send(self.room_id, 'message 2')['event_id']\n", "VAR_45 = self.get_success(VAR_35.get_topological_token_for_event(VAR_44))\n", "VAR_46 = self.get_success(VAR_45.to_string(VAR_35))\n", "self.helper.send(self.room_id, 'message 3')\n", "VAR_22, VAR_23 = self.make_request('GET', \n '/rooms/%s/messages?access_token=x&from=%s&dir=b&filter=%s' % (self.\n room_id, VAR_46, json.dumps({'types': [EventTypes.Message]})))\n", "self.assertEqual(VAR_23.code, 200, VAR_23.json_body)\n", "VAR_47 = VAR_23.json_body['chunk']\n", "self.assertEqual(len(VAR_47), 2, [event['content'] for event in VAR_47])\n", "VAR_48 = random_string(16)\n", "VAR_40._purges_by_id[VAR_48] = PurgeStatus()\n", "self.get_success(VAR_40._purge_history(VAR_48=purge_id, VAR_29=self.room_id,\n VAR_39=second_token_str, delete_local_events=True))\n", "VAR_22, VAR_23 = self.make_request('GET', \n '/rooms/%s/messages?access_token=x&from=%s&dir=b&filter=%s' % (self.\n room_id, VAR_46, json.dumps({'types': [EventTypes.Message]})))\n", "self.assertEqual(VAR_23.code, 200, VAR_23.json_body)\n", "VAR_47 = VAR_23.json_body['chunk']\n", "self.assertEqual(len(VAR_47), 1, [event['content'] for event in VAR_47])\n", "VAR_22, VAR_23 = self.make_request('GET', \n '/rooms/%s/messages?access_token=x&from=%s&dir=b&filter=%s' % (self.\n room_id, VAR_43, json.dumps({'types': [EventTypes.Message]})))\n", "self.assertEqual(VAR_23.code, 200, VAR_23.json_body)\n", "VAR_47 = VAR_23.json_body['chunk']\n", "self.assertEqual(len(VAR_47), 0, [event['content'] for event in VAR_47])\n" ]
[ "def test_room_messages_purge(self):...\n", "store = self.hs.get_datastore()\n", "pagination_handler = self.hs.get_pagination_handler()\n", "first_event_id = self.helper.send(self.room_id, 'message 1')['event_id']\n", "first_token = self.get_success(store.get_topological_token_for_event(\n first_event_id))\n", "first_token_str = self.get_success(first_token.to_string(store))\n", "second_event_id = self.helper.send(self.room_id, 'message 2')['event_id']\n", "second_token = self.get_success(store.get_topological_token_for_event(\n second_event_id))\n", "second_token_str = self.get_success(second_token.to_string(store))\n", "self.helper.send(self.room_id, 'message 3')\n", "request, channel = self.make_request('GET', \n '/rooms/%s/messages?access_token=x&from=%s&dir=b&filter=%s' % (self.\n room_id, second_token_str, json.dumps({'types': [EventTypes.Message]})))\n", "self.assertEqual(channel.code, 200, channel.json_body)\n", "chunk = channel.json_body['chunk']\n", "self.assertEqual(len(chunk), 2, [event['content'] for event in chunk])\n", "purge_id = random_string(16)\n", "pagination_handler._purges_by_id[purge_id] = PurgeStatus()\n", "self.get_success(pagination_handler._purge_history(purge_id=purge_id,\n room_id=self.room_id, token=second_token_str, delete_local_events=True))\n", "request, channel = self.make_request('GET', \n '/rooms/%s/messages?access_token=x&from=%s&dir=b&filter=%s' % (self.\n room_id, second_token_str, json.dumps({'types': [EventTypes.Message]})))\n", "self.assertEqual(channel.code, 200, channel.json_body)\n", "chunk = channel.json_body['chunk']\n", "self.assertEqual(len(chunk), 1, [event['content'] for event in chunk])\n", "request, channel = self.make_request('GET', \n '/rooms/%s/messages?access_token=x&from=%s&dir=b&filter=%s' % (self.\n room_id, first_token_str, json.dumps({'types': [EventTypes.Message]})))\n", "self.assertEqual(channel.code, 200, channel.json_body)\n", "chunk = channel.json_body['chunk']\n", "self.assertEqual(len(chunk), 0, [event['content'] for event in chunk])\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Expr'", "Assign'", "Expr'", "Assign'", "Expr'", "Assign'", "Assign'", "Expr'", "Assign'", "Expr'", "Assign'", "Expr'", "Assign'", "Expr'", "Assign'", "Expr'" ]
[ "def FUNC_0(self, VAR_3, VAR_4):...\n", "VAR_4['max_length'] = 255\n", "return django.forms.CharField(**options)\n" ]
[ "def create_singleline_field(self, field, options):...\n", "options['max_length'] = 255\n", "return django.forms.CharField(**options)\n" ]
[ 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Return'" ]
[ "@administrator_required...\n", "VAR_5 = get_object_or_404(VAR_0, pk=user_id)\n", "VAR_6 = UserForm(data=post_data(request), instance=user)\n", "VAR_7 = UserProfileForm(data=post_data(request), instance=user.st)\n", "if is_post(VAR_1) and all([VAR_6.is_valid(), VAR_7.is_valid()]):\n", "VAR_6.save()\n", "return render(VAR_1=request, template_name='spirit/user/admin/edit.html',\n context={'form': form, 'uform': uform})\n", "VAR_7.save()\n", "messages.info(VAR_1, _('This profile has been updated!'))\n", "return redirect(VAR_1.GET.get('next', VAR_1.get_full_path()))\n" ]
[ "@administrator_required...\n", "user = get_object_or_404(User, pk=user_id)\n", "uform = UserForm(data=post_data(request), instance=user)\n", "form = UserProfileForm(data=post_data(request), instance=user.st)\n", "if is_post(request) and all([uform.is_valid(), form.is_valid()]):\n", "uform.save()\n", "return render(request=request, template_name='spirit/user/admin/edit.html',\n context={'form': form, 'uform': uform})\n", "form.save()\n", "messages.info(request, _('This profile has been updated!'))\n", "return redirect(request.GET.get('next', request.get_full_path()))\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 4 ]
[ "Condition", "Assign'", "Assign'", "Assign'", "Condition", "Expr'", "Return'", "Expr'", "Expr'", "Return'" ]
[ "def FUNC_36():...\n", "return FUNC_2(VAR_8, VAR_15=additional_key_data)\n" ]
[ "def cache_key():...\n", "return _cache_key(key, additional_key_data=additional_key_data)\n" ]
[ 0, 0 ]
[ "FunctionDef'", "Return'" ]
[ "def FUNC_7(VAR_13):...\n", "VAR_23 = ['ffprobe', '-v', 'quiet', '-print_format', 'json', '-show_format',\n VAR_13]\n", "VAR_17 = subprocess.Popen(VAR_23, stdout=subprocess.PIPE, bufsize=-1)\n", "VAR_24 = json.load(VAR_17.stdout)\n", "return VAR_24\n" ]
[ "def _ffprobe(video_path):...\n", "cmd_l = ['ffprobe', '-v', 'quiet', '-print_format', 'json', '-show_format',\n video_path]\n", "proc = subprocess.Popen(cmd_l, stdout=subprocess.PIPE, bufsize=-1)\n", "data = json.load(proc.stdout)\n", "return data\n" ]
[ 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Assign'", "Assign'", "Return'" ]
[ "@staticmethod...\n", "if isinstance(VAR_5, int):\n", "return VAR_5\n", "VAR_48 = {'K': 1024, 'M': 1024 * 1024}\n", "VAR_49 = 1\n", "VAR_50 = VAR_5[-1]\n", "if VAR_50 in VAR_48:\n", "VAR_5 = VAR_5[:-1]\n", "return int(VAR_5) * VAR_49\n", "VAR_49 = VAR_48[VAR_50]\n" ]
[ "@staticmethod...\n", "if isinstance(value, int):\n", "return value\n", "sizes = {'K': 1024, 'M': 1024 * 1024}\n", "size = 1\n", "suffix = value[-1]\n", "if suffix in sizes:\n", "value = value[:-1]\n", "return int(value) * size\n", "size = sizes[suffix]\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "Condition", "Condition", "Return'", "Assign'", "Assign'", "Assign'", "Condition", "Assign'", "Return'", "Assign'" ]
[ "@login_required()...\n", "\"\"\"docstring\"\"\"\n", "VAR_15 = VAR_8.getObject('Image', VAR_6)\n", "if VAR_15 is None:\n", "VAR_156 = VAR_15.getImportedImageFilePaths()\n", "return {'repo': VAR_156['server_paths'], 'client': VAR_156['client_paths']}\n" ]
[ "@login_required()...\n", "\"\"\"docstring\"\"\"\n", "image = conn.getObject('Image', iid)\n", "if image is None:\n", "paths = image.getImportedImageFilePaths()\n", "return {'repo': paths['server_paths'], 'client': paths['client_paths']}\n" ]
[ 0, 0, 0, 0, 0, 0 ]
[ "Condition", "Docstring", "Assign'", "Condition", "Assign'", "Return'" ]
[ "def FUNC_4(self, VAR_2: str) ->None:...\n", "VAR_29 = VAR_2.split('/')\n", "VAR_13 = VAR_29[0]\n", "VAR_30 = self._registry.get_component_path(VAR_13)\n", "if VAR_30 is None:\n", "self.write('not found')\n", "VAR_27 = '/'.join(VAR_29[1:])\n", "self.set_status(404)\n", "VAR_16 = os.path.join(VAR_30, VAR_27)\n", "return\n", "VAR_0.debug('ComponentRequestHandler: GET: %s -> %s', VAR_2, VAR_16)\n", "VAR_42 = file.read()\n", "VAR_0.error(f'ComponentRequestHandler: GET {VAR_2} read error', exc_info=e)\n", "self.write(VAR_42)\n", "self.write('read error')\n", "self.set_header('Content-Type', self.get_content_type(VAR_16))\n", "self.set_status(404)\n", "self.set_extra_headers(VAR_2)\n", "return\n" ]
[ "def get(self, path: str) ->None:...\n", "parts = path.split('/')\n", "component_name = parts[0]\n", "component_root = self._registry.get_component_path(component_name)\n", "if component_root is None:\n", "self.write('not found')\n", "filename = '/'.join(parts[1:])\n", "self.set_status(404)\n", "abspath = os.path.join(component_root, filename)\n", "return\n", "LOGGER.debug('ComponentRequestHandler: GET: %s -> %s', path, abspath)\n", "contents = file.read()\n", "LOGGER.error(f'ComponentRequestHandler: GET {path} read error', exc_info=e)\n", "self.write(contents)\n", "self.write('read error')\n", "self.set_header('Content-Type', self.get_content_type(abspath))\n", "self.set_status(404)\n", "self.set_extra_headers(path)\n", "return\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Assign'", "Assign'", "Condition", "Expr'", "Assign'", "Expr'", "Assign'", "Return'", "Expr'", "Assign'", "Expr'", "Expr'", "Expr'", "Expr'", "Expr'", "Expr'", "Return'" ]
[ "@ensure_csrf_cookie...\n", "\"\"\"docstring\"\"\"\n", "VAR_10 = SlashSeparatedCourseKey.from_deprecated_string(VAR_10)\n", "VAR_65 = get_course_by_id(VAR_10)\n", "VAR_136 = has_access(VAR_9.user, 'instructor', VAR_65)\n", "VAR_137 = has_forum_access(VAR_9.user, VAR_10, FORUM_ROLE_ADMINISTRATOR)\n", "VAR_64 = VAR_9.GET.get('rolename')\n", "if not (VAR_137 or VAR_136):\n", "return HttpResponseBadRequest(\n 'Operation requires staff & forum admin or instructor access')\n", "if VAR_64 == FORUM_ROLE_ADMINISTRATOR and not VAR_136:\n", "return HttpResponseBadRequest('Operation requires instructor access.')\n", "if VAR_64 not in [FORUM_ROLE_ADMINISTRATOR, FORUM_ROLE_MODERATOR,\n", "return HttpResponseBadRequest(strip_tags(\"Unrecognized rolename '{}'.\".\n format(VAR_64)))\n", "VAR_190 = Role.objects.get(VAR_16=rolename, VAR_10=course_id)\n", "VAR_191 = []\n", "def FUNC_85(VAR_19):...\n", "VAR_191 = VAR_190.users.all().order_by('username')\n", "\"\"\"docstring\"\"\"\n", "return {'username': VAR_19.username, 'email': VAR_19.email, 'first_name':\n VAR_19.first_name, 'last_name': VAR_19.last_name}\n" ]
[ "@ensure_csrf_cookie...\n", "\"\"\"docstring\"\"\"\n", "course_id = SlashSeparatedCourseKey.from_deprecated_string(course_id)\n", "course = get_course_by_id(course_id)\n", "has_instructor_access = has_access(request.user, 'instructor', course)\n", "has_forum_admin = has_forum_access(request.user, course_id,\n FORUM_ROLE_ADMINISTRATOR)\n", "rolename = request.GET.get('rolename')\n", "if not (has_forum_admin or has_instructor_access):\n", "return HttpResponseBadRequest(\n 'Operation requires staff & forum admin or instructor access')\n", "if rolename == FORUM_ROLE_ADMINISTRATOR and not has_instructor_access:\n", "return HttpResponseBadRequest('Operation requires instructor access.')\n", "if rolename not in [FORUM_ROLE_ADMINISTRATOR, FORUM_ROLE_MODERATOR,\n", "return HttpResponseBadRequest(strip_tags(\"Unrecognized rolename '{}'.\".\n format(rolename)))\n", "role = Role.objects.get(name=rolename, course_id=course_id)\n", "users = []\n", "def extract_user_info(user):...\n", "users = role.users.all().order_by('username')\n", "\"\"\"docstring\"\"\"\n", "return {'username': user.username, 'email': user.email, 'first_name': user.\n first_name, 'last_name': user.last_name}\n" ]
[ 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "Condition", "Docstring", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Condition", "Return'", "Condition", "Return'", "Condition", "Return'", "Assign'", "Assign'", "FunctionDef'", "Assign'", "Docstring", "Return'" ]
[ "def FUNC_114():...\n", "if VAR_32:\n", "if VAR_19.rollback_on_exception:\n", "VAR_12.rollback()\n", "import inspect\n", "if inspect.isclass(VAR_32) and issubclass(VAR_32, Exception):\n" ]
[ "def _raise_exception():...\n", "if raise_exception:\n", "if flags.rollback_on_exception:\n", "db.rollback()\n", "import inspect\n", "if inspect.isclass(raise_exception) and issubclass(raise_exception, Exception):\n" ]
[ 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Condition", "Condition", "Expr'", "Import'", "Condition" ]
[ "def FUNC_0(VAR_0: Text) ->None:...\n", "import coloredlogs\n", "VAR_0 = VAR_0 or os.environ.get(rasa.shared.constants.ENV_LOG_LEVEL, rasa.\n shared.constants.DEFAULT_LOG_LEVEL)\n", "VAR_15 = coloredlogs.DEFAULT_FIELD_STYLES.copy()\n", "VAR_15['asctime'] = {}\n", "VAR_16 = coloredlogs.DEFAULT_LEVEL_STYLES.copy()\n", "VAR_16['debug'] = {}\n", "coloredlogs.install(level=loglevel, use_chroot=False, fmt=\n '%(asctime)s %(levelname)-8s %(name)s - %(message)s', VAR_16=\n level_styles, VAR_15=field_styles)\n" ]
[ "def configure_colored_logging(loglevel: Text) ->None:...\n", "import coloredlogs\n", "loglevel = loglevel or os.environ.get(rasa.shared.constants.ENV_LOG_LEVEL,\n rasa.shared.constants.DEFAULT_LOG_LEVEL)\n", "field_styles = coloredlogs.DEFAULT_FIELD_STYLES.copy()\n", "field_styles['asctime'] = {}\n", "level_styles = coloredlogs.DEFAULT_LEVEL_STYLES.copy()\n", "level_styles['debug'] = {}\n", "coloredlogs.install(level=loglevel, use_chroot=False, fmt=\n '%(asctime)s %(levelname)-8s %(name)s - %(message)s', level_styles=\n level_styles, field_styles=field_styles)\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Import'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Expr'" ]
[ "@VAR_2.route('/ajax/log/<int:logtype>')...\n", "if VAR_26 == 1:\n", "VAR_112 = logger.get_accesslogfile(config.config_access_logfile)\n", "if VAR_26 == 0:\n", "return send_from_directory(os.path.dirname(VAR_112), os.path.basename(VAR_112))\n", "VAR_112 = logger.get_logfile(config.config_logfile)\n", "return ''\n", "return send_from_directory(os.path.dirname(VAR_112), os.path.basename(VAR_112))\n" ]
[ "@admi.route('/ajax/log/<int:logtype>')...\n", "if logtype == 1:\n", "logfile = logger.get_accesslogfile(config.config_access_logfile)\n", "if logtype == 0:\n", "return send_from_directory(os.path.dirname(logfile), os.path.basename(logfile))\n", "logfile = logger.get_logfile(config.config_logfile)\n", "return ''\n", "return send_from_directory(os.path.dirname(logfile), os.path.basename(logfile))\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "Condition", "Condition", "Assign'", "Condition", "Return'", "Assign'", "Return'", "Return'" ]
[ "@VAR_2.route('/ajax/bookmark/<int:book_id>/<book_format>', methods=['POST'])...\n", "VAR_52 = request.form['bookmark']\n", "ub.session.query(ub.Bookmark).filter(and_(ub.Bookmark.user_id == int(VAR_87\n .id), ub.Bookmark.book_id == VAR_5, ub.Bookmark.format == VAR_6)).delete()\n", "if not VAR_52:\n", "ub.session_commit()\n", "VAR_53 = ub.Bookmark(VAR_11=current_user.id, VAR_5=book_id, format=\n book_format, VAR_52=bookmark_key)\n", "return '', 204\n", "ub.session.merge(VAR_53)\n", "ub.session_commit('Bookmark for user {} in book {} created'.format(VAR_87.\n id, VAR_5))\n", "return '', 201\n" ]
[ "@web.route('/ajax/bookmark/<int:book_id>/<book_format>', methods=['POST'])...\n", "bookmark_key = request.form['bookmark']\n", "ub.session.query(ub.Bookmark).filter(and_(ub.Bookmark.user_id == int(\n current_user.id), ub.Bookmark.book_id == book_id, ub.Bookmark.format ==\n book_format)).delete()\n", "if not bookmark_key:\n", "ub.session_commit()\n", "lbookmark = ub.Bookmark(user_id=current_user.id, book_id=book_id, format=\n book_format, bookmark_key=bookmark_key)\n", "return '', 204\n", "ub.session.merge(lbookmark)\n", "ub.session_commit('Bookmark for user {} in book {} created'.format(\n current_user.id, book_id))\n", "return '', 201\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "For", "Assign'", "Expr'", "Condition", "Expr'", "Assign'", "Return'", "Expr'", "Expr'", "Return'" ]
[ "def __call__(self):...\n", "return 'dummy'\n" ]
[ "def __call__(self):...\n", "return 'dummy'\n" ]
[ 0, 0 ]
[ "FunctionDef'", "Return'" ]
[ "def FUNC_13(self, VAR_61):...\n", "VAR_84 = VAR_6('', unquote_plus(VAR_61))\n", "if FUNC_0(VAR_84):\n", "return ''\n", "return VAR_61\n" ]
[ "def _remove_javascript_link(self, link):...\n", "new = _substitute_whitespace('', unquote_plus(link))\n", "if _is_javascript_scheme(new):\n", "return ''\n", "return link\n" ]
[ 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Condition", "Return'", "Return'" ]
[ "def FUNC_6(self, VAR_6):...\n", "VAR_13 = UploadForm(data={'file': ''}, instance=filemodel)\n", "assert VAR_13.is_valid(), VAR_13.errors\n", "assert not VAR_13.has_changed()\n", "assert VAR_13.cleaned_data['file'] == VAR_6.file\n" ]
[ "def test_initial_no_file_uploaded(self, filemodel):...\n", "form = UploadForm(data={'file': ''}, instance=filemodel)\n", "assert form.is_valid(), form.errors\n", "assert not form.has_changed()\n", "assert form.cleaned_data['file'] == filemodel.file\n" ]
[ 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Assert'", "Assert'", "Assert'" ]
[ "def FUNC_9(VAR_10, *VAR_9, **VAR_13):...\n", "VAR_14 = VAR_10.__code__.co_argcount\n", "VAR_181 = VAR_10.__code__.co_varnames[:VAR_14]\n", "VAR_182 = VAR_10.__defaults__ or []\n", "VAR_183 = VAR_181[0:-len(VAR_182)]\n", "VAR_184 = VAR_181[-len(VAR_182):]\n", "VAR_185 = {}\n", "for VAR_308, pos_val in enumerate(VAR_9[:VAR_14]):\n", "VAR_185[VAR_181[VAR_308]] = pos_val\n", "for VAR_390 in VAR_183[len(VAR_185):]:\n", "if VAR_390 in VAR_13:\n", "if len(VAR_185) >= len(VAR_183):\n", "VAR_185[VAR_390] = VAR_13[VAR_390]\n", "for VAR_390 in VAR_184:\n", "if VAR_390 in VAR_13:\n", "return VAR_10(**arg_dict)\n", "VAR_185[VAR_390] = VAR_13[VAR_390]\n" ]
[ "def universal_caller(f, *a, **b):...\n", "c = f.__code__.co_argcount\n", "n = f.__code__.co_varnames[:c]\n", "defaults = f.__defaults__ or []\n", "pos_args = n[0:-len(defaults)]\n", "named_args = n[-len(defaults):]\n", "arg_dict = {}\n", "for pos_index, pos_val in enumerate(a[:c]):\n", "arg_dict[n[pos_index]] = pos_val\n", "for arg_name in pos_args[len(arg_dict):]:\n", "if arg_name in b:\n", "if len(arg_dict) >= len(pos_args):\n", "arg_dict[arg_name] = b[arg_name]\n", "for arg_name in named_args:\n", "if arg_name in b:\n", "return f(**arg_dict)\n", "arg_dict[arg_name] = b[arg_name]\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "For", "Assign'", "For", "Condition", "Condition", "Assign'", "For", "Condition", "Return'", "Assign'" ]
[ "def __init__(self, VAR_21, VAR_26):...\n", "super().__init__(VAR_21, VAR_26)\n", "self.setContext('repeat', CLASS_5(self.repeat_vars))\n", "self.vars = VAR_41 = VAR_26.copy()\n", "self._vars_stack = [VAR_41]\n" ]
[ "def __init__(self, engine, contexts):...\n", "super().__init__(engine, contexts)\n", "self.setContext('repeat', SafeMapping(self.repeat_vars))\n", "self.vars = vars = contexts.copy()\n", "self._vars_stack = [vars]\n" ]
[ 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Expr'", "Expr'", "Assign'", "Assign'" ]
[ "@transaction.non_atomic_requests...\n", "\"\"\"docstring\"\"\"\n", "VAR_10 = SlashSeparatedCourseKey.from_deprecated_string(VAR_10)\n", "VAR_127 = strip_if_string(VAR_9.GET.get('problem_to_reset'))\n", "VAR_128 = VAR_9.GET.get('unique_student_identifier', None)\n", "VAR_40 = None\n", "if VAR_128 is not None:\n", "VAR_40 = get_student_from_identifier(VAR_128)\n", "VAR_129 = VAR_9.GET.get('all_students') in ['true', 'True', True]\n", "if not (VAR_127 and (VAR_129 or VAR_40)):\n", "return HttpResponseBadRequest('Missing query parameters.')\n", "if VAR_129 and VAR_40:\n", "return HttpResponseBadRequest(\n 'Cannot rescore with all_students and unique_student_identifier.')\n", "VAR_188 = VAR_10.make_usage_key_from_deprecated_string(VAR_127)\n", "return HttpResponseBadRequest('Unable to parse problem id')\n", "VAR_63 = {}\n", "VAR_63['problem_to_reset'] = VAR_127\n", "if VAR_40:\n", "VAR_63['student'] = VAR_128\n", "if VAR_129:\n", "instructor_task.api.submit_rescore_problem_for_student(VAR_9, VAR_188, VAR_40)\n", "instructor_task.api.submit_rescore_problem_for_all_students(VAR_9, VAR_188)\n", "return HttpResponseBadRequest()\n", "VAR_63['task'] = 'created'\n", "VAR_63['task'] = 'created'\n", "return JsonResponse(VAR_63)\n" ]
[ "@transaction.non_atomic_requests...\n", "\"\"\"docstring\"\"\"\n", "course_id = SlashSeparatedCourseKey.from_deprecated_string(course_id)\n", "problem_to_reset = strip_if_string(request.GET.get('problem_to_reset'))\n", "student_identifier = request.GET.get('unique_student_identifier', None)\n", "student = None\n", "if student_identifier is not None:\n", "student = get_student_from_identifier(student_identifier)\n", "all_students = request.GET.get('all_students') in ['true', 'True', True]\n", "if not (problem_to_reset and (all_students or student)):\n", "return HttpResponseBadRequest('Missing query parameters.')\n", "if all_students and student:\n", "return HttpResponseBadRequest(\n 'Cannot rescore with all_students and unique_student_identifier.')\n", "module_state_key = course_id.make_usage_key_from_deprecated_string(\n problem_to_reset)\n", "return HttpResponseBadRequest('Unable to parse problem id')\n", "response_payload = {}\n", "response_payload['problem_to_reset'] = problem_to_reset\n", "if student:\n", "response_payload['student'] = student_identifier\n", "if all_students:\n", "instructor_task.api.submit_rescore_problem_for_student(request,\n module_state_key, student)\n", "instructor_task.api.submit_rescore_problem_for_all_students(request,\n module_state_key)\n", "return HttpResponseBadRequest()\n", "response_payload['task'] = 'created'\n", "response_payload['task'] = 'created'\n", "return JsonResponse(response_payload)\n" ]
[ 0, 0, 0, 3, 3, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "Condition", "Docstring", "Assign'", "Assign'", "Assign'", "Assign'", "Condition", "Assign'", "Assign'", "Condition", "Return'", "Condition", "Return'", "Assign'", "Return'", "Assign'", "Assign'", "Condition", "Assign'", "Condition", "Expr'", "Expr'", "Return'", "Assign'", "Assign'", "Return'" ]
[ "def FUNC_7(VAR_8):...\n", "\"\"\"docstring\"\"\"\n", "while True:\n", "VAR_75 = VAR_8.get_frame()\n", "yield b'--frame\\r\\nContent-Type: image/jpeg\\r\\n\\r\\n' + VAR_75 + b'\\r\\n'\n" ]
[ "def gen(camera):...\n", "\"\"\"docstring\"\"\"\n", "while True:\n", "frame = camera.get_frame()\n", "yield b'--frame\\r\\nContent-Type: image/jpeg\\r\\n\\r\\n' + frame + b'\\r\\n'\n" ]
[ 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Condition", "Assign'", "Expr'" ]
[ "def FUNC_49(self, VAR_11=False):...\n", "\"\"\"docstring\"\"\"\n", "frappe.delete_doc(self.doctype, self.name, VAR_11=ignore_permissions, flags\n =self.flags)\n" ]
[ "def delete(self, ignore_permissions=False):...\n", "\"\"\"docstring\"\"\"\n", "frappe.delete_doc(self.doctype, self.name, ignore_permissions=\n ignore_permissions, flags=self.flags)\n" ]
[ 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Expr'" ]
[ "def __init__(self):...\n", "self.var = variables.Variable(1.0, name='my_var')\n", "self.write_var = variables.Variable(1.0, name='write_var')\n" ]
[ "def __init__(self):...\n", "self.var = variables.Variable(1.0, name='my_var')\n", "self.write_var = variables.Variable(1.0, name='write_var')\n" ]
[ 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Assign'" ]
[ "async def FUNC_0(VAR_8: IReactorTime, VAR_9: float, VAR_10:...\n", "\"\"\"docstring\"\"\"\n", "FUNC_2(VAR_11.headers)\n", "VAR_0.warning('{%s} [%s] Timed out reading response - %s %s', VAR_10.txn_id,\n VAR_10.destination, VAR_10.method, VAR_10.uri.decode('ascii'))\n", "VAR_23 = VAR_8.seconds() - VAR_12 / 1000\n", "VAR_46 = treq.text_content(VAR_11, encoding='utf-8')\n", "VAR_0.warning('{%s} [%s] Error reading response %s %s: %s', VAR_10.txn_id,\n VAR_10.destination, VAR_10.method, VAR_10.uri.decode('ascii'), VAR_13)\n", "VAR_0.info('{%s} [%s] Completed request: %d %s in %.2f secs - %s %s',\n VAR_10.txn_id, VAR_10.destination, VAR_11.code, VAR_11.phrase.decode(\n 'ascii', errors='replace'), VAR_23, VAR_10.method, VAR_10.uri.decode(\n 'ascii'))\n", "VAR_46.addCallback(json_decoder.decode)\n", "return VAR_47\n", "VAR_46 = timeout_deferred(VAR_46, VAR_29=timeout_sec, VAR_8=reactor)\n", "VAR_47 = await make_deferred_yieldable(VAR_46)\n" ]
[ "async def _handle_json_response(reactor: IReactorTime, timeout_sec: float,...\n", "\"\"\"docstring\"\"\"\n", "check_content_type_is_json(response.headers)\n", "logger.warning('{%s} [%s] Timed out reading response - %s %s', request.\n txn_id, request.destination, request.method, request.uri.decode('ascii'))\n", "time_taken_secs = reactor.seconds() - start_ms / 1000\n", "d = treq.text_content(response, encoding='utf-8')\n", "logger.warning('{%s} [%s] Error reading response %s %s: %s', request.txn_id,\n request.destination, request.method, request.uri.decode('ascii'), e)\n", "logger.info('{%s} [%s] Completed request: %d %s in %.2f secs - %s %s',\n request.txn_id, request.destination, response.code, response.phrase.\n decode('ascii', errors='replace'), time_taken_secs, request.method,\n request.uri.decode('ascii'))\n", "d.addCallback(json_decoder.decode)\n", "return body\n", "d = timeout_deferred(d, timeout=timeout_sec, reactor=reactor)\n", "body = await make_deferred_yieldable(d)\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "Condition", "Docstring", "Expr'", "Expr'", "Assign'", "Assign'", "Expr'", "Expr'", "Expr'", "Return'", "Assign'", "Assign'" ]
[ "def FUNC_18(self):...\n", "VAR_26 = np.array([[1], [2]])\n", "VAR_31 = os.path.join(test.get_temp_dir(), 'input.npz')\n", "np.savez(VAR_31, VAR_53=x0)\n", "VAR_27 = np.ones([2, 10])\n", "VAR_20 = 'x0=' + VAR_31 + '[a]'\n", "VAR_21 = 'x1=np.ones([2,10])'\n", "VAR_30 = saved_model_cli.load_inputs_from_input_arg_string(VAR_20, VAR_21, '')\n", "self.assertTrue(np.all(VAR_30['x0'] == VAR_26))\n", "self.assertTrue(np.all(VAR_30['x1'] == VAR_27))\n" ]
[ "def testInputParserBoth(self):...\n", "x0 = np.array([[1], [2]])\n", "input_path = os.path.join(test.get_temp_dir(), 'input.npz')\n", "np.savez(input_path, a=x0)\n", "x1 = np.ones([2, 10])\n", "input_str = 'x0=' + input_path + '[a]'\n", "input_expr_str = 'x1=np.ones([2,10])'\n", "feed_dict = saved_model_cli.load_inputs_from_input_arg_string(input_str,\n input_expr_str, '')\n", "self.assertTrue(np.all(feed_dict['x0'] == x0))\n", "self.assertTrue(np.all(feed_dict['x1'] == x1))\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Assign'", "Expr'", "Assign'", "Assign'", "Assign'", "Assign'", "Expr'", "Expr'" ]
[ "def FUNC_15(VAR_26, VAR_27):...\n", "\"\"\"docstring\"\"\"\n", "VAR_35, VAR_36 = urllib_parse.urlparse(VAR_26), urllib_parse.urlparse(VAR_27)\n", "return (VAR_35.scheme, VAR_35.hostname, VAR_35.port) == (VAR_36.scheme,\n VAR_36.hostname, VAR_36.port)\n", "return False\n" ]
[ "def same_origin(url1, url2):...\n", "\"\"\"docstring\"\"\"\n", "p1, p2 = urllib_parse.urlparse(url1), urllib_parse.urlparse(url2)\n", "return (p1.scheme, p1.hostname, p1.port) == (p2.scheme, p2.hostname, p2.port)\n", "return False\n" ]
[ 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Assign'", "Return'", "Return'" ]
[ "def FUNC_36():...\n", "return FUNC_2(VAR_8, VAR_15=additional_key_data)\n" ]
[ "def cache_key():...\n", "return _cache_key(key, additional_key_data=additional_key_data)\n" ]
[ 0, 0 ]
[ "FunctionDef'", "Return'" ]
[ "def FUNC_9(self):...\n", "return self.gist_id\n" ]
[ "def get_build_slug(self):...\n", "return self.gist_id\n" ]
[ 0, 0 ]
[ "FunctionDef'", "Return'" ]
[ "@login_required...\n", "return VAR_13(*VAR_41, **kwargs)\n" ]
[ "@login_required...\n", "return func(*args, **kwargs)\n" ]
[ 0, 0 ]
[ "Condition", "Return'" ]
[ "def FUNC_6(self):...\n", "self.room_members = [VAR_0, VAR_2]\n", "self.assertEquals(self.event_source.get_current_key(), 0)\n", "VAR_20, VAR_21 = self.make_request('PUT',\n '/_matrix/federation/v1/send/1000000', FUNC_1('m.typing', VAR_5={\n 'room_id': ROOM_ID, 'user_id': U_ONION.to_string(), 'typing': True}),\n federation_auth_origin=b'farm')\n", "self.assertEqual(VAR_21.code, 200)\n", "self.on_new_event.assert_has_calls([call('typing_key', 1, rooms=[ROOM_ID])])\n", "self.assertEquals(self.event_source.get_current_key(), 1)\n", "VAR_18 = self.get_success(self.event_source.get_new_events(room_ids=[\n ROOM_ID], from_key=0))\n", "self.assertEquals(VAR_18[0], [{'type': 'm.typing', 'room_id': VAR_3,\n 'content': {'user_ids': [VAR_2.to_string()]}}])\n" ]
[ "def test_started_typing_remote_recv(self):...\n", "self.room_members = [U_APPLE, U_ONION]\n", "self.assertEquals(self.event_source.get_current_key(), 0)\n", "request, channel = self.make_request('PUT',\n '/_matrix/federation/v1/send/1000000', _make_edu_transaction_json(\n 'm.typing', content={'room_id': ROOM_ID, 'user_id': U_ONION.to_string(),\n 'typing': True}), federation_auth_origin=b'farm')\n", "self.assertEqual(channel.code, 200)\n", "self.on_new_event.assert_has_calls([call('typing_key', 1, rooms=[ROOM_ID])])\n", "self.assertEquals(self.event_source.get_current_key(), 1)\n", "events = self.get_success(self.event_source.get_new_events(room_ids=[\n ROOM_ID], from_key=0))\n", "self.assertEquals(events[0], [{'type': 'm.typing', 'room_id': ROOM_ID,\n 'content': {'user_ids': [U_ONION.to_string()]}}])\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Expr'", "Assign'", "Expr'", "Expr'", "Expr'", "Assign'", "Expr'" ]
[ "def FUNC_4(self):...\n", "\"\"\"docstring\"\"\"\n", "if not getattr(self, '_metaclass', False) and self.meta.issingle:\n", "VAR_80 = frappe.db.get_singles_dict(self.doctype)\n", "VAR_21 = frappe.db.get_value(self.doctype, self.name, '*', as_dict=1,\n for_update=self.flags.for_update)\n", "if not VAR_80:\n", "if not VAR_21:\n", "VAR_80 = frappe.new_doc(self.doctype).as_dict()\n", "super(CLASS_0, self).__init__(VAR_80)\n", "frappe.throw(_('{0} {1} not found').format(_(self.doctype), self.name),\n frappe.DoesNotExistError)\n", "super(CLASS_0, self).__init__(VAR_21)\n", "VAR_80['name'] = self.doctype\n", "self.init_valid_columns()\n", "if self.name == 'DocType' and self.doctype == 'DocType':\n", "self._fix_numeric_types()\n", "from frappe.model.meta import DOCTYPE_TABLE_FIELDS\n", "VAR_81 = self.meta.get_table_fields()\n", "VAR_81 = DOCTYPE_TABLE_FIELDS\n", "for VAR_19 in VAR_81:\n", "VAR_50 = frappe.db.get_values(VAR_19.options, {'parent': self.name,\n 'parenttype': self.doctype, 'parentfield': VAR_19.fieldname}, '*',\n as_dict=True, order_by='idx asc')\n", "if hasattr(self, '__setup__'):\n", "if VAR_50:\n", "self.__setup__()\n", "self.set(VAR_19.fieldname, VAR_50)\n", "self.set(VAR_19.fieldname, [])\n" ]
[ "def load_from_db(self):...\n", "\"\"\"docstring\"\"\"\n", "if not getattr(self, '_metaclass', False) and self.meta.issingle:\n", "single_doc = frappe.db.get_singles_dict(self.doctype)\n", "d = frappe.db.get_value(self.doctype, self.name, '*', as_dict=1, for_update\n =self.flags.for_update)\n", "if not single_doc:\n", "if not d:\n", "single_doc = frappe.new_doc(self.doctype).as_dict()\n", "super(Document, self).__init__(single_doc)\n", "frappe.throw(_('{0} {1} not found').format(_(self.doctype), self.name),\n frappe.DoesNotExistError)\n", "super(Document, self).__init__(d)\n", "single_doc['name'] = self.doctype\n", "self.init_valid_columns()\n", "if self.name == 'DocType' and self.doctype == 'DocType':\n", "self._fix_numeric_types()\n", "from frappe.model.meta import DOCTYPE_TABLE_FIELDS\n", "table_fields = self.meta.get_table_fields()\n", "table_fields = DOCTYPE_TABLE_FIELDS\n", "for df in table_fields:\n", "children = frappe.db.get_values(df.options, {'parent': self.name,\n 'parenttype': self.doctype, 'parentfield': df.fieldname}, '*', as_dict=\n True, order_by='idx asc')\n", "if hasattr(self, '__setup__'):\n", "if children:\n", "self.__setup__()\n", "self.set(df.fieldname, children)\n", "self.set(df.fieldname, [])\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Condition", "Assign'", "Assign'", "Condition", "Condition", "Assign'", "Expr'", "Expr'", "Expr'", "Assign'", "Expr'", "Condition", "Expr'", "ImportFrom'", "Assign'", "Assign'", "For", "Assign'", "Condition", "Condition", "Expr'", "Expr'", "Expr'" ]
[ "def FUNC_26(self, VAR_23, VAR_24, VAR_25, VAR_26=False):...\n", "VAR_73 = self.playlistdb.savePlaylist(VAR_15=self.getUserId(), VAR_24=1 if\n public else 0, VAR_23=playlist, playlisttitle=playlistname, VAR_26=\n overwrite)\n", "if VAR_73 == 'success':\n", "return VAR_73\n" ]
[ "def api_saveplaylist(self, playlist, public, playlistname, overwrite=False):...\n", "res = self.playlistdb.savePlaylist(userid=self.getUserId(), public=1 if\n public else 0, playlist=playlist, playlisttitle=playlistname, overwrite\n =overwrite)\n", "if res == 'success':\n", "return res\n" ]
[ 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Condition", "Return'" ]
[ "def FUNC_26(self):...\n", "self.other_id = '@zzsid1:red'\n", "VAR_32 = '/rooms/%s/state/m.room.member/%s' % (urlparse.quote(self.room_id),\n self.other_id)\n", "VAR_19 = '{\"membership\":\"%s\",\"invite_text\":\"%s\"}' % (Membership.INVITE,\n 'Join us!')\n", "VAR_22, VAR_23 = self.make_request('PUT', VAR_32, VAR_19)\n", "self.assertEquals(200, VAR_23.code, msg=channel.result['body'])\n", "VAR_22, VAR_23 = self.make_request('GET', VAR_32, None)\n", "self.assertEquals(200, VAR_23.code, msg=channel.result['body'])\n", "self.assertEquals(json.loads(VAR_19), VAR_23.json_body)\n" ]
[ "def test_rooms_members_other_custom_keys(self):...\n", "self.other_id = '@zzsid1:red'\n", "path = '/rooms/%s/state/m.room.member/%s' % (urlparse.quote(self.room_id),\n self.other_id)\n", "content = '{\"membership\":\"%s\",\"invite_text\":\"%s\"}' % (Membership.INVITE,\n 'Join us!')\n", "request, channel = self.make_request('PUT', path, content)\n", "self.assertEquals(200, channel.code, msg=channel.result['body'])\n", "request, channel = self.make_request('GET', path, None)\n", "self.assertEquals(200, channel.code, msg=channel.result['body'])\n", "self.assertEquals(json.loads(content), channel.json_body)\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Assign'", "Assign'", "Assign'", "Expr'", "Assign'", "Expr'", "Expr'" ]
[ "async def FUNC_16(self, VAR_5: str, VAR_1: EventBase, VAR_28: RoomVersion):...\n", "\"\"\"docstring\"\"\"\n", "if VAR_1.state_key is None:\n", "VAR_96 = await self.store.is_room_blocked(VAR_1.room_id)\n", "if VAR_96:\n", "if self.hs.config.block_non_admin_invites:\n", "if not self.spam_checker.user_may_invite(VAR_1.sender, VAR_1.state_key,\n", "VAR_29 = VAR_1.content.get('membership')\n", "if VAR_1.type != VAR_188.Member or VAR_29 != Membership.INVITE:\n", "VAR_97 = get_domain_from_id(VAR_1.sender)\n", "if VAR_97 != VAR_5:\n", "if not self.is_mine_id(VAR_1.state_key):\n", "if VAR_1.state_key == self._server_notices_mxid:\n", "await self._maybe_store_room_on_outlier_membership(VAR_11=event.room_id,\n VAR_28=room_version)\n", "VAR_1.internal_metadata.outlier = True\n", "VAR_1.internal_metadata.out_of_band_membership = True\n", "VAR_1.signatures.update(compute_event_signature(VAR_28, VAR_1.get_pdu_json(\n ), self.hs.hostname, self.hs.signing_key))\n", "VAR_32 = await self.state_handler.compute_event_context(VAR_1)\n", "await self.persist_events_and_notify(VAR_1.room_id, [(VAR_1, VAR_32)])\n", "return VAR_1\n" ]
[ "async def on_invite_request(self, origin: str, event: EventBase,...\n", "\"\"\"docstring\"\"\"\n", "if event.state_key is None:\n", "is_blocked = await self.store.is_room_blocked(event.room_id)\n", "if is_blocked:\n", "if self.hs.config.block_non_admin_invites:\n", "if not self.spam_checker.user_may_invite(event.sender, event.state_key,\n", "membership = event.content.get('membership')\n", "if event.type != EventTypes.Member or membership != Membership.INVITE:\n", "sender_domain = get_domain_from_id(event.sender)\n", "if sender_domain != origin:\n", "if not self.is_mine_id(event.state_key):\n", "if event.state_key == self._server_notices_mxid:\n", "await self._maybe_store_room_on_outlier_membership(room_id=event.room_id,\n room_version=room_version)\n", "event.internal_metadata.outlier = True\n", "event.internal_metadata.out_of_band_membership = True\n", "event.signatures.update(compute_event_signature(room_version, event.\n get_pdu_json(), self.hs.hostname, self.hs.signing_key))\n", "context = await self.state_handler.compute_event_context(event)\n", "await self.persist_events_and_notify(event.room_id, [(event, context)])\n", "return event\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "AsyncFunctionDef'", "Docstring", "Condition", "Assign'", "Condition", "Condition", "Condition", "Assign'", "Condition", "Assign'", "Condition", "Condition", "Condition", "Expr'", "Assign'", "Assign'", "Expr'", "Assign'", "Expr'", "Return'" ]
[ "def FUNC_70(VAR_43):...\n", "\"\"\"docstring\"\"\"\n", "return json.load(f)\n" ]
[ "def get_file_json(path):...\n", "\"\"\"docstring\"\"\"\n", "return json.load(f)\n" ]
[ 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Return'" ]
[ "def FUNC_0(VAR_1: bytes) ->bool:...\n", "\"\"\"docstring\"\"\"\n", "VAR_14 = VAR_1.decode('ascii')\n", "IPAddress(VAR_14)\n", "return False\n", "return True\n" ]
[ "def _is_ip_literal(host: bytes) ->bool:...\n", "\"\"\"docstring\"\"\"\n", "host_str = host.decode('ascii')\n", "IPAddress(host_str)\n", "return False\n", "return True\n" ]
[ 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Assign'", "Expr'", "Return'", "Return'" ]
[ "async def FUNC_15(VAR_20):...\n", "" ]
[ "async def get_key(key_server):...\n", "" ]
[ 0, 0 ]
[ "AsyncFunctionDef'", "Condition" ]
[ "@VAR_0.route('/cli')...\n", "return render_template('cli.html')\n" ]
[ "@gui.route('/cli')...\n", "return render_template('cli.html')\n" ]
[ 0, 0 ]
[ "Condition", "Return'" ]
[ "from __future__ import absolute_import, division, unicode_literals\n", "from six import text_type\n", "import re\n", "from ..constants import voidElements, booleanAttributes, spaceCharacters\n", "from ..constants import rcdataElements, entities, xmlEntities\n", "from .. import utils\n", "from xml.sax.saxutils import escape\n", "VAR_0 = ''.join(VAR_0)\n", "VAR_1 = re.compile('[' + VAR_0 + '\"\\'=<>`]')\n", "from codecs import register_error, xmlcharrefreplace_errors\n", "VAR_3 = 'strict'\n", "VAR_3 = 'htmlentityreplace'\n", "VAR_7 = False\n", "VAR_4 = {}\n", "VAR_8 = '\"'\n", "VAR_5 = len('\\U0010ffff') == 1\n", "VAR_9 = True\n", "for VAR_38, VAR_32 in list(entities.items()):\n", "VAR_10 = True\n", "if VAR_5 and len(VAR_32) > 1 or not VAR_5 and len(VAR_32) > 2:\n", "def FUNC_1(VAR_6):...\n", "VAR_11 = True\n", "if VAR_32 != '&':\n", "if isinstance(VAR_6, (UnicodeEncodeError, UnicodeTranslateError)):\n", "VAR_12 = False\n", "if len(VAR_32) == 2:\n", "VAR_28 = []\n", "return xmlcharrefreplace_errors(VAR_6)\n", "VAR_13 = True\n", "VAR_32 = utils.surrogatePairToCodepoint(VAR_32)\n", "VAR_32 = ord(VAR_32)\n", "VAR_29 = []\n", "VAR_14 = False\n", "if VAR_32 not in VAR_4 or VAR_38.islower():\n", "VAR_30 = False\n", "VAR_15 = False\n", "VAR_4[VAR_32] = VAR_38\n", "for i, c in enumerate(VAR_6.object[VAR_6.start:VAR_6.end]):\n", "VAR_16 = True\n", "if VAR_30:\n", "for cp in VAR_29:\n", "VAR_17 = False\n", "VAR_30 = False\n", "VAR_33 = i + VAR_6.start\n", "VAR_34 = VAR_4.get(cp)\n", "return ''.join(VAR_28), VAR_6.end\n", "VAR_18 = True\n", "if utils.isSurrogatePair(VAR_6.object[VAR_33:min([VAR_6.end, VAR_33 + 2])]):\n", "if VAR_34:\n", "VAR_19 = False\n", "VAR_36 = utils.surrogatePairToCodepoint(VAR_6.object[VAR_33:VAR_33 + 2])\n", "VAR_36 = ord(c)\n", "VAR_28.append('&')\n", "VAR_28.append('&#x%s;' % hex(cp)[2:])\n", "VAR_20 = False\n", "VAR_30 = True\n", "VAR_29.append(VAR_36)\n", "VAR_28.append(VAR_34)\n", "VAR_21 = ('quote_attr_values', 'quote_char', 'use_best_quote_char',\n 'omit_optional_tags', 'minimize_boolean_attributes',\n 'use_trailing_solidus', 'space_before_trailing_solidus',\n 'escape_lt_in_attrs', 'escape_rcdata', 'resolve_entities',\n 'alphabetical_attributes', 'inject_meta_charset', 'strip_whitespace',\n 'sanitize')\n", "if not VAR_34.endswith(';'):\n", "def __init__(self, **VAR_22):...\n", "VAR_28.append(';')\n", "\"\"\"docstring\"\"\"\n", "if 'quote_char' in VAR_22:\n", "self.use_best_quote_char = False\n", "for attr in self.options:\n", "setattr(self, attr, VAR_22.get(attr, getattr(self, attr)))\n", "self.errors = []\n", "self.strict = False\n", "def FUNC_2(self, VAR_23):...\n", "assert isinstance(VAR_23, text_type)\n", "if self.encoding:\n", "return VAR_23.encode(self.encoding, VAR_3)\n", "return VAR_23\n" ]
[ "from __future__ import absolute_import, division, unicode_literals\n", "from six import text_type\n", "import re\n", "from ..constants import voidElements, booleanAttributes, spaceCharacters\n", "from ..constants import rcdataElements, entities, xmlEntities\n", "from .. import utils\n", "from xml.sax.saxutils import escape\n", "spaceCharacters = ''.join(spaceCharacters)\n", "quoteAttributeSpec = re.compile('[' + spaceCharacters + '\"\\'=<>`]')\n", "from codecs import register_error, xmlcharrefreplace_errors\n", "unicode_encode_errors = 'strict'\n", "unicode_encode_errors = 'htmlentityreplace'\n", "quote_attr_values = False\n", "encode_entity_map = {}\n", "quote_char = '\"'\n", "is_ucs4 = len('\\U0010ffff') == 1\n", "use_best_quote_char = True\n", "for k, v in list(entities.items()):\n", "omit_optional_tags = True\n", "if is_ucs4 and len(v) > 1 or not is_ucs4 and len(v) > 2:\n", "def htmlentityreplace_errors(exc):...\n", "minimize_boolean_attributes = True\n", "if v != '&':\n", "if isinstance(exc, (UnicodeEncodeError, UnicodeTranslateError)):\n", "use_trailing_solidus = False\n", "if len(v) == 2:\n", "res = []\n", "return xmlcharrefreplace_errors(exc)\n", "space_before_trailing_solidus = True\n", "v = utils.surrogatePairToCodepoint(v)\n", "v = ord(v)\n", "codepoints = []\n", "escape_lt_in_attrs = False\n", "if v not in encode_entity_map or k.islower():\n", "skip = False\n", "escape_rcdata = False\n", "encode_entity_map[v] = k\n", "for i, c in enumerate(exc.object[exc.start:exc.end]):\n", "resolve_entities = True\n", "if skip:\n", "for cp in codepoints:\n", "alphabetical_attributes = False\n", "skip = False\n", "index = i + exc.start\n", "e = encode_entity_map.get(cp)\n", "return ''.join(res), exc.end\n", "inject_meta_charset = True\n", "if utils.isSurrogatePair(exc.object[index:min([exc.end, index + 2])]):\n", "if e:\n", "strip_whitespace = False\n", "codepoint = utils.surrogatePairToCodepoint(exc.object[index:index + 2])\n", "codepoint = ord(c)\n", "res.append('&')\n", "res.append('&#x%s;' % hex(cp)[2:])\n", "sanitize = False\n", "skip = True\n", "codepoints.append(codepoint)\n", "res.append(e)\n", "options = ('quote_attr_values', 'quote_char', 'use_best_quote_char',\n 'omit_optional_tags', 'minimize_boolean_attributes',\n 'use_trailing_solidus', 'space_before_trailing_solidus',\n 'escape_lt_in_attrs', 'escape_rcdata', 'resolve_entities',\n 'alphabetical_attributes', 'inject_meta_charset', 'strip_whitespace',\n 'sanitize')\n", "if not e.endswith(';'):\n", "def __init__(self, **kwargs):...\n", "res.append(';')\n", "\"\"\"docstring\"\"\"\n", "if 'quote_char' in kwargs:\n", "self.use_best_quote_char = False\n", "for attr in self.options:\n", "setattr(self, attr, kwargs.get(attr, getattr(self, attr)))\n", "self.errors = []\n", "self.strict = False\n", "def encode(self, string):...\n", "assert isinstance(string, text_type)\n", "if self.encoding:\n", "return string.encode(self.encoding, unicode_encode_errors)\n", "return string\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "ImportFrom'", "ImportFrom'", "Import'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "Assign'", "Assign'", "ImportFrom'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "For", "Assign'", "Condition", "FunctionDef'", "Assign'", "Condition", "Condition", "Assign'", "Condition", "Assign'", "Return'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Condition", "Assign'", "Assign'", "Assign'", "For", "Assign'", "Condition", "For", "Assign'", "Assign'", "Assign'", "Assign'", "Return'", "Assign'", "Condition", "Condition", "Assign'", "Assign'", "Assign'", "Expr'", "Expr'", "Assign'", "Assign'", "Expr'", "Expr'", "Assign'", "Condition", "FunctionDef'", "Expr'", "Docstring", "Condition", "Assign'", "For", "Expr'", "Assign'", "Assign'", "FunctionDef'", "Assert'", "Condition", "Return'", "Return'" ]
[ "@staticmethod...\n", "if VAR_112:\n", "VAR_350 = VAR_112.split('/')\n", "return None\n", "if ':' not in VAR_350[0] and VAR_350[:2] != ['', '']:\n", "return VAR_112\n", "if len(VAR_350) > 2 and VAR_350[0].endswith(':') and VAR_350[1:3] == ['',\n", "return VAR_112\n" ]
[ "@staticmethod...\n", "if next:\n", "parts = next.split('/')\n", "return None\n", "if ':' not in parts[0] and parts[:2] != ['', '']:\n", "return next\n", "if len(parts) > 2 and parts[0].endswith(':') and parts[1:3] == ['', host]:\n", "return next\n" ]
[ 4, 4, 4, 4, 4, 4, 4, 4 ]
[ "Condition", "Condition", "Assign'", "Return'", "Condition", "Return'", "Condition", "Return'" ]
[ "async def FUNC_23():...\n", "context_12.request = 'context_12'\n", "VAR_53 = VAR_4.verify_json_objects_for_server([('server10', VAR_21, 0, 'test')]\n )\n", "VAR_53[0].addBoth(self.check_context, None)\n", "VAR_25[0] = 1\n", "await make_deferred_yieldable(VAR_53[0])\n", "VAR_25[0] = 2\n" ]
[ "async def second_lookup():...\n", "context_12.request = 'context_12'\n", "res_deferreds_2 = kr.verify_json_objects_for_server([('server10', json1, 0,\n 'test')])\n", "res_deferreds_2[0].addBoth(self.check_context, None)\n", "second_lookup_state[0] = 1\n", "await make_deferred_yieldable(res_deferreds_2[0])\n", "second_lookup_state[0] = 2\n" ]
[ 0, 0, 0, 0, 0, 0, 0 ]
[ "AsyncFunctionDef'", "Assign'", "Assign'", "Expr'", "Assign'", "Expr'", "Assign'" ]
[ "def FUNC_57(VAR_20):...\n", "return '.' in VAR_20 and VAR_20.rsplit('.', 1)[1].lower() in VAR_6\n" ]
[ "def allowed_file(filename):...\n", "return '.' in filename and filename.rsplit('.', 1)[1].lower(\n ) in ALLOWED_EXTENSIONS\n" ]
[ 0, 0 ]
[ "FunctionDef'", "Return'" ]
[ "@FUNC_0...\n", "return ApplicationServiceApi(self)\n" ]
[ "@cache_in_self...\n", "return ApplicationServiceApi(self)\n" ]
[ 0, 0 ]
[ "Condition", "Return'" ]
[ "def FUNC_3(VAR_3: Union[Text, Path]) ->Any:...\n", "\"\"\"docstring\"\"\"\n", "return pickle.load(VAR_18)\n" ]
[ "def pickle_load(filename: Union[Text, Path]) ->Any:...\n", "\"\"\"docstring\"\"\"\n", "return pickle.load(f)\n" ]
[ 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Return'" ]
[ "\"\"\"\nDefines helper methods useful for setting up ports, launching servers, and handling `ngrok`\n\"\"\"\n", "import os\n", "import socket\n", "import threading\n", "from flask import Flask, request, session, jsonify, abort, send_file, render_template, redirect\n", "from flask_cachebuster import CacheBuster\n", "from flask_login import LoginManager, login_user, current_user, login_required\n", "from flask_cors import CORS\n", "import threading\n", "import pkg_resources\n", "import datetime\n", "import time\n", "import json\n", "import urllib.request\n", "from shutil import copyfile\n", "import requests\n", "import sys\n", "import csv\n", "import logging\n", "from gradio.tunneling import create_tunnel\n", "from gradio import encryptor\n", "from gradio import queue\n", "from functools import wraps\n", "import io\n", "import inspect\n", "import traceback\n", "from werkzeug.security import safe_join\n", "VAR_0 = int(os.getenv('GRADIO_SERVER_PORT', '7860'))\n", "VAR_1 = int(os.getenv('GRADIO_NUM_PORTS', '100'))\n", "VAR_2 = os.getenv('GRADIO_SERVER_NAME', '127.0.0.1')\n", "VAR_3 = 'https://api.gradio.app/v1/tunnel-request'\n", "VAR_4 = 'https://api.gradio.app/gradio-feature-analytics/'\n", "VAR_5 = pkg_resources.resource_filename('gradio', 'templates/')\n", "VAR_6 = pkg_resources.resource_filename('gradio', 'templates/frontend/static')\n", "VAR_7 = pkg_resources.resource_filename('gradio', 'version.txt')\n", "VAR_39 = 'https://gradio.s3-us-west-2.amazonaws.com/' + version_file.read(\n ).strip() + '/static/'\n", "VAR_8 = Flask(__name__, template_folder=STATIC_TEMPLATE_LIB, static_folder=\n '', static_url_path='/none/')\n", "VAR_8.url_map.strict_slashes = False\n", "CORS(VAR_8)\n", "VAR_9 = CacheBuster(VAR_78={'extensions': ['.js', '.css'], 'hash_size': 5})\n", "VAR_9.init_app(VAR_8)\n", "VAR_8.secret_key = os.getenv('GRADIO_KEY', 'secret')\n", "VAR_10 = LoginManager()\n", "VAR_10.login_view = 'login'\n", "VAR_10.init_app(VAR_8)\n", "VAR_11 = sys.modules['flask.cli']\n", "VAR_11.show_server_banner = lambda *x: None\n", "def __init__(self, VAR_40):...\n", "self.is_authenticated = True\n", "self.is_active = True\n", "self.is_anonymous = False\n", "self.id = VAR_40\n", "def FUNC_28(self):...\n", "return self.id\n" ]
[ "\"\"\"\nDefines helper methods useful for setting up ports, launching servers, and handling `ngrok`\n\"\"\"\n", "import os\n", "import socket\n", "import threading\n", "from flask import Flask, request, session, jsonify, abort, send_file, render_template, redirect\n", "from flask_cachebuster import CacheBuster\n", "from flask_login import LoginManager, login_user, current_user, login_required\n", "from flask_cors import CORS\n", "import threading\n", "import pkg_resources\n", "import datetime\n", "import time\n", "import json\n", "import urllib.request\n", "from shutil import copyfile\n", "import requests\n", "import sys\n", "import csv\n", "import logging\n", "from gradio.tunneling import create_tunnel\n", "from gradio import encryptor\n", "from gradio import queue\n", "from functools import wraps\n", "import io\n", "import inspect\n", "import traceback\n", "from werkzeug.security import safe_join\n", "INITIAL_PORT_VALUE = int(os.getenv('GRADIO_SERVER_PORT', '7860'))\n", "TRY_NUM_PORTS = int(os.getenv('GRADIO_NUM_PORTS', '100'))\n", "LOCALHOST_NAME = os.getenv('GRADIO_SERVER_NAME', '127.0.0.1')\n", "GRADIO_API_SERVER = 'https://api.gradio.app/v1/tunnel-request'\n", "GRADIO_FEATURE_ANALYTICS_URL = (\n 'https://api.gradio.app/gradio-feature-analytics/')\n", "STATIC_TEMPLATE_LIB = pkg_resources.resource_filename('gradio', 'templates/')\n", "STATIC_PATH_LIB = pkg_resources.resource_filename('gradio',\n 'templates/frontend/static')\n", "VERSION_FILE = pkg_resources.resource_filename('gradio', 'version.txt')\n", "GRADIO_STATIC_ROOT = ('https://gradio.s3-us-west-2.amazonaws.com/' +\n version_file.read().strip() + '/static/')\n", "app = Flask(__name__, template_folder=STATIC_TEMPLATE_LIB, static_folder='',\n static_url_path='/none/')\n", "app.url_map.strict_slashes = False\n", "CORS(app)\n", "cache_buster = CacheBuster(config={'extensions': ['.js', '.css'],\n 'hash_size': 5})\n", "cache_buster.init_app(app)\n", "app.secret_key = os.getenv('GRADIO_KEY', 'secret')\n", "login_manager = LoginManager()\n", "login_manager.login_view = 'login'\n", "login_manager.init_app(app)\n", "cli = sys.modules['flask.cli']\n", "cli.show_server_banner = lambda *x: None\n", "def __init__(self, id):...\n", "self.is_authenticated = True\n", "self.is_active = True\n", "self.is_anonymous = False\n", "self.id = id\n", "def get_id(self):...\n", "return self.id\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "Expr'", "Import'", "Import'", "Import'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "Import'", "Import'", "Import'", "Import'", "Import'", "Import'", "ImportFrom'", "Import'", "Import'", "Import'", "Import'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "Import'", "Import'", "Import'", "ImportFrom'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Expr'", "Assign'", "Expr'", "Assign'", "Assign'", "Assign'", "Expr'", "Assign'", "Assign'", "FunctionDef'", "Assign'", "Assign'", "Assign'", "Assign'", "FunctionDef'", "Return'" ]
[ "def FUNC_11(self, VAR_3, VAR_4):...\n", "return django.forms.BooleanField(**options)\n" ]
[ "def create_checkbox_field(self, field, options):...\n", "return django.forms.BooleanField(**options)\n" ]
[ 0, 0 ]
[ "FunctionDef'", "Return'" ]
[ "def FUNC_168(*VAR_9, **VAR_13):...\n", "VAR_27 = None\n", "VAR_27 = VAR_10(*VAR_9, **b)\n", "thread.start_new_thread(VAR_26, (VAR_27,))\n", "return VAR_27\n" ]
[ "def __completion(*a, **b):...\n", "d = None\n", "d = f(*a, **b)\n", "thread.start_new_thread(callback, (d,))\n", "return d\n" ]
[ 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Assign'", "Expr'", "Return'" ]
[ "@VAR_2.route('/ajax/togglearchived/<int:book_id>', methods=['POST'])...\n", "VAR_54 = change_archived_books(VAR_5, message='Book {} archivebit toggled'.\n format(book_id))\n", "if VAR_54:\n", "remove_synced_book(VAR_5)\n", "return ''\n" ]
[ "@web.route('/ajax/togglearchived/<int:book_id>', methods=['POST'])...\n", "is_archived = change_archived_books(book_id, message=\n 'Book {} archivebit toggled'.format(book_id))\n", "if is_archived:\n", "remove_synced_book(book_id)\n", "return ''\n" ]
[ 0, 0, 0, 0, 0 ]
[ "Condition", "Assign'", "Condition", "Expr'", "Return'" ]
[ "def FUNC_100(VAR_62, VAR_9):...\n", "VAR_136 = (\n '<a href=\"/app/Form/{doctype}/{name}\" style=\"font-weight: bold;\">{doctype_local} {name}</a>'\n )\n", "return VAR_136.format(VAR_62=doctype, VAR_9=name, doctype_local=_(doctype))\n" ]
[ "def get_desk_link(doctype, name):...\n", "html = (\n '<a href=\"/app/Form/{doctype}/{name}\" style=\"font-weight: bold;\">{doctype_local} {name}</a>'\n )\n", "return html.format(doctype=doctype, name=name, doctype_local=_(doctype))\n" ]
[ 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Return'" ]
[ "\"\"\"Tests REST events for /rooms paths.\"\"\"\n", "import json\n", "from urllib import parse as urlparse\n", "from mock import Mock\n", "import synapse.rest.admin\n", "from synapse.api.constants import EventContentFields, EventTypes, Membership\n", "from synapse.handlers.pagination import PurgeStatus\n", "from synapse.rest.client.v1 import directory, login, profile, room\n", "from synapse.rest.client.v2_alpha import account\n", "from synapse.types import JsonDict, RoomAlias, UserID\n", "from synapse.util.stringutils import random_string\n", "from tests import unittest\n", "from tests.test_utils import make_awaitable\n", "VAR_0 = b'/_matrix/client/api/v1'\n", "VAR_1 = None\n", "VAR_2 = [VAR_7.register_servlets, VAR_7.register_deprecated_servlets]\n", "def FUNC_0(self, VAR_3, VAR_4):...\n", "self.hs = self.setup_test_homeserver('red', http_client=None,\n federation_client=Mock())\n", "self.hs.get_federation_handler = Mock()\n", "self.hs.get_federation_handler.return_value.maybe_backfill = Mock(return_value\n =make_awaitable(None))\n", "async def FUNC_76(*VAR_20, **VAR_21):...\n", "return None\n" ]
[ "\"\"\"Tests REST events for /rooms paths.\"\"\"\n", "import json\n", "from urllib import parse as urlparse\n", "from mock import Mock\n", "import synapse.rest.admin\n", "from synapse.api.constants import EventContentFields, EventTypes, Membership\n", "from synapse.handlers.pagination import PurgeStatus\n", "from synapse.rest.client.v1 import directory, login, profile, room\n", "from synapse.rest.client.v2_alpha import account\n", "from synapse.types import JsonDict, RoomAlias, UserID\n", "from synapse.util.stringutils import random_string\n", "from tests import unittest\n", "from tests.test_utils import make_awaitable\n", "PATH_PREFIX = b'/_matrix/client/api/v1'\n", "rmcreator_id = None\n", "servlets = [room.register_servlets, room.register_deprecated_servlets]\n", "def make_homeserver(self, reactor, clock):...\n", "self.hs = self.setup_test_homeserver('red', http_client=None,\n federation_client=Mock())\n", "self.hs.get_federation_handler = Mock()\n", "self.hs.get_federation_handler.return_value.maybe_backfill = Mock(return_value\n =make_awaitable(None))\n", "async def _insert_client_ip(*args, **kwargs):...\n", "return None\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 0, 0, 0, 0 ]
[ "Expr'", "Import'", "ImportFrom'", "ImportFrom'", "Import'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "Assign'", "Assign'", "Assign'", "FunctionDef'", "Assign'", "Assign'", "Assign'", "AsyncFunctionDef'", "Return'" ]
[ "def FUNC_6(self):...\n", "\"\"\"docstring\"\"\"\n", "super(CLASS_3, self).start()\n", "VAR_93 = self.log.info\n", "for VAR_104 in self.notebook_info().split('\\n'):\n", "VAR_93(VAR_104)\n", "VAR_93(\n 'Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).'\n )\n", "self.write_server_info_file()\n", "if self.open_browser or self.file_to_run:\n", "self.io_loop = ioloop.IOLoop.current()\n", "VAR_49 = webbrowser.get(self.browser or None)\n", "self.log.warn('No web browser found: %s.' % e)\n", "if self.file_to_run:\n", "if sys.platform.startswith('win'):\n", "VAR_49 = None\n", "if not os.path.exists(self.file_to_run):\n", "VAR_108 = 'tree'\n", "VAR_105 = ioloop.PeriodicCallback(lambda : None, 5000)\n", "self.io_loop.start()\n", "VAR_93('Interrupted...')\n", "self.cleanup_kernels()\n", "self.log.critical('%s does not exist' % self.file_to_run)\n", "VAR_107 = os.path.relpath(self.file_to_run, self.notebook_dir)\n", "if VAR_49:\n", "VAR_105.start()\n", "self.remove_server_info_file()\n", "self.exit(1)\n", "VAR_108 = url_path_join('notebooks', *VAR_107.split(os.sep))\n", "VAR_109 = lambda : VAR_49.open(url_path_join(self.connection_url, VAR_108),\n VAR_40=2)\n", "threading.Thread(target=b).start()\n" ]
[ "def start(self):...\n", "\"\"\"docstring\"\"\"\n", "super(NotebookApp, self).start()\n", "info = self.log.info\n", "for line in self.notebook_info().split('\\n'):\n", "info(line)\n", "info(\n 'Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).'\n )\n", "self.write_server_info_file()\n", "if self.open_browser or self.file_to_run:\n", "self.io_loop = ioloop.IOLoop.current()\n", "browser = webbrowser.get(self.browser or None)\n", "self.log.warn('No web browser found: %s.' % e)\n", "if self.file_to_run:\n", "if sys.platform.startswith('win'):\n", "browser = None\n", "if not os.path.exists(self.file_to_run):\n", "uri = 'tree'\n", "pc = ioloop.PeriodicCallback(lambda : None, 5000)\n", "self.io_loop.start()\n", "info('Interrupted...')\n", "self.cleanup_kernels()\n", "self.log.critical('%s does not exist' % self.file_to_run)\n", "relpath = os.path.relpath(self.file_to_run, self.notebook_dir)\n", "if browser:\n", "pc.start()\n", "self.remove_server_info_file()\n", "self.exit(1)\n", "uri = url_path_join('notebooks', *relpath.split(os.sep))\n", "b = lambda : browser.open(url_path_join(self.connection_url, uri), new=2)\n", "threading.Thread(target=b).start()\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Expr'", "Assign'", "For", "Expr'", "Expr'", "Expr'", "Condition", "Assign'", "Assign'", "Expr'", "Condition", "For", "Assign'", "Condition", "Assign'", "Assign'", "Expr'", "Expr'", "Expr'", "Expr'", "Assign'", "Condition", "Expr'", "Expr'", "Expr'", "Assign'", "Assign'", "Expr'" ]
[ "def FUNC_24(VAR_40):...\n", "return VAR_39[VAR_40]\n" ]
[ "def models_dir_get(x):...\n", "return module_paths[x]\n" ]
[ 0, 0 ]
[ "FunctionDef'", "Return'" ]
[ "def FUNC_1(*, VAR_0: Optional[str], VAR_1: Optional[Path]) ->Sequence[...\n", "\"\"\"docstring\"\"\"\n", "VAR_4 = FUNC_0(VAR_0=url, VAR_1=path)\n", "if isinstance(VAR_4, GeneratorError):\n", "return [VAR_4]\n", "return VAR_4.build()\n" ]
[ "def create_new_client(*, url: Optional[str], path: Optional[Path]) ->Sequence[...\n", "\"\"\"docstring\"\"\"\n", "project = _get_project_for_url_or_path(url=url, path=path)\n", "if isinstance(project, GeneratorError):\n", "return [project]\n", "return project.build()\n" ]
[ 0, 0, 0, 0, 0, 0 ]
[ "Condition", "Docstring", "Assign'", "Condition", "Return'", "Return'" ]
[ "def FUNC_43(self, VAR_53, VAR_54):...\n", "return VAR_53 * VAR_54\n" ]
[ "def multiply(self, a, b):...\n", "return a * b\n" ]
[ 0, 0 ]
[ "FunctionDef'", "Return'" ]
[ "def FUNC_114():...\n", "if VAR_32:\n", "if VAR_19.rollback_on_exception:\n", "VAR_12.rollback()\n", "import inspect\n", "if inspect.isclass(VAR_32) and issubclass(VAR_32, Exception):\n" ]
[ "def _raise_exception():...\n", "if raise_exception:\n", "if flags.rollback_on_exception:\n", "db.rollback()\n", "import inspect\n", "if inspect.isclass(raise_exception) and issubclass(raise_exception, Exception):\n" ]
[ 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Condition", "Condition", "Expr'", "Import'", "Condition" ]
[ "def FUNC_139(self):...\n", "if self.auth.user:\n", "if self.settings.menu_groups is None:\n", "return False\n", "return True\n", "VAR_167 = self.settings.groups\n", "if any(VAR_445 in self.settings.menu_groups for VAR_445 in VAR_167):\n", "return True\n" ]
[ "def can_see_menu(self):...\n", "if self.auth.user:\n", "if self.settings.menu_groups is None:\n", "return False\n", "return True\n", "groups = self.settings.groups\n", "if any(t in self.settings.menu_groups for t in groups):\n", "return True\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Condition", "Condition", "Return'", "Return'", "Assign'", "For", "Return'" ]
[ "def FUNC_14():...\n", "VAR_23.component_instance.json_args = VAR_34\n", "VAR_23.component_instance.special_args.extend(VAR_21)\n" ]
[ "def marshall_element_args():...\n", "element.component_instance.json_args = serialized_json_args\n", "element.component_instance.special_args.extend(special_args)\n" ]
[ 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Expr'" ]
[ "def FUNC_46(VAR_134):...\n", "def FUNC_47(VAR_136, VAR_38):...\n", "return VAR_134(VAR_136, VAR_38)\n", "VAR_0.exception('Error while extracting sorting keys for template {}'.\n format(VAR_117))\n", "return FUNC_47\n", "return None\n" ]
[ "def create_safe_extractor(extractor):...\n", "def f(x, k):...\n", "return extractor(x, k)\n", "_logger.exception('Error while extracting sorting keys for template {}'.\n format(t))\n", "return f\n", "return None\n" ]
[ 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "FunctionDef'", "Return'", "Expr'", "Return'", "Return'" ]
[ "@property...\n", "\"\"\"docstring\"\"\"\n", "VAR_87 = self.extra_nbextensions_path + jupyter_path('nbextensions')\n", "VAR_87.append(os.path.join(get_ipython_dir(), 'nbextensions'))\n", "return VAR_87\n" ]
[ "@property...\n", "\"\"\"docstring\"\"\"\n", "path = self.extra_nbextensions_path + jupyter_path('nbextensions')\n", "path.append(os.path.join(get_ipython_dir(), 'nbextensions'))\n", "return path\n" ]
[ 0, 0, 0, 0, 0 ]
[ "Condition", "Docstring", "Assign'", "Expr'", "Return'" ]
[ "def FUNC_60(self):...\n", "if not self.user:\n", "redirect(self.settings.login_url)\n", "VAR_277 = self.table_token()\n", "VAR_277.user_id.writable = False\n", "VAR_277.user_id.default = self.user.id\n", "VAR_277.token.writable = False\n", "if VAR_263.request.args(1) == 'new':\n", "VAR_277.token.readable = False\n", "VAR_7 = SQLFORM.grid(VAR_277, VAR_11=['manage_tokens'])\n", "return VAR_7\n" ]
[ "def manage_tokens(self):...\n", "if not self.user:\n", "redirect(self.settings.login_url)\n", "table_token = self.table_token()\n", "table_token.user_id.writable = False\n", "table_token.user_id.default = self.user.id\n", "table_token.token.writable = False\n", "if current.request.args(1) == 'new':\n", "table_token.token.readable = False\n", "form = SQLFORM.grid(table_token, args=['manage_tokens'])\n", "return form\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Condition", "Expr'", "Assign'", "Assign'", "Assign'", "Assign'", "Condition", "Assign'", "Assign'", "Return'" ]
[ "from __future__ import division, print_function, unicode_literals\n", "import sys\n", "import platform\n", "import sqlite3\n", "from collections import OrderedDict\n", "import babel, pytz, requests, sqlalchemy\n", "import werkzeug, flask, flask_login, flask_principal, jinja2\n", "from flask_babel import gettext as _\n", "from . import db, calibre_db, converter, uploader, server, isoLanguages, constants\n", "from .render_template import render_title_template\n", "from flask_login import __version__ as flask_loginVersion\n", "from flask_login.__about__ import __version__ as flask_loginVersion\n", "import unidecode\n", "VAR_2 = _(u'not installed')\n", "from flask_dance import __version__ as flask_danceVersion\n", "VAR_8 = None\n", "from greenlet import __version__ as greenlet_Version\n", "VAR_9 = None\n", "from scholarly import scholarly\n", "VAR_3 = _(u'not installed')\n", "from . import services\n", "VAR_2 = _(u'installed')\n", "VAR_3 = _(u'installed')\n", "VAR_0 = flask.Blueprint('about', __name__)\n", "VAR_1 = OrderedDict(Platform='{0[0]} {0[2]} {0[3]} {0[4]} {0[5]}'.format(\n platform.uname()), Python=sys.version, Calibre_Web=constants.\n STABLE_VERSION['version'] + ' - ' + constants.NIGHTLY_VERSION[0].\n replace('%', '%%') + ' - ' + constants.NIGHTLY_VERSION[1].replace('%',\n '%%'), WebServer=server.VERSION, Flask=flask.__version__, Flask_Login=\n flask_loginVersion, Flask_Principal=flask_principal.__version__,\n Werkzeug=werkzeug.__version__, Babel=babel.__version__, Jinja2=jinja2.\n __version__, Requests=requests.__version__, SqlAlchemy=sqlalchemy.\n __version__, pySqlite=sqlite3.version, SQLite=sqlite3.sqlite_version,\n iso639=isoLanguages.__version__, pytz=pytz.__version__, Unidecode=\n unidecode_version, Scholarly=scholarly_version, Flask_SimpleLDAP=\n u'installed' if bool(services.ldap) else None, python_LDAP=services.\n ldapVersion if bool(services.ldapVersion) else None, Goodreads=\n u'installed' if bool(services.goodreads_support) else None, jsonschema=\n services.SyncToken.__version__ if bool(services.SyncToken) else None,\n flask_dance=flask_danceVersion, greenlet=greenlet_Version)\n", "VAR_1.update(uploader.get_versions())\n", "def FUNC_0():...\n", "VAR_1['ebook converter'] = _(converter.get_calibre_version())\n", "VAR_1['unrar'] = _(converter.get_unrar_version())\n", "VAR_1['kepubify'] = _(converter.get_kepubify_version())\n", "return VAR_1\n" ]
[ "from __future__ import division, print_function, unicode_literals\n", "import sys\n", "import platform\n", "import sqlite3\n", "from collections import OrderedDict\n", "import babel, pytz, requests, sqlalchemy\n", "import werkzeug, flask, flask_login, flask_principal, jinja2\n", "from flask_babel import gettext as _\n", "from . import db, calibre_db, converter, uploader, server, isoLanguages, constants\n", "from .render_template import render_title_template\n", "from flask_login import __version__ as flask_loginVersion\n", "from flask_login.__about__ import __version__ as flask_loginVersion\n", "import unidecode\n", "unidecode_version = _(u'not installed')\n", "from flask_dance import __version__ as flask_danceVersion\n", "flask_danceVersion = None\n", "from greenlet import __version__ as greenlet_Version\n", "greenlet_Version = None\n", "from scholarly import scholarly\n", "scholarly_version = _(u'not installed')\n", "from . import services\n", "unidecode_version = _(u'installed')\n", "scholarly_version = _(u'installed')\n", "about = flask.Blueprint('about', __name__)\n", "_VERSIONS = OrderedDict(Platform='{0[0]} {0[2]} {0[3]} {0[4]} {0[5]}'.\n format(platform.uname()), Python=sys.version, Calibre_Web=constants.\n STABLE_VERSION['version'] + ' - ' + constants.NIGHTLY_VERSION[0].\n replace('%', '%%') + ' - ' + constants.NIGHTLY_VERSION[1].replace('%',\n '%%'), WebServer=server.VERSION, Flask=flask.__version__, Flask_Login=\n flask_loginVersion, Flask_Principal=flask_principal.__version__,\n Werkzeug=werkzeug.__version__, Babel=babel.__version__, Jinja2=jinja2.\n __version__, Requests=requests.__version__, SqlAlchemy=sqlalchemy.\n __version__, pySqlite=sqlite3.version, SQLite=sqlite3.sqlite_version,\n iso639=isoLanguages.__version__, pytz=pytz.__version__, Unidecode=\n unidecode_version, Scholarly=scholarly_version, Flask_SimpleLDAP=\n u'installed' if bool(services.ldap) else None, python_LDAP=services.\n ldapVersion if bool(services.ldapVersion) else None, Goodreads=\n u'installed' if bool(services.goodreads_support) else None, jsonschema=\n services.SyncToken.__version__ if bool(services.SyncToken) else None,\n flask_dance=flask_danceVersion, greenlet=greenlet_Version)\n", "_VERSIONS.update(uploader.get_versions())\n", "def collect_stats():...\n", "_VERSIONS['ebook converter'] = _(converter.get_calibre_version())\n", "_VERSIONS['unrar'] = _(converter.get_unrar_version())\n", "_VERSIONS['kepubify'] = _(converter.get_kepubify_version())\n", "return _VERSIONS\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0 ]
[ "ImportFrom'", "Import'", "Import'", "Import'", "ImportFrom'", "Import'", "Import'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "Import'", "Assign'", "ImportFrom'", "Assign'", "ImportFrom'", "Assign'", "ImportFrom'", "Assign'", "ImportFrom'", "Assign'", "Assign'", "Assign'", "Assign'", "Expr'", "FunctionDef'", "Assign'", "Assign'", "Assign'", "Return'" ]
[ "\"\"\"string\"\"\"\n", "from __future__ import annotations\n", "import datetime\n", "import os\n", "import re\n", "import unicodedata\n", "from typing import Any\n", "from typing import MutableMapping\n", "from typing import TypeVar\n", "import flask\n", "from beancount.core import compare\n", "from beancount.core import realization\n", "from beancount.core.account import ACCOUNT_RE\n", "from beancount.core.data import Directive\n", "from beancount.core.inventory import Inventory\n", "from beancount.core.number import Decimal\n", "from beancount.core.number import ZERO\n", "from fava.context import g\n", "from fava.core.conversion import cost\n", "from fava.core.conversion import cost_or_value as cost_or_value_without_context\n", "from fava.core.conversion import units\n", "from fava.core.tree import TreeNode\n", "from fava.util.date import Interval\n", "VAR_0 = TypeVar('MappingValue')\n", "def FUNC_0(VAR_1: (MutableMapping[str, MappingValue] | None), VAR_2: list[str]...\n", "\"\"\"docstring\"\"\"\n", "if not VAR_1:\n", "return {}\n", "VAR_17 = dict(VAR_1)\n", "for key in VAR_2:\n", "return VAR_17\n" ]
[ "\"\"\"Template filters for Fava.\n\nAll functions in this module will be automatically added as template filters.\n\"\"\"\n", "from __future__ import annotations\n", "import datetime\n", "import os\n", "import re\n", "import unicodedata\n", "from typing import Any\n", "from typing import MutableMapping\n", "from typing import TypeVar\n", "import flask\n", "from beancount.core import compare\n", "from beancount.core import realization\n", "from beancount.core.account import ACCOUNT_RE\n", "from beancount.core.data import Directive\n", "from beancount.core.inventory import Inventory\n", "from beancount.core.number import Decimal\n", "from beancount.core.number import ZERO\n", "from fava.context import g\n", "from fava.core.conversion import cost\n", "from fava.core.conversion import cost_or_value as cost_or_value_without_context\n", "from fava.core.conversion import units\n", "from fava.core.tree import TreeNode\n", "from fava.util.date import Interval\n", "MappingValue = TypeVar('MappingValue')\n", "def remove_keys(_dict: (MutableMapping[str, MappingValue] | None), keys:...\n", "\"\"\"docstring\"\"\"\n", "if not _dict:\n", "return {}\n", "new = dict(_dict)\n", "for key in keys:\n", "return new\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "Expr'", "ImportFrom'", "Import'", "Import'", "Import'", "Import'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "Import'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "Assign'", "Condition", "Docstring", "Condition", "Return'", "Assign'", "For", "Return'" ]
[ "def FUNC_4(self) ->str:...\n", "\"\"\"docstring\"\"\"\n", "if self.default:\n", "VAR_16 = self.default\n", "if not self.required:\n", "if VAR_16 is not None:\n", "VAR_16 = 'None'\n", "VAR_16 = None\n", "return f'{self.python_name}: {self.get_type_string()} = {self.default}'\n", "return f'{self.python_name}: {self.get_type_string()}'\n" ]
[ "def to_string(self) ->str:...\n", "\"\"\"docstring\"\"\"\n", "if self.default:\n", "default = self.default\n", "if not self.required:\n", "if default is not None:\n", "default = 'None'\n", "default = None\n", "return f'{self.python_name}: {self.get_type_string()} = {self.default}'\n", "return f'{self.python_name}: {self.get_type_string()}'\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Condition", "Assign'", "Condition", "Condition", "Assign'", "Assign'", "Return'", "Return'" ]
[ "def FUNC_15(VAR_3, VAR_31=None, VAR_32=0, VAR_33=False, VAR_34=False,...\n", "\"\"\"docstring\"\"\"\n", "from frappe.utils import strip_html_tags\n", "VAR_3 = FUNC_108(VAR_3)\n", "VAR_179 = CLASS_0(VAR_51=msg)\n", "def FUNC_114():...\n", "if VAR_32:\n", "if VAR_19.rollback_on_exception:\n", "if VAR_19.mute_messages:\n", "VAR_12.rollback()\n", "import inspect\n", "FUNC_114()\n", "if VAR_33 and VAR_171(VAR_3) in (list, tuple):\n", "if inspect.isclass(VAR_32) and issubclass(VAR_32, Exception):\n", "return\n", "VAR_179.as_table = 1\n", "if VAR_34 and VAR_171(VAR_3) in (list, tuple) and len(VAR_3) > 1:\n", "VAR_179.as_list = 1\n", "if VAR_19.print_messages and VAR_179.message:\n", "print(f'Message: {strip_html_tags(VAR_179.message)}')\n", "if VAR_31:\n", "VAR_179.title = VAR_31\n", "if not VAR_35 and VAR_32:\n", "VAR_35 = 'red'\n", "if VAR_35:\n", "VAR_179.indicator = VAR_35\n", "if VAR_38:\n", "VAR_179.is_minimizable = VAR_38\n", "if VAR_36:\n", "VAR_179.alert = 1\n", "if VAR_32:\n", "VAR_179.raise_exception = 1\n", "if VAR_37:\n", "VAR_179.primary_action = VAR_37\n", "if VAR_39:\n", "VAR_179.wide = VAR_39\n", "VAR_22.append(json.dumps(VAR_179))\n", "if VAR_32 and hasattr(VAR_32, '__name__'):\n", "VAR_1.response['exc_type'] = VAR_32.__name__\n", "FUNC_114()\n" ]
[ "def msgprint(msg, title=None, raise_exception=0, as_table=False, as_list=...\n", "\"\"\"docstring\"\"\"\n", "from frappe.utils import strip_html_tags\n", "msg = safe_decode(msg)\n", "out = _dict(message=msg)\n", "def _raise_exception():...\n", "if raise_exception:\n", "if flags.rollback_on_exception:\n", "if flags.mute_messages:\n", "db.rollback()\n", "import inspect\n", "_raise_exception()\n", "if as_table and type(msg) in (list, tuple):\n", "if inspect.isclass(raise_exception) and issubclass(raise_exception, Exception):\n", "return\n", "out.as_table = 1\n", "if as_list and type(msg) in (list, tuple) and len(msg) > 1:\n", "out.as_list = 1\n", "if flags.print_messages and out.message:\n", "print(f'Message: {strip_html_tags(out.message)}')\n", "if title:\n", "out.title = title\n", "if not indicator and raise_exception:\n", "indicator = 'red'\n", "if indicator:\n", "out.indicator = indicator\n", "if is_minimizable:\n", "out.is_minimizable = is_minimizable\n", "if alert:\n", "out.alert = 1\n", "if raise_exception:\n", "out.raise_exception = 1\n", "if primary_action:\n", "out.primary_action = primary_action\n", "if wide:\n", "out.wide = wide\n", "message_log.append(json.dumps(out))\n", "if raise_exception and hasattr(raise_exception, '__name__'):\n", "local.response['exc_type'] = raise_exception.__name__\n", "_raise_exception()\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "Condition", "Docstring", "ImportFrom'", "Assign'", "Assign'", "FunctionDef'", "Condition", "Condition", "Condition", "Expr'", "Import'", "Expr'", "Condition", "Condition", "Return'", "Assign'", "Condition", "Assign'", "Condition", "Expr'", "Condition", "Assign'", "Condition", "Assign'", "Condition", "Assign'", "Condition", "Assign'", "Condition", "Assign'", "Condition", "Assign'", "Condition", "Assign'", "Condition", "Assign'", "Expr'", "Condition", "Assign'", "Expr'" ]
[ "from __future__ import unicode_literals\n", "from django.conf.urls import url\n", "from django.contrib.auth.decorators import login_required\n", "from django.http.response import HttpResponse\n", "from django.views.decorators.csrf import csrf_exempt\n", "from django.views.i18n import set_language\n", "from itertools import chain\n", "from shuup.apps.provides import get_provide_objects\n", "from .views.basket import BasketView\n", "from .views.category import AllCategoriesView, CategoryView\n", "from .views.checkout import get_checkout_view\n", "from .views.dashboard import DashboardView\n", "from .views.index import IndexView\n", "from .views.misc import force_anonymous_contact, force_company_contact, force_person_contact, stop_impersonating, toggle_all_seeing\n", "from .views.order import OrderCompleteView\n", "from .views.payment import ProcessPaymentView\n", "from .views.product import ProductDetailView\n", "from .views.upload import media_upload\n", "def FUNC_0(VAR_0, *VAR_1, **VAR_2):...\n", "return HttpResponse('Not here yet: %s (%r, %r)' % (VAR_0.path, VAR_1, VAR_2\n ), status=410)\n" ]
[ "from __future__ import unicode_literals\n", "from django.conf.urls import url\n", "from django.contrib.auth.decorators import login_required\n", "from django.http.response import HttpResponse\n", "from django.views.decorators.csrf import csrf_exempt\n", "from django.views.i18n import set_language\n", "from itertools import chain\n", "from shuup.apps.provides import get_provide_objects\n", "from .views.basket import BasketView\n", "from .views.category import AllCategoriesView, CategoryView\n", "from .views.checkout import get_checkout_view\n", "from .views.dashboard import DashboardView\n", "from .views.index import IndexView\n", "from .views.misc import force_anonymous_contact, force_company_contact, force_person_contact, stop_impersonating, toggle_all_seeing\n", "from .views.order import OrderCompleteView\n", "from .views.payment import ProcessPaymentView\n", "from .views.product import ProductDetailView\n", "from .views.upload import media_upload\n", "def _not_here_yet(request, *args, **kwargs):...\n", "return HttpResponse('Not here yet: %s (%r, %r)' % (request.path, args,\n kwargs), status=410)\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2 ]
[ "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "FunctionDef'", "Return'" ]
[ "def FUNC_3(VAR_9: str) ->int:...\n", "VAR_35 = 0\n", "for c in VAR_9:\n", "VAR_35 += ord(c)\n", "return VAR_35\n" ]
[ "def string_ordinal_total(s: str) ->int:...\n", "tot = 0\n", "for c in s:\n", "tot += ord(c)\n", "return tot\n" ]
[ 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "For", "AugAssign'", "Return'" ]
[ "def FUNC_10(self, VAR_14):...\n", "\"\"\"docstring\"\"\"\n", "if self.isAdmin and not VAR_14.isAdmin():\n" ]
[ "def verify_is_admin(self, conn):...\n", "\"\"\"docstring\"\"\"\n", "if self.isAdmin and not conn.isAdmin():\n" ]
[ 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Condition" ]
[ "def FUNC_12(self):...\n", "VAR_17 = self.assertFormfield(models.Event, 'main_band', widgets.\n AdminRadioSelect, radio_fields={'main_band': admin.VERTICAL})\n", "self.assertEqual(VAR_17.empty_label, None)\n" ]
[ "def testRadioFieldsForeignKey(self):...\n", "ff = self.assertFormfield(models.Event, 'main_band', widgets.\n AdminRadioSelect, radio_fields={'main_band': admin.VERTICAL})\n", "self.assertEqual(ff.empty_label, None)\n" ]
[ 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Expr'" ]
[ "def FUNC_2(self, VAR_12):...\n", "return CLASS_2(self._reactor, self._tls_client_options_factory, self.\n _srv_resolver, VAR_12)\n" ]
[ "def endpointForURI(self, parsed_uri):...\n", "return MatrixHostnameEndpoint(self._reactor, self.\n _tls_client_options_factory, self._srv_resolver, parsed_uri)\n" ]
[ 0, 0 ]
[ "FunctionDef'", "Return'" ]
[ "@def_function.function...\n", "return VAR_49 + 2 * VAR_55\n" ]
[ "@def_function.function...\n", "return y + 2 * c\n" ]
[ 0, 0 ]
[ "Condition", "Return'" ]
[ "def FUNC_4(self, VAR_6):...\n", "VAR_13 = UploadForm(instance=filemodel)\n", "assert VAR_6.file.name in VAR_13.as_p(), VAR_13.as_p()\n", "assert not VAR_13.is_valid()\n" ]
[ "def test_value_from_datadict_initial_data(self, filemodel):...\n", "form = UploadForm(instance=filemodel)\n", "assert filemodel.file.name in form.as_p(), form.as_p()\n", "assert not form.is_valid()\n" ]
[ 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Assert'", "Assert'" ]
[ "def FUNC_51(VAR_21, VAR_26):...\n", "if VAR_26:\n", "if config.config_read_column:\n", "return VAR_21\n", "if VAR_26 == 'True':\n", "if VAR_26 == 'True':\n", "VAR_3.error(u'Custom Column No.%d is not existing in calibre database',\n config.config_read_column)\n", "VAR_21 = VAR_21.join(ub.ReadBook, db.Books.id == ub.ReadBook.book_id,\n isouter=True).filter(ub.ReadBook.user_id == int(VAR_87.id), ub.ReadBook\n .read_status == ub.ReadBook.STATUS_FINISHED)\n", "VAR_21 = VAR_21.join(ub.ReadBook, db.Books.id == ub.ReadBook.book_id,\n isouter=True).filter(ub.ReadBook.user_id == int(VAR_87.id), coalesce(ub\n .ReadBook.read_status, 0) != ub.ReadBook.STATUS_FINISHED)\n", "VAR_21 = VAR_21.join(db.cc_classes[config.config_read_column], isouter=True\n ).filter(db.cc_classes[config.config_read_column].value == True)\n", "VAR_21 = VAR_21.join(db.cc_classes[config.config_read_column], isouter=True\n ).filter(coalesce(db.cc_classes[config.config_read_column].value, False\n ) != True)\n", "flash(_('Custom Column No.%(column)d is not existing in calibre database',\n column=config.config_read_column), category='error')\n", "return VAR_21\n" ]
[ "def adv_search_read_status(q, read_status):...\n", "if read_status:\n", "if config.config_read_column:\n", "return q\n", "if read_status == 'True':\n", "if read_status == 'True':\n", "log.error(u'Custom Column No.%d is not existing in calibre database',\n config.config_read_column)\n", "q = q.join(ub.ReadBook, db.Books.id == ub.ReadBook.book_id, isouter=True\n ).filter(ub.ReadBook.user_id == int(current_user.id), ub.ReadBook.\n read_status == ub.ReadBook.STATUS_FINISHED)\n", "q = q.join(ub.ReadBook, db.Books.id == ub.ReadBook.book_id, isouter=True\n ).filter(ub.ReadBook.user_id == int(current_user.id), coalesce(ub.\n ReadBook.read_status, 0) != ub.ReadBook.STATUS_FINISHED)\n", "q = q.join(db.cc_classes[config.config_read_column], isouter=True).filter(\n db.cc_classes[config.config_read_column].value == True)\n", "q = q.join(db.cc_classes[config.config_read_column], isouter=True).filter(\n coalesce(db.cc_classes[config.config_read_column].value, False) != True)\n", "flash(_('Custom Column No.%(column)d is not existing in calibre database',\n column=config.config_read_column), category='error')\n", "return q\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Condition", "Condition", "Return'", "Condition", "Condition", "Expr'", "Assign'", "Assign'", "Assign'", "Assign'", "Expr'", "Return'" ]
[ "def FUNC_3(self):...\n", "assert controller_name(CLASS_10) == 'some'\n" ]
[ "def test_it_strips_view(self):...\n", "assert controller_name(SomeView) == 'some'\n" ]
[ 0, 0 ]
[ "FunctionDef'", "Assert'" ]
[ "def FUNC_91(VAR_62, VAR_9, VAR_152=None, VAR_146=None, VAR_147=None,...\n", "from frappe.utils import scrub_urls\n", "if not VAR_152:\n", "VAR_152 = VAR_9\n", "VAR_152 = VAR_152.replace(' ', '').replace('/', '-')\n", "VAR_199 = VAR_12.get_singles_dict('Print Settings')\n", "VAR_200 = VAR_1.lang\n", "if VAR_4:\n", "VAR_1.lang = VAR_4\n", "VAR_1.flags.ignore_print_permissions = True\n", "VAR_150 = not VAR_81\n", "VAR_42 = dict(VAR_146=print_format, VAR_147=style, VAR_136=html, VAR_94=doc,\n VAR_150=no_letterhead, VAR_151=password)\n", "VAR_61 = ''\n", "if int(VAR_199.send_print_as_pdf or 0):\n", "VAR_213 = '.pdf'\n", "VAR_213 = '.html'\n", "VAR_42['as_pdf'] = True\n", "VAR_61 = scrub_urls(FUNC_90(VAR_62, VAR_9, **kwargs)).encode('utf-8')\n", "VAR_61 = FUNC_90(VAR_62, VAR_9, **kwargs)\n", "VAR_179 = {'fname': VAR_152 + VAR_213, 'fcontent': VAR_61}\n", "VAR_1.flags.ignore_print_permissions = False\n", "VAR_1.lang = VAR_200\n", "return VAR_179\n" ]
[ "def attach_print(doctype, name, file_name=None, print_format=None, style=...\n", "from frappe.utils import scrub_urls\n", "if not file_name:\n", "file_name = name\n", "file_name = file_name.replace(' ', '').replace('/', '-')\n", "print_settings = db.get_singles_dict('Print Settings')\n", "_lang = local.lang\n", "if lang:\n", "local.lang = lang\n", "local.flags.ignore_print_permissions = True\n", "no_letterhead = not print_letterhead\n", "kwargs = dict(print_format=print_format, style=style, html=html, doc=doc,\n no_letterhead=no_letterhead, password=password)\n", "content = ''\n", "if int(print_settings.send_print_as_pdf or 0):\n", "ext = '.pdf'\n", "ext = '.html'\n", "kwargs['as_pdf'] = True\n", "content = scrub_urls(get_print(doctype, name, **kwargs)).encode('utf-8')\n", "content = get_print(doctype, name, **kwargs)\n", "out = {'fname': file_name + ext, 'fcontent': content}\n", "local.flags.ignore_print_permissions = False\n", "local.lang = _lang\n", "return out\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "Condition", "ImportFrom'", "Condition", "Assign'", "Assign'", "Assign'", "Assign'", "Condition", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Condition", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Return'" ]
[ "def FUNC_8(self):...\n", "return [d.as_dict(no_default_fields=True) for d in self.columns]\n" ]
[ "def get_columns(self):...\n", "return [d.as_dict(no_default_fields=True) for d in self.columns]\n" ]
[ 0, 0 ]
[ "FunctionDef'", "Return'" ]
[ "def FUNC_0(self, VAR_0, VAR_1):...\n", "self.mock_federation = Mock()\n", "self.mock_registry = Mock()\n", "self.query_handlers = {}\n", "def FUNC_21(VAR_8, VAR_9):...\n", "self.query_handlers[VAR_8] = VAR_9\n", "self.mock_registry.register_query_handler = FUNC_21\n", "VAR_3 = self.setup_test_homeserver(http_client=None,\n resource_for_federation=Mock(), federation_client=self.mock_federation,\n federation_registry=self.mock_registry)\n", "self.handler = VAR_3.get_directory_handler()\n", "self.store = VAR_3.get_datastore()\n", "self.my_room = RoomAlias.from_string('#my-room:test')\n", "self.your_room = RoomAlias.from_string('#your-room:test')\n", "self.remote_room = RoomAlias.from_string('#another:remote')\n", "return VAR_3\n" ]
[ "def make_homeserver(self, reactor, clock):...\n", "self.mock_federation = Mock()\n", "self.mock_registry = Mock()\n", "self.query_handlers = {}\n", "def register_query_handler(query_type, handler):...\n", "self.query_handlers[query_type] = handler\n", "self.mock_registry.register_query_handler = register_query_handler\n", "hs = self.setup_test_homeserver(http_client=None, resource_for_federation=\n Mock(), federation_client=self.mock_federation, federation_registry=\n self.mock_registry)\n", "self.handler = hs.get_directory_handler()\n", "self.store = hs.get_datastore()\n", "self.my_room = RoomAlias.from_string('#my-room:test')\n", "self.your_room = RoomAlias.from_string('#your-room:test')\n", "self.remote_room = RoomAlias.from_string('#another:remote')\n", "return hs\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 4, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Assign'", "Assign'", "FunctionDef'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Return'" ]
[ "def FUNC_1(VAR_0: str) ->str:...\n", "VAR_0 = re.sub('([A-Z]{2,})([A-Z][a-z]|[ -_]|$)', lambda m: m.group(1).\n title() + m.group(2), VAR_0.strip())\n", "VAR_0 = re.sub('(^|[ _-])([A-Z])', lambda m: m.group(1) + m.group(2).lower(\n ), VAR_0)\n", "return VAR_0\n" ]
[ "def group_title(value: str) ->str:...\n", "value = re.sub('([A-Z]{2,})([A-Z][a-z]|[ -_]|$)', lambda m: m.group(1).\n title() + m.group(2), value.strip())\n", "value = re.sub('(^|[ _-])([A-Z])', lambda m: m.group(1) + m.group(2).lower(\n ), value)\n", "return value\n" ]
[ 0, 5, 0, 0 ]
[ "FunctionDef'", "Assign'", "Assign'", "Return'" ]
[ "@VAR_0.route('/systemctl/<action>')...\n", "\"\"\"docstring\"\"\"\n", "if not utils_general.user_has_permission('edit_settings'):\n", "return redirect(url_for('routes_general.home'))\n", "if VAR_27 not in ['restart', 'shutdown', 'daemon_restart', 'frontend_reload']:\n", "VAR_1.error(\"System command '{cmd}' raised and error: {err}\".format(VAR_108\n =action, err=e))\n", "flash('Unrecognized command: {action}'.format(VAR_27=action), 'success')\n", "if DOCKER_CONTAINER:\n", "flash(\"System command '{cmd}' raised and error: {err}\".format(VAR_108=\n action, err=e), 'error')\n", "return redirect('/settings')\n", "if VAR_27 == 'daemon_restart':\n", "VAR_108 = '{path}/mycodo/scripts/mycodo_wrapper {action} 2>&1'.format(VAR_34\n =INSTALL_DIRECTORY, VAR_27=action)\n", "return redirect(url_for('routes_general.home'))\n", "VAR_91 = DaemonControl()\n", "if VAR_27 == 'frontend_reload':\n", "subprocess.Popen(VAR_108, shell=True)\n", "VAR_91.terminate_daemon()\n", "subprocess.Popen('docker restart mycodo_flask 2>&1', shell=True)\n", "if VAR_27 == 'restart':\n", "flash(gettext('Command to restart the daemon sent'), 'success')\n", "flash(gettext('Command to reload the frontend sent'), 'success')\n", "flash(gettext('System rebooting in 10 seconds'), 'success')\n", "if VAR_27 == 'shutdown':\n", "return redirect('/settings')\n", "flash(gettext('System shutting down in 10 seconds'), 'success')\n", "if VAR_27 == 'daemon_restart':\n", "flash(gettext('Command to restart the daemon sent'), 'success')\n", "if VAR_27 == 'frontend_reload':\n", "flash(gettext('Command to reload the frontend sent'), 'success')\n" ]
[ "@blueprint.route('/systemctl/<action>')...\n", "\"\"\"docstring\"\"\"\n", "if not utils_general.user_has_permission('edit_settings'):\n", "return redirect(url_for('routes_general.home'))\n", "if action not in ['restart', 'shutdown', 'daemon_restart', 'frontend_reload']:\n", "logger.error(\"System command '{cmd}' raised and error: {err}\".format(cmd=\n action, err=e))\n", "flash('Unrecognized command: {action}'.format(action=action), 'success')\n", "if DOCKER_CONTAINER:\n", "flash(\"System command '{cmd}' raised and error: {err}\".format(cmd=action,\n err=e), 'error')\n", "return redirect('/settings')\n", "if action == 'daemon_restart':\n", "cmd = '{path}/mycodo/scripts/mycodo_wrapper {action} 2>&1'.format(path=\n INSTALL_DIRECTORY, action=action)\n", "return redirect(url_for('routes_general.home'))\n", "control = DaemonControl()\n", "if action == 'frontend_reload':\n", "subprocess.Popen(cmd, shell=True)\n", "control.terminate_daemon()\n", "subprocess.Popen('docker restart mycodo_flask 2>&1', shell=True)\n", "if action == 'restart':\n", "flash(gettext('Command to restart the daemon sent'), 'success')\n", "flash(gettext('Command to reload the frontend sent'), 'success')\n", "flash(gettext('System rebooting in 10 seconds'), 'success')\n", "if action == 'shutdown':\n", "return redirect('/settings')\n", "flash(gettext('System shutting down in 10 seconds'), 'success')\n", "if action == 'daemon_restart':\n", "flash(gettext('Command to restart the daemon sent'), 'success')\n", "if action == 'frontend_reload':\n", "flash(gettext('Command to reload the frontend sent'), 'success')\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "Condition", "Docstring", "Condition", "Return'", "Condition", "Expr'", "Expr'", "Condition", "Expr'", "Return'", "Condition", "Assign'", "Return'", "Assign'", "Condition", "Expr'", "Expr'", "Expr'", "Condition", "Expr'", "Expr'", "Expr'", "Condition", "Return'", "Expr'", "Condition", "Expr'", "Condition", "Expr'" ]
[ "def FUNC_2(self, *VAR_8, **VAR_9):...\n", "VAR_10 = VAR_9.get('type', self.type)\n", "for _, _, files in os.walk(self._buildPath(VAR_8, VAR_10=fileType)):\n", "yield from files\n" ]
[ "def walkFiles(self, *segs, **kwargs):...\n", "fileType = kwargs.get('type', self.type)\n", "for _, _, files in os.walk(self._buildPath(segs, fileType=fileType)):\n", "yield from files\n" ]
[ 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "For", "Expr'" ]
[ "def FUNC_19(VAR_10, VAR_20, VAR_17):...\n", "\"\"\"docstring\"\"\"\n", "VAR_67 = os.path.join(VAR_20, VAR_10.filename)\n", "if os.path.exists(VAR_67):\n", "VAR_1.info('File was already downloaded %s', VAR_67)\n", "return None\n", "if VAR_17:\n", "return VAR_67\n", "VAR_17.check_against_path(VAR_67)\n", "VAR_1.warning('Previously-downloaded file %s has bad hash. Re-downloading.',\n VAR_67)\n", "os.unlink(VAR_67)\n", "return None\n" ]
[ "def _check_download_dir(link, download_dir, hashes):...\n", "\"\"\"docstring\"\"\"\n", "download_path = os.path.join(download_dir, link.filename)\n", "if os.path.exists(download_path):\n", "logger.info('File was already downloaded %s', download_path)\n", "return None\n", "if hashes:\n", "return download_path\n", "hashes.check_against_path(download_path)\n", "logger.warning('Previously-downloaded file %s has bad hash. Re-downloading.',\n download_path)\n", "os.unlink(download_path)\n", "return None\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Assign'", "Condition", "Expr'", "Return'", "Condition", "Return'", "Expr'", "Expr'", "Expr'", "Return'" ]
[ "def FUNC_1(self):...\n", "VAR_6 = Mock()\n", "VAR_3 = '@foo:bar'\n", "VAR_7 = 5000000\n", "VAR_8 = UserPresenceState.default(VAR_3)\n", "VAR_8 = VAR_8.copy_and_replace(VAR_10=PresenceState.ONLINE, last_active_ts=\n now, currently_active=True)\n", "VAR_9 = VAR_8.copy_and_replace(VAR_10=PresenceState.ONLINE, last_active_ts=now)\n", "VAR_10, VAR_11, VAR_12 = handle_update(VAR_8, VAR_9, is_mine=True, VAR_6=\n wheel_timer, VAR_7=now)\n", "self.assertFalse(VAR_11)\n", "self.assertTrue(VAR_12)\n", "self.assertTrue(VAR_10.currently_active)\n", "self.assertEquals(VAR_9.state, VAR_10.state)\n", "self.assertEquals(VAR_9.status_msg, VAR_10.status_msg)\n", "self.assertEquals(VAR_10.last_federation_update_ts, VAR_7)\n", "self.assertEquals(VAR_6.insert.call_count, 3)\n", "VAR_6.insert.assert_has_calls([call(VAR_7=now, obj=user_id, then=new_state.\n last_active_ts + IDLE_TIMER), call(VAR_7=now, obj=user_id, then=\n new_state.last_user_sync_ts + SYNC_ONLINE_TIMEOUT), call(VAR_7=now, obj\n =user_id, then=new_state.last_active_ts + LAST_ACTIVE_GRANULARITY)],\n any_order=True)\n" ]
[ "def test_online_to_online(self):...\n", "wheel_timer = Mock()\n", "user_id = '@foo:bar'\n", "now = 5000000\n", "prev_state = UserPresenceState.default(user_id)\n", "prev_state = prev_state.copy_and_replace(state=PresenceState.ONLINE,\n last_active_ts=now, currently_active=True)\n", "new_state = prev_state.copy_and_replace(state=PresenceState.ONLINE,\n last_active_ts=now)\n", "state, persist_and_notify, federation_ping = handle_update(prev_state,\n new_state, is_mine=True, wheel_timer=wheel_timer, now=now)\n", "self.assertFalse(persist_and_notify)\n", "self.assertTrue(federation_ping)\n", "self.assertTrue(state.currently_active)\n", "self.assertEquals(new_state.state, state.state)\n", "self.assertEquals(new_state.status_msg, state.status_msg)\n", "self.assertEquals(state.last_federation_update_ts, now)\n", "self.assertEquals(wheel_timer.insert.call_count, 3)\n", "wheel_timer.insert.assert_has_calls([call(now=now, obj=user_id, then=\n new_state.last_active_ts + IDLE_TIMER), call(now=now, obj=user_id, then\n =new_state.last_user_sync_ts + SYNC_ONLINE_TIMEOUT), call(now=now, obj=\n user_id, then=new_state.last_active_ts + LAST_ACTIVE_GRANULARITY)],\n any_order=True)\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Expr'", "Expr'", "Expr'", "Expr'", "Expr'", "Expr'", "Expr'", "Expr'" ]