@GET('^/api/v1/profile')
    @authenticated
    def get_profile(self, request):
        def parse_profile(profile, temp_handle=None):
            if profile is not None:
                profile_json = {
                    "profile": {
                        "name": profile.name,
                        "location": str(CountryCode.Name(profile.location)),
                        "public_key": profile.guid_key.public_key.encode("hex"),
                        "nsfw": profile.nsfw,
                        "vendor": profile.vendor,
                        "moderator": profile.moderator,
                        "moderation_fee": round(profile.moderation_fee, 2),
                        "handle": profile.handle,
                        "about": profile.about,
                        "short_description": profile.short_description,
                        "website": profile.website,
                        "email": profile.email,
                        "primary_color": profile.primary_color,
                        "secondary_color": profile.secondary_color,
                        "background_color": profile.background_color,
                        "text_color": profile.text_color,
                        "pgp_key": profile.pgp_key.public_key,
                        "avatar_hash": profile.avatar_hash.encode("hex"),
                        "header_hash": profile.header_hash.encode("hex"),
                        "social_accounts": {}
                    }
                }
                if temp_handle:
                    profile_json["profile"]["temp_handle"] = temp_handle
                if "guid" in request.args:
                    profile_json["profile"]["guid"] = request.args["guid"][0]
                else:
                    profile_json["profile"]["guid"] = self.keychain.guid.encode("hex")
                for account in profile.social:
                    profile_json["profile"]["social_accounts"][str(
                        objects.Profile.SocialAccount.SocialType.Name(account.type)).lower()] = {
                            "username": account.username,
                            "proof_url": account.proof_url
                        }
                if (profile.handle is not "" and "(unconfirmed)" not in profile.handle and
                        not blockchainid.validate(profile.handle, profile_json["profile"]["guid"])):
                    profile_json["profile"]["handle"] = ""
                request.setHeader('content-type', "application/json")
                request.write(json.dumps(sanitize_html(profile_json), indent=4))
                request.finish()
            else:
                request.write(json.dumps({}))
                request.finish()
        if "guid" in request.args:
            def get_node(node):
                if node is not None:
                    self.mserver.get_profile(node).addCallback(parse_profile)
                else:
                    request.write(json.dumps({}))
                    request.finish()
            self.kserver.resolve(unhexlify(request.args["guid"][0])).addCallback(get_node)
        else:
            p = Profile(self.db).get()
            if not p.HasField("guid_key"):
                request.write(json.dumps({}))
                request.finish()
            else:
                temp_handle = self.db.profile.get_temp_handle()
                parse_profile(p, None if temp_handle == "" else temp_handle)
        return server.NOT_DONE_YET
dataset/ETHPy150Open OpenBazaar/OpenBazaar-Server/api/restapi.py/OpenBazaarAPI.get_profile/original