python类InputFileContent()的实例源码

setup.py 文件源码 项目:gitpwnd 作者: nccgroup 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def create_private_gist(config, main_github_token, filename, content, description):
    g = Github(main_github_token)
    g_user = g.get_user()
    gist = g_user.create_gist(False, {filename: github.InputFileContent(content)}, description)

    # gists have a list of files associated with them, we just want the first one
    # gist.files = {'filename': GistFile(filename), ...}
    gist_file = [x for x in gist.files.values()][0]
    config["gist_raw_contents_url"] = gist_file.raw_url

    # The structure of the url is:
    # https://gist.githubusercontent.com/<username>/<gist guid>/raw/<file guid>/<filename.txt>
    #
    # Since we're only uploading one file and we want to make the URL as concise as possible,
    # it turns out we can actually trim off everything after /raw/ and it'll still give us what
    # we want.
    config["gist_raw_contents_url"] = config["gist_raw_contents_url"].split("/raw/")[0] + "/raw"

    print("[*] Private gist content at:")
    print("- %s" % config["gist_raw_contents_url"])

    return config

# Return the content that will placed in the private gist
AuthenticatedUser.py 文件源码 项目:Repobot 作者: Desgard 项目源码 文件源码 阅读 18 收藏 0 点赞 0 评论 0
def testCreateGist(self):
        gist = self.user.create_gist(True, {"foobar.txt": github.InputFileContent("File created by PyGithub")}, "Gist created by PyGithub")
        self.assertEqual(gist.description, "Gist created by PyGithub")
        self.assertEqual(list(gist.files.keys()), ["foobar.txt"])
        self.assertEqual(gist.files["foobar.txt"].content, "File created by PyGithub")
AuthenticatedUser.py 文件源码 项目:Repobot 作者: Desgard 项目源码 文件源码 阅读 17 收藏 0 点赞 0 评论 0
def testCreateGistWithoutDescription(self):
        gist = self.user.create_gist(True, {"foobar.txt": github.InputFileContent("File created by PyGithub")})
        self.assertEqual(gist.description, None)
        self.assertEqual(list(gist.files.keys()), ["foobar.txt"])
        self.assertEqual(gist.files["foobar.txt"].content, "File created by PyGithub")
Gist.py 文件源码 项目:Repobot 作者: Desgard 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
def testEditWithAllParameters(self):
        gist = self.g.get_gist("2729810")
        gist.edit("Description edited by PyGithub", {"barbaz.txt": github.InputFileContent("File also created by PyGithub")})
        self.assertEqual(gist.description, "Description edited by PyGithub")
        self.assertEqual(gist.updated_at, datetime.datetime(2012, 5, 19, 7, 6, 10))
        self.assertEqual(set(gist.files.keys()), set(["foobar.txt", "barbaz.txt"]))
Gist.py 文件源码 项目:Repobot 作者: Desgard 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
def testRenameFile(self):
        gist = self.g.get_gist("5339374")
        self.assertEqual(list(gist.files.keys()), ["bar.txt"])
        gist.edit(files={"bar.txt": github.InputFileContent(gist.files["bar.txt"].content, new_name="baz.txt")})
        self.assertEqual(list(gist.files.keys()), ["baz.txt"])
AuthenticatedUser.py 文件源码 项目:TutLab 作者: KingsMentor 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def testCreateGist(self):
        gist = self.user.create_gist(True, {"foobar.txt": github.InputFileContent("File created by PyGithub")}, "Gist created by PyGithub")
        self.assertEqual(gist.description, "Gist created by PyGithub")
        self.assertEqual(gist.files.keys(), ["foobar.txt"])
        self.assertEqual(gist.files["foobar.txt"].content, "File created by PyGithub")
AuthenticatedUser.py 文件源码 项目:TutLab 作者: KingsMentor 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def testCreateGistWithoutDescription(self):
        gist = self.user.create_gist(True, {"foobar.txt": github.InputFileContent("File created by PyGithub")})
        self.assertEqual(gist.description, None)
        self.assertEqual(gist.files.keys(), ["foobar.txt"])
        self.assertEqual(gist.files["foobar.txt"].content, "File created by PyGithub")
Gist.py 文件源码 项目:TutLab 作者: KingsMentor 项目源码 文件源码 阅读 30 收藏 0 点赞 0 评论 0
def testEditWithAllParameters(self):
        gist = self.g.get_gist("2729810")
        gist.edit("Description edited by PyGithub", {"barbaz.txt": github.InputFileContent("File also created by PyGithub")})
        self.assertEqual(gist.description, "Description edited by PyGithub")
        self.assertEqual(gist.updated_at, datetime.datetime(2012, 5, 19, 7, 6, 10))
        self.assertEqual(set(gist.files.keys()), set(["foobar.txt", "barbaz.txt"]))
