/ github / InputFileContent.py
InputFileContent.py
 1  ############################ Copyrights and license ############################
 2  #                                                                              #
 3  # Copyright 2012 Vincent Jacques <vincent@vincent-jacques.net>                 #
 4  # Copyright 2012 Zearin <zearin@gonk.net>                                      #
 5  # Copyright 2013 Vincent Jacques <vincent@vincent-jacques.net>                 #
 6  # Copyright 2014 Vincent Jacques <vincent@vincent-jacques.net>                 #
 7  # Copyright 2016 Peter Buckley <dx-pbuckley@users.noreply.github.com>          #
 8  # Copyright 2018 Wan Liuyang <tsfdye@gmail.com>                                #
 9  # Copyright 2018 sfdye <tsfdye@gmail.com>                                      #
10  #                                                                              #
11  # This file is part of PyGithub.                                               #
12  # http://pygithub.readthedocs.io/                                              #
13  #                                                                              #
14  # PyGithub is free software: you can redistribute it and/or modify it under    #
15  # the terms of the GNU Lesser General Public License as published by the Free  #
16  # Software Foundation, either version 3 of the License, or (at your option)    #
17  # any later version.                                                           #
18  #                                                                              #
19  # PyGithub is distributed in the hope that it will be useful, but WITHOUT ANY  #
20  # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS    #
21  # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more #
22  # details.                                                                     #
23  #                                                                              #
24  # You should have received a copy of the GNU Lesser General Public License     #
25  # along with PyGithub. If not, see <http://www.gnu.org/licenses/>.             #
26  #                                                                              #
27  ################################################################################
28  
29  
30  from __future__ import annotations
31  
32  from typing import Any
33  
34  from github.GithubObject import NotSet, Opt, is_defined, is_optional
35  
36  
37  class InputFileContent:
38      """
39      This class represents InputFileContents
40      """
41  
42      def __init__(self, content: str, new_name: Opt[str] = NotSet):
43          assert isinstance(content, str), content
44          assert is_optional(new_name, str), new_name
45          self.__newName: Opt[str] = new_name
46          self.__content: str = content
47  
48      @property
49      def _identity(self) -> dict[str, str]:
50          identity: dict[str, Any] = {
51              "content": self.__content,
52          }
53          if is_defined(self.__newName):
54              identity["filename"] = self.__newName
55          return identity