Python github 模块,InputFileContent() 实例源码

我们从Python开源项目中,提取了以下17个代码示例,用于说明如何使用github.InputFileContent()

项目:gitpwnd    作者:nccgroup    | 项目源码 | 文件源码
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
项目:Repobot    作者:Desgard    | 项目源码 | 文件源码
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")
项目:Repobot    作者:Desgard    | 项目源码 | 文件源码
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")
项目:Repobot    作者:Desgard    | 项目源码 | 文件源码
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"]))
项目:Repobot    作者:Desgard    | 项目源码 | 文件源码
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"])
项目:TutLab    作者:KingsMentor    | 项目源码 | 文件源码
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")
项目:TutLab    作者:KingsMentor    | 项目源码 | 文件源码
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")
项目:TutLab    作者:KingsMentor    | 项目源码 | 文件源码
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"]))
项目:TutLab    作者:KingsMentor    | 项目源码 | 文件源码
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"])
项目:skill-for-github    作者:dkavanagh    | 项目源码 | 文件源码
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")
项目:skill-for-github    作者:dkavanagh    | 项目源码 | 文件源码
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")
项目:skill-for-github    作者:dkavanagh    | 项目源码 | 文件源码
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"]))
项目:skill-for-github    作者:dkavanagh    | 项目源码 | 文件源码
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"])
项目:hudl-bugbounty    作者:lewislabs    | 项目源码 | 文件源码
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")
项目:hudl-bugbounty    作者:lewislabs    | 项目源码 | 文件源码
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")
项目:hudl-bugbounty    作者:lewislabs    | 项目源码 | 文件源码
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"]))
项目:hudl-bugbounty    作者:lewislabs    | 项目源码 | 文件源码
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"])