• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python profile.Profile类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中market.profile.Profile的典型用法代码示例。如果您正苦于以下问题:Python Profile类的具体用法?Python Profile怎么用?Python Profile使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了Profile类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: test_MarketProfile_replace_social_no_proof

 def test_MarketProfile_replace_social_no_proof(self):
     p = Profile(self.db)
     p.add_social_account("FACEBOOK", "test_updated_username")
     u = p.get()
     self.assertEqual(1, len(u.social))
     self.assertEqual(0, u.social[0].type)
     self.assertEqual('test_updated_username', u.social[0].username)
开发者ID:1234max,项目名称:OpenBazaar-Server,代码行数:7,代码来源:test_profile.py


示例2: test_MarketProfile_update_success

 def test_MarketProfile_update_success(self):
     u = objects.Profile()
     u.about = "updated world"
     p = Profile(self.db)
     p.update(u)
     updated_user = p.get()
     self.assertEqual("updated world", updated_user.about)
开发者ID:1234max,项目名称:OpenBazaar-Server,代码行数:7,代码来源:test_profile.py


示例3: test_MarketProfile_add_social_invalid

 def test_MarketProfile_add_social_invalid(self):
     p = Profile(self.db)
     p.add_social_account("TEST", "test_twitter_username")
     u = p.get()
     self.assertEqual(1, len(u.social))
     self.assertEqual(0, u.social[0].type)
     self.assertEqual('test_fb_username', u.social[0].username)
开发者ID:1234max,项目名称:OpenBazaar-Server,代码行数:7,代码来源:test_profile.py


示例4: test_MarketProfile_add_social_no_proof

 def test_MarketProfile_add_social_no_proof(self):
     p = Profile(self.db)
     p.add_social_account("TWITTER", "test_twitter_username")
     u = p.get()
     self.assertEqual(2, len(u.social))
     self.assertEqual(0, u.social[0].type)
     self.assertEqual('test_fb_username', u.social[0].username)
     self.assertEqual(1, u.social[1].type)
     self.assertEqual('test_twitter_username', u.social[1].username)
开发者ID:1234max,项目名称:OpenBazaar-Server,代码行数:9,代码来源:test_profile.py


示例5: addsocialaccount

 def addsocialaccount():
     parser = argparse.ArgumentParser(
         description="Add a social media account to the profile.",
         usage='''usage:
 networkcli.py addsocialaccout -t TYPE, -u USERNAME, -p PROOF''')
     parser.add_argument('-t', '--type', help="the type of account")
     parser.add_argument('-u', '--username', help="the username")
     parser.add_argument('-p', '--proof', help="the proof url")
     args = parser.parse_args(sys.argv[2:])
     p = Profile()
     p.add_social_account(args.type, args.username, args.proof)
开发者ID:the9ull,项目名称:OpenBazaar-Server,代码行数:11,代码来源:networkcli.py


示例6: delete_social_account

 def delete_social_account(self, request):
     try:
         p = Profile(self.db)
         if "account_type" in request.args:
             p.remove_social_account(request.args["account_type"][0])
         request.write(json.dumps({"success": True}))
         request.finish()
         return server.NOT_DONE_YET
     except Exception, e:
         request.write(json.dumps({"success": False, "reason": e.message}, indent=4))
         request.finish()
         return server.NOT_DONE_YET
开发者ID:syntox,项目名称:OpenBazaar-Server,代码行数:12,代码来源:restapi.py


示例7: addpgpkey

 def addpgpkey():
     parser = argparse.ArgumentParser(
         description="Add a pgp key to the profile.",
         usage='''usage:
 networkcli.py addpgpkey -k KEY, -s SIGNATURE''')
     parser.add_argument('-k', '--key', help="path to the key file")
     parser.add_argument('-s', '--signature', help="path to the signature file")
     args = parser.parse_args(sys.argv[2:])
     with open(args.key, "r") as filename:
         key = filename.read()
     with open(args.signature, "r") as filename:
         sig = filename.read()
     p = Profile()
     print p.add_pgp_key(key, sig, KeyChain().guid.encode("hex"))
开发者ID:the9ull,项目名称:OpenBazaar-Server,代码行数:14,代码来源:networkcli.py