Gist.py 文件源码 项目:TutLab 作者: KingsMentor 项目源码 文件源码 阅读 28 收藏 0 点赞 0 评论 0
def testRenameFile(self):
        gist = self.g.get_gist("5339374")
        self.assertEqual(gist.files.keys(), ["bar.txt"])
        gist.edit(files={"bar.txt": github.InputFileContent(gist.files["bar.txt"].content, new_name="baz.txt")})
        self.assertEqual(gist.files.keys(), ["baz.txt"])
AuthenticatedUser.py 文件源码 项目:skill-for-github 作者: dkavanagh 项目源码 文件源码 阅读 18 收藏 0 点赞 0 评论 0
def testCreateGist(self):
        gist = self.user.create_gist(True, {"foobar.txt": github.InputFileContent("File created by PyGithub")}, "Gist created by PyGithub")
        self.assertEqual(gist.description, "Gist created by PyGithub")
        self.assertEqual(gist.files.keys(), ["foobar.txt"])
        self.assertEqual(gist.files["foobar.txt"].content, "File created by PyGithub")
AuthenticatedUser.py 文件源码 项目:skill-for-github 作者: dkavanagh 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def testCreateGistWithoutDescription(self):
        gist = self.user.create_gist(True, {"foobar.txt": github.InputFileContent("File created by PyGithub")})
        self.assertEqual(gist.description, None)
        self.assertEqual(gist.files.keys(), ["foobar.txt"])
        self.assertEqual(gist.files["foobar.txt"].content, "File created by PyGithub")
Gist.py 文件源码 项目:skill-for-github 作者: dkavanagh 项目源码 文件源码 阅读 28 收藏 0 点赞 0 评论 0
def testEditWithAllParameters(self):
        gist = self.g.get_gist("2729810")
        gist.edit("Description edited by PyGithub", {"barbaz.txt": github.InputFileContent("File also created by PyGithub")})
        self.assertEqual(gist.description, "Description edited by PyGithub")
        self.assertEqual(gist.updated_at, datetime.datetime(2012, 5, 19, 7, 6, 10))
        self.assertEqual(set(gist.files.keys()), set(["foobar.txt", "barbaz.txt"]))
Gist.py 文件源码 项目:skill-for-github 作者: dkavanagh 项目源码 文件源码 阅读 30 收藏 0 点赞 0 评论 0
def testRenameFile(self):
        gist = self.g.get_gist("5339374")
        self.assertEqual(gist.files.keys(), ["bar.txt"])
        gist.edit(files={"bar.txt": github.InputFileContent(gist.files["bar.txt"].content, new_name="baz.txt")})
        self.assertEqual(gist.files.keys(), ["baz.txt"])
AuthenticatedUser.py 文件源码 项目:hudl-bugbounty 作者: lewislabs 项目源码 文件源码 阅读 18 收藏 0 点赞 0 评论 0
def testCreateGist(self):
        gist = self.user.create_gist(True, {"foobar.txt": github.InputFileContent("File created by PyGithub")}, "Gist created by PyGithub")
        self.assertEqual(gist.description, "Gist created by PyGithub")
        self.assertEqual(gist.files.keys(), ["foobar.txt"])
        self.assertEqual(gist.files["foobar.txt"].content, "File created by PyGithub")
AuthenticatedUser.py 文件源码 项目:hudl-bugbounty 作者: lewislabs 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def testCreateGistWithoutDescription(self):
        gist = self.user.create_gist(True, {"foobar.txt": github.InputFileContent("File created by PyGithub")})
        self.assertEqual(gist.description, None)
        self.assertEqual(gist.files.keys(), ["foobar.txt"])
        self.assertEqual(gist.files["foobar.txt"].content, "File created by PyGithub")
Gist.py 文件源码 项目:hudl-bugbounty 作者: lewislabs 项目源码 文件源码 阅读 29 收藏 0 点赞 0 评论 0
def testEditWithAllParameters(self):
        gist = self.g.get_gist("2729810")
        gist.edit("Description edited by PyGithub", {"barbaz.txt": github.InputFileContent("File also created by PyGithub")})
        self.assertEqual(gist.description, "Description edited by PyGithub")
        self.assertEqual(gist.updated_at, datetime.datetime(2012, 5, 19, 7, 6, 10))
        self.assertEqual(set(gist.files.keys()), set(["foobar.txt", "barbaz.txt"]))
Gist.py 文件源码 项目:hudl-bugbounty 作者: lewislabs 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
def testRenameFile(self):
        gist = self.g.get_gist("5339374")
        self.assertEqual(gist.files.keys(), ["bar.txt"])
        gist.edit(files={"bar.txt": github.InputFileContent(gist.files["bar.txt"].content, new_name="baz.txt")})
        self.assertEqual(gist.files.keys(), ["baz.txt"])


问题


面经


文章

微信
公众号

扫码关注公众号