File size: 27,636 Bytes
c7f4bd0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
{"nwo":"3n1b-com\/3n1b.com","sha":"5ee4db23bb665dcbb926c9a55603279ea8a2a73e","path":"helper.py","language":"python","identifier":"Filters.pretty_date","parameters":"(self, time = False)","argument_list":"","return_statement":"return str(day_diff \/ 365) + \" \u5929\u524d\"","docstring":"Get a datetime object or a int() Epoch timestamp and return a\n        pretty string like 'an hour ago', 'Yesterday', '3 months ago',\n        'just now', etc","docstring_summary":"Get a datetime object or a int() Epoch timestamp and return a\n        pretty string like 'an hour ago', 'Yesterday', '3 months ago',\n        'just now', etc","docstring_tokens":["Get","a","datetime","object","or","a","int","()","Epoch","timestamp","and","return","a","pretty","string","like","an","hour","ago","Yesterday","3","months","ago","just","now","etc"],"function":"def pretty_date(self, time = False):\n        \"\"\"\n        Get a datetime object or a int() Epoch timestamp and return a\n        pretty string like 'an hour ago', 'Yesterday', '3 months ago',\n        'just now', etc\n        \"\"\"\n        if time == None:\n            return time\n\n        from datetime import datetime\n        now = datetime.now()\n        if type(time) is str or type(time) is unicode:\n            time = datetime.strptime(time, '%Y-%m-%d %H:%M:%S')\n        elif type(time) is int:\n            diff = now - datetime.fromtimestamp(time)\n        elif isinstance(time, datetime):\n            diff = now - time \n        elif not time:\n            diff = now - now\n        second_diff = diff.seconds\n        day_diff = diff.days\n\n        if day_diff < 0:\n            return ''\n\n        if day_diff == 0:\n            if second_diff < 10:\n                return \"\u521a\u521a\"\n            if second_diff < 60:\n                return str(second_diff) + \" \u79d2\u524d\"\n            if second_diff < 120:\n                return  \"1 \u5206\u949f\u524d\"\n            if second_diff < 3600:\n                return str(second_diff \/ 60) + \" \u5206\u949f\u524d\"\n            if second_diff < 7200:\n                return \"1 \u5c0f\u65f6\u524d\"\n            if second_diff < 86400:\n                return str(second_diff \/ 3600) + \" \u5c0f\u65f6\u524d\"\n        if day_diff == 1:\n            return \"\u6628\u5929\"\n        if day_diff < 7:\n            return str(day_diff) + \" \u5929\u524d\"\n        if day_diff < 31:\n            return str(day_diff \/ 7) + \" \u5468\u524d\"\n        if day_diff < 365:\n            return str(day_diff \/ 30) + \" \u6708\u524d\"\n        return str(day_diff \/ 365) + \" \u5929\u524d\"","function_tokens":["def","pretty_date","(","self",",","time","=","False",")",":","if","time","==","None",":","return","time","from","datetime","import","datetime","now","=","datetime",".","now","(",")","if","type","(","time",")","is","str","or","type","(","time",")","is","unicode",":","time","=","datetime",".","strptime","(","time",",","'%Y-%m-%d %H:%M:%S'",")","elif","type","(","time",")","is","int",":","diff","=","now","-","datetime",".","fromtimestamp","(","time",")","elif","isinstance","(","time",",","datetime",")",":","diff","=","now","-","time","elif","not","time",":","diff","=","now","-","now","second_diff","=","diff",".","seconds","day_diff","=","diff",".","days","if","day_diff","<","0",":","return","''","if","day_diff","==","0",":","if","second_diff","<","10",":","return","\"\u521a\u521a\"","if","second_diff","<","60",":","return","str","(","second_diff",")","+","\" \u79d2\u524d\"","if","second_diff","<","120",":","return","\"1 \u5206\u949f\u524d\"","if","second_diff","<","3600",":","return","str","(","second_diff","\/","60",")","+","\" \u5206\u949f\u524d\"","if","second_diff","<","7200",":","return","\"1 \u5c0f\u65f6\u524d\"","if","second_diff","<","86400",":","return","str","(","second_diff","\/","3600",")","+","\" \u5c0f\u65f6\u524d\"","if","day_diff","==","1",":","return","\"\u6628\u5929\"","if","day_diff","<","7",":","return","str","(","day_diff",")","+","\" \u5929\u524d\"","if","day_diff","<","31",":","return","str","(","day_diff","\/","7",")","+","\" \u5468\u524d\"","if","day_diff","<","365",":","return","str","(","day_diff","\/","30",")","+","\" \u6708\u524d\"","return","str","(","day_diff","\/","365",")","+","\" \u5929\u524d\""],"url":"https:\/\/github.com\/3n1b-com\/3n1b.com\/blob\/5ee4db23bb665dcbb926c9a55603279ea8a2a73e\/helper.py#L82-L128"}
{"nwo":"3n1b-com\/3n1b.com","sha":"5ee4db23bb665dcbb926c9a55603279ea8a2a73e","path":"lib\/gravatar.py","language":"python","identifier":"sanitize_email","parameters":"(email)","argument_list":"","return_statement":"return email.lower().strip()","docstring":"Returns an e-mail address in lower-case and strip leading and trailing\n    whitespaces.\n\n    >>> sanitize_email(' MyEmailAddress@example.com ')\n    'myemailaddress@example.com'","docstring_summary":"Returns an e-mail address in lower-case and strip leading and trailing\n    whitespaces.","docstring_tokens":["Returns","an","e","-","mail","address","in","lower","-","case","and","strip","leading","and","trailing","whitespaces","."],"function":"def sanitize_email(email):\n    \"\"\"\n    Returns an e-mail address in lower-case and strip leading and trailing\n    whitespaces.\n\n    >>> sanitize_email(' MyEmailAddress@example.com ')\n    'myemailaddress@example.com'\n\n    \"\"\"\n    return email.lower().strip()","function_tokens":["def","sanitize_email","(","email",")",":","return","email",".","lower","(",")",".","strip","(",")"],"url":"https:\/\/github.com\/3n1b-com\/3n1b.com\/blob\/5ee4db23bb665dcbb926c9a55603279ea8a2a73e\/lib\/gravatar.py#L129-L138"}
{"nwo":"3n1b-com\/3n1b.com","sha":"5ee4db23bb665dcbb926c9a55603279ea8a2a73e","path":"lib\/gravatar.py","language":"python","identifier":"md5_hash","parameters":"(email)","argument_list":"","return_statement":"return md5(email.encode('utf-8')).hexdigest()","docstring":"Returns a md5 hash from an e-mail address.\n\n    >>> md5_hash('myemailaddress@example.com')\n    '0bc83cb571cd1c50ba6f3e8a78ef1346'","docstring_summary":"Returns a md5 hash from an e-mail address.","docstring_tokens":["Returns","a","md5","hash","from","an","e","-","mail","address","."],"function":"def md5_hash(email):\n    \"\"\"\n    Returns a md5 hash from an e-mail address.\n\n    >>> md5_hash('myemailaddress@example.com')\n    '0bc83cb571cd1c50ba6f3e8a78ef1346'\n\n    \"\"\"\n    return md5(email.encode('utf-8')).hexdigest()","function_tokens":["def","md5_hash","(","email",")",":","return","md5","(","email",".","encode","(","'utf-8'",")",")",".","hexdigest","(",")"],"url":"https:\/\/github.com\/3n1b-com\/3n1b.com\/blob\/5ee4db23bb665dcbb926c9a55603279ea8a2a73e\/lib\/gravatar.py#L141-L149"}
{"nwo":"3n1b-com\/3n1b.com","sha":"5ee4db23bb665dcbb926c9a55603279ea8a2a73e","path":"lib\/gravatar.py","language":"python","identifier":"Gravatar.get_image","parameters":"(self, size=80, filetype_extension=True)","argument_list":"","return_statement":"return base_url.format(**data)","docstring":"Returns an URL to the user profile image.","docstring_summary":"Returns an URL to the user profile image.","docstring_tokens":["Returns","an","URL","to","the","user","profile","image","."],"function":"def get_image(self, size=80, filetype_extension=True):\n        \"\"\"\n        Returns an URL to the user profile image.\n        \"\"\"\n        base_url = 'http:\/\/www.gravatar.com\/avatar\/' \\\n            '{hash}{extension}?size={size}'\n        extension = '.jpg' if filetype_extension else ''\n\n        data = {\n            'hash': self.email_hash,\n            'extension': extension,\n            'size': size,\n        }\n        return base_url.format(**data)","function_tokens":["def","get_image","(","self",",","size","=","80",",","filetype_extension","=","True",")",":","base_url","=","'http:\/\/www.gravatar.com\/avatar\/'","'{hash}{extension}?size={size}'","extension","=","'.jpg'","if","filetype_extension","else","''","data","=","{","'hash'",":","self",".","email_hash",",","'extension'",":","extension",",","'size'",":","size",",","}","return","base_url",".","format","(","*","*","data",")"],"url":"https:\/\/github.com\/3n1b-com\/3n1b.com\/blob\/5ee4db23bb665dcbb926c9a55603279ea8a2a73e\/lib\/gravatar.py#L44-L57"}
{"nwo":"3n1b-com\/3n1b.com","sha":"5ee4db23bb665dcbb926c9a55603279ea8a2a73e","path":"lib\/gravatar.py","language":"python","identifier":"Gravatar.get_profile","parameters":"(self, data_format='')","argument_list":"","return_statement":"return base_url.format(**data)","docstring":"Returns an URL to the profile information associated with the\n        Gravatar account.","docstring_summary":"Returns an URL to the profile information associated with the\n        Gravatar account.","docstring_tokens":["Returns","an","URL","to","the","profile","information","associated","with","the","Gravatar","account","."],"function":"def get_profile(self, data_format=''):\n        \"\"\"\n        Returns an URL to the profile information associated with the\n        Gravatar account.\n        \"\"\"\n        base_url = 'http:\/\/www.gravatar.com\/{hash}{data_format}'\n\n        valid_formats = ['json', 'xml', 'php', 'vcf', 'qr']\n        if data_format and data_format in valid_formats:\n            data_format = '.%s' % data_format\n\n        data = {\n            'hash': self.email_hash,\n            'data_format': data_format,\n        }\n        return base_url.format(**data)","function_tokens":["def","get_profile","(","self",",","data_format","=","''",")",":","base_url","=","'http:\/\/www.gravatar.com\/{hash}{data_format}'","valid_formats","=","[","'json'",",","'xml'",",","'php'",",","'vcf'",",","'qr'","]","if","data_format","and","data_format","in","valid_formats",":","data_format","=","'.%s'","%","data_format","data","=","{","'hash'",":","self",".","email_hash",",","'data_format'",":","data_format",",","}","return","base_url",".","format","(","*","*","data",")"],"url":"https:\/\/github.com\/3n1b-com\/3n1b.com\/blob\/5ee4db23bb665dcbb926c9a55603279ea8a2a73e\/lib\/gravatar.py#L59-L74"}
{"nwo":"3n1b-com\/3n1b.com","sha":"5ee4db23bb665dcbb926c9a55603279ea8a2a73e","path":"lib\/gravatar.py","language":"python","identifier":"GravatarXMLRPC.exists","parameters":"(self, hashes)","argument_list":"","return_statement":"return results","docstring":"Checks whether a hash has a gravatar.","docstring_summary":"Checks whether a hash has a gravatar.","docstring_tokens":["Checks","whether","a","hash","has","a","gravatar","."],"function":"def exists(self, hashes):\n        \"\"\"Checks whether a hash has a gravatar.\"\"\"\n        response = self._call('exists', params={'hashes': hashes})\n        results = {}\n        for key, value in response.items():\n            results[key] = True if value else False\n        return results","function_tokens":["def","exists","(","self",",","hashes",")",":","response","=","self",".","_call","(","'exists'",",","params","=","{","'hashes'",":","hashes","}",")","results","=","{","}","for","key",",","value","in","response",".","items","(",")",":","results","[","key","]","=","True","if","value","else","False","return","results"],"url":"https:\/\/github.com\/3n1b-com\/3n1b.com\/blob\/5ee4db23bb665dcbb926c9a55603279ea8a2a73e\/lib\/gravatar.py#L93-L99"}
{"nwo":"3n1b-com\/3n1b.com","sha":"5ee4db23bb665dcbb926c9a55603279ea8a2a73e","path":"lib\/gravatar.py","language":"python","identifier":"GravatarXMLRPC.addresses","parameters":"(self)","argument_list":"","return_statement":"return self._call('addresses')","docstring":"Gets a list of addresses for this account.","docstring_summary":"Gets a list of addresses for this account.","docstring_tokens":["Gets","a","list","of","addresses","for","this","account","."],"function":"def addresses(self):\n        \"\"\"Gets a list of addresses for this account.\"\"\"\n        return self._call('addresses')","function_tokens":["def","addresses","(","self",")",":","return","self",".","_call","(","'addresses'",")"],"url":"https:\/\/github.com\/3n1b-com\/3n1b.com\/blob\/5ee4db23bb665dcbb926c9a55603279ea8a2a73e\/lib\/gravatar.py#L101-L103"}
{"nwo":"3n1b-com\/3n1b.com","sha":"5ee4db23bb665dcbb926c9a55603279ea8a2a73e","path":"lib\/gravatar.py","language":"python","identifier":"GravatarXMLRPC.userimages","parameters":"(self)","argument_list":"","return_statement":"return self._call('userimages')","docstring":"Returns a dict of userimages for this account.","docstring_summary":"Returns a dict of userimages for this account.","docstring_tokens":["Returns","a","dict","of","userimages","for","this","account","."],"function":"def userimages(self):\n        \"\"\"Returns a dict of userimages for this account.\"\"\"\n        return self._call('userimages')","function_tokens":["def","userimages","(","self",")",":","return","self",".","_call","(","'userimages'",")"],"url":"https:\/\/github.com\/3n1b-com\/3n1b.com\/blob\/5ee4db23bb665dcbb926c9a55603279ea8a2a73e\/lib\/gravatar.py#L105-L107"}
{"nwo":"3n1b-com\/3n1b.com","sha":"5ee4db23bb665dcbb926c9a55603279ea8a2a73e","path":"lib\/gravatar.py","language":"python","identifier":"GravatarXMLRPC.test","parameters":"(self)","argument_list":"","return_statement":"return self._call('test')","docstring":"Test the API.","docstring_summary":"Test the API.","docstring_tokens":["Test","the","API","."],"function":"def test(self):\n        \"\"\"Test the API.\"\"\"\n        return self._call('test')","function_tokens":["def","test","(","self",")",":","return","self",".","_call","(","'test'",")"],"url":"https:\/\/github.com\/3n1b-com\/3n1b.com\/blob\/5ee4db23bb665dcbb926c9a55603279ea8a2a73e\/lib\/gravatar.py#L109-L111"}
{"nwo":"3n1b-com\/3n1b.com","sha":"5ee4db23bb665dcbb926c9a55603279ea8a2a73e","path":"lib\/gravatar.py","language":"python","identifier":"GravatarXMLRPC._call","parameters":"(self, method, params={})","argument_list":"","return_statement":"","docstring":"Call a method from the API, gets 'grav.' prepended to it.","docstring_summary":"Call a method from the API, gets 'grav.' prepended to it.","docstring_tokens":["Call","a","method","from","the","API","gets","grav",".","prepended","to","it","."],"function":"def _call(self, method, params={}):\n        \"\"\"Call a method from the API, gets 'grav.' prepended to it.\"\"\"\n\n        args = {\n            'apikey': self.apikey,\n            'password': self.password,\n        }\n        args.update(params)\n\n        try:\n            return getattr(self._server, 'grav.' + method, None)(args)\n        except xmlrpc.client.Fault as error:\n            error_msg = \"Server error: {1} (error code: {0})\"\n            print(error_msg.format(error.faultCode, error.faultString))","function_tokens":["def","_call","(","self",",","method",",","params","=","{","}",")",":","args","=","{","'apikey'",":","self",".","apikey",",","'password'",":","self",".","password",",","}","args",".","update","(","params",")","try",":","return","getattr","(","self",".","_server",",","'grav.'","+","method",",","None",")","(","args",")","except","xmlrpc",".","client",".","Fault","as","error",":","error_msg","=","\"Server error: {1} (error code: {0})\"","print","(","error_msg",".","format","(","error",".","faultCode",",","error",".","faultString",")",")"],"url":"https:\/\/github.com\/3n1b-com\/3n1b.com\/blob\/5ee4db23bb665dcbb926c9a55603279ea8a2a73e\/lib\/gravatar.py#L113-L126"}
{"nwo":"3n1b-com\/3n1b.com","sha":"5ee4db23bb665dcbb926c9a55603279ea8a2a73e","path":"lib\/forms.py","language":"python","identifier":"Form.__init__","parameters":"(self, formdata=None, obj=None, prefix='', **kwargs)","argument_list":"","return_statement":"","docstring":"Wrap the `formdata` with the `TornadoInputWrapper` and call the base\n        constuctor.","docstring_summary":"Wrap the `formdata` with the `TornadoInputWrapper` and call the base\n        constuctor.","docstring_tokens":["Wrap","the","formdata","with","the","TornadoInputWrapper","and","call","the","base","constuctor","."],"function":"def __init__(self, formdata=None, obj=None, prefix='', **kwargs):\n        \"\"\"\n        Wrap the `formdata` with the `TornadoInputWrapper` and call the base\n        constuctor.\n        \"\"\"\n        self._handler = formdata\n        super(Form, self).__init__(TornadoInputWrapper(formdata),\n            obj=obj, prefix=prefix, **kwargs)","function_tokens":["def","__init__","(","self",",","formdata","=","None",",","obj","=","None",",","prefix","=","''",",","*","*","kwargs",")",":","self",".","_handler","=","formdata","super","(","Form",",","self",")",".","__init__","(","TornadoInputWrapper","(","formdata",")",",","obj","=","obj",",","prefix","=","prefix",",","*","*","kwargs",")"],"url":"https:\/\/github.com\/3n1b-com\/3n1b.com\/blob\/5ee4db23bb665dcbb926c9a55603279ea8a2a73e\/lib\/forms.py#L58-L65"}
{"nwo":"3n1b-com\/3n1b.com","sha":"5ee4db23bb665dcbb926c9a55603279ea8a2a73e","path":"lib\/xss.py","language":"python","identifier":"xssescape","parameters":"(text)","argument_list":"","return_statement":"return escape(text, quote=True)","docstring":"Gets rid of < and > and & and, for good measure, :","docstring_summary":"Gets rid of < and > and & and, for good measure, :","docstring_tokens":["Gets","rid","of","<","and",">","and","&","and","for","good","measure",":"],"function":"def xssescape(text):\n    \"\"\"Gets rid of < and > and & and, for good measure, :\"\"\"\n    # return escape(text, quote=True).replace(':','&#58;')\n    # return re.sub(r'(?<!http)(?<!https):', '&#58;', escape(text, quote=True))\n    return escape(text, quote=True)","function_tokens":["def","xssescape","(","text",")",":","# return escape(text, quote=True).replace(':','&#58;')","# return re.sub(r'(?<!http)(?<!https):', '&#58;', escape(text, quote=True))","return","escape","(","text",",","quote","=","True",")"],"url":"https:\/\/github.com\/3n1b-com\/3n1b.com\/blob\/5ee4db23bb665dcbb926c9a55603279ea8a2a73e\/lib\/xss.py#L17-L21"}
{"nwo":"3n1b-com\/3n1b.com","sha":"5ee4db23bb665dcbb926c9a55603279ea8a2a73e","path":"lib\/xss.py","language":"python","identifier":"XssCleaner.strip","parameters":"(self, rawstring)","argument_list":"","return_statement":"return self.result","docstring":"Returns the argument stripped of potentially harmful HTML or Javascript code","docstring_summary":"Returns the argument stripped of potentially harmful HTML or Javascript code","docstring_tokens":["Returns","the","argument","stripped","of","potentially","harmful","HTML","or","Javascript","code"],"function":"def strip(self, rawstring):\n        \"\"\"Returns the argument stripped of potentially harmful HTML or Javascript code\"\"\"\n        self.result = \"\"\n        self.feed(rawstring)\n        for endtag in self.open_tags:\n            if endtag not in self.requires_no_close:\n                self.result += \"<\/%s>\" % endtag\n        return self.result","function_tokens":["def","strip","(","self",",","rawstring",")",":","self",".","result","=","\"\"","self",".","feed","(","rawstring",")","for","endtag","in","self",".","open_tags",":","if","endtag","not","in","self",".","requires_no_close",":","self",".","result","+=","\"<\/%s>\"","%","endtag","return","self",".","result"],"url":"https:\/\/github.com\/3n1b-com\/3n1b.com\/blob\/5ee4db23bb665dcbb926c9a55603279ea8a2a73e\/lib\/xss.py#L107-L114"}
{"nwo":"3n1b-com\/3n1b.com","sha":"5ee4db23bb665dcbb926c9a55603279ea8a2a73e","path":"lib\/xss.py","language":"python","identifier":"XssCleaner.xtags","parameters":"(self)","argument_list":"","return_statement":"return xssescape(tg.strip())","docstring":"Returns a printable string informing the user which tags are allowed","docstring_summary":"Returns a printable string informing the user which tags are allowed","docstring_tokens":["Returns","a","printable","string","informing","the","user","which","tags","are","allowed"],"function":"def xtags(self):\n        \"\"\"Returns a printable string informing the user which tags are allowed\"\"\"\n        self.permitted_tags.sort()\n        tg = \"\"\n        for x in self.permitted_tags:\n            tg += \"<\" + x\n            if x in self.allowed_attributes:\n                for y in self.allowed_attributes[x]:\n                    tg += ' %s=\"\"' % y\n            tg += \"> \"\n        return xssescape(tg.strip())","function_tokens":["def","xtags","(","self",")",":","self",".","permitted_tags",".","sort","(",")","tg","=","\"\"","for","x","in","self",".","permitted_tags",":","tg","+=","\"<\"","+","x","if","x","in","self",".","allowed_attributes",":","for","y","in","self",".","allowed_attributes","[","x","]",":","tg","+=","' %s=\"\"'","%","y","tg","+=","\"> \"","return","xssescape","(","tg",".","strip","(",")",")"],"url":"https:\/\/github.com\/3n1b-com\/3n1b.com\/blob\/5ee4db23bb665dcbb926c9a55603279ea8a2a73e\/lib\/xss.py#L115-L125"}
{"nwo":"3n1b-com\/3n1b.com","sha":"5ee4db23bb665dcbb926c9a55603279ea8a2a73e","path":"handler\/topic.py","language":"python","identifier":"ProfileHandler.get","parameters":"(self, user, template_variables = {})","argument_list":"","return_statement":"","docstring":"if user_info[\"github\"]:\n            github_repos = self.mc.get(str(\"%s_github_repos\" % user_info[\"github\"])) or json.JSONDecoder().decode(urllib2.urlopen('https:\/\/api.github.com\/users\/%s\/repos' % user_info[\"github\"]).read())\n            self.mc.set(str(\"%s_github_repos\" % user_info[\"github\"]), github_repos)\n            template_variables[\"github_repos\"] = github_repos","docstring_summary":"if user_info[\"github\"]:\n            github_repos = self.mc.get(str(\"%s_github_repos\" % user_info[\"github\"])) or json.JSONDecoder().decode(urllib2.urlopen('https:\/\/api.github.com\/users\/%s\/repos' % user_info[\"github\"]).read())\n            self.mc.set(str(\"%s_github_repos\" % user_info[\"github\"]), github_repos)\n            template_variables[\"github_repos\"] = github_repos","docstring_tokens":["if","user_info","[","github","]",":","github_repos","=","self",".","mc",".","get","(","str","(","%s_github_repos","%","user_info","[","github","]","))","or","json",".","JSONDecoder","()",".","decode","(","urllib2",".","urlopen","(","https",":","\/\/","api",".","github",".","com","\/","users","\/","%s","\/","repos","%","user_info","[","github","]",")",".","read","()",")","self",".","mc",".","set","(","str","(","%s_github_repos","%","user_info","[","github","]",")","github_repos",")","template_variables","[","github_repos","]","=","github_repos"],"function":"def get(self, user, template_variables = {}):\n        current_user_info = self.current_user\n        if(re.match(r'^\\d+$', user)):\n            user_info = self.user_model.get_user_by_uid(user)\n        else:\n            user_info = self.user_model.get_user_by_username(user)\n        page = int(self.get_argument(\"p\", \"1\"))\n        template_variables[\"user_info\"] = user_info\n        follow_text = \"+\u5173\u6ce8\"\n        show_follow = True;\n        if(user_info):\n            template_variables[\"user_info\"][\"counter\"] = {\n                \"topics\": self.topic_model.get_user_all_topics_count(user_info[\"uid\"]),\n                \"replies\": self.reply_model.get_user_all_replies_count(user_info[\"uid\"]),\n                \"favorites\": self.favorite_model.get_user_favorite_count(user_info[\"uid\"]),\n                \"notifications\": self.notification_model.get_user_unread_notification_count(user_info[\"uid\"]),\n                \"messages\": self.message_model.get_user_unread_message_count(user_info[\"uid\"]),\n            }\n            if(current_user_info):\n                if(user_info[\"uid\"] == current_user_info[\"uid\"]):\n                    show_follow = False;\n                else:\n                    show_follow = True;\n                    follow = self.follow_model.get_follow_info_by_user_id_and_follow_user_id(current_user_info[\"uid\"], user_info[\"uid\"])\n                    if(follow):\n                        follow_text = \"\u53d6\u6d88\u5173\u6ce8\"                     \n        template_variables[\"follow_text\"] = follow_text\n        template_variables[\"show_follow\"] = show_follow\n\n        '''\n        if user_info[\"github\"]:\n            github_repos = self.mc.get(str(\"%s_github_repos\" % user_info[\"github\"])) or json.JSONDecoder().decode(urllib2.urlopen('https:\/\/api.github.com\/users\/%s\/repos' % user_info[\"github\"]).read())\n            self.mc.set(str(\"%s_github_repos\" % user_info[\"github\"]), github_repos)\n            template_variables[\"github_repos\"] = github_repos\n        '''\n\n        template_variables[\"topics\"] = self.topic_model.get_user_all_topics(user_info[\"uid\"], current_page = page)\n        template_variables[\"replies\"] = self.reply_model.get_user_all_replies(user_info[\"uid\"], current_page = page)\n        template_variables[\"gen_random\"] = gen_random\n        template_variables[\"active_page\"] = \"_blank\"\n        template_variables[\"wallpaper\"] = self.get_wallpaper()\n        self.render(\"topic\/profile.html\", **template_variables)","function_tokens":["def","get","(","self",",","user",",","template_variables","=","{","}",")",":","current_user_info","=","self",".","current_user","if","(","re",".","match","(","r'^\\d+$'",",","user",")",")",":","user_info","=","self",".","user_model",".","get_user_by_uid","(","user",")","else",":","user_info","=","self",".","user_model",".","get_user_by_username","(","user",")","page","=","int","(","self",".","get_argument","(","\"p\"",",","\"1\"",")",")","template_variables","[","\"user_info\"","]","=","user_info","follow_text","=","\"+\u5173\u6ce8\"","show_follow","=","True","if","(","user_info",")",":","template_variables","[","\"user_info\"","]","[","\"counter\"","]","=","{","\"topics\"",":","self",".","topic_model",".","get_user_all_topics_count","(","user_info","[","\"uid\"","]",")",",","\"replies\"",":","self",".","reply_model",".","get_user_all_replies_count","(","user_info","[","\"uid\"","]",")",",","\"favorites\"",":","self",".","favorite_model",".","get_user_favorite_count","(","user_info","[","\"uid\"","]",")",",","\"notifications\"",":","self",".","notification_model",".","get_user_unread_notification_count","(","user_info","[","\"uid\"","]",")",",","\"messages\"",":","self",".","message_model",".","get_user_unread_message_count","(","user_info","[","\"uid\"","]",")",",","}","if","(","current_user_info",")",":","if","(","user_info","[","\"uid\"","]","==","current_user_info","[","\"uid\"","]",")",":","show_follow","=","False","else",":","show_follow","=","True","follow","=","self",".","follow_model",".","get_follow_info_by_user_id_and_follow_user_id","(","current_user_info","[","\"uid\"","]",",","user_info","[","\"uid\"","]",")","if","(","follow",")",":","follow_text","=","\"\u53d6\u6d88\u5173\u6ce8\"        ","template_variables","[","\"follow_text\"","]","=","follow_text","template_variables","[","\"show_follow\"","]","=","show_follow","template_variables","[","\"topics\"","]","=","self",".","topic_model",".","get_user_all_topics","(","user_info","[","\"uid\"","]",",","current_page","=","page",")","template_variables","[","\"replies\"","]","=","self",".","reply_model",".","get_user_all_replies","(","user_info","[","\"uid\"","]",",","current_page","=","page",")","template_variables","[","\"gen_random\"","]","=","gen_random","template_variables","[","\"active_page\"","]","=","\"_blank\"","template_variables","[","\"wallpaper\"","]","=","self",".","get_wallpaper","(",")","self",".","render","(","\"topic\/profile.html\"",",","*","*","template_variables",")"],"url":"https:\/\/github.com\/3n1b-com\/3n1b.com\/blob\/5ee4db23bb665dcbb926c9a55603279ea8a2a73e\/handler\/topic.py#L407-L448"}