示例8: add_social_account

 def add_social_account(self, request):
     try:
         p = Profile(self.db)
         if "account_type" in request.args and "username" in request.args:
             p.add_social_account(request.args["account_type"][0], request.args["username"][0],
                                  request.args["proof"][0] if "proof" in request.args else None)
         else:
             raise Exception("Missing required fields")
         request.write(json.dumps({"success": True}))
         request.finish()
         return server.NOT_DONE_YET
     except Exception, e:
         request.write(json.dumps({"success": False, "reason": e.message}, indent=4))
         request.finish()
         return server.NOT_DONE_YET
开发者ID:syntox,项目名称:OpenBazaar-Server,代码行数:15,代码来源:restapi.py


示例9: update_profile

 def update_profile(self, request):
     try:
         p = Profile(self.db)
         if not p.get().encryption_key \
                 and "name" not in request.args \
                 and "location" not in request.args:
             request.write(json.dumps({"success": False, "reason": "name or location not included"}, indent=4))
             request.finish()
             return False
         u = objects.Profile()
         if "name" in request.args:
             u.name = request.args["name"][0]
         if "location" in request.args:
             # This needs to be formatted. Either here or from the UI.
             u.location = CountryCode.Value(request.args["location"][0].upper())
         if "handle" in request.args:
             u.handle = request.args["handle"][0]
         if "about" in request.args:
             u.about = request.args["about"][0]
         if "short_description" in request.args:
             u.short_description = request.args["short_description"][0]
         if "nsfw" in request.args:
             u.nsfw = bool(request.args["nsfw"][0])
         if "vendor" in request.args:
             u.vendor = bool(request.args["vendor"][0])
         if "moderator" in request.args:
             u.moderator = bool(request.args["moderator"][0])
         if "website" in request.args:
             u.website = request.args["website"][0]
         if "email" in request.args:
             u.email = request.args["email"][0]
         if "primary_color" in request.args:
             u.primary_color = int(request.args["primary_color"][0])
         if "secondary_color" in request.args:
             u.secondary_color = int(request.args["secondary_color"][0])
         if "background_color" in request.args:
             u.background_color = int(request.args["background_color"][0])
         if "text_color" in request.args:
             u.text_color = int(request.args["text_color"][0])
         if "avatar" in request.args:
             u.avatar_hash = unhexlify(request.args["avatar"][0])
         if "header" in request.args:
             u.header_hash = unhexlify(request.args["header"][0])
         if "pgp_key" in request.args and "signature" in request.args:
             p.add_pgp_key(request.args["pgp_key"][0], request.args["signature"][0],
                           self.keychain.guid.encode("hex"))
         enc = u.PublicKey()
         enc.public_key = self.keychain.encryption_pubkey
         enc.signature = self.keychain.signing_key.sign(enc.public_key)[:64]
         u.encryption_key.MergeFrom(enc)
         p.update(u)
         request.write(json.dumps({"success": True}))
         request.finish()
         return server.NOT_DONE_YET
     except Exception, e:
         request.write(json.dumps({"success": False, "reason": e.message}, indent=4))
         request.finish()
         return server.NOT_DONE_YET
开发者ID:gubatron,项目名称:OpenBazaar-Server,代码行数:58,代码来源:restapi.py


示例10: update_profile

 def update_profile(self, request):
     try:
         p = Profile(self.db)
         if not p.get().encryption_key \
                 and "name" not in request.args \
                 and "location" not in request.args:
             return "False"
         u = objects.Profile()
         if "name" in request.args:
             u.name = request.args["name"][0]
         if "location" in request.args:
             # This needs to be formatted. Either here or from the UI.
             u.location = CountryCode.Value(request.args["location"][0].upper())
         if "handle" in request.args:
             u.handle = request.args["handle"][0]
         if "about" in request.args:
             u.about = request.args["about"][0]
         if "short_description" in request.args:
             u.short_description = request.args["short_description"][0]
         if "nsfw" in request.args:
             u.nsfw = True
         if "vendor" in request.args:
             u.vendor = True
         if "moderator" in request.args:
             u.moderator = True
         if "website" in request.args:
             u.website = request.args["website"][0]
         if "email" in request.args:
             u.email = request.args["email"][0]
         if "avatar" in request.args:
             with open(DATA_FOLDER + "store/avatar", 'wb') as outfile:
                 outfile.write(request.args["avatar"][0])
             avatar_hash = digest(request.args["avatar"][0])
             self.db.HashMap().insert(avatar_hash, DATA_FOLDER + "store/avatar")
             u.avatar_hash = avatar_hash
         if "header" in request.args:
             with open(DATA_FOLDER + "store/header", 'wb') as outfile:
                 outfile.write(request.args["header"][0])
             header_hash = digest(request.args["header"][0])
             self.db.HashMap().insert(header_hash, DATA_FOLDER + "store/header")
             u.header_hash = header_hash
         if "pgp_key" in request.args and "signature" in request.args:
             p.add_pgp_key(request.args["pgp_key"][0], request.args["signature"][0],
                           self.keychain.guid.encode("hex"))
         enc = u.PublicKey()
         enc.public_key = self.keychain.encryption_pubkey
         enc.signature = self.keychain.signing_key.sign(enc.public_key)[:64]
         u.encryption_key.MergeFrom(enc)
         p.update(u)
         request.write(json.dumps({"success": True}))
         request.finish()
         return server.NOT_DONE_YET
     except Exception, e:
         request.write(json.dumps({"success": False, "reason": e.message}, indent=4))
         request.finish()
         return server.NOT_DONE_YET
开发者ID:Joaz,项目名称:OpenBazaar-Server,代码行数:56,代码来源:restapi.py


示例11: setprofile

 def setprofile():
     parser = argparse.ArgumentParser(
         description="Sets a profile in the database.",
         usage='''usage:
 networkcli.py setprofile [options]''')
     parser.add_argument('-n', '--name', help="the name of the user/store")
     parser.add_argument('-o', '--onename', help="the onename id")
     parser.add_argument('-a', '--avatar', help="the file path to the avatar image")
     parser.add_argument('-hd', '--header', help="the file path to the header image")
     parser.add_argument('-c', '--country',
                         help="a string consisting of country from protos.countries.CountryCode")
     # we could add all the fields here but this is good enough to test.
     args = parser.parse_args(sys.argv[2:])
     p = Profile()
     u = objects.Profile()
     h = HashMap()
     if args.name is not None:
         u.name = args.name
     if args.country is not None:
         u.location = countries.CountryCode.Value(args.country.upper())
     if args.onename is not None:
         u.handle = args.onename
     if args.avatar is not None:
         with open(args.avatar, "r") as filename:
             image = filename.read()
         hash_value = digest(image)
         u.avatar_hash = hash_value
         h.insert(hash_value, args.avatar)
     if args.header is not None:
         with open(args.header, "r") as filename:
             image = filename.read()
         hash_value = digest(image)
         u.header_hash = hash_value
         h.insert(hash_value, args.header)
     u.encryption_key = KeyChain().encryption_pubkey
     p.update(u)
开发者ID:Bitorious,项目名称:OpenBazaar-Server,代码行数:36,代码来源:networkcli.py


示例12: update_profile

 def update_profile(self, request):
     p = Profile()
     if not p.get().encryption_key \
             and "name" not in request.args \
             and "location" not in request.args:
         return "False"
     u = objects.Profile()
     if "name" in request.args:
         u.name = request.args["name"][0]
     if "location" in request.args:
         # This needs to be formatted. Either here or from the UI.
         u.location = CountryCode.Value(request.args["location"][0].upper())
     if "handle" in request.args:
         u.handle = request.args["handle"][0]
     if "about" in request.args:
         u.about = request.args["about"][0]
     if "short_description" in request.args:
         u.short_description = request.args["short_description"][0]
     if "nsfw" in request.args:
         u.nsfw = True
     if "vendor" in request.args:
         u.vendor = True
     if "moderator" in request.args:
         u.moderator = True
     if "website" in request.args:
         u.website = request.args["website"][0]
     if "email" in request.args:
         u.email = request.args["email"][0]
     if "avatar" in request.args:
         with open(DATA_FOLDER + "store/avatar", 'wb') as outfile:
             outfile.write(request.args["avatar"][0])
         avatar_hash = digest(request.args["avatar"][0])
         HashMap().insert(avatar_hash, DATA_FOLDER + "store/avatar")
         u.avatar_hash = avatar_hash
     if "header" in request.args:
         with open(DATA_FOLDER + "store/header", 'wb') as outfile:
             outfile.write(request.args["header"][0])
         header_hash = digest(request.args["header"][0])
         HashMap().insert(header_hash, DATA_FOLDER + "store/header")
         u.header_hash = header_hash
     if "pgp_key" in request.args and "signature" in request.args:
         p.add_pgp_key(request.args["pgp_key"][0], request.args["signature"][0],
                       KeyChain().guid.encode("hex"))
     enc = u.PublicKey()
     enc.public_key = KeyChain().encryption_pubkey
     enc.signature = KeyChain().signing_key.sign(enc.public_key)[:64]
     u.encryption_key.MergeFrom(enc)
     p.update(u)
开发者ID:bglassy,项目名称:OpenBazaar-Server,代码行数:48,代码来源:restapi.py


示例13: delete_social_account

 def delete_social_account(self, request):
     p = Profile()
     if "account_type" in request.args:
         p.remove_social_account(request.args["account_type"][0])
开发者ID:the9ull,项目名称:OpenBazaar-Server,代码行数:4,代码来源:restapi.py


示例14: add_social_account

 def add_social_account(self, request):
     p = Profile()
     if "account_type" in request.args and "username" in request.args and "proof" in request.args:
         p.add_social_account(request.args["account_type"][0], request.args["username"][0],
                              request.args["proof"][0])
开发者ID:the9ull,项目名称:OpenBazaar-Server,代码行数:5,代码来源:restapi.py


示例15: test_MarketProfile_remove_social

 def test_MarketProfile_remove_social(self):
     p = Profile(self.db)
     p.remove_social_account("FACEBOOK")
     u = p.get()
     self.assertEqual(0, len(u.social))
开发者ID:1234max,项目名称:OpenBazaar-Server,代码行数:5,代码来源:test_profile.py


示例16: test_MarketProfile_remove_field_success

 def test_MarketProfile_remove_field_success(self):
     p = Profile(self.db)
     p.remove_field("about")
     user = p.get()
     self.assertEqual('test_name', user.name)
     self.assertEqual('', user.about)
开发者ID:1234max,项目名称:OpenBazaar-Server,代码行数:6,代码来源:test_profile.py


示例17: test_MarketProfile_add_pgp_key_wrong_guid

 def test_MarketProfile_add_pgp_key_wrong_guid(self):
     p = Profile(self.db)
     wrong_guid = '5c2dedbd-5977-4326-b965-c9a2435c8e91'
     self.assertFalse(p.add_pgp_key(self.PUBLIC_KEY, self.SIGNATURE, wrong_guid))
开发者ID:1234max,项目名称:OpenBazaar-Server,代码行数:4,代码来源:test_profile.py


示例18: test_MarketProfile_add_pgp_key_success

 def test_MarketProfile_add_pgp_key_success(self):
     p = Profile(self.db)
     self.assertTrue(p.add_pgp_key(self.PUBLIC_KEY, self.SIGNATURE, self.VALID_GUID))
     u = p.get()
     self.assertEqual(self.SIGNATURE, u.pgp_key.signature)
     self.assertEqual(self.PUBLIC_KEY, u.pgp_key.public_key)
开发者ID:1234max,项目名称:OpenBazaar-Server,代码行数:6,代码来源:test_profile.py


示例19: test_MarketProfile_get_temp_handle

 def test_MarketProfile_get_temp_handle(self):
     p = Profile(self.db)
     self.assertEqual("test_handle", p.get_temp_handle())
开发者ID:1234max,项目名称:OpenBazaar-Server,代码行数:3,代码来源:test_profile.py


示例20: test_MarketProfile_remove_social_invalid

 def test_MarketProfile_remove_social_invalid(self):
     p = Profile(self.db)
     p.remove_social_account("TEST")
     u = p.get()
     self.assertEqual(1, len(u.social))
开发者ID:1234max,项目名称:OpenBazaar-Server,代码行数:5,代码来源:test_profile.py



注:本文中的market.profile.Profile类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python app.Marketplace类代码示例发布时间:2022-05-27
下一篇:
Python models.AddonPremium类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap