././@PaxHeader0000000000000000000000000000003400000000000010212 xustar0028 mtime=1619412318.9267669 PyGithub-1.55/0000755000175100001710000000000000000000000012537 5ustar00runnerdocker././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1619412308.0 PyGithub-1.55/COPYING0000644000175100001710000010451300000000000013576 0ustar00runnerdocker GNU GENERAL PUBLIC LICENSE Version 3, 29 June 2007 Copyright (C) 2007 Free Software Foundation, Inc. Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The GNU General Public License is a free, copyleft license for software and other kinds of works. The licenses for most software and other practical works are designed to take away your freedom to share and change the works. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change all versions of a program--to make sure it remains free software for all its users. We, the Free Software Foundation, use the GNU General Public License for most of our software; it applies also to any other work released this way by its authors. You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for them if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs, and that you know you can do these things. To protect your rights, we need to prevent others from denying you these rights or asking you to surrender the rights. Therefore, you have certain responsibilities if you distribute copies of the software, or if you modify it: responsibilities to respect the freedom of others. For example, if you distribute copies of such a program, whether gratis or for a fee, you must pass on to the recipients the same freedoms that you received. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. Developers that use the GNU GPL protect your rights with two steps: (1) assert copyright on the software, and (2) offer you this License giving you legal permission to copy, distribute and/or modify it. For the developers' and authors' protection, the GPL clearly explains that there is no warranty for this free software. For both users' and authors' sake, the GPL requires that modified versions be marked as changed, so that their problems will not be attributed erroneously to authors of previous versions. Some devices are designed to deny users access to install or run modified versions of the software inside them, although the manufacturer can do so. This is fundamentally incompatible with the aim of protecting users' freedom to change the software. The systematic pattern of such abuse occurs in the area of products for individuals to use, which is precisely where it is most unacceptable. Therefore, we have designed this version of the GPL to prohibit the practice for those products. If such problems arise substantially in other domains, we stand ready to extend this provision to those domains in future versions of the GPL, as needed to protect the freedom of users. Finally, every program is threatened constantly by software patents. States should not allow patents to restrict development and use of software on general-purpose computers, but in those that do, we wish to avoid the special danger that patents applied to a free program could make it effectively proprietary. To prevent this, the GPL assures that patents cannot be used to render the program non-free. The precise terms and conditions for copying, distribution and modification follow. TERMS AND CONDITIONS 0. Definitions. "This License" refers to version 3 of the GNU General Public License. "Copyright" also means copyright-like laws that apply to other kinds of works, such as semiconductor masks. "The Program" refers to any copyrightable work licensed under this License. Each licensee is addressed as "you". "Licensees" and "recipients" may be individuals or organizations. To "modify" a work means to copy from or adapt all or part of the work in a fashion requiring copyright permission, other than the making of an exact copy. The resulting work is called a "modified version" of the earlier work or a work "based on" the earlier work. A "covered work" means either the unmodified Program or a work based on the Program. To "propagate" a work means to do anything with it that, without permission, would make you directly or secondarily liable for infringement under applicable copyright law, except executing it on a computer or modifying a private copy. Propagation includes copying, distribution (with or without modification), making available to the public, and in some countries other activities as well. To "convey" a work means any kind of propagation that enables other parties to make or receive copies. Mere interaction with a user through a computer network, with no transfer of a copy, is not conveying. An interactive user interface displays "Appropriate Legal Notices" to the extent that it includes a convenient and prominently visible feature that (1) displays an appropriate copyright notice, and (2) tells the user that there is no warranty for the work (except to the extent that warranties are provided), that licensees may convey the work under this License, and how to view a copy of this License. If the interface presents a list of user commands or options, such as a menu, a prominent item in the list meets this criterion. 1. Source Code. The "source code" for a work means the preferred form of the work for making modifications to it. "Object code" means any non-source form of a work. A "Standard Interface" means an interface that either is an official standard defined by a recognized standards body, or, in the case of interfaces specified for a particular programming language, one that is widely used among developers working in that language. The "System Libraries" of an executable work include anything, other than the work as a whole, that (a) is included in the normal form of packaging a Major Component, but which is not part of that Major Component, and (b) serves only to enable use of the work with that Major Component, or to implement a Standard Interface for which an implementation is available to the public in source code form. A "Major Component", in this context, means a major essential component (kernel, window system, and so on) of the specific operating system (if any) on which the executable work runs, or a compiler used to produce the work, or an object code interpreter used to run it. The "Corresponding Source" for a work in object code form means all the source code needed to generate, install, and (for an executable work) run the object code and to modify the work, including scripts to control those activities. However, it does not include the work's System Libraries, or general-purpose tools or generally available free programs which are used unmodified in performing those activities but which are not part of the work. For example, Corresponding Source includes interface definition files associated with source files for the work, and the source code for shared libraries and dynamically linked subprograms that the work is specifically designed to require, such as by intimate data communication or control flow between those subprograms and other parts of the work. The Corresponding Source need not include anything that users can regenerate automatically from other parts of the Corresponding Source. The Corresponding Source for a work in source code form is that same work. 2. Basic Permissions. All rights granted under this License are granted for the term of copyright on the Program, and are irrevocable provided the stated conditions are met. This License explicitly affirms your unlimited permission to run the unmodified Program. The output from running a covered work is covered by this License only if the output, given its content, constitutes a covered work. This License acknowledges your rights of fair use or other equivalent, as provided by copyright law. You may make, run and propagate covered works that you do not convey, without conditions so long as your license otherwise remains in force. You may convey covered works to others for the sole purpose of having them make modifications exclusively for you, or provide you with facilities for running those works, provided that you comply with the terms of this License in conveying all material for which you do not control copyright. Those thus making or running the covered works for you must do so exclusively on your behalf, under your direction and control, on terms that prohibit them from making any copies of your copyrighted material outside their relationship with you. Conveying under any other circumstances is permitted solely under the conditions stated below. Sublicensing is not allowed; section 10 makes it unnecessary. 3. Protecting Users' Legal Rights From Anti-Circumvention Law. No covered work shall be deemed part of an effective technological measure under any applicable law fulfilling obligations under article 11 of the WIPO copyright treaty adopted on 20 December 1996, or similar laws prohibiting or restricting circumvention of such measures. When you convey a covered work, you waive any legal power to forbid circumvention of technological measures to the extent such circumvention is effected by exercising rights under this License with respect to the covered work, and you disclaim any intention to limit operation or modification of the work as a means of enforcing, against the work's users, your or third parties' legal rights to forbid circumvention of technological measures. 4. Conveying Verbatim Copies. You may convey verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice; keep intact all notices stating that this License and any non-permissive terms added in accord with section 7 apply to the code; keep intact all notices of the absence of any warranty; and give all recipients a copy of this License along with the Program. You may charge any price or no price for each copy that you convey, and you may offer support or warranty protection for a fee. 5. Conveying Modified Source Versions. You may convey a work based on the Program, or the modifications to produce it from the Program, in the form of source code under the terms of section 4, provided that you also meet all of these conditions: a) The work must carry prominent notices stating that you modified it, and giving a relevant date. b) The work must carry prominent notices stating that it is released under this License and any conditions added under section 7. This requirement modifies the requirement in section 4 to "keep intact all notices". c) You must license the entire work, as a whole, under this License to anyone who comes into possession of a copy. This License will therefore apply, along with any applicable section 7 additional terms, to the whole of the work, and all its parts, regardless of how they are packaged. This License gives no permission to license the work in any other way, but it does not invalidate such permission if you have separately received it. d) If the work has interactive user interfaces, each must display Appropriate Legal Notices; however, if the Program has interactive interfaces that do not display Appropriate Legal Notices, your work need not make them do so. A compilation of a covered work with other separate and independent works, which are not by their nature extensions of the covered work, and which are not combined with it such as to form a larger program, in or on a volume of a storage or distribution medium, is called an "aggregate" if the compilation and its resulting copyright are not used to limit the access or legal rights of the compilation's users beyond what the individual works permit. Inclusion of a covered work in an aggregate does not cause this License to apply to the other parts of the aggregate. 6. Conveying Non-Source Forms. You may convey a covered work in object code form under the terms of sections 4 and 5, provided that you also convey the machine-readable Corresponding Source under the terms of this License, in one of these ways: a) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by the Corresponding Source fixed on a durable physical medium customarily used for software interchange. b) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by a written offer, valid for at least three years and valid for as long as you offer spare parts or customer support for that product model, to give anyone who possesses the object code either (1) a copy of the Corresponding Source for all the software in the product that is covered by this License, on a durable physical medium customarily used for software interchange, for a price no more than your reasonable cost of physically performing this conveying of source, or (2) access to copy the Corresponding Source from a network server at no charge. c) Convey individual copies of the object code with a copy of the written offer to provide the Corresponding Source. This alternative is allowed only occasionally and noncommercially, and only if you received the object code with such an offer, in accord with subsection 6b. d) Convey the object code by offering access from a designated place (gratis or for a charge), and offer equivalent access to the Corresponding Source in the same way through the same place at no further charge. You need not require recipients to copy the Corresponding Source along with the object code. If the place to copy the object code is a network server, the Corresponding Source may be on a different server (operated by you or a third party) that supports equivalent copying facilities, provided you maintain clear directions next to the object code saying where to find the Corresponding Source. Regardless of what server hosts the Corresponding Source, you remain obligated to ensure that it is available for as long as needed to satisfy these requirements. e) Convey the object code using peer-to-peer transmission, provided you inform other peers where the object code and Corresponding Source of the work are being offered to the general public at no charge under subsection 6d. A separable portion of the object code, whose source code is excluded from the Corresponding Source as a System Library, need not be included in conveying the object code work. A "User Product" is either (1) a "consumer product", which means any tangible personal property which is normally used for personal, family, or household purposes, or (2) anything designed or sold for incorporation into a dwelling. In determining whether a product is a consumer product, doubtful cases shall be resolved in favor of coverage. For a particular product received by a particular user, "normally used" refers to a typical or common use of that class of product, regardless of the status of the particular user or of the way in which the particular user actually uses, or expects or is expected to use, the product. A product is a consumer product regardless of whether the product has substantial commercial, industrial or non-consumer uses, unless such uses represent the only significant mode of use of the product. "Installation Information" for a User Product means any methods, procedures, authorization keys, or other information required to install and execute modified versions of a covered work in that User Product from a modified version of its Corresponding Source. The information must suffice to ensure that the continued functioning of the modified object code is in no case prevented or interfered with solely because modification has been made. If you convey an object code work under this section in, or with, or specifically for use in, a User Product, and the conveying occurs as part of a transaction in which the right of possession and use of the User Product is transferred to the recipient in perpetuity or for a fixed term (regardless of how the transaction is characterized), the Corresponding Source conveyed under this section must be accompanied by the Installation Information. But this requirement does not apply if neither you nor any third party retains the ability to install modified object code on the User Product (for example, the work has been installed in ROM). The requirement to provide Installation Information does not include a requirement to continue to provide support service, warranty, or updates for a work that has been modified or installed by the recipient, or for the User Product in which it has been modified or installed. Access to a network may be denied when the modification itself materially and adversely affects the operation of the network or violates the rules and protocols for communication across the network. Corresponding Source conveyed, and Installation Information provided, in accord with this section must be in a format that is publicly documented (and with an implementation available to the public in source code form), and must require no special password or key for unpacking, reading or copying. 7. Additional Terms. "Additional permissions" are terms that supplement the terms of this License by making exceptions from one or more of its conditions. Additional permissions that are applicable to the entire Program shall be treated as though they were included in this License, to the extent that they are valid under applicable law. If additional permissions apply only to part of the Program, that part may be used separately under those permissions, but the entire Program remains governed by this License without regard to the additional permissions. When you convey a copy of a covered work, you may at your option remove any additional permissions from that copy, or from any part of it. (Additional permissions may be written to require their own removal in certain cases when you modify the work.) You may place additional permissions on material, added by you to a covered work, for which you have or can give appropriate copyright permission. Notwithstanding any other provision of this License, for material you add to a covered work, you may (if authorized by the copyright holders of that material) supplement the terms of this License with terms: a) Disclaiming warranty or limiting liability differently from the terms of sections 15 and 16 of this License; or b) Requiring preservation of specified reasonable legal notices or author attributions in that material or in the Appropriate Legal Notices displayed by works containing it; or c) Prohibiting misrepresentation of the origin of that material, or requiring that modified versions of such material be marked in reasonable ways as different from the original version; or d) Limiting the use for publicity purposes of names of licensors or authors of the material; or e) Declining to grant rights under trademark law for use of some trade names, trademarks, or service marks; or f) Requiring indemnification of licensors and authors of that material by anyone who conveys the material (or modified versions of it) with contractual assumptions of liability to the recipient, for any liability that these contractual assumptions directly impose on those licensors and authors. All other non-permissive additional terms are considered "further restrictions" within the meaning of section 10. If the Program as you received it, or any part of it, contains a notice stating that it is governed by this License along with a term that is a further restriction, you may remove that term. If a license document contains a further restriction but permits relicensing or conveying under this License, you may add to a covered work material governed by the terms of that license document, provided that the further restriction does not survive such relicensing or conveying. If you add terms to a covered work in accord with this section, you must place, in the relevant source files, a statement of the additional terms that apply to those files, or a notice indicating where to find the applicable terms. Additional terms, permissive or non-permissive, may be stated in the form of a separately written license, or stated as exceptions; the above requirements apply either way. 8. Termination. You may not propagate or modify a covered work except as expressly provided under this License. Any attempt otherwise to propagate or modify it is void, and will automatically terminate your rights under this License (including any patent licenses granted under the third paragraph of section 11). However, if you cease all violation of this License, then your license from a particular copyright holder is reinstated (a) provisionally, unless and until the copyright holder explicitly and finally terminates your license, and (b) permanently, if the copyright holder fails to notify you of the violation by some reasonable means prior to 60 days after the cessation. Moreover, your license from a particular copyright holder is reinstated permanently if the copyright holder notifies you of the violation by some reasonable means, this is the first time you have received notice of violation of this License (for any work) from that copyright holder, and you cure the violation prior to 30 days after your receipt of the notice. Termination of your rights under this section does not terminate the licenses of parties who have received copies or rights from you under this License. If your rights have been terminated and not permanently reinstated, you do not qualify to receive new licenses for the same material under section 10. 9. Acceptance Not Required for Having Copies. You are not required to accept this License in order to receive or run a copy of the Program. Ancillary propagation of a covered work occurring solely as a consequence of using peer-to-peer transmission to receive a copy likewise does not require acceptance. However, nothing other than this License grants you permission to propagate or modify any covered work. These actions infringe copyright if you do not accept this License. Therefore, by modifying or propagating a covered work, you indicate your acceptance of this License to do so. 10. Automatic Licensing of Downstream Recipients. Each time you convey a covered work, the recipient automatically receives a license from the original licensors, to run, modify and propagate that work, subject to this License. You are not responsible for enforcing compliance by third parties with this License. An "entity transaction" is a transaction transferring control of an organization, or substantially all assets of one, or subdividing an organization, or merging organizations. If propagation of a covered work results from an entity transaction, each party to that transaction who receives a copy of the work also receives whatever licenses to the work the party's predecessor in interest had or could give under the previous paragraph, plus a right to possession of the Corresponding Source of the work from the predecessor in interest, if the predecessor has it or can get it with reasonable efforts. You may not impose any further restrictions on the exercise of the rights granted or affirmed under this License. For example, you may not impose a license fee, royalty, or other charge for exercise of rights granted under this License, and you may not initiate litigation (including a cross-claim or counterclaim in a lawsuit) alleging that any patent claim is infringed by making, using, selling, offering for sale, or importing the Program or any portion of it. 11. Patents. A "contributor" is a copyright holder who authorizes use under this License of the Program or a work on which the Program is based. The work thus licensed is called the contributor's "contributor version". A contributor's "essential patent claims" are all patent claims owned or controlled by the contributor, whether already acquired or hereafter acquired, that would be infringed by some manner, permitted by this License, of making, using, or selling its contributor version, but do not include claims that would be infringed only as a consequence of further modification of the contributor version. For purposes of this definition, "control" includes the right to grant patent sublicenses in a manner consistent with the requirements of this License. Each contributor grants you a non-exclusive, worldwide, royalty-free patent license under the contributor's essential patent claims, to make, use, sell, offer for sale, import and otherwise run, modify and propagate the contents of its contributor version. In the following three paragraphs, a "patent license" is any express agreement or commitment, however denominated, not to enforce a patent (such as an express permission to practice a patent or covenant not to sue for patent infringement). To "grant" such a patent license to a party means to make such an agreement or commitment not to enforce a patent against the party. If you convey a covered work, knowingly relying on a patent license, and the Corresponding Source of the work is not available for anyone to copy, free of charge and under the terms of this License, through a publicly available network server or other readily accessible means, then you must either (1) cause the Corresponding Source to be so available, or (2) arrange to deprive yourself of the benefit of the patent license for this particular work, or (3) arrange, in a manner consistent with the requirements of this License, to extend the patent license to downstream recipients. "Knowingly relying" means you have actual knowledge that, but for the patent license, your conveying the covered work in a country, or your recipient's use of the covered work in a country, would infringe one or more identifiable patents in that country that you have reason to believe are valid. If, pursuant to or in connection with a single transaction or arrangement, you convey, or propagate by procuring conveyance of, a covered work, and grant a patent license to some of the parties receiving the covered work authorizing them to use, propagate, modify or convey a specific copy of the covered work, then the patent license you grant is automatically extended to all recipients of the covered work and works based on it. A patent license is "discriminatory" if it does not include within the scope of its coverage, prohibits the exercise of, or is conditioned on the non-exercise of one or more of the rights that are specifically granted under this License. You may not convey a covered work if you are a party to an arrangement with a third party that is in the business of distributing software, under which you make payment to the third party based on the extent of your activity of conveying the work, and under which the third party grants, to any of the parties who would receive the covered work from you, a discriminatory patent license (a) in connection with copies of the covered work conveyed by you (or copies made from those copies), or (b) primarily for and in connection with specific products or compilations that contain the covered work, unless you entered into that arrangement, or that patent license was granted, prior to 28 March 2007. Nothing in this License shall be construed as excluding or limiting any implied license or other defenses to infringement that may otherwise be available to you under applicable patent law. 12. No Surrender of Others' Freedom. If conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot convey a covered work so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not convey it at all. For example, if you agree to terms that obligate you to collect a royalty for further conveying from those to whom you convey the Program, the only way you could satisfy both those terms and this License would be to refrain entirely from conveying the Program. 13. Use with the GNU Affero General Public License. Notwithstanding any other provision of this License, you have permission to link or combine any covered work with a work licensed under version 3 of the GNU Affero General Public License into a single combined work, and to convey the resulting work. The terms of this License will continue to apply to the part which is the covered work, but the special requirements of the GNU Affero General Public License, section 13, concerning interaction through a network will apply to the combination as such. 14. Revised Versions of this License. The Free Software Foundation may publish revised and/or new versions of the GNU General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies that a certain numbered version of the GNU General Public License "or any later version" applies to it, you have the option of following the terms and conditions either of that numbered version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of the GNU General Public License, you may choose any version ever published by the Free Software Foundation. If the Program specifies that a proxy can decide which future versions of the GNU General Public License can be used, that proxy's public statement of acceptance of a version permanently authorizes you to choose that version for the Program. Later license versions may give you additional or different permissions. However, no additional obligations are imposed on any author or copyright holder as a result of your choosing to follow a later version. 15. Disclaimer of Warranty. THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 16. Limitation of Liability. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. 17. Interpretation of Sections 15 and 16. If the disclaimer of warranty and limitation of liability provided above cannot be given local legal effect according to their terms, reviewing courts shall apply local law that most closely approximates an absolute waiver of all civil liability in connection with the Program, unless a warranty or assumption of liability accompanies a copy of the Program in return for a fee. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively state the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . Also add information on how to contact you by electronic and paper mail. If the program does terminal interaction, make it output a short notice like this when it starts in an interactive mode: Copyright (C) This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, your program's commands might be different; for a GUI interface, you would use an "about box". You should also get your employer (if you work as a programmer) or school, if any, to sign a "copyright disclaimer" for the program, if necessary. For more information on this, and how to apply and follow the GNU GPL, see . The GNU General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Lesser General Public License instead of this License. But first, please read . ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1619412308.0 PyGithub-1.55/COPYING.LESSER0000644000175100001710000001674300000000000014601 0ustar00runnerdocker GNU LESSER GENERAL PUBLIC LICENSE Version 3, 29 June 2007 Copyright (C) 2007 Free Software Foundation, Inc. Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. This version of the GNU Lesser General Public License incorporates the terms and conditions of version 3 of the GNU General Public License, supplemented by the additional permissions listed below. 0. Additional Definitions. As used herein, "this License" refers to version 3 of the GNU Lesser General Public License, and the "GNU GPL" refers to version 3 of the GNU General Public License. "The Library" refers to a covered work governed by this License, other than an Application or a Combined Work as defined below. An "Application" is any work that makes use of an interface provided by the Library, but which is not otherwise based on the Library. Defining a subclass of a class defined by the Library is deemed a mode of using an interface provided by the Library. A "Combined Work" is a work produced by combining or linking an Application with the Library. The particular version of the Library with which the Combined Work was made is also called the "Linked Version". The "Minimal Corresponding Source" for a Combined Work means the Corresponding Source for the Combined Work, excluding any source code for portions of the Combined Work that, considered in isolation, are based on the Application, and not on the Linked Version. The "Corresponding Application Code" for a Combined Work means the object code and/or source code for the Application, including any data and utility programs needed for reproducing the Combined Work from the Application, but excluding the System Libraries of the Combined Work. 1. Exception to Section 3 of the GNU GPL. You may convey a covered work under sections 3 and 4 of this License without being bound by section 3 of the GNU GPL. 2. Conveying Modified Versions. If you modify a copy of the Library, and, in your modifications, a facility refers to a function or data to be supplied by an Application that uses the facility (other than as an argument passed when the facility is invoked), then you may convey a copy of the modified version: a) under this License, provided that you make a good faith effort to ensure that, in the event an Application does not supply the function or data, the facility still operates, and performs whatever part of its purpose remains meaningful, or b) under the GNU GPL, with none of the additional permissions of this License applicable to that copy. 3. Object Code Incorporating Material from Library Header Files. The object code form of an Application may incorporate material from a header file that is part of the Library. You may convey such object code under terms of your choice, provided that, if the incorporated material is not limited to numerical parameters, data structure layouts and accessors, or small macros, inline functions and templates (ten or fewer lines in length), you do both of the following: a) Give prominent notice with each copy of the object code that the Library is used in it and that the Library and its use are covered by this License. b) Accompany the object code with a copy of the GNU GPL and this license document. 4. Combined Works. You may convey a Combined Work under terms of your choice that, taken together, effectively do not restrict modification of the portions of the Library contained in the Combined Work and reverse engineering for debugging such modifications, if you also do each of the following: a) Give prominent notice with each copy of the Combined Work that the Library is used in it and that the Library and its use are covered by this License. b) Accompany the Combined Work with a copy of the GNU GPL and this license document. c) For a Combined Work that displays copyright notices during execution, include the copyright notice for the Library among these notices, as well as a reference directing the user to the copies of the GNU GPL and this license document. d) Do one of the following: 0) Convey the Minimal Corresponding Source under the terms of this License, and the Corresponding Application Code in a form suitable for, and under terms that permit, the user to recombine or relink the Application with a modified version of the Linked Version to produce a modified Combined Work, in the manner specified by section 6 of the GNU GPL for conveying Corresponding Source. 1) Use a suitable shared library mechanism for linking with the Library. A suitable mechanism is one that (a) uses at run time a copy of the Library already present on the user's computer system, and (b) will operate properly with a modified version of the Library that is interface-compatible with the Linked Version. e) Provide Installation Information, but only if you would otherwise be required to provide such information under section 6 of the GNU GPL, and only to the extent that such information is necessary to install and execute a modified version of the Combined Work produced by recombining or relinking the Application with a modified version of the Linked Version. (If you use option 4d0, the Installation Information must accompany the Minimal Corresponding Source and Corresponding Application Code. If you use option 4d1, you must provide the Installation Information in the manner specified by section 6 of the GNU GPL for conveying Corresponding Source.) 5. Combined Libraries. You may place library facilities that are a work based on the Library side by side in a single library together with other library facilities that are not Applications and are not covered by this License, and convey such a combined library under terms of your choice, if you do both of the following: a) Accompany the combined library with a copy of the same work based on the Library, uncombined with any other library facilities, conveyed under the terms of this License. b) Give prominent notice with the combined library that part of it is a work based on the Library, and explaining where to find the accompanying uncombined form of the same work. 6. Revised Versions of the GNU Lesser General Public License. The Free Software Foundation may publish revised and/or new versions of the GNU Lesser General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Library as you received it specifies that a certain numbered version of the GNU Lesser General Public License "or any later version" applies to it, you have the option of following the terms and conditions either of that published version or of any later version published by the Free Software Foundation. If the Library as you received it does not specify a version number of the GNU Lesser General Public License, you may choose any version of the GNU Lesser General Public License ever published by the Free Software Foundation. If the Library as you received it specifies that a proxy can decide whether future versions of the GNU Lesser General Public License shall apply, that proxy's public statement of acceptance of any version is permanent authorization for you to choose that version for the Library. ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1619412308.0 PyGithub-1.55/MANIFEST.in0000644000175100001710000000004300000000000014272 0ustar00runnerdockerinclude COPYING* include README.md ././@PaxHeader0000000000000000000000000000003400000000000010212 xustar0028 mtime=1619412318.9267669 PyGithub-1.55/PKG-INFO0000644000175100001710000000334300000000000013637 0ustar00runnerdockerMetadata-Version: 2.1 Name: PyGithub Version: 1.55 Summary: Use the full Github API v3 Home-page: https://github.com/pygithub/pygithub Author: Vincent Jacques Author-email: vincent@vincent-jacques.net License: UNKNOWN Project-URL: Documentation, http://pygithub.readthedocs.io/en/latest/ Project-URL: Source, https://github.com/pygithub/pygithub Project-URL: Tracker, https://github.com/pygithub/pygithub/issues Description: (Very short) Tutorial ===================== First create a Github instance:: from github import Github # using username and password g = Github("user", "password") # or using an access token g = Github("access_token") Then play with your Github objects:: for repo in g.get_user().get_repos(): print(repo.name) repo.edit(has_wiki=False) Reference documentation ======================= See http://pygithub.readthedocs.io/en/latest/ Platform: UNKNOWN Classifier: Development Status :: 5 - Production/Stable Classifier: Environment :: Web Environment Classifier: Intended Audience :: Developers Classifier: License :: OSI Approved :: GNU Library or Lesser General Public License (LGPL) Classifier: Operating System :: OS Independent Classifier: Programming Language :: Python Classifier: Programming Language :: Python :: 3 Classifier: Programming Language :: Python :: 3.6 Classifier: Programming Language :: Python :: 3.7 Classifier: Programming Language :: Python :: 3.8 Classifier: Programming Language :: Python :: 3.9 Classifier: Topic :: Software Development Requires-Python: >=3.6 Provides-Extra: integrations ././@PaxHeader0000000000000000000000000000003400000000000010212 xustar0028 mtime=1619412318.9027653 PyGithub-1.55/PyGithub.egg-info/0000755000175100001710000000000000000000000015764 5ustar00runnerdocker././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1619412318.0 PyGithub-1.55/PyGithub.egg-info/PKG-INFO0000644000175100001710000000334300000000000017064 0ustar00runnerdockerMetadata-Version: 2.1 Name: PyGithub Version: 1.55 Summary: Use the full Github API v3 Home-page: https://github.com/pygithub/pygithub Author: Vincent Jacques Author-email: vincent@vincent-jacques.net License: UNKNOWN Project-URL: Documentation, http://pygithub.readthedocs.io/en/latest/ Project-URL: Source, https://github.com/pygithub/pygithub Project-URL: Tracker, https://github.com/pygithub/pygithub/issues Description: (Very short) Tutorial ===================== First create a Github instance:: from github import Github # using username and password g = Github("user", "password") # or using an access token g = Github("access_token") Then play with your Github objects:: for repo in g.get_user().get_repos(): print(repo.name) repo.edit(has_wiki=False) Reference documentation ======================= See http://pygithub.readthedocs.io/en/latest/ Platform: UNKNOWN Classifier: Development Status :: 5 - Production/Stable Classifier: Environment :: Web Environment Classifier: Intended Audience :: Developers Classifier: License :: OSI Approved :: GNU Library or Lesser General Public License (LGPL) Classifier: Operating System :: OS Independent Classifier: Programming Language :: Python Classifier: Programming Language :: Python :: 3 Classifier: Programming Language :: Python :: 3.6 Classifier: Programming Language :: Python :: 3.7 Classifier: Programming Language :: Python :: 3.8 Classifier: Programming Language :: Python :: 3.9 Classifier: Topic :: Software Development Requires-Python: >=3.6 Provides-Extra: integrations ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1619412318.0 PyGithub-1.55/PyGithub.egg-info/SOURCES.txt0000644000175100001710000001212200000000000017646 0ustar00runnerdockerCOPYING COPYING.LESSER MANIFEST.in README.md setup.py PyGithub.egg-info/PKG-INFO PyGithub.egg-info/SOURCES.txt PyGithub.egg-info/dependency_links.txt PyGithub.egg-info/requires.txt PyGithub.egg-info/top_level.txt github/AccessToken.py github/AccessToken.pyi github/ApplicationOAuth.py github/ApplicationOAuth.pyi github/AuthenticatedUser.py github/AuthenticatedUser.pyi github/Authorization.py github/Authorization.pyi github/AuthorizationApplication.py github/AuthorizationApplication.pyi github/Branch.py github/Branch.pyi github/BranchProtection.py github/BranchProtection.pyi github/CheckRun.py github/CheckRun.pyi github/CheckRunAnnotation.py github/CheckRunAnnotation.pyi github/CheckRunOutput.py github/CheckRunOutput.pyi github/CheckSuite.py github/CheckSuite.pyi github/Clones.py github/Clones.pyi github/Commit.py github/Commit.pyi github/CommitCombinedStatus.py github/CommitCombinedStatus.pyi github/CommitComment.py github/CommitComment.pyi github/CommitStats.py github/CommitStats.pyi github/CommitStatus.py github/CommitStatus.pyi github/Comparison.py github/Comparison.pyi github/Consts.py github/ContentFile.py github/ContentFile.pyi github/Deployment.py github/Deployment.pyi github/DeploymentStatus.py github/DeploymentStatus.pyi github/Download.py github/Download.pyi github/Event.py github/Event.pyi github/File.py github/File.pyi github/Gist.py github/Gist.pyi github/GistComment.py github/GistComment.pyi github/GistFile.py github/GistFile.pyi github/GistHistoryState.py github/GistHistoryState.pyi github/GitAuthor.py github/GitAuthor.pyi github/GitBlob.py github/GitBlob.pyi github/GitCommit.py github/GitCommit.pyi github/GitObject.py github/GitObject.pyi github/GitRef.py github/GitRef.pyi github/GitRelease.py github/GitRelease.pyi github/GitReleaseAsset.py github/GitReleaseAsset.pyi github/GitTag.py github/GitTag.pyi github/GitTree.py github/GitTree.pyi github/GitTreeElement.py github/GitTreeElement.pyi github/GithubApp.py github/GithubApp.pyi github/GithubException.py github/GithubException.pyi github/GithubObject.py github/GithubObject.pyi github/GitignoreTemplate.py github/GitignoreTemplate.pyi github/Hook.py github/Hook.pyi github/HookDescription.py github/HookDescription.pyi github/HookResponse.py github/HookResponse.pyi github/InputFileContent.py github/InputFileContent.pyi github/InputGitAuthor.py github/InputGitAuthor.pyi github/InputGitTreeElement.py github/InputGitTreeElement.pyi github/Installation.py github/Installation.pyi github/InstallationAuthorization.py github/InstallationAuthorization.pyi github/Invitation.py github/Invitation.pyi github/Issue.py github/Issue.pyi github/IssueComment.py github/IssueComment.pyi github/IssueEvent.py github/IssueEvent.pyi github/IssuePullRequest.py github/IssuePullRequest.pyi github/Label.py github/Label.pyi github/License.py github/License.pyi github/MainClass.py github/MainClass.pyi github/Membership.py github/Membership.pyi github/Migration.py github/Migration.pyi github/Milestone.py github/Milestone.pyi github/NamedUser.py github/NamedUser.pyi github/Notification.py github/Notification.pyi github/NotificationSubject.py github/NotificationSubject.pyi github/Organization.py github/Organization.pyi github/PaginatedList.py github/PaginatedList.pyi github/Path.py github/Path.pyi github/Permissions.py github/Permissions.pyi github/Plan.py github/Plan.pyi github/Project.py github/Project.pyi github/ProjectCard.py github/ProjectCard.pyi github/ProjectColumn.py github/ProjectColumn.pyi github/PublicKey.py github/PublicKey.pyi github/PullRequest.py github/PullRequest.pyi github/PullRequestComment.py github/PullRequestComment.pyi github/PullRequestMergeStatus.py github/PullRequestMergeStatus.pyi github/PullRequestPart.py github/PullRequestPart.pyi github/PullRequestReview.py github/PullRequestReview.pyi github/Rate.py github/Rate.pyi github/RateLimit.py github/RateLimit.pyi github/Reaction.py github/Reaction.pyi github/Referrer.py github/Referrer.pyi github/Repository.py github/Repository.pyi github/RepositoryKey.py github/RepositoryKey.pyi github/RepositoryPreferences.py github/RepositoryPreferences.pyi github/Requester.py github/Requester.pyi github/RequiredPullRequestReviews.py github/RequiredPullRequestReviews.pyi github/RequiredStatusChecks.py github/RequiredStatusChecks.pyi github/SelfHostedActionsRunner.py github/SelfHostedActionsRunner.pyi github/SourceImport.py github/SourceImport.pyi github/Stargazer.py github/Stargazer.pyi github/StatsCodeFrequency.py github/StatsCodeFrequency.pyi github/StatsCommitActivity.py github/StatsCommitActivity.pyi github/StatsContributor.py github/StatsContributor.pyi github/StatsParticipation.py github/StatsParticipation.pyi github/StatsPunchCard.py github/StatsPunchCard.pyi github/Tag.py github/Tag.pyi github/Team.py github/Team.pyi github/TeamDiscussion.py github/TeamDiscussion.pyi github/TimelineEvent.py github/TimelineEvent.pyi github/TimelineEventSource.py github/TimelineEventSource.pyi github/Topic.py github/Topic.pyi github/UserKey.py github/UserKey.pyi github/View.py github/View.pyi github/Workflow.py github/Workflow.pyi github/WorkflowRun.py github/WorkflowRun.pyi github/__init__.py github/__init__.pyi github/py.typed././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1619412318.0 PyGithub-1.55/PyGithub.egg-info/dependency_links.txt0000644000175100001710000000000100000000000022032 0ustar00runnerdocker ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1619412318.0 PyGithub-1.55/PyGithub.egg-info/requires.txt0000644000175100001710000000012200000000000020357 0ustar00runnerdockerdeprecated pyjwt>=2.0 pynacl>=1.4.0 requests>=2.14.0 [integrations] cryptography ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1619412318.0 PyGithub-1.55/PyGithub.egg-info/top_level.txt0000644000175100001710000000000700000000000020513 0ustar00runnerdockergithub ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1619412308.0 PyGithub-1.55/README.md0000644000175100001710000000444100000000000014021 0ustar00runnerdocker# PyGitHub [![PyPI](https://img.shields.io/pypi/v/PyGithub.svg)](https://pypi.python.org/pypi/PyGithub) ![CI](https://github.com/PyGithub/PyGithub/workflows/CI/badge.svg) [![readthedocs](https://img.shields.io/badge/docs-latest-brightgreen.svg?style=flat)](https://pygithub.readthedocs.io/en/latest/?badge=latest) [![License](https://img.shields.io/badge/license-LGPL-blue.svg)](https://en.wikipedia.org/wiki/GNU_Lesser_General_Public_License) [![Slack](https://img.shields.io/badge/Slack%20channel-%20%20-blue.svg)](https://join.slack.com/t/pygithub-project/shared_invite/zt-duj89xtx-uKFZtgAg209o6Vweqm8xeQ) [![Open Source Helpers](https://www.codetriage.com/pygithub/pygithub/badges/users.svg)](https://www.codetriage.com/pygithub/pygithub) [![codecov](https://codecov.io/gh/PyGithub/PyGithub/branch/master/graph/badge.svg)](https://codecov.io/gh/PyGithub/PyGithub) [![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black) PyGitHub is a Python library to access the [GitHub REST API]. This library enables you to manage [GitHub] resources such as repositories, user profiles, and organizations in your Python applications. [GitHub REST API]: https://docs.github.com/en/rest [GitHub]: https://github.com ## Install ```bash $ pip install PyGithub ``` ## Simple Demo ```python from github import Github # First create a Github instance: # using an access token g = Github("access_token") # Github Enterprise with custom hostname g = Github(base_url="https://{hostname}/api/v3", login_or_token="access_token") # Then play with your Github objects: for repo in g.get_user().get_repos(): print(repo.name) ``` ## Documentation More information can be found on the [PyGitHub documentation site.](https://pygithub.readthedocs.io/en/latest/introduction.html) ## Development ### Contributing Long-term discussion and bug reports are maintained via GitHub Issues. Code review is done via GitHub Pull Requests. For more information read [CONTRIBUTING.md]. [CONTRIBUTING.md]: /CONTRIBUTING.md ### Maintainership We're actively seeking maintainers that will triage issues and pull requests and cut releases. If you work on a project that leverages PyGitHub and have a vested interest in keeping the code alive and well, send an email to someone in the MAINTAINERS file. ././@PaxHeader0000000000000000000000000000003400000000000010212 xustar0028 mtime=1619412318.9267669 PyGithub-1.55/github/0000755000175100001710000000000000000000000014021 5ustar00runnerdocker././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1619412308.0 PyGithub-1.55/github/AccessToken.py0000644000175100001710000000575000000000000016604 0ustar00runnerdocker############################ Copyrights and license ############################ # # # Copyright 2019 Rigas Papathanasopoulos # # # # This file is part of PyGithub. # # http://pygithub.readthedocs.io/ # # # # PyGithub is free software: you can redistribute it and/or modify it under # # the terms of the GNU Lesser General Public License as published by the Free # # Software Foundation, either version 3 of the License, or (at your option) # # any later version. # # # # PyGithub is distributed in the hope that it will be useful, but WITHOUT ANY # # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more # # details. # # # # You should have received a copy of the GNU Lesser General Public License # # along with PyGithub. If not, see . # # # ################################################################################ import github.GithubObject class AccessToken(github.GithubObject.NonCompletableGithubObject): """ This class represents access tokens. """ def __repr__(self): return self.get__repr__( { "token": "{}...".format(self.token[:5]), "scope": self.scope, "type": self.type, } ) @property def token(self): """ :type: string """ return self._token.value @property def type(self): """ :type: string """ return self._type.value @property def scope(self): """ :type: string """ return self._scope.value def _initAttributes(self): self._token = github.GithubObject.NotSet self._type = github.GithubObject.NotSet self._scope = github.GithubObject.NotSet def _useAttributes(self, attributes): if "access_token" in attributes: # pragma no branch self._token = self._makeStringAttribute(attributes["access_token"]) if "token_type" in attributes: # pragma no branch self._type = self._makeStringAttribute(attributes["token_type"]) if "scope" in attributes: # pragma no branch self._scope = self._makeStringAttribute(attributes["scope"]) ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1619412308.0 PyGithub-1.55/github/AccessToken.pyi0000644000175100001710000000064600000000000016754 0ustar00runnerdockerfrom typing import Any, Dict from github.GithubObject import NonCompletableGithubObject class AccessToken(NonCompletableGithubObject): def __repr__(self) -> str: ... def _initAttributes(self) -> None: ... def _useAttributes(self, attributes: Dict[str, Any]) -> None: ... @property def token(self) -> str: ... @property def type(self) -> str: ... @property def scope(self) -> str: ... ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1619412308.0 PyGithub-1.55/github/ApplicationOAuth.py0000644000175100001710000001132300000000000017577 0ustar00runnerdocker############################ Copyrights and license ########################### # # # Copyright 2019 Rigas Papathanasopoulos # # # # This file is part of PyGithub. # # http://pygithub.readthedocs.io/ # # # # PyGithub is free software: you can redistribute it and/or modify it under # # the terms of the GNU Lesser General Public License as published by the Free # # Software Foundation, either version 3 of the License, or (at your option) # # any later version. # # # # PyGithub is distributed in the hope that it will be useful, but WITHOUT ANY # # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more# # details. # # # # You should have received a copy of the GNU Lesser General Public License # # along with PyGithub. If not, see . # # # ############################################################################### import urllib import github.GithubObject from github.AccessToken import AccessToken class ApplicationOAuth(github.GithubObject.NonCompletableGithubObject): """ This class is used for identifying and authorizing users for Github Apps. The reference can be found at https://docs.github.com/en/developers/apps/identifying-and-authorizing-users-for-github-apps """ def __repr__(self): return self.get__repr__({"client_id": self._client_id.value}) @property def client_id(self): return self._client_id.value @property def client_secret(self): return self._client_secret.value def _initAttributes(self): self._client_id = github.GithubObject.NotSet self._client_secret = github.GithubObject.NotSet def _useAttributes(self, attributes): if "client_id" in attributes: # pragma no branch self._client_id = self._makeStringAttribute(attributes["client_id"]) if "client_secret" in attributes: # pragma no branch self._client_secret = self._makeStringAttribute(attributes["client_secret"]) def get_login_url(self, redirect_uri=None, state=None, login=None): """ Return the URL you need to redirect a user to in order to authorize your App. :type: string """ parameters = {"client_id": self.client_id} if redirect_uri is not None: assert isinstance(redirect_uri, str), redirect_uri parameters["redirect_uri"] = redirect_uri if state is not None: assert isinstance(state, str), state parameters["state"] = state if login is not None: assert isinstance(login, str), login parameters["login"] = login parameters = urllib.parse.urlencode(parameters) base_url = "https://github.com/login/oauth/authorize" return f"{base_url}?{parameters}" def get_access_token(self, code, state=None): """ :calls: `POST /login/oauth/access_token `_ :param code: string :param state: string """ assert isinstance(code, str), code post_parameters = { "code": code, "client_id": self.client_id, "client_secret": self.client_secret, } if state is not None: post_parameters["state"] = state self._requester._Requester__authorizationHeader = None headers, data = self._requester.requestJsonAndCheck( "POST", "https://github.com/login/oauth/access_token", headers={ "Accept": "application/json", "Content-Type": "application/json", "User-Agent": "PyGithub/Python", }, input=post_parameters, ) return AccessToken( requester=self._requester, # not required, this is a NonCompletableGithubObject headers={}, attributes=data, completed=False, ) ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1619412308.0 PyGithub-1.55/github/ApplicationOAuth.pyi0000644000175100001710000000131000000000000017743 0ustar00runnerdockerfrom typing import Any, Dict, Optional from github.AccessToken import AccessToken from github.GithubObject import NonCompletableGithubObject class ApplicationOAuth(NonCompletableGithubObject): def __repr__(self) -> str: ... def _initAttributes(self) -> None: ... def _useAttributes(self, attributes: Dict[str, Any]) -> None: ... @property def client_id(self) -> str: ... @property def client_secret(self) -> str: ... def get_login_url( self, redirect_uri: Optional[str], state: Optional[str], login: Optional[str] ) -> str: ... def get_access_token( self, code: str, state: Optional[str] ) -> AccessToken: ... ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1619412308.0 PyGithub-1.55/github/AuthenticatedUser.py0000644000175100001710000016314400000000000020025 0ustar00runnerdocker############################ Copyrights and license ############################ # # # Copyright 2012 Steve English # # Copyright 2012 Vincent Jacques # # Copyright 2012 Zearin # # Copyright 2013 AKFish # # Copyright 2013 Cameron White # # Copyright 2013 Vincent Jacques # # Copyright 2013 poulp # # Copyright 2014 Tomas Radej # # Copyright 2014 Vincent Jacques # # Copyright 2016 E. Dunham # # Copyright 2016 Jannis Gebauer # # Copyright 2016 Peter Buckley # # Copyright 2017 Balázs Rostás # # Copyright 2017 Jannis Gebauer # # Copyright 2017 Simon # # Copyright 2018 Wan Liuyang # # Copyright 2018 bryanhuntesl <31992054+bryanhuntesl@users.noreply.github.com> # # Copyright 2018 sfdye # # Copyright 2018 itsbruce # # Copyright 2019 Rigas Papathanasopoulos # # # # This file is part of PyGithub. # # http://pygithub.readthedocs.io/ # # # # PyGithub is free software: you can redistribute it and/or modify it under # # the terms of the GNU Lesser General Public License as published by the Free # # Software Foundation, either version 3 of the License, or (at your option) # # any later version. # # # # PyGithub is distributed in the hope that it will be useful, but WITHOUT ANY # # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more # # details. # # # # You should have received a copy of the GNU Lesser General Public License # # along with PyGithub. If not, see . # # # ################################################################################ import datetime from collections import namedtuple import github.Authorization import github.Event import github.Gist import github.GithubObject import github.Invitation import github.Issue import github.Membership import github.Migration import github.NamedUser import github.Notification import github.Organization import github.PaginatedList import github.Plan import github.Repository import github.UserKey from . import Consts class AuthenticatedUser(github.GithubObject.CompletableGithubObject): """ This class represents AuthenticatedUsers as returned by https://docs.github.com/en/rest/reference/users#get-the-authenticated-user An AuthenticatedUser object can be created by calling ``get_user()`` on a Github object. """ def __repr__(self): return self.get__repr__({"login": self._login.value}) @property def avatar_url(self): """ :type: string """ self._completeIfNotSet(self._avatar_url) return self._avatar_url.value @property def bio(self): """ :type: string """ self._completeIfNotSet(self._bio) return self._bio.value @property def blog(self): """ :type: string """ self._completeIfNotSet(self._blog) return self._blog.value @property def collaborators(self): """ :type: integer """ self._completeIfNotSet(self._collaborators) return self._collaborators.value @property def company(self): """ :type: string """ self._completeIfNotSet(self._company) return self._company.value @property def created_at(self): """ :type: datetime.datetime """ self._completeIfNotSet(self._created_at) return self._created_at.value @property def disk_usage(self): """ :type: integer """ self._completeIfNotSet(self._disk_usage) return self._disk_usage.value @property def email(self): """ :type: string """ self._completeIfNotSet(self._email) return self._email.value @property def events_url(self): """ :type: string """ self._completeIfNotSet(self._events_url) return self._events_url.value @property def followers(self): """ :type: integer """ self._completeIfNotSet(self._followers) return self._followers.value @property def followers_url(self): """ :type: string """ self._completeIfNotSet(self._followers_url) return self._followers_url.value @property def following(self): """ :type: integer """ self._completeIfNotSet(self._following) return self._following.value @property def following_url(self): """ :type: string """ self._completeIfNotSet(self._following_url) return self._following_url.value @property def gists_url(self): """ :type: string """ self._completeIfNotSet(self._gists_url) return self._gists_url.value @property def gravatar_id(self): """ :type: string """ self._completeIfNotSet(self._gravatar_id) return self._gravatar_id.value @property def hireable(self): """ :type: bool """ self._completeIfNotSet(self._hireable) return self._hireable.value @property def html_url(self): """ :type: string """ self._completeIfNotSet(self._html_url) return self._html_url.value @property def id(self): """ :type: integer """ self._completeIfNotSet(self._id) return self._id.value @property def location(self): """ :type: string """ self._completeIfNotSet(self._location) return self._location.value @property def login(self): """ :type: string """ self._completeIfNotSet(self._login) return self._login.value @property def name(self): """ :type: string """ self._completeIfNotSet(self._name) return self._name.value @property def node_id(self): """ :type: string """ self._completeIfNotSet(self._node_id) return self._node_id.value @property def organizations_url(self): """ :type: string """ self._completeIfNotSet(self._organizations_url) return self._organizations_url.value @property def owned_private_repos(self): """ :type: integer """ self._completeIfNotSet(self._owned_private_repos) return self._owned_private_repos.value @property def plan(self): """ :type: :class:`github.Plan.Plan` """ self._completeIfNotSet(self._plan) return self._plan.value @property def private_gists(self): """ :type: integer """ self._completeIfNotSet(self._private_gists) return self._private_gists.value @property def public_gists(self): """ :type: integer """ self._completeIfNotSet(self._public_gists) return self._public_gists.value @property def public_repos(self): """ :type: integer """ self._completeIfNotSet(self._public_repos) return self._public_repos.value @property def received_events_url(self): """ :type: string """ self._completeIfNotSet(self._received_events_url) return self._received_events_url.value @property def repos_url(self): """ :type: string """ self._completeIfNotSet(self._repos_url) return self._repos_url.value @property def site_admin(self): """ :type: bool """ self._completeIfNotSet(self._site_admin) return self._site_admin.value @property def starred_url(self): """ :type: string """ self._completeIfNotSet(self._starred_url) return self._starred_url.value @property def subscriptions_url(self): """ :type: string """ self._completeIfNotSet(self._subscriptions_url) return self._subscriptions_url.value @property def total_private_repos(self): """ :type: integer """ self._completeIfNotSet(self._total_private_repos) return self._total_private_repos.value @property def type(self): """ :type: string """ self._completeIfNotSet(self._type) return self._type.value @property def updated_at(self): """ :type: datetime.datetime """ self._completeIfNotSet(self._updated_at) return self._updated_at.value @property def url(self): """ :type: string """ self._completeIfNotSet(self._url) return self._url.value def add_to_emails(self, *emails): """ :calls: `POST /user/emails `_ :param email: string :rtype: None """ assert all(isinstance(element, str) for element in emails), emails post_parameters = {"emails": emails} headers, data = self._requester.requestJsonAndCheck( "POST", "/user/emails", input=post_parameters ) def add_to_following(self, following): """ :calls: `PUT /user/following/{user} `_ :param following: :class:`github.NamedUser.NamedUser` :rtype: None """ assert isinstance(following, github.NamedUser.NamedUser), following headers, data = self._requester.requestJsonAndCheck( "PUT", f"/user/following/{following._identity}" ) def add_to_starred(self, starred): """ :calls: `PUT /user/starred/{owner}/{repo} `_ :param starred: :class:`github.Repository.Repository` :rtype: None """ assert isinstance(starred, github.Repository.Repository), starred headers, data = self._requester.requestJsonAndCheck( "PUT", f"/user/starred/{starred._identity}" ) def add_to_subscriptions(self, subscription): """ :calls: `PUT /user/subscriptions/{owner}/{repo} `_ :param subscription: :class:`github.Repository.Repository` :rtype: None """ assert isinstance(subscription, github.Repository.Repository), subscription headers, data = self._requester.requestJsonAndCheck( "PUT", f"/user/subscriptions/{subscription._identity}" ) def add_to_watched(self, watched): """ :calls: `PUT /repos/{owner}/{repo}/subscription `_ :param watched: :class:`github.Repository.Repository` :rtype: None """ assert isinstance(watched, github.Repository.Repository), watched headers, data = self._requester.requestJsonAndCheck( "PUT", f"/repos/{watched._identity}/subscription", input={"subscribed": True}, ) def create_authorization( self, scopes=github.GithubObject.NotSet, note=github.GithubObject.NotSet, note_url=github.GithubObject.NotSet, client_id=github.GithubObject.NotSet, client_secret=github.GithubObject.NotSet, onetime_password=None, ): """ :calls: `POST /authorizations `_ :param scopes: list of string :param note: string :param note_url: string :param client_id: string :param client_secret: string :param onetime_password: string :rtype: :class:`github.Authorization.Authorization` """ assert scopes is github.GithubObject.NotSet or all( isinstance(element, str) for element in scopes ), scopes assert note is github.GithubObject.NotSet or isinstance(note, str), note assert note_url is github.GithubObject.NotSet or isinstance( note_url, str ), note_url assert client_id is github.GithubObject.NotSet or isinstance( client_id, str ), client_id assert client_secret is github.GithubObject.NotSet or isinstance( client_secret, str ), client_secret assert onetime_password is None or isinstance( onetime_password, str ), onetime_password post_parameters = dict() if scopes is not github.GithubObject.NotSet: post_parameters["scopes"] = scopes if note is not github.GithubObject.NotSet: post_parameters["note"] = note if note_url is not github.GithubObject.NotSet: post_parameters["note_url"] = note_url if client_id is not github.GithubObject.NotSet: post_parameters["client_id"] = client_id if client_secret is not github.GithubObject.NotSet: post_parameters["client_secret"] = client_secret if onetime_password is not None: request_header = { Consts.headerOTP: onetime_password } # pragma no cover (Should be covered) else: request_header = None headers, data = self._requester.requestJsonAndCheck( "POST", "/authorizations", input=post_parameters, headers=request_header, ) return github.Authorization.Authorization( self._requester, headers, data, completed=True ) def create_fork(self, repo): """ :calls: `POST /repos/{owner}/{repo}/forks `_ :param repo: :class:`github.Repository.Repository` :rtype: :class:`github.Repository.Repository` """ assert isinstance(repo, github.Repository.Repository), repo headers, data = self._requester.requestJsonAndCheck( "POST", f"/repos/{repo.owner.login}/{repo.name}/forks" ) return github.Repository.Repository( self._requester, headers, data, completed=True ) def create_gist(self, public, files, description=github.GithubObject.NotSet): """ :calls: `POST /gists `_ :param public: bool :param files: dict of string to :class:`github.InputFileContent.InputFileContent` :param description: string :rtype: :class:`github.Gist.Gist` """ assert isinstance(public, bool), public assert all( isinstance(element, github.InputFileContent) for element in files.values() ), files assert description is github.GithubObject.NotSet or isinstance( description, str ), description post_parameters = { "public": public, "files": {key: value._identity for key, value in files.items()}, } if description is not github.GithubObject.NotSet: post_parameters["description"] = description headers, data = self._requester.requestJsonAndCheck( "POST", "/gists", input=post_parameters ) return github.Gist.Gist(self._requester, headers, data, completed=True) def create_key(self, title, key): """ :calls: `POST /user/keys `_ :param title: string :param key: string :rtype: :class:`github.UserKey.UserKey` """ assert isinstance(title, str), title assert isinstance(key, str), key post_parameters = { "title": title, "key": key, } headers, data = self._requester.requestJsonAndCheck( "POST", "/user/keys", input=post_parameters ) return github.UserKey.UserKey(self._requester, headers, data, completed=True) def create_project(self, name, body=github.GithubObject.NotSet): """ :calls: `POST /user/projects `_ :param name: string :param body: string :rtype: :class:`github.Project.Project` """ assert isinstance(name, str), name assert body is github.GithubObject.NotSet or isinstance(body, str), body post_parameters = { "name": name, "body": body, } headers, data = self._requester.requestJsonAndCheck( "POST", "/user/projects", input=post_parameters, headers={"Accept": Consts.mediaTypeProjectsPreview}, ) return github.Project.Project(self._requester, headers, data, completed=True) def create_repo( self, name, description=github.GithubObject.NotSet, homepage=github.GithubObject.NotSet, private=github.GithubObject.NotSet, has_issues=github.GithubObject.NotSet, has_wiki=github.GithubObject.NotSet, has_downloads=github.GithubObject.NotSet, has_projects=github.GithubObject.NotSet, auto_init=github.GithubObject.NotSet, license_template=github.GithubObject.NotSet, gitignore_template=github.GithubObject.NotSet, allow_squash_merge=github.GithubObject.NotSet, allow_merge_commit=github.GithubObject.NotSet, allow_rebase_merge=github.GithubObject.NotSet, delete_branch_on_merge=github.GithubObject.NotSet, ): """ :calls: `POST /user/repos `_ :param name: string :param description: string :param homepage: string :param private: bool :param has_issues: bool :param has_wiki: bool :param has_downloads: bool :param has_projects: bool :param auto_init: bool :param license_template: string :param gitignore_template: string :param allow_squash_merge: bool :param allow_merge_commit: bool :param allow_rebase_merge: bool :param delete_branch_on_merge: bool :rtype: :class:`github.Repository.Repository` """ assert isinstance(name, str), name assert description is github.GithubObject.NotSet or isinstance( description, str ), description assert homepage is github.GithubObject.NotSet or isinstance( homepage, str ), homepage assert private is github.GithubObject.NotSet or isinstance( private, bool ), private assert has_issues is github.GithubObject.NotSet or isinstance( has_issues, bool ), has_issues assert has_wiki is github.GithubObject.NotSet or isinstance( has_wiki, bool ), has_wiki assert has_downloads is github.GithubObject.NotSet or isinstance( has_downloads, bool ), has_downloads assert has_projects is github.GithubObject.NotSet or isinstance( has_projects, bool ), has_projects assert auto_init is github.GithubObject.NotSet or isinstance( auto_init, bool ), auto_init assert license_template is github.GithubObject.NotSet or isinstance( license_template, str ), license_template assert gitignore_template is github.GithubObject.NotSet or isinstance( gitignore_template, str ), gitignore_template assert allow_squash_merge is github.GithubObject.NotSet or isinstance( allow_squash_merge, bool ), allow_squash_merge assert allow_merge_commit is github.GithubObject.NotSet or isinstance( allow_merge_commit, bool ), allow_merge_commit assert allow_rebase_merge is github.GithubObject.NotSet or isinstance( allow_rebase_merge, bool ), allow_rebase_merge assert delete_branch_on_merge is github.GithubObject.NotSet or isinstance( delete_branch_on_merge, bool ), delete_branch_on_merge post_parameters = { "name": name, } if description is not github.GithubObject.NotSet: post_parameters["description"] = description if homepage is not github.GithubObject.NotSet: post_parameters["homepage"] = homepage if private is not github.GithubObject.NotSet: post_parameters["private"] = private if has_issues is not github.GithubObject.NotSet: post_parameters["has_issues"] = has_issues if has_wiki is not github.GithubObject.NotSet: post_parameters["has_wiki"] = has_wiki if has_downloads is not github.GithubObject.NotSet: post_parameters["has_downloads"] = has_downloads if has_projects is not github.GithubObject.NotSet: post_parameters["has_projects"] = has_projects if auto_init is not github.GithubObject.NotSet: post_parameters["auto_init"] = auto_init if license_template is not github.GithubObject.NotSet: post_parameters["license_template"] = license_template if gitignore_template is not github.GithubObject.NotSet: post_parameters["gitignore_template"] = gitignore_template if allow_squash_merge is not github.GithubObject.NotSet: post_parameters["allow_squash_merge"] = allow_squash_merge if allow_merge_commit is not github.GithubObject.NotSet: post_parameters["allow_merge_commit"] = allow_merge_commit if allow_rebase_merge is not github.GithubObject.NotSet: post_parameters["allow_rebase_merge"] = allow_rebase_merge if delete_branch_on_merge is not github.GithubObject.NotSet: post_parameters["delete_branch_on_merge"] = delete_branch_on_merge headers, data = self._requester.requestJsonAndCheck( "POST", "/user/repos", input=post_parameters ) return github.Repository.Repository( self._requester, headers, data, completed=True ) def edit( self, name=github.GithubObject.NotSet, email=github.GithubObject.NotSet, blog=github.GithubObject.NotSet, company=github.GithubObject.NotSet, location=github.GithubObject.NotSet, hireable=github.GithubObject.NotSet, bio=github.GithubObject.NotSet, ): """ :calls: `PATCH /user `_ :param name: string :param email: string :param blog: string :param company: string :param location: string :param hireable: bool :param bio: string :rtype: None """ assert name is github.GithubObject.NotSet or isinstance(name, str), name assert email is github.GithubObject.NotSet or isinstance(email, str), email assert blog is github.GithubObject.NotSet or isinstance(blog, str), blog assert company is github.GithubObject.NotSet or isinstance( company, str ), company assert location is github.GithubObject.NotSet or isinstance( location, str ), location assert hireable is github.GithubObject.NotSet or isinstance( hireable, bool ), hireable assert bio is github.GithubObject.NotSet or isinstance(bio, str), bio post_parameters = dict() if name is not github.GithubObject.NotSet: post_parameters["name"] = name if email is not github.GithubObject.NotSet: post_parameters["email"] = email if blog is not github.GithubObject.NotSet: post_parameters["blog"] = blog if company is not github.GithubObject.NotSet: post_parameters["company"] = company if location is not github.GithubObject.NotSet: post_parameters["location"] = location if hireable is not github.GithubObject.NotSet: post_parameters["hireable"] = hireable if bio is not github.GithubObject.NotSet: post_parameters["bio"] = bio headers, data = self._requester.requestJsonAndCheck( "PATCH", "/user", input=post_parameters ) self._useAttributes(data) def get_authorization(self, id): """ :calls: `GET /authorizations/{id} `_ :param id: integer :rtype: :class:`github.Authorization.Authorization` """ assert isinstance(id, int), id headers, data = self._requester.requestJsonAndCheck( "GET", f"/authorizations/{id}" ) return github.Authorization.Authorization( self._requester, headers, data, completed=True ) def get_authorizations(self): """ :calls: `GET /authorizations `_ :rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.Authorization.Authorization` """ return github.PaginatedList.PaginatedList( github.Authorization.Authorization, self._requester, "/authorizations", None ) def get_emails(self): """ :calls: `GET /user/emails `_ :rtype: list of namedtuples with members email, primary, verified and visibility """ headers, data = self._requester.requestJsonAndCheck("GET", "/user/emails") itemdata = namedtuple("EmailData", data[0].keys()) return [itemdata._make(item.values()) for item in data] def get_events(self): """ :calls: `GET /events `_ :rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.Event.Event` """ return github.PaginatedList.PaginatedList( github.Event.Event, self._requester, "/events", None ) def get_followers(self): """ :calls: `GET /user/followers `_ :rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.NamedUser.NamedUser` """ return github.PaginatedList.PaginatedList( github.NamedUser.NamedUser, self._requester, "/user/followers", None ) def get_following(self): """ :calls: `GET /user/following `_ :rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.NamedUser.NamedUser` """ return github.PaginatedList.PaginatedList( github.NamedUser.NamedUser, self._requester, "/user/following", None ) def get_gists(self, since=github.GithubObject.NotSet): """ :calls: `GET /gists `_ :param since: datetime.datetime format YYYY-MM-DDTHH:MM:SSZ :rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.Gist.Gist` """ assert since is github.GithubObject.NotSet or isinstance( since, datetime.datetime ), since url_parameters = dict() if since is not github.GithubObject.NotSet: url_parameters["since"] = since.strftime("%Y-%m-%dT%H:%M:%SZ") return github.PaginatedList.PaginatedList( github.Gist.Gist, self._requester, "/gists", url_parameters ) def get_issues( self, filter=github.GithubObject.NotSet, state=github.GithubObject.NotSet, labels=github.GithubObject.NotSet, sort=github.GithubObject.NotSet, direction=github.GithubObject.NotSet, since=github.GithubObject.NotSet, ): """ :calls: `GET /issues `_ :rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.Issue.Issue` :param filter: string :param state: string :param labels: list of :class:`github.Label.Label` :param sort: string :param direction: string :param since: datetime.datetime :rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.Issue.Issue` """ assert filter is github.GithubObject.NotSet or isinstance(filter, str), filter assert state is github.GithubObject.NotSet or isinstance(state, str), state assert labels is github.GithubObject.NotSet or all( isinstance(element, github.Label.Label) for element in labels ), labels assert sort is github.GithubObject.NotSet or isinstance(sort, str), sort assert direction is github.GithubObject.NotSet or isinstance( direction, str ), direction assert since is github.GithubObject.NotSet or isinstance( since, datetime.datetime ), since url_parameters = dict() if filter is not github.GithubObject.NotSet: url_parameters["filter"] = filter if state is not github.GithubObject.NotSet: url_parameters["state"] = state if labels is not github.GithubObject.NotSet: url_parameters["labels"] = ",".join(label.name for label in labels) if sort is not github.GithubObject.NotSet: url_parameters["sort"] = sort if direction is not github.GithubObject.NotSet: url_parameters["direction"] = direction if since is not github.GithubObject.NotSet: url_parameters["since"] = since.strftime("%Y-%m-%dT%H:%M:%SZ") return github.PaginatedList.PaginatedList( github.Issue.Issue, self._requester, "/issues", url_parameters ) def get_user_issues( self, filter=github.GithubObject.NotSet, state=github.GithubObject.NotSet, labels=github.GithubObject.NotSet, sort=github.GithubObject.NotSet, direction=github.GithubObject.NotSet, since=github.GithubObject.NotSet, ): """ :calls: `GET /user/issues `_ :rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.Issue.Issue` :param filter: string :param state: string :param labels: list of :class:`github.Label.Label` :param sort: string :param direction: string :param since: datetime.datetime :rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.Issue.Issue` """ assert filter is github.GithubObject.NotSet or isinstance(filter, str), filter assert state is github.GithubObject.NotSet or isinstance(state, str), state assert labels is github.GithubObject.NotSet or all( isinstance(element, github.Label.Label) for element in labels ), labels assert sort is github.GithubObject.NotSet or isinstance(sort, str), sort assert direction is github.GithubObject.NotSet or isinstance( direction, str ), direction assert since is github.GithubObject.NotSet or isinstance( since, datetime.datetime ), since url_parameters = dict() if filter is not github.GithubObject.NotSet: url_parameters["filter"] = filter if state is not github.GithubObject.NotSet: url_parameters["state"] = state if labels is not github.GithubObject.NotSet: url_parameters["labels"] = ",".join(label.name for label in labels) if sort is not github.GithubObject.NotSet: url_parameters["sort"] = sort if direction is not github.GithubObject.NotSet: url_parameters["direction"] = direction if since is not github.GithubObject.NotSet: url_parameters["since"] = since.strftime("%Y-%m-%dT%H:%M:%SZ") return github.PaginatedList.PaginatedList( github.Issue.Issue, self._requester, "/user/issues", url_parameters ) def get_key(self, id): """ :calls: `GET /user/keys/{id} `_ :param id: integer :rtype: :class:`github.UserKey.UserKey` """ assert isinstance(id, int), id headers, data = self._requester.requestJsonAndCheck("GET", f"/user/keys/{id}") return github.UserKey.UserKey(self._requester, headers, data, completed=True) def get_keys(self): """ :calls: `GET /user/keys `_ :rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.UserKey.UserKey` """ return github.PaginatedList.PaginatedList( github.UserKey.UserKey, self._requester, "/user/keys", None ) def get_notification(self, id): """ :calls: `GET /notifications/threads/{id} `_ :rtype: :class:`github.Notification.Notification` """ assert isinstance(id, str), id headers, data = self._requester.requestJsonAndCheck( "GET", f"/notifications/threads/{id}" ) return github.Notification.Notification( self._requester, headers, data, completed=True ) def get_notifications( self, all=github.GithubObject.NotSet, participating=github.GithubObject.NotSet, since=github.GithubObject.NotSet, before=github.GithubObject.NotSet, ): """ :calls: `GET /notifications `_ :param all: bool :param participating: bool :param since: datetime.datetime :param before: datetime.datetime :rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.Notification.Notification` """ assert all is github.GithubObject.NotSet or isinstance(all, bool), all assert participating is github.GithubObject.NotSet or isinstance( participating, bool ), participating assert since is github.GithubObject.NotSet or isinstance( since, datetime.datetime ), since assert before is github.GithubObject.NotSet or isinstance( before, datetime.datetime ), before params = dict() if all is not github.GithubObject.NotSet: params["all"] = all if participating is not github.GithubObject.NotSet: params["participating"] = participating if since is not github.GithubObject.NotSet: params["since"] = since.strftime("%Y-%m-%dT%H:%M:%SZ") if before is not github.GithubObject.NotSet: params["before"] = before.strftime("%Y-%m-%dT%H:%M:%SZ") return github.PaginatedList.PaginatedList( github.Notification.Notification, self._requester, "/notifications", params ) def get_organization_events(self, org): """ :calls: `GET /users/{user}/events/orgs/{org} `_ :param org: :class:`github.Organization.Organization` :rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.Event.Event` """ assert isinstance(org, github.Organization.Organization), org return github.PaginatedList.PaginatedList( github.Event.Event, self._requester, f"/users/{self.login}/events/orgs/{org.login}", None, ) def get_orgs(self): """ :calls: `GET /user/orgs `_ :rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.Organization.Organization` """ return github.PaginatedList.PaginatedList( github.Organization.Organization, self._requester, "/user/orgs", None ) def get_repo(self, name): """ :calls: `GET /repos/{owner}/{repo} `_ :param name: string :rtype: :class:`github.Repository.Repository` """ assert isinstance(name, str), name headers, data = self._requester.requestJsonAndCheck( "GET", f"/repos/{self.login}/{name}" ) return github.Repository.Repository( self._requester, headers, data, completed=True ) def get_repos( self, visibility=github.GithubObject.NotSet, affiliation=github.GithubObject.NotSet, type=github.GithubObject.NotSet, sort=github.GithubObject.NotSet, direction=github.GithubObject.NotSet, ): """ :calls: `GET /user/repos ` :param visibility: string :param affiliation: string :param type: string :param sort: string :param direction: string :rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.Repository.Repository` """ assert visibility is github.GithubObject.NotSet or isinstance( visibility, str ), visibility assert affiliation is github.GithubObject.NotSet or isinstance( affiliation, str ), affiliation assert type is github.GithubObject.NotSet or isinstance(type, str), type assert sort is github.GithubObject.NotSet or isinstance(sort, str), sort assert direction is github.GithubObject.NotSet or isinstance( direction, str ), direction url_parameters = dict() if visibility is not github.GithubObject.NotSet: url_parameters["visibility"] = visibility if affiliation is not github.GithubObject.NotSet: url_parameters["affiliation"] = affiliation if type is not github.GithubObject.NotSet: url_parameters["type"] = type if sort is not github.GithubObject.NotSet: url_parameters["sort"] = sort if direction is not github.GithubObject.NotSet: url_parameters["direction"] = direction return github.PaginatedList.PaginatedList( github.Repository.Repository, self._requester, "/user/repos", url_parameters ) def get_starred(self): """ :calls: `GET /user/starred `_ :rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.Repository.Repository` """ return github.PaginatedList.PaginatedList( github.Repository.Repository, self._requester, "/user/starred", None ) def get_starred_gists(self): """ :calls: `GET /gists/starred `_ :rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.Gist.Gist` """ return github.PaginatedList.PaginatedList( github.Gist.Gist, self._requester, "/gists/starred", None ) def get_subscriptions(self): """ :calls: `GET /user/subscriptions `_ :rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.Repository.Repository` """ return github.PaginatedList.PaginatedList( github.Repository.Repository, self._requester, "/user/subscriptions", None ) def get_teams(self): """ :calls: `GET /user/teams `_ :rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.Team.Team` """ return github.PaginatedList.PaginatedList( github.Team.Team, self._requester, "/user/teams", None ) def get_watched(self): """ :calls: `GET /user/subscriptions `_ :rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.Repository.Repository` """ return github.PaginatedList.PaginatedList( github.Repository.Repository, self._requester, "/user/subscriptions", None ) def get_installations(self): """ :calls: `GET /user/installations `_ :rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.Installation.Installation` """ return github.PaginatedList.PaginatedList( github.Installation.Installation, self._requester, "/user/installations", None, headers={"Accept": Consts.mediaTypeIntegrationPreview}, list_item="installations", ) def has_in_following(self, following): """ :calls: `GET /user/following/{user} `_ :param following: :class:`github.NamedUser.NamedUser` :rtype: bool """ assert isinstance(following, github.NamedUser.NamedUser), following status, headers, data = self._requester.requestJson( "GET", f"/user/following/{following._identity}" ) return status == 204 def has_in_starred(self, starred): """ :calls: `GET /user/starred/{owner}/{repo} `_ :param starred: :class:`github.Repository.Repository` :rtype: bool """ assert isinstance(starred, github.Repository.Repository), starred status, headers, data = self._requester.requestJson( "GET", f"/user/starred/{starred._identity}" ) return status == 204 def has_in_subscriptions(self, subscription): """ :calls: `GET /user/subscriptions/{owner}/{repo} `_ :param subscription: :class:`github.Repository.Repository` :rtype: bool """ assert isinstance(subscription, github.Repository.Repository), subscription status, headers, data = self._requester.requestJson( "GET", f"/user/subscriptions/{subscription._identity}" ) return status == 204 def has_in_watched(self, watched): """ :calls: `GET /repos/{owner}/{repo}/subscription `_ :param watched: :class:`github.Repository.Repository` :rtype: bool """ assert isinstance(watched, github.Repository.Repository), watched status, headers, data = self._requester.requestJson( "GET", f"/repos/{watched._identity}/subscription" ) return status == 200 def mark_notifications_as_read(self, last_read_at=datetime.datetime.utcnow()): """ :calls: `PUT /notifications `_ :param last_read_at: datetime """ assert isinstance(last_read_at, datetime.datetime) put_parameters = {"last_read_at": last_read_at.strftime("%Y-%m-%dT%H:%M:%SZ")} headers, data = self._requester.requestJsonAndCheck( "PUT", "/notifications", input=put_parameters ) def remove_from_emails(self, *emails): """ :calls: `DELETE /user/emails `_ :param email: string :rtype: None """ assert all(isinstance(element, str) for element in emails), emails post_parameters = {"emails": emails} headers, data = self._requester.requestJsonAndCheck( "DELETE", "/user/emails", input=post_parameters ) def remove_from_following(self, following): """ :calls: `DELETE /user/following/{user} `_ :param following: :class:`github.NamedUser.NamedUser` :rtype: None """ assert isinstance(following, github.NamedUser.NamedUser), following headers, data = self._requester.requestJsonAndCheck( "DELETE", f"/user/following/{following._identity}" ) def remove_from_starred(self, starred): """ :calls: `DELETE /user/starred/{owner}/{repo} `_ :param starred: :class:`github.Repository.Repository` :rtype: None """ assert isinstance(starred, github.Repository.Repository), starred headers, data = self._requester.requestJsonAndCheck( "DELETE", f"/user/starred/{starred._identity}" ) def remove_from_subscriptions(self, subscription): """ :calls: `DELETE /user/subscriptions/{owner}/{repo} `_ :param subscription: :class:`github.Repository.Repository` :rtype: None """ assert isinstance(subscription, github.Repository.Repository), subscription headers, data = self._requester.requestJsonAndCheck( "DELETE", f"/user/subscriptions/{subscription._identity}" ) def remove_from_watched(self, watched): """ :calls: `DELETE /repos/{owner}/{repo}/subscription `_ :param watched: :class:`github.Repository.Repository` :rtype: None """ assert isinstance(watched, github.Repository.Repository), watched headers, data = self._requester.requestJsonAndCheck( "DELETE", f"/repos/{watched._identity}/subscription" ) def accept_invitation(self, invitation): """ :calls: `PATCH /user/repository_invitations/{invitation_id} ` :param invitation: :class:`github.Invitation.Invitation` or int :rtype: None """ assert isinstance(invitation, github.Invitation.Invitation) or isinstance( invitation, int ) if isinstance(invitation, github.Invitation.Invitation): invitation = invitation.id headers, data = self._requester.requestJsonAndCheck( "PATCH", f"/user/repository_invitations/{invitation}", input={} ) def get_invitations(self): """ :calls: `GET /user/repository_invitations `_ :rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.Invitation.Invitation` """ return github.PaginatedList.PaginatedList( github.Invitation.Invitation, self._requester, "/user/repository_invitations", None, ) def create_migration( self, repos, lock_repositories=github.GithubObject.NotSet, exclude_attachments=github.GithubObject.NotSet, ): """ :calls: `POST /user/migrations `_ :param repos: list or tuple of str :param lock_repositories: bool :param exclude_attachments: bool :rtype: :class:`github.Migration.Migration` """ assert isinstance(repos, (list, tuple)), repos assert all(isinstance(repo, str) for repo in repos), repos assert lock_repositories is github.GithubObject.NotSet or isinstance( lock_repositories, bool ), lock_repositories assert exclude_attachments is github.GithubObject.NotSet or isinstance( exclude_attachments, bool ), exclude_attachments post_parameters = {"repositories": repos} if lock_repositories is not github.GithubObject.NotSet: post_parameters["lock_repositories"] = lock_repositories if exclude_attachments is not github.GithubObject.NotSet: post_parameters["exclude_attachments"] = exclude_attachments headers, data = self._requester.requestJsonAndCheck( "POST", "/user/migrations", input=post_parameters, headers={"Accept": Consts.mediaTypeMigrationPreview}, ) return github.Migration.Migration( self._requester, headers, data, completed=True ) def get_migrations(self): """ :calls: `GET /user/migrations `_ :rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.Migration.Migration` """ return github.PaginatedList.PaginatedList( github.Migration.Migration, self._requester, "/user/migrations", None, headers={"Accept": Consts.mediaTypeMigrationPreview}, ) def get_organization_membership(self, org): """ :calls: `GET /user/memberships/orgs/{org} `_ :rtype: :class:`github.Membership.Membership` """ assert isinstance(org, str) headers, data = self._requester.requestJsonAndCheck( "GET", f"/user/memberships/orgs/{org}" ) return github.Membership.Membership( self._requester, headers, data, completed=True ) def _initAttributes(self): self._avatar_url = github.GithubObject.NotSet self._bio = github.GithubObject.NotSet self._blog = github.GithubObject.NotSet self._collaborators = github.GithubObject.NotSet self._company = github.GithubObject.NotSet self._created_at = github.GithubObject.NotSet self._disk_usage = github.GithubObject.NotSet self._email = github.GithubObject.NotSet self._events_url = github.GithubObject.NotSet self._followers = github.GithubObject.NotSet self._followers_url = github.GithubObject.NotSet self._following = github.GithubObject.NotSet self._following_url = github.GithubObject.NotSet self._gists_url = github.GithubObject.NotSet self._gravatar_id = github.GithubObject.NotSet self._hireable = github.GithubObject.NotSet self._html_url = github.GithubObject.NotSet self._id = github.GithubObject.NotSet self._location = github.GithubObject.NotSet self._login = github.GithubObject.NotSet self._name = github.GithubObject.NotSet self._node_id = github.GithubObject.NotSet self._organizations_url = github.GithubObject.NotSet self._owned_private_repos = github.GithubObject.NotSet self._plan = github.GithubObject.NotSet self._private_gists = github.GithubObject.NotSet self._public_gists = github.GithubObject.NotSet self._public_repos = github.GithubObject.NotSet self._received_events_url = github.GithubObject.NotSet self._repos_url = github.GithubObject.NotSet self._site_admin = github.GithubObject.NotSet self._starred_url = github.GithubObject.NotSet self._subscriptions_url = github.GithubObject.NotSet self._total_private_repos = github.GithubObject.NotSet self._type = github.GithubObject.NotSet self._updated_at = github.GithubObject.NotSet self._url = github.GithubObject.NotSet def _useAttributes(self, attributes): if "avatar_url" in attributes: # pragma no branch self._avatar_url = self._makeStringAttribute(attributes["avatar_url"]) if "bio" in attributes: # pragma no branch self._bio = self._makeStringAttribute(attributes["bio"]) if "blog" in attributes: # pragma no branch self._blog = self._makeStringAttribute(attributes["blog"]) if "collaborators" in attributes: # pragma no branch self._collaborators = self._makeIntAttribute(attributes["collaborators"]) if "company" in attributes: # pragma no branch self._company = self._makeStringAttribute(attributes["company"]) if "created_at" in attributes: # pragma no branch self._created_at = self._makeDatetimeAttribute(attributes["created_at"]) if "disk_usage" in attributes: # pragma no branch self._disk_usage = self._makeIntAttribute(attributes["disk_usage"]) if "email" in attributes: # pragma no branch self._email = self._makeStringAttribute(attributes["email"]) if "events_url" in attributes: # pragma no branch self._events_url = self._makeStringAttribute(attributes["events_url"]) if "followers" in attributes: # pragma no branch self._followers = self._makeIntAttribute(attributes["followers"]) if "followers_url" in attributes: # pragma no branch self._followers_url = self._makeStringAttribute(attributes["followers_url"]) if "following" in attributes: # pragma no branch self._following = self._makeIntAttribute(attributes["following"]) if "following_url" in attributes: # pragma no branch self._following_url = self._makeStringAttribute(attributes["following_url"]) if "gists_url" in attributes: # pragma no branch self._gists_url = self._makeStringAttribute(attributes["gists_url"]) if "gravatar_id" in attributes: # pragma no branch self._gravatar_id = self._makeStringAttribute(attributes["gravatar_id"]) if "hireable" in attributes: # pragma no branch self._hireable = self._makeBoolAttribute(attributes["hireable"]) if "html_url" in attributes: # pragma no branch self._html_url = self._makeStringAttribute(attributes["html_url"]) if "id" in attributes: # pragma no branch self._id = self._makeIntAttribute(attributes["id"]) if "location" in attributes: # pragma no branch self._location = self._makeStringAttribute(attributes["location"]) if "login" in attributes: # pragma no branch self._login = self._makeStringAttribute(attributes["login"]) if "name" in attributes: # pragma no branch self._name = self._makeStringAttribute(attributes["name"]) if "node_id" in attributes: # pragma no branch self._node_id = self._makeStringAttribute(attributes["node_id"]) if "organizations_url" in attributes: # pragma no branch self._organizations_url = self._makeStringAttribute( attributes["organizations_url"] ) if "owned_private_repos" in attributes: # pragma no branch self._owned_private_repos = self._makeIntAttribute( attributes["owned_private_repos"] ) if "plan" in attributes: # pragma no branch self._plan = self._makeClassAttribute(github.Plan.Plan, attributes["plan"]) if "private_gists" in attributes: # pragma no branch self._private_gists = self._makeIntAttribute(attributes["private_gists"]) if "public_gists" in attributes: # pragma no branch self._public_gists = self._makeIntAttribute(attributes["public_gists"]) if "public_repos" in attributes: # pragma no branch self._public_repos = self._makeIntAttribute(attributes["public_repos"]) if "received_events_url" in attributes: # pragma no branch self._received_events_url = self._makeStringAttribute( attributes["received_events_url"] ) if "repos_url" in attributes: # pragma no branch self._repos_url = self._makeStringAttribute(attributes["repos_url"]) if "site_admin" in attributes: # pragma no branch self._site_admin = self._makeBoolAttribute(attributes["site_admin"]) if "starred_url" in attributes: # pragma no branch self._starred_url = self._makeStringAttribute(attributes["starred_url"]) if "subscriptions_url" in attributes: # pragma no branch self._subscriptions_url = self._makeStringAttribute( attributes["subscriptions_url"] ) if "total_private_repos" in attributes: # pragma no branch self._total_private_repos = self._makeIntAttribute( attributes["total_private_repos"] ) if "type" in attributes: # pragma no branch self._type = self._makeStringAttribute(attributes["type"]) if "updated_at" in attributes: # pragma no branch self._updated_at = self._makeDatetimeAttribute(attributes["updated_at"]) if "url" in attributes: # pragma no branch self._url = self._makeStringAttribute(attributes["url"]) ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1619412308.0 PyGithub-1.55/github/AuthenticatedUser.pyi0000644000175100001710000002113200000000000020164 0ustar00runnerdockerfrom datetime import datetime from typing import Any, Dict, List, Optional, Union, NamedTuple from github.Authorization import Authorization from github.Event import Event from github.Gist import Gist from github.GithubObject import CompletableGithubObject, _NotSetType from github.InputFileContent import InputFileContent from github.Invitation import Invitation from github.Issue import Issue from github.Label import Label from github.Membership import Membership from github.Migration import Migration from github.NamedUser import NamedUser from github.Notification import Notification from github.Organization import Organization from github.PaginatedList import PaginatedList from github.Plan import Plan from github.Repository import Repository from github.Team import Team from github.UserKey import UserKey class EmailData(NamedTuple): email: str primary: bool verified: bool visibility: str class AuthenticatedUser(CompletableGithubObject): def __repr__(self) -> str: ... def _initAttributes(self) -> None: ... def _useAttributes(self, attributes: Dict[str, Any]) -> None: ... def accept_invitation(self, invitation: Union[int, Invitation]) -> None: ... def add_to_emails(self, *emails: List[str]) -> None: ... def add_to_following(self, following: NamedUser) -> None: ... def add_to_starred(self, starred: Repository) -> None: ... def add_to_subscriptions(self, subscription: Repository) -> None: ... def add_to_watched(self, watched: Repository) -> None: ... @property def avatar_url(self) -> str: ... @property def bio(self) -> str: ... @property def blog(self) -> str: ... @property def collaborators(self) -> int: ... @property def company(self) -> str: ... def create_authorization( self, scopes: Union[List[str], _NotSetType] = ..., note: Union[str, _NotSetType] = ..., note_url: Union[str, _NotSetType] = ..., client_id: Union[str, _NotSetType] = ..., client_secret: Union[str, _NotSetType] = ..., onetime_password: Union[str, None] = ..., ) -> Authorization: ... def create_fork(self, repo: Repository) -> Repository: ... def create_gist( self, public: bool, files: Dict[str, InputFileContent], description: Union[str, _NotSetType] = ..., ) -> Gist: ... def create_key(self, title: str, key: str) -> UserKey: ... def create_migration( self, repos: List[str], lock_repositories: Union[bool, _NotSetType] = ..., exclude_attachments: Union[bool, _NotSetType] = ..., ) -> Migration: ... def create_repo( self, name: str, description: Union[str, _NotSetType] = ..., homepage: Union[str, _NotSetType] = ..., private: Union[bool, _NotSetType] = ..., has_issues: Union[bool, _NotSetType] = ..., has_wiki: Union[bool, _NotSetType] = ..., has_downloads: Union[bool, _NotSetType] = ..., has_projects: Union[bool, _NotSetType] = ..., auto_init: Union[bool, _NotSetType] = ..., license_template: _NotSetType = ..., gitignore_template: Union[str, _NotSetType] = ..., allow_squash_merge: Union[bool, _NotSetType] = ..., allow_merge_commit: Union[bool, _NotSetType] = ..., allow_rebase_merge: Union[bool, _NotSetType] = ..., ) -> Repository: ... @property def created_at(self) -> datetime: ... @property def disk_usage(self) -> int: ... def edit( self, name: Union[str, _NotSetType] = ..., email: Union[str, _NotSetType] = ..., blog: Union[str, _NotSetType] = ..., company: Union[str, _NotSetType] = ..., location: Union[str, _NotSetType] = ..., hireable: Union[bool, _NotSetType] = ..., bio: Union[str, _NotSetType] = ..., ) -> None: ... @property def email(self) -> str: ... @property def events_url(self) -> str: ... @property def followers(self) -> int: ... @property def followers_url(self) -> str: ... @property def following(self) -> int: ... @property def following_url(self) -> str: ... def get_authorization(self, id: int) -> Authorization: ... def get_authorizations(self) -> PaginatedList[Authorization]: ... def get_emails(self) -> List[EmailData]: ... def get_events(self) -> PaginatedList[Event]: ... def get_followers(self) -> PaginatedList[NamedUser]: ... def get_following(self) -> PaginatedList[NamedUser]: ... def get_gists( self, since: Union[datetime, _NotSetType] = ... ) -> PaginatedList[Gist]: ... def get_invitations(self) -> PaginatedList[Invitation]: ... def get_issues( self, filter: Union[str, _NotSetType] = ..., state: Union[str, _NotSetType] = ..., labels: Union[List[Label], _NotSetType] = ..., sort: Union[str, _NotSetType] = ..., direction: Union[str, _NotSetType] = ..., since: Union[_NotSetType, datetime] = ..., ) -> PaginatedList[Issue]: ... def get_key(self, id: int) -> UserKey: ... def get_keys(self) -> PaginatedList[UserKey]: ... def get_migrations(self) -> PaginatedList[Migration]: ... def get_notification(self, id: str) -> Notification: ... def get_notifications( self, all: Union[bool, _NotSetType] = ..., participating: Union[bool, _NotSetType] = ..., since: Union[datetime, _NotSetType] = ..., before: Union[datetime, _NotSetType] = ..., ) -> PaginatedList[Notification]: ... def get_organization_events(self, org: Organization) -> PaginatedList[Event]: ... def get_organization_membership(self, org: int) -> Membership: ... def get_orgs(self) -> PaginatedList[Organization]: ... def get_repo(self, name: str) -> Repository: ... def get_repos( self, visibility: Union[str, _NotSetType] = ..., affiliation: Union[str, _NotSetType] = ..., type: Union[str, _NotSetType] = ..., sort: Union[str, _NotSetType] = ..., direction: Union[str, _NotSetType] = ..., ) -> PaginatedList[Repository]: ... def get_starred(self) -> PaginatedList[Repository]: ... def get_starred_gists(self) -> PaginatedList[Gist]: ... def get_subscriptions(self) -> PaginatedList[Repository]: ... def get_teams(self) -> PaginatedList[Team]: ... def get_user_issues( self, filter: Union[str, _NotSetType] = ..., state: Union[str, _NotSetType] = ..., labels: Union[List[Label], _NotSetType] = ..., sort: Union[str, _NotSetType] = ..., direction: Union[str, _NotSetType] = ..., since: Union[_NotSetType, datetime] = ..., ) -> PaginatedList[Issue]: ... def get_watched(self) -> PaginatedList[Repository]: ... @property def gists_url(self) -> str: ... @property def gravatar_id(self) -> str: ... def has_in_following(self, following: NamedUser) -> bool: ... def has_in_starred(self, starred: Repository) -> bool: ... def has_in_subscriptions(self, subscription: Repository) -> bool: ... def has_in_watched(self, watched: Repository) -> bool: ... @property def hireable(self) -> bool: ... @property def html_url(self) -> str: ... @property def id(self) -> int: ... @property def location(self) -> str: ... @property def login(self) -> str: ... def mark_notifications_as_read(self, last_read_at: datetime = ...) -> None: ... @property def name(self) -> str: ... @property def node_id(self) -> str: ... @property def organizations_url(self) -> str: ... @property def owned_private_repos(self) -> int: ... @property def plan(self) -> Plan: ... @property def private_gists(self) -> int: ... @property def public_gists(self) -> int: ... @property def public_repos(self) -> int: ... @property def received_events_url(self) -> str: ... def remove_from_emails(self, *emails: str) -> None: ... def remove_from_following(self, following: NamedUser) -> None: ... def remove_from_starred(self, starred: Repository) -> None: ... def remove_from_subscriptions(self, subscription: Repository) -> None: ... def remove_from_watched(self, watched: Repository) -> None: ... @property def repos_url(self) -> str: ... @property def site_admin(self) -> bool: ... @property def starred_url(self) -> str: ... @property def subscriptions_url(self) -> str: ... @property def total_private_repos(self) -> int: ... @property def type(self) -> str: ... @property def updated_at(self) -> datetime: ... @property def url(self) -> str: ... ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1619412308.0 PyGithub-1.55/github/Authorization.py0000644000175100001710000002017300000000000017236 0ustar00runnerdocker############################ Copyrights and license ############################ # # # Copyright 2012 Vincent Jacques # # Copyright 2012 Zearin # # Copyright 2013 AKFish # # Copyright 2013 Vincent Jacques # # Copyright 2014 Vincent Jacques # # Copyright 2016 Jannis Gebauer # # Copyright 2016 Peter Buckley # # Copyright 2018 Wan Liuyang # # Copyright 2018 sfdye # # # # This file is part of PyGithub. # # http://pygithub.readthedocs.io/ # # # # PyGithub is free software: you can redistribute it and/or modify it under # # the terms of the GNU Lesser General Public License as published by the Free # # Software Foundation, either version 3 of the License, or (at your option) # # any later version. # # # # PyGithub is distributed in the hope that it will be useful, but WITHOUT ANY # # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more # # details. # # # # You should have received a copy of the GNU Lesser General Public License # # along with PyGithub. If not, see . # # # ################################################################################ import github.AuthorizationApplication import github.GithubObject class Authorization(github.GithubObject.CompletableGithubObject): """ This class represents Authorizations. The reference can be found here https://docs.github.com/en/enterprise-server@3.0/rest/reference/oauth-authorizations """ def __repr__(self): return self.get__repr__({"scopes": self._scopes.value}) @property def app(self): """ :type: :class:`github.AuthorizationApplication.AuthorizationApplication` """ self._completeIfNotSet(self._app) return self._app.value @property def created_at(self): """ :type: datetime.datetime """ self._completeIfNotSet(self._created_at) return self._created_at.value @property def id(self): """ :type: integer """ self._completeIfNotSet(self._id) return self._id.value @property def note(self): """ :type: string """ self._completeIfNotSet(self._note) return self._note.value @property def note_url(self): """ :type: string """ self._completeIfNotSet(self._note_url) return self._note_url.value @property def scopes(self): """ :type: list of string """ self._completeIfNotSet(self._scopes) return self._scopes.value @property def token(self): """ :type: string """ self._completeIfNotSet(self._token) return self._token.value @property def updated_at(self): """ :type: datetime.datetime """ self._completeIfNotSet(self._updated_at) return self._updated_at.value @property def url(self): """ :type: string """ self._completeIfNotSet(self._url) return self._url.value def delete(self): """ :calls: `DELETE /authorizations/{id} `_ :rtype: None """ headers, data = self._requester.requestJsonAndCheck("DELETE", self.url) def edit( self, scopes=github.GithubObject.NotSet, add_scopes=github.GithubObject.NotSet, remove_scopes=github.GithubObject.NotSet, note=github.GithubObject.NotSet, note_url=github.GithubObject.NotSet, ): """ :calls: `PATCH /authorizations/{id} `_ :param scopes: list of string :param add_scopes: list of string :param remove_scopes: list of string :param note: string :param note_url: string :rtype: None """ assert scopes is github.GithubObject.NotSet or all( isinstance(element, str) for element in scopes ), scopes assert add_scopes is github.GithubObject.NotSet or all( isinstance(element, str) for element in add_scopes ), add_scopes assert remove_scopes is github.GithubObject.NotSet or all( isinstance(element, str) for element in remove_scopes ), remove_scopes assert note is github.GithubObject.NotSet or isinstance(note, str), note assert note_url is github.GithubObject.NotSet or isinstance( note_url, str ), note_url post_parameters = dict() if scopes is not github.GithubObject.NotSet: post_parameters["scopes"] = scopes if add_scopes is not github.GithubObject.NotSet: post_parameters["add_scopes"] = add_scopes if remove_scopes is not github.GithubObject.NotSet: post_parameters["remove_scopes"] = remove_scopes if note is not github.GithubObject.NotSet: post_parameters["note"] = note if note_url is not github.GithubObject.NotSet: post_parameters["note_url"] = note_url headers, data = self._requester.requestJsonAndCheck( "PATCH", self.url, input=post_parameters ) self._useAttributes(data) def _initAttributes(self): self._app = github.GithubObject.NotSet self._created_at = github.GithubObject.NotSet self._id = github.GithubObject.NotSet self._note = github.GithubObject.NotSet self._note_url = github.GithubObject.NotSet self._scopes = github.GithubObject.NotSet self._token = github.GithubObject.NotSet self._updated_at = github.GithubObject.NotSet self._url = github.GithubObject.NotSet def _useAttributes(self, attributes): if "app" in attributes: # pragma no branch self._app = self._makeClassAttribute( github.AuthorizationApplication.AuthorizationApplication, attributes["app"], ) if "created_at" in attributes: # pragma no branch self._created_at = self._makeDatetimeAttribute(attributes["created_at"]) if "id" in attributes: # pragma no branch self._id = self._makeIntAttribute(attributes["id"]) if "note" in attributes: # pragma no branch self._note = self._makeStringAttribute(attributes["note"]) if "note_url" in attributes: # pragma no branch self._note_url = self._makeStringAttribute(attributes["note_url"]) if "scopes" in attributes: # pragma no branch self._scopes = self._makeListOfStringsAttribute(attributes["scopes"]) if "token" in attributes: # pragma no branch self._token = self._makeStringAttribute(attributes["token"]) if "updated_at" in attributes: # pragma no branch self._updated_at = self._makeDatetimeAttribute(attributes["updated_at"]) if "url" in attributes: # pragma no branch self._url = self._makeStringAttribute(attributes["url"]) ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1619412308.0 PyGithub-1.55/github/Authorization.pyi0000644000175100001710000000232600000000000017407 0ustar00runnerdockerfrom datetime import datetime from typing import Any, Dict, List, Optional, Union from github.AuthorizationApplication import AuthorizationApplication from github.GithubObject import CompletableGithubObject, _NotSetType class Authorization(CompletableGithubObject): def __repr__(self) -> str: ... def _initAttributes(self) -> None: ... def _useAttributes(self, attributes: Dict[str, Any]) -> None: ... @property def app(self) -> AuthorizationApplication: ... @property def created_at(self) -> datetime: ... def delete(self) -> None: ... def edit( self, scopes: Union[_NotSetType, List[str]] = ..., add_scopes: Union[_NotSetType, List[str]] = ..., remove_scopes: Union[_NotSetType, List[str]] = ..., note: Union[_NotSetType, str] = ..., note_url: Union[_NotSetType, str] = ..., ) -> None: ... @property def id(self) -> int: ... @property def note(self) -> Optional[str]: ... @property def note_url(self) -> Optional[str]: ... @property def scopes(self) -> List[str]: ... @property def token(self) -> str: ... @property def updated_at(self) -> datetime: ... @property def url(self) -> str: ... ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1619412308.0 PyGithub-1.55/github/AuthorizationApplication.py0000644000175100001710000000640500000000000021424 0ustar00runnerdocker############################ Copyrights and license ############################ # # # Copyright 2012 Vincent Jacques # # Copyright 2012 Zearin # # Copyright 2013 AKFish # # Copyright 2013 Vincent Jacques # # Copyright 2014 Vincent Jacques # # Copyright 2016 Jannis Gebauer # # Copyright 2016 Peter Buckley # # Copyright 2018 Wan Liuyang # # Copyright 2018 sfdye # # # # This file is part of PyGithub. # # http://pygithub.readthedocs.io/ # # # # PyGithub is free software: you can redistribute it and/or modify it under # # the terms of the GNU Lesser General Public License as published by the Free # # Software Foundation, either version 3 of the License, or (at your option) # # any later version. # # # # PyGithub is distributed in the hope that it will be useful, but WITHOUT ANY # # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more # # details. # # # # You should have received a copy of the GNU Lesser General Public License # # along with PyGithub. If not, see . # # # ################################################################################ import github.GithubObject class AuthorizationApplication(github.GithubObject.CompletableGithubObject): """ This class represents AuthorizationApplications """ def __repr__(self): return self.get__repr__({"name": self._name.value}) @property def name(self): """ :type: string """ self._completeIfNotSet(self._name) return self._name.value @property def url(self): """ :type: string """ self._completeIfNotSet(self._url) return self._url.value def _initAttributes(self): self._name = github.GithubObject.NotSet self._url = github.GithubObject.NotSet def _useAttributes(self, attributes): if "name" in attributes: # pragma no branch self._name = self._makeStringAttribute(attributes["name"]) if "url" in attributes: # pragma no branch self._url = self._makeStringAttribute(attributes["url"]) ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1619412308.0 PyGithub-1.55/github/AuthorizationApplication.pyi0000644000175100001710000000052500000000000021572 0ustar00runnerdockerfrom typing import Dict from github.GithubObject import CompletableGithubObject class AuthorizationApplication(CompletableGithubObject): def _initAttributes(self) -> None: ... def _useAttributes(self, attributes: Dict[str, str]) -> None: ... @property def name(self) -> str: ... @property def url(self) -> str: ... ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1619412308.0 PyGithub-1.55/github/Branch.py0000644000175100001710000005725000000000000015601 0ustar00runnerdocker############################ Copyrights and license ############################ # # # Copyright 2012 Vincent Jacques # # Copyright 2012 Zearin # # Copyright 2013 AKFish # # Copyright 2013 Vincent Jacques # # Copyright 2013 martinqt # # Copyright 2014 Vincent Jacques # # Copyright 2015 Kyle Hornberg # # Copyright 2016 Jannis Gebauer # # Copyright 2016 Peter Buckley # # Copyright 2018 Steve Kowalik # # Copyright 2018 Wan Liuyang # # Copyright 2018 sfdye # # # # This file is part of PyGithub. # # http://pygithub.readthedocs.io/ # # # # PyGithub is free software: you can redistribute it and/or modify it under # # the terms of the GNU Lesser General Public License as published by the Free # # Software Foundation, either version 3 of the License, or (at your option) # # any later version. # # # # PyGithub is distributed in the hope that it will be useful, but WITHOUT ANY # # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more # # details. # # # # You should have received a copy of the GNU Lesser General Public License # # along with PyGithub. If not, see . # # # ################################################################################ import github.BranchProtection import github.Commit import github.GithubObject import github.RequiredPullRequestReviews import github.RequiredStatusChecks from . import Consts class Branch(github.GithubObject.NonCompletableGithubObject): """ This class represents Branches. The reference can be found here https://docs.github.com/en/rest/reference/repos#branches """ def __repr__(self): return self.get__repr__({"name": self._name.value}) @property def commit(self): """ :type: :class:`github.Commit.Commit` """ return self._commit.value @property def name(self): """ :type: string """ return self._name.value @property def protected(self): """ :type: bool """ return self._protected.value @property def protection_url(self): """ :type: string """ return self._protection_url.value def _initAttributes(self): self._commit = github.GithubObject.NotSet self._name = github.GithubObject.NotSet self._protection_url = github.GithubObject.NotSet self._protected = github.GithubObject.NotSet def _useAttributes(self, attributes): if "commit" in attributes: # pragma no branch self._commit = self._makeClassAttribute( github.Commit.Commit, attributes["commit"] ) if "name" in attributes: # pragma no branch self._name = self._makeStringAttribute(attributes["name"]) if "protection_url" in attributes: # pragma no branch self._protection_url = self._makeStringAttribute( attributes["protection_url"] ) if "protected" in attributes: # pragma no branch self._protected = self._makeBoolAttribute(attributes["protected"]) def get_protection(self): """ :calls: `GET /repos/{owner}/{repo}/branches/{branch}/protection `_ """ headers, data = self._requester.requestJsonAndCheck( "GET", self.protection_url, headers={"Accept": Consts.mediaTypeRequireMultipleApprovingReviews}, ) return github.BranchProtection.BranchProtection( self._requester, headers, data, completed=True ) def edit_protection( self, strict=github.GithubObject.NotSet, contexts=github.GithubObject.NotSet, enforce_admins=github.GithubObject.NotSet, dismissal_users=github.GithubObject.NotSet, dismissal_teams=github.GithubObject.NotSet, dismiss_stale_reviews=github.GithubObject.NotSet, require_code_owner_reviews=github.GithubObject.NotSet, required_approving_review_count=github.GithubObject.NotSet, user_push_restrictions=github.GithubObject.NotSet, team_push_restrictions=github.GithubObject.NotSet, ): """ :calls: `PUT /repos/{owner}/{repo}/branches/{branch}/protection `_ :strict: bool :contexts: list of strings :enforce_admins: bool :dismissal_users: list of strings :dismissal_teams: list of strings :dismiss_stale_reviews: bool :require_code_owner_reviews: bool :required_approving_review_count: int :user_push_restrictions: list of strings :team_push_restrictions: list of strings NOTE: The GitHub API groups strict and contexts together, both must be submitted. Take care to pass both as arguments even if only one is changing. Use edit_required_status_checks() to avoid this. """ assert strict is github.GithubObject.NotSet or isinstance(strict, bool), strict assert contexts is github.GithubObject.NotSet or all( isinstance(element, str) for element in contexts ), contexts assert enforce_admins is github.GithubObject.NotSet or isinstance( enforce_admins, bool ), enforce_admins assert dismissal_users is github.GithubObject.NotSet or all( isinstance(element, str) for element in dismissal_users ), dismissal_users assert dismissal_teams is github.GithubObject.NotSet or all( isinstance(element, str) for element in dismissal_teams ), dismissal_teams assert dismiss_stale_reviews is github.GithubObject.NotSet or isinstance( dismiss_stale_reviews, bool ), dismiss_stale_reviews assert require_code_owner_reviews is github.GithubObject.NotSet or isinstance( require_code_owner_reviews, bool ), require_code_owner_reviews assert ( required_approving_review_count is github.GithubObject.NotSet or isinstance(required_approving_review_count, int) ), (required_approving_review_count) post_parameters = {} if ( strict is not github.GithubObject.NotSet or contexts is not github.GithubObject.NotSet ): if strict is github.GithubObject.NotSet: strict = False if contexts is github.GithubObject.NotSet: contexts = [] post_parameters["required_status_checks"] = { "strict": strict, "contexts": contexts, } else: post_parameters["required_status_checks"] = None if enforce_admins is not github.GithubObject.NotSet: post_parameters["enforce_admins"] = enforce_admins else: post_parameters["enforce_admins"] = None if ( dismissal_users is not github.GithubObject.NotSet or dismissal_teams is not github.GithubObject.NotSet or dismiss_stale_reviews is not github.GithubObject.NotSet or require_code_owner_reviews is not github.GithubObject.NotSet or required_approving_review_count is not github.GithubObject.NotSet ): post_parameters["required_pull_request_reviews"] = {} if dismiss_stale_reviews is not github.GithubObject.NotSet: post_parameters["required_pull_request_reviews"][ "dismiss_stale_reviews" ] = dismiss_stale_reviews if require_code_owner_reviews is not github.GithubObject.NotSet: post_parameters["required_pull_request_reviews"][ "require_code_owner_reviews" ] = require_code_owner_reviews if required_approving_review_count is not github.GithubObject.NotSet: post_parameters["required_pull_request_reviews"][ "required_approving_review_count" ] = required_approving_review_count if dismissal_users is not github.GithubObject.NotSet: post_parameters["required_pull_request_reviews"][ "dismissal_restrictions" ] = {"users": dismissal_users} if dismissal_teams is not github.GithubObject.NotSet: if ( "dismissal_restrictions" not in post_parameters["required_pull_request_reviews"] ): post_parameters["required_pull_request_reviews"][ "dismissal_restrictions" ] = {} post_parameters["required_pull_request_reviews"][ "dismissal_restrictions" ]["teams"] = dismissal_teams else: post_parameters["required_pull_request_reviews"] = None if ( user_push_restrictions is not github.GithubObject.NotSet or team_push_restrictions is not github.GithubObject.NotSet ): if user_push_restrictions is github.GithubObject.NotSet: user_push_restrictions = [] if team_push_restrictions is github.GithubObject.NotSet: team_push_restrictions = [] post_parameters["restrictions"] = { "users": user_push_restrictions, "teams": team_push_restrictions, } else: post_parameters["restrictions"] = None headers, data = self._requester.requestJsonAndCheck( "PUT", self.protection_url, headers={"Accept": Consts.mediaTypeRequireMultipleApprovingReviews}, input=post_parameters, ) def remove_protection(self): """ :calls: `DELETE /repos/{owner}/{repo}/branches/{branch}/protection `_ """ headers, data = self._requester.requestJsonAndCheck( "DELETE", self.protection_url, ) def get_required_status_checks(self): """ :calls: `GET /repos/{owner}/{repo}/branches/{branch}/protection/required_status_checks `_ :rtype: :class:`github.RequiredStatusChecks.RequiredStatusChecks` """ headers, data = self._requester.requestJsonAndCheck( "GET", f"{self.protection_url}/required_status_checks" ) return github.RequiredStatusChecks.RequiredStatusChecks( self._requester, headers, data, completed=True ) def edit_required_status_checks( self, strict=github.GithubObject.NotSet, contexts=github.GithubObject.NotSet ): """ :calls: `PATCH /repos/{owner}/{repo}/branches/{branch}/protection/required_status_checks `_ :strict: bool :contexts: list of strings """ assert strict is github.GithubObject.NotSet or isinstance(strict, bool), strict assert contexts is github.GithubObject.NotSet or all( isinstance(element, str) for element in contexts ), contexts post_parameters = {} if strict is not github.GithubObject.NotSet: post_parameters["strict"] = strict if contexts is not github.GithubObject.NotSet: post_parameters["contexts"] = contexts headers, data = self._requester.requestJsonAndCheck( "PATCH", f"{self.protection_url}/required_status_checks", input=post_parameters, ) def remove_required_status_checks(self): """ :calls: `DELETE /repos/{owner}/{repo}/branches/{branch}/protection/required_status_checks `_ """ headers, data = self._requester.requestJsonAndCheck( "DELETE", f"{self.protection_url}/required_status_checks", ) def get_required_pull_request_reviews(self): """ :calls: `GET /repos/{owner}/{repo}/branches/{branch}/protection/required_pull_request_reviews `_ :rtype: :class:`github.RequiredPullRequestReviews.RequiredPullRequestReviews` """ headers, data = self._requester.requestJsonAndCheck( "GET", f"{self.protection_url}/required_pull_request_reviews", headers={"Accept": Consts.mediaTypeRequireMultipleApprovingReviews}, ) return github.RequiredPullRequestReviews.RequiredPullRequestReviews( self._requester, headers, data, completed=True ) def edit_required_pull_request_reviews( self, dismissal_users=github.GithubObject.NotSet, dismissal_teams=github.GithubObject.NotSet, dismiss_stale_reviews=github.GithubObject.NotSet, require_code_owner_reviews=github.GithubObject.NotSet, required_approving_review_count=github.GithubObject.NotSet, ): """ :calls: `PATCH /repos/{owner}/{repo}/branches/{branch}/protection/required_pull_request_reviews `_ :dismissal_users: list of strings :dismissal_teams: list of strings :dismiss_stale_reviews: bool :require_code_owner_reviews: bool :required_approving_review_count: int """ assert dismissal_users is github.GithubObject.NotSet or all( isinstance(element, str) for element in dismissal_users ), dismissal_users assert dismissal_teams is github.GithubObject.NotSet or all( isinstance(element, str) for element in dismissal_teams ), dismissal_teams assert dismiss_stale_reviews is github.GithubObject.NotSet or isinstance( dismiss_stale_reviews, bool ), dismiss_stale_reviews assert require_code_owner_reviews is github.GithubObject.NotSet or isinstance( require_code_owner_reviews, bool ), require_code_owner_reviews assert ( required_approving_review_count is github.GithubObject.NotSet or isinstance(required_approving_review_count, int) ), (required_approving_review_count) post_parameters = {} if dismissal_users is not github.GithubObject.NotSet: post_parameters["dismissal_restrictions"] = {"users": dismissal_users} if dismissal_teams is not github.GithubObject.NotSet: if "dismissal_restrictions" not in post_parameters: post_parameters["dismissal_restrictions"] = {} post_parameters["dismissal_restrictions"]["teams"] = dismissal_teams if dismiss_stale_reviews is not github.GithubObject.NotSet: post_parameters["dismiss_stale_reviews"] = dismiss_stale_reviews if require_code_owner_reviews is not github.GithubObject.NotSet: post_parameters["require_code_owner_reviews"] = require_code_owner_reviews if required_approving_review_count is not github.GithubObject.NotSet: post_parameters[ "required_approving_review_count" ] = required_approving_review_count headers, data = self._requester.requestJsonAndCheck( "PATCH", f"{self.protection_url}/required_pull_request_reviews", headers={"Accept": Consts.mediaTypeRequireMultipleApprovingReviews}, input=post_parameters, ) def remove_required_pull_request_reviews(self): """ :calls: `DELETE /repos/{owner}/{repo}/branches/{branch}/protection/required_pull_request_reviews `_ """ headers, data = self._requester.requestJsonAndCheck( "DELETE", f"{self.protection_url}/required_pull_request_reviews", ) def get_admin_enforcement(self): """ :calls: `GET /repos/{owner}/{repo}/branches/{branch}/protection/enforce_admins `_ :rtype: bool """ headers, data = self._requester.requestJsonAndCheck( "GET", f"{self.protection_url}/enforce_admins" ) return data["enabled"] def set_admin_enforcement(self): """ :calls: `POST /repos/{owner}/{repo}/branches/{branch}/protection/enforce_admins `_ """ headers, data = self._requester.requestJsonAndCheck( "POST", f"{self.protection_url}/enforce_admins" ) def remove_admin_enforcement(self): """ :calls: `DELETE /repos/{owner}/{repo}/branches/{branch}/protection/enforce_admins `_ """ headers, data = self._requester.requestJsonAndCheck( "DELETE", f"{self.protection_url}/enforce_admins" ) def get_user_push_restrictions(self): """ :calls: `GET /repos/{owner}/{repo}/branches/{branch}/protection/restrictions/users `_ :rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.NamedUser.NamedUser` """ return github.PaginatedList.PaginatedList( github.NamedUser.NamedUser, self._requester, f"{self.protection_url}/restrictions/users", None, ) def get_team_push_restrictions(self): """ :calls: `GET /repos/{owner}/{repo}/branches/{branch}/protection/restrictions/teams `_ :rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.Team.Team` """ return github.PaginatedList.PaginatedList( github.Team.Team, self._requester, f"{self.protection_url}/restrictions/teams", None, ) def add_user_push_restrictions(self, *users): """ :calls: `POST /repos/{owner}/{repo}/branches/{branch}/protection/restrictions/users `_ :users: list of strings (user names) """ assert all(isinstance(element, str) for element in users), users headers, data = self._requester.requestJsonAndCheck( "POST", f"{self.protection_url}/restrictions/users", input=users ) def replace_user_push_restrictions(self, *users): """ :calls: `PUT /repos/{owner}/{repo}/branches/{branch}/protection/restrictions/users `_ :users: list of strings (user names) """ assert all(isinstance(element, str) for element in users), users headers, data = self._requester.requestJsonAndCheck( "PUT", f"{self.protection_url}/restrictions/users", input=users ) def remove_user_push_restrictions(self, *users): """ :calls: `DELETE /repos/{owner}/{repo}/branches/{branch}/protection/restrictions/users `_ :users: list of strings (user names) """ assert all(isinstance(element, str) for element in users), users headers, data = self._requester.requestJsonAndCheck( "DELETE", f"{self.protection_url}/restrictions/users", input=users ) def add_team_push_restrictions(self, *teams): """ :calls: `POST /repos/{owner}/{repo}/branches/{branch}/protection/restrictions/teams `_ :teams: list of strings (team slugs) """ assert all(isinstance(element, str) for element in teams), teams headers, data = self._requester.requestJsonAndCheck( "POST", f"{self.protection_url}/restrictions/teams", input=teams ) def replace_team_push_restrictions(self, *teams): """ :calls: `PUT /repos/{owner}/{repo}/branches/{branch}/protection/restrictions/teams `_ :teams: list of strings (team slugs) """ assert all(isinstance(element, str) for element in teams), teams headers, data = self._requester.requestJsonAndCheck( "PUT", f"{self.protection_url}/restrictions/teams", input=teams ) def remove_team_push_restrictions(self, *teams): """ :calls: `DELETE /repos/{owner}/{repo}/branches/{branch}/protection/restrictions/teams `_ :teams: list of strings (team slugs) """ assert all(isinstance(element, str) for element in teams), teams headers, data = self._requester.requestJsonAndCheck( "DELETE", f"{self.protection_url}/restrictions/teams", input=teams ) def remove_push_restrictions(self): """ :calls: `DELETE /repos/{owner}/{repo}/branches/{branch}/protection/restrictions `_ """ headers, data = self._requester.requestJsonAndCheck( "DELETE", f"{self.protection_url}/restrictions" ) def get_required_signatures(self): """ :calls: `GET /repos/{owner}/{repo}/branches/{branch}/protection/required_signatures ` """ headers, data = self._requester.requestJsonAndCheck( "GET", f"{self.protection_url}/required_signatures", headers={"Accept": Consts.signaturesProtectedBranchesPreview}, ) return data["enabled"] def add_required_signatures(self): """ :calls: `POST /repos/{owner}/{repo}/branches/{branch}/protection/required_signatures ` """ headers, data = self._requester.requestJsonAndCheck( "POST", f"{self.protection_url}/required_signatures", headers={"Accept": Consts.signaturesProtectedBranchesPreview}, ) def remove_required_signatures(self): """ :calls: `DELETE /repos/{owner}/{repo}/branches/{branch}/protection/required_signatures ` """ headers, data = self._requester.requestJsonAndCheck( "DELETE", f"{self.protection_url}/required_signatures", headers={"Accept": Consts.signaturesProtectedBranchesPreview}, ) ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1619412308.0 PyGithub-1.55/github/Branch.pyi0000644000175100001710000000604700000000000015750 0ustar00runnerdockerfrom typing import Any, Dict, List, Union from github.BranchProtection import BranchProtection from github.Commit import Commit from github.GithubObject import NonCompletableGithubObject, _NotSetType from github.NamedUser import NamedUser from github.PaginatedList import PaginatedList from github.RequiredPullRequestReviews import RequiredPullRequestReviews from github.RequiredStatusChecks import RequiredStatusChecks from github.Team import Team class Branch(NonCompletableGithubObject): def __repr__(self) -> str: ... def _initAttributes(self) -> None: ... def _useAttributes(self, attributes: Dict[str, Any]) -> None: ... def add_required_signatures(self) -> None: ... @property def commit(self) -> Commit: ... def edit_protection( self, strict: Union[bool, _NotSetType] = ..., contexts: Union[List[str], _NotSetType] = ..., enforce_admins: Union[bool, _NotSetType] = ..., dismissal_users: Union[_NotSetType, List[str]] = ..., dismissal_teams: Union[_NotSetType, List[str]] = ..., dismiss_stale_reviews: Union[bool, _NotSetType] = ..., require_code_owner_reviews: Union[bool, _NotSetType] = ..., required_approving_review_count: Union[int, _NotSetType] = ..., user_push_restrictions: Union[_NotSetType, List[str]] = ..., team_push_restrictions: Union[_NotSetType, List[str]] = ..., ) -> None: ... def edit_required_pull_request_reviews( self, dismissal_users: Union[_NotSetType, List[str]] = ..., dismissal_teams: Union[_NotSetType, List[str]] = ..., dismiss_stale_reviews: Union[bool, _NotSetType] = ..., require_code_owner_reviews: Union[_NotSetType, bool] = ..., required_approving_review_count: Union[int, _NotSetType] = ..., ) -> None: ... def edit_required_status_checks( self, strict: Union[_NotSetType, bool] = ..., contexts: Union[List[str], _NotSetType] = ..., ) -> None: ... def edit_team_push_restrictions(self, *teams: str) -> None: ... def edit_user_push_restrictions(self, *users: str) -> None: ... def get_admin_enforcement(self) -> bool: ... def get_protection(self) -> BranchProtection: ... def get_required_pull_request_reviews(self) -> RequiredPullRequestReviews: ... def get_required_signatures(self) -> bool: ... def get_required_status_checks(self) -> RequiredStatusChecks: ... def get_team_push_restrictions(self) -> PaginatedList[Team]: ... def get_user_push_restrictions(self) -> PaginatedList[NamedUser]: ... @property def name(self) -> str: ... @property def protected(self) -> bool: ... @property def protection_url(self) -> str: ... def remove_admin_enforcement(self) -> None: ... def remove_protection(self) -> None: ... def remove_push_restrictions(self) -> None: ... def remove_required_pull_request_reviews(self) -> None: ... def remove_required_signatures(self) -> None: ... def remove_required_status_checks(self) -> None: ... def set_admin_enforcement(self) -> None: ... ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1619412308.0 PyGithub-1.55/github/BranchProtection.py0000644000175100001710000001254300000000000017644 0ustar00runnerdocker############################ Copyrights and license ############################ # # # Copyright 2018 Steve Kowalik # # # # This file is part of PyGithub. # # http://pygithub.readthedocs.io/ # # # # PyGithub is free software: you can redistribute it and/or modify it under # # the terms of the GNU Lesser General Public License as published by the Free # # Software Foundation, either version 3 of the License, or (at your option) # # any later version. # # # # PyGithub is distributed in the hope that it will be useful, but WITHOUT ANY # # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more # # details. # # # # You should have received a copy of the GNU Lesser General Public License # # along with PyGithub. If not, see . # # # ################################################################################ import github.GithubObject import github.NamedUser import github.RequiredPullRequestReviews import github.RequiredStatusChecks import github.Team class BranchProtection(github.GithubObject.CompletableGithubObject): """ This class represents Branch Protection. The reference can be found here https://docs.github.com/en/rest/reference/repos#get-branch-protection """ def __repr__(self): return self.get__repr__({"url": self._url.value}) @property def url(self): """ :type: string """ self._completeIfNotSet(self._url) return self._url.value @property def required_status_checks(self): """ :type: :class:`github.RequiredStatusChecks.RequiredStatusChecks` """ self._completeIfNotSet(self._required_status_checks) return self._required_status_checks.value @property def enforce_admins(self): """ :type: bool """ self._completeIfNotSet(self._enforce_admins) return self._enforce_admins.value @property def required_pull_request_reviews(self): """ :type: :class:`github.RequiredPullRequestReviews.RequiredPullRequestReviews` """ self._completeIfNotSet(self._required_pull_request_reviews) return self._required_pull_request_reviews.value def get_user_push_restrictions(self): """ :rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.NamedUser.NamedUser` """ if self._user_push_restrictions is github.GithubObject.NotSet: return None return github.PaginatedList.PaginatedList( github.NamedUser.NamedUser, self._requester, self._user_push_restrictions, None, ) def get_team_push_restrictions(self): """ :rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.Team.Team` """ if self._team_push_restrictions is github.GithubObject.NotSet: return None return github.PaginatedList.PaginatedList( github.Team.Team, self._requester, self._team_push_restrictions, None ) def _initAttributes(self): self._url = github.GithubObject.NotSet self._required_status_checks = github.GithubObject.NotSet self._enforce_admins = github.GithubObject.NotSet self._required_pull_request_reviews = github.GithubObject.NotSet self._user_push_restrictions = github.GithubObject.NotSet self._team_push_restrictions = github.GithubObject.NotSet def _useAttributes(self, attributes): if "url" in attributes: # pragma no branch self._url = self._makeStringAttribute(attributes["url"]) if "required_status_checks" in attributes: # pragma no branch self._required_status_checks = self._makeClassAttribute( github.RequiredStatusChecks.RequiredStatusChecks, attributes["required_status_checks"], ) if "enforce_admins" in attributes: # pragma no branch self._enforce_admins = self._makeBoolAttribute( attributes["enforce_admins"]["enabled"] ) if "required_pull_request_reviews" in attributes: # pragma no branch self._required_pull_request_reviews = self._makeClassAttribute( github.RequiredPullRequestReviews.RequiredPullRequestReviews, attributes["required_pull_request_reviews"], ) if "restrictions" in attributes: # pragma no branch self._user_push_restrictions = attributes["restrictions"]["users_url"] self._team_push_restrictions = attributes["restrictions"]["teams_url"] ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1619412308.0 PyGithub-1.55/github/BranchProtection.pyi0000644000175100001710000000166500000000000020020 0ustar00runnerdockerfrom typing import Any, Dict from github.GithubObject import CompletableGithubObject from github.NamedUser import NamedUser from github.PaginatedList import PaginatedList from github.RequiredPullRequestReviews import RequiredPullRequestReviews from github.RequiredStatusChecks import RequiredStatusChecks from github.Team import Team class BranchProtection(CompletableGithubObject): def __repr__(self) -> str: ... def _initAttributes(self) -> None: ... def _useAttributes(self, attributes: Dict[str, Any]) -> None: ... @property def enforce_admins(self) -> bool: ... def get_team_push_restrictions(self) -> PaginatedList[NamedUser]: ... def get_user_push_restrictions(self) -> PaginatedList[Team]: ... @property def required_pull_request_reviews(self) -> RequiredPullRequestReviews: ... @property def required_status_checks(self) -> RequiredStatusChecks: ... @property def url(self) -> str: ... ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1619412308.0 PyGithub-1.55/github/CheckRun.py0000644000175100001710000003064400000000000016104 0ustar00runnerdocker############################ Copyrights and license ############################ # # # Copyright 2020 Dhruv Manilawala # # # # This file is part of PyGithub. # # http://pygithub.readthedocs.io/ # # # # PyGithub is free software: you can redistribute it and/or modify it under # # the terms of the GNU Lesser General Public License as published by the Free # # Software Foundation, either version 3 of the License, or (at your option) # # any later version. # # # # PyGithub is distributed in the hope that it will be useful, but WITHOUT ANY # # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more # # details. # # # # You should have received a copy of the GNU Lesser General Public License # # along with PyGithub. If not, see . # # # ################################################################################ import datetime import github.CheckRunAnnotation import github.CheckRunOutput import github.GithubApp import github.GithubObject import github.PaginatedList import github.PullRequest class CheckRun(github.GithubObject.CompletableGithubObject): """ This class represents check runs. The reference can be found here https://docs.github.com/en/rest/reference/checks#check-runs """ def __repr__(self): return self.get__repr__( {"id": self._id.value, "conclusion": self._conclusion.value} ) @property def app(self): """ :type: :class:`github.GithubApp.GithubApp` """ self._completeIfNotSet(self._app) return self._app.value @property def check_suite_id(self): """ :type: integer """ self._completeIfNotSet(self._check_suite_id) return self._check_suite_id.value @property def completed_at(self): """ :type: datetime.datetime """ self._completeIfNotSet(self._completed_at) return self._completed_at.value @property def conclusion(self): """ :type: string """ self._completeIfNotSet(self._conclusion) return self._conclusion.value @property def details_url(self): """ :type: string """ self._completeIfNotSet(self._details_url) return self._details_url.value @property def external_id(self): """ :type: string """ self._completeIfNotSet(self._external_id) return self._external_id.value @property def head_sha(self): """ :type: string """ self._completeIfNotSet(self._head_sha) return self._head_sha.value @property def html_url(self): """ :type: string """ self._completeIfNotSet(self._html_url) return self._html_url.value @property def id(self): """ :type: integer """ self._completeIfNotSet(self._id) return self._id.value @property def name(self): """ :type: string """ self._completeIfNotSet(self._name) return self._name.value @property def node_id(self): """ :type: string """ self._completeIfNotSet(self._node_id) return self._node_id.value @property def output(self): """ :type: :class:`github.CheckRunOutput.CheckRunOutput` """ self._completeIfNotSet(self._output) return self._output.value @property def pull_requests(self): """ :type: list of :class:`github.PullRequest.PullRequest` """ self._completeIfNotSet(self._pull_requests) return self._pull_requests.value @property def started_at(self): """ :type: datetime.datetime """ self._completeIfNotSet(self._started_at) return self._started_at.value @property def status(self): """ :type: string """ self._completeIfNotSet(self._status) return self._status.value @property def url(self): """ :type: string """ self._completeIfNotSet(self._url) return self._url.value def get_annotations(self): """ :calls: `GET /repos/{owner}/{repo}/check-runs/{check_run_id}/annotations `_ :rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.CheckRunAnnotation.CheckRunAnnotation` """ return github.PaginatedList.PaginatedList( github.CheckRunAnnotation.CheckRunAnnotation, self._requester, f"{self.url}/annotations", None, headers={"Accept": "application/vnd.github.v3+json"}, ) def edit( self, name=github.GithubObject.NotSet, head_sha=github.GithubObject.NotSet, details_url=github.GithubObject.NotSet, external_id=github.GithubObject.NotSet, status=github.GithubObject.NotSet, started_at=github.GithubObject.NotSet, conclusion=github.GithubObject.NotSet, completed_at=github.GithubObject.NotSet, output=github.GithubObject.NotSet, actions=github.GithubObject.NotSet, ): """ :calls: `PATCH /repos/{owner}/{repo}/check-runs/{check_run_id} `_ :param name: string :param head_sha: string :param details_url: string :param external_id: string :param status: string :param started_at: datetime.datetime :param conclusion: string :param completed_at: datetime.datetime :param output: dict :param actions: list of dict :rtype: None """ assert name is github.GithubObject.NotSet or isinstance(name, str), name assert head_sha is github.GithubObject.NotSet or isinstance( head_sha, str ), head_sha assert details_url is github.GithubObject.NotSet or isinstance( details_url, str ), details_url assert external_id is github.GithubObject.NotSet or isinstance( external_id, str ), external_id assert status is github.GithubObject.NotSet or isinstance(status, str), status assert started_at is github.GithubObject.NotSet or isinstance( started_at, datetime.datetime ), started_at assert conclusion is github.GithubObject.NotSet or isinstance( conclusion, str ), conclusion assert completed_at is github.GithubObject.NotSet or isinstance( completed_at, datetime.datetime ), completed_at assert output is github.GithubObject.NotSet or isinstance(output, dict), output assert actions is github.GithubObject.NotSet or all( isinstance(element, dict) for element in actions ), actions post_parameters = dict() if name is not github.GithubObject.NotSet: post_parameters["name"] = name if head_sha is not github.GithubObject.NotSet: post_parameters["head_sha"] = head_sha if details_url is not github.GithubObject.NotSet: post_parameters["details_url"] = details_url if external_id is not github.GithubObject.NotSet: post_parameters["external_id"] = external_id if status is not github.GithubObject.NotSet: post_parameters["status"] = status if started_at is not github.GithubObject.NotSet: post_parameters["started_at"] = started_at.strftime("%Y-%m-%dT%H:%M:%SZ") if completed_at is not github.GithubObject.NotSet: post_parameters["completed_at"] = completed_at.strftime( "%Y-%m-%dT%H:%M:%SZ" ) if conclusion is not github.GithubObject.NotSet: post_parameters["conclusion"] = conclusion if output is not github.GithubObject.NotSet: post_parameters["output"] = output if actions is not github.GithubObject.NotSet: post_parameters["actions"] = actions headers, data = self._requester.requestJsonAndCheck( "PATCH", self.url, input=post_parameters ) self._useAttributes(data) def _initAttributes(self): self._app = github.GithubObject.NotSet self._check_suite_id = github.GithubObject.NotSet self._completed_at = github.GithubObject.NotSet self._conclusion = github.GithubObject.NotSet self._details_url = github.GithubObject.NotSet self._external_id = github.GithubObject.NotSet self._head_sha = github.GithubObject.NotSet self._html_url = github.GithubObject.NotSet self._id = github.GithubObject.NotSet self._name = github.GithubObject.NotSet self._node_id = github.GithubObject.NotSet self._output = github.GithubObject.NotSet self._output = github.GithubObject.NotSet self._pull_requests = github.GithubObject.NotSet self._started_at = github.GithubObject.NotSet self._status = github.GithubObject.NotSet self._url = github.GithubObject.NotSet def _useAttributes(self, attributes): if "app" in attributes: # pragma no branch self._app = self._makeClassAttribute( github.GithubApp.GithubApp, attributes["app"] ) # This only gives us a dictionary with `id` attribute of `check_suite` if ( "check_suite" in attributes and "id" in attributes["check_suite"] ): # pragma no branch self._check_suite_id = self._makeIntAttribute( attributes["check_suite"]["id"] ) if "completed_at" in attributes: # pragma no branch self._completed_at = self._makeDatetimeAttribute(attributes["completed_at"]) if "conclusion" in attributes: # pragma no branch self._conclusion = self._makeStringAttribute(attributes["conclusion"]) if "details_url" in attributes: # pragma no branch self._details_url = self._makeStringAttribute(attributes["details_url"]) if "external_id" in attributes: # pragma no branch self._external_id = self._makeStringAttribute(attributes["external_id"]) if "head_sha" in attributes: # pragma no branch self._head_sha = self._makeStringAttribute(attributes["head_sha"]) if "html_url" in attributes: # pragma no branch self._html_url = self._makeStringAttribute(attributes["html_url"]) if "id" in attributes: # pragma no branch self._id = self._makeIntAttribute(attributes["id"]) if "name" in attributes: # pragma no branch self._name = self._makeStringAttribute(attributes["name"]) if "node_id" in attributes: # pragma no branch self._node_id = self._makeStringAttribute(attributes["node_id"]) if "output" in attributes: # pragma no branch self._output = self._makeClassAttribute( github.CheckRunOutput.CheckRunOutput, attributes["output"] ) if "pull_requests" in attributes: # pragma no branch self._pull_requests = self._makeListOfClassesAttribute( github.PullRequest.PullRequest, attributes["pull_requests"] ) if "started_at" in attributes: # pragma no branch self._started_at = self._makeDatetimeAttribute(attributes["started_at"]) if "status" in attributes: # pragma no branch self._status = self._makeStringAttribute(attributes["status"]) if "url" in attributes: # pragma no branch self._url = self._makeStringAttribute(attributes["url"]) ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1619412308.0 PyGithub-1.55/github/CheckRun.pyi0000644000175100001710000000407300000000000016252 0ustar00runnerdockerfrom datetime import datetime from typing import Any, Dict, List, Union from github.CheckRunAnnotation import CheckRunAnnotation from github.CheckRunOutput import CheckRunOutput from github.GithubApp import GithubApp from github.GithubObject import CompletableGithubObject, _NotSetType from github.PaginatedList import PaginatedList from github.PullRequest import PullRequest class CheckRun(CompletableGithubObject): def __repr__(self) -> str: ... def _initAttributes(self) -> None: ... def _useAttributes(self, attributes: Dict[str, Any]) -> None: ... def get_annotations(self) -> PaginatedList[CheckRunAnnotation]: ... def edit( self, name: Union[_NotSetType, str] = ..., head_sha: Union[_NotSetType, str] = ..., details_url: Union[_NotSetType, str] = ..., external_id: Union[_NotSetType, str] = ..., status: Union[_NotSetType, str] = ..., started_at: Union[_NotSetType, datetime] = ..., conclusion: Union[_NotSetType, str] = ..., completed_at: Union[_NotSetType, datetime] = ..., output: Union[ _NotSetType, Dict[str, Union[str, List[Dict[str, Union[str, int]]]]] ] = ..., actions: Union[_NotSetType, List[Dict[str, str]]] = ..., ) -> None: ... @property def app(self) -> GithubApp: ... @property def check_suite_id(self) -> int: ... @property def completed_at(self) -> datetime: ... @property def conclusion(self) -> str: ... @property def details_url(self) -> str: ... @property def external_id(self) -> str: ... @property def head_sha(self) -> str: ... @property def html_url(self) -> str: ... @property def id(self) -> int: ... @property def name(self) -> str: ... @property def node_id(self) -> str: ... @property def output(self) -> CheckRunOutput: ... @property def pull_requests(self) -> List[PullRequest]: ... @property def started_at(self) -> datetime: ... @property def status(self) -> str: ... @property def url(self) -> str: ... ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1619412308.0 PyGithub-1.55/github/CheckRunAnnotation.py0000644000175100001710000001162600000000000020136 0ustar00runnerdocker############################ Copyrights and license ############################ # # # Copyright 2020 Dhruv Manilawala # # # # This file is part of PyGithub. # # http://pygithub.readthedocs.io/ # # # # PyGithub is free software: you can redistribute it and/or modify it under # # the terms of the GNU Lesser General Public License as published by the Free # # Software Foundation, either version 3 of the License, or (at your option) # # any later version. # # # # PyGithub is distributed in the hope that it will be useful, but WITHOUT ANY # # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more # # details. # # # # You should have received a copy of the GNU Lesser General Public License # # along with PyGithub. If not, see . # # # ################################################################################ import github.GithubObject class CheckRunAnnotation(github.GithubObject.NonCompletableGithubObject): """ This class represents check run annotations. The reference can be found here: https://docs.github.com/en/rest/reference/checks#list-check-run-annotations """ def __repr__(self): return self.get__repr__({"title": self._title.value}) @property def annotation_level(self): """ :type: string """ return self._annotation_level.value @property def end_column(self): """ :type: integer """ return self._end_column.value @property def end_line(self): """ :type: integer """ return self._end_line.value @property def message(self): """ :type: string """ return self._message.value @property def path(self): """ :type: string """ return self._path.value @property def raw_details(self): """ :type: string """ return self._raw_details.value @property def start_column(self): """ :type: integer """ return self._start_column.value @property def start_line(self): """ :type: integer """ return self._start_line.value @property def title(self): """ :type: string """ return self._title.value def _initAttributes(self): self._annotation_level = github.GithubObject.NotSet self._end_column = github.GithubObject.NotSet self._end_line = github.GithubObject.NotSet self._message = github.GithubObject.NotSet self._path = github.GithubObject.NotSet self._raw_details = github.GithubObject.NotSet self._start_column = github.GithubObject.NotSet self._start_line = github.GithubObject.NotSet self._title = github.GithubObject.NotSet def _useAttributes(self, attributes): if "annotation_level" in attributes: # pragma no branch self._annotation_level = self._makeStringAttribute( attributes["annotation_level"] ) if "end_column" in attributes: # pragma no branch self._end_column = self._makeIntAttribute(attributes["end_column"]) if "end_line" in attributes: # pragma no branch self._end_line = self._makeIntAttribute(attributes["end_line"]) if "message" in attributes: # pragma no branch self._message = self._makeStringAttribute(attributes["message"]) if "path" in attributes: # pragma no branch self._path = self._makeStringAttribute(attributes["path"]) if "raw_details" in attributes: # pragma no branch self._raw_details = self._makeStringAttribute(attributes["raw_details"]) if "start_column" in attributes: # pragma no branch self._start_column = self._makeIntAttribute(attributes["start_column"]) if "start_line" in attributes: # pragma no branch self._start_line = self._makeIntAttribute(attributes["start_line"]) if "title" in attributes: # pragma no branch self._title = self._makeStringAttribute(attributes["title"]) ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1619412308.0 PyGithub-1.55/github/CheckRunAnnotation.pyi0000644000175100001710000000135000000000000020300 0ustar00runnerdockerfrom typing import Any, Dict from github.GithubObject import NonCompletableGithubObject class CheckRunAnnotation(NonCompletableGithubObject): def __repr__(self) -> str: ... def _initAttributes(self) -> None: ... def _useAttributes(self, attributes: Dict[str, Any]) -> None: ... @property def annotation_level(self) -> str: ... @property def end_column(self) -> int: ... @property def end_line(self) -> int: ... @property def message(self) -> str: ... @property def path(self) -> str: ... @property def raw_details(self) -> str: ... @property def start_column(self) -> int: ... @property def start_line(self) -> int: ... @property def title(self) -> str: ... ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1619412308.0 PyGithub-1.55/github/CheckRunOutput.py0000644000175100001710000000712700000000000017325 0ustar00runnerdocker############################ Copyrights and license ############################ # # # Copyright 2020 Dhruv Manilawala # # # # This file is part of PyGithub. # # http://pygithub.readthedocs.io/ # # # # PyGithub is free software: you can redistribute it and/or modify it under # # the terms of the GNU Lesser General Public License as published by the Free # # Software Foundation, either version 3 of the License, or (at your option) # # any later version. # # # # PyGithub is distributed in the hope that it will be useful, but WITHOUT ANY # # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more # # details. # # # # You should have received a copy of the GNU Lesser General Public License # # along with PyGithub. If not, see . # # # ################################################################################ import github.GithubObject class CheckRunOutput(github.GithubObject.NonCompletableGithubObject): """This class represents the output of check run.""" def __repr__(self): return self.get__repr__({"title": self._title.value}) @property def annotations_count(self): """ :type: integer """ return self._annotations_count.value @property def annotations_url(self): """ :type: string """ return self._annotations_url.value @property def summary(self): """ :type: string """ return self._summary.value @property def text(self): """ :type: string """ return self._text.value @property def title(self): """ :type: string """ return self._title.value def _initAttributes(self): self._annotations_count = github.GithubObject.NotSet self._annotations_url = github.GithubObject.NotSet self._summary = github.GithubObject.NotSet self._text = github.GithubObject.NotSet self._title = github.GithubObject.NotSet def _useAttributes(self, attributes): if "annotations_count" in attributes: # pragma no branch self._annotations_count = self._makeIntAttribute( attributes["annotations_count"] ) if "annotations_url" in attributes: # pragma no branch self._annotations_url = self._makeStringAttribute( attributes["annotations_url"] ) if "summary" in attributes: # pragma no branch self._summary = self._makeStringAttribute(attributes["summary"]) if "text" in attributes: # pragma no branch self._text = self._makeStringAttribute(attributes["text"]) if "title" in attributes: # pragma no branch self._title = self._makeStringAttribute(attributes["title"]) ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1619412308.0 PyGithub-1.55/github/CheckRunOutput.pyi0000644000175100001710000000103500000000000017466 0ustar00runnerdockerfrom typing import Any, Dict from github.GithubObject import NonCompletableGithubObject class CheckRunOutput(NonCompletableGithubObject): def __repr__(self) -> str: ... def _initAttributes(self) -> None: ... def _useAttributes(self, attributes: Dict[str, Any]) -> None: ... @property def annotations_count(self) -> int: ... @property def annotations_url(self) -> str: ... @property def summary(self) -> str: ... @property def text(self) -> str: ... @property def title(self) -> str: ... ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1619412308.0 PyGithub-1.55/github/CheckSuite.py0000644000175100001710000002454100000000000016430 0ustar00runnerdocker############################ Copyrights and license ############################ # # # Copyright 2020 Raju Subramanian # # # # This file is part of PyGithub. # # http://pygithub.readthedocs.io/ # # # # PyGithub is free software: you can redistribute it and/or modify it under # # the terms of the GNU Lesser General Public License as published by the Free # # Software Foundation, either version 3 of the License, or (at your option) # # any later version. # # # # PyGithub is distributed in the hope that it will be useful, but WITHOUT ANY # # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more # # details. # # # # You should have received a copy of the GNU Lesser General Public License # # along with PyGithub. If not, see . # # # ################################################################################ import github class CheckSuite(github.GithubObject.CompletableGithubObject): """ This class represents check suites. The reference can be found here https://docs.github.com/en/rest/reference/checks#check-suites """ def __repr__(self): return self.get__repr__({"id": self._id.value, "url": self._url.value}) @property def after(self): """ :type: string """ self._completeIfNotSet(self._after) return self._after.value @property def app(self): """ :type: :class:`github.GithubApp.GithubApp` """ self._completeIfNotSet(self._app) return self._app.value @property def before(self): """ :type: string """ self._completeIfNotSet(self._before) return self._before.value @property def check_runs_url(self): """ :type: string """ self._completeIfNotSet(self._check_runs_url) return self._check_runs_url.value @property def conclusion(self): """ :type: string """ self._completeIfNotSet(self._conclusion) return self._conclusion.value @property def created_at(self): """ :type: datetime.datetime """ self._completeIfNotSet(self._created_at) return self._created_at.value @property def head_branch(self): """ :type: string """ self._completeIfNotSet(self._head_branch) return self._head_branch.value @property def head_commit(self): """ :type: :class:`github.GitCommit.GitCommit` """ self._completeIfNotSet(self._head_commit) return self._head_commit.value @property def head_sha(self): """ :type: string """ self._completeIfNotSet(self._head_sha) return self._head_sha.value @property def id(self): """ :type: int """ self._completeIfNotSet(self._id) return self._id.value @property def latest_check_runs_count(self): """ :type: int """ self._completeIfNotSet(self._latest_check_runs_count) return self._latest_check_runs_count.value @property def pull_requests(self): """ :type: list of :class:`github.PullRequest.PullRequest` """ self._completeIfNotSet(self._pull_requests) return self._pull_requests.value @property def repository(self): """ :type: :class:`github.Repository.Repository` """ self._completeIfNotSet(self._repository) return self._repository.value @property def status(self): """ :type: string """ self._completeIfNotSet(self._status) return self._status.value @property def updated_at(self): """ :type: datetime.datetime """ self._completeIfNotSet(self._updated_at) return self._updated_at.value @property def url(self): """ :type: string """ self._completeIfNotSet(self._url) return self._url.value def rerequest(self): """ :calls: `POST /repos/{owner}/{repo}/check-suites/{check_suite_id}/rerequest `_ :rtype: bool """ request_headers = {"Accept": "application/vnd.github.v3+json"} status, _, _ = self._requester.requestJson( "POST", f"{self.url}/rerequest", headers=request_headers ) return status == 201 def get_check_runs( self, check_name=github.GithubObject.NotSet, status=github.GithubObject.NotSet, filter=github.GithubObject.NotSet, ): """ :calls: `GET /repos/{owner}/{repo}/check-suites/{check_suite_id}/check-runs `_ :param check_name: string :param status: string :param filter: string :rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.CheckRun.CheckRun` """ assert check_name is github.GithubObject.NotSet or isinstance( check_name, str ), check_name assert status is github.GithubObject.NotSet or isinstance(status, str), status assert filter is github.GithubObject.NotSet or isinstance(filter, str), filter url_parameters = dict() if check_name is not github.GithubObject.NotSet: url_parameters["check_name"] = check_name if status is not github.GithubObject.NotSet: url_parameters["status"] = status if filter is not github.GithubObject.NotSet: url_parameters["filter"] = filter return github.PaginatedList.PaginatedList( github.CheckRun.CheckRun, self._requester, f"{self.url}/check-runs", url_parameters, headers={"Accept": "application/vnd.github.v3+json"}, list_item="check_runs", ) def _initAttributes(self): self._after = github.GithubObject.NotSet self._app = github.GithubObject.NotSet self._before = github.GithubObject.NotSet self._check_runs_url = github.GithubObject.NotSet self._conclusion = github.GithubObject.NotSet self._created_at = github.GithubObject.NotSet self._head_branch = github.GithubObject.NotSet self._head_commit = github.GithubObject.NotSet self._head_sha = github.GithubObject.NotSet self._id = github.GithubObject.NotSet self._latest_check_runs_count = github.GithubObject.NotSet self._pull_requests = github.GithubObject.NotSet self._repository = github.GithubObject.NotSet self._status = github.GithubObject.NotSet self._updated_at = github.GithubObject.NotSet self._url = github.GithubObject.NotSet def _useAttributes(self, attributes): if "after" in attributes: # pragma no branch self._after = self._makeStringAttribute(attributes["after"]) if "app" in attributes: # pragma no branch self._app = self._makeClassAttribute( github.GithubApp.GithubApp, attributes["app"] ) if "before" in attributes: # pragma no branch self._before = self._makeStringAttribute(attributes["before"]) if "check_runs_url" in attributes: # pragma no branch self._check_runs_url = self._makeStringAttribute( attributes["check_runs_url"] ) if "conclusion" in attributes: # pragma no branch self._conclusion = self._makeStringAttribute(attributes["conclusion"]) if "created_at" in attributes: # pragma no branch self._created_at = self._makeDatetimeAttribute(attributes["created_at"]) if "head_branch" in attributes: # pragma no branch self._head_branch = self._makeStringAttribute(attributes["head_branch"]) if "head_commit" in attributes: # pragma no branch # This JSON swaps the 'sha' attribute for an 'id' attribute. # The GitCommit object only looks for 'sha' if "id" in attributes["head_commit"]: attributes["head_commit"]["sha"] = attributes["head_commit"]["id"] self._head_commit = self._makeClassAttribute( github.GitCommit.GitCommit, attributes["head_commit"] ) if "head_sha" in attributes: # pragma no branch self._head_sha = self._makeStringAttribute(attributes["head_sha"]) if "id" in attributes: # pragma no branch self._id = self._makeIntAttribute(attributes["id"]) if "latest_check_runs_count" in attributes: # pragma no branch self._latest_check_runs_count = self._makeIntAttribute( attributes["latest_check_runs_count"] ) if "pull_requests" in attributes: # pragma no branch self._pull_requests = self._makeListOfClassesAttribute( github.PullRequest.PullRequest, attributes["pull_requests"] ) if "repository" in attributes: # pragma no branch self._repository = self._makeClassAttribute( github.Repository.Repository, attributes["repository"] ) if "status" in attributes: # pragma no branch self._status = self._makeStringAttribute(attributes["status"]) if "updated_at" in attributes: # pragma no branch self._updated_at = self._makeDatetimeAttribute(attributes["updated_at"]) if "url" in attributes: # pragma no branch self._url = self._makeStringAttribute(attributes["url"]) ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1619412308.0 PyGithub-1.55/github/CheckSuite.pyi0000644000175100001710000000302700000000000016575 0ustar00runnerdockerfrom datetime import datetime from typing import Any, Dict, List from github.CheckRun import CheckRun from github.GitCommit import GitCommit from github.GithubApp import GithubApp from github.GithubObject import CompletableGithubObject from github.PaginatedList import PaginatedList from github.PullRequest import PullRequest from github.Repository import Repository class CheckSuite(CompletableGithubObject): def __repr__(self) -> str: ... def _initAttributes(self) -> None: ... def _useAttributes(self, attributes: Dict[str, Any]) -> None: ... @property def after(self) -> str: ... @property def app(self) -> GithubApp: ... @property def before(self) -> str: ... @property def check_runs_url(self) -> str: ... @property def conclusion(self) -> str: ... @property def created_at(self) -> datetime: ... @property def head_branch(self) -> str: ... @property def head_commit(self) -> GitCommit: ... @property def head_sha(self) -> str: ... @property def id(self) -> int: ... @property def latest_check_runs_count(self) -> int: ... @property def pull_requests(self) -> List[PullRequest]: ... @property def repository(self) -> Repository: ... @property def status(self) -> str: ... @property def updated_at(self) -> datetime: ... @property def url(self) -> str: ... def rerequest(self) -> bool: ... def get_check_runs( self, check_name: str, status: str, filter: str ) -> PaginatedList[CheckRun]: ... ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1619412308.0 PyGithub-1.55/github/Clones.py0000644000175100001710000000672200000000000015625 0ustar00runnerdocker############################ Copyrights and license ############################ # # # Copyright 2018 Justin Kufro # # Copyright 2018 Ivan Minno # # Copyright 2018 Zilei Gu # # Copyright 2018 Yves Zumbach # # Copyright 2018 Leying Chen # # # # This file is part of PyGithub. # # http://pygithub.readthedocs.io/ # # # # PyGithub is free software: you can redistribute it and/or modify it under # # the terms of the GNU Lesser General Public License as published by the Free # # Software Foundation, either version 3 of the License, or (at your option) # # any later version. # # # # PyGithub is distributed in the hope that it will be useful, but WITHOUT ANY # # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more # # details. # # # # You should have received a copy of the GNU Lesser General Public License # # along with PyGithub. If not, see . # # # ################################################################################ import github.GithubObject class Clones(github.GithubObject.NonCompletableGithubObject): """ This class represents a popular Path for a GitHub repository. The reference can be found here https://docs.github.com/en/rest/reference/repos#get-repository-clones """ def __repr__(self): return self.get__repr__( { "timestamp": self._timestamp.value, "count": self._count.value, "uniques": self._uniques.value, } ) @property def timestamp(self): """ :type: datetime.datetime """ return self._timestamp.value @property def count(self): """ :type: integer """ return self._count.value @property def uniques(self): """ :type: integer """ return self._uniques.value def _initAttributes(self): self._timestamp = github.GithubObject.NotSet self._count = github.GithubObject.NotSet self._uniques = github.GithubObject.NotSet def _useAttributes(self, attributes): if "timestamp" in attributes: # pragma no branch self._timestamp = self._makeDatetimeAttribute(attributes["timestamp"]) if "count" in attributes: # pragma no branch self._count = self._makeIntAttribute(attributes["count"]) if "uniques" in attributes: # pragma no branch self._uniques = self._makeIntAttribute(attributes["uniques"]) ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1619412308.0 PyGithub-1.55/github/Clones.pyi0000644000175100001710000000071300000000000015770 0ustar00runnerdockerfrom datetime import datetime from typing import Any, Dict from github.GithubObject import NonCompletableGithubObject class Clones(NonCompletableGithubObject): def __repr__(self) -> str: ... def _initAttributes(self) -> None: ... def _useAttributes(self, attributes: Dict[str, Any]) -> None: ... @property def count(self) -> int: ... @property def timestamp(self) -> datetime: ... @property def uniques(self) -> int: ... ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1619412308.0 PyGithub-1.55/github/Commit.py0000644000175100001710000003531600000000000015633 0ustar00runnerdocker############################ Copyrights and license ############################ # # # Copyright 2012 Vincent Jacques # # Copyright 2012 Zearin # # Copyright 2013 AKFish # # Copyright 2013 Vincent Jacques # # Copyright 2013 martinqt # # Copyright 2014 Andy Casey # # Copyright 2014 Vincent Jacques # # Copyright 2016 Jannis Gebauer # # Copyright 2016 John Eskew # # Copyright 2016 Peter Buckley # # Copyright 2018 sfdye # # # # This file is part of PyGithub. # # http://pygithub.readthedocs.io/ # # # # PyGithub is free software: you can redistribute it and/or modify it under # # the terms of the GNU Lesser General Public License as published by the Free # # Software Foundation, either version 3 of the License, or (at your option) # # any later version. # # # # PyGithub is distributed in the hope that it will be useful, but WITHOUT ANY # # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more # # details. # # # # You should have received a copy of the GNU Lesser General Public License # # along with PyGithub. If not, see . # # # ################################################################################ import github.CheckRun import github.CheckSuite import github.CommitCombinedStatus import github.CommitComment import github.CommitStats import github.CommitStatus import github.File import github.GitCommit import github.GithubObject import github.NamedUser import github.PaginatedList class Commit(github.GithubObject.CompletableGithubObject): """ This class represents Commits. The reference can be found here http://docs.github.com/en/rest/reference/git#commits """ def __repr__(self): return self.get__repr__({"sha": self._sha.value}) @property def author(self): """ :type: :class:`github.NamedUser.NamedUser` """ self._completeIfNotSet(self._author) return self._author.value @property def comments_url(self): """ :type: string """ self._completeIfNotSet(self._comments_url) return self._comments_url.value @property def commit(self): """ :type: :class:`github.GitCommit.GitCommit` """ self._completeIfNotSet(self._commit) return self._commit.value @property def committer(self): """ :type: :class:`github.NamedUser.NamedUser` """ self._completeIfNotSet(self._committer) return self._committer.value @property def files(self): """ :type: list of :class:`github.File.File` """ self._completeIfNotSet(self._files) return self._files.value @property def html_url(self): """ :type: string """ self._completeIfNotSet(self._html_url) return self._html_url.value @property def parents(self): """ :type: list of :class:`github.Commit.Commit` """ self._completeIfNotSet(self._parents) return self._parents.value @property def sha(self): """ :type: string """ self._completeIfNotSet(self._sha) return self._sha.value @property def stats(self): """ :type: :class:`github.CommitStats.CommitStats` """ self._completeIfNotSet(self._stats) return self._stats.value @property def url(self): """ :type: string """ self._completeIfNotSet(self._url) return self._url.value def create_comment( self, body, line=github.GithubObject.NotSet, path=github.GithubObject.NotSet, position=github.GithubObject.NotSet, ): """ :calls: `POST /repos/{owner}/{repo}/commits/{sha}/comments `_ :param body: string :param line: integer :param path: string :param position: integer :rtype: :class:`github.CommitComment.CommitComment` """ assert isinstance(body, str), body assert line is github.GithubObject.NotSet or isinstance(line, int), line assert path is github.GithubObject.NotSet or isinstance(path, str), path assert position is github.GithubObject.NotSet or isinstance( position, int ), position post_parameters = { "body": body, } if line is not github.GithubObject.NotSet: post_parameters["line"] = line if path is not github.GithubObject.NotSet: post_parameters["path"] = path if position is not github.GithubObject.NotSet: post_parameters["position"] = position headers, data = self._requester.requestJsonAndCheck( "POST", f"{self.url}/comments", input=post_parameters ) return github.CommitComment.CommitComment( self._requester, headers, data, completed=True ) def create_status( self, state, target_url=github.GithubObject.NotSet, description=github.GithubObject.NotSet, context=github.GithubObject.NotSet, ): """ :calls: `POST /repos/{owner}/{repo}/statuses/{sha} `_ :param state: string :param target_url: string :param description: string :param context: string :rtype: :class:`github.CommitStatus.CommitStatus` """ assert isinstance(state, str), state assert target_url is github.GithubObject.NotSet or isinstance( target_url, str ), target_url assert description is github.GithubObject.NotSet or isinstance( description, str ), description assert context is github.GithubObject.NotSet or isinstance( context, str ), context post_parameters = { "state": state, } if target_url is not github.GithubObject.NotSet: post_parameters["target_url"] = target_url if description is not github.GithubObject.NotSet: post_parameters["description"] = description if context is not github.GithubObject.NotSet: post_parameters["context"] = context headers, data = self._requester.requestJsonAndCheck( "POST", f"{self._parentUrl(self._parentUrl(self.url))}/statuses/{self.sha}", input=post_parameters, ) return github.CommitStatus.CommitStatus( self._requester, headers, data, completed=True ) def get_comments(self): """ :calls: `GET /repos/{owner}/{repo}/commits/{sha}/comments `_ :rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.CommitComment.CommitComment` """ return github.PaginatedList.PaginatedList( github.CommitComment.CommitComment, self._requester, f"{self.url}/comments", None, ) def get_statuses(self): """ :calls: `GET /repos/{owner}/{repo}/statuses/{ref} `_ :rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.CommitStatus.CommitStatus` """ return github.PaginatedList.PaginatedList( github.CommitStatus.CommitStatus, self._requester, f"{self._parentUrl(self._parentUrl(self.url))}/statuses/{self.sha}", None, ) def get_combined_status(self): """ :calls: `GET /repos/{owner}/{repo}/commits/{ref}/status/ `_ :rtype: :class:`github.CommitCombinedStatus.CommitCombinedStatus` """ headers, data = self._requester.requestJsonAndCheck("GET", f"{self.url}/status") return github.CommitCombinedStatus.CommitCombinedStatus( self._requester, headers, data, completed=True ) def get_pulls(self): """ :calls: `GET /repos/{owner}/{repo}/commits/{sha}/pulls `_ :rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.PullRequest.PullRequest` """ return github.PaginatedList.PaginatedList( github.PullRequest.PullRequest, self._requester, f"{self.url}/pulls", None, headers={"Accept": "application/vnd.github.groot-preview+json"}, ) def get_check_runs( self, check_name=github.GithubObject.NotSet, status=github.GithubObject.NotSet, filter=github.GithubObject.NotSet, ): """ :calls: `GET /repos/{owner}/{repo}/commits/{sha}/check-runs `_ :param check_name: string :param status: string :param filter: string :rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.CheckRun.CheckRun` """ assert check_name is github.GithubObject.NotSet or isinstance( check_name, str ), check_name assert status is github.GithubObject.NotSet or isinstance(status, str), status assert filter is github.GithubObject.NotSet or isinstance(filter, str), filter url_parameters = dict() if check_name is not github.GithubObject.NotSet: url_parameters["check_name"] = check_name if status is not github.GithubObject.NotSet: url_parameters["status"] = status if filter is not github.GithubObject.NotSet: url_parameters["filter"] = filter return github.PaginatedList.PaginatedList( github.CheckRun.CheckRun, self._requester, f"{self.url}/check-runs", url_parameters, headers={"Accept": "application/vnd.github.v3+json"}, list_item="check_runs", ) def get_check_suites( self, app_id=github.GithubObject.NotSet, check_name=github.GithubObject.NotSet ): """ :class: `GET /repos/{owner}/{repo}/commits/{ref}/check-suites `_ :param app_id: int :param check_name: string :rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.CheckSuite.CheckSuite` """ assert app_id is github.GithubObject.NotSet or isinstance(app_id, int), app_id assert check_name is github.GithubObject.NotSet or isinstance( check_name, str ), check_name parameters = dict() if app_id is not github.GithubObject.NotSet: parameters["app_id"] = app_id if check_name is not github.GithubObject.NotSet: parameters["check_name"] = check_name request_headers = {"Accept": "application/vnd.github.v3+json"} return github.PaginatedList.PaginatedList( github.CheckSuite.CheckSuite, self._requester, f"{self.url}/check-suites", parameters, headers=request_headers, list_item="check_suites", ) @property def _identity(self): return self.sha def _initAttributes(self): self._author = github.GithubObject.NotSet self._comments_url = github.GithubObject.NotSet self._commit = github.GithubObject.NotSet self._committer = github.GithubObject.NotSet self._files = github.GithubObject.NotSet self._html_url = github.GithubObject.NotSet self._parents = github.GithubObject.NotSet self._sha = github.GithubObject.NotSet self._stats = github.GithubObject.NotSet self._url = github.GithubObject.NotSet def _useAttributes(self, attributes): if "author" in attributes: # pragma no branch self._author = self._makeClassAttribute( github.NamedUser.NamedUser, attributes["author"] ) if "comments_url" in attributes: # pragma no branch self._comments_url = self._makeStringAttribute(attributes["comments_url"]) if "commit" in attributes: # pragma no branch self._commit = self._makeClassAttribute( github.GitCommit.GitCommit, attributes["commit"] ) if "committer" in attributes: # pragma no branch self._committer = self._makeClassAttribute( github.NamedUser.NamedUser, attributes["committer"] ) if "files" in attributes: # pragma no branch self._files = self._makeListOfClassesAttribute( github.File.File, attributes["files"] ) if "html_url" in attributes: # pragma no branch self._html_url = self._makeStringAttribute(attributes["html_url"]) if "parents" in attributes: # pragma no branch self._parents = self._makeListOfClassesAttribute( Commit, attributes["parents"] ) if "sha" in attributes: # pragma no branch self._sha = self._makeStringAttribute(attributes["sha"]) if "stats" in attributes: # pragma no branch self._stats = self._makeClassAttribute( github.CommitStats.CommitStats, attributes["stats"] ) if "url" in attributes: # pragma no branch self._url = self._makeStringAttribute(attributes["url"]) ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1619412308.0 PyGithub-1.55/github/Commit.pyi0000644000175100001710000000443200000000000015777 0ustar00runnerdockerfrom typing import Any, Dict, List, Union from github.CheckRun import CheckRun from github.CheckSuite import CheckSuite from github.CommitCombinedStatus import CommitCombinedStatus from github.CommitComment import CommitComment from github.CommitStats import CommitStats from github.CommitStatus import CommitStatus from github.File import File from github.GitCommit import GitCommit from github.GithubObject import CompletableGithubObject, _NotSetType from github.NamedUser import NamedUser from github.PaginatedList import PaginatedList class Commit(CompletableGithubObject): def __repr__(self) -> str: ... @property def _identity(self) -> str: ... def _initAttributes(self) -> None: ... def _useAttributes(self, attributes: Dict[str, Any]) -> None: ... @property def author(self) -> NamedUser: ... @property def comments_url(self) -> str: ... @property def commit(self) -> GitCommit: ... @property def committer(self) -> NamedUser: ... def create_comment( self, body: str, line: Union[int, _NotSetType] = ..., path: Union[_NotSetType, str] = ..., position: Union[int, _NotSetType] = ..., ) -> CommitComment: ... def create_status( self, state: str, target_url: Union[_NotSetType, str] = ..., description: Union[_NotSetType, str] = ..., context: Union[_NotSetType, str] = ..., ) -> CommitStatus: ... @property def files(self) -> List[File]: ... def get_check_suites( self, app_id: Union[_NotSetType, int], check_name: Union[_NotSetType, str], ) -> PaginatedList[CheckSuite]: ... def get_combined_status(self) -> CommitCombinedStatus: ... def get_comments(self) -> PaginatedList[CommitComment]: ... def get_statuses(self) -> PaginatedList[CommitStatus]: ... def get_check_runs( self, check_name: Union[_NotSetType, str] = ..., status: Union[_NotSetType, str] = ..., filter: Union[_NotSetType, str] = ..., ) -> PaginatedList[CheckRun]: ... @property def html_url(self) -> str: ... @property def parents(self) -> List[Commit]: ... @property def sha(self) -> str: ... @property def stats(self) -> CommitStats: ... @property def url(self) -> str: ... ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1619412308.0 PyGithub-1.55/github/CommitCombinedStatus.py0000644000175100001710000001134100000000000020470 0ustar00runnerdocker############################ Copyrights and license ############################ # # # Copyright 2016 Jannis Gebauer # # Copyright 2016 John Eskew # # Copyright 2016 Peter Buckley # # Copyright 2018 Wan Liuyang # # Copyright 2018 sfdye # # # # This file is part of PyGithub. # # http://pygithub.readthedocs.io/ # # # # PyGithub is free software: you can redistribute it and/or modify it under # # the terms of the GNU Lesser General Public License as published by the Free # # Software Foundation, either version 3 of the License, or (at your option) # # any later version. # # # # PyGithub is distributed in the hope that it will be useful, but WITHOUT ANY # # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more # # details. # # # # You should have received a copy of the GNU Lesser General Public License # # along with PyGithub. If not, see . # # # ################################################################################ import github.CommitStatus import github.GithubObject import github.Repository class CommitCombinedStatus(github.GithubObject.NonCompletableGithubObject): """ This class represents CommitCombinedStatuses. The reference can be found here https://docs.github.com/en/rest/reference/repos#statuses """ def __repr__(self): return self.get__repr__({"sha": self._sha.value, "state": self._state.value}) @property def state(self): """ :type: string """ return self._state.value @property def sha(self): """ :type: string """ return self._sha.value @property def total_count(self): """ :type: integer """ return self._total_count.value @property def commit_url(self): """ :type: string """ return self._commit_url.value @property def url(self): """ :type: string """ return self._url.value @property def repository(self): """ :type: :class:`github.Repository.Repository` """ return self._repository.value @property def statuses(self): """ :type: list of :class:`CommitStatus` """ return self._statuses.value def _initAttributes(self): self._state = github.GithubObject.NotSet self._sha = github.GithubObject.NotSet self._total_count = github.GithubObject.NotSet self._commit_url = github.GithubObject.NotSet self._url = github.GithubObject.NotSet self._repository = github.GithubObject.NotSet self._statuses = github.GithubObject.NotSet def _useAttributes(self, attributes): if "state" in attributes: # pragma no branch self._state = self._makeStringAttribute(attributes["state"]) if "sha" in attributes: # pragma no branch self._sha = self._makeStringAttribute(attributes["sha"]) if "total_count" in attributes: # pragma no branch self._total_count = self._makeIntAttribute(attributes["total_count"]) if "commit_url" in attributes: # pragma no branch self._commit_url = self._makeStringAttribute(attributes["commit_url"]) if "url" in attributes: # pragma no branch self._url = self._makeStringAttribute(attributes["url"]) if "repository" in attributes: # pragma no branch self._repository = self._makeClassAttribute( github.Repository.Repository, attributes["repository"] ) if "statuses" in attributes: # pragma no branch self._statuses = self._makeListOfClassesAttribute( github.CommitStatus.CommitStatus, attributes["statuses"] ) ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1619412308.0 PyGithub-1.55/github/CommitCombinedStatus.pyi0000644000175100001710000000135100000000000020641 0ustar00runnerdockerfrom typing import Any, Dict, List from github.CommitStatus import CommitStatus from github.GithubObject import NonCompletableGithubObject from github.Repository import Repository class CommitCombinedStatus(NonCompletableGithubObject): def __repr__(self) -> str: ... def _initAttributes(self) -> None: ... def _useAttributes(self, attributes: Dict[str, Any]) -> None: ... @property def commit_url(self) -> str: ... @property def repository(self) -> Repository: ... @property def sha(self) -> str: ... @property def state(self) -> str: ... @property def statuses(self) -> List[CommitStatus]: ... @property def total_count(self) -> int: ... @property def url(self) -> str: ... ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1619412308.0 PyGithub-1.55/github/CommitComment.py0000644000175100001710000002267400000000000017161 0ustar00runnerdocker############################ Copyrights and license ############################ # # # Copyright 2012 Vincent Jacques # # Copyright 2012 Zearin # # Copyright 2013 AKFish # # Copyright 2013 Vincent Jacques # # Copyright 2014 Vincent Jacques # # Copyright 2016 Jannis Gebauer # # Copyright 2016 Peter Buckley # # Copyright 2017 Nicolas Agustín Torres # # Copyright 2018 Wan Liuyang # # Copyright 2018 per1234 # # Copyright 2018 sfdye # # Copyright 2020 Huan-Cheng Chang # # # # This file is part of PyGithub. # # http://pygithub.readthedocs.io/ # # # # PyGithub is free software: you can redistribute it and/or modify it under # # the terms of the GNU Lesser General Public License as published by the Free # # Software Foundation, either version 3 of the License, or (at your option) # # any later version. # # # # PyGithub is distributed in the hope that it will be useful, but WITHOUT ANY # # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more # # details. # # # # You should have received a copy of the GNU Lesser General Public License # # along with PyGithub. If not, see . # # # ################################################################################ import github.GithubObject import github.NamedUser from . import Consts class CommitComment(github.GithubObject.CompletableGithubObject): """ This class represents CommitComments. The reference can be found here https://docs.github.com/en/rest/reference/repos#comments """ def __repr__(self): return self.get__repr__({"id": self._id.value, "user": self.user}) @property def body(self): """ :type: string """ self._completeIfNotSet(self._body) return self._body.value @property def commit_id(self): """ :type: string """ self._completeIfNotSet(self._commit_id) return self._commit_id.value @property def created_at(self): """ :type: datetime.datetime """ self._completeIfNotSet(self._created_at) return self._created_at.value @property def html_url(self): """ :type: string """ self._completeIfNotSet(self._html_url) return self._html_url.value @property def id(self): """ :type: integer """ self._completeIfNotSet(self._id) return self._id.value @property def line(self): """ :type: integer """ self._completeIfNotSet(self._line) return self._line.value @property def path(self): """ :type: string """ self._completeIfNotSet(self._path) return self._path.value @property def position(self): """ :type: integer """ self._completeIfNotSet(self._position) return self._position.value @property def updated_at(self): """ :type: datetime.datetime """ self._completeIfNotSet(self._updated_at) return self._updated_at.value @property def url(self): """ :type: string """ self._completeIfNotSet(self._url) return self._url.value @property def user(self): """ :type: :class:`github.NamedUser.NamedUser` """ self._completeIfNotSet(self._user) return self._user.value def delete(self): """ :calls: `DELETE /repos/{owner}/{repo}/comments/{id} `_ :rtype: None """ headers, data = self._requester.requestJsonAndCheck("DELETE", self.url) def edit(self, body): """ :calls: `PATCH /repos/{owner}/{repo}/comments/{id} `_ :param body: string :rtype: None """ assert isinstance(body, str), body post_parameters = { "body": body, } headers, data = self._requester.requestJsonAndCheck( "PATCH", self.url, input=post_parameters ) self._useAttributes(data) def get_reactions(self): """ :calls: `GET /repos/{owner}/{repo}/comments/{id}/reactions `_ :return: :class: :class:`github.PaginatedList.PaginatedList` of :class:`github.Reaction.Reaction` """ return github.PaginatedList.PaginatedList( github.Reaction.Reaction, self._requester, f"{self.url}/reactions", None, headers={"Accept": Consts.mediaTypeReactionsPreview}, ) def create_reaction(self, reaction_type): """ :calls: `POST /repos/{owner}/{repo}/comments/{id}/reactions `_ :param reaction_type: string :rtype: :class:`github.Reaction.Reaction` """ assert isinstance(reaction_type, str), reaction_type post_parameters = { "content": reaction_type, } headers, data = self._requester.requestJsonAndCheck( "POST", f"{self.url}/reactions", input=post_parameters, headers={"Accept": Consts.mediaTypeReactionsPreview}, ) return github.Reaction.Reaction(self._requester, headers, data, completed=True) def delete_reaction(self, reaction_id): """ :calls: `DELETE /repos/{owner}/{repo}/comments/{comment_id}/reactions/{reaction_id} `_ :param reaction_id: integer :rtype: bool """ assert isinstance(reaction_id, int), reaction_id status, _, _ = self._requester.requestJson( "DELETE", f"{self.url}/reactions/{reaction_id}", headers={"Accept": Consts.mediaTypeReactionsPreview}, ) return status == 204 def _initAttributes(self): self._body = github.GithubObject.NotSet self._commit_id = github.GithubObject.NotSet self._created_at = github.GithubObject.NotSet self._html_url = github.GithubObject.NotSet self._id = github.GithubObject.NotSet self._line = github.GithubObject.NotSet self._path = github.GithubObject.NotSet self._position = github.GithubObject.NotSet self._updated_at = github.GithubObject.NotSet self._url = github.GithubObject.NotSet self._user = github.GithubObject.NotSet def _useAttributes(self, attributes): if "body" in attributes: # pragma no branch self._body = self._makeStringAttribute(attributes["body"]) if "commit_id" in attributes: # pragma no branch self._commit_id = self._makeStringAttribute(attributes["commit_id"]) if "created_at" in attributes: # pragma no branch self._created_at = self._makeDatetimeAttribute(attributes["created_at"]) if "html_url" in attributes: # pragma no branch self._html_url = self._makeStringAttribute(attributes["html_url"]) if "id" in attributes: # pragma no branch self._id = self._makeIntAttribute(attributes["id"]) if "line" in attributes: # pragma no branch self._line = self._makeIntAttribute(attributes["line"]) if "path" in attributes: # pragma no branch self._path = self._makeStringAttribute(attributes["path"]) if "position" in attributes: # pragma no branch self._position = self._makeIntAttribute(attributes["position"]) if "updated_at" in attributes: # pragma no branch self._updated_at = self._makeDatetimeAttribute(attributes["updated_at"]) if "url" in attributes: # pragma no branch self._url = self._makeStringAttribute(attributes["url"]) if "user" in attributes: # pragma no branch self._user = self._makeClassAttribute( github.NamedUser.NamedUser, attributes["user"] ) ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1619412308.0 PyGithub-1.55/github/CommitComment.pyi0000644000175100001710000000237000000000000017321 0ustar00runnerdockerfrom datetime import datetime from typing import Any, Dict, Optional from github.GithubObject import CompletableGithubObject from github.NamedUser import NamedUser from github.PaginatedList import PaginatedList from github.Reaction import Reaction class CommitComment(CompletableGithubObject): def __repr__(self) -> str: ... def _initAttributes(self) -> None: ... def _useAttributes(self, attributes: Dict[str, Any]) -> None: ... @property def body(self) -> str: ... @property def commit_id(self) -> str: ... def create_reaction(self, reaction_type: str) -> Reaction: ... @property def created_at(self) -> datetime: ... def delete(self) -> None: ... def delete_reaction(self, reaction_id: int) -> bool: ... def edit(self, body: str) -> None: ... def get_reactions(self) -> PaginatedList[Reaction]: ... @property def html_url(self) -> str: ... @property def id(self) -> int: ... @property def line(self) -> Optional[int]: ... @property def path(self) -> Optional[str]: ... @property def position(self) -> Optional[int]: ... @property def updated_at(self) -> datetime: ... @property def url(self) -> str: ... @property def user(self) -> NamedUser: ... ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1619412308.0 PyGithub-1.55/github/CommitStats.py0000644000175100001710000000652400000000000016651 0ustar00runnerdocker############################ Copyrights and license ############################ # # # Copyright 2012 Vincent Jacques # # Copyright 2012 Zearin # # Copyright 2013 AKFish # # Copyright 2013 Vincent Jacques # # Copyright 2014 Vincent Jacques # # Copyright 2016 Peter Buckley # # Copyright 2018 Wan Liuyang # # Copyright 2018 sfdye # # # # This file is part of PyGithub. # # http://pygithub.readthedocs.io/ # # # # PyGithub is free software: you can redistribute it and/or modify it under # # the terms of the GNU Lesser General Public License as published by the Free # # Software Foundation, either version 3 of the License, or (at your option) # # any later version. # # # # PyGithub is distributed in the hope that it will be useful, but WITHOUT ANY # # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more # # details. # # # # You should have received a copy of the GNU Lesser General Public License # # along with PyGithub. If not, see . # # # ################################################################################ import github.GithubObject class CommitStats(github.GithubObject.NonCompletableGithubObject): """ This class represents CommitStatses. """ @property def additions(self): """ :type: integer """ return self._additions.value @property def deletions(self): """ :type: integer """ return self._deletions.value @property def total(self): """ :type: integer """ return self._total.value def _initAttributes(self): self._additions = github.GithubObject.NotSet self._deletions = github.GithubObject.NotSet self._total = github.GithubObject.NotSet def _useAttributes(self, attributes): if "additions" in attributes: # pragma no branch self._additions = self._makeIntAttribute(attributes["additions"]) if "deletions" in attributes: # pragma no branch self._deletions = self._makeIntAttribute(attributes["deletions"]) if "total" in attributes: # pragma no branch self._total = self._makeIntAttribute(attributes["total"]) ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1619412308.0 PyGithub-1.55/github/CommitStats.pyi0000644000175100001710000000060700000000000017016 0ustar00runnerdockerfrom typing import Dict from github.GithubObject import NonCompletableGithubObject class CommitStats(NonCompletableGithubObject): def _initAttributes(self) -> None: ... def _useAttributes(self, attributes: Dict[str, int]) -> None: ... @property def additions(self) -> int: ... @property def deletions(self) -> int: ... @property def total(self) -> int: ... ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1619412308.0 PyGithub-1.55/github/CommitStatus.py0000644000175100001710000001345100000000000017033 0ustar00runnerdocker############################ Copyrights and license ############################ # # # Copyright 2012 Vincent Jacques # # Copyright 2012 Zearin # # Copyright 2013 AKFish # # Copyright 2013 Vincent Jacques # # Copyright 2014 Vincent Jacques # # Copyright 2015 Matt Babineau # # Copyright 2016 Jannis Gebauer # # Copyright 2016 Martijn Koster # # Copyright 2016 Peter Buckley # # Copyright 2018 Wan Liuyang # # Copyright 2018 sfdye # # # # This file is part of PyGithub. # # http://pygithub.readthedocs.io/ # # # # PyGithub is free software: you can redistribute it and/or modify it under # # the terms of the GNU Lesser General Public License as published by the Free # # Software Foundation, either version 3 of the License, or (at your option) # # any later version. # # # # PyGithub is distributed in the hope that it will be useful, but WITHOUT ANY # # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more # # details. # # # # You should have received a copy of the GNU Lesser General Public License # # along with PyGithub. If not, see . # # # ################################################################################ import github.GithubObject import github.NamedUser class CommitStatus(github.GithubObject.NonCompletableGithubObject): """ This class represents CommitStatuses.The reference can be found here https://docs.github.com/en/rest/reference/repos#statuses """ def __repr__(self): return self.get__repr__( { "id": self._id.value, "state": self._state.value, "context": self._context.value, } ) @property def created_at(self): """ :type: datetime.datetime """ return self._created_at.value @property def creator(self): """ :type: :class:`github.NamedUser.NamedUser` """ return self._creator.value @property def description(self): """ :type: string """ return self._description.value @property def id(self): """ :type: integer """ return self._id.value @property def state(self): """ :type: string """ return self._state.value @property def context(self): """ :type: string """ return self._context.value @property def target_url(self): """ :type: string """ return self._target_url.value @property def updated_at(self): """ :type: datetime.datetime """ return self._updated_at.value @property def url(self): """ :type: string """ return self._url.value def _initAttributes(self): self._created_at = github.GithubObject.NotSet self._creator = github.GithubObject.NotSet self._description = github.GithubObject.NotSet self._id = github.GithubObject.NotSet self._state = github.GithubObject.NotSet self._context = github.GithubObject.NotSet self._target_url = github.GithubObject.NotSet self._updated_at = github.GithubObject.NotSet self._url = github.GithubObject.NotSet def _useAttributes(self, attributes): if "created_at" in attributes: # pragma no branch self._created_at = self._makeDatetimeAttribute(attributes["created_at"]) if "creator" in attributes: # pragma no branch self._creator = self._makeClassAttribute( github.NamedUser.NamedUser, attributes["creator"] ) if "description" in attributes: # pragma no branch self._description = self._makeStringAttribute(attributes["description"]) if "id" in attributes: # pragma no branch self._id = self._makeIntAttribute(attributes["id"]) if "state" in attributes: # pragma no branch self._state = self._makeStringAttribute(attributes["state"]) if "context" in attributes: # pragma no branch self._context = self._makeStringAttribute(attributes["context"]) if "target_url" in attributes: # pragma no branch self._target_url = self._makeStringAttribute(attributes["target_url"]) if "updated_at" in attributes: # pragma no branch self._updated_at = self._makeDatetimeAttribute(attributes["updated_at"]) if "url" in attributes: # pragma no branch self._url = self._makeStringAttribute(attributes["url"]) ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1619412308.0 PyGithub-1.55/github/CommitStatus.pyi0000644000175100001710000000150300000000000017177 0ustar00runnerdockerfrom datetime import datetime from typing import Any, Dict, Optional from github.GithubObject import NonCompletableGithubObject from github.NamedUser import NamedUser class CommitStatus(NonCompletableGithubObject): def __repr__(self) -> str: ... def _initAttributes(self) -> None: ... def _useAttributes(self, attributes: Dict[str, Any]) -> None: ... @property def context(self) -> str: ... @property def created_at(self) -> datetime: ... @property def creator(self) -> NamedUser: ... @property def description(self) -> Optional[str]: ... @property def id(self) -> int: ... @property def state(self) -> str: ... @property def target_url(self) -> Optional[str]: ... @property def updated_at(self) -> datetime: ... @property def url(self) -> str: ... ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1619412308.0 PyGithub-1.55/github/Comparison.py0000644000175100001710000001661300000000000016514 0ustar00runnerdocker############################ Copyrights and license ############################ # # # Copyright 2012 Vincent Jacques # # Copyright 2012 Zearin # # Copyright 2013 AKFish # # Copyright 2013 Vincent Jacques # # Copyright 2014 Vincent Jacques # # Copyright 2016 Peter Buckley # # Copyright 2018 Wan Liuyang # # Copyright 2018 sfdye # # # # This file is part of PyGithub. # # http://pygithub.readthedocs.io/ # # # # PyGithub is free software: you can redistribute it and/or modify it under # # the terms of the GNU Lesser General Public License as published by the Free # # Software Foundation, either version 3 of the License, or (at your option) # # any later version. # # # # PyGithub is distributed in the hope that it will be useful, but WITHOUT ANY # # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more # # details. # # # # You should have received a copy of the GNU Lesser General Public License # # along with PyGithub. If not, see . # # # ################################################################################ import github.Commit import github.File import github.GithubObject class Comparison(github.GithubObject.CompletableGithubObject): """ This class represents Comparisons """ @property def ahead_by(self): """ :type: integer """ self._completeIfNotSet(self._ahead_by) return self._ahead_by.value @property def base_commit(self): """ :type: :class:`github.Commit.Commit` """ self._completeIfNotSet(self._base_commit) return self._base_commit.value @property def behind_by(self): """ :type: integer """ self._completeIfNotSet(self._behind_by) return self._behind_by.value @property def commits(self): """ :type: list of :class:`github.Commit.Commit` """ self._completeIfNotSet(self._commits) return self._commits.value @property def diff_url(self): """ :type: string """ self._completeIfNotSet(self._diff_url) return self._diff_url.value @property def files(self): """ :type: list of :class:`github.File.File` """ self._completeIfNotSet(self._files) return self._files.value @property def html_url(self): """ :type: string """ self._completeIfNotSet(self._html_url) return self._html_url.value @property def merge_base_commit(self): """ :type: :class:`github.Commit.Commit` """ self._completeIfNotSet(self._merge_base_commit) return self._merge_base_commit.value @property def patch_url(self): """ :type: string """ self._completeIfNotSet(self._patch_url) return self._patch_url.value @property def permalink_url(self): """ :type: string """ self._completeIfNotSet(self._permalink_url) return self._permalink_url.value @property def status(self): """ :type: string """ self._completeIfNotSet(self._status) return self._status.value @property def total_commits(self): """ :type: integer """ self._completeIfNotSet(self._total_commits) return self._total_commits.value @property def url(self): """ :type: string """ self._completeIfNotSet(self._url) return self._url.value def _initAttributes(self): self._ahead_by = github.GithubObject.NotSet self._base_commit = github.GithubObject.NotSet self._behind_by = github.GithubObject.NotSet self._commits = github.GithubObject.NotSet self._diff_url = github.GithubObject.NotSet self._files = github.GithubObject.NotSet self._html_url = github.GithubObject.NotSet self._merge_base_commit = github.GithubObject.NotSet self._patch_url = github.GithubObject.NotSet self._permalink_url = github.GithubObject.NotSet self._status = github.GithubObject.NotSet self._total_commits = github.GithubObject.NotSet self._url = github.GithubObject.NotSet def _useAttributes(self, attributes): if "ahead_by" in attributes: # pragma no branch self._ahead_by = self._makeIntAttribute(attributes["ahead_by"]) if "base_commit" in attributes: # pragma no branch self._base_commit = self._makeClassAttribute( github.Commit.Commit, attributes["base_commit"] ) if "behind_by" in attributes: # pragma no branch self._behind_by = self._makeIntAttribute(attributes["behind_by"]) if "commits" in attributes: # pragma no branch self._commits = self._makeListOfClassesAttribute( github.Commit.Commit, attributes["commits"] ) if "diff_url" in attributes: # pragma no branch self._diff_url = self._makeStringAttribute(attributes["diff_url"]) if "files" in attributes: # pragma no branch self._files = self._makeListOfClassesAttribute( github.File.File, attributes["files"] ) if "html_url" in attributes: # pragma no branch self._html_url = self._makeStringAttribute(attributes["html_url"]) if "merge_base_commit" in attributes: # pragma no branch self._merge_base_commit = self._makeClassAttribute( github.Commit.Commit, attributes["merge_base_commit"] ) if "patch_url" in attributes: # pragma no branch self._patch_url = self._makeStringAttribute(attributes["patch_url"]) if "permalink_url" in attributes: # pragma no branch self._permalink_url = self._makeStringAttribute(attributes["permalink_url"]) if "status" in attributes: # pragma no branch self._status = self._makeStringAttribute(attributes["status"]) if "total_commits" in attributes: # pragma no branch self._total_commits = self._makeIntAttribute(attributes["total_commits"]) if "url" in attributes: # pragma no branch self._url = self._makeStringAttribute(attributes["url"]) ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1619412308.0 PyGithub-1.55/github/Comparison.pyi0000644000175100001710000000172700000000000016665 0ustar00runnerdockerfrom typing import Any, Dict, List from github.Commit import Commit from github.File import File from github.GithubObject import CompletableGithubObject class Comparison(CompletableGithubObject): def _initAttributes(self) -> None: ... def _useAttributes(self, attributes: Dict[str, Any]) -> None: ... @property def ahead_by(self) -> int: ... @property def base_commit(self) -> Commit: ... @property def behind_by(self) -> int: ... @property def commits(self) -> List[Commit]: ... @property def diff_url(self) -> str: ... @property def files(self) -> List[File]: ... @property def html_url(self) -> str: ... @property def merge_base_commit(self) -> Commit: ... @property def patch_url(self) -> str: ... @property def permalink_url(self) -> str: ... @property def status(self) -> str: ... @property def total_commits(self) -> int: ... @property def url(self) -> str: ... ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1619412308.0 PyGithub-1.55/github/Consts.py0000644000175100001710000001533600000000000015654 0ustar00runnerdocker############################ Copyrights and license ############################ # # # Copyright 2013 AKFish # # Copyright 2013 Vincent Jacques # # Copyright 2014 Vincent Jacques # # Copyright 2016 Jakub Wilk # # Copyright 2016 Peter Buckley # # Copyright 2018 Maarten Fonville # # Copyright 2018 Wan Liuyang # # Copyright 2018 sfdye # # Copyright 2019 Nick Campbell # # Copyright 2020 Pascal Hofmann # # # # This file is part of PyGithub. # # http://pygithub.readthedocs.io/ # # # # PyGithub is free software: you can redistribute it and/or modify it under # # the terms of the GNU Lesser General Public License as published by the Free # # Software Foundation, either version 3 of the License, or (at your option) # # any later version. # # # # PyGithub is distributed in the hope that it will be useful, but WITHOUT ANY # # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more # # details. # # # # You should have received a copy of the GNU Lesser General Public License # # along with PyGithub. If not, see . # # # ################################################################################ REQ_IF_NONE_MATCH = "If-None-Match" REQ_IF_MODIFIED_SINCE = "If-Modified-Since" PROCESSING_202_WAIT_TIME = 2 # ############################################################################## # Response Header # # (Lower Case) # # ############################################################################## RES_ETAG = "etag" RES_LAST_MODIFIED = "last-modified" # Inspired by https://github.com/google/go-github # Headers headerRateLimit = "x-ratelimit-limit" headerRateRemaining = "x-ratelimit-remaining" headerRateReset = "x-ratelimit-reset" headerOAuthScopes = "x-oauth-scopes" headerOTP = "x-github-otp" defaultMediaType = "application/octet-stream" # Custom media type for preview API # https://developer.github.com/changes/2014-12-09-new-attributes-for-stars-api/ mediaTypeStarringPreview = "application/vnd.github.v3.star+json" # https://developer.github.com/changes/2016-02-19-source-import-preview-api/ mediaTypeImportPreview = "application/vnd.github.barred-rock-preview" # https://developer.github.com/changes/2016-05-12-reactions-api-preview/ mediaTypeReactionsPreview = "application/vnd.github.squirrel-girl-preview" # https://developer.github.com/changes/2016-09-14-Integrations-Early-Access/ mediaTypeIntegrationPreview = "application/vnd.github.machine-man-preview+json" # https://developer.github.com/changes/2016-09-14-projects-api/ mediaTypeProjectsPreview = "application/vnd.github.inertia-preview+json" # https://developer.github.com/changes/2017-01-05-commit-search-api/ mediaTypeCommitSearchPreview = "application/vnd.github.cloak-preview" # https://developer.github.com/changes/2017-02-28-user-blocking-apis-and-webhook/ mediaTypeBlockUsersPreview = "application/vnd.github.giant-sentry-fist-preview+json" # https://developer.github.com/changes/2017-07-17-update-topics-on-repositories/ mediaTypeTopicsPreview = "application/vnd.github.mercy-preview+json" # https://developer.github.com/changes/2018-02-22-label-description-search-preview/ mediaTypeLabelDescriptionSearchPreview = "application/vnd.github.symmetra-preview+json" # https://developer.github.com/changes/2018-01-10-lock-reason-api-preview/ mediaTypeLockReasonPreview = "application/vnd.github.sailor-v-preview+json" # https://developer.github.com/changes/2018-01-25-organization-invitation-api-preview/ mediaTypeOrganizationInvitationPreview = "application/vnd.github.dazzler-preview+json" # https://developer.github.com/changes/2018-02-07-team-discussions-api mediaTypeTeamDiscussionsPreview = "application/vnd.github.echo-preview+json" # https://developer.github.com/changes/2018-03-16-protected-branches-required-approving-reviews/ mediaTypeRequireMultipleApprovingReviews = ( "application/vnd.github.luke-cage-preview+json" ) # https://developer.github.com/changes/2018-05-24-user-migration-api/ mediaTypeMigrationPreview = "application/vnd.github.wyandotte-preview+json" # https://docs.github.com/en/rest/reference/search#highlighting-code-search-results-1 highLightSearchPreview = "application/vnd.github.v3.text-match+json" # https://developer.github.com/changes/2018-02-22-protected-branches-required-signatures/ signaturesProtectedBranchesPreview = "application/vnd.github.zzzax-preview+json" # https://developer.github.com/changes/2019-04-24-vulnerability-alerts/ vulnerabilityAlertsPreview = "application/vnd.github.dorian-preview+json" # https://developer.github.com/changes/2019-06-04-automated-security-fixes/ automatedSecurityFixes = "application/vnd.github.london-preview+json" # https://developer.github.com/changes/2019-05-29-update-branch-api/ updateBranchPreview = "application/vnd.github.lydian-preview+json" # https://developer.github.com/changes/2016-05-23-timeline-preview-api/ issueTimelineEventsPreview = "application/vnd.github.mockingbird-preview" # https://docs.github.com/en/rest/reference/teams#check-if-a-team-manages-a-repository teamRepositoryPermissions = "application/vnd.github.v3.repository+json" # https://developer.github.com/changes/2016-04-06-deployment-and-deployment-status-enhancements/ deploymentEnhancementsPreview = "application/vnd.github.ant-man-preview+json" # https://developer.github.com/changes/2018-10-16-deployments-environments-states-and-auto-inactive-updates/ deploymentStatusEnhancementsPreview = "application/vnd.github.flash-preview+json" ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1619412308.0 PyGithub-1.55/github/ContentFile.py0000644000175100001710000002064300000000000016612 0ustar00runnerdocker############################ Copyrights and license ############################ # # # Copyright 2012 Vincent Jacques # # Copyright 2012 Zearin # # Copyright 2013 AKFish # # Copyright 2013 Vincent Jacques # # Copyright 2014 Thialfihar # # Copyright 2014 Vincent Jacques # # Copyright 2016 Jannis Gebauer # # Copyright 2016 Peter Buckley # # Copyright 2018 Wan Liuyang # # Copyright 2018 sfdye # # # # This file is part of PyGithub. # # http://pygithub.readthedocs.io/ # # # # PyGithub is free software: you can redistribute it and/or modify it under # # the terms of the GNU Lesser General Public License as published by the Free # # Software Foundation, either version 3 of the License, or (at your option) # # any later version. # # # # PyGithub is distributed in the hope that it will be useful, but WITHOUT ANY # # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more # # details. # # # # You should have received a copy of the GNU Lesser General Public License # # along with PyGithub. If not, see . # # # ################################################################################ import base64 import github.GithubObject import github.Repository class ContentFile(github.GithubObject.CompletableGithubObject): """ This class represents ContentFiles. The reference can be found here https://docs.github.com/en/rest/reference/repos#contents """ def __repr__(self): return self.get__repr__({"path": self._path.value}) @property def content(self): """ :type: string """ self._completeIfNotSet(self._content) return self._content.value @property def decoded_content(self): """ :type: bytes """ assert self.encoding == "base64", f"unsupported encoding: {self.encoding}" return base64.b64decode(bytearray(self.content, "utf-8")) @property def download_url(self): """ :type: string """ self._completeIfNotSet(self._download_url) return self._download_url.value @property def encoding(self): """ :type: string """ self._completeIfNotSet(self._encoding) return self._encoding.value @property def git_url(self): """ :type: string """ self._completeIfNotSet(self._git_url) return self._git_url.value @property def html_url(self): """ :type: string """ self._completeIfNotSet(self._html_url) return self._html_url.value @property def license(self): """ :type: :class:`github.License.License` """ self._completeIfNotSet(self._license) return self._license.value @property def name(self): """ :type: string """ self._completeIfNotSet(self._name) return self._name.value @property def path(self): """ :type: string """ self._completeIfNotSet(self._path) return self._path.value @property def repository(self): """ :type: :class:`github.Repository.Repository` """ if self._repository is github.GithubObject.NotSet: # The repository was not set automatically, so it must be looked up by url. repo_url = "/".join( self.url.split("/")[:6] ) # pragma no cover (Should be covered) self._repository = github.GithubObject._ValuedAttribute( github.Repository.Repository( self._requester, self._headers, {"url": repo_url}, completed=False ) ) # pragma no cover (Should be covered) return self._repository.value @property def sha(self): """ :type: string """ self._completeIfNotSet(self._sha) return self._sha.value @property def size(self): """ :type: integer """ self._completeIfNotSet(self._size) return self._size.value @property def type(self): """ :type: string """ self._completeIfNotSet(self._type) return self._type.value @property def url(self): """ :type: string """ self._completeIfNotSet(self._url) return self._url.value @property def text_matches(self): """ :type: string """ self._completeIfNotSet(self._text_matches) return self._text_matches.value def _initAttributes(self): self._content = github.GithubObject.NotSet self._text_matches = github.GithubObject.NotSet self._encoding = github.GithubObject.NotSet self._download_url = github.GithubObject.NotSet self._git_url = github.GithubObject.NotSet self._html_url = github.GithubObject.NotSet self._license = github.GithubObject.NotSet self._name = github.GithubObject.NotSet self._path = github.GithubObject.NotSet self._repository = github.GithubObject.NotSet self._sha = github.GithubObject.NotSet self._size = github.GithubObject.NotSet self._type = github.GithubObject.NotSet def _useAttributes(self, attributes): if "content" in attributes: # pragma no branch self._content = self._makeStringAttribute(attributes["content"]) if "download_url" in attributes: # pragma no branch self._download_url = self._makeStringAttribute(attributes["download_url"]) if "encoding" in attributes: # pragma no branch self._encoding = self._makeStringAttribute(attributes["encoding"]) if "git_url" in attributes: # pragma no branch self._git_url = self._makeStringAttribute(attributes["git_url"]) if "html_url" in attributes: # pragma no branch self._html_url = self._makeStringAttribute(attributes["html_url"]) if "license" in attributes: # pragma no branch self._license = self._makeClassAttribute( github.License.License, attributes["license"] ) if "name" in attributes: # pragma no branch self._name = self._makeStringAttribute(attributes["name"]) if "path" in attributes: # pragma no branch self._path = self._makeStringAttribute(attributes["path"]) if "repository" in attributes: # pragma no branch self._repository = self._makeClassAttribute( github.Repository.Repository, attributes["repository"] ) if "sha" in attributes: # pragma no branch self._sha = self._makeStringAttribute(attributes["sha"]) if "size" in attributes: # pragma no branch self._size = self._makeIntAttribute(attributes["size"]) if "type" in attributes: # pragma no branch self._type = self._makeStringAttribute(attributes["type"]) if "url" in attributes: # pragma no branch self._url = self._makeStringAttribute(attributes["url"]) if "text_matches" in attributes: # pragma no branch self._text_matches = self._makeListOfDictsAttribute( attributes["text_matches"] ) ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1619412308.0 PyGithub-1.55/github/ContentFile.pyi0000644000175100001710000000215600000000000016762 0ustar00runnerdockerfrom typing import Any, Dict, List, Optional from github.GithubObject import CompletableGithubObject from github.License import License from github.Repository import Repository class ContentFile(CompletableGithubObject): def __repr__(self) -> str: ... def _initAttributes(self) -> None: ... def _useAttributes(self, attributes: Dict[str, Any]) -> None: ... @property def content(self) -> Optional[str]: ... @property def decoded_content(self) -> bytes: ... @property def download_url(self) -> str: ... @property def encoding(self) -> str: ... @property def git_url(self) -> str: ... @property def html_url(self) -> str: ... @property def name(self) -> str: ... @property def path(self) -> str: ... @property def repository(self) -> Repository: ... @property def sha(self) -> str: ... @property def size(self) -> int: ... @property def text_matches(self) -> List[Dict[str, Any]]: ... @property def type(self) -> str: ... @property def url(self) -> str: ... @property def license(self) -> License: ... ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1619412308.0 PyGithub-1.55/github/Deployment.py0000644000175100001710000002737200000000000016526 0ustar00runnerdocker############################ Copyrights and license ############################ # # # Copyright 2020 Steve Kowalik # # Copyright 2020 Colby Gallup # # Copyright 2020 Pascal Hofmann # # # # This file is part of PyGithub. # # http://pygithub.readthedocs.io/ # # # # PyGithub is free software: you can redistribute it and/or modify it under # # the terms of the GNU Lesser General Public License as published by the Free # # Software Foundation, either version 3 of the License, or (at your option) # # any later version. # # # # PyGithub is distributed in the hope that it will be useful, but WITHOUT ANY # # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more # # details. # # # # You should have received a copy of the GNU Lesser General Public License # # along with PyGithub. If not, see . # # # ################################################################################ import github.Consts import github.DeploymentStatus import github.GithubObject class Deployment(github.GithubObject.CompletableGithubObject): """ This class represents Deployments. The reference can be found here https://docs.github.com/en/rest/reference/repos#deployments """ def __repr__(self): return self.get__repr__({"id": self._id.value, "url": self._url.value}) @property def id(self): """ :type: int """ self._completeIfNotSet(self._id) return self._id.value @property def url(self): """ :type: string """ self._completeIfNotSet(self._url) return self._url.value @property def sha(self): """ :type: string """ self._completeIfNotSet(self._sha) return self._sha.value @property def task(self): """ :type: string """ self._completeIfNotSet(self._task) return self._task.value @property def payload(self): """ :type: dict """ self._completeIfNotSet(self._payload) return self._payload.value @property def original_environment(self): """ :type: string """ self._completeIfNotSet(self._original_environment) return self._original_environment.value @property def environment(self): """ :type: string """ self._completeIfNotSet(self._environment) return self._environment.value @property def production_environment(self): """ :type: bool """ self._completeIfNotSet(self._production_environment) return self._production_environment.value @property def transient_environment(self): """ :type: bool """ self._completeIfNotSet(self._transient_environment) return self._transient_environment.value @property def description(self): """ :type: string """ self._completeIfNotSet(self._description) return self._description.value @property def creator(self): """ :type: :class:`github.NamedUser.NamedUser` """ self._completeIfNotSet(self._creator) return self._creator.value @property def created_at(self): """ :type: datetime """ self._completeIfNotSet(self._created_at) return self._created_at.value @property def updated_at(self): """ :type: datetime """ self._completeIfNotSet(self._updated_at) return self._updated_at.value @property def statuses_url(self): """ :type: string """ self._completeIfNotSet(self._statuses_url) return self._statuses_url.value @property def repository_url(self): """ :type: string """ self._completeIfNotSet(self._repository_url) return self._repository_url.value def get_statuses(self): """ :calls: `GET /repos/{owner}/deployments/{deployment_id}/statuses `_ :rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.DeploymentStatus.DeploymentStatus` """ return github.PaginatedList.PaginatedList( github.DeploymentStatus.DeploymentStatus, self._requester, f"{self.url}/statuses", None, headers={"Accept": self._get_accept_header()}, ) def get_status(self, id_): """ :calls: `GET /repos/{owner}/deployments/{deployment_id}/statuses/{status_id} `_ :param id_: int :rtype: :class:`github.DeploymentStatus.DeploymentStatus` """ assert isinstance(id_, int), id_ headers, data = self._requester.requestJsonAndCheck( "GET", f"{self.url}/statuses/{id_}", headers={"Accept": self._get_accept_header()}, ) return github.DeploymentStatus.DeploymentStatus( self._requester, headers, data, completed=True ) def create_status( self, state, target_url=github.GithubObject.NotSet, description=github.GithubObject.NotSet, environment=github.GithubObject.NotSet, environment_url=github.GithubObject.NotSet, auto_inactive=github.GithubObject.NotSet, ): """ :calls: `POST /repos/{owner}/{repo}/deployments/{deployment_id}/statuses `_ :param: state: string :param: target_url: string :param: description: string :param: environment: string :param: environment_url: string :param: auto_inactive: bool :rtype: :class:`github.DeploymentStatus.DeploymentStatus` """ assert isinstance(state, str), state assert target_url is github.GithubObject.NotSet or isinstance( target_url, str ), target_url assert description is github.GithubObject.NotSet or isinstance( description, str ), description assert environment is github.GithubObject.NotSet or isinstance( environment, str ), environment assert environment_url is github.GithubObject.NotSet or isinstance( environment_url, str ), environment_url assert auto_inactive is github.GithubObject.NotSet or isinstance( auto_inactive, bool ), auto_inactive post_parameters = {"state": state} if target_url is not github.GithubObject.NotSet: post_parameters["target_url"] = target_url if description is not github.GithubObject.NotSet: post_parameters["description"] = description if environment is not github.GithubObject.NotSet: post_parameters["environment"] = environment if environment_url is not github.GithubObject.NotSet: post_parameters["environment_url"] = environment_url if auto_inactive is not github.GithubObject.NotSet: post_parameters["auto_inactive"] = auto_inactive headers, data = self._requester.requestJsonAndCheck( "POST", f"{self.url}/statuses", input=post_parameters, headers={"Accept": self._get_accept_header()}, ) return github.DeploymentStatus.DeploymentStatus( self._requester, headers, data, completed=True ) @staticmethod def _get_accept_header(): return ", ".join( [ github.Consts.deploymentEnhancementsPreview, github.Consts.deploymentStatusEnhancementsPreview, ] ) def _initAttributes(self): self._id = github.GithubObject.NotSet self._production_environment = github.GithubObject.NotSet self._transient_environment = github.GithubObject.NotSet self._url = github.GithubObject.NotSet self._sha = github.GithubObject.NotSet self._task = github.GithubObject.NotSet self._payload = github.GithubObject.NotSet self._original_environment = github.GithubObject.NotSet self._environment = github.GithubObject.NotSet self._description = github.GithubObject.NotSet self._creator = github.GithubObject.NotSet self._created_at = github.GithubObject.NotSet self._updated_at = github.GithubObject.NotSet self._statuses_url = github.GithubObject.NotSet self._repository_url = github.GithubObject.NotSet def _useAttributes(self, attributes): if "id" in attributes: # pragma no branch self._id = self._makeIntAttribute(attributes["id"]) if "production_environment" in attributes: # pragma no branch self._production_environment = self._makeBoolAttribute( attributes["production_environment"] ) if "transient_environment" in attributes: # pragma no branch self._transient_environment = self._makeBoolAttribute( attributes["transient_environment"] ) if "url" in attributes: # pragma no branch self._url = self._makeStringAttribute(attributes["url"]) if "sha" in attributes: # pragma no branch self._sha = self._makeStringAttribute(attributes["sha"]) if "task" in attributes: # pragma no branch self._task = self._makeStringAttribute(attributes["task"]) if "payload" in attributes: # pragma no branch self._payload = self._makeDictAttribute(attributes["payload"]) if "original_environment" in attributes: # pragma no branch self._original_environment = self._makeStringAttribute( attributes["original_environment"] ) if "environment" in attributes: # pragma no branch self._environment = self._makeStringAttribute(attributes["environment"]) if "description" in attributes: # pragma no branch self._description = self._makeStringAttribute(attributes["description"]) if "creator" in attributes: # pragma no branch self._creator = self._makeClassAttribute( github.NamedUser.NamedUser, attributes["creator"] ) if "created_at" in attributes: # pragma no branch self._created_at = self._makeDatetimeAttribute(attributes["created_at"]) if "updated_at" in attributes: # pragma no branch self._updated_at = self._makeDatetimeAttribute(attributes["updated_at"]) if "statuses_url" in attributes: # pragma no branch self._statuses_url = self._makeStringAttribute(attributes["statuses_url"]) if "repository_url" in attributes: # pragma no branch self._repository_url = self._makeStringAttribute( attributes["repository_url"] ) ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1619412308.0 PyGithub-1.55/github/Deployment.pyi0000644000175100001710000000342000000000000016663 0ustar00runnerdockerfrom datetime import datetime from typing import Any, Dict, Union from github.DeploymentStatus import DeploymentStatus from github.GithubObject import CompletableGithubObject, _NotSetType from github.NamedUser import NamedUser from github.PaginatedList import PaginatedList class Deployment(CompletableGithubObject): def __repr__(self) -> str: ... @staticmethod def _get_accept_header() -> str: ... def _initAttributes(self) -> None: ... def _useAttributes(self, attributes: Dict[str, Any]) -> None: ... def get_statuses(self) -> PaginatedList[DeploymentStatus]: ... def get_status(self, id_: int) -> DeploymentStatus: ... def create_status( self, state: str, target_url: Union[str, _NotSetType] = ..., description: Union[str, _NotSetType] = ..., environment: Union[str, _NotSetType] = ..., environment_url: Union[str, _NotSetType] = ..., auto_inactive: Union[bool, _NotSetType] = ..., ) -> DeploymentStatus: ... @property def id(self) -> int: ... @property def url(self) -> str: ... @property def sha(self) -> str: ... @property def task(self) -> str: ... @property def payload(self) -> Dict[str, Any]: ... @property def original_environment(self) -> str: ... @property def environment(self) -> str: ... @property def production_environment(self) -> bool: ... @property def transient_environment(self) -> bool: ... @property def description(self) -> str: ... @property def creator(self) -> NamedUser: ... @property def created_at(self) -> datetime: ... @property def updated_at(self) -> datetime: ... @property def statuses_url(self) -> str: ... @property def repository_url(self) -> str: ... ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1619412308.0 PyGithub-1.55/github/DeploymentStatus.py0000644000175100001710000001575100000000000017730 0ustar00runnerdocker############################ Copyrights and license ############################ # # # Copyright 2020 Colby Gallup # # Copyright 2020 Pascal Hofmann # # # # This file is part of PyGithub. # # http://pygithub.readthedocs.io/ # # # # PyGithub is free software: you can redistribute it and/or modify it under # # the terms of the GNU Lesser General Public License as published by the Free # # Software Foundation, either version 3 of the License, or (at your option) # # any later version. # # # # PyGithub is distributed in the hope that it will be useful, but WITHOUT ANY # # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more # # details. # # # # You should have received a copy of the GNU Lesser General Public License # # along with PyGithub. If not, see . # # # ################################################################################ import github.GithubObject class DeploymentStatus(github.GithubObject.CompletableGithubObject): """ This class represents Deployment Statuses. The reference can be found here https://docs.github.com/en/rest/reference/repos#deployments """ def __repr__(self): return self.get__repr__({"id": self._id.value, "url": self._url.value}) @property def created_at(self): """ :type: datetime.datetime """ self._completeIfNotSet(self._created_at) return self._created_at.value @property def creator(self): """ :type: :class:`github.NamedUser.NamedUser` """ self._completeIfNotSet(self._creator) return self._creator.value @property def deployment_url(self): """ :type: string """ self._completeIfNotSet(self._deployment_url) return self._deployment_url.value @property def description(self): """ :type: string """ self._completeIfNotSet(self._description) return self._description.value @property def environment(self): """ :type: string """ self._completeIfNotSet(self._environment) return self._environment.value @property def environment_url(self): """ :type: string """ self._completeIfNotSet(self._environment_url) return self._environment_url.value @property def repository_url(self): """ :type: string """ self._completeIfNotSet(self._repository_url) return self._repository_url.value @property def state(self): """ :type: string """ self._completeIfNotSet(self._state) return self._state.value @property def target_url(self): """ :type: string """ self._completeIfNotSet(self._target_url) return self._target_url.value @property def updated_at(self): """ :type: datetime.datetime """ self._completeIfNotSet(self._updated_at) return self._updated_at.value @property def url(self): """ :type: string """ self._completeIfNotSet(self._url) return self._url.value @property def id(self): """ :type: int """ self._completeIfNotSet(self._id) return self._id.value @property def node_id(self): """ :type: string """ self._completeIfNotSet(self._node_id) return self._node_id.value def _initAttributes(self): self._created_at = github.GithubObject.NotSet self._creator = github.GithubObject.NotSet self._deployment_url = github.GithubObject.NotSet self._description = github.GithubObject.NotSet self._environment = github.GithubObject.NotSet self._environment_url = github.GithubObject.NotSet self._repository_url = github.GithubObject.NotSet self._state = github.GithubObject.NotSet self._target_url = github.GithubObject.NotSet self._updated_at = github.GithubObject.NotSet self._url = github.GithubObject.NotSet self._id = github.GithubObject.NotSet self._node_id = github.GithubObject.NotSet def _useAttributes(self, attributes): if "environment_url" in attributes: # pragma no branch self._environment_url = self._makeStringAttribute( attributes["environment_url"] ) if "url" in attributes: # pragma no branch self._url = self._makeStringAttribute(attributes["url"]) if "id" in attributes: # pragma no branch self._id = self._makeIntAttribute(attributes["id"]) if "node_id" in attributes: # pragma no branch self._node_id = self._makeStringAttribute(attributes["node_id"]) if "created_at" in attributes: # pragma no branch self._created_at = self._makeDatetimeAttribute(attributes["created_at"]) if "creator" in attributes: # pragma no branch self._creator = self._makeClassAttribute( github.NamedUser.NamedUser, attributes["creator"] ) if "deployment_url" in attributes: # pragma no branch self._deployment_url = self._makeStringAttribute( attributes["deployment_url"] ) if "description" in attributes: # pragma no branch self._description = self._makeStringAttribute(attributes["description"]) if "environment" in attributes: # pragma no branch self._environment = self._makeStringAttribute(attributes["environment"]) if "repository_url" in attributes: # pragma no branch self._repository_url = self._makeStringAttribute( attributes["repository_url"] ) if "state" in attributes: # pragma no branch self._state = self._makeStringAttribute(attributes["state"]) if "target_url" in attributes: # pragma no branch self._target_url = self._makeStringAttribute(attributes["target_url"]) if "updated_at" in attributes: # pragma no branch self._updated_at = self._makeDatetimeAttribute(attributes["updated_at"]) ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1619412308.0 PyGithub-1.55/github/DeploymentStatus.pyi0000644000175100001710000000177600000000000020103 0ustar00runnerdockerfrom datetime import datetime from typing import Any, Dict from github.GithubObject import CompletableGithubObject from github.NamedUser import NamedUser class DeploymentStatus(CompletableGithubObject): def __repr__(self) -> str: ... def _initAttributes(self) -> None: ... def _useAttributes(self, attributes: Dict[str, Any]) -> None: ... @property def created_at(self) -> datetime: ... @property def creator(self) -> NamedUser: ... @property def deployment_url(self) -> str: ... @property def description(self) -> str: ... @property def environment(self) -> str: ... @property def environment_url(self) -> str: ... @property def repository_url(self) -> str: ... @property def state(self) -> str: ... @property def target_url(self) -> str: ... @property def updated_at(self) -> datetime: ... @property def url(self) -> str: ... @property def id(self) -> int: ... @property def node_id(self) -> str: ... ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1619412308.0 PyGithub-1.55/github/Download.py0000644000175100001710000002601500000000000016146 0ustar00runnerdocker############################ Copyrights and license ############################ # # # Copyright 2012 Vincent Jacques # # Copyright 2012 Zearin # # Copyright 2013 AKFish # # Copyright 2013 Vincent Jacques # # Copyright 2014 Vincent Jacques # # Copyright 2016 Jannis Gebauer # # Copyright 2016 Peter Buckley # # Copyright 2018 Wan Liuyang # # Copyright 2018 sfdye # # # # This file is part of PyGithub. # # http://pygithub.readthedocs.io/ # # # # PyGithub is free software: you can redistribute it and/or modify it under # # the terms of the GNU Lesser General Public License as published by the Free # # Software Foundation, either version 3 of the License, or (at your option) # # any later version. # # # # PyGithub is distributed in the hope that it will be useful, but WITHOUT ANY # # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more # # details. # # # # You should have received a copy of the GNU Lesser General Public License # # along with PyGithub. If not, see . # # # ################################################################################ import github.GithubObject class Download(github.GithubObject.CompletableGithubObject): """ This class represents Downloads. The reference can be found here https://docs.github.com/en/rest/reference/repos """ def __repr__(self): return self.get__repr__({"id": self._id.value}) @property def accesskeyid(self): """ :type: string """ self._completeIfNotSet(self._accesskeyid) return self._accesskeyid.value @property def acl(self): """ :type: string """ self._completeIfNotSet(self._acl) return self._acl.value @property def bucket(self): """ :type: string """ self._completeIfNotSet(self._bucket) return self._bucket.value @property def content_type(self): """ :type: string """ self._completeIfNotSet(self._content_type) return self._content_type.value @property def created_at(self): """ :type: datetime.datetime """ self._completeIfNotSet(self._created_at) return self._created_at.value @property def description(self): """ :type: string """ self._completeIfNotSet(self._description) return self._description.value @property def download_count(self): """ :type: integer """ self._completeIfNotSet(self._download_count) return self._download_count.value @property def expirationdate(self): """ :type: datetime.datetime """ self._completeIfNotSet(self._expirationdate) return self._expirationdate.value @property def html_url(self): """ :type: string """ self._completeIfNotSet(self._html_url) return self._html_url.value @property def id(self): """ :type: integer """ self._completeIfNotSet(self._id) return self._id.value @property def mime_type(self): """ :type: string """ self._completeIfNotSet(self._mime_type) return self._mime_type.value @property def name(self): """ :type: string """ self._completeIfNotSet(self._name) return self._name.value @property def path(self): """ :type: string """ self._completeIfNotSet(self._path) return self._path.value @property def policy(self): """ :type: string """ self._completeIfNotSet(self._policy) return self._policy.value @property def prefix(self): """ :type: string """ self._completeIfNotSet(self._prefix) return self._prefix.value @property def redirect(self): """ :type: bool """ self._completeIfNotSet(self._redirect) return self._redirect.value @property def s3_url(self): """ :type: string """ self._completeIfNotSet(self._s3_url) return self._s3_url.value @property def signature(self): """ :type: string """ self._completeIfNotSet(self._signature) return self._signature.value @property def size(self): """ :type: integer """ self._completeIfNotSet(self._size) return self._size.value @property def url(self): """ :type: string """ self._completeIfNotSet(self._url) return self._url.value def delete(self): """ :calls: `DELETE /repos/{owner}/{repo}/downloads/{id} `_ :rtype: None """ headers, data = self._requester.requestJsonAndCheck("DELETE", self.url) def _initAttributes(self): self._accesskeyid = github.GithubObject.NotSet self._acl = github.GithubObject.NotSet self._bucket = github.GithubObject.NotSet self._content_type = github.GithubObject.NotSet self._created_at = github.GithubObject.NotSet self._description = github.GithubObject.NotSet self._download_count = github.GithubObject.NotSet self._expirationdate = github.GithubObject.NotSet self._html_url = github.GithubObject.NotSet self._id = github.GithubObject.NotSet self._mime_type = github.GithubObject.NotSet self._name = github.GithubObject.NotSet self._path = github.GithubObject.NotSet self._policy = github.GithubObject.NotSet self._prefix = github.GithubObject.NotSet self._redirect = github.GithubObject.NotSet self._s3_url = github.GithubObject.NotSet self._signature = github.GithubObject.NotSet self._size = github.GithubObject.NotSet self._url = github.GithubObject.NotSet def _useAttributes(self, attributes): if "accesskeyid" in attributes: # pragma no branch self._accesskeyid = self._makeStringAttribute( attributes["accesskeyid"] ) # pragma no cover (was covered only by create_download, which has been removed) if "acl" in attributes: # pragma no branch self._acl = self._makeStringAttribute( attributes["acl"] ) # pragma no cover (was covered only by create_download, which has been removed) if "bucket" in attributes: # pragma no branch self._bucket = self._makeStringAttribute( attributes["bucket"] ) # pragma no cover (was covered only by create_download, which has been removed) if "content_type" in attributes: # pragma no branch self._content_type = self._makeStringAttribute(attributes["content_type"]) if "created_at" in attributes: # pragma no branch self._created_at = self._makeDatetimeAttribute(attributes["created_at"]) if "description" in attributes: # pragma no branch self._description = self._makeStringAttribute(attributes["description"]) if "download_count" in attributes: # pragma no branch self._download_count = self._makeIntAttribute(attributes["download_count"]) if "expirationdate" in attributes: # pragma no branch self._expirationdate = self._makeDatetimeAttribute( attributes["expirationdate"] ) # pragma no cover (was covered only by create_download, which has been removed) if "html_url" in attributes: # pragma no branch self._html_url = self._makeStringAttribute(attributes["html_url"]) if "id" in attributes: # pragma no branch self._id = self._makeIntAttribute(attributes["id"]) if "mime_type" in attributes: # pragma no branch self._mime_type = self._makeStringAttribute( attributes["mime_type"] ) # pragma no cover (was covered only by create_download, which has been removed) if "name" in attributes: # pragma no branch self._name = self._makeStringAttribute(attributes["name"]) if "path" in attributes: # pragma no branch self._path = self._makeStringAttribute( attributes["path"] ) # pragma no cover (was covered only by create_download, which has been removed) if "policy" in attributes: # pragma no branch self._policy = self._makeStringAttribute( attributes["policy"] ) # pragma no cover (was covered only by create_download, which has been removed) if "prefix" in attributes: # pragma no branch self._prefix = self._makeStringAttribute( attributes["prefix"] ) # pragma no cover (was covered only by create_download, which has been removed) if "redirect" in attributes: # pragma no branch self._redirect = self._makeBoolAttribute( attributes["redirect"] ) # pragma no cover (was covered only by create_download, which has been removed) if "s3_url" in attributes: # pragma no branch self._s3_url = self._makeStringAttribute( attributes["s3_url"] ) # pragma no cover (was covered only by create_download, which has been removed) if "signature" in attributes: # pragma no branch self._signature = self._makeStringAttribute( attributes["signature"] ) # pragma no cover (was covered only by create_download, which has been removed) if "size" in attributes: # pragma no branch self._size = self._makeIntAttribute(attributes["size"]) if "url" in attributes: # pragma no branch self._url = self._makeStringAttribute(attributes["url"]) ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1619412308.0 PyGithub-1.55/github/Download.pyi0000644000175100001710000000276100000000000016321 0ustar00runnerdockerfrom datetime import datetime from typing import Any, Dict, Optional from github.GithubObject import CompletableGithubObject class Download(CompletableGithubObject): def __repr__(self) -> str: ... def _initAttributes(self) -> None: ... def _useAttributes(self, attributes: Dict[str, Any]) -> None: ... @property def accesskeyid(self) -> Optional[str]: ... @property def acl(self) -> Optional[str]: ... @property def bucket(self) -> Optional[str]: ... @property def content_type(self) -> Optional[str]: ... @property def created_at(self) -> Optional[datetime]: ... def delete(self) -> None: ... @property def description(self) -> Optional[str]: ... @property def download_count(self) -> Optional[int]: ... @property def expirationdate(self) -> Optional[datetime]: ... @property def html_url(self) -> Optional[str]: ... @property def id(self) -> int: ... @property def mime_type(self) -> Optional[str]: ... @property def name(self) -> Optional[str]: ... @property def path(self) -> Optional[str]: ... @property def policy(self) -> Optional[str]: ... @property def prefix(self) -> Optional[str]: ... @property def redirect(self) -> Optional[bool]: ... @property def s3_url(self) -> Optional[str]: ... @property def signature(self) -> Optional[str]: ... @property def size(self) -> Optional[int]: ... @property def url(self) -> Optional[str]: ... ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1619412308.0 PyGithub-1.55/github/Event.py0000644000175100001710000001251300000000000015456 0ustar00runnerdocker############################ Copyrights and license ############################ # # # Copyright 2012 Vincent Jacques # # Copyright 2012 Zearin # # Copyright 2013 AKFish # # Copyright 2013 Vincent Jacques # # Copyright 2013 martinqt # # Copyright 2014 Vincent Jacques # # Copyright 2016 Jannis Gebauer # # Copyright 2016 Peter Buckley # # Copyright 2018 sfdye # # # # This file is part of PyGithub. # # http://pygithub.readthedocs.io/ # # # # PyGithub is free software: you can redistribute it and/or modify it under # # the terms of the GNU Lesser General Public License as published by the Free # # Software Foundation, either version 3 of the License, or (at your option) # # any later version. # # # # PyGithub is distributed in the hope that it will be useful, but WITHOUT ANY # # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more # # details. # # # # You should have received a copy of the GNU Lesser General Public License # # along with PyGithub. If not, see . # # # ################################################################################ import github.GithubObject import github.NamedUser import github.Organization import github.Repository class Event(github.GithubObject.NonCompletableGithubObject): """ This class represents Events. The reference can be found here https://docs.github.com/en/rest/reference/activity#events """ def __repr__(self): return self.get__repr__({"id": self._id.value, "type": self._type.value}) @property def actor(self): """ :type: :class:`github.NamedUser.NamedUser` """ return self._actor.value @property def created_at(self): """ :type: datetime.datetime """ return self._created_at.value @property def id(self): """ :type: string """ return self._id.value @property def org(self): """ :type: :class:`github.Organization.Organization` """ return self._org.value @property def payload(self): """ :type: dict """ return self._payload.value @property def public(self): """ :type: bool """ return self._public.value @property def repo(self): """ :type: :class:`github.Repository.Repository` """ return self._repo.value @property def type(self): """ :type: string """ return self._type.value def _initAttributes(self): self._actor = github.GithubObject.NotSet self._created_at = github.GithubObject.NotSet self._id = github.GithubObject.NotSet self._org = github.GithubObject.NotSet self._payload = github.GithubObject.NotSet self._public = github.GithubObject.NotSet self._repo = github.GithubObject.NotSet self._type = github.GithubObject.NotSet def _useAttributes(self, attributes): if "actor" in attributes: # pragma no branch self._actor = self._makeClassAttribute( github.NamedUser.NamedUser, attributes["actor"] ) if "created_at" in attributes: # pragma no branch self._created_at = self._makeDatetimeAttribute(attributes["created_at"]) if "id" in attributes: # pragma no branch self._id = self._makeStringAttribute(attributes["id"]) if "org" in attributes: # pragma no branch self._org = self._makeClassAttribute( github.Organization.Organization, attributes["org"] ) if "payload" in attributes: # pragma no branch self._payload = self._makeDictAttribute(attributes["payload"]) if "public" in attributes: # pragma no branch self._public = self._makeBoolAttribute(attributes["public"]) if "repo" in attributes: # pragma no branch self._repo = self._makeClassAttribute( github.Repository.Repository, attributes["repo"] ) if "type" in attributes: # pragma no branch self._type = self._makeStringAttribute(attributes["type"]) ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1619412308.0 PyGithub-1.55/github/Event.pyi0000644000175100001710000000151200000000000015624 0ustar00runnerdockerfrom datetime import datetime from typing import Any, Dict from github.GithubObject import NonCompletableGithubObject from github.NamedUser import NamedUser from github.Organization import Organization from github.Repository import Repository class Event(NonCompletableGithubObject): def __repr__(self) -> str: ... def _initAttributes(self) -> None: ... def _useAttributes(self, attributes: Dict[str, Any]) -> None: ... @property def actor(self) -> NamedUser: ... @property def created_at(self) -> datetime: ... @property def id(self) -> str: ... @property def org(self) -> Organization: ... @property def payload(self) -> Dict[str, Any]: ... @property def public(self) -> bool: ... @property def repo(self) -> Repository: ... @property def type(self) -> str: ... ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1619412308.0 PyGithub-1.55/github/File.py0000644000175100001710000001424000000000000015253 0ustar00runnerdocker############################ Copyrights and license ############################ # # # Copyright 2012 Vincent Jacques # # Copyright 2012 Zearin # # Copyright 2013 AKFish # # Copyright 2013 Vincent Jacques # # Copyright 2014 Vincent Jacques # # Copyright 2016 Jannis Gebauer # # Copyright 2016 Jeffrey Melvin # # Copyright 2016 Peter Buckley # # Copyright 2017 Simon # # Copyright 2018 Wan Liuyang # # Copyright 2018 sfdye # # # # This file is part of PyGithub. # # http://pygithub.readthedocs.io/ # # # # PyGithub is free software: you can redistribute it and/or modify it under # # the terms of the GNU Lesser General Public License as published by the Free # # Software Foundation, either version 3 of the License, or (at your option) # # any later version. # # # # PyGithub is distributed in the hope that it will be useful, but WITHOUT ANY # # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more # # details. # # # # You should have received a copy of the GNU Lesser General Public License # # along with PyGithub. If not, see . # # # ################################################################################ import github.GithubObject class File(github.GithubObject.NonCompletableGithubObject): """ This class represents Files """ def __repr__(self): return self.get__repr__( {"sha": self._sha.value, "filename": self._filename.value} ) @property def additions(self): """ :type: integer """ return self._additions.value @property def blob_url(self): """ :type: string """ return self._blob_url.value @property def changes(self): """ :type: integer """ return self._changes.value @property def contents_url(self): """ :type: string """ return self._contents_url.value @property def deletions(self): """ :type: integer """ return self._deletions.value @property def filename(self): """ :type: string """ return self._filename.value @property def patch(self): """ :type: string """ return self._patch.value @property def previous_filename(self): """ :type: string """ return self._previous_filename.value @property def raw_url(self): """ :type: string """ return self._raw_url.value @property def sha(self): """ :type: string """ return self._sha.value @property def status(self): """ :type: string """ return self._status.value def _initAttributes(self): self._additions = github.GithubObject.NotSet self._blob_url = github.GithubObject.NotSet self._changes = github.GithubObject.NotSet self._contents_url = github.GithubObject.NotSet self._deletions = github.GithubObject.NotSet self._filename = github.GithubObject.NotSet self._patch = github.GithubObject.NotSet self._previous_filename = github.GithubObject.NotSet self._raw_url = github.GithubObject.NotSet self._sha = github.GithubObject.NotSet self._status = github.GithubObject.NotSet def _useAttributes(self, attributes): if "additions" in attributes: # pragma no branch self._additions = self._makeIntAttribute(attributes["additions"]) if "blob_url" in attributes: # pragma no branch self._blob_url = self._makeStringAttribute(attributes["blob_url"]) if "changes" in attributes: # pragma no branch self._changes = self._makeIntAttribute(attributes["changes"]) if "contents_url" in attributes: # pragma no branch self._contents_url = self._makeStringAttribute(attributes["contents_url"]) if "deletions" in attributes: # pragma no branch self._deletions = self._makeIntAttribute(attributes["deletions"]) if "filename" in attributes: # pragma no branch self._filename = self._makeStringAttribute(attributes["filename"]) if "patch" in attributes: # pragma no branch self._patch = self._makeStringAttribute(attributes["patch"]) if "previous_filename" in attributes: # pragma no branch self._previous_filename = self._makeStringAttribute( attributes["previous_filename"] ) if "raw_url" in attributes: # pragma no branch self._raw_url = self._makeStringAttribute(attributes["raw_url"]) if "sha" in attributes: # pragma no branch self._sha = self._makeStringAttribute(attributes["sha"]) if "status" in attributes: # pragma no branch self._status = self._makeStringAttribute(attributes["status"]) ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1619412308.0 PyGithub-1.55/github/File.pyi0000644000175100001710000000146400000000000015430 0ustar00runnerdockerfrom typing import Any, Dict from github.GithubObject import NonCompletableGithubObject class File(NonCompletableGithubObject): def __repr__(self) -> str: ... def _initAttributes(self) -> None: ... def _useAttributes(self, attributes: Dict[str, Any]) -> None: ... @property def additions(self) -> int: ... @property def blob_url(self) -> str: ... @property def changes(self) -> int: ... @property def contents_url(self) -> str: ... @property def deletions(self) -> int: ... @property def filename(self) -> str: ... @property def patch(self) -> str: ... @property def raw_url(self) -> str: ... @property def sha(self) -> str: ... @property def status(self) -> str: ... @property def previous_filename(self) -> str: ... ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1619412308.0 PyGithub-1.55/github/Gist.py0000644000175100001710000003423700000000000015312 0ustar00runnerdocker############################ Copyrights and license ############################ # # # Copyright 2012 Steve English # # Copyright 2012 Vincent Jacques # # Copyright 2012 Zearin # # Copyright 2013 AKFish # # Copyright 2013 Vincent Jacques # # Copyright 2014 Dale Jung # # Copyright 2014 Vincent Jacques # # Copyright 2016 Jannis Gebauer # # Copyright 2016 Peter Buckley # # Copyright 2018 Wan Liuyang # # Copyright 2018 sfdye # # Copyright 2018 羽 # # # # This file is part of PyGithub. # # http://pygithub.readthedocs.io/ # # # # PyGithub is free software: you can redistribute it and/or modify it under # # the terms of the GNU Lesser General Public License as published by the Free # # Software Foundation, either version 3 of the License, or (at your option) # # any later version. # # # # PyGithub is distributed in the hope that it will be useful, but WITHOUT ANY # # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more # # details. # # # # You should have received a copy of the GNU Lesser General Public License # # along with PyGithub. If not, see . # # # ################################################################################ import github.GistComment import github.GistFile import github.GistHistoryState import github.GithubObject import github.NamedUser import github.PaginatedList class Gist(github.GithubObject.CompletableGithubObject): """ This class represents Gists. The reference can be found here https://docs.github.com/en/rest/reference/gists """ def __repr__(self): return self.get__repr__({"id": self._id.value}) @property def comments(self): """ :type: integer """ self._completeIfNotSet(self._comments) return self._comments.value @property def comments_url(self): """ :type: string """ self._completeIfNotSet(self._comments_url) return self._comments_url.value @property def commits_url(self): """ :type: string """ self._completeIfNotSet(self._commits_url) return self._commits_url.value @property def created_at(self): """ :type: datetime.datetime """ self._completeIfNotSet(self._created_at) return self._created_at.value @property def description(self): """ :type: string """ self._completeIfNotSet(self._description) return self._description.value @property def files(self): """ :type: dict of string to :class:`github.GistFile.GistFile` """ self._completeIfNeeded() return self._files.value @property def fork_of(self): """ :type: :class:`github.Gist.Gist` """ self._completeIfNotSet(self._fork_of) return self._fork_of.value @property def forks(self): """ :type: list of :class:`github.Gist.Gist` """ self._completeIfNotSet(self._forks) return self._forks.value @property def forks_url(self): """ :type: string """ self._completeIfNotSet(self._forks_url) return self._forks_url.value @property def git_pull_url(self): """ :type: string """ self._completeIfNotSet(self._git_pull_url) return self._git_pull_url.value @property def git_push_url(self): """ :type: string """ self._completeIfNotSet(self._git_push_url) return self._git_push_url.value @property def history(self): """ :type: list of :class:`github.GistHistoryState.GistHistoryState` """ self._completeIfNotSet(self._history) return self._history.value @property def html_url(self): """ :type: string """ self._completeIfNotSet(self._html_url) return self._html_url.value @property def id(self): """ :type: string """ self._completeIfNotSet(self._id) return self._id.value @property def owner(self): """ :type: :class:`github.NamedUser.NamedUser` """ self._completeIfNotSet(self._owner) return self._owner.value @property def public(self): """ :type: bool """ self._completeIfNotSet(self._public) return self._public.value @property def updated_at(self): """ :type: datetime.datetime """ self._completeIfNotSet(self._updated_at) return self._updated_at.value @property def url(self): """ :type: string """ self._completeIfNotSet(self._url) return self._url.value @property def user(self): """ :type: :class:`github.NamedUser.NamedUser` """ self._completeIfNotSet(self._user) return self._user.value def create_comment(self, body): """ :calls: `POST /gists/{gist_id}/comments `_ :param body: string :rtype: :class:`github.GistComment.GistComment` """ assert isinstance(body, str), body post_parameters = { "body": body, } headers, data = self._requester.requestJsonAndCheck( "POST", f"{self.url}/comments", input=post_parameters ) return github.GistComment.GistComment( self._requester, headers, data, completed=True ) def create_fork(self): """ :calls: `POST /gists/{id}/forks `_ :rtype: :class:`github.Gist.Gist` """ headers, data = self._requester.requestJsonAndCheck("POST", f"{self.url}/forks") return Gist(self._requester, headers, data, completed=True) def delete(self): """ :calls: `DELETE /gists/{id} `_ :rtype: None """ headers, data = self._requester.requestJsonAndCheck("DELETE", self.url) def edit( self, description=github.GithubObject.NotSet, files=github.GithubObject.NotSet ): """ :calls: `PATCH /gists/{id} `_ :param description: string :param files: dict of string to :class:`github.InputFileContent.InputFileContent` :rtype: None """ assert description is github.GithubObject.NotSet or isinstance( description, str ), description assert files is github.GithubObject.NotSet or all( element is None or isinstance(element, github.InputFileContent) for element in files.values() ), files post_parameters = dict() if description is not github.GithubObject.NotSet: post_parameters["description"] = description if files is not github.GithubObject.NotSet: post_parameters["files"] = { key: None if value is None else value._identity for key, value in files.items() } headers, data = self._requester.requestJsonAndCheck( "PATCH", self.url, input=post_parameters ) self._useAttributes(data) def get_comment(self, id): """ :calls: `GET /gists/{gist_id}/comments/{id} `_ :param id: integer :rtype: :class:`github.GistComment.GistComment` """ assert isinstance(id, int), id headers, data = self._requester.requestJsonAndCheck( "GET", f"{self.url}/comments/{id}" ) return github.GistComment.GistComment( self._requester, headers, data, completed=True ) def get_comments(self): """ :calls: `GET /gists/{gist_id}/comments `_ :rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.GistComment.GistComment` """ return github.PaginatedList.PaginatedList( github.GistComment.GistComment, self._requester, f"{self.url}/comments", None, ) def is_starred(self): """ :calls: `GET /gists/{id}/star `_ :rtype: bool """ status, headers, data = self._requester.requestJson("GET", f"{self.url}/star") return status == 204 def reset_starred(self): """ :calls: `DELETE /gists/{id}/star `_ :rtype: None """ headers, data = self._requester.requestJsonAndCheck( "DELETE", f"{self.url}/star" ) def set_starred(self): """ :calls: `PUT /gists/{id}/star `_ :rtype: None """ headers, data = self._requester.requestJsonAndCheck("PUT", f"{self.url}/star") def _initAttributes(self): self._comments = github.GithubObject.NotSet self._comments_url = github.GithubObject.NotSet self._commits_url = github.GithubObject.NotSet self._created_at = github.GithubObject.NotSet self._description = github.GithubObject.NotSet self._files = github.GithubObject.NotSet self._fork_of = github.GithubObject.NotSet self._forks = github.GithubObject.NotSet self._forks_url = github.GithubObject.NotSet self._git_pull_url = github.GithubObject.NotSet self._git_push_url = github.GithubObject.NotSet self._history = github.GithubObject.NotSet self._html_url = github.GithubObject.NotSet self._id = github.GithubObject.NotSet self._owner = github.GithubObject.NotSet self._public = github.GithubObject.NotSet self._updated_at = github.GithubObject.NotSet self._url = github.GithubObject.NotSet self._user = github.GithubObject.NotSet def _useAttributes(self, attributes): if "comments" in attributes: # pragma no branch self._comments = self._makeIntAttribute(attributes["comments"]) if "comments_url" in attributes: # pragma no branch self._comments_url = self._makeStringAttribute(attributes["comments_url"]) if "commits_url" in attributes: # pragma no branch self._commits_url = self._makeStringAttribute(attributes["commits_url"]) if "created_at" in attributes: # pragma no branch self._created_at = self._makeDatetimeAttribute(attributes["created_at"]) if "description" in attributes: # pragma no branch self._description = self._makeStringAttribute(attributes["description"]) if "files" in attributes: # pragma no branch self._files = self._makeDictOfStringsToClassesAttribute( github.GistFile.GistFile, attributes["files"] ) if "fork_of" in attributes: # pragma no branch self._fork_of = self._makeClassAttribute(Gist, attributes["fork_of"]) if "forks" in attributes: # pragma no branch self._forks = self._makeListOfClassesAttribute(Gist, attributes["forks"]) if "forks_url" in attributes: # pragma no branch self._forks_url = self._makeStringAttribute(attributes["forks_url"]) if "git_pull_url" in attributes: # pragma no branch self._git_pull_url = self._makeStringAttribute(attributes["git_pull_url"]) if "git_push_url" in attributes: # pragma no branch self._git_push_url = self._makeStringAttribute(attributes["git_push_url"]) if "history" in attributes: # pragma no branch self._history = self._makeListOfClassesAttribute( github.GistHistoryState.GistHistoryState, attributes["history"] ) if "html_url" in attributes: # pragma no branch self._html_url = self._makeStringAttribute(attributes["html_url"]) if "id" in attributes: # pragma no branch self._id = self._makeStringAttribute(attributes["id"]) if "owner" in attributes: # pragma no branch self._owner = self._makeClassAttribute( github.NamedUser.NamedUser, attributes["owner"] ) if "public" in attributes: # pragma no branch self._public = self._makeBoolAttribute(attributes["public"]) if "updated_at" in attributes: # pragma no branch self._updated_at = self._makeDatetimeAttribute(attributes["updated_at"]) if "url" in attributes: # pragma no branch self._url = self._makeStringAttribute(attributes["url"]) if "user" in attributes: # pragma no branch self._user = self._makeClassAttribute( github.NamedUser.NamedUser, attributes["user"] ) ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1619412308.0 PyGithub-1.55/github/Gist.pyi0000644000175100001710000000420300000000000015451 0ustar00runnerdockerfrom datetime import datetime from typing import Any, Dict, List, Optional, Union from github.GistComment import GistComment from github.GistFile import GistFile from github.GistHistoryState import GistHistoryState from github.GithubObject import CompletableGithubObject, _NotSetType from github.InputFileContent import InputFileContent from github.NamedUser import NamedUser from github.PaginatedList import PaginatedList class Gist(CompletableGithubObject): def __repr__(self) -> str: ... def _initAttributes(self) -> None: ... def _useAttributes(self, attributes: Dict[str, Any]) -> None: ... @property def comments(self) -> int: ... @property def comments_url(self) -> str: ... @property def commits_url(self) -> str: ... def create_comment(self, body: str) -> GistComment: ... def create_fork(self) -> Gist: ... @property def created_at(self) -> datetime: ... def delete(self) -> None: ... @property def description(self) -> Optional[str]: ... def edit( self, description: Union[_NotSetType, str] = ..., files: Union[_NotSetType, Dict[str, Optional[InputFileContent]]] = ..., ) -> None: ... @property def files(self) -> Dict[str, GistFile]: ... @property def fork_of(self) -> Optional[Gist]: ... @property def forks(self) -> List[Gist]: ... @property def forks_url(self) -> str: ... def get_comment(self, id: int) -> GistComment: ... def get_comments(self) -> PaginatedList[GistComment]: ... @property def git_pull_url(self) -> str: ... @property def git_push_url(self) -> str: ... @property def history(self) -> List[GistHistoryState]: ... @property def html_url(self) -> str: ... @property def id(self) -> str: ... def is_starred(self) -> bool: ... @property def owner(self) -> NamedUser: ... @property def public(self) -> bool: ... def reset_starred(self) -> None: ... def set_starred(self) -> None: ... @property def updated_at(self) -> datetime: ... @property def url(self) -> str: ... @property def user(self) -> Optional[NamedUser]: ... ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1619412308.0 PyGithub-1.55/github/GistComment.py0000644000175100001710000001305500000000000016630 0ustar00runnerdocker############################ Copyrights and license ############################ # # # Copyright 2012 Vincent Jacques # # Copyright 2012 Zearin # # Copyright 2013 AKFish # # Copyright 2013 Vincent Jacques # # Copyright 2014 Vincent Jacques # # Copyright 2016 Jannis Gebauer # # Copyright 2016 Peter Buckley # # Copyright 2018 Wan Liuyang # # Copyright 2018 sfdye # # # # This file is part of PyGithub. # # http://pygithub.readthedocs.io/ # # # # PyGithub is free software: you can redistribute it and/or modify it under # # the terms of the GNU Lesser General Public License as published by the Free # # Software Foundation, either version 3 of the License, or (at your option) # # any later version. # # # # PyGithub is distributed in the hope that it will be useful, but WITHOUT ANY # # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more # # details. # # # # You should have received a copy of the GNU Lesser General Public License # # along with PyGithub. If not, see . # # # ################################################################################ import github.GithubObject import github.NamedUser class GistComment(github.GithubObject.CompletableGithubObject): """ This class represents GistComments. The reference can be found here https://docs.github.com/en/rest/reference/gists#comments """ def __repr__(self): return self.get__repr__({"id": self._id.value, "user": self._user.value}) @property def body(self): """ :type: string """ self._completeIfNotSet(self._body) return self._body.value @property def created_at(self): """ :type: datetime.datetime """ self._completeIfNotSet(self._created_at) return self._created_at.value @property def id(self): """ :type: integer """ self._completeIfNotSet(self._id) return self._id.value @property def updated_at(self): """ :type: datetime.datetime """ self._completeIfNotSet(self._updated_at) return self._updated_at.value @property def url(self): """ :type: string """ self._completeIfNotSet(self._url) return self._url.value @property def user(self): """ :type: :class:`github.NamedUser.NamedUser` """ self._completeIfNotSet(self._user) return self._user.value def delete(self): """ :calls: `DELETE /gists/{gist_id}/comments/{id} `_ :rtype: None """ headers, data = self._requester.requestJsonAndCheck("DELETE", self.url) def edit(self, body): """ :calls: `PATCH /gists/{gist_id}/comments/{id} `_ :param body: string :rtype: None """ assert isinstance(body, str), body post_parameters = { "body": body, } headers, data = self._requester.requestJsonAndCheck( "PATCH", self.url, input=post_parameters ) self._useAttributes(data) def _initAttributes(self): self._body = github.GithubObject.NotSet self._created_at = github.GithubObject.NotSet self._id = github.GithubObject.NotSet self._updated_at = github.GithubObject.NotSet self._url = github.GithubObject.NotSet self._user = github.GithubObject.NotSet def _useAttributes(self, attributes): if "body" in attributes: # pragma no branch self._body = self._makeStringAttribute(attributes["body"]) if "created_at" in attributes: # pragma no branch self._created_at = self._makeDatetimeAttribute(attributes["created_at"]) if "id" in attributes: # pragma no branch self._id = self._makeIntAttribute(attributes["id"]) if "updated_at" in attributes: # pragma no branch self._updated_at = self._makeDatetimeAttribute(attributes["updated_at"]) if "url" in attributes: # pragma no branch self._url = self._makeStringAttribute(attributes["url"]) if "user" in attributes: # pragma no branch self._user = self._makeClassAttribute( github.NamedUser.NamedUser, attributes["user"] ) ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1619412308.0 PyGithub-1.55/github/GistComment.pyi0000644000175100001710000000132000000000000016771 0ustar00runnerdockerfrom datetime import datetime from typing import Any, Dict from github.GithubObject import CompletableGithubObject from github.NamedUser import NamedUser class GistComment(CompletableGithubObject): def __repr__(self) -> str: ... def _initAttributes(self) -> None: ... def _useAttributes(self, attributes: Dict[str, Any]) -> None: ... @property def body(self) -> str: ... @property def created_at(self) -> datetime: ... @property def id(self) -> int: ... def delete(self) -> None: ... def edit(self, body: str) -> None: ... @property def updated_at(self) -> datetime: ... @property def url(self) -> str: ... @property def user(self) -> NamedUser: ... ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1619412308.0 PyGithub-1.55/github/GistFile.py0000644000175100001710000001054700000000000016110 0ustar00runnerdocker############################ Copyrights and license ############################ # # # Copyright 2012 Vincent Jacques # # Copyright 2012 Zearin # # Copyright 2013 AKFish # # Copyright 2013 Vincent Jacques # # Copyright 2014 Vincent Jacques # # Copyright 2016 Jannis Gebauer # # Copyright 2016 Peter Buckley # # Copyright 2018 Wan Liuyang # # Copyright 2018 sfdye # # # # This file is part of PyGithub. # # http://pygithub.readthedocs.io/ # # # # PyGithub is free software: you can redistribute it and/or modify it under # # the terms of the GNU Lesser General Public License as published by the Free # # Software Foundation, either version 3 of the License, or (at your option) # # any later version. # # # # PyGithub is distributed in the hope that it will be useful, but WITHOUT ANY # # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more # # details. # # # # You should have received a copy of the GNU Lesser General Public License # # along with PyGithub. If not, see . # # # ################################################################################ import github.GithubObject class GistFile(github.GithubObject.NonCompletableGithubObject): """ This class represents GistFiles """ def __repr__(self): return self.get__repr__({"filename": self._filename.value}) @property def content(self): """ :type: string """ return self._content.value @property def filename(self): """ :type: string """ return self._filename.value @property def language(self): """ :type: string """ return self._language.value @property def raw_url(self): """ :type: string """ return self._raw_url.value @property def size(self): """ :type: integer """ return self._size.value @property def type(self): """ :type: string """ return self._type.value def _initAttributes(self): self._content = github.GithubObject.NotSet self._filename = github.GithubObject.NotSet self._language = github.GithubObject.NotSet self._raw_url = github.GithubObject.NotSet self._size = github.GithubObject.NotSet self._type = github.GithubObject.NotSet def _useAttributes(self, attributes): if "content" in attributes: # pragma no branch self._content = self._makeStringAttribute(attributes["content"]) if "filename" in attributes: # pragma no branch self._filename = self._makeStringAttribute(attributes["filename"]) if "language" in attributes: # pragma no branch self._language = self._makeStringAttribute(attributes["language"]) if "raw_url" in attributes: # pragma no branch self._raw_url = self._makeStringAttribute(attributes["raw_url"]) if "size" in attributes: # pragma no branch self._size = self._makeIntAttribute(attributes["size"]) if "type" in attributes: # pragma no branch self._type = self._makeStringAttribute(attributes["type"]) ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1619412308.0 PyGithub-1.55/github/GistFile.pyi0000644000175100001710000000111200000000000016245 0ustar00runnerdockerfrom typing import Any, Dict, Optional from github.GithubObject import NonCompletableGithubObject class GistFile(NonCompletableGithubObject): def __repr__(self) -> str: ... def _initAttributes(self) -> None: ... def _useAttributes(self, attributes: Dict[str, Any]) -> None: ... @property def content(self) -> str: ... @property def filename(self) -> str: ... @property def language(self) -> Optional[str]: ... @property def raw_url(self) -> str: ... @property def size(self) -> int: ... @property def type(self) -> str: ... ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1619412308.0 PyGithub-1.55/github/GistHistoryState.py0000644000175100001710000002463700000000000017700 0ustar00runnerdocker############################ Copyrights and license ############################ # # # Copyright 2012 Vincent Jacques # # Copyright 2012 Zearin # # Copyright 2013 AKFish # # Copyright 2013 Vincent Jacques # # Copyright 2014 Vincent Jacques # # Copyright 2016 Peter Buckley # # Copyright 2018 Wan Liuyang # # Copyright 2018 sfdye # # # # This file is part of PyGithub. # # http://pygithub.readthedocs.io/ # # # # PyGithub is free software: you can redistribute it and/or modify it under # # the terms of the GNU Lesser General Public License as published by the Free # # Software Foundation, either version 3 of the License, or (at your option) # # any later version. # # # # PyGithub is distributed in the hope that it will be useful, but WITHOUT ANY # # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more # # details. # # # # You should have received a copy of the GNU Lesser General Public License # # along with PyGithub. If not, see . # # # ################################################################################ import github.CommitStats import github.Gist import github.GithubObject import github.NamedUser class GistHistoryState(github.GithubObject.CompletableGithubObject): """ This class represents GistHistoryStates """ @property def change_status(self): """ :type: :class:`github.CommitStats.CommitStats` """ self._completeIfNotSet(self._change_status) return self._change_status.value @property def comments(self): """ :type: integer """ self._completeIfNotSet(self._comments) return self._comments.value @property def comments_url(self): """ :type: string """ self._completeIfNotSet(self._comments_url) return self._comments_url.value @property def commits_url(self): """ :type: string """ self._completeIfNotSet(self._commits_url) return self._commits_url.value @property def committed_at(self): """ :type: datetime.datetime """ self._completeIfNotSet(self._committed_at) return self._committed_at.value @property def created_at(self): """ :type: datetime.datetime """ self._completeIfNotSet(self._created_at) return self._created_at.value @property def description(self): """ :type: string """ self._completeIfNotSet(self._description) return self._description.value @property def files(self): """ :type: dict of string to :class:`github.GistFile.GistFile` """ self._completeIfNotSet(self._files) return self._files.value @property def forks(self): """ :type: list of :class:`github.Gist.Gist` """ self._completeIfNotSet(self._forks) return self._forks.value @property def forks_url(self): """ :type: string """ self._completeIfNotSet(self._forks_url) return self._forks_url.value @property def git_pull_url(self): """ :type: string """ self._completeIfNotSet(self._git_pull_url) return self._git_pull_url.value @property def git_push_url(self): """ :type: string """ self._completeIfNotSet(self._git_push_url) return self._git_push_url.value @property def history(self): """ :type: list of :class:`GistHistoryState` """ self._completeIfNotSet(self._history) return self._history.value @property def html_url(self): """ :type: string """ self._completeIfNotSet(self._html_url) return self._html_url.value @property def id(self): """ :type: string """ self._completeIfNotSet(self._id) return self._id.value @property def owner(self): """ :type: :class:`github.NamedUser.NamedUser` """ self._completeIfNotSet(self._owner) return self._owner.value @property def public(self): """ :type: bool """ self._completeIfNotSet(self._public) return self._public.value @property def updated_at(self): """ :type: datetime.datetime """ self._completeIfNotSet(self._updated_at) return self._updated_at.value @property def url(self): """ :type: string """ self._completeIfNotSet(self._url) return self._url.value @property def user(self): """ :type: :class:`github.NamedUser.NamedUser` """ self._completeIfNotSet(self._user) return self._user.value @property def version(self): """ :type: string """ self._completeIfNotSet(self._version) return self._version.value def _initAttributes(self): self._change_status = github.GithubObject.NotSet self._comments = github.GithubObject.NotSet self._comments_url = github.GithubObject.NotSet self._commits_url = github.GithubObject.NotSet self._committed_at = github.GithubObject.NotSet self._created_at = github.GithubObject.NotSet self._description = github.GithubObject.NotSet self._files = github.GithubObject.NotSet self._forks = github.GithubObject.NotSet self._forks_url = github.GithubObject.NotSet self._git_pull_url = github.GithubObject.NotSet self._git_push_url = github.GithubObject.NotSet self._history = github.GithubObject.NotSet self._html_url = github.GithubObject.NotSet self._id = github.GithubObject.NotSet self._owner = github.GithubObject.NotSet self._public = github.GithubObject.NotSet self._updated_at = github.GithubObject.NotSet self._url = github.GithubObject.NotSet self._user = github.GithubObject.NotSet self._version = github.GithubObject.NotSet def _useAttributes(self, attributes): if "change_status" in attributes: # pragma no branch self._change_status = self._makeClassAttribute( github.CommitStats.CommitStats, attributes["change_status"] ) if "comments" in attributes: # pragma no branch self._comments = self._makeIntAttribute(attributes["comments"]) if "comments_url" in attributes: # pragma no branch self._comments_url = self._makeStringAttribute(attributes["comments_url"]) if "commits_url" in attributes: # pragma no branch self._commits_url = self._makeStringAttribute(attributes["commits_url"]) if "committed_at" in attributes: # pragma no branch self._committed_at = self._makeDatetimeAttribute(attributes["committed_at"]) if "created_at" in attributes: # pragma no branch self._created_at = self._makeDatetimeAttribute(attributes["created_at"]) if "description" in attributes: # pragma no branch self._description = self._makeStringAttribute(attributes["description"]) if "files" in attributes: # pragma no branch self._files = self._makeDictOfStringsToClassesAttribute( github.GistFile.GistFile, attributes["files"] ) if "forks" in attributes: # pragma no branch self._forks = self._makeListOfClassesAttribute( github.Gist.Gist, attributes["forks"] ) if "forks_url" in attributes: # pragma no branch self._forks_url = self._makeStringAttribute(attributes["forks_url"]) if "git_pull_url" in attributes: # pragma no branch self._git_pull_url = self._makeStringAttribute(attributes["git_pull_url"]) if "git_push_url" in attributes: # pragma no branch self._git_push_url = self._makeStringAttribute(attributes["git_push_url"]) if "history" in attributes: # pragma no branch self._history = self._makeListOfClassesAttribute( GistHistoryState, attributes["history"] ) if "html_url" in attributes: # pragma no branch self._html_url = self._makeStringAttribute(attributes["html_url"]) if "id" in attributes: # pragma no branch self._id = self._makeStringAttribute(attributes["id"]) if "owner" in attributes: # pragma no branch self._owner = self._makeClassAttribute( github.NamedUser.NamedUser, attributes["owner"] ) if "public" in attributes: # pragma no branch self._public = self._makeBoolAttribute(attributes["public"]) if "updated_at" in attributes: # pragma no branch self._updated_at = self._makeDatetimeAttribute(attributes["updated_at"]) if "url" in attributes: # pragma no branch self._url = self._makeStringAttribute(attributes["url"]) if "user" in attributes: # pragma no branch self._user = self._makeClassAttribute( github.NamedUser.NamedUser, attributes["user"] ) if "version" in attributes: # pragma no branch self._version = self._makeStringAttribute(attributes["version"]) ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1619412308.0 PyGithub-1.55/github/GistHistoryState.pyi0000644000175100001710000000303400000000000020035 0ustar00runnerdockerfrom datetime import datetime from typing import Any, Dict, List, Optional from github.CommitStats import CommitStats from github.Gist import Gist from github.GistFile import GistFile from github.GithubObject import CompletableGithubObject from github.NamedUser import NamedUser class GistHistoryState(CompletableGithubObject): def _initAttributes(self) -> None: ... def _useAttributes(self, attributes: Dict[str, Any]) -> None: ... @property def change_status(self) -> CommitStats: ... @property def comments(self) -> int: ... @property def comments_url(self) -> str: ... @property def commits_url(self) -> str: ... @property def committed_at(self) -> datetime: ... @property def created_at(self) -> datetime: ... @property def description(self) -> str: ... @property def files(self) -> Dict[str, GistFile]: ... @property def forks(self) -> List[Gist]: ... @property def forks_url(self) -> str: ... @property def git_pull_url(self) -> str: ... @property def git_push_url(self) -> str: ... @property def history(self) -> List[GistHistoryState]: ... @property def html_url(self) -> str: ... @property def id(self) -> str: ... @property def owner(self) -> NamedUser: ... @property def public(self) -> bool: ... @property def updated_at(self) -> datetime: ... @property def url(self) -> str: ... @property def user(self) -> Optional[NamedUser]: ... @property def version(self) -> str: ... ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1619412308.0 PyGithub-1.55/github/GitAuthor.py0000644000175100001710000000671300000000000016310 0ustar00runnerdocker############################ Copyrights and license ############################ # # # Copyright 2012 Vincent Jacques # # Copyright 2012 Zearin # # Copyright 2013 AKFish # # Copyright 2013 Vincent Jacques # # Copyright 2014 Vincent Jacques # # Copyright 2016 Jannis Gebauer # # Copyright 2016 Peter Buckley # # Copyright 2018 Wan Liuyang # # Copyright 2018 sfdye # # # # This file is part of PyGithub. # # http://pygithub.readthedocs.io/ # # # # PyGithub is free software: you can redistribute it and/or modify it under # # the terms of the GNU Lesser General Public License as published by the Free # # Software Foundation, either version 3 of the License, or (at your option) # # any later version. # # # # PyGithub is distributed in the hope that it will be useful, but WITHOUT ANY # # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more # # details. # # # # You should have received a copy of the GNU Lesser General Public License # # along with PyGithub. If not, see . # # # ################################################################################ import github.GithubObject class GitAuthor(github.GithubObject.NonCompletableGithubObject): """ This class represents GitAuthors """ def __repr__(self): return self.get__repr__({"name": self._name.value}) @property def date(self): """ :type: datetime.datetime """ return self._date.value @property def email(self): """ :type: string """ return self._email.value @property def name(self): """ :type: string """ return self._name.value def _initAttributes(self): self._date = github.GithubObject.NotSet self._email = github.GithubObject.NotSet self._name = github.GithubObject.NotSet def _useAttributes(self, attributes): if "date" in attributes: # pragma no branch self._date = self._makeDatetimeAttribute(attributes["date"]) if "email" in attributes: # pragma no branch self._email = self._makeStringAttribute(attributes["email"]) if "name" in attributes: # pragma no branch self._name = self._makeStringAttribute(attributes["name"]) ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1619412308.0 PyGithub-1.55/github/GitAuthor.pyi0000644000175100001710000000070100000000000016450 0ustar00runnerdockerfrom datetime import datetime from typing import Dict from github.GithubObject import NonCompletableGithubObject class GitAuthor(NonCompletableGithubObject): def __repr__(self) -> str: ... def _initAttributes(self) -> None: ... def _useAttributes(self, attributes: Dict[str, str]) -> None: ... @property def date(self) -> datetime: ... @property def email(self) -> str: ... @property def name(self) -> str: ... ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1619412308.0 PyGithub-1.55/github/GitBlob.py0000644000175100001710000001046600000000000015724 0ustar00runnerdocker############################ Copyrights and license ############################ # # # Copyright 2012 Vincent Jacques # # Copyright 2012 Zearin # # Copyright 2013 AKFish # # Copyright 2013 Vincent Jacques # # Copyright 2014 Vincent Jacques # # Copyright 2016 Jannis Gebauer # # Copyright 2016 Peter Buckley # # Copyright 2018 Wan Liuyang # # Copyright 2018 sfdye # # # # This file is part of PyGithub. # # http://pygithub.readthedocs.io/ # # # # PyGithub is free software: you can redistribute it and/or modify it under # # the terms of the GNU Lesser General Public License as published by the Free # # Software Foundation, either version 3 of the License, or (at your option) # # any later version. # # # # PyGithub is distributed in the hope that it will be useful, but WITHOUT ANY # # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more # # details. # # # # You should have received a copy of the GNU Lesser General Public License # # along with PyGithub. If not, see . # # # ################################################################################ import github.GithubObject class GitBlob(github.GithubObject.CompletableGithubObject): """ This class represents GitBlobs. The reference can be found here https://docs.github.com/en/rest/reference/git#blobs """ def __repr__(self): return self.get__repr__({"sha": self._sha.value}) @property def content(self): """ :type: string """ self._completeIfNotSet(self._content) return self._content.value @property def encoding(self): """ :type: string """ self._completeIfNotSet(self._encoding) return self._encoding.value @property def sha(self): """ :type: string """ self._completeIfNotSet(self._sha) return self._sha.value @property def size(self): """ :type: integer """ self._completeIfNotSet(self._size) return self._size.value @property def url(self): """ :type: string """ self._completeIfNotSet(self._url) return self._url.value def _initAttributes(self): self._content = github.GithubObject.NotSet self._encoding = github.GithubObject.NotSet self._sha = github.GithubObject.NotSet self._size = github.GithubObject.NotSet self._url = github.GithubObject.NotSet def _useAttributes(self, attributes): if "content" in attributes: # pragma no branch self._content = self._makeStringAttribute(attributes["content"]) if "encoding" in attributes: # pragma no branch self._encoding = self._makeStringAttribute(attributes["encoding"]) if "sha" in attributes: # pragma no branch self._sha = self._makeStringAttribute(attributes["sha"]) if "size" in attributes: # pragma no branch self._size = self._makeIntAttribute(attributes["size"]) if "url" in attributes: # pragma no branch self._url = self._makeStringAttribute(attributes["url"]) ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1619412308.0 PyGithub-1.55/github/GitBlob.pyi0000644000175100001710000000077100000000000016073 0ustar00runnerdockerfrom typing import Any, Dict from github.GithubObject import CompletableGithubObject class GitBlob(CompletableGithubObject): def __repr__(self) -> str: ... def _initAttributes(self) -> None: ... def _useAttributes(self, attributes: Dict[str, Any]) -> None: ... @property def content(self) -> str: ... @property def encoding(self) -> str: ... @property def sha(self) -> str: ... @property def size(self) -> int: ... @property def url(self) -> str: ... ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1619412308.0 PyGithub-1.55/github/GitCommit.py0000644000175100001710000001343100000000000016271 0ustar00runnerdocker############################ Copyrights and license ############################ # # # Copyright 2012 Vincent Jacques # # Copyright 2012 Zearin # # Copyright 2013 AKFish # # Copyright 2013 Vincent Jacques # # Copyright 2014 Vincent Jacques # # Copyright 2016 Jannis Gebauer # # Copyright 2016 Peter Buckley # # Copyright 2018 Wan Liuyang # # Copyright 2018 sfdye # # # # This file is part of PyGithub. # # http://pygithub.readthedocs.io/ # # # # PyGithub is free software: you can redistribute it and/or modify it under # # the terms of the GNU Lesser General Public License as published by the Free # # Software Foundation, either version 3 of the License, or (at your option) # # any later version. # # # # PyGithub is distributed in the hope that it will be useful, but WITHOUT ANY # # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more # # details. # # # # You should have received a copy of the GNU Lesser General Public License # # along with PyGithub. If not, see . # # # ################################################################################ import github.GitAuthor import github.GithubObject import github.GitTree class GitCommit(github.GithubObject.CompletableGithubObject): """ This class represents GitCommits. The reference can be found here https://docs.github.com/en/rest/reference/git#commits """ def __repr__(self): return self.get__repr__({"sha": self._sha.value}) @property def author(self): """ :type: :class:`github.GitAuthor.GitAuthor` """ self._completeIfNotSet(self._author) return self._author.value @property def committer(self): """ :type: :class:`github.GitAuthor.GitAuthor` """ self._completeIfNotSet(self._committer) return self._committer.value @property def html_url(self): """ :type: string """ self._completeIfNotSet(self._html_url) return self._html_url.value @property def message(self): """ :type: string """ self._completeIfNotSet(self._message) return self._message.value @property def parents(self): """ :type: list of :class:`github.GitCommit.GitCommit` """ self._completeIfNotSet(self._parents) return self._parents.value @property def sha(self): """ :type: string """ self._completeIfNotSet(self._sha) return self._sha.value @property def tree(self): """ :type: :class:`github.GitTree.GitTree` """ self._completeIfNotSet(self._tree) return self._tree.value @property def url(self): """ :type: string """ self._completeIfNotSet(self._url) return self._url.value @property def _identity(self): return self.sha def _initAttributes(self): self._author = github.GithubObject.NotSet self._committer = github.GithubObject.NotSet self._html_url = github.GithubObject.NotSet self._message = github.GithubObject.NotSet self._parents = github.GithubObject.NotSet self._sha = github.GithubObject.NotSet self._tree = github.GithubObject.NotSet self._url = github.GithubObject.NotSet def _useAttributes(self, attributes): if "author" in attributes: # pragma no branch self._author = self._makeClassAttribute( github.GitAuthor.GitAuthor, attributes["author"] ) if "committer" in attributes: # pragma no branch self._committer = self._makeClassAttribute( github.GitAuthor.GitAuthor, attributes["committer"] ) if "html_url" in attributes: # pragma no branch self._html_url = self._makeStringAttribute(attributes["html_url"]) if "message" in attributes: # pragma no branch self._message = self._makeStringAttribute(attributes["message"]) if "parents" in attributes: # pragma no branch self._parents = self._makeListOfClassesAttribute( GitCommit, attributes["parents"] ) if "sha" in attributes: # pragma no branch self._sha = self._makeStringAttribute(attributes["sha"]) if "tree" in attributes: # pragma no branch self._tree = self._makeClassAttribute( github.GitTree.GitTree, attributes["tree"] ) if "url" in attributes: # pragma no branch self._url = self._makeStringAttribute(attributes["url"]) ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1619412308.0 PyGithub-1.55/github/GitCommit.pyi0000644000175100001710000000145200000000000016442 0ustar00runnerdockerfrom typing import Any, Dict, List from github.GitAuthor import GitAuthor from github.GithubObject import CompletableGithubObject from github.GitTree import GitTree class GitCommit(CompletableGithubObject): def __repr__(self) -> str: ... @property def _identity(self) -> str: ... def _initAttributes(self) -> None: ... def _useAttributes(self, attributes: Dict[str, Any]) -> None: ... @property def author(self) -> GitAuthor: ... @property def committer(self) -> GitAuthor: ... @property def html_url(self) -> str: ... @property def message(self) -> str: ... @property def parents(self) -> List[GitCommit]: ... @property def sha(self) -> str: ... @property def tree(self) -> GitTree: ... @property def url(self) -> str: ... ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1619412308.0 PyGithub-1.55/github/GitObject.py0000644000175100001710000000665200000000000016256 0ustar00runnerdocker############################ Copyrights and license ############################ # # # Copyright 2012 Vincent Jacques # # Copyright 2012 Zearin # # Copyright 2013 AKFish # # Copyright 2013 Vincent Jacques # # Copyright 2014 Vincent Jacques # # Copyright 2016 Jannis Gebauer # # Copyright 2016 Peter Buckley # # Copyright 2018 Wan Liuyang # # Copyright 2018 sfdye # # # # This file is part of PyGithub. # # http://pygithub.readthedocs.io/ # # # # PyGithub is free software: you can redistribute it and/or modify it under # # the terms of the GNU Lesser General Public License as published by the Free # # Software Foundation, either version 3 of the License, or (at your option) # # any later version. # # # # PyGithub is distributed in the hope that it will be useful, but WITHOUT ANY # # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more # # details. # # # # You should have received a copy of the GNU Lesser General Public License # # along with PyGithub. If not, see . # # # ################################################################################ import github.GithubObject class GitObject(github.GithubObject.NonCompletableGithubObject): """ This class represents GitObjects """ def __repr__(self): return self.get__repr__({"sha": self._sha.value}) @property def sha(self): """ :type: string """ return self._sha.value @property def type(self): """ :type: string """ return self._type.value @property def url(self): """ :type: string """ return self._url.value def _initAttributes(self): self._sha = github.GithubObject.NotSet self._type = github.GithubObject.NotSet self._url = github.GithubObject.NotSet def _useAttributes(self, attributes): if "sha" in attributes: # pragma no branch self._sha = self._makeStringAttribute(attributes["sha"]) if "type" in attributes: # pragma no branch self._type = self._makeStringAttribute(attributes["type"]) if "url" in attributes: # pragma no branch self._url = self._makeStringAttribute(attributes["url"]) ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1619412308.0 PyGithub-1.55/github/GitObject.pyi0000644000175100001710000000057000000000000016420 0ustar00runnerdockerfrom typing import Dict from github.GithubObject import NonCompletableGithubObject class GitObject(NonCompletableGithubObject): def _initAttributes(self) -> None: ... def _useAttributes(self, attributes: Dict[str, str]) -> None: ... @property def sha(self) -> str: ... @property def type(self) -> str: ... @property def url(self) -> str: ... ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1619412308.0 PyGithub-1.55/github/GitRef.py0000644000175100001710000001130300000000000015551 0ustar00runnerdocker############################ Copyrights and license ############################ # # # Copyright 2012 Vincent Jacques # # Copyright 2012 Zearin # # Copyright 2013 AKFish # # Copyright 2013 Vincent Jacques # # Copyright 2014 Vincent Jacques # # Copyright 2016 Jannis Gebauer # # Copyright 2016 Peter Buckley # # Copyright 2018 Wan Liuyang # # Copyright 2018 sfdye # # # # This file is part of PyGithub. # # http://pygithub.readthedocs.io/ # # # # PyGithub is free software: you can redistribute it and/or modify it under # # the terms of the GNU Lesser General Public License as published by the Free # # Software Foundation, either version 3 of the License, or (at your option) # # any later version. # # # # PyGithub is distributed in the hope that it will be useful, but WITHOUT ANY # # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more # # details. # # # # You should have received a copy of the GNU Lesser General Public License # # along with PyGithub. If not, see . # # # ################################################################################ import github.GithubObject import github.GitObject class GitRef(github.GithubObject.CompletableGithubObject): """ This class represents GitRefs. The reference can be found here https://docs.github.com/en/rest/reference/git#refs """ def __repr__(self): return self.get__repr__({"ref": self._ref.value}) @property def object(self): """ :type: :class:`github.GitObject.GitObject` """ self._completeIfNotSet(self._object) return self._object.value @property def ref(self): """ :type: string """ self._completeIfNotSet(self._ref) return self._ref.value @property def url(self): """ :type: string """ self._completeIfNotSet(self._url) return self._url.value def delete(self): """ :calls: `DELETE /repos/{owner}/{repo}/git/refs/{ref} `_ :rtype: None """ headers, data = self._requester.requestJsonAndCheck("DELETE", self.url) def edit(self, sha, force=github.GithubObject.NotSet): """ :calls: `PATCH /repos/{owner}/{repo}/git/refs/{ref} `_ :param sha: string :param force: bool :rtype: None """ assert isinstance(sha, str), sha assert force is github.GithubObject.NotSet or isinstance(force, bool), force post_parameters = { "sha": sha, } if force is not github.GithubObject.NotSet: post_parameters["force"] = force headers, data = self._requester.requestJsonAndCheck( "PATCH", self.url, input=post_parameters ) self._useAttributes(data) def _initAttributes(self): self._object = github.GithubObject.NotSet self._ref = github.GithubObject.NotSet self._url = github.GithubObject.NotSet def _useAttributes(self, attributes): if "object" in attributes: # pragma no branch self._object = self._makeClassAttribute( github.GitObject.GitObject, attributes["object"] ) if "ref" in attributes: # pragma no branch self._ref = self._makeStringAttribute(attributes["ref"]) if "url" in attributes: # pragma no branch self._url = self._makeStringAttribute(attributes["url"]) ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1619412308.0 PyGithub-1.55/github/GitRef.pyi0000644000175100001710000000111500000000000015722 0ustar00runnerdockerfrom typing import Any, Dict, Union from github.GithubObject import CompletableGithubObject, _NotSetType from github.GitObject import GitObject class GitRef(CompletableGithubObject): def __repr__(self) -> str: ... def _initAttributes(self) -> None: ... def _useAttributes(self, attributes: Dict[str, Any]) -> None: ... def delete(self) -> None: ... def edit(self, sha: str, force: Union[bool, _NotSetType] = ...) -> None: ... @property def object(self) -> GitObject: ... @property def ref(self) -> str: ... @property def url(self) -> str: ... ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1619412308.0 PyGithub-1.55/github/GitRelease.py0000644000175100001710000003414100000000000016422 0ustar00runnerdocker############################ Copyrights and license ############################ # # # Copyright 2015 Ed Holland # # Copyright 2016 Benjamin Whitney # # Copyright 2016 Jannis Gebauer # # Copyright 2016 Peter Buckley # # Copyright 2017 Chris McBride # # Copyright 2017 Simon # # Copyright 2018 Daniel Kesler # # Copyright 2018 Kuba # # Copyright 2018 Maarten Fonville # # Copyright 2018 Shinichi TAMURA # # Copyright 2018 Wan Liuyang # # Copyright 2018 edquist # # Copyright 2018 nurupo # # Copyright 2018 sfdye # # # # This file is part of PyGithub. # # http://pygithub.readthedocs.io/ # # # # PyGithub is free software: you can redistribute it and/or modify it under # # the terms of the GNU Lesser General Public License as published by the Free # # Software Foundation, either version 3 of the License, or (at your option) # # any later version. # # # # PyGithub is distributed in the hope that it will be useful, but WITHOUT ANY # # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more # # details. # # # # You should have received a copy of the GNU Lesser General Public License # # along with PyGithub. If not, see . # # # ################################################################################ from os.path import basename import github.GithubObject import github.GitReleaseAsset import github.NamedUser from . import Consts class GitRelease(github.GithubObject.CompletableGithubObject): """ This class represents GitReleases. The reference can be found here https://docs.github.com/en/rest/reference/repos#releases """ def __repr__(self): return self.get__repr__({"title": self._title.value}) @property def id(self): """ :type: integer """ self._completeIfNotSet(self._id) return self._id.value @property def body(self): """ :type: string """ self._completeIfNotSet(self._body) return self._body.value @property def title(self): """ :type: string """ self._completeIfNotSet(self._title) return self._title.value @property def tag_name(self): """ :type: string """ self._completeIfNotSet(self._tag_name) return self._tag_name.value @property def target_commitish(self): """ :type: string """ self._completeIfNotSet(self._target_commitish) return self._target_commitish.value @property def draft(self): """ :type: bool """ self._completeIfNotSet(self._draft) return self._draft.value @property def prerelease(self): """ :type: bool """ self._completeIfNotSet(self._prerelease) return self._prerelease.value @property def author(self): """ :type: :class:`github.NamedUser.NamedUser` """ self._completeIfNotSet(self._author) return self._author.value @property def created_at(self): """ :type: datetime.datetime """ self._completeIfNotSet(self._created_at) return self._created_at.value @property def published_at(self): """ :type: datetime.datetime """ self._completeIfNotSet(self._published_at) return self._published_at.value @property def url(self): """ :type: string """ self._completeIfNotSet(self._url) return self._url.value @property def upload_url(self): """ :type: string """ self._completeIfNotSet(self._upload_url) return self._upload_url.value @property def html_url(self): """ :type: string """ self._completeIfNotSet(self._html_url) return self._html_url.value @property def tarball_url(self): """ :type: string """ self._completeIfNotSet(self._tarball_url) return self._tarball_url.value @property def zipball_url(self): """ :type: string """ self._completeIfNotSet(self._zipball_url) return self._zipball_url.value def delete_release(self): """ :calls: `DELETE /repos/{owner}/{repo}/releases/{release_id} `_ :rtype: None """ headers, data = self._requester.requestJsonAndCheck("DELETE", self.url) def update_release( self, name, message, draft=False, prerelease=False, tag_name=github.GithubObject.NotSet, target_commitish=github.GithubObject.NotSet, ): """ :calls: `PATCH /repos/{owner}/{repo}/releases/{release_id} `_ :param name: string :param message: string :param draft: bool :param prerelease: bool :param tag_name: string :param target_commitish: string :rtype: :class:`github.GitRelease.GitRelease` """ assert tag_name is github.GithubObject.NotSet or isinstance( tag_name, str ), "tag_name must be a str/unicode object" assert target_commitish is github.GithubObject.NotSet or isinstance( target_commitish, str ), "target_commitish must be a str/unicode object" assert isinstance(name, str), name assert isinstance(message, str), message assert isinstance(draft, bool), draft assert isinstance(prerelease, bool), prerelease if tag_name is github.GithubObject.NotSet: tag_name = self.tag_name post_parameters = { "tag_name": tag_name, "name": name, "body": message, "draft": draft, "prerelease": prerelease, } # Do not set target_commitish to self.target_commitish when omitted, just don't send it # altogether in that case, in order to match the Github API behaviour. Only send it when set. if target_commitish is not github.GithubObject.NotSet: post_parameters["target_commitish"] = target_commitish headers, data = self._requester.requestJsonAndCheck( "PATCH", self.url, input=post_parameters ) return github.GitRelease.GitRelease( self._requester, headers, data, completed=True ) def upload_asset( self, path, label="", content_type=github.GithubObject.NotSet, name=github.GithubObject.NotSet, ): """ :calls: `POST https:///repos/{owner}/{repo}/releases/{release_id}/assets `_ :param path: string :param label: string :param content_type: string :param name: string :rtype: :class:`github.GitReleaseAsset.GitReleaseAsset` """ assert isinstance(path, str), path assert isinstance(label, str), label assert name is github.GithubObject.NotSet or isinstance(name, str), name post_parameters = {"label": label} if name is github.GithubObject.NotSet: post_parameters["name"] = basename(path) else: post_parameters["name"] = name headers = {} if content_type is not github.GithubObject.NotSet: headers["Content-Type"] = content_type resp_headers, data = self._requester.requestBlobAndCheck( "POST", self.upload_url.split("{?")[0], parameters=post_parameters, headers=headers, input=path, ) return github.GitReleaseAsset.GitReleaseAsset( self._requester, resp_headers, data, completed=True ) def upload_asset_from_memory( self, file_like, file_size, name, content_type=github.GithubObject.NotSet, label="", ): """Uploads an asset. Unlike ``upload_asset()`` this method allows you to pass in a file-like object to upload. Note that this method is more strict and requires you to specify the ``name``, since there's no file name to infer these from. :calls: `POST https:///repos/{owner}/{repo}/releases/{release_id}/assets `_ :param file_like: binary file-like object, such as those returned by ``open("file_name", "rb")``. At the very minimum, this object must implement ``read()``. :param file_size: int, size in bytes of ``file_like`` :param content_type: string :param name: string :param label: string :rtype: :class:`github.GitReleaseAsset.GitReleaseAsset` """ assert isinstance(name, str), name assert isinstance(file_size, int), file_size assert isinstance(label, str), label post_parameters = {"label": label, "name": name} content_type = ( content_type if content_type is not github.GithubObject.NotSet else Consts.defaultMediaType ) headers = {"Content-Type": content_type, "Content-Length": str(file_size)} resp_headers, data = self._requester.requestMemoryBlobAndCheck( "POST", self.upload_url.split("{?")[0], parameters=post_parameters, headers=headers, file_like=file_like, ) return github.GitReleaseAsset.GitReleaseAsset( self._requester, resp_headers, data, completed=True ) def get_assets(self): """ :calls: `GET /repos/{owner}/{repo}/releases/{release_id}/assets `_ :rtype: :class:`github.PaginatedList.PaginatedList` """ return github.PaginatedList.PaginatedList( github.GitReleaseAsset.GitReleaseAsset, self._requester, f"{self.url}/assets", None, ) def _initAttributes(self): self._id = github.GithubObject.NotSet self._body = github.GithubObject.NotSet self._title = github.GithubObject.NotSet self._tag_name = github.GithubObject.NotSet self._target_commitish = github.GithubObject.NotSet self._draft = github.GithubObject.NotSet self._prerelease = github.GithubObject.NotSet self._author = github.GithubObject.NotSet self._url = github.GithubObject.NotSet self._upload_url = github.GithubObject.NotSet self._html_url = github.GithubObject.NotSet self._created_at = github.GithubObject.NotSet self._published_at = github.GithubObject.NotSet self._tarball_url = github.GithubObject.NotSet self._zipball_url = github.GithubObject.NotSet def _useAttributes(self, attributes): if "id" in attributes: self._id = self._makeIntAttribute(attributes["id"]) if "body" in attributes: self._body = self._makeStringAttribute(attributes["body"]) if "name" in attributes: self._title = self._makeStringAttribute(attributes["name"]) if "tag_name" in attributes: self._tag_name = self._makeStringAttribute(attributes["tag_name"]) if "target_commitish" in attributes: self._target_commitish = self._makeStringAttribute( attributes["target_commitish"] ) if "draft" in attributes: self._draft = self._makeBoolAttribute(attributes["draft"]) if "prerelease" in attributes: self._prerelease = self._makeBoolAttribute(attributes["prerelease"]) if "author" in attributes: self._author = self._makeClassAttribute( github.NamedUser.NamedUser, attributes["author"] ) if "url" in attributes: self._url = self._makeStringAttribute(attributes["url"]) if "upload_url" in attributes: self._upload_url = self._makeStringAttribute(attributes["upload_url"]) if "html_url" in attributes: self._html_url = self._makeStringAttribute(attributes["html_url"]) if "created_at" in attributes: self._created_at = self._makeDatetimeAttribute(attributes["created_at"]) if "published_at" in attributes: self._published_at = self._makeDatetimeAttribute(attributes["published_at"]) if "tarball_url" in attributes: self._tarball_url = self._makeStringAttribute(attributes["tarball_url"]) if "zipball_url" in attributes: self._zipball_url = self._makeStringAttribute(attributes["zipball_url"]) ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1619412308.0 PyGithub-1.55/github/GitRelease.pyi0000644000175100001710000000341300000000000016571 0ustar00runnerdockerfrom datetime import datetime from typing import Any, Dict, Union from github.GithubObject import CompletableGithubObject, _NotSetType from github.GitReleaseAsset import GitReleaseAsset from github.NamedUser import NamedUser from github.PaginatedList import PaginatedList class GitRelease(CompletableGithubObject): def __repr__(self) -> str: ... def _initAttributes(self) -> None: ... def _useAttributes(self, attributes: Dict[str, Any]) -> None: ... @property def author(self) -> NamedUser: ... @property def body(self) -> str: ... @property def created_at(self) -> datetime: ... def delete_release(self) -> None: ... @property def draft(self) -> bool: ... def get_assets(self) -> PaginatedList[GitReleaseAsset]: ... @property def html_url(self) -> str: ... @property def id(self) -> int: ... @property def prerelease(self) -> bool: ... @property def published_at(self) -> datetime: ... @property def tag_name(self) -> str: ... @property def tarball_url(self) -> str: ... @property def target_commitish(self) -> str: ... @property def title(self) -> str: ... def update_release( self, name: str, message: str, draft: bool = ..., prerelease: bool = ..., tag_name: Union[str, _NotSetType] = ..., target_commitish: Union[str, _NotSetType] = ..., ) -> GitRelease: ... def upload_asset( self, path: str, label: str = ..., content_type: Union[_NotSetType, str] = ..., name: Union[_NotSetType, str] = ..., ) -> GitReleaseAsset: ... @property def upload_url(self) -> str: ... @property def url(self) -> str: ... @property def zipball_url(self) -> str: ... ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1619412308.0 PyGithub-1.55/github/GitReleaseAsset.py0000644000175100001710000001642600000000000017430 0ustar00runnerdocker############################ Copyrights and license ############################ # # # Copyright 2017 Chris McBride # # Copyright 2017 Simon # # Copyright 2018 Wan Liuyang # # Copyright 2018 sfdye # # # # This file is part of PyGithub. # # http://pygithub.readthedocs.io/ # # # # PyGithub is free software: you can redistribute it and/or modify it under # # the terms of the GNU Lesser General Public License as published by the Free # # Software Foundation, either version 3 of the License, or (at your option) # # any later version. # # # # PyGithub is distributed in the hope that it will be useful, but WITHOUT ANY # # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more # # details. # # # # You should have received a copy of the GNU Lesser General Public License # # along with PyGithub. If not, see . # # # ################################################################################ import github.GithubObject class GitReleaseAsset(github.GithubObject.CompletableGithubObject): """ This class represents GitReleaseAssets. The reference can be found here https://docs.github.com/en/rest/reference/repos#releases """ def __repr__(self): return self.get__repr__({"url": self.url}) @property def url(self): """ :type: string """ self._completeIfNotSet(self._url) return self._url.value @property def id(self): """ :type: integer """ self._completeIfNotSet(self._id) return self._id.value @property def name(self): """ :type: string """ self._completeIfNotSet(self._name) return self._name.value @property def label(self): """ :type: string """ self._completeIfNotSet(self._label) return self._label.value @property def content_type(self): """ :type: string """ self._completeIfNotSet(self._content_type) return self._content_type.value @property def state(self): """ :type: string """ self._completeIfNotSet(self._state) return self._state.value @property def size(self): """ :type: integer """ self._completeIfNotSet(self._size) return self._size.value @property def download_count(self): """ :type: integer """ self._completeIfNotSet(self._download_count) return self._download_count.value @property def created_at(self): """ :type: datetime """ self._completeIfNotSet(self._created_at) return self._created_at.value @property def updated_at(self): """ :type: datetime """ self._completeIfNotSet(self._updated_at) return self._updated_at.value @property def browser_download_url(self): """ :type: string """ self._completeIfNotSet(self._browser_download_url) return self._browser_download_url.value @property def uploader(self): """ :type: github.NamedUser.NamedUser """ self._completeIfNotSet(self._uploader) return self._uploader.value def delete_asset(self): """ Delete asset from the release. :rtype: bool """ headers, data = self._requester.requestJsonAndCheck("DELETE", self.url) return True def update_asset(self, name, label=""): """ Update asset metadata. :rtype: github.GitReleaseAsset.GitReleaseAsset """ assert isinstance(name, str), name assert isinstance(label, str), label post_parameters = {"name": name, "label": label} headers, data = self._requester.requestJsonAndCheck( "PATCH", self.url, input=post_parameters ) return GitReleaseAsset(self._requester, headers, data, completed=True) def _initAttributes(self): self._url = github.GithubObject.NotSet self._id = github.GithubObject.NotSet self._name = github.GithubObject.NotSet self._label = github.GithubObject.NotSet self._uploader = github.GithubObject.NotSet self._content_type = github.GithubObject.NotSet self._state = github.GithubObject.NotSet self._size = github.GithubObject.NotSet self._download_count = github.GithubObject.NotSet self._created_at = github.GithubObject.NotSet self._updated_at = github.GithubObject.NotSet self._browser_download_url = github.GithubObject.NotSet def _useAttributes(self, attributes): if "url" in attributes: # pragma no branch self._url = self._makeStringAttribute(attributes["url"]) if "id" in attributes: # pragma no branch self._id = self._makeIntAttribute(attributes["id"]) if "name" in attributes: # pragma no branch self._name = self._makeStringAttribute(attributes["name"]) if "label" in attributes: # pragma no branch self._label = self._makeStringAttribute(attributes["label"]) if "uploader" in attributes: # pragma no branch self._uploader = self._makeClassAttribute( github.NamedUser.NamedUser, attributes["uploader"] ) if "content_type" in attributes: # pragma no branch self._content_type = self._makeStringAttribute(attributes["content_type"]) if "state" in attributes: # pragma no branch self._state = self._makeStringAttribute(attributes["state"]) if "size" in attributes: # pragma no branch self._size = self._makeIntAttribute(attributes["size"]) if "download_count" in attributes: # pragma no branch self._download_count = self._makeIntAttribute(attributes["download_count"]) if "created_at" in attributes: # pragma no branch self._created_at = self._makeDatetimeAttribute(attributes["created_at"]) if "updated_at" in attributes: # pragma no branch self._updated_at = self._makeDatetimeAttribute(attributes["updated_at"]) if "browser_download_url" in attributes: # pragma no branch self._browser_download_url = self._makeStringAttribute( attributes["browser_download_url"] ) ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1619412308.0 PyGithub-1.55/github/GitReleaseAsset.pyi0000644000175100001710000000207400000000000017573 0ustar00runnerdockerfrom datetime import datetime from typing import Any, Dict, Union from github.GithubObject import CompletableGithubObject from github.NamedUser import NamedUser class GitReleaseAsset(CompletableGithubObject): def __repr__(self) -> str: ... def _initAttributes(self) -> None: ... def _useAttributes(self, attributes: Dict[str, Any]) -> None: ... @property def browser_download_url(self) -> str: ... @property def content_type(self) -> str: ... @property def created_at(self) -> datetime: ... def delete_asset(self) -> bool: ... @property def download_count(self) -> int: ... @property def id(self) -> int: ... @property def label(self) -> str: ... @property def name(self) -> str: ... @property def size(self) -> int: ... @property def state(self) -> str: ... def update_asset(self, name: str, label: str = ...) -> GitReleaseAsset: ... @property def updated_at(self) -> datetime: ... @property def uploader(self) -> NamedUser: ... @property def url(self) -> str: ... ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1619412308.0 PyGithub-1.55/github/GitTag.py0000644000175100001710000001155200000000000015556 0ustar00runnerdocker############################ Copyrights and license ############################ # # # Copyright 2012 Vincent Jacques # # Copyright 2012 Zearin # # Copyright 2013 AKFish # # Copyright 2013 Vincent Jacques # # Copyright 2014 Vincent Jacques # # Copyright 2016 Jannis Gebauer # # Copyright 2016 Peter Buckley # # Copyright 2018 Wan Liuyang # # Copyright 2018 sfdye # # # # This file is part of PyGithub. # # http://pygithub.readthedocs.io/ # # # # PyGithub is free software: you can redistribute it and/or modify it under # # the terms of the GNU Lesser General Public License as published by the Free # # Software Foundation, either version 3 of the License, or (at your option) # # any later version. # # # # PyGithub is distributed in the hope that it will be useful, but WITHOUT ANY # # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more # # details. # # # # You should have received a copy of the GNU Lesser General Public License # # along with PyGithub. If not, see . # # # ################################################################################ import github.GitAuthor import github.GithubObject import github.GitObject class GitTag(github.GithubObject.CompletableGithubObject): """ This class represents GitTags. The reference can be found here https://docs.github.com/en/rest/reference/git#tags """ def __repr__(self): return self.get__repr__({"sha": self._sha.value, "tag": self._tag.value}) @property def message(self): """ :type: string """ self._completeIfNotSet(self._message) return self._message.value @property def object(self): """ :type: :class:`github.GitObject.GitObject` """ self._completeIfNotSet(self._object) return self._object.value @property def sha(self): """ :type: string """ self._completeIfNotSet(self._sha) return self._sha.value @property def tag(self): """ :type: string """ self._completeIfNotSet(self._tag) return self._tag.value @property def tagger(self): """ :type: :class:`github.GitAuthor.GitAuthor` """ self._completeIfNotSet(self._tagger) return self._tagger.value @property def url(self): """ :type: string """ self._completeIfNotSet(self._url) return self._url.value def _initAttributes(self): self._message = github.GithubObject.NotSet self._object = github.GithubObject.NotSet self._sha = github.GithubObject.NotSet self._tag = github.GithubObject.NotSet self._tagger = github.GithubObject.NotSet self._url = github.GithubObject.NotSet def _useAttributes(self, attributes): if "message" in attributes: # pragma no branch self._message = self._makeStringAttribute(attributes["message"]) if "object" in attributes: # pragma no branch self._object = self._makeClassAttribute( github.GitObject.GitObject, attributes["object"] ) if "sha" in attributes: # pragma no branch self._sha = self._makeStringAttribute(attributes["sha"]) if "tag" in attributes: # pragma no branch self._tag = self._makeStringAttribute(attributes["tag"]) if "tagger" in attributes: # pragma no branch self._tagger = self._makeClassAttribute( github.GitAuthor.GitAuthor, attributes["tagger"] ) if "url" in attributes: # pragma no branch self._url = self._makeStringAttribute(attributes["url"]) ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1619412308.0 PyGithub-1.55/github/GitTag.pyi0000644000175100001710000000120500000000000015721 0ustar00runnerdockerfrom typing import Any, Dict, Union from github.GitAuthor import GitAuthor from github.GithubObject import CompletableGithubObject from github.GitObject import GitObject class GitTag(CompletableGithubObject): def __repr__(self) -> str: ... def _initAttributes(self) -> None: ... def _useAttributes(self, attributes: Dict[str, Any]) -> None: ... @property def message(self) -> str: ... @property def object(self) -> GitObject: ... @property def sha(self) -> str: ... @property def tag(self) -> str: ... @property def tagger(self) -> GitAuthor: ... @property def url(self) -> str: ... ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1619412308.0 PyGithub-1.55/github/GitTree.py0000644000175100001710000000751600000000000015747 0ustar00runnerdocker############################ Copyrights and license ############################ # # # Copyright 2012 Vincent Jacques # # Copyright 2012 Zearin # # Copyright 2013 AKFish # # Copyright 2013 Vincent Jacques # # Copyright 2014 Vincent Jacques # # Copyright 2016 Jannis Gebauer # # Copyright 2016 Peter Buckley # # Copyright 2018 Wan Liuyang # # Copyright 2018 sfdye # # # # This file is part of PyGithub. # # http://pygithub.readthedocs.io/ # # # # PyGithub is free software: you can redistribute it and/or modify it under # # the terms of the GNU Lesser General Public License as published by the Free # # Software Foundation, either version 3 of the License, or (at your option) # # any later version. # # # # PyGithub is distributed in the hope that it will be useful, but WITHOUT ANY # # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more # # details. # # # # You should have received a copy of the GNU Lesser General Public License # # along with PyGithub. If not, see . # # # ################################################################################ import github.GithubObject import github.GitTreeElement class GitTree(github.GithubObject.CompletableGithubObject): """ This class represents GitTrees. The reference can be found here https://docs.github.com/en/rest/reference/git#trees """ def __repr__(self): return self.get__repr__({"sha": self._sha.value}) @property def sha(self): """ :type: string """ self._completeIfNotSet(self._sha) return self._sha.value @property def tree(self): """ :type: list of :class:`github.GitTreeElement.GitTreeElement` """ self._completeIfNotSet(self._tree) return self._tree.value @property def url(self): """ :type: string """ self._completeIfNotSet(self._url) return self._url.value @property def _identity(self): return self.sha def _initAttributes(self): self._sha = github.GithubObject.NotSet self._tree = github.GithubObject.NotSet self._url = github.GithubObject.NotSet def _useAttributes(self, attributes): if "sha" in attributes: # pragma no branch self._sha = self._makeStringAttribute(attributes["sha"]) if "tree" in attributes: # pragma no branch self._tree = self._makeListOfClassesAttribute( github.GitTreeElement.GitTreeElement, attributes["tree"] ) if "url" in attributes: # pragma no branch self._url = self._makeStringAttribute(attributes["url"]) ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1619412308.0 PyGithub-1.55/github/GitTree.pyi0000644000175100001710000000102200000000000016102 0ustar00runnerdockerfrom typing import Any, Dict, List from github.GithubObject import CompletableGithubObject from github.GitTreeElement import GitTreeElement class GitTree(CompletableGithubObject): def __repr__(self) -> str: ... @property def _identity(self) -> str: ... def _initAttributes(self) -> None: ... def _useAttributes(self, attributes: Dict[str, Any]) -> None: ... @property def sha(self) -> str: ... @property def tree(self) -> List[GitTreeElement]: ... @property def url(self) -> str: ... ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1619412308.0 PyGithub-1.55/github/GitTreeElement.py0000644000175100001710000001044300000000000017252 0ustar00runnerdocker############################ Copyrights and license ############################ # # # Copyright 2012 Vincent Jacques # # Copyright 2012 Zearin # # Copyright 2013 AKFish # # Copyright 2013 Vincent Jacques # # Copyright 2014 Vincent Jacques # # Copyright 2016 Jannis Gebauer # # Copyright 2016 Peter Buckley # # Copyright 2018 Wan Liuyang # # Copyright 2018 sfdye # # # # This file is part of PyGithub. # # http://pygithub.readthedocs.io/ # # # # PyGithub is free software: you can redistribute it and/or modify it under # # the terms of the GNU Lesser General Public License as published by the Free # # Software Foundation, either version 3 of the License, or (at your option) # # any later version. # # # # PyGithub is distributed in the hope that it will be useful, but WITHOUT ANY # # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more # # details. # # # # You should have received a copy of the GNU Lesser General Public License # # along with PyGithub. If not, see . # # # ################################################################################ import github.GithubObject class GitTreeElement(github.GithubObject.NonCompletableGithubObject): """ This class represents GitTreeElements """ def __repr__(self): return self.get__repr__({"sha": self._sha.value, "path": self._path.value}) @property def mode(self): """ :type: string """ return self._mode.value @property def path(self): """ :type: string """ return self._path.value @property def sha(self): """ :type: string """ return self._sha.value @property def size(self): """ :type: integer """ return self._size.value @property def type(self): """ :type: string """ return self._type.value @property def url(self): """ :type: string """ return self._url.value def _initAttributes(self): self._mode = github.GithubObject.NotSet self._path = github.GithubObject.NotSet self._sha = github.GithubObject.NotSet self._size = github.GithubObject.NotSet self._type = github.GithubObject.NotSet self._url = github.GithubObject.NotSet def _useAttributes(self, attributes): if "mode" in attributes: # pragma no branch self._mode = self._makeStringAttribute(attributes["mode"]) if "path" in attributes: # pragma no branch self._path = self._makeStringAttribute(attributes["path"]) if "sha" in attributes: # pragma no branch self._sha = self._makeStringAttribute(attributes["sha"]) if "size" in attributes: # pragma no branch self._size = self._makeIntAttribute(attributes["size"]) if "type" in attributes: # pragma no branch self._type = self._makeStringAttribute(attributes["type"]) if "url" in attributes: # pragma no branch self._url = self._makeStringAttribute(attributes["url"]) ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1619412308.0 PyGithub-1.55/github/GitTreeElement.pyi0000644000175100001710000000110000000000000017411 0ustar00runnerdockerfrom typing import Any, Dict, Optional from github.GithubObject import NonCompletableGithubObject class GitTreeElement(NonCompletableGithubObject): def __repr__(self) -> str: ... def _initAttributes(self) -> None: ... def _useAttributes(self, attributes: Dict[str, Any]) -> None: ... @property def mode(self) -> str: ... @property def path(self) -> str: ... @property def sha(self) -> str: ... @property def size(self) -> Optional[int]: ... @property def type(self) -> str: ... @property def url(self) -> str: ... ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1619412308.0 PyGithub-1.55/github/GithubApp.py0000644000175100001710000001443200000000000016262 0ustar00runnerdocker############################ Copyrights and license ############################ # # # Copyright 2020 Raju Subramanian # # # # This file is part of PyGithub. # # http://pygithub.readthedocs.io/ # # # # PyGithub is free software: you can redistribute it and/or modify it under # # the terms of the GNU Lesser General Public License as published by the Free # # Software Foundation, either version 3 of the License, or (at your option) # # any later version. # # # # PyGithub is distributed in the hope that it will be useful, but WITHOUT ANY # # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more # # details. # # # # You should have received a copy of the GNU Lesser General Public License # # along with PyGithub. If not, see . # # # ################################################################################ import github.GithubObject import github.NamedUser class GithubApp(github.GithubObject.CompletableGithubObject): """ This class represents github apps. The reference can be found here https://docs.github.com/en/rest/reference/apps """ def __repr__(self): return self.get__repr__({"id": self._id.value, "url": self._url.value}) @property def created_at(self): """ :type: datetime.datetime """ self._completeIfNotSet(self._created_at) return self._created_at.value @property def description(self): """ :type: string """ self._completeIfNotSet(self._description) return self._description.value @property def events(self): """ :type: list of string """ self._completeIfNotSet(self._events) return self._events.value @property def external_url(self): """ :type: string """ self._completeIfNotSet(self._external_url) return self._external_url.value @property def html_url(self): """ :type: string """ self._completeIfNotSet(self._html_url) return self._html_url.value @property def id(self): """ :type: int """ self._completeIfNotSet(self._id) return self._id.value @property def name(self): """ :type: string """ self._completeIfNotSet(self._name) return self._name.value @property def owner(self): """ :type: :class:`Github.NamedUser.NamedUser` """ self._completeIfNotSet(self._owner) return self._owner.value @property def permissions(self): """ :type: dict """ self._completeIfNotSet(self._permissions) return self._permissions.value @property def slug(self): """ :type: string """ return self._slug.value @property def updated_at(self): """ :type: datetime.datetime """ self._completeIfNotSet(self._updated_at) return self._updated_at.value @property def url(self): """ :type: string """ return self._url.value def _initAttributes(self): self._created_at = github.GithubObject.NotSet self._description = github.GithubObject.NotSet self._events = github.GithubObject.NotSet self._external_url = github.GithubObject.NotSet self._html_url = github.GithubObject.NotSet self._id = github.GithubObject.NotSet self._name = github.GithubObject.NotSet self._owner = github.GithubObject.NotSet self._permissions = github.GithubObject.NotSet self._slug = github.GithubObject.NotSet self._updated_at = github.GithubObject.NotSet self._url = github.GithubObject.NotSet def _useAttributes(self, attributes): if "created_at" in attributes: # pragma no branch self._created_at = self._makeDatetimeAttribute(attributes["created_at"]) if "description" in attributes: # pragma no branch self._description = self._makeStringAttribute(attributes["description"]) if "events" in attributes: # pragma no branch self._events = self._makeListOfStringsAttribute(attributes["events"]) if "external_url" in attributes: # pragma no branch self._external_url = self._makeStringAttribute(attributes["external_url"]) if "html_url" in attributes: # pragma no branch self._html_url = self._makeStringAttribute(attributes["html_url"]) if "id" in attributes: # pragma no branch self._id = self._makeIntAttribute(attributes["id"]) if "name" in attributes: # pragma no branch self._name = self._makeStringAttribute(attributes["name"]) if "owner" in attributes: # pragma no branch self._owner = self._makeClassAttribute( github.NamedUser.NamedUser, attributes["owner"] ) if "permissions" in attributes: # pragma no branch self._permissions = self._makeDictAttribute(attributes["permissions"]) if "slug" in attributes: # pragma no branch self._slug = self._makeStringAttribute(attributes["slug"]) self._url = self._makeStringAttribute(f"/apps/{attributes['slug']}") if "updated_at" in attributes: # pragma no branch self._updated_at = self._makeDatetimeAttribute(attributes["updated_at"]) if "url" in attributes: self._url = self._makeStringAttribute(attributes["url"]) ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1619412308.0 PyGithub-1.55/github/GithubApp.pyi0000644000175100001710000000170500000000000016432 0ustar00runnerdocker from typing import Any, Dict, List from datetime import datetime from github.GithubObject import CompletableGithubObject from github.NamedUser import NamedUser class GithubApp(CompletableGithubObject): def __repr__(self) -> str: ... def _initAttributes(self) -> None: ... def _useAttributes(self, attributes: Dict[str, Any]) -> None: ... @property def id(self) -> str: ... @property def slug(self) -> str: ... @property def url(self) -> str: ... @property def name(self) -> str: ... @property def description(self) -> str: ... @property def external_url(self) -> str: ... @property def html_url(self) -> str: ... @property def created_at(self) -> datetime: ... @property def updated_at(self) -> datetime: ... @property def owner(self) -> NamedUser: ... @property def permissions(self) -> Dict[str, str]: ... @property def events(self) -> List[str]: ... ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1619412308.0 PyGithub-1.55/github/GithubException.py0000644000175100001710000001233100000000000017474 0ustar00runnerdocker############################ Copyrights and license ############################ # # # Copyright 2012 Vincent Jacques # # Copyright 2012 Zearin # # Copyright 2013 AKFish # # Copyright 2013 Cameron White # # Copyright 2013 Vincent Jacques # # Copyright 2014 Vincent Jacques # # Copyright 2016 Peter Buckley # # Copyright 2016 humbug # # Copyright 2018 sfdye # # # # This file is part of PyGithub. # # http://pygithub.readthedocs.io/ # # # # PyGithub is free software: you can redistribute it and/or modify it under # # the terms of the GNU Lesser General Public License as published by the Free # # Software Foundation, either version 3 of the License, or (at your option) # # any later version. # # # # PyGithub is distributed in the hope that it will be useful, but WITHOUT ANY # # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more # # details. # # # # You should have received a copy of the GNU Lesser General Public License # # along with PyGithub. If not, see . # # # ################################################################################ import json class GithubException(Exception): """ Error handling in PyGithub is done with exceptions. This class is the base of all exceptions raised by PyGithub (but :class:`github.GithubException.BadAttributeException`). Some other types of exceptions might be raised by underlying libraries, for example for network-related issues. """ def __init__(self, status, data, headers): super().__init__() self.__status = status self.__data = data self.__headers = headers self.args = [status, data, headers] @property def status(self): """ The status returned by the Github API """ return self.__status @property def data(self): """ The (decoded) data returned by the Github API """ return self.__data @property def headers(self): """ The headers returned by the Github API """ return self.__headers def __str__(self): return "{status} {data}".format(status=self.status, data=json.dumps(self.data)) class BadCredentialsException(GithubException): """ Exception raised in case of bad credentials (when Github API replies with a 401 or 403 HTML status) """ class UnknownObjectException(GithubException): """ Exception raised when a non-existing object is requested (when Github API replies with a 404 HTML status) """ class BadUserAgentException(GithubException): """ Exception raised when request is sent with a bad user agent header (when Github API replies with a 403 bad user agent HTML status) """ class RateLimitExceededException(GithubException): """ Exception raised when the rate limit is exceeded (when Github API replies with a 403 rate limit exceeded HTML status) """ class BadAttributeException(Exception): """ Exception raised when Github returns an attribute with the wrong type. """ def __init__(self, actualValue, expectedType, transformationException): self.__actualValue = actualValue self.__expectedType = expectedType self.__transformationException = transformationException @property def actual_value(self): """ The value returned by Github """ return self.__actualValue @property def expected_type(self): """ The type PyGithub expected """ return self.__expectedType @property def transformation_exception(self): """ The exception raised when PyGithub tried to parse the value """ return self.__transformationException class TwoFactorException(GithubException): """ Exception raised when Github requires a onetime password for two-factor authentication """ class IncompletableObject(GithubException): """ Exception raised when we can not request an object from Github because the data returned did not include a URL """ ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1619412308.0 PyGithub-1.55/github/GithubException.pyi0000644000175100001710000000277300000000000017656 0ustar00runnerdockerfrom typing import Any, Dict, List, Optional, Tuple, Type, Union class GithubException(Exception): def __init__(self, status: Union[int, str], data: Any, headers: Optional[Dict[str, str]]) -> None: ... def __str__(self) -> str: ... @property def data(self) -> Dict[str, Union[str, List[str], List[Dict[str, str]]]]: ... @property def status(self) -> int: ... @property def headers(self) -> Union[None, Dict[str, str]]: ... class BadAttributeException(GithubException): def __init__( self, actualValue: Any, expectedType: Union[ Dict[Tuple[Type[str], Type[str]], Type[dict]], Tuple[Type[str], Type[str]], List[Type[dict]], List[Tuple[Type[str], Type[str]]], ], transformationException: Optional[ValueError], ) -> None: ... @property def actual_value(self) -> Any: ... @property def expected_type( self, ) -> Union[ List[Type[dict]], Tuple[Type[str], Type[str]], Dict[Tuple[Type[str], Type[str]], Type[dict]], List[Tuple[Type[str], Type[str]]], ]: ... @property def transformation_exception(self) -> Optional[ValueError]: ... class BadCredentialsException(GithubException): ... class UnknownObjectException(GithubException): ... class BadUserAgentException(GithubException): ... class RateLimitExceededException(GithubException): ... class TwoFactorException(GithubException): ... class IncompletableObject(GithubException): ... ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1619412308.0 PyGithub-1.55/github/GithubObject.py0000644000175100001710000002751100000000000016752 0ustar00runnerdocker############################ Copyrights and license ############################ # # # Copyright 2012 Vincent Jacques # # Copyright 2012 Zearin # # Copyright 2013 AKFish # # Copyright 2013 Vincent Jacques # # Copyright 2014 Andrew Scheller # # Copyright 2014 Vincent Jacques # # Copyright 2016 Jakub Wilk # # Copyright 2016 Jannis Gebauer # # Copyright 2016 Peter Buckley # # Copyright 2016 Sam Corbett # # Copyright 2018 sfdye # # # # This file is part of PyGithub. # # http://pygithub.readthedocs.io/ # # # # PyGithub is free software: you can redistribute it and/or modify it under # # the terms of the GNU Lesser General Public License as published by the Free # # Software Foundation, either version 3 of the License, or (at your option) # # any later version. # # # # PyGithub is distributed in the hope that it will be useful, but WITHOUT ANY # # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more # # details. # # # # You should have received a copy of the GNU Lesser General Public License # # along with PyGithub. If not, see . # # # ################################################################################ import datetime from operator import itemgetter from . import Consts, GithubException class _NotSetType: def __repr__(self): return "NotSet" value = None NotSet = _NotSetType() class _ValuedAttribute: def __init__(self, value): self.value = value class _BadAttribute: def __init__(self, value, expectedType, exception=None): self.__value = value self.__expectedType = expectedType self.__exception = exception @property def value(self): raise GithubException.BadAttributeException( self.__value, self.__expectedType, self.__exception ) class GithubObject: """ Base class for all classes representing objects returned by the API. """ """ A global debug flag to enable header validation by requester for all objects """ CHECK_AFTER_INIT_FLAG = False @classmethod def setCheckAfterInitFlag(cls, flag): cls.CHECK_AFTER_INIT_FLAG = flag def __init__(self, requester, headers, attributes, completed): self._requester = requester self._initAttributes() self._storeAndUseAttributes(headers, attributes) # Ask requester to do some checking, for debug and test purpose # Since it's most handy to access and kinda all-knowing if self.CHECK_AFTER_INIT_FLAG: # pragma no branch (Flag always set in tests) requester.check_me(self) def _storeAndUseAttributes(self, headers, attributes): # Make sure headers are assigned before calling _useAttributes # (Some derived classes will use headers in _useAttributes) self._headers = headers self._rawData = attributes self._useAttributes(attributes) @property def raw_data(self): """ :type: dict """ self._completeIfNeeded() return self._rawData @property def raw_headers(self): """ :type: dict """ self._completeIfNeeded() return self._headers @staticmethod def _parentUrl(url): return "/".join(url.split("/")[:-1]) @staticmethod def __makeSimpleAttribute(value, type): if value is None or isinstance(value, type): return _ValuedAttribute(value) else: return _BadAttribute(value, type) @staticmethod def __makeSimpleListAttribute(value, type): if isinstance(value, list) and all( isinstance(element, type) for element in value ): return _ValuedAttribute(value) else: return _BadAttribute(value, [type]) @staticmethod def __makeTransformedAttribute(value, type, transform): if value is None: return _ValuedAttribute(None) elif isinstance(value, type): try: return _ValuedAttribute(transform(value)) except Exception as e: return _BadAttribute(value, type, e) else: return _BadAttribute(value, type) @staticmethod def _makeStringAttribute(value): return GithubObject.__makeSimpleAttribute(value, str) @staticmethod def _makeIntAttribute(value): return GithubObject.__makeSimpleAttribute(value, int) @staticmethod def _makeFloatAttribute(value): return GithubObject.__makeSimpleAttribute(value, float) @staticmethod def _makeBoolAttribute(value): return GithubObject.__makeSimpleAttribute(value, bool) @staticmethod def _makeDictAttribute(value): return GithubObject.__makeSimpleAttribute(value, dict) @staticmethod def _makeTimestampAttribute(value): return GithubObject.__makeTransformedAttribute( value, int, datetime.datetime.utcfromtimestamp ) @staticmethod def _makeDatetimeAttribute(value): def parseDatetime(s): if ( len(s) == 24 ): # pragma no branch (This branch was used only when creating a download) # The Downloads API has been removed. I'm keeping this branch because I have no mean # to check if it's really useless now. return datetime.datetime.strptime( s, "%Y-%m-%dT%H:%M:%S.000Z" ) # pragma no cover (This branch was used only when creating a download) elif len(s) >= 25: return datetime.datetime.strptime(s[:19], "%Y-%m-%dT%H:%M:%S") + ( 1 if s[19] == "-" else -1 ) * datetime.timedelta(hours=int(s[20:22]), minutes=int(s[23:25])) else: return datetime.datetime.strptime(s, "%Y-%m-%dT%H:%M:%SZ") return GithubObject.__makeTransformedAttribute(value, str, parseDatetime) def _makeClassAttribute(self, klass, value): return GithubObject.__makeTransformedAttribute( value, dict, lambda value: klass(self._requester, self._headers, value, completed=False), ) @staticmethod def _makeListOfStringsAttribute(value): return GithubObject.__makeSimpleListAttribute(value, str) @staticmethod def _makeListOfIntsAttribute(value): return GithubObject.__makeSimpleListAttribute(value, int) @staticmethod def _makeListOfDictsAttribute(value): return GithubObject.__makeSimpleListAttribute(value, dict) @staticmethod def _makeListOfListOfStringsAttribute(value): return GithubObject.__makeSimpleListAttribute(value, list) def _makeListOfClassesAttribute(self, klass, value): if isinstance(value, list) and all( isinstance(element, dict) for element in value ): return _ValuedAttribute( [ klass(self._requester, self._headers, element, completed=False) for element in value ] ) else: return _BadAttribute(value, [dict]) def _makeDictOfStringsToClassesAttribute(self, klass, value): if isinstance(value, dict) and all( isinstance(key, str) and isinstance(element, dict) for key, element in value.items() ): return _ValuedAttribute( { key: klass(self._requester, self._headers, element, completed=False) for key, element in value.items() } ) else: return _BadAttribute(value, {str: dict}) @property def etag(self): """ :type: str """ return self._headers.get(Consts.RES_ETAG) @property def last_modified(self): """ :type: str """ return self._headers.get(Consts.RES_LAST_MODIFIED) def get__repr__(self, params): """ Converts the object to a nicely printable string. """ def format_params(params): items = list(params.items()) for k, v in sorted(items, key=itemgetter(0), reverse=True): if isinstance(v, bytes): v = v.decode("utf-8") if isinstance(v, str): v = f'"{v}"' yield f"{k}={v}" return "{class_name}({params})".format( class_name=self.__class__.__name__, params=", ".join(list(format_params(params))), ) class NonCompletableGithubObject(GithubObject): def _completeIfNeeded(self): pass class CompletableGithubObject(GithubObject): def __init__(self, requester, headers, attributes, completed): super().__init__(requester, headers, attributes, completed) self.__completed = completed def __eq__(self, other): return other.__class__ is self.__class__ and other._url.value == self._url.value def __hash__(self): return hash(self._url.value) def __ne__(self, other): return not self == other def _completeIfNotSet(self, value): if value is NotSet: self._completeIfNeeded() def _completeIfNeeded(self): if not self.__completed: self.__complete() def __complete(self): if self._url.value is None: raise GithubException.IncompletableObject( 400, "Returned object contains no URL", None ) headers, data = self._requester.requestJsonAndCheck("GET", self._url.value) self._storeAndUseAttributes(headers, data) self.__completed = True def update(self, additional_headers=None): """ Check and update the object with conditional request :rtype: Boolean value indicating whether the object is changed """ conditionalRequestHeader = dict() if self.etag is not None: conditionalRequestHeader[Consts.REQ_IF_NONE_MATCH] = self.etag if self.last_modified is not None: conditionalRequestHeader[Consts.REQ_IF_MODIFIED_SINCE] = self.last_modified if additional_headers is not None: conditionalRequestHeader.update(additional_headers) status, responseHeaders, output = self._requester.requestJson( "GET", self._url.value, headers=conditionalRequestHeader ) if status == 304: return False else: headers, data = self._requester._Requester__check( status, responseHeaders, output ) self._storeAndUseAttributes(headers, data) self.__completed = True return True ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1619412308.0 PyGithub-1.55/github/GithubObject.pyi0000644000175100001710000001031000000000000017110 0ustar00runnerdockerfrom typing import Any, Callable, Dict, List, Optional, Type, Union from github.Commit import Commit from github.GistFile import GistFile from github.GitRelease import GitRelease from github.NamedUser import NamedUser from github.Organization import Organization from github.PullRequestReview import PullRequestReview from github.Requester import Requester class GithubObject: def __init__( self, requester: Optional[Requester], headers: Dict[str, Union[str, int]], attributes: Any, completed: bool, ) -> None: ... @staticmethod def _makeBoolAttribute(value: Optional[bool]) -> _ValuedAttribute: ... def _makeClassAttribute( self, klass: Any, value: Any ) -> Union[_ValuedAttribute, _BadAttribute]: ... @staticmethod def _makeDatetimeAttribute( value: Optional[Union[int, str]] ) -> Union[_ValuedAttribute, _BadAttribute]: ... @staticmethod def _makeDictAttribute(value: Dict[str, Any]) -> _ValuedAttribute: ... def _makeDictOfStringsToClassesAttribute( self, klass: Type[GistFile], value: Dict[ str, Union[int, Dict[str, Union[str, int, None]], Dict[str, Union[str, int]]], ], ) -> Union[_ValuedAttribute, _BadAttribute]: ... @staticmethod def _makeIntAttribute( value: Optional[Union[int, str]] ) -> Union[_ValuedAttribute, _BadAttribute]: ... def _makeListOfClassesAttribute( self, klass: Any, value: Any ) -> Union[_ValuedAttribute, _BadAttribute]: ... @staticmethod def _makeListOfDictsAttribute( value: List[Dict[str, Union[str, List[Dict[str, Union[str, List[int]]]]]]] ) -> _ValuedAttribute: ... @staticmethod def _makeListOfIntsAttribute(value: List[int]) -> _ValuedAttribute: ... @staticmethod def _makeListOfListOfStringsAttribute( value: List[List[str]], ) -> _ValuedAttribute: ... @staticmethod def _makeListOfStringsAttribute( value: Union[List[List[str]], List[str], List[Union[str, int]]] ) -> Union[_ValuedAttribute, _BadAttribute]: ... @staticmethod def __makeSimpleAttribute( value: Any, type: type ) -> Union[_ValuedAttribute, _BadAttribute]: ... @staticmethod def __makeSimpleListAttribute( value: list, type: type ) -> Union[_ValuedAttribute, _BadAttribute]: ... @staticmethod def __makeTransformedAttribute( value: Any, type: type, transform: Callable[..., Any] ) -> Union[_ValuedAttribute, _BadAttribute]: ... @staticmethod def _makeStringAttribute( value: Optional[Union[int, str]] ) -> Union[_ValuedAttribute, _BadAttribute]: ... @staticmethod def _makeTimestampAttribute(value: int) -> _ValuedAttribute: ... @staticmethod def _parentUrl(url: str) -> str: ... def _storeAndUseAttributes( self, headers: Dict[str, Union[str, int]], attributes: Any ) -> None: ... @property def etag(self) -> Optional[str]: ... def get__repr__(self, params: Dict[str, Any]) -> str: ... @property def last_modified(self) -> Optional[str]: ... @property def raw_data(self) -> Dict[str, Any]: ... @property def raw_headers(self) -> Dict[str, Union[str, int]]: ... @classmethod def setCheckAfterInitFlag(cls, flag: bool) -> None: ... class NonCompletableGithubObject(GithubObject): def _completeIfNeeded(self) -> None: ... class CompletableGithubObject(GithubObject): def __eq__(self, other: Any) -> bool: ... def __init__( self, requester: Requester, headers: Dict[str, Union[str, int]], attributes: Dict[str, Any], completed: bool, ) -> None: ... def __ne__(self, other: Any) -> bool: ... def _completeIfNeeded(self) -> None: ... def _completeIfNotSet( self, value: Union[_ValuedAttribute, _BadAttribute, _NotSetType] ) -> None: ... def update(self) -> bool: ... class _BadAttribute: def __init__( self, value: Any, expectedType: Any, exception: Optional[ValueError] = ... ) -> None: ... @property def value(self) -> Any: ... class _NotSetType: def __repr__(self) -> str: ... class _ValuedAttribute: def __init__(self, value: Any) -> None: ... ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1619412308.0 PyGithub-1.55/github/GitignoreTemplate.py0000644000175100001710000000627300000000000020026 0ustar00runnerdocker############################ Copyrights and license ############################ # # # Copyright 2012 Vincent Jacques # # Copyright 2013 AKFish # # Copyright 2013 Vincent Jacques # # Copyright 2014 Vincent Jacques # # Copyright 2016 Jannis Gebauer # # Copyright 2016 Peter Buckley # # Copyright 2018 Wan Liuyang # # Copyright 2018 sfdye # # # # This file is part of PyGithub. # # http://pygithub.readthedocs.io/ # # # # PyGithub is free software: you can redistribute it and/or modify it under # # the terms of the GNU Lesser General Public License as published by the Free # # Software Foundation, either version 3 of the License, or (at your option) # # any later version. # # # # PyGithub is distributed in the hope that it will be useful, but WITHOUT ANY # # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more # # details. # # # # You should have received a copy of the GNU Lesser General Public License # # along with PyGithub. If not, see . # # # ################################################################################ import github.GithubObject class GitignoreTemplate(github.GithubObject.NonCompletableGithubObject): """ This class represents GitignoreTemplates. The reference can be found here https://docs.github.com/en/rest/reference/gitignore """ def __repr__(self): return self.get__repr__({"name": self._name.value}) @property def source(self): """ :type: string """ return self._source.value @property def name(self): """ :type: string """ return self._name.value def _initAttributes(self): self._source = github.GithubObject.NotSet self._name = github.GithubObject.NotSet def _useAttributes(self, attributes): if "source" in attributes: # pragma no branch self._source = self._makeStringAttribute(attributes["source"]) if "name" in attributes: # pragma no branch self._name = self._makeStringAttribute(attributes["name"]) ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1619412308.0 PyGithub-1.55/github/GitignoreTemplate.pyi0000644000175100001710000000057700000000000020200 0ustar00runnerdockerfrom typing import Any, Dict from github.GithubObject import NonCompletableGithubObject class GitignoreTemplate(NonCompletableGithubObject): def __repr__(self) -> str: ... def _initAttributes(self) -> None: ... def _useAttributes(self, attributes: Dict[str, Any]) -> None: ... @property def name(self) -> str: ... @property def source(self) -> str: ... ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1619412308.0 PyGithub-1.55/github/Hook.py0000644000175100001710000002253600000000000015303 0ustar00runnerdocker############################ Copyrights and license ############################ # # # Copyright 2012 Vincent Jacques # # Copyright 2012 Zearin # # Copyright 2013 AKFish # # Copyright 2013 Vincent Jacques # # Copyright 2014 Vincent Jacques # # Copyright 2016 Jannis Gebauer # # Copyright 2016 Peter Buckley # # Copyright 2017 Wan Liuyang # # Copyright 2018 Wan Liuyang # # Copyright 2018 sfdye # # # # This file is part of PyGithub. # # http://pygithub.readthedocs.io/ # # # # PyGithub is free software: you can redistribute it and/or modify it under # # the terms of the GNU Lesser General Public License as published by the Free # # Software Foundation, either version 3 of the License, or (at your option) # # any later version. # # # # PyGithub is distributed in the hope that it will be useful, but WITHOUT ANY # # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more # # details. # # # # You should have received a copy of the GNU Lesser General Public License # # along with PyGithub. If not, see . # # # ################################################################################ import github.GithubObject import github.HookResponse class Hook(github.GithubObject.CompletableGithubObject): """ This class represents Hooks. The reference can be found here http://docs.github.com/en/rest/reference/repos#webhooks """ def __repr__(self): return self.get__repr__({"id": self._id.value, "url": self._url.value}) @property def active(self): """ :type: bool """ self._completeIfNotSet(self._active) return self._active.value @property def config(self): """ :type: dict """ self._completeIfNotSet(self._config) return self._config.value @property def created_at(self): """ :type: datetime.datetime """ self._completeIfNotSet(self._created_at) return self._created_at.value @property def events(self): """ :type: list of string """ self._completeIfNotSet(self._events) return self._events.value @property def id(self): """ :type: integer """ self._completeIfNotSet(self._id) return self._id.value @property def last_response(self): """ :type: :class:`github.HookResponse.HookResponse` """ self._completeIfNotSet(self._last_response) return self._last_response.value @property def name(self): """ :type: string """ self._completeIfNotSet(self._name) return self._name.value @property def test_url(self): """ :type: string """ self._completeIfNotSet(self._test_url) return self._test_url.value @property def updated_at(self): """ :type: datetime.datetime """ self._completeIfNotSet(self._updated_at) return self._updated_at.value @property def url(self): """ :type: string """ self._completeIfNotSet(self._url) return self._url.value @property def ping_url(self): """ :type: string """ self._completeIfNotSet(self._ping_url) return self._ping_url.value def delete(self): """ :calls: `DELETE /repos/{owner}/{repo}/hooks/{id} `_ :rtype: None """ headers, data = self._requester.requestJsonAndCheck("DELETE", self.url) def edit( self, name, config, events=github.GithubObject.NotSet, add_events=github.GithubObject.NotSet, remove_events=github.GithubObject.NotSet, active=github.GithubObject.NotSet, ): """ :calls: `PATCH /repos/{owner}/{repo}/hooks/{id} `_ :param name: string :param config: dict :param events: list of string :param add_events: list of string :param remove_events: list of string :param active: bool :rtype: None """ assert isinstance(name, str), name assert isinstance(config, dict), config assert events is github.GithubObject.NotSet or all( isinstance(element, str) for element in events ), events assert add_events is github.GithubObject.NotSet or all( isinstance(element, str) for element in add_events ), add_events assert remove_events is github.GithubObject.NotSet or all( isinstance(element, str) for element in remove_events ), remove_events assert active is github.GithubObject.NotSet or isinstance(active, bool), active post_parameters = { "name": name, "config": config, } if events is not github.GithubObject.NotSet: post_parameters["events"] = events if add_events is not github.GithubObject.NotSet: post_parameters["add_events"] = add_events if remove_events is not github.GithubObject.NotSet: post_parameters["remove_events"] = remove_events if active is not github.GithubObject.NotSet: post_parameters["active"] = active headers, data = self._requester.requestJsonAndCheck( "PATCH", self.url, input=post_parameters ) self._useAttributes(data) def test(self): """ :calls: `POST /repos/{owner}/{repo}/hooks/{id}/tests `_ :rtype: None """ headers, data = self._requester.requestJsonAndCheck("POST", f"{self.url}/tests") def ping(self): """ :calls: `POST /repos/{owner}/{repo}/hooks/{id}/pings `_ :rtype: None """ headers, data = self._requester.requestJsonAndCheck("POST", f"{self.url}/pings") def _initAttributes(self): self._active = github.GithubObject.NotSet self._config = github.GithubObject.NotSet self._created_at = github.GithubObject.NotSet self._events = github.GithubObject.NotSet self._id = github.GithubObject.NotSet self._last_response = github.GithubObject.NotSet self._name = github.GithubObject.NotSet self._test_url = github.GithubObject.NotSet self._updated_at = github.GithubObject.NotSet self._url = github.GithubObject.NotSet self._ping_url = github.GithubObject.NotSet def _useAttributes(self, attributes): if "active" in attributes: # pragma no branch self._active = self._makeBoolAttribute(attributes["active"]) if "config" in attributes: # pragma no branch self._config = self._makeDictAttribute(attributes["config"]) if "created_at" in attributes: # pragma no branch self._created_at = self._makeDatetimeAttribute(attributes["created_at"]) if "events" in attributes: # pragma no branch self._events = self._makeListOfStringsAttribute(attributes["events"]) if "id" in attributes: # pragma no branch self._id = self._makeIntAttribute(attributes["id"]) if "last_response" in attributes: # pragma no branch self._last_response = self._makeClassAttribute( github.HookResponse.HookResponse, attributes["last_response"] ) if "name" in attributes: # pragma no branch self._name = self._makeStringAttribute(attributes["name"]) if "test_url" in attributes: # pragma no branch self._test_url = self._makeStringAttribute(attributes["test_url"]) if "updated_at" in attributes: # pragma no branch self._updated_at = self._makeDatetimeAttribute(attributes["updated_at"]) if "url" in attributes: # pragma no branch self._url = self._makeStringAttribute(attributes["url"]) if "ping_url" in attributes: # pragma no branch self._ping_url = self._makeStringAttribute(attributes["ping_url"]) ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1619412308.0 PyGithub-1.55/github/Hook.pyi0000644000175100001710000000250700000000000015450 0ustar00runnerdockerfrom datetime import datetime from typing import Any, Dict, List, Union from github.GithubObject import CompletableGithubObject, _NotSetType from github.HookResponse import HookResponse class Hook(CompletableGithubObject): def __repr__(self) -> str: ... def _initAttributes(self) -> None: ... def _useAttributes(self, attributes: Dict[str, Any]) -> None: ... @property def active(self) -> bool: ... @property def config(self) -> Dict[str, str]: ... @property def created_at(self) -> datetime: ... def delete(self) -> None: ... def edit( self, name: str, config: Dict[str, str], events: Union[_NotSetType, List[str]] = ..., add_events: Union[_NotSetType, List[str]] = ..., remove_events: Union[_NotSetType, List[str]] = ..., active: Union[bool, _NotSetType] = ..., ) -> None: ... @property def events(self) -> List[str]: ... @property def id(self) -> int: ... @property def last_response(self) -> HookResponse: ... @property def name(self) -> str: ... def ping(self) -> None: ... @property def ping_url(self) -> str: ... def test(self) -> None: ... @property def test_url(self) -> str: ... @property def updated_at(self) -> datetime: ... @property def url(self) -> str: ... ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1619412308.0 PyGithub-1.55/github/HookDescription.py0000644000175100001710000000763200000000000017507 0ustar00runnerdocker############################ Copyrights and license ############################ # # # Copyright 2012 Vincent Jacques # # Copyright 2012 Zearin # # Copyright 2013 AKFish # # Copyright 2013 Vincent Jacques # # Copyright 2014 Vincent Jacques # # Copyright 2016 Jannis Gebauer # # Copyright 2016 Peter Buckley # # Copyright 2018 Wan Liuyang # # Copyright 2018 sfdye # # # # This file is part of PyGithub. # # http://pygithub.readthedocs.io/ # # # # PyGithub is free software: you can redistribute it and/or modify it under # # the terms of the GNU Lesser General Public License as published by the Free # # Software Foundation, either version 3 of the License, or (at your option) # # any later version. # # # # PyGithub is distributed in the hope that it will be useful, but WITHOUT ANY # # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more # # details. # # # # You should have received a copy of the GNU Lesser General Public License # # along with PyGithub. If not, see . # # # ################################################################################ import github.GithubObject class HookDescription(github.GithubObject.NonCompletableGithubObject): """ This class represents HookDescriptions """ def __repr__(self): return self.get__repr__({"name": self._name.value}) @property def events(self): """ :type: list of string """ return self._events.value @property def name(self): """ :type: string """ return self._name.value @property def schema(self): """ :type: list of list of string """ return self._schema.value @property def supported_events(self): """ :type: list of string """ return self._supported_events.value def _initAttributes(self): self._events = github.GithubObject.NotSet self._name = github.GithubObject.NotSet self._schema = github.GithubObject.NotSet self._supported_events = github.GithubObject.NotSet def _useAttributes(self, attributes): if "events" in attributes: # pragma no branch self._events = self._makeListOfStringsAttribute(attributes["events"]) if "name" in attributes: # pragma no branch self._name = self._makeStringAttribute(attributes["name"]) if "schema" in attributes: # pragma no branch self._schema = self._makeListOfListOfStringsAttribute(attributes["schema"]) if "supported_events" in attributes: # pragma no branch self._supported_events = self._makeListOfStringsAttribute( attributes["supported_events"] ) ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1619412308.0 PyGithub-1.55/github/HookDescription.pyi0000644000175100001710000000100300000000000017642 0ustar00runnerdockerfrom typing import Any, Dict, List from github.GithubObject import NonCompletableGithubObject class HookDescription(NonCompletableGithubObject): def __repr__(self) -> str: ... def _initAttributes(self) -> None: ... def _useAttributes(self, attributes: Dict[str, Any]) -> None: ... @property def events(self) -> List[str]: ... @property def name(self) -> str: ... @property def schema(self) -> List[List[str]]: ... @property def supported_events(self) -> List[str]: ... ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1619412308.0 PyGithub-1.55/github/HookResponse.py0000644000175100001710000000673600000000000017026 0ustar00runnerdocker############################ Copyrights and license ############################ # # # Copyright 2012 Vincent Jacques # # Copyright 2012 Zearin # # Copyright 2013 AKFish # # Copyright 2013 Vincent Jacques # # Copyright 2014 Vincent Jacques # # Copyright 2016 Jannis Gebauer # # Copyright 2016 Peter Buckley # # Copyright 2018 Wan Liuyang # # Copyright 2018 sfdye # # # # This file is part of PyGithub. # # http://pygithub.readthedocs.io/ # # # # PyGithub is free software: you can redistribute it and/or modify it under # # the terms of the GNU Lesser General Public License as published by the Free # # Software Foundation, either version 3 of the License, or (at your option) # # any later version. # # # # PyGithub is distributed in the hope that it will be useful, but WITHOUT ANY # # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more # # details. # # # # You should have received a copy of the GNU Lesser General Public License # # along with PyGithub. If not, see . # # # ################################################################################ import github.GithubObject class HookResponse(github.GithubObject.NonCompletableGithubObject): """ This class represents HookResponses """ def __repr__(self): return self.get__repr__({"status": self._status.value}) @property def code(self): """ :type: integer """ return self._code.value @property def message(self): """ :type: string """ return self._message.value @property def status(self): """ :type: string """ return self._status.value def _initAttributes(self): self._code = github.GithubObject.NotSet self._message = github.GithubObject.NotSet self._status = github.GithubObject.NotSet def _useAttributes(self, attributes): if "code" in attributes: # pragma no branch self._code = self._makeIntAttribute(attributes["code"]) if "message" in attributes: # pragma no branch self._message = self._makeStringAttribute(attributes["message"]) if "status" in attributes: # pragma no branch self._status = self._makeStringAttribute(attributes["status"]) ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1619412308.0 PyGithub-1.55/github/HookResponse.pyi0000644000175100001710000000065200000000000017166 0ustar00runnerdockerfrom typing import Any, Dict from github.GithubObject import NonCompletableGithubObject class HookResponse(NonCompletableGithubObject): def __repr__(self) -> str: ... def _initAttributes(self) -> None: ... def _useAttributes(self, attributes: Dict[str, Any]) -> None: ... @property def code(self) -> int: ... @property def message(self) -> str: ... @property def status(self) -> str: ... ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1619412308.0 PyGithub-1.55/github/InputFileContent.py0000644000175100001710000000557000000000000017634 0ustar00runnerdocker############################ Copyrights and license ############################ # # # Copyright 2012 Vincent Jacques # # Copyright 2012 Zearin # # Copyright 2013 Vincent Jacques # # Copyright 2014 Vincent Jacques # # Copyright 2016 Peter Buckley # # Copyright 2018 Wan Liuyang # # Copyright 2018 sfdye # # # # This file is part of PyGithub. # # http://pygithub.readthedocs.io/ # # # # PyGithub is free software: you can redistribute it and/or modify it under # # the terms of the GNU Lesser General Public License as published by the Free # # Software Foundation, either version 3 of the License, or (at your option) # # any later version. # # # # PyGithub is distributed in the hope that it will be useful, but WITHOUT ANY # # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more # # details. # # # # You should have received a copy of the GNU Lesser General Public License # # along with PyGithub. If not, see . # # # ################################################################################ import github.GithubObject class InputFileContent: """ This class represents InputFileContents """ def __init__(self, content, new_name=github.GithubObject.NotSet): """ :param content: string :param new_name: string """ assert isinstance(content, str), content assert new_name is github.GithubObject.NotSet or isinstance( new_name, str ), new_name self.__newName = new_name self.__content = content @property def _identity(self): identity = { "content": self.__content, } if self.__newName is not github.GithubObject.NotSet: identity["filename"] = self.__newName return identity ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1619412308.0 PyGithub-1.55/github/InputFileContent.pyi0000644000175100001710000000041300000000000017774 0ustar00runnerdockerfrom typing import Dict, Union from github.GithubObject import _NotSetType class InputFileContent: def __init__( self, content: str, new_name: Union[str, _NotSetType] = ... ) -> None: ... @property def _identity(self) -> Dict[str, str]: ... ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1619412308.0 PyGithub-1.55/github/InputGitAuthor.py0000644000175100001710000000631600000000000017327 0ustar00runnerdocker############################ Copyrights and license ############################ # # # Copyright 2012 Vincent Jacques # # Copyright 2012 Zearin # # Copyright 2013 Vincent Jacques # # Copyright 2014 Nic Dahlquist # # Copyright 2014 Vincent Jacques # # Copyright 2016 Jannis Gebauer # # Copyright 2016 Peter Buckley # # Copyright 2018 Wan Liuyang # # Copyright 2018 sfdye # # # # This file is part of PyGithub. # # http://pygithub.readthedocs.io/ # # # # PyGithub is free software: you can redistribute it and/or modify it under # # the terms of the GNU Lesser General Public License as published by the Free # # Software Foundation, either version 3 of the License, or (at your option) # # any later version. # # # # PyGithub is distributed in the hope that it will be useful, but WITHOUT ANY # # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more # # details. # # # # You should have received a copy of the GNU Lesser General Public License # # along with PyGithub. If not, see . # # # ################################################################################ import github.GithubObject class InputGitAuthor: """ This class represents InputGitAuthors """ def __init__(self, name, email, date=github.GithubObject.NotSet): """ :param name: string :param email: string :param date: string """ assert isinstance(name, str), name assert isinstance(email, str), email assert date is github.GithubObject.NotSet or isinstance( date, str ), date # @todo Datetime? self.__name = name self.__email = email self.__date = date def __repr__(self): return f'InputGitAuthor(name="{self.__name}")' @property def _identity(self): identity = { "name": self.__name, "email": self.__email, } if self.__date is not github.GithubObject.NotSet: identity["date"] = self.__date return identity ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1619412308.0 PyGithub-1.55/github/InputGitAuthor.pyi0000644000175100001710000000041600000000000017473 0ustar00runnerdockerfrom typing import Dict, Union from github.GithubObject import _NotSetType class InputGitAuthor: def __init__( self, name: str, email: str, date: Union[str, _NotSetType] = ... ) -> None: ... @property def _identity(self) -> Dict[str, str]: ... ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1619412308.0 PyGithub-1.55/github/InputGitTreeElement.py0000644000175100001710000000673300000000000020301 0ustar00runnerdocker############################ Copyrights and license ############################ # # # Copyright 2012 Vincent Jacques # # Copyright 2012 Zearin # # Copyright 2013 Vincent Jacques # # Copyright 2014 Vincent Jacques # # Copyright 2016 Peter Buckley # # Copyright 2018 Wan Liuyang # # Copyright 2018 sfdye # # # # This file is part of PyGithub. # # http://pygithub.readthedocs.io/ # # # # PyGithub is free software: you can redistribute it and/or modify it under # # the terms of the GNU Lesser General Public License as published by the Free # # Software Foundation, either version 3 of the License, or (at your option) # # any later version. # # # # PyGithub is distributed in the hope that it will be useful, but WITHOUT ANY # # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more # # details. # # # # You should have received a copy of the GNU Lesser General Public License # # along with PyGithub. If not, see . # # # ################################################################################ import github.GithubObject class InputGitTreeElement: """ This class represents InputGitTreeElements """ def __init__( self, path, mode, type, content=github.GithubObject.NotSet, sha=github.GithubObject.NotSet, ): """ :param path: string :param mode: string :param type: string :param content: string :param sha: string or None """ assert isinstance(path, str), path assert isinstance(mode, str), mode assert isinstance(type, str), type assert content is github.GithubObject.NotSet or isinstance( content, str ), content assert ( sha is github.GithubObject.NotSet or sha is None or isinstance(sha, str) ), sha self.__path = path self.__mode = mode self.__type = type self.__content = content self.__sha = sha @property def _identity(self): identity = { "path": self.__path, "mode": self.__mode, "type": self.__type, } if self.__sha is not github.GithubObject.NotSet: identity["sha"] = self.__sha if self.__content is not github.GithubObject.NotSet: identity["content"] = self.__content return identity ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1619412308.0 PyGithub-1.55/github/InputGitTreeElement.pyi0000644000175100001710000000056300000000000020445 0ustar00runnerdockerfrom typing import Dict, Union from github.GithubObject import _NotSetType class InputGitTreeElement: def __init__( self, path: str, mode: str, type: str, content: Union[str, _NotSetType] = ..., sha: Union[str, _NotSetType, None] = ..., ) -> None: ... @property def _identity(self) -> Dict[str, str]: ... ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1619412308.0 PyGithub-1.55/github/Installation.py0000644000175100001710000001102200000000000017030 0ustar00runnerdocker############################ Copyrights and license ############################ # # # Copyright 2017 Jannis Gebauer # # Copyright 2017 Simon # # Copyright 2018 Wan Liuyang # # Copyright 2018 sfdye # # Copyright 2019 Rigas Papathanasopoulos # # # # This file is part of PyGithub. # # http://pygithub.readthedocs.io/ # # # # PyGithub is free software: you can redistribute it and/or modify it under # # the terms of the GNU Lesser General Public License as published by the Free # # Software Foundation, either version 3 of the License, or (at your option) # # any later version. # # # # PyGithub is distributed in the hope that it will be useful, but WITHOUT ANY # # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more # # details. # # # # You should have received a copy of the GNU Lesser General Public License # # along with PyGithub. If not, see . # # # ################################################################################ import github.Authorization import github.Event import github.Gist import github.GithubObject import github.Issue import github.Notification import github.Organization import github.PaginatedList import github.Plan import github.Repository import github.UserKey from . import Consts INTEGRATION_PREVIEW_HEADERS = {"Accept": Consts.mediaTypeIntegrationPreview} class Installation(github.GithubObject.NonCompletableGithubObject): """ This class represents Installations. The reference can be found here https://docs.github.com/en/rest/reference/apps#installations """ def __repr__(self): return self.get__repr__({"id": self._id.value}) @property def id(self): """ :type: integer """ return self._id.value @property def app_id(self): """ :type: integer """ return self._app_id.value @property def target_id(self): """ :type: integer """ return self._target_id.value @property def target_type(self): """ :type: string """ return self._target_type.value def get_repos(self): """ :calls: `GET /installation/repositories `_ :rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.Repository.Repository` """ url_parameters = dict() return github.PaginatedList.PaginatedList( contentClass=github.Repository.Repository, requester=self._requester, firstUrl="/installation/repositories", firstParams=url_parameters, headers=INTEGRATION_PREVIEW_HEADERS, list_item="repositories", ) def _initAttributes(self): self._id = github.GithubObject.NotSet self._app_id = github.GithubObject.NotSet self._target_id = github.GithubObject.NotSet self._target_type = github.GithubObject.NotSet def _useAttributes(self, attributes): if "id" in attributes: # pragma no branch self._id = self._makeIntAttribute(attributes["id"]) if "app_id" in attributes: # pragma no branch self._app_id = self._makeIntAttribute(attributes["app_id"]) if "target_id" in attributes: # pragma no branch self._target_id = self._makeIntAttribute(attributes["target_id"]) if "target_type" in attributes: # pragma no branch self._target_type = self._makeStringAttribute(attributes["target_type"]) ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1619412308.0 PyGithub-1.55/github/Installation.pyi0000644000175100001710000000067000000000000017210 0ustar00runnerdockerfrom typing import Any, Dict from github.GithubObject import NonCompletableGithubObject from github.PaginatedList import PaginatedList from github.Repository import Repository class Installation(NonCompletableGithubObject): def _initAttributes(self) -> None: ... def _useAttributes(self, attributes: Dict[str, Any]) -> None: ... @property def id(self) -> int: ... def get_repos(self) -> PaginatedList[Repository]: ... ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1619412308.0 PyGithub-1.55/github/InstallationAuthorization.py0000644000175100001710000000646700000000000021632 0ustar00runnerdocker############################ Copyrights and license ############################ # # # Copyright 2016 Jannis Gebauer # # Copyright 2017 Simon # # Copyright 2018 Wan Liuyang # # Copyright 2018 sfdye # # # # This file is part of PyGithub. # # http://pygithub.readthedocs.io/ # # # # PyGithub is free software: you can redistribute it and/or modify it under # # the terms of the GNU Lesser General Public License as published by the Free # # Software Foundation, either version 3 of the License, or (at your option) # # any later version. # # # # PyGithub is distributed in the hope that it will be useful, but WITHOUT ANY # # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more # # details. # # # # You should have received a copy of the GNU Lesser General Public License # # along with PyGithub. If not, see . # # # ################################################################################ import github.GithubObject import github.NamedUser import github.PaginatedList class InstallationAuthorization(github.GithubObject.NonCompletableGithubObject): """ This class represents InstallationAuthorizations """ def __repr__(self): return self.get__repr__({"expires_at": self._expires_at.value}) @property def token(self): """ :type: string """ return self._token.value @property def expires_at(self): """ :type: datetime """ return self._expires_at.value @property def on_behalf_of(self): """ :type: :class:`github.NamedUser.NamedUser` """ return self._on_behalf_of.value def _initAttributes(self): self._token = github.GithubObject.NotSet self._expires_at = github.GithubObject.NotSet self._on_behalf_of = github.GithubObject.NotSet def _useAttributes(self, attributes): if "token" in attributes: # pragma no branch self._token = self._makeStringAttribute(attributes["token"]) if "expires_at" in attributes: # pragma no branch self._expires_at = self._makeDatetimeAttribute(attributes["expires_at"]) if "on_behalf_of" in attributes: # pragma no branch self._on_behalf_of = self._makeClassAttribute( github.NamedUser.NamedUser, attributes["on_behalf_of"] ) ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1619412308.0 PyGithub-1.55/github/InstallationAuthorization.pyi0000644000175100001710000000102100000000000021760 0ustar00runnerdockerfrom datetime import datetime from typing import Any, Dict from github.GithubObject import NonCompletableGithubObject from github.NamedUser import NamedUser class InstallationAuthorization(NonCompletableGithubObject): def __repr__(self) -> str: ... def _initAttributes(self) -> None: ... def _useAttributes(self, attributes: Dict[str, Any]) -> None: ... @property def expires_at(self) -> datetime: ... @property def on_behalf_of(self) -> NamedUser: ... @property def token(self) -> str: ... ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1619412308.0 PyGithub-1.55/github/Invitation.py0000644000175100001710000001221400000000000016517 0ustar00runnerdocker############################ Copyrights and license ############################ # # # Copyright 2017 Jannis Gebauer # # Copyright 2017 Simon # # Copyright 2018 sfdye # # # # This file is part of PyGithub. # # http://pygithub.readthedocs.io/ # # # # PyGithub is free software: you can redistribute it and/or modify it under # # the terms of the GNU Lesser General Public License as published by the Free # # Software Foundation, either version 3 of the License, or (at your option) # # any later version. # # # # PyGithub is distributed in the hope that it will be useful, but WITHOUT ANY # # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more # # details. # # # # You should have received a copy of the GNU Lesser General Public License # # along with PyGithub. If not, see . # # # ################################################################################ import github.GithubObject class Invitation(github.GithubObject.CompletableGithubObject): """ This class represents repository invitations. The reference can be found here https://docs.github.com/en/rest/reference/repos#invitations """ def __repr__(self): return self.get__repr__({"id": self._id.value}) @property def id(self): """ :type: integer """ self._completeIfNotSet(self._id) return self._id.value @property def permissions(self): """ :type: string """ self._completeIfNotSet(self._permissions) return self._permissions.value @property def created_at(self): """ :type: string """ self._completeIfNotSet(self._created_at) return self._created_at.value @property def invitee(self): """ :type: NamedUser """ self._completeIfNotSet(self._invitee) return self._invitee.value @property def inviter(self): """ :type: NamedUser """ self._completeIfNotSet(self._inviter) return self._inviter.value @property def url(self): """ :type: string """ self._completeIfNotSet(self._url) return self._url.value @property def html_url(self): """ :type: string """ self._completeIfNotSet(self._html_url) return self._html_url.value @property def repository(self): """ :type: Repository """ self._completeIfNotSet(self._repository) return self._repository.value def _initAttributes(self): self._id = github.GithubObject.NotSet self._permissions = github.GithubObject.NotSet self._created_at = github.GithubObject.NotSet self._invitee = github.GithubObject.NotSet self._inviter = github.GithubObject.NotSet self._url = github.GithubObject.NotSet self._html_url = github.GithubObject.NotSet self._repository = github.GithubObject.NotSet def _useAttributes(self, attributes): if "repository" in attributes: # pragma no branch self._repository = self._makeClassAttribute( github.Repository.Repository, attributes["repository"] ) if "created_at" in attributes: # pragma no branch self._created_at = self._makeDatetimeAttribute(attributes["created_at"]) if "invitee" in attributes: # pragma no branch self._invitee = self._makeClassAttribute( github.NamedUser.NamedUser, attributes["invitee"] ) if "inviter" in attributes: # pragma no branch self._inviter = self._makeClassAttribute( github.NamedUser.NamedUser, attributes["inviter"] ) if "id" in attributes: # pragma no branch self._id = self._makeIntAttribute(attributes["id"]) if "permissions" in attributes: # pragma no branch self._permissions = self._makeStringAttribute(attributes["permissions"]) if "url" in attributes: # pragma no branch self._url = self._makeStringAttribute(attributes["url"]) if "html_url" in attributes: # pragma no branch self._html_url = self._makeStringAttribute(attributes["html_url"]) ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1619412308.0 PyGithub-1.55/github/Invitation.pyi0000644000175100001710000000137300000000000016674 0ustar00runnerdockerfrom typing import Any, Dict from github.GithubObject import CompletableGithubObject from github.NamedUser import NamedUser from github.Repository import Repository class Invitation(CompletableGithubObject): def __repr__(self) -> str: ... def _initAttributes(self) -> None: ... def _useAttributes(self, attributes: Dict[str, Any]) -> None: ... @property def created_at(self) -> str: ... @property def html_url(self) -> str: ... @property def id(self) -> int: ... @property def invitee(self) -> NamedUser: ... @property def inviter(self) -> NamedUser: ... @property def permissions(self) -> str: ... @property def repository(self) -> Repository: ... @property def url(self) -> str: ... ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1619412308.0 PyGithub-1.55/github/Issue.py0000644000175100001710000006746400000000000015504 0ustar00runnerdocker############################ Copyrights and license ############################ # # # Copyright 2012 Andrew Bettison # # Copyright 2012 Philip Kimmey # # Copyright 2012 Vincent Jacques # # Copyright 2012 Zearin # # Copyright 2013 AKFish # # Copyright 2013 David Farr # # Copyright 2013 Stuart Glaser # # Copyright 2013 Vincent Jacques # # Copyright 2014 Vincent Jacques # # Copyright 2015 Raja Reddy Karri # # Copyright 2016 @tmshn # # Copyright 2016 Jannis Gebauer # # Copyright 2016 Matt Babineau # # Copyright 2016 Peter Buckley # # Copyright 2017 Nicolas Agustín Torres # # Copyright 2017 Simon # # Copyright 2018 Shinichi TAMURA # # Copyright 2018 Steve Kowalik # # Copyright 2018 Wan Liuyang # # Copyright 2018 per1234 # # Copyright 2018 sfdye # # Copyright 2019 Nick Campbell # # Copyright 2020 Huan-Cheng Chang # # # # This file is part of PyGithub. # # http://pygithub.readthedocs.io/ # # # # PyGithub is free software: you can redistribute it and/or modify it under # # the terms of the GNU Lesser General Public License as published by the Free # # Software Foundation, either version 3 of the License, or (at your option) # # any later version. # # # # PyGithub is distributed in the hope that it will be useful, but WITHOUT ANY # # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more # # details. # # # # You should have received a copy of the GNU Lesser General Public License # # along with PyGithub. If not, see . # # # ################################################################################ import datetime import urllib.parse import github.GithubObject import github.IssueComment import github.IssueEvent import github.IssuePullRequest import github.Label import github.Milestone import github.NamedUser import github.PaginatedList import github.Reaction import github.Repository import github.TimelineEvent from . import Consts class Issue(github.GithubObject.CompletableGithubObject): """ This class represents Issues. The reference can be found here https://docs.github.com/en/rest/reference/issues """ def __repr__(self): return self.get__repr__( {"number": self._number.value, "title": self._title.value} ) @property def assignee(self): """ :type: :class:`github.NamedUser.NamedUser` """ self._completeIfNotSet(self._assignee) return self._assignee.value @property def assignees(self): """ :type: list of :class:`github.NamedUser.NamedUser` """ self._completeIfNotSet(self._assignees) return self._assignees.value @property def body(self): """ :type: string """ self._completeIfNotSet(self._body) return self._body.value @property def closed_at(self): """ :type: datetime.datetime """ self._completeIfNotSet(self._closed_at) return self._closed_at.value @property def closed_by(self): """ :type: :class:`github.NamedUser.NamedUser` """ self._completeIfNotSet(self._closed_by) return self._closed_by.value @property def comments(self): """ :type: integer """ self._completeIfNotSet(self._comments) return self._comments.value @property def comments_url(self): """ :type: string """ self._completeIfNotSet(self._comments_url) return self._comments_url.value @property def created_at(self): """ :type: datetime.datetime """ self._completeIfNotSet(self._created_at) return self._created_at.value @property def events_url(self): """ :type: string """ self._completeIfNotSet(self._events_url) return self._events_url.value @property def html_url(self): """ :type: string """ self._completeIfNotSet(self._html_url) return self._html_url.value @property def id(self): """ :type: integer """ self._completeIfNotSet(self._id) return self._id.value @property def labels(self): """ :type: list of :class:`github.Label.Label` """ self._completeIfNotSet(self._labels) return self._labels.value @property def labels_url(self): """ :type: string """ self._completeIfNotSet(self._labels_url) return self._labels_url.value @property def milestone(self): """ :type: :class:`github.Milestone.Milestone` """ self._completeIfNotSet(self._milestone) return self._milestone.value @property def number(self): """ :type: integer """ self._completeIfNotSet(self._number) return self._number.value @property def pull_request(self): """ :type: :class:`github.IssuePullRequest.IssuePullRequest` """ self._completeIfNotSet(self._pull_request) return self._pull_request.value @property def repository(self): """ :type: :class:`github.Repository.Repository` """ self._completeIfNotSet(self._repository) if self._repository is github.GithubObject.NotSet: # The repository was not set automatically, so it must be looked up by url. repo_url = "/".join(self.url.split("/")[:-2]) self._repository = github.GithubObject._ValuedAttribute( github.Repository.Repository( self._requester, self._headers, {"url": repo_url}, completed=False ) ) return self._repository.value @property def state(self): """ :type: string """ self._completeIfNotSet(self._state) return self._state.value @property def title(self): """ :type: string """ self._completeIfNotSet(self._title) return self._title.value @property def updated_at(self): """ :type: datetime.datetime """ self._completeIfNotSet(self._updated_at) return self._updated_at.value @property def url(self): """ :type: string """ self._completeIfNotSet(self._url) return self._url.value @property def user(self): """ :type: :class:`github.NamedUser.NamedUser` """ self._completeIfNotSet(self._user) return self._user.value @property def locked(self): """ :type: bool """ self._completeIfNotSet(self._locked) return self._locked.value @property def active_lock_reason(self): """ :type: string """ self._completeIfNotSet(self._active_lock_reason) return self._active_lock_reason.value def as_pull_request(self): """ :calls: `GET /repos/{owner}/{repo}/pulls/{number} `_ :rtype: :class:`github.PullRequest.PullRequest` """ headers, data = self._requester.requestJsonAndCheck( "GET", "/pulls/".join(self.url.rsplit("/issues/", 1)) ) return github.PullRequest.PullRequest( self._requester, headers, data, completed=True ) def add_to_assignees(self, *assignees): """ :calls: `POST /repos/{owner}/{repo}/issues/{number}/assignees `_ :param assignee: :class:`github.NamedUser.NamedUser` or string :rtype: None """ assert all( isinstance(element, (github.NamedUser.NamedUser, str)) for element in assignees ), assignees post_parameters = { "assignees": [ assignee.login if isinstance(assignee, github.NamedUser.NamedUser) else assignee for assignee in assignees ] } headers, data = self._requester.requestJsonAndCheck( "POST", f"{self.url}/assignees", input=post_parameters ) self._useAttributes(data) def add_to_labels(self, *labels): """ :calls: `POST /repos/{owner}/{repo}/issues/{number}/labels `_ :param label: :class:`github.Label.Label` or string :rtype: None """ assert all( isinstance(element, (github.Label.Label, str)) for element in labels ), labels post_parameters = [ label.name if isinstance(label, github.Label.Label) else label for label in labels ] headers, data = self._requester.requestJsonAndCheck( "POST", f"{self.url}/labels", input=post_parameters ) def create_comment(self, body): """ :calls: `POST /repos/{owner}/{repo}/issues/{number}/comments `_ :param body: string :rtype: :class:`github.IssueComment.IssueComment` """ assert isinstance(body, str), body post_parameters = { "body": body, } headers, data = self._requester.requestJsonAndCheck( "POST", f"{self.url}/comments", input=post_parameters ) return github.IssueComment.IssueComment( self._requester, headers, data, completed=True ) def delete_labels(self): """ :calls: `DELETE /repos/{owner}/{repo}/issues/{number}/labels `_ :rtype: None """ headers, data = self._requester.requestJsonAndCheck( "DELETE", f"{self.url}/labels" ) def edit( self, title=github.GithubObject.NotSet, body=github.GithubObject.NotSet, assignee=github.GithubObject.NotSet, state=github.GithubObject.NotSet, milestone=github.GithubObject.NotSet, labels=github.GithubObject.NotSet, assignees=github.GithubObject.NotSet, ): """ :calls: `PATCH /repos/{owner}/{repo}/issues/{number} `_ :param title: string :param body: string :param assignee: string or :class:`github.NamedUser.NamedUser` or None :param assignees: list of string or :class:`github.NamedUser.NamedUser` :param state: string :param milestone: :class:`github.Milestone.Milestone` or None :param labels: list of string :rtype: None """ assert title is github.GithubObject.NotSet or isinstance(title, str), title assert body is github.GithubObject.NotSet or isinstance(body, str), body assert ( assignee is github.GithubObject.NotSet or assignee is None or isinstance(assignee, github.NamedUser.NamedUser) or isinstance(assignee, str) ), assignee assert assignees is github.GithubObject.NotSet or all( isinstance(element, github.NamedUser.NamedUser) or isinstance(element, str) for element in assignees ), assignees assert state is github.GithubObject.NotSet or isinstance(state, str), state assert ( milestone is github.GithubObject.NotSet or milestone is None or isinstance(milestone, github.Milestone.Milestone) ), milestone assert labels is github.GithubObject.NotSet or all( isinstance(element, str) for element in labels ), labels post_parameters = dict() if title is not github.GithubObject.NotSet: post_parameters["title"] = title if body is not github.GithubObject.NotSet: post_parameters["body"] = body if assignee is not github.GithubObject.NotSet: if isinstance(assignee, str): post_parameters["assignee"] = assignee else: post_parameters["assignee"] = assignee._identity if assignee else "" if assignees is not github.GithubObject.NotSet: post_parameters["assignees"] = [ element._identity if isinstance(element, github.NamedUser.NamedUser) else element for element in assignees ] if state is not github.GithubObject.NotSet: post_parameters["state"] = state if milestone is not github.GithubObject.NotSet: post_parameters["milestone"] = milestone._identity if milestone else "" if labels is not github.GithubObject.NotSet: post_parameters["labels"] = labels headers, data = self._requester.requestJsonAndCheck( "PATCH", self.url, input=post_parameters ) self._useAttributes(data) def lock(self, lock_reason): """ :calls: `PUT /repos/{owner}/{repo}/issues/{issue_number}/lock `_ :param lock_reason: string :rtype: None """ assert isinstance(lock_reason, str), lock_reason put_parameters = dict() put_parameters["lock_reason"] = lock_reason headers, data = self._requester.requestJsonAndCheck( "PUT", f"{self.url}/lock", input=put_parameters, headers={"Accept": Consts.mediaTypeLockReasonPreview}, ) def unlock(self): """ :calls: `DELETE /repos/{owner}/{repo}/issues/{issue_number}/lock `_ :rtype: None """ headers, data = self._requester.requestJsonAndCheck( "DELETE", f"{self.url}/lock" ) def get_comment(self, id): """ :calls: `GET /repos/{owner}/{repo}/issues/comments/{id} `_ :param id: integer :rtype: :class:`github.IssueComment.IssueComment` """ assert isinstance(id, int), id headers, data = self._requester.requestJsonAndCheck( "GET", f"{self._parentUrl(self.url)}/comments/{id}" ) return github.IssueComment.IssueComment( self._requester, headers, data, completed=True ) def get_comments(self, since=github.GithubObject.NotSet): """ :calls: `GET /repos/{owner}/{repo}/issues/{number}/comments `_ :param since: datetime.datetime format YYYY-MM-DDTHH:MM:SSZ :rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.IssueComment.IssueComment` """ assert since is github.GithubObject.NotSet or isinstance( since, datetime.datetime ), since url_parameters = dict() if since is not github.GithubObject.NotSet: url_parameters["since"] = since.strftime("%Y-%m-%dT%H:%M:%SZ") return github.PaginatedList.PaginatedList( github.IssueComment.IssueComment, self._requester, f"{self.url}/comments", url_parameters, ) def get_events(self): """ :calls: `GET /repos/{owner}/{repo}/issues/{issue_number}/events `_ :rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.IssueEvent.IssueEvent` """ return github.PaginatedList.PaginatedList( github.IssueEvent.IssueEvent, self._requester, f"{self.url}/events", None, headers={"Accept": Consts.mediaTypeLockReasonPreview}, ) def get_labels(self): """ :calls: `GET /repos/{owner}/{repo}/issues/{number}/labels `_ :rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.Label.Label` """ return github.PaginatedList.PaginatedList( github.Label.Label, self._requester, f"{self.url}/labels", None ) def remove_from_assignees(self, *assignees): """ :calls: `DELETE /repos/{owner}/{repo}/issues/{number}/assignees `_ :param assignee: :class:`github.NamedUser.NamedUser` or string :rtype: None """ assert all( isinstance(element, (github.NamedUser.NamedUser, str)) for element in assignees ), assignees post_parameters = { "assignees": [ assignee.login if isinstance(assignee, github.NamedUser.NamedUser) else assignee for assignee in assignees ] } headers, data = self._requester.requestJsonAndCheck( "DELETE", f"{self.url}/assignees", input=post_parameters ) self._useAttributes(data) def remove_from_labels(self, label): """ :calls: `DELETE /repos/{owner}/{repo}/issues/{number}/labels/{name} `_ :param label: :class:`github.Label.Label` or string :rtype: None """ assert isinstance(label, (github.Label.Label, str)), label if isinstance(label, github.Label.Label): label = label._identity else: label = urllib.parse.quote(label) headers, data = self._requester.requestJsonAndCheck( "DELETE", f"{self.url}/labels/{label}" ) def set_labels(self, *labels): """ :calls: `PUT /repos/{owner}/{repo}/issues/{number}/labels `_ :param labels: list of :class:`github.Label.Label` or strings :rtype: None """ assert all( isinstance(element, (github.Label.Label, str)) for element in labels ), labels post_parameters = [ label.name if isinstance(label, github.Label.Label) else label for label in labels ] headers, data = self._requester.requestJsonAndCheck( "PUT", f"{self.url}/labels", input=post_parameters ) def get_reactions(self): """ :calls: `GET /repos/{owner}/{repo}/issues/{number}/reactions `_ :return: :class: :class:`github.PaginatedList.PaginatedList` of :class:`github.Reaction.Reaction` """ return github.PaginatedList.PaginatedList( github.Reaction.Reaction, self._requester, f"{self.url}/reactions", None, headers={"Accept": Consts.mediaTypeReactionsPreview}, ) def create_reaction(self, reaction_type): """ :calls: `POST /repos/{owner}/{repo}/issues/{number}/reactions `_ :param reaction_type: string :rtype: :class:`github.Reaction.Reaction` """ assert isinstance(reaction_type, str), reaction_type post_parameters = { "content": reaction_type, } headers, data = self._requester.requestJsonAndCheck( "POST", f"{self.url}/reactions", input=post_parameters, headers={"Accept": Consts.mediaTypeReactionsPreview}, ) return github.Reaction.Reaction(self._requester, headers, data, completed=True) def delete_reaction(self, reaction_id): """ :calls: `DELETE /repos/{owner}/{repo}/issues/{issue_number}/reactions/{reaction_id} `_ :param reaction_id: integer :rtype: bool """ assert isinstance(reaction_id, int), reaction_id status, _, _ = self._requester.requestJson( "DELETE", f"{self.url}/reactions/{reaction_id}", headers={"Accept": Consts.mediaTypeReactionsPreview}, ) return status == 204 def get_timeline(self): """ :calls: `GET /repos/{owner}/{repo}/issues/{number}/timeline `_ :return: :class: :class:`github.PaginatedList.PaginatedList` of :class:`github.TimelineEvent.TimelineEvent` """ return github.PaginatedList.PaginatedList( github.TimelineEvent.TimelineEvent, self._requester, f"{self.url}/timeline", None, headers={"Accept": Consts.issueTimelineEventsPreview}, ) @property def _identity(self): return self.number def _initAttributes(self): self._active_lock_reason = github.GithubObject.NotSet self._assignee = github.GithubObject.NotSet self._assignees = github.GithubObject.NotSet self._body = github.GithubObject.NotSet self._closed_at = github.GithubObject.NotSet self._closed_by = github.GithubObject.NotSet self._comments = github.GithubObject.NotSet self._comments_url = github.GithubObject.NotSet self._created_at = github.GithubObject.NotSet self._events_url = github.GithubObject.NotSet self._html_url = github.GithubObject.NotSet self._id = github.GithubObject.NotSet self._labels = github.GithubObject.NotSet self._labels_url = github.GithubObject.NotSet self._locked = github.GithubObject.NotSet self._milestone = github.GithubObject.NotSet self._number = github.GithubObject.NotSet self._pull_request = github.GithubObject.NotSet self._repository = github.GithubObject.NotSet self._state = github.GithubObject.NotSet self._title = github.GithubObject.NotSet self._updated_at = github.GithubObject.NotSet self._url = github.GithubObject.NotSet self._user = github.GithubObject.NotSet def _useAttributes(self, attributes): if "active_lock_reason" in attributes: # pragma no branch self._active_lock_reason = self._makeStringAttribute( attributes["active_lock_reason"] ) if "assignee" in attributes: # pragma no branch self._assignee = self._makeClassAttribute( github.NamedUser.NamedUser, attributes["assignee"] ) if "assignees" in attributes: # pragma no branch self._assignees = self._makeListOfClassesAttribute( github.NamedUser.NamedUser, attributes["assignees"] ) elif "assignee" in attributes: if attributes["assignee"] is not None: self._assignees = self._makeListOfClassesAttribute( github.NamedUser.NamedUser, [attributes["assignee"]] ) else: self._assignees = self._makeListOfClassesAttribute( github.NamedUser.NamedUser, [] ) if "body" in attributes: # pragma no branch self._body = self._makeStringAttribute(attributes["body"]) if "closed_at" in attributes: # pragma no branch self._closed_at = self._makeDatetimeAttribute(attributes["closed_at"]) if "closed_by" in attributes: # pragma no branch self._closed_by = self._makeClassAttribute( github.NamedUser.NamedUser, attributes["closed_by"] ) if "comments" in attributes: # pragma no branch self._comments = self._makeIntAttribute(attributes["comments"]) if "comments_url" in attributes: # pragma no branch self._comments_url = self._makeStringAttribute(attributes["comments_url"]) if "created_at" in attributes: # pragma no branch self._created_at = self._makeDatetimeAttribute(attributes["created_at"]) if "events_url" in attributes: # pragma no branch self._events_url = self._makeStringAttribute(attributes["events_url"]) if "html_url" in attributes: # pragma no branch self._html_url = self._makeStringAttribute(attributes["html_url"]) if "id" in attributes: # pragma no branch self._id = self._makeIntAttribute(attributes["id"]) if "labels" in attributes: # pragma no branch self._labels = self._makeListOfClassesAttribute( github.Label.Label, attributes["labels"] ) if "labels_url" in attributes: # pragma no branch self._labels_url = self._makeStringAttribute(attributes["labels_url"]) if "locked" in attributes: # pragma no branch self._locked = self._makeBoolAttribute(attributes["locked"]) if "milestone" in attributes: # pragma no branch self._milestone = self._makeClassAttribute( github.Milestone.Milestone, attributes["milestone"] ) if "number" in attributes: # pragma no branch self._number = self._makeIntAttribute(attributes["number"]) if "pull_request" in attributes: # pragma no branch self._pull_request = self._makeClassAttribute( github.IssuePullRequest.IssuePullRequest, attributes["pull_request"] ) if "repository" in attributes: # pragma no branch self._repository = self._makeClassAttribute( github.Repository.Repository, attributes["repository"] ) if "state" in attributes: # pragma no branch self._state = self._makeStringAttribute(attributes["state"]) if "title" in attributes: # pragma no branch self._title = self._makeStringAttribute(attributes["title"]) if "updated_at" in attributes: # pragma no branch self._updated_at = self._makeDatetimeAttribute(attributes["updated_at"]) if "url" in attributes: # pragma no branch self._url = self._makeStringAttribute(attributes["url"]) if "user" in attributes: # pragma no branch self._user = self._makeClassAttribute( github.NamedUser.NamedUser, attributes["user"] ) ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1619412308.0 PyGithub-1.55/github/Issue.pyi0000644000175100001710000000720300000000000015636 0ustar00runnerdockerfrom datetime import datetime from typing import Any, Dict, List, Optional, Union from github.GithubObject import CompletableGithubObject, _NotSetType from github.IssueComment import IssueComment from github.IssueEvent import IssueEvent from github.IssuePullRequest import IssuePullRequest from github.Label import Label from github.Milestone import Milestone from github.NamedUser import NamedUser from github.PaginatedList import PaginatedList from github.PullRequest import PullRequest from github.Reaction import Reaction from github.Repository import Repository from github.TimelineEvent import TimelineEvent class Issue(CompletableGithubObject): def __repr__(self) -> str: ... @property def _identity(self) -> int: ... def _initAttributes(self) -> None: ... def _useAttributes(self, attributes: Dict[str, Any]) -> None: ... def add_to_assignees(self, *assignees: Union[NamedUser, str]) -> None: ... def add_to_labels(self, *labels: Union[Label, str]) -> None: ... def as_pull_request(self) -> PullRequest: ... @property def active_lock_reason(self) -> str: ... @property def assignee(self) -> Optional[NamedUser]: ... @property def assignees(self) -> List[NamedUser]: ... @property def body(self) -> str: ... @property def closed_at(self) -> datetime: ... @property def closed_by(self) -> Optional[NamedUser]: ... @property def comments(self) -> int: ... @property def comments_url(self) -> str: ... def create_comment(self, body: str) -> IssueComment: ... def create_reaction(self, reaction_type: str) -> Reaction: ... def get_timeline(self) -> PaginatedList[TimelineEvent]: ... @property def created_at(self) -> datetime: ... def delete_labels(self) -> None: ... def delete_reaction(self, reaction_id: int) -> bool: ... def edit( self, title: Union[str, _NotSetType] = ..., body: Union[str, _NotSetType] = ..., assignee: Optional[Union[str, _NotSetType, NamedUser]] = ..., state: Union[str, _NotSetType] = ..., milestone: Optional[Union[Milestone, _NotSetType]] = ..., labels: Union[_NotSetType, List[str]] = ..., assignees: Union[_NotSetType, List[str]] = ..., ) -> None: ... @property def events_url(self) -> str: ... def get_comment(self, id: int) -> IssueComment: ... def get_comments( self, since: Union[_NotSetType, datetime] = ... ) -> PaginatedList[IssueComment]: ... def get_events(self) -> PaginatedList[IssueEvent]: ... def get_labels(self) -> PaginatedList[Label]: ... def get_reactions(self) -> PaginatedList[Reaction]: ... @property def html_url(self) -> str: ... @property def id(self) -> int: ... @property def labels(self) -> List[Label]: ... @property def labels_url(self) -> str: ... def lock(self, lock_reason: str) -> None: ... @property def locked(self) -> bool: ... @property def milestone(self) -> Optional[Milestone]: ... @property def number(self) -> int: ... @property def pull_request(self) -> IssuePullRequest: ... def remove_from_assignees(self, *assignees: Union[NamedUser, str]) -> None: ... def remove_from_labels(self, label: Union[str, Label]) -> None: ... @property def repository(self) -> Repository: ... def set_labels(self, *labels: Union[str, Label]) -> None: ... @property def state(self) -> str: ... @property def title(self) -> str: ... def unlock(self) -> None: ... @property def updated_at(self) -> datetime: ... @property def url(self) -> str: ... @property def user(self) -> NamedUser: ... ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1619412308.0 PyGithub-1.55/github/IssueComment.py0000644000175100001710000002111000000000000017001 0ustar00runnerdocker############################ Copyrights and license ############################ # # # Copyright 2012 Vincent Jacques # # Copyright 2012 Zearin # # Copyright 2013 AKFish # # Copyright 2013 Michael Stead # # Copyright 2013 Vincent Jacques # # Copyright 2014 Vincent Jacques # # Copyright 2016 Jannis Gebauer # # Copyright 2016 Peter Buckley # # Copyright 2017 Nicolas Agustín Torres # # Copyright 2018 Wan Liuyang # # Copyright 2018 per1234 # # Copyright 2018 sfdye # # Copyright 2020 Huan-Cheng Chang # # # # This file is part of PyGithub. # # http://pygithub.readthedocs.io/ # # # # PyGithub is free software: you can redistribute it and/or modify it under # # the terms of the GNU Lesser General Public License as published by the Free # # Software Foundation, either version 3 of the License, or (at your option) # # any later version. # # # # PyGithub is distributed in the hope that it will be useful, but WITHOUT ANY # # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more # # details. # # # # You should have received a copy of the GNU Lesser General Public License # # along with PyGithub. If not, see . # # # ################################################################################ import github.GithubObject import github.NamedUser from . import Consts class IssueComment(github.GithubObject.CompletableGithubObject): """ This class represents IssueComments. The reference can be found here https://docs.github.com/en/rest/reference/issues#comments """ def __repr__(self): return self.get__repr__({"id": self._id.value, "user": self._user.value}) @property def body(self): """ :type: string """ self._completeIfNotSet(self._body) return self._body.value @property def created_at(self): """ :type: datetime.datetime """ self._completeIfNotSet(self._created_at) return self._created_at.value @property def id(self): """ :type: integer """ self._completeIfNotSet(self._id) return self._id.value @property def issue_url(self): """ :type: string """ self._completeIfNotSet(self._issue_url) return self._issue_url.value @property def updated_at(self): """ :type: datetime.datetime """ self._completeIfNotSet(self._updated_at) return self._updated_at.value @property def url(self): """ :type: string """ self._completeIfNotSet(self._url) return self._url.value @property def html_url(self): """ :type: string """ self._completeIfNotSet(self._html_url) return self._html_url.value @property def user(self): """ :type: :class:`github.NamedUser.NamedUser` """ self._completeIfNotSet(self._user) return self._user.value def delete(self): """ :calls: `DELETE /repos/{owner}/{repo}/issues/comments/{id} `_ :rtype: None """ headers, data = self._requester.requestJsonAndCheck("DELETE", self.url) def edit(self, body): """ :calls: `PATCH /repos/{owner}/{repo}/issues/comments/{id} `_ :param body: string :rtype: None """ assert isinstance(body, str), body post_parameters = { "body": body, } headers, data = self._requester.requestJsonAndCheck( "PATCH", self.url, input=post_parameters ) self._useAttributes(data) def get_reactions(self): """ :calls: `GET /repos/{owner}/{repo}/issues/comments/{id}/reactions `_ :return: :class: :class:`github.PaginatedList.PaginatedList` of :class:`github.Reaction.Reaction` """ return github.PaginatedList.PaginatedList( github.Reaction.Reaction, self._requester, f"{self.url}/reactions", None, headers={"Accept": Consts.mediaTypeReactionsPreview}, ) def create_reaction(self, reaction_type): """ :calls: `POST /repos/{owner}/{repo}/issues/comments/{id}/reactions `_ :param reaction_type: string :rtype: :class:`github.Reaction.Reaction` """ assert isinstance(reaction_type, str), reaction_type post_parameters = { "content": reaction_type, } headers, data = self._requester.requestJsonAndCheck( "POST", f"{self.url}/reactions", input=post_parameters, headers={"Accept": Consts.mediaTypeReactionsPreview}, ) return github.Reaction.Reaction(self._requester, headers, data, completed=True) def delete_reaction(self, reaction_id): """ :calls: `DELETE /repos/{owner}/{repo}/issues/comments/{comment_id}/reactions/{reaction_id} `_ :param reaction_id: integer :rtype: bool """ assert isinstance(reaction_id, int), reaction_id status, _, _ = self._requester.requestJson( "DELETE", f"{self.url}/reactions/{reaction_id}", headers={"Accept": Consts.mediaTypeReactionsPreview}, ) return status == 204 def _initAttributes(self): self._body = github.GithubObject.NotSet self._created_at = github.GithubObject.NotSet self._id = github.GithubObject.NotSet self._issue_url = github.GithubObject.NotSet self._updated_at = github.GithubObject.NotSet self._url = github.GithubObject.NotSet self._html_url = github.GithubObject.NotSet self._user = github.GithubObject.NotSet def _useAttributes(self, attributes): if "body" in attributes: # pragma no branch self._body = self._makeStringAttribute(attributes["body"]) if "created_at" in attributes: # pragma no branch self._created_at = self._makeDatetimeAttribute(attributes["created_at"]) if "id" in attributes: # pragma no branch self._id = self._makeIntAttribute(attributes["id"]) if "issue_url" in attributes: # pragma no branch self._issue_url = self._makeStringAttribute(attributes["issue_url"]) if "updated_at" in attributes: # pragma no branch self._updated_at = self._makeDatetimeAttribute(attributes["updated_at"]) if "url" in attributes: # pragma no branch self._url = self._makeStringAttribute(attributes["url"]) if "html_url" in attributes: # pragma no branch self._html_url = self._makeStringAttribute(attributes["html_url"]) if "user" in attributes: # pragma no branch self._user = self._makeClassAttribute( github.NamedUser.NamedUser, attributes["user"] ) ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1619412308.0 PyGithub-1.55/github/IssueComment.pyi0000644000175100001710000000210400000000000017154 0ustar00runnerdockerfrom datetime import datetime from typing import Any, Dict from github.GithubObject import CompletableGithubObject from github.NamedUser import NamedUser from github.PaginatedList import PaginatedList from github.Reaction import Reaction class IssueComment(CompletableGithubObject): def __repr__(self) -> str: ... def _initAttributes(self) -> None: ... def _useAttributes(self, attributes: Dict[str, Any]) -> None: ... @property def body(self) -> str: ... def create_reaction(self, reaction_type: str) -> Reaction: ... @property def created_at(self) -> datetime: ... def delete(self) -> None: ... def delete_reaction(self, reaction_id: int) -> bool: ... def edit(self, body: str) -> None: ... def get_reactions(self) -> PaginatedList[Reaction]: ... @property def html_url(self) -> str: ... @property def id(self) -> int: ... @property def issue_url(self) -> str: ... @property def updated_at(self) -> datetime: ... @property def url(self) -> str: ... @property def user(self) -> NamedUser: ... ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1619412308.0 PyGithub-1.55/github/IssueEvent.py0000644000175100001710000002345200000000000016473 0ustar00runnerdocker############################ Copyrights and license ############################ # # # Copyright 2012 Vincent Jacques # # Copyright 2012 Zearin # # Copyright 2013 AKFish # # Copyright 2013 Vincent Jacques # # Copyright 2014 Vincent Jacques # # Copyright 2016 Jannis Gebauer # # Copyright 2016 Peter Buckley # # Copyright 2017 Simon # # Copyright 2018 Wan Liuyang # # Copyright 2018 sfdye # # # # This file is part of PyGithub. # # http://pygithub.readthedocs.io/ # # # # PyGithub is free software: you can redistribute it and/or modify it under # # the terms of the GNU Lesser General Public License as published by the Free # # Software Foundation, either version 3 of the License, or (at your option) # # any later version. # # # # PyGithub is distributed in the hope that it will be useful, but WITHOUT ANY # # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more # # details. # # # # You should have received a copy of the GNU Lesser General Public License # # along with PyGithub. If not, see . # # # ################################################################################ import github.GithubObject import github.Issue import github.NamedUser class IssueEvent(github.GithubObject.CompletableGithubObject): """ This class represents IssueEvents. The reference can be found here https://docs.github.com/en/rest/reference/issues#events """ def __repr__(self): return self.get__repr__({"id": self._id.value}) @property def actor(self): """ :type: :class:`github.NamedUser.NamedUser` """ self._completeIfNotSet(self._actor) return self._actor.value @property def commit_id(self): """ :type: string """ self._completeIfNotSet(self._commit_id) return self._commit_id.value @property def created_at(self): """ :type: datetime.datetime """ self._completeIfNotSet(self._created_at) return self._created_at.value @property def event(self): """ :type: string """ self._completeIfNotSet(self._event) return self._event.value @property def id(self): """ :type: integer """ self._completeIfNotSet(self._id) return self._id.value @property def issue(self): """ :type: :class:`github.Issue.Issue` """ self._completeIfNotSet(self._issue) return self._issue.value @property def url(self): """ :type: string """ self._completeIfNotSet(self._url) return self._url.value @property def node_id(self): """ :type: string """ self._completeIfNotSet(self._node_id) return self._node_id.value @property def commit_url(self): """ :type: string """ self._completeIfNotSet(self._commit_url) return self._commit_url.value @property def label(self): """ :type: :class:`github.Label.Label` """ self._completeIfNotSet(self._label) return self._label.value @property def assignee(self): """ :type: :class:`github.NamedUser.NamedUser` """ self._completeIfNotSet(self._assignee) return self._assignee.value @property def assigner(self): """ :type: :class:`github.NamedUser.NamedUser` """ self._completeIfNotSet(self._assigner) return self._assigner.value @property def review_requester(self): """ :type: :class:`github.NamedUser.NamedUser` """ self._completeIfNotSet(self._review_requester) return self._review_requester.value @property def requested_reviewer(self): """ :type: :class:`github.NamedUser.NamedUser` """ self._completeIfNotSet(self._requested_reviewer) return self._requested_reviewer.value @property def milestone(self): """ :type: :class:`github.Milestone.Milestone` """ self._completeIfNotSet(self._milestone) return self._milestone.value @property def rename(self): """ :type: dict """ self._completeIfNotSet(self._rename) return self._rename.value @property def dismissed_review(self): """ :type: dict """ self._completeIfNotSet(self._dismissed_review) return self._dismissed_review.value @property def lock_reason(self): """ :type: string """ self._completeIfNotSet(self._lock_reason) return self._lock_reason.value def _initAttributes(self): self._actor = github.GithubObject.NotSet self._commit_id = github.GithubObject.NotSet self._created_at = github.GithubObject.NotSet self._event = github.GithubObject.NotSet self._id = github.GithubObject.NotSet self._issue = github.GithubObject.NotSet self._url = github.GithubObject.NotSet self._node_id = github.GithubObject.NotSet self._commit_url = github.GithubObject.NotSet self._label = github.GithubObject.NotSet self._assignee = github.GithubObject.NotSet self._assigner = github.GithubObject.NotSet self._review_requester = github.GithubObject.NotSet self._requested_reviewer = github.GithubObject.NotSet self._milestone = github.GithubObject.NotSet self._rename = github.GithubObject.NotSet self._dismissed_review = github.GithubObject.NotSet self._lock_reason = github.GithubObject.NotSet def _useAttributes(self, attributes): if "actor" in attributes: # pragma no branch self._actor = self._makeClassAttribute( github.NamedUser.NamedUser, attributes["actor"] ) if "commit_id" in attributes: # pragma no branch self._commit_id = self._makeStringAttribute(attributes["commit_id"]) if "created_at" in attributes: # pragma no branch self._created_at = self._makeDatetimeAttribute(attributes["created_at"]) if "event" in attributes: # pragma no branch self._event = self._makeStringAttribute(attributes["event"]) if "id" in attributes: # pragma no branch self._id = self._makeIntAttribute(attributes["id"]) if "issue" in attributes: # pragma no branch self._issue = self._makeClassAttribute( github.Issue.Issue, attributes["issue"] ) if "url" in attributes: # pragma no branch self._url = self._makeStringAttribute(attributes["url"]) if "node_id" in attributes: # pragma no branch self._node_id = self._makeStringAttribute(attributes["node_id"]) if "commit_url" in attributes: # pragma no branch self._commit_url = self._makeStringAttribute(attributes["commit_url"]) if "label" in attributes: # pragma no branch self._label = self._makeClassAttribute( github.Label.Label, attributes["label"] ) if "assignee" in attributes: # pragma no branch self._assignee = self._makeClassAttribute( github.NamedUser.NamedUser, attributes["assignee"] ) if "assigner" in attributes: # pragma no branch self._assigner = self._makeClassAttribute( github.NamedUser.NamedUser, attributes["assigner"] ) if "review_requester" in attributes: # pragma no branch self._review_requester = self._makeClassAttribute( github.NamedUser.NamedUser, attributes["review_requester"] ) if "requested_reviewer" in attributes: # pragma no branch self._requested_reviewer = self._makeClassAttribute( github.NamedUser.NamedUser, attributes["requested_reviewer"] ) if "milestone" in attributes: # pragma no branch self._milestone = self._makeClassAttribute( github.Milestone.Milestone, attributes["milestone"] ) if "rename" in attributes: # pragma no branch self._rename = self._makeDictAttribute(attributes["rename"]) if "dismissed_review" in attributes: # pragma no branch self._dismissed_review = self._makeDictAttribute( attributes["dismissed_review"] ) if "lock_reason" in attributes: # pragma no branch self._lock_reason = self._makeStringAttribute(attributes["lock_reason"]) ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1619412308.0 PyGithub-1.55/github/IssueEvent.pyi0000644000175100001710000000261000000000000016635 0ustar00runnerdockerfrom typing import Any, Dict, Optional, Union from github.GithubObject import CompletableGithubObject from github.Issue import Issue from github.Label import Label from github.Milestone import Milestone from github.NamedUser import NamedUser class IssueEvent(CompletableGithubObject): def __repr__(self) -> str: ... def _initAttributes(self) -> None: ... def _useAttributes(self, attributes: Dict[str, Any]) -> None: ... @property def actor(self) -> NamedUser: ... @property def assignee(self) -> Optional[NamedUser]: ... @property def assigner(self) -> Optional[NamedUser]: ... @property def commit_id(self) -> Optional[str]: ... @property def commit_url(self) -> Optional[str]: ... @property def dismissed_review(self) -> Optional[Dict[str, Union[str, int]]]: ... @property def event(self) -> str: ... @property def issue(self) -> Issue: ... @property def label(self) -> Optional[Label]: ... @property def lock_reason(self) -> Optional[str]: ... @property def milestone(self) -> Optional[Milestone]: ... @property def node_id(self) -> str: ... @property def rename(self) -> Optional[Dict[str, str]]: ... @property def requested_reviewer(self) -> Optional[NamedUser]: ... @property def review_requester(self) -> Optional[NamedUser]: ... @property def url(self) -> str: ... ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1619412308.0 PyGithub-1.55/github/IssuePullRequest.py0000644000175100001710000000655600000000000017705 0ustar00runnerdocker############################ Copyrights and license ############################ # # # Copyright 2012 Vincent Jacques # # Copyright 2012 Zearin # # Copyright 2013 AKFish # # Copyright 2013 Vincent Jacques # # Copyright 2014 Vincent Jacques # # Copyright 2016 Peter Buckley # # Copyright 2018 Wan Liuyang # # Copyright 2018 sfdye # # # # This file is part of PyGithub. # # http://pygithub.readthedocs.io/ # # # # PyGithub is free software: you can redistribute it and/or modify it under # # the terms of the GNU Lesser General Public License as published by the Free # # Software Foundation, either version 3 of the License, or (at your option) # # any later version. # # # # PyGithub is distributed in the hope that it will be useful, but WITHOUT ANY # # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more # # details. # # # # You should have received a copy of the GNU Lesser General Public License # # along with PyGithub. If not, see . # # # ################################################################################ import github.GithubObject class IssuePullRequest(github.GithubObject.NonCompletableGithubObject): """ This class represents IssuePullRequests """ @property def diff_url(self): """ :type: string """ return self._diff_url.value @property def html_url(self): """ :type: string """ return self._html_url.value @property def patch_url(self): """ :type: string """ return self._patch_url.value def _initAttributes(self): self._diff_url = github.GithubObject.NotSet self._html_url = github.GithubObject.NotSet self._patch_url = github.GithubObject.NotSet def _useAttributes(self, attributes): if "diff_url" in attributes: # pragma no branch self._diff_url = self._makeStringAttribute(attributes["diff_url"]) if "html_url" in attributes: # pragma no branch self._html_url = self._makeStringAttribute(attributes["html_url"]) if "patch_url" in attributes: # pragma no branch self._patch_url = self._makeStringAttribute(attributes["patch_url"]) ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1619412308.0 PyGithub-1.55/github/IssuePullRequest.pyi0000644000175100001710000000062300000000000020043 0ustar00runnerdockerfrom typing import Any, Dict from github.GithubObject import NonCompletableGithubObject class IssuePullRequest(NonCompletableGithubObject): def _initAttributes(self) -> None: ... def _useAttributes(self, attributes: Dict[str, Any]) -> None: ... @property def diff_url(self) -> str: ... @property def html_url(self) -> str: ... @property def patch_url(self) -> str: ... ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1619412308.0 PyGithub-1.55/github/Label.py0000644000175100001710000001272100000000000015415 0ustar00runnerdocker############################ Copyrights and license ############################ # # # Copyright 2012 Vincent Jacques # # Copyright 2012 Zearin # # Copyright 2013 AKFish # # Copyright 2013 Vincent Jacques # # Copyright 2013 martinqt # # Copyright 2014 Vincent Jacques # # Copyright 2016 Jannis Gebauer # # Copyright 2016 Peter Buckley # # Copyright 2018 Mateusz Loskot # # Copyright 2018 sfdye # # # # This file is part of PyGithub. # # http://pygithub.readthedocs.io/ # # # # PyGithub is free software: you can redistribute it and/or modify it under # # the terms of the GNU Lesser General Public License as published by the Free # # Software Foundation, either version 3 of the License, or (at your option) # # any later version. # # # # PyGithub is distributed in the hope that it will be useful, but WITHOUT ANY # # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more # # details. # # # # You should have received a copy of the GNU Lesser General Public License # # along with PyGithub. If not, see . # # # ################################################################################ import urllib.parse import github.GithubObject from . import Consts class Label(github.GithubObject.CompletableGithubObject): """ This class represents Labels. The reference can be found here http://docs.github.com/en/rest/reference/issues#labels """ def __repr__(self): return self.get__repr__({"name": self._name.value}) @property def color(self): """ :type: string """ self._completeIfNotSet(self._color) return self._color.value @property def description(self): """ :type: string """ self._completeIfNotSet(self._description) return self._description.value @property def name(self): """ :type: string """ self._completeIfNotSet(self._name) return self._name.value @property def url(self): """ :type: string """ self._completeIfNotSet(self._url) return self._url.value def delete(self): """ :calls: `DELETE /repos/{owner}/{repo}/labels/{name} `_ :rtype: None """ headers, data = self._requester.requestJsonAndCheck("DELETE", self.url) def edit(self, name, color, description=github.GithubObject.NotSet): """ :calls: `PATCH /repos/{owner}/{repo}/labels/{name} `_ :param name: string :param color: string :param description: string :rtype: None """ assert isinstance(name, str), name assert isinstance(color, str), color assert description is github.GithubObject.NotSet or isinstance( description, str ), description post_parameters = { "new_name": name, "color": color, } if description is not github.GithubObject.NotSet: post_parameters["description"] = description headers, data = self._requester.requestJsonAndCheck( "PATCH", self.url, input=post_parameters, headers={"Accept": Consts.mediaTypeLabelDescriptionSearchPreview}, ) self._useAttributes(data) @property def _identity(self): return urllib.parse.quote(self.name) def _initAttributes(self): self._color = github.GithubObject.NotSet self._description = github.GithubObject.NotSet self._name = github.GithubObject.NotSet self._url = github.GithubObject.NotSet def _useAttributes(self, attributes): if "color" in attributes: # pragma no branch self._color = self._makeStringAttribute(attributes["color"]) if "description" in attributes: # pragma no branch self._description = self._makeStringAttribute(attributes["description"]) if "name" in attributes: # pragma no branch self._name = self._makeStringAttribute(attributes["name"]) if "url" in attributes: # pragma no branch self._url = self._makeStringAttribute(attributes["url"]) ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1619412308.0 PyGithub-1.55/github/Label.pyi0000644000175100001710000000127100000000000015564 0ustar00runnerdockerfrom typing import Any, Dict, Optional, Union from github.GithubObject import CompletableGithubObject, _NotSetType class Label(CompletableGithubObject): def __repr__(self) -> str: ... @property def _identity(self) -> str: ... def _initAttributes(self) -> None: ... def _useAttributes(self, attributes: Dict[str, Any]) -> None: ... @property def color(self) -> str: ... def delete(self) -> None: ... @property def description(self) -> Optional[str]: ... def edit( self, name: str, color: str, description: Union[str, _NotSetType] = ... ) -> None: ... @property def name(self) -> str: ... @property def url(self) -> str: ... ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1619412308.0 PyGithub-1.55/github/License.py0000644000175100001710000001401100000000000015752 0ustar00runnerdocker############################ Copyrights and license ############################ # # # Copyright 2018 Wan Liuyang # # # # This file is part of PyGithub. # # http://pygithub.readthedocs.io/ # # # # PyGithub is free software: you can redistribute it and/or modify it under # # the terms of the GNU Lesser General Public License as published by the Free # # Software Foundation, either version 3 of the License, or (at your option) # # any later version. # # # # PyGithub is distributed in the hope that it will be useful, but WITHOUT ANY # # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more # # details. # # # # You should have received a copy of the GNU Lesser General Public License # # along with PyGithub. If not, see . # # # ################################################################################ import github.GithubObject class License(github.GithubObject.CompletableGithubObject): """ This class represents Licenses. The reference can be found here https://docs.github.com/en/rest/reference/licenses """ def __repr__(self): return self.get__repr__({"name": self._name.value}) @property def key(self): """ :type: string """ self._completeIfNotSet(self._key) return self._key.value @property def name(self): """ :type: string """ self._completeIfNotSet(self._name) return self._name.value @property def spdx_id(self): """ :type: string """ self._completeIfNotSet(self._spdx_id) return self._spdx_id.value @property def url(self): """ :type: string """ self._completeIfNotSet(self._url) return self._url.value @property def html_url(self): """ :type: string """ self._completeIfNotSet(self._html_url) return self._html_url.value @property def description(self): """ :type: string """ self._completeIfNotSet(self._description) return self._description.value @property def implementation(self): """ :type: string """ self._completeIfNotSet(self._implementation) return self._implementation.value @property def body(self): """ :type: string """ self._completeIfNotSet(self._body) return self._body.value @property def permissions(self): """ :type: list of string """ self._completeIfNotSet(self._permissions) return self._permissions.value @property def conditions(self): """ :type: list of string """ self._completeIfNotSet(self._conditions) return self._conditions.value @property def limitations(self): """ :type: list of string """ self._completeIfNotSet(self._limitations) return self._limitations.value def _initAttributes(self): self._key = github.GithubObject.NotSet self._name = github.GithubObject.NotSet self._spdx_id = github.GithubObject.NotSet self._url = github.GithubObject.NotSet self._html_url = github.GithubObject.NotSet self._description = github.GithubObject.NotSet self._implementation = github.GithubObject.NotSet self._body = github.GithubObject.NotSet self._permissions = github.GithubObject.NotSet self._conditions = github.GithubObject.NotSet self._limitations = github.GithubObject.NotSet def _useAttributes(self, attributes): if "key" in attributes: # pragma no branch self._key = self._makeStringAttribute(attributes["key"]) if "name" in attributes: # pragma no branch self._name = self._makeStringAttribute(attributes["name"]) if "spdx_id" in attributes: # pragma no branch self._spdx_id = self._makeStringAttribute(attributes["spdx_id"]) if "url" in attributes: # pragma no branch self._url = self._makeStringAttribute(attributes["url"]) if "html_url" in attributes: # pragma no branch self._html_url = self._makeStringAttribute(attributes["html_url"]) if "description" in attributes: # pragma no branch self._description = self._makeStringAttribute(attributes["description"]) if "implementation" in attributes: # pragma no branch self._implementation = self._makeStringAttribute( attributes["implementation"] ) if "body" in attributes: # pragma no branch self._body = self._makeStringAttribute(attributes["body"]) if "permissions" in attributes: # pragma no branch self._permissions = self._makeListOfStringsAttribute( attributes["permissions"] ) if "conditions" in attributes: # pragma no branch self._conditions = self._makeListOfStringsAttribute( attributes["conditions"] ) if "limitations" in attributes: # pragma no branch self._limitations = self._makeListOfStringsAttribute( attributes["limitations"] ) ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1619412308.0 PyGithub-1.55/github/License.pyi0000644000175100001710000000150400000000000016126 0ustar00runnerdockerfrom typing import Any, Dict, List from github.GithubObject import CompletableGithubObject class License(CompletableGithubObject): def __repr__(self) -> str: ... def _initAttributes(self) -> None: ... def _useAttributes(self, attributes: Dict[str, Any]) -> None: ... @property def body(self) -> str: ... @property def conditions(self) -> List[str]: ... @property def description(self) -> str: ... @property def html_url(self) -> str: ... @property def implementation(self) -> str: ... @property def key(self) -> str: ... @property def limitations(self) -> List[str]: ... @property def name(self) -> str: ... @property def permissions(self) -> List[str]: ... @property def url(self) -> str: ... @property def spdx_id(self) -> str: ... ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1619412308.0 PyGithub-1.55/github/MainClass.py0000644000175100001710000010457500000000000016261 0ustar00runnerdocker############################ Copyrights and license ############################ # # # Copyright 2013 AKFish # # Copyright 2013 Ed Jackson # # Copyright 2013 Jonathan J Hunt # # Copyright 2013 Peter Golm # # Copyright 2013 Steve Brown # # Copyright 2013 Vincent Jacques # # Copyright 2014 C. R. Oldham # # Copyright 2014 Thialfihar # # Copyright 2014 Tyler Treat # # Copyright 2014 Vincent Jacques # # Copyright 2015 Daniel Pocock # # Copyright 2015 Joseph Rawson # # Copyright 2015 Uriel Corfa # # Copyright 2015 edhollandAL # # Copyright 2016 Jannis Gebauer # # Copyright 2016 Peter Buckley # # Copyright 2017 Colin Hoglund # # Copyright 2017 Jannis Gebauer # # Copyright 2018 Agor Maxime # # Copyright 2018 Joshua Hoblitt # # Copyright 2018 Maarten Fonville # # Copyright 2018 Mike Miller # # Copyright 2018 Svend Sorensen # # Copyright 2018 Wan Liuyang # # Copyright 2018 sfdye # # Copyright 2018 itsbruce # # Copyright 2019 Tomas Tomecek # # Copyright 2019 Rigas Papathanasopoulos # # # # This file is part of PyGithub. # # http://pygithub.readthedocs.io/ # # # # PyGithub is free software: you can redistribute it and/or modify it under # # the terms of the GNU Lesser General Public License as published by the Free # # Software Foundation, either version 3 of the License, or (at your option) # # any later version. # # # # PyGithub is distributed in the hope that it will be useful, but WITHOUT ANY # # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more # # details. # # # # You should have received a copy of the GNU Lesser General Public License # # along with PyGithub. If not, see . # # # ################################################################################ import datetime import pickle import time import jwt import requests import urllib3 import github.ApplicationOAuth import github.Event import github.Gist import github.GithubObject import github.License import github.NamedUser import github.PaginatedList import github.Topic from . import ( AuthenticatedUser, Consts, GithubApp, GithubException, GitignoreTemplate, HookDescription, Installation, InstallationAuthorization, RateLimit, Repository, ) from .Requester import Requester DEFAULT_BASE_URL = "https://api.github.com" DEFAULT_STATUS_URL = "https://status.github.com" # As of 2018-05-17, Github imposes a 10s limit for completion of API requests. # Thus, the timeout should be slightly > 10s to account for network/front-end # latency. DEFAULT_TIMEOUT = 15 DEFAULT_PER_PAGE = 30 class Github: """ This is the main class you instantiate to access the Github API v3. Optional parameters allow different authentication methods. """ def __init__( self, login_or_token=None, password=None, jwt=None, base_url=DEFAULT_BASE_URL, timeout=DEFAULT_TIMEOUT, user_agent="PyGithub/Python", per_page=DEFAULT_PER_PAGE, verify=True, retry=None, pool_size=None, ): """ :param login_or_token: string :param password: string :param base_url: string :param timeout: integer :param user_agent: string :param per_page: int :param verify: boolean or string :param retry: int or urllib3.util.retry.Retry object :param pool_size: int """ assert login_or_token is None or isinstance(login_or_token, str), login_or_token assert password is None or isinstance(password, str), password assert jwt is None or isinstance(jwt, str), jwt assert isinstance(base_url, str), base_url assert isinstance(timeout, int), timeout assert user_agent is None or isinstance(user_agent, str), user_agent assert ( retry is None or isinstance(retry, (int)) or isinstance(retry, (urllib3.util.Retry)) ) assert pool_size is None or isinstance(pool_size, (int)), pool_size self.__requester = Requester( login_or_token, password, jwt, base_url, timeout, user_agent, per_page, verify, retry, pool_size, ) @property def FIX_REPO_GET_GIT_REF(self): """ :type: bool """ return self.__requester.FIX_REPO_GET_GIT_REF @FIX_REPO_GET_GIT_REF.setter def FIX_REPO_GET_GIT_REF(self, value): self.__requester.FIX_REPO_GET_GIT_REF = value # v2: Remove this property? Why should it be necessary to read/modify it after construction @property def per_page(self): """ :type: int """ return self.__requester.per_page @per_page.setter def per_page(self, value): self.__requester.per_page = value # v2: Provide a unified way to access values of headers of last response # v2: (and add/keep ad hoc properties for specific useful headers like rate limiting, oauth scopes, etc.) # v2: Return an instance of a class: using a tuple did not allow to add a field "resettime" @property def rate_limiting(self): """ First value is requests remaining, second value is request limit. :type: (int, int) """ remaining, limit = self.__requester.rate_limiting if limit < 0: self.get_rate_limit() return self.__requester.rate_limiting @property def rate_limiting_resettime(self): """ Unix timestamp indicating when rate limiting will reset. :type: int """ if self.__requester.rate_limiting_resettime == 0: self.get_rate_limit() return self.__requester.rate_limiting_resettime def get_rate_limit(self): """ Rate limit status for different resources (core/search/graphql). :calls: `GET /rate_limit `_ :rtype: :class:`github.RateLimit.RateLimit` """ headers, data = self.__requester.requestJsonAndCheck("GET", "/rate_limit") return RateLimit.RateLimit(self.__requester, headers, data["resources"], True) @property def oauth_scopes(self): """ :type: list of string """ return self.__requester.oauth_scopes def get_license(self, key=github.GithubObject.NotSet): """ :calls: `GET /license/{license} `_ :param key: string :rtype: :class:`github.License.License` """ assert isinstance(key, str), key headers, data = self.__requester.requestJsonAndCheck("GET", f"/licenses/{key}") return github.License.License(self.__requester, headers, data, completed=True) def get_licenses(self): """ :calls: `GET /licenses `_ :rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.License.License` """ url_parameters = dict() return github.PaginatedList.PaginatedList( github.License.License, self.__requester, "/licenses", url_parameters ) def get_events(self): """ :calls: `GET /events `_ :rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.Event.Event` """ return github.PaginatedList.PaginatedList( github.Event.Event, self.__requester, "/events", None ) def get_user(self, login=github.GithubObject.NotSet): """ :calls: `GET /users/{user} `_ or `GET /user `_ :param login: string :rtype: :class:`github.NamedUser.NamedUser` or :class:`github.AuthenticatedUser.AuthenticatedUser` """ assert login is github.GithubObject.NotSet or isinstance(login, str), login if login is github.GithubObject.NotSet: return AuthenticatedUser.AuthenticatedUser( self.__requester, {}, {"url": "/user"}, completed=False ) else: headers, data = self.__requester.requestJsonAndCheck( "GET", f"/users/{login}" ) return github.NamedUser.NamedUser( self.__requester, headers, data, completed=True ) def get_user_by_id(self, user_id): """ :calls: `GET /user/{id} `_ :param user_id: int :rtype: :class:`github.NamedUser.NamedUser` """ assert isinstance(user_id, int), user_id headers, data = self.__requester.requestJsonAndCheck("GET", f"/user/{user_id}") return github.NamedUser.NamedUser( self.__requester, headers, data, completed=True ) def get_users(self, since=github.GithubObject.NotSet): """ :calls: `GET /users `_ :param since: integer :rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.NamedUser.NamedUser` """ assert since is github.GithubObject.NotSet or isinstance(since, int), since url_parameters = dict() if since is not github.GithubObject.NotSet: url_parameters["since"] = since return github.PaginatedList.PaginatedList( github.NamedUser.NamedUser, self.__requester, "/users", url_parameters ) def get_organization(self, login): """ :calls: `GET /orgs/{org} `_ :param login: string :rtype: :class:`github.Organization.Organization` """ assert isinstance(login, str), login headers, data = self.__requester.requestJsonAndCheck("GET", f"/orgs/{login}") return github.Organization.Organization( self.__requester, headers, data, completed=True ) def get_organizations(self, since=github.GithubObject.NotSet): """ :calls: `GET /organizations `_ :param since: integer :rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.Organization.Organization` """ assert since is github.GithubObject.NotSet or isinstance(since, int), since url_parameters = dict() if since is not github.GithubObject.NotSet: url_parameters["since"] = since return github.PaginatedList.PaginatedList( github.Organization.Organization, self.__requester, "/organizations", url_parameters, ) def get_repo(self, full_name_or_id, lazy=False): """ :calls: `GET /repos/{owner}/{repo} `_ or `GET /repositories/{id} `_ :rtype: :class:`github.Repository.Repository` """ assert isinstance(full_name_or_id, (str, int)), full_name_or_id url_base = "/repositories/" if isinstance(full_name_or_id, int) else "/repos/" url = f"{url_base}{full_name_or_id}" if lazy: return Repository.Repository( self.__requester, {}, {"url": url}, completed=False ) headers, data = self.__requester.requestJsonAndCheck("GET", url) return Repository.Repository(self.__requester, headers, data, completed=True) def get_repos( self, since=github.GithubObject.NotSet, visibility=github.GithubObject.NotSet ): """ :calls: `GET /repositories `_ :param since: integer :param visibility: string ('all','public') :rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.Repository.Repository` """ assert since is github.GithubObject.NotSet or isinstance(since, int), since url_parameters = dict() if since is not github.GithubObject.NotSet: url_parameters["since"] = since if visibility is not github.GithubObject.NotSet: assert visibility in ("public", "all"), visibility url_parameters["visibility"] = visibility return github.PaginatedList.PaginatedList( github.Repository.Repository, self.__requester, "/repositories", url_parameters, ) def get_project(self, id): """ :calls: `GET /projects/{project_id} `_ :rtype: :class:`github.Project.Project` :param id: integer """ headers, data = self.__requester.requestJsonAndCheck( "GET", "/projects/%d" % (id), headers={"Accept": Consts.mediaTypeProjectsPreview}, ) return github.Project.Project(self.__requester, headers, data, completed=True) def get_project_column(self, id): """ :calls: `GET /projects/columns/{column_id} `_ :rtype: :class:`github.ProjectColumn.ProjectColumn` :param id: integer """ headers, data = self.__requester.requestJsonAndCheck( "GET", "/projects/columns/%d" % id, headers={"Accept": Consts.mediaTypeProjectsPreview}, ) return github.ProjectColumn.ProjectColumn( self.__requester, headers, data, completed=True ) def get_gist(self, id): """ :calls: `GET /gists/{id} `_ :param id: string :rtype: :class:`github.Gist.Gist` """ assert isinstance(id, str), id headers, data = self.__requester.requestJsonAndCheck("GET", f"/gists/{id}") return github.Gist.Gist(self.__requester, headers, data, completed=True) def get_gists(self, since=github.GithubObject.NotSet): """ :calls: `GET /gists/public `_ :param since: datetime.datetime format YYYY-MM-DDTHH:MM:SSZ :rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.Gist.Gist` """ assert since is github.GithubObject.NotSet or isinstance( since, datetime.datetime ), since url_parameters = dict() if since is not github.GithubObject.NotSet: url_parameters["since"] = since.strftime("%Y-%m-%dT%H:%M:%SZ") return github.PaginatedList.PaginatedList( github.Gist.Gist, self.__requester, "/gists/public", url_parameters ) def search_repositories( self, query, sort=github.GithubObject.NotSet, order=github.GithubObject.NotSet, **qualifiers, ): """ :calls: `GET /search/repositories `_ :param query: string :param sort: string ('stars', 'forks', 'updated') :param order: string ('asc', 'desc') :param qualifiers: keyword dict query qualifiers :rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.Repository.Repository` """ assert isinstance(query, str), query url_parameters = dict() if ( sort is not github.GithubObject.NotSet ): # pragma no branch (Should be covered) assert sort in ("stars", "forks", "updated"), sort url_parameters["sort"] = sort if ( order is not github.GithubObject.NotSet ): # pragma no branch (Should be covered) assert order in ("asc", "desc"), order url_parameters["order"] = order query_chunks = [] if query: # pragma no branch (Should be covered) query_chunks.append(query) for qualifier, value in qualifiers.items(): query_chunks.append(f"{qualifier}:{value}") url_parameters["q"] = " ".join(query_chunks) assert url_parameters["q"], "need at least one qualifier" return github.PaginatedList.PaginatedList( github.Repository.Repository, self.__requester, "/search/repositories", url_parameters, ) def search_users( self, query, sort=github.GithubObject.NotSet, order=github.GithubObject.NotSet, **qualifiers, ): """ :calls: `GET /search/users `_ :param query: string :param sort: string ('followers', 'repositories', 'joined') :param order: string ('asc', 'desc') :param qualifiers: keyword dict query qualifiers :rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.NamedUser.NamedUser` """ assert isinstance(query, str), query url_parameters = dict() if sort is not github.GithubObject.NotSet: assert sort in ("followers", "repositories", "joined"), sort url_parameters["sort"] = sort if order is not github.GithubObject.NotSet: assert order in ("asc", "desc"), order url_parameters["order"] = order query_chunks = [] if query: query_chunks.append(query) for qualifier, value in qualifiers.items(): query_chunks.append(f"{qualifier}:{value}") url_parameters["q"] = " ".join(query_chunks) assert url_parameters["q"], "need at least one qualifier" return github.PaginatedList.PaginatedList( github.NamedUser.NamedUser, self.__requester, "/search/users", url_parameters, ) def search_issues( self, query, sort=github.GithubObject.NotSet, order=github.GithubObject.NotSet, **qualifiers, ): """ :calls: `GET /search/issues `_ :param query: string :param sort: string ('comments', 'created', 'updated') :param order: string ('asc', 'desc') :param qualifiers: keyword dict query qualifiers :rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.Issue.Issue` """ assert isinstance(query, str), query url_parameters = dict() if sort is not github.GithubObject.NotSet: assert sort in ("comments", "created", "updated"), sort url_parameters["sort"] = sort if order is not github.GithubObject.NotSet: assert order in ("asc", "desc"), order url_parameters["order"] = order query_chunks = [] if query: # pragma no branch (Should be covered) query_chunks.append(query) for qualifier, value in qualifiers.items(): query_chunks.append(f"{qualifier}:{value}") url_parameters["q"] = " ".join(query_chunks) assert url_parameters["q"], "need at least one qualifier" return github.PaginatedList.PaginatedList( github.Issue.Issue, self.__requester, "/search/issues", url_parameters ) def search_code( self, query, sort=github.GithubObject.NotSet, order=github.GithubObject.NotSet, highlight=False, **qualifiers, ): """ :calls: `GET /search/code `_ :param query: string :param sort: string ('indexed') :param order: string ('asc', 'desc') :param highlight: boolean (True, False) :param qualifiers: keyword dict query qualifiers :rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.ContentFile.ContentFile` """ assert isinstance(query, str), query url_parameters = dict() if ( sort is not github.GithubObject.NotSet ): # pragma no branch (Should be covered) assert sort in ("indexed",), sort url_parameters["sort"] = sort if ( order is not github.GithubObject.NotSet ): # pragma no branch (Should be covered) assert order in ("asc", "desc"), order url_parameters["order"] = order query_chunks = [] if query: # pragma no branch (Should be covered) query_chunks.append(query) for qualifier, value in qualifiers.items(): query_chunks.append(f"{qualifier}:{value}") url_parameters["q"] = " ".join(query_chunks) assert url_parameters["q"], "need at least one qualifier" headers = {"Accept": Consts.highLightSearchPreview} if highlight else None return github.PaginatedList.PaginatedList( github.ContentFile.ContentFile, self.__requester, "/search/code", url_parameters, headers=headers, ) def search_commits( self, query, sort=github.GithubObject.NotSet, order=github.GithubObject.NotSet, **qualifiers, ): """ :calls: `GET /search/commits `_ :param query: string :param sort: string ('author-date', 'committer-date') :param order: string ('asc', 'desc') :param qualifiers: keyword dict query qualifiers :rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.Commit.Commit` """ assert isinstance(query, str), query url_parameters = dict() if ( sort is not github.GithubObject.NotSet ): # pragma no branch (Should be covered) assert sort in ("author-date", "committer-date"), sort url_parameters["sort"] = sort if ( order is not github.GithubObject.NotSet ): # pragma no branch (Should be covered) assert order in ("asc", "desc"), order url_parameters["order"] = order query_chunks = [] if query: # pragma no branch (Should be covered) query_chunks.append(query) for qualifier, value in qualifiers.items(): query_chunks.append(f"{qualifier}:{value}") url_parameters["q"] = " ".join(query_chunks) assert url_parameters["q"], "need at least one qualifier" return github.PaginatedList.PaginatedList( github.Commit.Commit, self.__requester, "/search/commits", url_parameters, headers={"Accept": Consts.mediaTypeCommitSearchPreview}, ) def search_topics(self, query, **qualifiers): """ :calls: `GET /search/topics `_ :param query: string :param qualifiers: keyword dict query qualifiers :rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.Topic.Topic` """ assert isinstance(query, str), query url_parameters = dict() query_chunks = [] if query: # pragma no branch (Should be covered) query_chunks.append(query) for qualifier, value in qualifiers.items(): query_chunks.append(f"{qualifier}:{value}") url_parameters["q"] = " ".join(query_chunks) assert url_parameters["q"], "need at least one qualifier" return github.PaginatedList.PaginatedList( github.Topic.Topic, self.__requester, "/search/topics", url_parameters, headers={"Accept": Consts.mediaTypeTopicsPreview}, ) def render_markdown(self, text, context=github.GithubObject.NotSet): """ :calls: `POST /markdown `_ :param text: string :param context: :class:`github.Repository.Repository` :rtype: string """ assert isinstance(text, str), text assert context is github.GithubObject.NotSet or isinstance( context, github.Repository.Repository ), context post_parameters = {"text": text} if context is not github.GithubObject.NotSet: post_parameters["mode"] = "gfm" post_parameters["context"] = context._identity status, headers, data = self.__requester.requestJson( "POST", "/markdown", input=post_parameters ) return data def get_hook(self, name): """ :calls: `GET /hooks/{name} `_ :param name: string :rtype: :class:`github.HookDescription.HookDescription` """ assert isinstance(name, str), name headers, attributes = self.__requester.requestJsonAndCheck( "GET", f"/hooks/{name}" ) return HookDescription.HookDescription( self.__requester, headers, attributes, completed=True ) def get_hooks(self): """ :calls: `GET /hooks `_ :rtype: list of :class:`github.HookDescription.HookDescription` """ headers, data = self.__requester.requestJsonAndCheck("GET", "/hooks") return [ HookDescription.HookDescription( self.__requester, headers, attributes, completed=True ) for attributes in data ] def get_gitignore_templates(self): """ :calls: `GET /gitignore/templates `_ :rtype: list of string """ headers, data = self.__requester.requestJsonAndCheck( "GET", "/gitignore/templates" ) return data def get_gitignore_template(self, name): """ :calls: `GET /gitignore/templates/{name} `_ :rtype: :class:`github.GitignoreTemplate.GitignoreTemplate` """ assert isinstance(name, str), name headers, attributes = self.__requester.requestJsonAndCheck( "GET", f"/gitignore/templates/{name}" ) return GitignoreTemplate.GitignoreTemplate( self.__requester, headers, attributes, completed=True ) def get_emojis(self): """ :calls: `GET /emojis `_ :rtype: dictionary of type => url for emoji` """ headers, attributes = self.__requester.requestJsonAndCheck("GET", "/emojis") return attributes def create_from_raw_data(self, klass, raw_data, headers={}): """ Creates an object from raw_data previously obtained by :attr:`github.GithubObject.GithubObject.raw_data`, and optionally headers previously obtained by :attr:`github.GithubObject.GithubObject.raw_headers`. :param klass: the class of the object to create :param raw_data: dict :param headers: dict :rtype: instance of class ``klass`` """ return klass(self.__requester, headers, raw_data, completed=True) def dump(self, obj, file, protocol=0): """ Dumps (pickles) a PyGithub object to a file-like object. Some effort is made to not pickle sensitive information like the Github credentials used in the :class:`Github` instance. But NO EFFORT is made to remove sensitive information from the object's attributes. :param obj: the object to pickle :param file: the file-like object to pickle to :param protocol: the `pickling protocol `_ """ pickle.dump((obj.__class__, obj.raw_data, obj.raw_headers), file, protocol) def load(self, f): """ Loads (unpickles) a PyGithub object from a file-like object. :param f: the file-like object to unpickle from :return: the unpickled object """ return self.create_from_raw_data(*pickle.load(f)) def get_oauth_application(self, client_id, client_secret): return github.ApplicationOAuth.ApplicationOAuth( self.__requester, headers={}, attributes={"client_id": client_id, "client_secret": client_secret}, completed=False, ) def get_app(self, slug=github.GithubObject.NotSet): """ :calls: `GET /apps/{slug} `_ or `GET /app `_ :param slug: string :rtype: :class:`github.GithubApp.GithubApp` """ assert slug is github.GithubObject.NotSet or isinstance(slug, str), slug if slug is github.GithubObject.NotSet: return GithubApp.GithubApp( self.__requester, {}, {"url": "/app"}, completed=False ) else: headers, data = self.__requester.requestJsonAndCheck("GET", f"/apps/{slug}") return GithubApp.GithubApp(self.__requester, headers, data, completed=True) class GithubIntegration: """ Main class to obtain tokens for a GitHub integration. """ def __init__(self, integration_id, private_key, base_url=DEFAULT_BASE_URL): """ :param base_url: string :param integration_id: int :param private_key: string """ self.base_url = base_url self.integration_id = integration_id self.private_key = private_key assert isinstance(base_url, str), base_url def create_jwt(self, expiration=60): """ Creates a signed JWT, valid for 60 seconds by default. The expiration can be extended beyond this, to a maximum of 600 seconds. :param expiration: int :return string: """ now = int(time.time()) payload = {"iat": now, "exp": now + expiration, "iss": self.integration_id} encrypted = jwt.encode(payload, key=self.private_key, algorithm="RS256") if isinstance(encrypted, bytes): encrypted = encrypted.decode("utf-8") return encrypted def get_access_token(self, installation_id, user_id=None): """ Get an access token for the given installation id. POSTs https://api.github.com/app/installations//access_tokens :param user_id: int :param installation_id: int :return: :class:`github.InstallationAuthorization.InstallationAuthorization` """ body = {} if user_id: body = {"user_id": user_id} response = requests.post( f"{self.base_url}/app/installations/{installation_id}/access_tokens", headers={ "Authorization": f"Bearer {self.create_jwt()}", "Accept": Consts.mediaTypeIntegrationPreview, "User-Agent": "PyGithub/Python", }, json=body, ) if response.status_code == 201: return InstallationAuthorization.InstallationAuthorization( requester=None, # not required, this is a NonCompletableGithubObject headers={}, # not required, this is a NonCompletableGithubObject attributes=response.json(), completed=True, ) elif response.status_code == 403: raise GithubException.BadCredentialsException( status=response.status_code, data=response.text ) elif response.status_code == 404: raise GithubException.UnknownObjectException( status=response.status_code, data=response.text ) raise GithubException.GithubException( status=response.status_code, data=response.text ) def get_installation(self, owner, repo): """ :calls: `GET /repos/{owner}/{repo}/installation `_ :param owner: str :param repo: str :rtype: :class:`github.Installation.Installation` """ headers = { "Authorization": f"Bearer {self.create_jwt()}", "Accept": Consts.mediaTypeIntegrationPreview, "User-Agent": "PyGithub/Python", } response = requests.get( f"{self.base_url}/repos/{owner}/{repo}/installation", headers=headers, ) response_dict = response.json() return Installation.Installation(None, headers, response_dict, True) ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1619412308.0 PyGithub-1.55/github/MainClass.pyi0000644000175100001710000001276300000000000016427 0ustar00runnerdockerfrom datetime import datetime from io import BytesIO from typing import Any, Dict, List, Optional, Tuple, Type, TypeVar, Union, overload from github.AuthenticatedUser import AuthenticatedUser from github.Commit import Commit from github.ContentFile import ContentFile from github.Event import Event from github.Gist import Gist from github.GithubObject import GithubObject, _NotSetType from github.GitignoreTemplate import GitignoreTemplate from github.HookDescription import HookDescription from github.Installation import Installation from github.InstallationAuthorization import InstallationAuthorization from github.Issue import Issue from github.License import License from github.NamedUser import NamedUser from github.Organization import Organization from github.PaginatedList import PaginatedList from github.Project import Project from github.RateLimit import RateLimit from github.Repository import Repository from github.Topic import Topic # from urllib3.util.retry import Retry TGithubObject = TypeVar('TGithubObject', bound=GithubObject) class Github: def __init__( self, login_or_token: Optional[str] = ..., password: Optional[str] = ..., jwt: Optional[str] = ..., base_url: str = ..., timeout: int = ..., client_id: Optional[str] = ..., client_secret: Optional[str] = ..., user_agent: str = ..., per_page: int = ..., verify: bool = ..., retry: Any = ..., ) -> None: ... @property def FIX_REPO_GET_GIT_REF(self) -> bool: ... @FIX_REPO_GET_GIT_REF.setter def FIX_REPO_GET_GIT_REF(self, value: bool) -> None: ... @property def per_page(self) -> int: ... @per_page.setter def per_page(self, value: int) -> None: ... def create_from_raw_data( self, klass: Type[TGithubObject], raw_data: Dict[str, Any], headers: Dict[str, Union[str, int]] = ..., ) -> TGithubObject: ... def dump(self, obj: GithubObject, file: BytesIO, protocol: int = ...) -> None: ... def get_emojis(self) -> Dict[str, str]: ... def get_events(self) -> PaginatedList[Event]: ... def get_gist(self, id: str) -> Gist: ... def get_gists( self, since: Union[datetime, _NotSetType] = ... ) -> PaginatedList[Gist]: ... def get_gitignore_template(self, name: str) -> GitignoreTemplate: ... def get_gitignore_templates(self) -> List[str]: ... def get_hook(self, name: str) -> HookDescription: ... def get_hooks(self) -> List[HookDescription]: ... def get_installation(self, id: int) -> Installation: ... def get_license(self, key: Union[str, _NotSetType] = ...) -> License: ... def get_licenses(self) -> PaginatedList[License]: ... def get_organization(self, login: str) -> Organization: ... def get_organizations( self, since: Union[int, _NotSetType] = ... ) -> PaginatedList[Organization]: ... def get_project(self, id: int) -> Project: ... def get_rate_limit(self) -> RateLimit: ... def get_repo( self, full_name_or_id: Union[int, str], lazy: bool = ... ) -> Repository: ... def get_repos( self, since: Union[int, _NotSetType] = ..., visibility: Union[str, _NotSetType] = ..., ) -> PaginatedList[Repository]: ... @overload def get_user(self, login: _NotSetType = ...) -> AuthenticatedUser: ... @overload def get_user(self, login: str) -> NamedUser: ... def get_user_by_id(self, user_id: int) -> NamedUser: ... def get_users( self, since: Union[int, _NotSetType] = ... ) -> PaginatedList[NamedUser]: ... def load(self, f: BytesIO) -> Repository: ... @property def oauth_scopes(self) -> Optional[List[str]]: ... @property def rate_limiting(self) -> Tuple[int, int]: ... @property def rate_limiting_resettime(self) -> int: ... def render_markdown( self, text: str, context: Union[Repository, _NotSetType] = ... ) -> str: ... def search_code( self, query: str, sort: Union[str, _NotSetType] = ..., order: Union[str, _NotSetType] = ..., highlight: bool = ..., **qualifiers: Any ) -> PaginatedList[ContentFile]: ... def search_commits( self, query: str, sort: Union[str, _NotSetType] = ..., order: Union[str, _NotSetType] = ..., **qualifiers: Any ) -> PaginatedList[Commit]: ... def search_issues( self, query: str, sort: Union[str, _NotSetType] = ..., order: Union[str, _NotSetType] = ..., **qualifiers: Any ) -> PaginatedList[Issue]: ... def search_repositories( self, query: str, sort: Union[str, _NotSetType] = ..., order: Union[str, _NotSetType] = ..., **qualifiers: Any ) -> PaginatedList[Repository]: ... def search_topics( self, query: str, **qualifiers: Any ) -> PaginatedList[Topic]: ... def search_users( self, query: str, sort: Union[str, _NotSetType] = ..., order: Union[str, _NotSetType] = ..., **qualifiers: Any ) -> PaginatedList[NamedUser]: ... class GithubIntegration: def __init__( self, integration_id: Union[int, str], private_key: str, base_url: str = ... ) -> None: ... def create_jwt(self, expiration: int = ...) -> str: ... def get_access_token( self, installation_id: int, user_id: Optional[int] = ... ) -> InstallationAuthorization: ... def get_installation(self, owner: str, repo: str) -> Installation: ... ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1619412308.0 PyGithub-1.55/github/Membership.py0000644000175100001710000001337500000000000016477 0ustar00runnerdocker############################ Copyrights and license ############################ # # # Copyright 2012 Steve English # # Copyright 2012 Vincent Jacques # # Copyright 2012 Zearin # # Copyright 2013 AKFish # # Copyright 2013 Cameron White # # Copyright 2013 Vincent Jacques # # Copyright 2013 poulp # # Copyright 2014 Tomas Radej # # Copyright 2014 Vincent Jacques # # Copyright 2016 E. Dunham # # Copyright 2016 Jannis Gebauer # # Copyright 2016 Peter Buckley # # Copyright 2017 Balázs Rostás # # Copyright 2017 Jannis Gebauer # # Copyright 2017 Simon # # Copyright 2018 Wan Liuyang # # Copyright 2018 bryanhuntesl <31992054+bryanhuntesl@users.noreply.github.com> # # Copyright 2018 sfdye # # Copyright 2018 itsbruce # # # # This file is part of PyGithub. # # http://pygithub.readthedocs.io/ # # # # PyGithub is free software: you can redistribute it and/or modify it under # # the terms of the GNU Lesser General Public License as published by the Free # # Software Foundation, either version 3 of the License, or (at your option) # # any later version. # # # # PyGithub is distributed in the hope that it will be useful, but WITHOUT ANY # # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more # # details. # # # # You should have received a copy of the GNU Lesser General Public License # # along with PyGithub. If not, see . # # # ################################################################################ import github.GithubObject class Membership(github.GithubObject.CompletableGithubObject): """ This class represents Membership of an organization. The reference can be found here http://docs.github.com/en/rest/reference/orgs """ def __repr__(self): return self.get__repr__({"url": self._url.value}) @property def url(self): """ :type: string """ self._completeIfNotSet(self._url) return self._url.value @property def state(self): """ :type: string """ self._completeIfNotSet(self._state) return self._state.value @property def role(self): """ :type: string """ self._completeIfNotSet(self._role) return self._role.value @property def organization_url(self): """ :type: string """ self._completeIfNotSet(self._organization_url) return self._organization_url.value @property def organization(self): """ :type: :class:`github.Organization.Organization` """ self._completeIfNotSet(self._organization) return self._organization.value @property def user(self): """ :type: :class:`github.NamedUser.NamedUser` """ self._completeIfNotSet(self._user) return self._user.value def _initAttributes(self): self._url = github.GithubObject.NotSet self._state = github.GithubObject.NotSet self._role = github.GithubObject.NotSet self._organization_url = github.GithubObject.NotSet self._organization = github.GithubObject.NotSet self._user = github.GithubObject.NotSet def _useAttributes(self, attributes): if "url" in attributes: # pragma no branch self._url = self._makeStringAttribute(attributes["url"]) if "state" in attributes: # pragma no branch self._state = self._makeStringAttribute(attributes["state"]) if "role" in attributes: # pragma no branch self._role = self._makeStringAttribute(attributes["role"]) if "organization_url" in attributes: # pragma no branch self._organization_url = self._makeStringAttribute( attributes["organization_url"] ) if "organization" in attributes: # pragma no branch self._organization = self._makeClassAttribute( github.Organization.Organization, attributes["organization"] ) if "user" in attributes: # pragma no branch self._user = self._makeClassAttribute( github.NamedUser.NamedUser, attributes["user"] ) ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1619412308.0 PyGithub-1.55/github/Membership.pyi0000644000175100001710000000115500000000000016641 0ustar00runnerdockerfrom typing import Any, Dict from github.GithubObject import CompletableGithubObject from github.NamedUser import NamedUser from github.Organization import Organization class Membership(CompletableGithubObject): def __repr__(self) -> str: ... def _initAttributes(self) -> None: ... def _useAttributes(self, attributes: Dict[str, Any]) -> None: ... @property def url(self) -> str: ... @property def role(self) -> str: ... @property def organization_url(self) -> str: ... @property def organization(self) -> Organization: ... @property def user(self) -> NamedUser: ... ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1619412308.0 PyGithub-1.55/github/Migration.py0000644000175100001710000002027400000000000016331 0ustar00runnerdocker############################ Copyrights and license ############################ # # # Copyright 2012 Vincent Jacques # # Copyright 2012 Zearin # # Copyright 2013 AKFish # # Copyright 2013 Vincent Jacques # # Copyright 2013 martinqt # # Copyright 2014 Andy Casey # # Copyright 2014 Vincent Jacques # # Copyright 2016 Jannis Gebauer # # Copyright 2016 John Eskew # # Copyright 2016 Peter Buckley # # Copyright 2018 sfdye # # # # This file is part of PyGithub. # # http://pygithub.readthedocs.io/ # # # # PyGithub is free software: you can redistribute it and/or modify it under # # the terms of the GNU Lesser General Public License as published by the Free # # Software Foundation, either version 3 of the License, or (at your option) # # any later version. # # # # PyGithub is distributed in the hope that it will be useful, but WITHOUT ANY # # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more # # details. # # # # You should have received a copy of the GNU Lesser General Public License # # along with PyGithub. If not, see . # # # ################################################################################ import github.GithubObject import github.NamedUser import github.PaginatedList from . import Consts class Migration(github.GithubObject.CompletableGithubObject): """ This class represents Migrations. The reference can be found here http://docs.github.com/en/rest/reference/migrations """ def __repr__(self): return self.get__repr__({"state": self._state.value, "url": self._url.value}) @property def id(self): """ :type: int """ return self._id.value @property def owner(self): """ :type: :class:`github.NamedUser.NamedUser` """ self._completeIfNotSet(self._owner) return self._owner.value @property def guid(self): """ :type: str """ self._completeIfNotSet(self._guid) return self._guid.value @property def state(self): """ :type: str """ self._completeIfNotSet(self._guid) return self._state.value @property def lock_repositories(self): """ :type: bool """ self._completeIfNotSet(self._repositories) return self._lock_repositories.value @property def exclude_attachments(self): """ :type: bool """ self._completeIfNotSet(self._exclude_attachments) return self._exclude_attachments.value @property def repositories(self): """ :type: :class:`github.PaginatedList.PaginatedList` of :class:`github.Repository.Repository` """ self._completeIfNotSet(self._repositories) return self._repositories.value @property def url(self): """ :type: str """ self._completeIfNotSet(self._url) return self._url.value @property def created_at(self): """ :type: datetime.datetime :rtype: None """ self._completeIfNotSet(self._created_at) return self._created_at.value @property def updated_at(self): """ :type: datetime.datetime :rtype: None """ self._completeIfNotSet(self._updated_at) return self._updated_at.value def get_status(self): """ :calls: `GET /user/migrations/{migration_id} `_ :rtype: str """ headers, data = self._requester.requestJsonAndCheck( "GET", self.url, headers={"Accept": Consts.mediaTypeMigrationPreview} ) self._useAttributes(data) return self.state def get_archive_url(self): """ :calls: `GET /user/migrations/{migration_id}/archive `_ :rtype: str """ headers, data = self._requester.requestJsonAndCheck( "GET", f"{self.url}/archive", headers={"Accept": Consts.mediaTypeMigrationPreview}, ) return data["data"] def delete(self): """ :calls: `DELETE /user/migrations/{migration_id}/archive `_ """ headers, data = self._requester.requestJsonAndCheck( "DELETE", f"{self.url}/archive", headers={"Accept": Consts.mediaTypeMigrationPreview}, ) def unlock_repo(self, repo_name): """ :calls: `DELETE /user/migrations/{migration_id}/repos/{repo_name}/lock `_ :param repo_name: str :rtype: None """ assert isinstance(repo_name, str), repo_name headers, data = self._requester.requestJsonAndCheck( "DELETE", f"{self.url}/repos/{repo_name}/lock", headers={"Accept": Consts.mediaTypeMigrationPreview}, ) def _initAttributes(self): self._id = github.GithubObject.NotSet self._owner = github.GithubObject.NotSet self._guid = github.GithubObject.NotSet self._state = github.GithubObject.NotSet self._lock_repositories = github.GithubObject.NotSet self._exclude_attachments = github.GithubObject.NotSet self._repositories = github.GithubObject.NotSet self._url = github.GithubObject.NotSet self._created_at = github.GithubObject.NotSet self._updated_at = github.GithubObject.NotSet def _useAttributes(self, attributes): if "id" in attributes: self._id = self._makeIntAttribute(attributes["id"]) if "owner" in attributes: self._owner = self._makeClassAttribute( github.NamedUser.NamedUser, attributes["owner"] ) if "guid" in attributes: self._guid = self._makeStringAttribute(attributes["guid"]) if "state" in attributes: self._state = self._makeStringAttribute(attributes["state"]) if "lock_repositories" in attributes: self._lock_repositories = self._makeBoolAttribute( attributes["lock_repositories"] ) if "exclude_attachments" in attributes: self._exclude_attachments = self._makeBoolAttribute( attributes["exclude_attachments"] ) if "repositories" in attributes: self._repositories = self._makeListOfClassesAttribute( github.Repository.Repository, attributes["repositories"] ) if "url" in attributes: self._url = self._makeStringAttribute(attributes["url"]) if "created_at" in attributes: self._created_at = self._makeDatetimeAttribute(attributes["created_at"]) if "updated_at" in attributes: self._updated_at = self._makeDatetimeAttribute(attributes["updated_at"]) ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1619412308.0 PyGithub-1.55/github/Migration.pyi0000644000175100001710000000212200000000000016472 0ustar00runnerdockerfrom datetime import datetime from typing import Any, Dict, List, Optional, Union from github.GithubObject import CompletableGithubObject from github.NamedUser import NamedUser from github.Repository import Repository class Migration(CompletableGithubObject): def __repr__(self) -> str: ... def _initAttributes(self) -> None: ... def _useAttributes(self, attributes: Dict[str, Any]) -> None: ... @property def created_at(self) -> datetime: ... def delete(self) -> None: ... @property def exclude_attachments(self) -> bool: ... def get_archive_url(self) -> str: ... def get_status(self) -> str: ... @property def guid(self) -> str: ... @property def id(self) -> int: ... @property def lock_repositories(self) -> bool: ... @property def owner(self) -> NamedUser: ... @property def repositories(self) -> List[Repository]: ... @property def state(self) -> str: ... def unlock_repo(self, repo_name: str) -> None: ... @property def updated_at(self) -> datetime: ... @property def url(self) -> str: ... ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1619412308.0 PyGithub-1.55/github/Milestone.py0000644000175100001710000002303600000000000016336 0ustar00runnerdocker############################ Copyrights and license ############################ # # # Copyright 2012 Vincent Jacques # # Copyright 2012 Zearin # # Copyright 2013 AKFish # # Copyright 2013 Vincent Jacques # # Copyright 2013 martinqt # # Copyright 2014 Vincent Jacques # # Copyright 2016 Jannis Gebauer # # Copyright 2016 Peter Buckley # # Copyright 2018 sfdye # # # # This file is part of PyGithub. # # http://pygithub.readthedocs.io/ # # # # PyGithub is free software: you can redistribute it and/or modify it under # # the terms of the GNU Lesser General Public License as published by the Free # # Software Foundation, either version 3 of the License, or (at your option) # # any later version. # # # # PyGithub is distributed in the hope that it will be useful, but WITHOUT ANY # # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more # # details. # # # # You should have received a copy of the GNU Lesser General Public License # # along with PyGithub. If not, see . # # # ################################################################################ import datetime import github.GithubObject import github.Label import github.NamedUser import github.PaginatedList class Milestone(github.GithubObject.CompletableGithubObject): """ This class represents Milestones. The reference can be found here http://docs.github.com/en/rest/reference/issues#milestones """ def __repr__(self): return self.get__repr__( {"number": self._number.value, "title": self._title.value} ) @property def closed_issues(self): """ :type: integer """ self._completeIfNotSet(self._closed_issues) return self._closed_issues.value @property def created_at(self): """ :type: datetime.datetime """ self._completeIfNotSet(self._created_at) return self._created_at.value @property def creator(self): """ :type: :class:`github.NamedUser.NamedUser` """ self._completeIfNotSet(self._creator) return self._creator.value @property def description(self): """ :type: string """ self._completeIfNotSet(self._description) return self._description.value @property def due_on(self): """ :type: datetime.datetime """ self._completeIfNotSet(self._due_on) return self._due_on.value @property def id(self): """ :type: integer """ self._completeIfNotSet(self._id) return self._id.value @property def labels_url(self): """ :type: string """ self._completeIfNotSet(self._labels_url) return self._labels_url.value @property def number(self): """ :type: integer """ self._completeIfNotSet(self._number) return self._number.value @property def open_issues(self): """ :type: integer """ self._completeIfNotSet(self._open_issues) return self._open_issues.value @property def state(self): """ :type: string """ self._completeIfNotSet(self._state) return self._state.value @property def title(self): """ :type: string """ self._completeIfNotSet(self._title) return self._title.value @property def updated_at(self): """ :type: datetime.datetime """ self._completeIfNotSet(self._updated_at) return self._updated_at.value @property def url(self): """ :type: string """ self._completeIfNotSet(self._url) return self._url.value def delete(self): """ :calls: `DELETE /repos/{owner}/{repo}/milestones/{number} `_ :rtype: None """ headers, data = self._requester.requestJsonAndCheck("DELETE", self.url) def edit( self, title, state=github.GithubObject.NotSet, description=github.GithubObject.NotSet, due_on=github.GithubObject.NotSet, ): """ :calls: `PATCH /repos/{owner}/{repo}/milestones/{number} `_ :param title: string :param state: string :param description: string :param due_on: date :rtype: None """ assert isinstance(title, str), title assert state is github.GithubObject.NotSet or isinstance(state, str), state assert description is github.GithubObject.NotSet or isinstance( description, str ), description assert due_on is github.GithubObject.NotSet or isinstance( due_on, datetime.date ), due_on post_parameters = { "title": title, } if state is not github.GithubObject.NotSet: post_parameters["state"] = state if description is not github.GithubObject.NotSet: post_parameters["description"] = description if due_on is not github.GithubObject.NotSet: post_parameters["due_on"] = due_on.strftime("%Y-%m-%d") headers, data = self._requester.requestJsonAndCheck( "PATCH", self.url, input=post_parameters ) self._useAttributes(data) def get_labels(self): """ :calls: `GET /repos/{owner}/{repo}/milestones/{number}/labels `_ :rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.Label.Label` """ return github.PaginatedList.PaginatedList( github.Label.Label, self._requester, f"{self.url}/labels", None ) @property def _identity(self): return self.number def _initAttributes(self): self._closed_issues = github.GithubObject.NotSet self._created_at = github.GithubObject.NotSet self._creator = github.GithubObject.NotSet self._description = github.GithubObject.NotSet self._due_on = github.GithubObject.NotSet self._id = github.GithubObject.NotSet self._labels_url = github.GithubObject.NotSet self._number = github.GithubObject.NotSet self._open_issues = github.GithubObject.NotSet self._state = github.GithubObject.NotSet self._title = github.GithubObject.NotSet self._updated_at = github.GithubObject.NotSet self._url = github.GithubObject.NotSet def _useAttributes(self, attributes): if "closed_issues" in attributes: # pragma no branch self._closed_issues = self._makeIntAttribute(attributes["closed_issues"]) if "created_at" in attributes: # pragma no branch self._created_at = self._makeDatetimeAttribute(attributes["created_at"]) if "creator" in attributes: # pragma no branch self._creator = self._makeClassAttribute( github.NamedUser.NamedUser, attributes["creator"] ) if "description" in attributes: # pragma no branch self._description = self._makeStringAttribute(attributes["description"]) if "due_on" in attributes: # pragma no branch self._due_on = self._makeDatetimeAttribute(attributes["due_on"]) if "id" in attributes: # pragma no branch self._id = self._makeIntAttribute(attributes["id"]) if "labels_url" in attributes: # pragma no branch self._labels_url = self._makeStringAttribute(attributes["labels_url"]) if "number" in attributes: # pragma no branch self._number = self._makeIntAttribute(attributes["number"]) if "open_issues" in attributes: # pragma no branch self._open_issues = self._makeIntAttribute(attributes["open_issues"]) if "state" in attributes: # pragma no branch self._state = self._makeStringAttribute(attributes["state"]) if "title" in attributes: # pragma no branch self._title = self._makeStringAttribute(attributes["title"]) if "updated_at" in attributes: # pragma no branch self._updated_at = self._makeDatetimeAttribute(attributes["updated_at"]) if "url" in attributes: # pragma no branch self._url = self._makeStringAttribute(attributes["url"]) ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1619412308.0 PyGithub-1.55/github/Milestone.pyi0000644000175100001710000000270200000000000016504 0ustar00runnerdockerfrom datetime import date, datetime from typing import Any, Dict, Optional, Union from github.GithubObject import CompletableGithubObject, _NotSetType from github.Label import Label from github.NamedUser import NamedUser from github.PaginatedList import PaginatedList class Milestone(CompletableGithubObject): def __repr__(self) -> str: ... @property def _identity(self) -> int: ... def _initAttributes(self) -> None: ... def _useAttributes(self, attributes: Dict[str, Any]) -> None: ... @property def closed_issues(self) -> int: ... @property def created_at(self) -> datetime: ... @property def creator(self) -> NamedUser: ... def delete(self) -> None: ... @property def description(self) -> str: ... @property def due_on(self) -> Optional[datetime]: ... def edit( self, title: str, state: Union[_NotSetType, str] = ..., description: Union[_NotSetType, str] = ..., due_on: Union[date, _NotSetType] = ..., ) -> None: ... def get_labels(self) -> PaginatedList[Label]: ... @property def id(self) -> int: ... @property def labels_url(self) -> str: ... @property def number(self) -> int: ... @property def open_issues(self) -> int: ... @property def state(self) -> str: ... @property def title(self) -> str: ... @property def updated_at(self) -> datetime: ... @property def url(self) -> str: ... ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1619412308.0 PyGithub-1.55/github/NamedUser.py0000644000175100001710000007235200000000000016267 0ustar00runnerdocker############################ Copyrights and license ############################ # # # Copyright 2012 Steve English # # Copyright 2012 Vincent Jacques # # Copyright 2012 Zearin # # Copyright 2013 AKFish # # Copyright 2013 Vincent Jacques # # Copyright 2014 Vincent Jacques # # Copyright 2016 Jannis Gebauer # # Copyright 2016 Peter Buckley # # Copyright 2017 Simon # # Copyright 2018 Iraquitan Cordeiro Filho # # Copyright 2018 Steve Kowalik # # Copyright 2018 Victor Granic # # Copyright 2018 Wan Liuyang # # Copyright 2018 namc # # Copyright 2018 sfdye # # Copyright 2018 itsbruce # # # # This file is part of PyGithub. # # http://pygithub.readthedocs.io/ # # # # PyGithub is free software: you can redistribute it and/or modify it under # # the terms of the GNU Lesser General Public License as published by the Free # # Software Foundation, either version 3 of the License, or (at your option) # # any later version. # # # # PyGithub is distributed in the hope that it will be useful, but WITHOUT ANY # # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more # # details. # # # # You should have received a copy of the GNU Lesser General Public License # # along with PyGithub. If not, see . # # # ################################################################################ import datetime import github.Event import github.Gist import github.GithubObject import github.NamedUser import github.Organization import github.PaginatedList import github.Permissions import github.Plan import github.Repository from . import Consts class NamedUser(github.GithubObject.CompletableGithubObject): """ This class represents NamedUsers. The reference can be found here https://docs.github.com/en/rest/reference/users#get-a-single-user """ def __repr__(self): return self.get__repr__({"login": self._login.value}) @property def node_id(self): """ :type: string """ self._completeIfNotSet(self._node_id) return self._node_id.value @property def twitter_username(self): """ :type: string """ self._completeIfNotSet(self._twitter_username) return self._twitter_username.value def __hash__(self): return hash((self.id, self.login)) def __eq__(self, other): return ( isinstance(other, type(self)) and self.login == other.login and self.id == other.id ) @property def avatar_url(self): """ :type: string """ self._completeIfNotSet(self._avatar_url) return self._avatar_url.value @property def bio(self): """ :type: string """ self._completeIfNotSet(self._bio) return self._bio.value @property def blog(self): """ :type: string """ self._completeIfNotSet(self._blog) return self._blog.value @property def collaborators(self): """ :type: integer """ self._completeIfNotSet(self._collaborators) return self._collaborators.value @property def company(self): """ :type: string """ self._completeIfNotSet(self._company) return self._company.value @property def contributions(self): """ :type: integer """ self._completeIfNotSet(self._contributions) return self._contributions.value @property def created_at(self): """ :type: datetime.datetime """ self._completeIfNotSet(self._created_at) return self._created_at.value @property def disk_usage(self): """ :type: integer """ self._completeIfNotSet(self._disk_usage) return self._disk_usage.value @property def email(self): """ :type: string """ self._completeIfNotSet(self._email) return self._email.value @property def events_url(self): """ :type: string """ self._completeIfNotSet(self._events_url) return self._events_url.value @property def followers(self): """ :type: integer """ self._completeIfNotSet(self._followers) return self._followers.value @property def followers_url(self): """ :type: string """ self._completeIfNotSet(self._followers_url) return self._followers_url.value @property def following(self): """ :type: integer """ self._completeIfNotSet(self._following) return self._following.value @property def following_url(self): """ :type: string """ self._completeIfNotSet(self._following_url) return self._following_url.value @property def gists_url(self): """ :type: string """ self._completeIfNotSet(self._gists_url) return self._gists_url.value @property def gravatar_id(self): """ :type: string """ self._completeIfNotSet(self._gravatar_id) return self._gravatar_id.value @property def hireable(self): """ :type: bool """ self._completeIfNotSet(self._hireable) return self._hireable.value @property def html_url(self): """ :type: string """ self._completeIfNotSet(self._html_url) return self._html_url.value @property def id(self): """ :type: integer """ self._completeIfNotSet(self._id) return self._id.value @property def invitation_teams_url(self): """ :type: string """ self._completeIfNotSet(self._invitation_teams_url) return self._invitation_teams_url.value @property def inviter(self): """ :type: github.NamedUser.NamedUser """ self._completeIfNotSet(self._inviter) return self._inviter.value @property def location(self): """ :type: string """ self._completeIfNotSet(self._location) return self._location.value @property def login(self): """ :type: string """ self._completeIfNotSet(self._login) return self._login.value @property def name(self): """ :type: string """ self._completeIfNotSet(self._name) return self._name.value @property def organizations_url(self): """ :type: string """ self._completeIfNotSet(self._organizations_url) return self._organizations_url.value @property def owned_private_repos(self): """ :type: integer """ self._completeIfNotSet(self._owned_private_repos) return self._owned_private_repos.value @property def permissions(self): """ :type: :class:`github.Permissions.Permissions` """ self._completeIfNotSet(self._permissions) return self._permissions.value @property def plan(self): """ :type: :class:`github.Plan.Plan` """ self._completeIfNotSet(self._plan) return self._plan.value @property def private_gists(self): """ :type: integer """ self._completeIfNotSet(self._private_gists) return self._private_gists.value @property def public_gists(self): """ :type: integer """ self._completeIfNotSet(self._public_gists) return self._public_gists.value @property def public_repos(self): """ :type: integer """ self._completeIfNotSet(self._public_repos) return self._public_repos.value @property def received_events_url(self): """ :type: string """ self._completeIfNotSet(self._received_events_url) return self._received_events_url.value @property def repos_url(self): """ :type: string """ self._completeIfNotSet(self._repos_url) return self._repos_url.value @property def role(self): """ :type: string """ self._completeIfNotSet(self._role) return self._role.value @property def site_admin(self): """ :type: bool """ self._completeIfNotSet(self._site_admin) return self._site_admin.value @property def starred_url(self): """ :type: string """ self._completeIfNotSet(self._starred_url) return self._starred_url.value @property def subscriptions_url(self): """ :type: string """ self._completeIfNotSet(self._subscriptions_url) return self._subscriptions_url.value @property def suspended_at(self): """ :type: datetime.datetime """ self._completeIfNotSet(self._suspended_at) return self._suspended_at.value @property def team_count(self): """ :type: integer """ self._completeIfNotSet(self._team_count) return self._team_count.value @property def total_private_repos(self): """ :type: integer """ self._completeIfNotSet(self._total_private_repos) return self._total_private_repos.value @property def type(self): """ :type: string """ self._completeIfNotSet(self._type) return self._type.value @property def updated_at(self): """ :type: datetime.datetime """ self._completeIfNotSet(self._updated_at) return self._updated_at.value @property def url(self): """ :type: string """ self._completeIfNotSet(self._url) return self._url.value def get_events(self): """ :calls: `GET /users/{user}/events `_ :rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.Event.Event` """ return github.PaginatedList.PaginatedList( github.Event.Event, self._requester, f"{self.url}/events", None ) def get_followers(self): """ :calls: `GET /users/{user}/followers `_ :rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.NamedUser.NamedUser` """ return github.PaginatedList.PaginatedList( NamedUser, self._requester, f"{self.url}/followers", None ) def get_following(self): """ :calls: `GET /users/{user}/following `_ :rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.NamedUser.NamedUser` """ return github.PaginatedList.PaginatedList( NamedUser, self._requester, f"{self.url}/following", None ) def get_gists(self, since=github.GithubObject.NotSet): """ :calls: `GET /users/{user}/gists `_ :param since: datetime.datetime format YYYY-MM-DDTHH:MM:SSZ :rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.Gist.Gist` """ assert since is github.GithubObject.NotSet or isinstance( since, datetime.datetime ), since url_parameters = dict() if since is not github.GithubObject.NotSet: url_parameters["since"] = since.strftime("%Y-%m-%dT%H:%M:%SZ") return github.PaginatedList.PaginatedList( github.Gist.Gist, self._requester, f"{self.url}/gists", url_parameters ) def get_keys(self): """ :calls: `GET /users/{user}/keys `_ :rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.UserKey.UserKey` """ return github.PaginatedList.PaginatedList( github.UserKey.UserKey, self._requester, f"{self.url}/keys", None ) def get_orgs(self): """ :calls: `GET /users/{user}/orgs `_ :rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.Organization.Organization` """ return github.PaginatedList.PaginatedList( github.Organization.Organization, self._requester, f"{self.url}/orgs", None ) def get_projects(self, state="open"): """ :calls: `GET /users/{user}/projects `_ :param state: string :rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.Project.Project` """ assert isinstance(state, str), state url_parameters = {"state": state} return github.PaginatedList.PaginatedList( github.Project.Project, self._requester, f"{self.url}/projects", url_parameters, headers={"Accept": Consts.mediaTypeProjectsPreview}, ) def get_public_events(self): """ :calls: `GET /users/{user}/events/public `_ :rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.Event.Event` """ return github.PaginatedList.PaginatedList( github.Event.Event, self._requester, f"{self.url}/events/public", None ) def get_public_received_events(self): """ :calls: `GET /users/{user}/received_events/public `_ :rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.Event.Event` """ return github.PaginatedList.PaginatedList( github.Event.Event, self._requester, f"{self.url}/received_events/public", None, ) def get_received_events(self): """ :calls: `GET /users/{user}/received_events `_ :rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.Event.Event` """ return github.PaginatedList.PaginatedList( github.Event.Event, self._requester, f"{self.url}/received_events", None ) def get_repo(self, name): """ :calls: `GET /repos/{owner}/{repo} `_ :param name: string :rtype: :class:`github.Repository.Repository` """ assert isinstance(name, str), name headers, data = self._requester.requestJsonAndCheck( "GET", f"/repos/{self.login}/{name}" ) return github.Repository.Repository( self._requester, headers, data, completed=True ) def get_repos( self, type=github.GithubObject.NotSet, sort=github.GithubObject.NotSet, direction=github.GithubObject.NotSet, ): """ :calls: `GET /users/{user}/repos `_ :param type: string :param sort: string :param direction: string :rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.Repository.Repository` """ assert type is github.GithubObject.NotSet or isinstance(type, str), type assert sort is github.GithubObject.NotSet or isinstance(sort, str), sort assert direction is github.GithubObject.NotSet or isinstance( direction, str ), direction url_parameters = dict() if type is not github.GithubObject.NotSet: url_parameters["type"] = type if sort is not github.GithubObject.NotSet: url_parameters["sort"] = sort if direction is not github.GithubObject.NotSet: url_parameters["direction"] = direction return github.PaginatedList.PaginatedList( github.Repository.Repository, self._requester, f"{self.url}/repos", url_parameters, ) def get_starred(self): """ :calls: `GET /users/{user}/starred `_ :rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.Repository.Repository` """ return github.PaginatedList.PaginatedList( github.Repository.Repository, self._requester, f"{self.url}/starred", None ) def get_subscriptions(self): """ :calls: `GET /users/{user}/subscriptions `_ :rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.Repository.Repository` """ return github.PaginatedList.PaginatedList( github.Repository.Repository, self._requester, f"{self.url}/subscriptions", None, ) def get_watched(self): """ :calls: `GET /users/{user}/watched `_ :rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.Repository.Repository` """ return github.PaginatedList.PaginatedList( github.Repository.Repository, self._requester, f"{self.url}/watched", None ) def has_in_following(self, following): """ :calls: `GET /users/{user}/following/{target_user} `_ :param following: :class:`github.NamedUser.NamedUser` :rtype: bool """ assert isinstance(following, github.NamedUser.NamedUser), following status, headers, data = self._requester.requestJson( "GET", f"{self.url}/following/{following._identity}" ) return status == 204 @property def _identity(self): return self.login def get_organization_membership(self, org): """ :calls: `GET /orgs/{org}/memberships/{username} `_ :param org: string or :class:`github.Organization.Organization` :rtype: :class:`github.Membership.Membership` """ assert isinstance(org, str) or isinstance( org, github.Organization.Organization ), org if isinstance(org, github.Organization.Organization): org = org.login headers, data = self._requester.requestJsonAndCheck( "GET", f"/orgs/{org}/memberships/{self.login}" ) return github.Membership.Membership( self._requester, headers, data, completed=True ) def _initAttributes(self): self._avatar_url = github.GithubObject.NotSet self._bio = github.GithubObject.NotSet self._blog = github.GithubObject.NotSet self._collaborators = github.GithubObject.NotSet self._company = github.GithubObject.NotSet self._contributions = github.GithubObject.NotSet self._created_at = github.GithubObject.NotSet self._disk_usage = github.GithubObject.NotSet self._email = github.GithubObject.NotSet self._events_url = github.GithubObject.NotSet self._followers = github.GithubObject.NotSet self._followers_url = github.GithubObject.NotSet self._following = github.GithubObject.NotSet self._following_url = github.GithubObject.NotSet self._gists_url = github.GithubObject.NotSet self._gravatar_id = github.GithubObject.NotSet self._hireable = github.GithubObject.NotSet self._html_url = github.GithubObject.NotSet self._id = github.GithubObject.NotSet self._invitation_teams_url = github.GithubObject.NotSet self._inviter = github.GithubObject.NotSet self._location = github.GithubObject.NotSet self._login = github.GithubObject.NotSet self._name = github.GithubObject.NotSet self._node_id = github.GithubObject.NotSet self._organizations_url = github.GithubObject.NotSet self._owned_private_repos = github.GithubObject.NotSet self._permissions = github.GithubObject.NotSet self._plan = github.GithubObject.NotSet self._private_gists = github.GithubObject.NotSet self._public_gists = github.GithubObject.NotSet self._public_repos = github.GithubObject.NotSet self._received_events_url = github.GithubObject.NotSet self._repos_url = github.GithubObject.NotSet self._role = github.GithubObject.NotSet self._site_admin = github.GithubObject.NotSet self._starred_url = github.GithubObject.NotSet self._subscriptions_url = github.GithubObject.NotSet self._suspended_at = github.GithubObject.NotSet self._team_count = github.GithubObject.NotSet self._total_private_repos = github.GithubObject.NotSet self._twitter_username = github.GithubObject.NotSet self._type = github.GithubObject.NotSet self._updated_at = github.GithubObject.NotSet self._url = github.GithubObject.NotSet def _useAttributes(self, attributes): if "avatar_url" in attributes: # pragma no branch self._avatar_url = self._makeStringAttribute(attributes["avatar_url"]) if "bio" in attributes: # pragma no branch self._bio = self._makeStringAttribute(attributes["bio"]) if "blog" in attributes: # pragma no branch self._blog = self._makeStringAttribute(attributes["blog"]) if "collaborators" in attributes: # pragma no branch self._collaborators = self._makeIntAttribute(attributes["collaborators"]) if "company" in attributes: # pragma no branch self._company = self._makeStringAttribute(attributes["company"]) if "contributions" in attributes: # pragma no branch self._contributions = self._makeIntAttribute(attributes["contributions"]) if "created_at" in attributes: # pragma no branch self._created_at = self._makeDatetimeAttribute(attributes["created_at"]) if "disk_usage" in attributes: # pragma no branch self._disk_usage = self._makeIntAttribute(attributes["disk_usage"]) if "email" in attributes: # pragma no branch self._email = self._makeStringAttribute(attributes["email"]) if "events_url" in attributes: # pragma no branch self._events_url = self._makeStringAttribute(attributes["events_url"]) if "followers" in attributes: # pragma no branch self._followers = self._makeIntAttribute(attributes["followers"]) if "followers_url" in attributes: # pragma no branch self._followers_url = self._makeStringAttribute(attributes["followers_url"]) if "following" in attributes: # pragma no branch self._following = self._makeIntAttribute(attributes["following"]) if "following_url" in attributes: # pragma no branch self._following_url = self._makeStringAttribute(attributes["following_url"]) if "gists_url" in attributes: # pragma no branch self._gists_url = self._makeStringAttribute(attributes["gists_url"]) if "gravatar_id" in attributes: # pragma no branch self._gravatar_id = self._makeStringAttribute(attributes["gravatar_id"]) if "hireable" in attributes: # pragma no branch self._hireable = self._makeBoolAttribute(attributes["hireable"]) if "html_url" in attributes: # pragma no branch self._html_url = self._makeStringAttribute(attributes["html_url"]) if "id" in attributes: # pragma no branch self._id = self._makeIntAttribute(attributes["id"]) if "invitation_teams_url" in attributes: # pragma no branch self._invitation_teams_url = self._makeStringAttribute( attributes["invitation_teams_url"] ) if "inviter" in attributes: # pragma no branch self._inviter = self._makeClassAttribute( github.NamedUser.NamedUser, attributes["inviter"] ) if "location" in attributes: # pragma no branch self._location = self._makeStringAttribute(attributes["location"]) if "login" in attributes: # pragma no branch self._login = self._makeStringAttribute(attributes["login"]) if "name" in attributes: # pragma no branch self._name = self._makeStringAttribute(attributes["name"]) if "node_id" in attributes: # pragma no branch self._node_id = self._makeStringAttribute(attributes["node_id"]) if "organizations_url" in attributes: # pragma no branch self._organizations_url = self._makeStringAttribute( attributes["organizations_url"] ) if "owned_private_repos" in attributes: # pragma no branch self._owned_private_repos = self._makeIntAttribute( attributes["owned_private_repos"] ) if "permissions" in attributes: # pragma no branch self._permissions = self._makeClassAttribute( github.Permissions.Permissions, attributes["permissions"] ) if "plan" in attributes: # pragma no branch self._plan = self._makeClassAttribute(github.Plan.Plan, attributes["plan"]) if "private_gists" in attributes: # pragma no branch self._private_gists = self._makeIntAttribute(attributes["private_gists"]) if "public_gists" in attributes: # pragma no branch self._public_gists = self._makeIntAttribute(attributes["public_gists"]) if "public_repos" in attributes: # pragma no branch self._public_repos = self._makeIntAttribute(attributes["public_repos"]) if "received_events_url" in attributes: # pragma no branch self._received_events_url = self._makeStringAttribute( attributes["received_events_url"] ) if "repos_url" in attributes: # pragma no branch self._repos_url = self._makeStringAttribute(attributes["repos_url"]) if "role" in attributes: # pragma no branch self._role = self._makeStringAttribute(attributes["role"]) if "site_admin" in attributes: # pragma no branch self._site_admin = self._makeBoolAttribute(attributes["site_admin"]) if "starred_url" in attributes: # pragma no branch self._starred_url = self._makeStringAttribute(attributes["starred_url"]) if "subscriptions_url" in attributes: # pragma no branch self._subscriptions_url = self._makeStringAttribute( attributes["subscriptions_url"] ) if "suspended_at" in attributes: # pragma no branch self._suspended_at = self._makeDatetimeAttribute(attributes["suspended_at"]) if "team_count" in attributes: self._team_count = self._makeIntAttribute(attributes["team_count"]) if "total_private_repos" in attributes: # pragma no branch self._total_private_repos = self._makeIntAttribute( attributes["total_private_repos"] ) if "twitter_username" in attributes: # pragma no branch self._twitter_username = self._makeStringAttribute( attributes["twitter_username"] ) if "type" in attributes: # pragma no branch self._type = self._makeStringAttribute(attributes["type"]) if "updated_at" in attributes: # pragma no branch self._updated_at = self._makeDatetimeAttribute(attributes["updated_at"]) if "url" in attributes: # pragma no branch self._url = self._makeStringAttribute(attributes["url"]) ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1619412308.0 PyGithub-1.55/github/NamedUser.pyi0000644000175100001710000001063400000000000016433 0ustar00runnerdockerfrom datetime import datetime from typing import Any, Dict, Optional, Union from github.Event import Event from github.Gist import Gist from github.GithubObject import CompletableGithubObject, _NotSetType from github.Membership import Membership from github.Organization import Organization from github.PaginatedList import PaginatedList from github.Permissions import Permissions from github.Plan import Plan from github.Project import Project from github.Repository import Repository from github.UserKey import UserKey class NamedUser(CompletableGithubObject): def __eq__(self, other: Any) -> bool: ... def __hash__(self) -> int: ... def __repr__(self) -> str: ... @property def _identity(self) -> str: ... def _initAttributes(self) -> None: ... def _useAttributes(self, attributes: Dict[str, Any]) -> None: ... @property def avatar_url(self) -> str: ... @property def bio(self) -> Optional[str]: ... @property def blog(self) -> str: ... @property def collaborators(self) -> Optional[int]: ... @property def company(self) -> str: ... @property def contributions(self) -> int: ... @property def created_at(self) -> datetime: ... @property def disk_usage(self) -> Optional[int]: ... @property def email(self) -> str: ... @property def events_url(self) -> str: ... @property def followers(self) -> int: ... @property def followers_url(self) -> str: ... @property def following(self) -> int: ... @property def following_url(self) -> str: ... def get_events(self) -> PaginatedList[Event]: ... def get_followers(self) -> PaginatedList[NamedUser]: ... def get_following(self) -> PaginatedList[NamedUser]: ... def get_gists( self, since: Union[_NotSetType, datetime] = ... ) -> PaginatedList[Gist]: ... def get_keys(self) -> PaginatedList[UserKey]: ... def get_organization_membership(self, org: int) -> Membership: ... def get_orgs(self) -> PaginatedList[Organization]: ... def get_projects(self, state: str = ...) -> PaginatedList[Project]: ... def get_public_events(self) -> PaginatedList[Event]: ... def get_public_received_events(self) -> PaginatedList[Event]: ... def get_received_events(self) -> PaginatedList[Event]: ... def get_repo(self, name: str) -> Repository: ... def get_repos( self, type: Union[str, _NotSetType] = ..., sort: Union[str, _NotSetType] = ..., direction: Union[str, _NotSetType] = ..., ) -> PaginatedList[Repository]: ... def get_starred(self) -> PaginatedList[Repository]: ... def get_subscriptions(self) -> PaginatedList[Repository]: ... def get_watched(self) -> PaginatedList[Repository]: ... @property def gists_url(self) -> str: ... @property def gravatar_id(self) -> str: ... def has_in_following(self, following: NamedUser) -> bool: ... @property def hireable(self) -> bool: ... @property def html_url(self) -> str: ... @property def id(self) -> int: ... @property def invitation_teams_url(self) -> str: ... @property def inviter(self) -> NamedUser: ... @property def location(self) -> str: ... @property def login(self) -> str: ... @property def name(self) -> str: ... @property def node_id(self) -> str: ... @property def organizations_url(self) -> str: ... @property def owned_private_repos(self) -> Optional[int]: ... @property def permissions(self) -> Permissions: ... @property def plan(self) -> Optional[Plan]: ... @property def private_gists(self) -> Optional[int]: ... @property def public_gists(self) -> int: ... @property def public_repos(self) -> int: ... @property def received_events_url(self) -> str: ... @property def repos_url(self) -> str: ... @property def role(self) -> str: ... @property def site_admin(self) -> bool: ... @property def starred_url(self) -> str: ... @property def subscriptions_url(self) -> str: ... @property def suspended_at(self) -> Optional[datetime]: ... @property def team_count(self) -> int: ... @property def total_private_repos(self) -> Optional[int]: ... @property def twitter_username(self) -> str: ... @property def type(self) -> str: ... @property def updated_at(self) -> datetime: ... @property def url(self) -> str: ... ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1619412308.0 PyGithub-1.55/github/Notification.py0000644000175100001710000001560000000000000017023 0ustar00runnerdocker############################ Copyrights and license ############################ # # # Copyright 2013 AKFish # # Copyright 2013 Peter Golm # # Copyright 2013 Vincent Jacques # # Copyright 2013 martinqt # # Copyright 2014 Vincent Jacques # # Copyright 2016 Jannis Gebauer # # Copyright 2016 Peter Buckley # # Copyright 2018 sfdye # # # # This file is part of PyGithub. # # http://pygithub.readthedocs.io/ # # # # PyGithub is free software: you can redistribute it and/or modify it under # # the terms of the GNU Lesser General Public License as published by the Free # # Software Foundation, either version 3 of the License, or (at your option) # # any later version. # # # # PyGithub is distributed in the hope that it will be useful, but WITHOUT ANY # # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more # # details. # # # # You should have received a copy of the GNU Lesser General Public License # # along with PyGithub. If not, see . # # # ################################################################################ import github.GithubObject import github.NotificationSubject import github.Repository class Notification(github.GithubObject.CompletableGithubObject): """ This class represents Notifications. The reference can be found here http://docs.github.com/en/rest/reference/activity#notifications """ def __repr__(self): return self.get__repr__({"id": self._id.value, "subject": self._subject.value}) @property def id(self): """ :type: string """ self._completeIfNotSet(self._id) return self._id.value @property def last_read_at(self): """ :type: datetime.datetime """ self._completeIfNotSet(self._last_read_at) return self._last_read_at.value @property def repository(self): """ :type: :class:`github.Repository.Repository` """ self._completeIfNotSet(self._repository) return self._repository.value @property def subject(self): """ :type: :class:`github.NotificationSubject.NotificationSubject` """ self._completeIfNotSet(self._subject) return self._subject.value @property def reason(self): """ :type: string """ self._completeIfNotSet(self._reason) return self._reason.value @property def subscription_url(self): """ :type: string """ self._completeIfNotSet(self._subscription_url) return self._subscription_url.value @property def unread(self): """ :type: bool """ self._completeIfNotSet(self._unread) return self._unread.value @property def updated_at(self): """ :type: datetime.datetime """ self._completeIfNotSet(self._updated_at) return self._updated_at.value @property def url(self): """ :type: string """ self._completeIfNotSet(self._url) return self._url.value def mark_as_read(self): """ :calls: `PATCH /notifications/threads/{id} `_ """ headers, data = self._requester.requestJsonAndCheck( "PATCH", self.url, ) def get_pull_request(self): """ :type: :class:github.PullRequest.PullRequest """ headers, data = self._requester.requestJsonAndCheck("GET", self.subject.url) return github.PullRequest.PullRequest( self._requester, headers, data, completed=True ) def get_issue(self): """ :type: :class:github.Issue.Issue """ headers, data = self._requester.requestJsonAndCheck("GET", self.subject.url) return github.Issue.Issue(self._requester, headers, data, completed=True) def _initAttributes(self): self._id = github.GithubObject.NotSet self._last_read_at = github.GithubObject.NotSet self._repository = github.GithubObject.NotSet self._reason = github.GithubObject.NotSet self._subscription_url = github.GithubObject.NotSet self._unread = github.GithubObject.NotSet self._updated_at = github.GithubObject.NotSet self._url = github.GithubObject.NotSet def _useAttributes(self, attributes): if "id" in attributes: # pragma no branch self._id = self._makeStringAttribute(attributes["id"]) if "last_read_at" in attributes: # pragma no branch self._last_read_at = self._makeDatetimeAttribute(attributes["last_read_at"]) if "repository" in attributes: # pragma no branch self._repository = self._makeClassAttribute( github.Repository.Repository, attributes["repository"] ) if "subject" in attributes: # pragma no branch self._subject = self._makeClassAttribute( github.NotificationSubject.NotificationSubject, attributes["subject"] ) if "reason" in attributes: # pragma no branch self._reason = self._makeStringAttribute(attributes["reason"]) if "subscription_url" in attributes: # pragma no branch self._subscription_url = self._makeStringAttribute( attributes["subscription_url"] ) if "unread" in attributes: # pragma no branch self._unread = self._makeBoolAttribute(attributes["unread"]) if "updated_at" in attributes: # pragma no branch self._updated_at = self._makeDatetimeAttribute(attributes["updated_at"]) if "url" in attributes: # pragma no branch self._url = self._makeStringAttribute(attributes["url"]) ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1619412308.0 PyGithub-1.55/github/Notification.pyi0000644000175100001710000000210500000000000017170 0ustar00runnerdockerfrom datetime import datetime from typing import Any, Dict, Optional from github.GithubObject import CompletableGithubObject from github.Issue import Issue from github.NotificationSubject import NotificationSubject from github.PullRequest import PullRequest from github.Repository import Repository class Notification(CompletableGithubObject): def _initAttributes(self) -> None: ... def _useAttributes(self, attributes: Dict[str, Any]) -> None: ... @property def id(self) -> str: ... @property def last_read_at(self) -> datetime: ... def mark_as_read(self) -> None: ... @property def reason(self) -> str: ... @property def repository(self) -> Repository: ... @property def subject(self) -> NotificationSubject: ... @property def subscription_url(self) -> str: ... @property def unread(self) -> Optional[bool]: ... @property def updated_at(self) -> Optional[datetime]: ... @property def url(self) -> Optional[str]: ... def get_pull_request(self) -> PullRequest: ... def get_issue(self) -> Issue: ... ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1619412308.0 PyGithub-1.55/github/NotificationSubject.py0000644000175100001710000000747100000000000020352 0ustar00runnerdocker############################ Copyrights and license ############################ # # # Copyright 2013 AKFish # # Copyright 2013 Vincent Jacques # # Copyright 2014 Vincent Jacques # # Copyright 2016 Jannis Gebauer # # Copyright 2016 Peter Buckley # # Copyright 2018 Wan Liuyang # # Copyright 2018 sfdye # # # # This file is part of PyGithub. # # http://pygithub.readthedocs.io/ # # # # PyGithub is free software: you can redistribute it and/or modify it under # # the terms of the GNU Lesser General Public License as published by the Free # # Software Foundation, either version 3 of the License, or (at your option) # # any later version. # # # # PyGithub is distributed in the hope that it will be useful, but WITHOUT ANY # # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more # # details. # # # # You should have received a copy of the GNU Lesser General Public License # # along with PyGithub. If not, see . # # # ################################################################################ import github.GithubObject class NotificationSubject(github.GithubObject.NonCompletableGithubObject): """ This class represents Subjects of Notifications. The reference can be found here http://docs.github.com/en/rest/reference/activity/notifications#list-your-notifications """ def __repr__(self): return self.get__repr__({"title": self._title.value}) @property def title(self): """ :type: string """ return self._title.value @property def url(self): """ :type: string """ return self._url.value @property def latest_comment_url(self): """ :type: string """ return self._latest_comment_url.value @property def type(self): """ :type: string """ return self._type.value def _initAttributes(self): self._title = github.GithubObject.NotSet self._url = github.GithubObject.NotSet self._latest_comment_url = github.GithubObject.NotSet self._type = github.GithubObject.NotSet def _useAttributes(self, attributes): if "title" in attributes: # pragma no branch self._title = self._makeStringAttribute(attributes["title"]) if "url" in attributes: # pragma no branch self._url = self._makeStringAttribute(attributes["url"]) if "latest_comment_url" in attributes: # pragma no branch self._latest_comment_url = self._makeStringAttribute( attributes["latest_comment_url"] ) if "type" in attributes: # pragma no branch self._type = self._makeStringAttribute(attributes["type"]) ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1619412308.0 PyGithub-1.55/github/NotificationSubject.pyi0000644000175100001710000000100500000000000020506 0ustar00runnerdockerfrom typing import Any, Dict, Optional from github.GithubObject import NonCompletableGithubObject class NotificationSubject(NonCompletableGithubObject): def __repr__(self) -> str: ... def _initAttributes(self) -> None: ... def _useAttributes(self, attributes: Dict[str, Any]) -> None: ... @property def latest_comment_url(self) -> Optional[str]: ... @property def title(self) -> str: ... @property def type(self) -> str: ... @property def url(self) -> Optional[str]: ... ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1619412308.0 PyGithub-1.55/github/Organization.py0000644000175100001710000014625300000000000017052 0ustar00runnerdocker############################ Copyrights and license ############################ # # # Copyright 2012 Steve English # # Copyright 2012 Vincent Jacques # # Copyright 2012 Zearin # # Copyright 2013 AKFish # # Copyright 2013 Vincent Jacques # # Copyright 2013 martinqt # # Copyright 2014 Vincent Jacques # # Copyright 2015 Sebastien Besson # # Copyright 2016 Jannis Gebauer # # Copyright 2016 Matthew Neal # # Copyright 2016 Michael Pereira # # Copyright 2016 Peter Buckley # # Copyright 2017 Balázs Rostás # # Copyright 2018 Anton Nguyen # # Copyright 2018 Jacopo Notarstefano # # Copyright 2018 Jasper van Wanrooy # # Copyright 2018 Raihaan <31362124+res0nance@users.noreply.github.com> # # Copyright 2018 Tim Boring # # Copyright 2018 sfdye # # Copyright 2018 Steve Kowalik # # # # This file is part of PyGithub. # # http://pygithub.readthedocs.io/ # # # # PyGithub is free software: you can redistribute it and/or modify it under # # the terms of the GNU Lesser General Public License as published by the Free # # Software Foundation, either version 3 of the License, or (at your option) # # any later version. # # # # PyGithub is distributed in the hope that it will be useful, but WITHOUT ANY # # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more # # details. # # # # You should have received a copy of the GNU Lesser General Public License # # along with PyGithub. If not, see . # # # ################################################################################ import datetime import github.Event import github.GithubObject import github.NamedUser import github.PaginatedList import github.Plan import github.Project import github.Repository import github.Team from . import Consts class Organization(github.GithubObject.CompletableGithubObject): """ This class represents Organizations. The reference can be found here http://docs.github.com/en/rest/reference/orgs """ def __repr__(self): return self.get__repr__({"login": self._login.value}) @property def avatar_url(self): """ :type: string """ self._completeIfNotSet(self._avatar_url) return self._avatar_url.value @property def billing_email(self): """ :type: string """ self._completeIfNotSet(self._billing_email) return self._billing_email.value @property def blog(self): """ :type: string """ self._completeIfNotSet(self._blog) return self._blog.value @property def collaborators(self): """ :type: integer """ self._completeIfNotSet(self._collaborators) return self._collaborators.value @property def company(self): """ :type: string """ self._completeIfNotSet(self._company) return self._company.value @property def created_at(self): """ :type: datetime.datetime """ self._completeIfNotSet(self._created_at) return self._created_at.value @property def default_repository_permission(self): """ :type: string """ self._completeIfNotSet(self._default_repository_permission) return self._default_repository_permission.value @property def description(self): """ :type: string """ self._completeIfNotSet(self._description) return self._description.value @property def disk_usage(self): """ :type: integer """ self._completeIfNotSet(self._disk_usage) return self._disk_usage.value @property def email(self): """ :type: string """ self._completeIfNotSet(self._email) return self._email.value @property def events_url(self): """ :type: string """ self._completeIfNotSet(self._events_url) return self._events_url.value @property def followers(self): """ :type: integer """ self._completeIfNotSet(self._followers) return self._followers.value @property def following(self): """ :type: integer """ self._completeIfNotSet(self._following) return self._following.value @property def gravatar_id(self): """ :type: string """ self._completeIfNotSet(self._gravatar_id) return self._gravatar_id.value @property def has_organization_projects(self): """ :type: bool """ self._completeIfNotSet(self._has_organization_projects) return self._has_organization_projects.value @property def has_repository_projects(self): """ :type: bool """ self._completeIfNotSet(self._has_repository_projects) return self._has_repository_projects.value @property def hooks_url(self): """ :type: string """ self._completeIfNotSet(self._hooks_url) return self._hooks_url.value @property def html_url(self): """ :type: string """ self._completeIfNotSet(self._html_url) return self._html_url.value @property def id(self): """ :type: integer """ self._completeIfNotSet(self._id) return self._id.value @property def issues_url(self): """ :type: string """ self._completeIfNotSet(self._issues_url) return self._issues_url.value @property def location(self): """ :type: string """ self._completeIfNotSet(self._location) return self._location.value @property def login(self): """ :type: string """ self._completeIfNotSet(self._login) return self._login.value @property def members_can_create_repositories(self): """ :type: bool """ self._completeIfNotSet(self._members_can_create_repositories) return self._members_can_create_repositories.value @property def members_url(self): """ :type: string """ self._completeIfNotSet(self._members_url) return self._members_url.value @property def name(self): """ :type: string """ self._completeIfNotSet(self._name) return self._name.value @property def owned_private_repos(self): """ :type: integer """ self._completeIfNotSet(self._owned_private_repos) return self._owned_private_repos.value @property def plan(self): """ :type: :class:`github.Plan.Plan` """ self._completeIfNotSet(self._plan) return self._plan.value @property def private_gists(self): """ :type: integer """ self._completeIfNotSet(self._private_gists) return self._private_gists.value @property def public_gists(self): """ :type: integer """ self._completeIfNotSet(self._public_gists) return self._public_gists.value @property def public_members_url(self): """ :type: string """ self._completeIfNotSet(self._public_members_url) return self._public_members_url.value @property def public_repos(self): """ :type: integer """ self._completeIfNotSet(self._public_repos) return self._public_repos.value @property def repos_url(self): """ :type: string """ self._completeIfNotSet(self._repos_url) return self._repos_url.value @property def total_private_repos(self): """ :type: integer """ self._completeIfNotSet(self._total_private_repos) return self._total_private_repos.value @property def two_factor_requirement_enabled(self): """ :type: bool """ self._completeIfNotSet(self._two_factor_requirement_enabled) return self._two_factor_requirement_enabled.value @property def type(self): """ :type: string """ self._completeIfNotSet(self._type) return self._type.value @property def updated_at(self): """ :type: datetime.datetime """ self._completeIfNotSet(self._updated_at) return self._updated_at.value @property def url(self): """ :type: string """ self._completeIfNotSet(self._url) return self._url.value def add_to_members(self, member, role=github.GithubObject.NotSet): """ :calls: `PUT /orgs/{org}/memberships/{user} `_ :param member: :class:`github.NamedUser.NamedUser` :param role: string :rtype: None """ assert role is github.GithubObject.NotSet or isinstance(role, str), role assert isinstance(member, github.NamedUser.NamedUser), member put_parameters = {} if role is not github.GithubObject.NotSet: put_parameters["role"] = role headers, data = self._requester.requestJsonAndCheck( "PUT", f"{self.url}/memberships/{member._identity}", input=put_parameters ) def add_to_public_members(self, public_member): """ :calls: `PUT /orgs/{org}/public_members/{user} `_ :param public_member: :class:`github.NamedUser.NamedUser` :rtype: None """ assert isinstance(public_member, github.NamedUser.NamedUser), public_member headers, data = self._requester.requestJsonAndCheck( "PUT", f"{self.url}/public_members/{public_member._identity}" ) def create_fork(self, repo): """ :calls: `POST /repos/{owner}/{repo}/forks `_ :param repo: :class:`github.Repository.Repository` :rtype: :class:`github.Repository.Repository` """ assert isinstance(repo, github.Repository.Repository), repo url_parameters = { "org": self.login, } headers, data = self._requester.requestJsonAndCheck( "POST", f"/repos/{repo.owner.login}/{repo.name}/forks", parameters=url_parameters, ) return github.Repository.Repository( self._requester, headers, data, completed=True ) def create_hook( self, name, config, events=github.GithubObject.NotSet, active=github.GithubObject.NotSet, ): """ :calls: `POST /orgs/{owner}/hooks `_ :param name: string :param config: dict :param events: list of string :param active: bool :rtype: :class:`github.Hook.Hook` """ assert isinstance(name, str), name assert isinstance(config, dict), config assert events is github.GithubObject.NotSet or all( isinstance(element, str) for element in events ), events assert active is github.GithubObject.NotSet or isinstance(active, bool), active post_parameters = { "name": name, "config": config, } if events is not github.GithubObject.NotSet: post_parameters["events"] = events if active is not github.GithubObject.NotSet: post_parameters["active"] = active headers, data = self._requester.requestJsonAndCheck( "POST", f"{self.url}/hooks", input=post_parameters ) return github.Hook.Hook(self._requester, headers, data, completed=True) def create_project(self, name, body=github.GithubObject.NotSet): """ :calls: `POST /orgs/{org}/projects `_ :param name: string :param body: string :rtype: :class:`github.Project.Project` """ assert isinstance(name, str), name assert body is github.GithubObject.NotSet or isinstance(body, str), body post_parameters = {"name": name} if body is not github.GithubObject.NotSet: post_parameters["body"] = body headers, data = self._requester.requestJsonAndCheck( "POST", f"{self.url}/projects", input=post_parameters, headers={"Accept": Consts.mediaTypeProjectsPreview}, ) return github.Project.Project(self._requester, headers, data, completed=True) def create_repo( self, name, description=github.GithubObject.NotSet, homepage=github.GithubObject.NotSet, private=github.GithubObject.NotSet, has_issues=github.GithubObject.NotSet, has_wiki=github.GithubObject.NotSet, has_downloads=github.GithubObject.NotSet, has_projects=github.GithubObject.NotSet, team_id=github.GithubObject.NotSet, auto_init=github.GithubObject.NotSet, license_template=github.GithubObject.NotSet, gitignore_template=github.GithubObject.NotSet, allow_squash_merge=github.GithubObject.NotSet, allow_merge_commit=github.GithubObject.NotSet, allow_rebase_merge=github.GithubObject.NotSet, delete_branch_on_merge=github.GithubObject.NotSet, ): """ :calls: `POST /orgs/{org}/repos `_ :param name: string :param description: string :param homepage: string :param private: bool :param has_issues: bool :param has_wiki: bool :param has_downloads: bool :param has_projects: bool :param team_id: : int :param auto_init: bool :param license_template: string :param gitignore_template: string :param allow_squash_merge: bool :param allow_merge_commit: bool :param allow_rebase_merge: bool :param delete_branch_on_merge: bool :rtype: :class:`github.Repository.Repository` """ assert isinstance(name, str), name assert description is github.GithubObject.NotSet or isinstance( description, str ), description assert homepage is github.GithubObject.NotSet or isinstance( homepage, str ), homepage assert private is github.GithubObject.NotSet or isinstance( private, bool ), private assert has_issues is github.GithubObject.NotSet or isinstance( has_issues, bool ), has_issues assert has_wiki is github.GithubObject.NotSet or isinstance( has_wiki, bool ), has_wiki assert has_downloads is github.GithubObject.NotSet or isinstance( has_downloads, bool ), has_downloads assert has_projects is github.GithubObject.NotSet or isinstance( has_projects, bool ), has_projects assert team_id is github.GithubObject.NotSet or isinstance( team_id, int ), team_id assert auto_init is github.GithubObject.NotSet or isinstance( auto_init, bool ), auto_init assert license_template is github.GithubObject.NotSet or isinstance( license_template, str ), license_template assert gitignore_template is github.GithubObject.NotSet or isinstance( gitignore_template, str ), gitignore_template assert allow_squash_merge is github.GithubObject.NotSet or isinstance( allow_squash_merge, bool ), allow_squash_merge assert allow_merge_commit is github.GithubObject.NotSet or isinstance( allow_merge_commit, bool ), allow_merge_commit assert allow_rebase_merge is github.GithubObject.NotSet or isinstance( allow_rebase_merge, bool ), allow_rebase_merge assert delete_branch_on_merge is github.GithubObject.NotSet or isinstance( delete_branch_on_merge, bool ), delete_branch_on_merge post_parameters = { "name": name, } if description is not github.GithubObject.NotSet: post_parameters["description"] = description if homepage is not github.GithubObject.NotSet: post_parameters["homepage"] = homepage if private is not github.GithubObject.NotSet: post_parameters["private"] = private if has_issues is not github.GithubObject.NotSet: post_parameters["has_issues"] = has_issues if has_wiki is not github.GithubObject.NotSet: post_parameters["has_wiki"] = has_wiki if has_downloads is not github.GithubObject.NotSet: post_parameters["has_downloads"] = has_downloads if has_projects is not github.GithubObject.NotSet: post_parameters["has_projects"] = has_projects if team_id is not github.GithubObject.NotSet: post_parameters["team_id"] = team_id if auto_init is not github.GithubObject.NotSet: post_parameters["auto_init"] = auto_init if license_template is not github.GithubObject.NotSet: post_parameters["license_template"] = license_template if gitignore_template is not github.GithubObject.NotSet: post_parameters["gitignore_template"] = gitignore_template if allow_squash_merge is not github.GithubObject.NotSet: post_parameters["allow_squash_merge"] = allow_squash_merge if allow_merge_commit is not github.GithubObject.NotSet: post_parameters["allow_merge_commit"] = allow_merge_commit if allow_rebase_merge is not github.GithubObject.NotSet: post_parameters["allow_rebase_merge"] = allow_rebase_merge if delete_branch_on_merge is not github.GithubObject.NotSet: post_parameters["delete_branch_on_merge"] = delete_branch_on_merge headers, data = self._requester.requestJsonAndCheck( "POST", f"{self.url}/repos", input=post_parameters ) return github.Repository.Repository( self._requester, headers, data, completed=True ) def create_team( self, name, repo_names=github.GithubObject.NotSet, permission=github.GithubObject.NotSet, privacy=github.GithubObject.NotSet, description=github.GithubObject.NotSet, ): """ :calls: `POST /orgs/{org}/teams `_ :param name: string :param repo_names: list of :class:`github.Repository.Repository` :param permission: string :param privacy: string :param description: string :rtype: :class:`github.Team.Team` """ assert isinstance(name, str), name assert repo_names is github.GithubObject.NotSet or all( isinstance(element, github.Repository.Repository) for element in repo_names ), repo_names assert permission is github.GithubObject.NotSet or isinstance( permission, str ), permission assert privacy is github.GithubObject.NotSet or isinstance( privacy, str ), privacy assert description is github.GithubObject.NotSet or isinstance( description, str ), description post_parameters = { "name": name, } if repo_names is not github.GithubObject.NotSet: post_parameters["repo_names"] = [ element._identity for element in repo_names ] if permission is not github.GithubObject.NotSet: post_parameters["permission"] = permission if privacy is not github.GithubObject.NotSet: post_parameters["privacy"] = privacy if description is not github.GithubObject.NotSet: post_parameters["description"] = description headers, data = self._requester.requestJsonAndCheck( "POST", f"{self.url}/teams", input=post_parameters ) return github.Team.Team(self._requester, headers, data, completed=True) def delete_hook(self, id): """ :calls: `DELETE /orgs/{owner}/hooks/{id} `_ :param id: integer :rtype: None` """ assert isinstance(id, int), id headers, data = self._requester.requestJsonAndCheck( "DELETE", f"{self.url}/hooks/{id}" ) def edit( self, billing_email=github.GithubObject.NotSet, blog=github.GithubObject.NotSet, company=github.GithubObject.NotSet, description=github.GithubObject.NotSet, email=github.GithubObject.NotSet, location=github.GithubObject.NotSet, name=github.GithubObject.NotSet, ): """ :calls: `PATCH /orgs/{org} `_ :param billing_email: string :param blog: string :param company: string :param description: string :param email: string :param location: string :param name: string :rtype: None """ assert billing_email is github.GithubObject.NotSet or isinstance( billing_email, str ), billing_email assert blog is github.GithubObject.NotSet or isinstance(blog, str), blog assert company is github.GithubObject.NotSet or isinstance( company, str ), company assert description is github.GithubObject.NotSet or isinstance( description, str ), description assert email is github.GithubObject.NotSet or isinstance(email, str), email assert location is github.GithubObject.NotSet or isinstance( location, str ), location assert name is github.GithubObject.NotSet or isinstance(name, str), name post_parameters = dict() if billing_email is not github.GithubObject.NotSet: post_parameters["billing_email"] = billing_email if blog is not github.GithubObject.NotSet: post_parameters["blog"] = blog if company is not github.GithubObject.NotSet: post_parameters["company"] = company if description is not github.GithubObject.NotSet: post_parameters["description"] = description if email is not github.GithubObject.NotSet: post_parameters["email"] = email if location is not github.GithubObject.NotSet: post_parameters["location"] = location if name is not github.GithubObject.NotSet: post_parameters["name"] = name headers, data = self._requester.requestJsonAndCheck( "PATCH", self.url, input=post_parameters ) self._useAttributes(data) def edit_hook( self, id, name, config, events=github.GithubObject.NotSet, active=github.GithubObject.NotSet, ): """ :calls: `PATCH /orgs/{owner}/hooks/{id} `_ :param id: integer :param name: string :param config: dict :param events: list of string :param active: bool :rtype: :class:`github.Hook.Hook` """ assert isinstance(id, int), id assert isinstance(name, str), name assert isinstance(config, dict), config assert events is github.GithubObject.NotSet or all( isinstance(element, str) for element in events ), events assert active is github.GithubObject.NotSet or isinstance(active, bool), active post_parameters = { "name": name, "config": config, } if events is not github.GithubObject.NotSet: post_parameters["events"] = events if active is not github.GithubObject.NotSet: post_parameters["active"] = active headers, data = self._requester.requestJsonAndCheck( "PATCH", f"{self.url}/hooks/{id}", input=post_parameters ) return github.Hook.Hook(self._requester, headers, data, completed=True) def get_events(self): """ :calls: `GET /orgs/{org}/events `_ :rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.Event.Event` """ return github.PaginatedList.PaginatedList( github.Event.Event, self._requester, f"{self.url}/events", None ) def get_hook(self, id): """ :calls: `GET /orgs/{owner}/hooks/{id} `_ :param id: integer :rtype: :class:`github.Hook.Hook` """ assert isinstance(id, int), id headers, data = self._requester.requestJsonAndCheck( "GET", f"{self.url}/hooks/{id}" ) return github.Hook.Hook(self._requester, headers, data, completed=True) def get_hooks(self): """ :calls: `GET /orgs/{owner}/hooks `_ :rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.Hook.Hook` """ return github.PaginatedList.PaginatedList( github.Hook.Hook, self._requester, f"{self.url}/hooks", None ) def get_issues( self, filter=github.GithubObject.NotSet, state=github.GithubObject.NotSet, labels=github.GithubObject.NotSet, sort=github.GithubObject.NotSet, direction=github.GithubObject.NotSet, since=github.GithubObject.NotSet, ): """ :calls: `GET /orgs/{org}/issues `_ :rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.Issue.Issue` :param filter: string :param state: string :param labels: list of :class:`github.Label.Label` :param sort: string :param direction: string :param since: datetime.datetime :rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.Issue.Issue` """ assert filter is github.GithubObject.NotSet or isinstance(filter, str), filter assert state is github.GithubObject.NotSet or isinstance(state, str), state assert labels is github.GithubObject.NotSet or all( isinstance(element, github.Label.Label) for element in labels ), labels assert sort is github.GithubObject.NotSet or isinstance(sort, str), sort assert direction is github.GithubObject.NotSet or isinstance( direction, str ), direction assert since is github.GithubObject.NotSet or isinstance( since, datetime.datetime ), since url_parameters = dict() if filter is not github.GithubObject.NotSet: url_parameters["filter"] = filter if state is not github.GithubObject.NotSet: url_parameters["state"] = state if labels is not github.GithubObject.NotSet: url_parameters["labels"] = ",".join(label.name for label in labels) if sort is not github.GithubObject.NotSet: url_parameters["sort"] = sort if direction is not github.GithubObject.NotSet: url_parameters["direction"] = direction if since is not github.GithubObject.NotSet: url_parameters["since"] = since.strftime("%Y-%m-%dT%H:%M:%SZ") return github.PaginatedList.PaginatedList( github.Issue.Issue, self._requester, f"{self.url}/issues", url_parameters ) def get_members( self, filter_=github.GithubObject.NotSet, role=github.GithubObject.NotSet ): """ :calls: `GET /orgs/{org}/members `_ :param filter_: string :param role: string :rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.NamedUser.NamedUser` """ assert filter_ is github.GithubObject.NotSet or isinstance( filter_, str ), filter_ assert role is github.GithubObject.NotSet or isinstance(role, str), role url_parameters = {} if filter_ is not github.GithubObject.NotSet: url_parameters["filter"] = filter_ if role is not github.GithubObject.NotSet: url_parameters["role"] = role return github.PaginatedList.PaginatedList( github.NamedUser.NamedUser, self._requester, f"{self.url}/members", url_parameters, ) def get_projects(self, state=github.GithubObject.NotSet): """ :calls: `GET /orgs/{org}/projects `_ :rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.Project.Project` :param state: string """ url_parameters = dict() if state is not github.GithubObject.NotSet: url_parameters["state"] = state return github.PaginatedList.PaginatedList( github.Project.Project, self._requester, f"{self.url}/projects", url_parameters, {"Accept": Consts.mediaTypeProjectsPreview}, ) def get_public_members(self): """ :calls: `GET /orgs/{org}/public_members `_ :rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.NamedUser.NamedUser` """ return github.PaginatedList.PaginatedList( github.NamedUser.NamedUser, self._requester, f"{self.url}/public_members", None, ) def get_outside_collaborators(self, filter_=github.GithubObject.NotSet): """ :calls: `GET /orgs/{org}/outside_collaborators `_ :param filter_: string :rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.NamedUser.NamedUser` """ assert filter_ is github.GithubObject.NotSet or isinstance( filter_, str ), filter_ url_parameters = {} if filter_ is not github.GithubObject.NotSet: url_parameters["filter"] = filter_ return github.PaginatedList.PaginatedList( github.NamedUser.NamedUser, self._requester, f"{self.url}/outside_collaborators", url_parameters, ) def remove_outside_collaborator(self, collaborator): """ :calls: `DELETE /orgs/{org}/outside_collaborators/{username} `_ :param collaborator: :class:`github.NamedUser.NamedUser` :rtype: None """ assert isinstance(collaborator, github.NamedUser.NamedUser), collaborator headers, data = self._requester.requestJsonAndCheck( "DELETE", f"{self.url}/outside_collaborators/{collaborator._identity}" ) def convert_to_outside_collaborator(self, member): """ :calls: `PUT /orgs/{org}/outside_collaborators/{username} `_ :param member: :class:`github.NamedUser.NamedUser` :rtype: None """ assert isinstance(member, github.NamedUser.NamedUser), member headers, data = self._requester.requestJsonAndCheck( "PUT", f"{self.url}/outside_collaborators/{member._identity}" ) def get_repo(self, name): """ :calls: `GET /repos/{owner}/{repo} `_ :param name: string :rtype: :class:`github.Repository.Repository` """ assert isinstance(name, str), name headers, data = self._requester.requestJsonAndCheck( "GET", f"/repos/{self.login}/{name}" ) return github.Repository.Repository( self._requester, headers, data, completed=True ) def get_repos( self, type=github.GithubObject.NotSet, sort=github.GithubObject.NotSet, direction=github.GithubObject.NotSet, ): """ :calls: `GET /orgs/{org}/repos `_ :param type: string ('all', 'public', 'private', 'forks', 'sources', 'member') :param sort: string ('created', 'updated', 'pushed', 'full_name') :param direction: string ('asc', desc') :rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.Repository.Repository` """ assert type is github.GithubObject.NotSet or isinstance(type, str), type assert sort is github.GithubObject.NotSet or isinstance(sort, str), sort assert direction is github.GithubObject.NotSet or isinstance( direction, str ), direction url_parameters = dict() if type is not github.GithubObject.NotSet: url_parameters["type"] = type if sort is not github.GithubObject.NotSet: url_parameters["sort"] = sort if direction is not github.GithubObject.NotSet: url_parameters["direction"] = direction return github.PaginatedList.PaginatedList( github.Repository.Repository, self._requester, f"{self.url}/repos", url_parameters, ) def get_team(self, id): """ :calls: `GET /teams/{id} `_ :param id: integer :rtype: :class:`github.Team.Team` """ assert isinstance(id, int), id headers, data = self._requester.requestJsonAndCheck("GET", f"/teams/{id}") return github.Team.Team(self._requester, headers, data, completed=True) def get_team_by_slug(self, slug): """ :calls: `GET /orgs/{org}/teams/{team_slug} `_ :param slug: string :rtype: :class:`github.Team.Team` """ assert isinstance(slug, str), slug headers, data = self._requester.requestJsonAndCheck( "GET", f"{self.url}/teams/{slug}" ) return github.Team.Team(self._requester, headers, data, completed=True) def get_teams(self): """ :calls: `GET /orgs/{org}/teams `_ :rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.Team.Team` """ return github.PaginatedList.PaginatedList( github.Team.Team, self._requester, f"{self.url}/teams", None ) def invitations(self): """ :calls: `GET /orgs/{org}/invitations `_ :rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.NamedUser.NamedUser` """ return github.PaginatedList.PaginatedList( github.NamedUser.NamedUser, self._requester, f"{self.url}/invitations", None, headers={"Accept": Consts.mediaTypeOrganizationInvitationPreview}, ) def invite_user( self, user=github.GithubObject.NotSet, email=github.GithubObject.NotSet, role=github.GithubObject.NotSet, teams=github.GithubObject.NotSet, ): """ :calls: `POST /orgs/{org}/invitations `_ :param user: :class:`github.NamedUser.NamedUser` :param email: string :param role: string :param teams: array of :class:`github.Team.Team` :rtype: None """ assert user is github.GithubObject.NotSet or isinstance( user, github.NamedUser.NamedUser ), user assert email is github.GithubObject.NotSet or isinstance(email, str), email assert (email is github.GithubObject.NotSet) ^ ( user is github.GithubObject.NotSet ), "specify only one of email or user" parameters = {} if user is not github.GithubObject.NotSet: parameters["invitee_id"] = user.id elif email is not github.GithubObject.NotSet: parameters["email"] = email if role is not github.GithubObject.NotSet: assert isinstance(role, str), role assert role in ["admin", "direct_member", "billing_manager"] parameters["role"] = role if teams is not github.GithubObject.NotSet: assert all(isinstance(team, github.Team.Team) for team in teams) parameters["team_ids"] = [t.id for t in teams] headers, data = self._requester.requestJsonAndCheck( "POST", f"{self.url}/invitations", headers={"Accept": Consts.mediaTypeOrganizationInvitationPreview}, input=parameters, ) def has_in_members(self, member): """ :calls: `GET /orgs/{org}/members/{user} `_ :param member: :class:`github.NamedUser.NamedUser` :rtype: bool """ assert isinstance(member, github.NamedUser.NamedUser), member status, headers, data = self._requester.requestJson( "GET", f"{self.url}/members/{member._identity}" ) if status == 302: status, headers, data = self._requester.requestJson( "GET", headers["location"] ) return status == 204 def has_in_public_members(self, public_member): """ :calls: `GET /orgs/{org}/public_members/{user} `_ :param public_member: :class:`github.NamedUser.NamedUser` :rtype: bool """ assert isinstance(public_member, github.NamedUser.NamedUser), public_member status, headers, data = self._requester.requestJson( "GET", f"{self.url}/public_members/{public_member._identity}" ) return status == 204 def remove_from_membership(self, member): """ :calls: `DELETE /orgs/{org}/memberships/{user} `_ :param member: :class:`github.NamedUser.NamedUser` :rtype: None """ assert isinstance(member, github.NamedUser.NamedUser), member headers, data = self._requester.requestJsonAndCheck( "DELETE", f"{self.url}/memberships/{member._identity}" ) def remove_from_members(self, member): """ :calls: `DELETE /orgs/{org}/members/{user} `_ :param member: :class:`github.NamedUser.NamedUser` :rtype: None """ assert isinstance(member, github.NamedUser.NamedUser), member headers, data = self._requester.requestJsonAndCheck( "DELETE", f"{self.url}/members/{member._identity}" ) def remove_from_public_members(self, public_member): """ :calls: `DELETE /orgs/{org}/public_members/{user} `_ :param public_member: :class:`github.NamedUser.NamedUser` :rtype: None """ assert isinstance(public_member, github.NamedUser.NamedUser), public_member headers, data = self._requester.requestJsonAndCheck( "DELETE", f"{self.url}/public_members/{public_member._identity}" ) def create_migration( self, repos, lock_repositories=github.GithubObject.NotSet, exclude_attachments=github.GithubObject.NotSet, ): """ :calls: `POST /orgs/{org}/migrations `_ :param repos: list or tuple of str :param lock_repositories: bool :param exclude_attachments: bool :rtype: :class:`github.Migration.Migration` """ assert isinstance(repos, (list, tuple)), repos assert all(isinstance(repo, str) for repo in repos), repos assert lock_repositories is github.GithubObject.NotSet or isinstance( lock_repositories, bool ), lock_repositories assert exclude_attachments is github.GithubObject.NotSet or isinstance( exclude_attachments, bool ), exclude_attachments post_parameters = {"repositories": repos} if lock_repositories is not github.GithubObject.NotSet: post_parameters["lock_repositories"] = lock_repositories if exclude_attachments is not github.GithubObject.NotSet: post_parameters["exclude_attachments"] = exclude_attachments headers, data = self._requester.requestJsonAndCheck( "POST", f"/orgs/{self.login}/migrations", input=post_parameters, headers={"Accept": Consts.mediaTypeMigrationPreview}, ) return github.Migration.Migration( self._requester, headers, data, completed=True ) def get_migrations(self): """ :calls: `GET /orgs/{org}/migrations `_ :rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.Migration.Migration` """ return github.PaginatedList.PaginatedList( github.Migration.Migration, self._requester, f"/orgs/{self.login}/migrations", None, headers={"Accept": Consts.mediaTypeMigrationPreview}, ) def get_installations(self): """ :calls: `GET /orgs/{org}/installations `_ :rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.Installation.Installation` """ return github.PaginatedList.PaginatedList( github.Installation.Installation, self._requester, f"{self.url}/installations", None, None, list_item="installations", ) def _initAttributes(self): self._default_repository_permission = github.GithubObject.NotSet self._has_organization_projects = github.GithubObject.NotSet self._has_repository_projects = github.GithubObject.NotSet self._hooks_url = github.GithubObject.NotSet self._issues_url = github.GithubObject.NotSet self._members_can_create_repositories = github.GithubObject.NotSet self._two_factor_requirement_enabled = github.GithubObject.NotSet self._avatar_url = github.GithubObject.NotSet self._billing_email = github.GithubObject.NotSet self._blog = github.GithubObject.NotSet self._collaborators = github.GithubObject.NotSet self._company = github.GithubObject.NotSet self._created_at = github.GithubObject.NotSet self._description = github.GithubObject.NotSet self._disk_usage = github.GithubObject.NotSet self._email = github.GithubObject.NotSet self._events_url = github.GithubObject.NotSet self._followers = github.GithubObject.NotSet self._following = github.GithubObject.NotSet self._gravatar_id = github.GithubObject.NotSet self._html_url = github.GithubObject.NotSet self._id = github.GithubObject.NotSet self._location = github.GithubObject.NotSet self._login = github.GithubObject.NotSet self._members_url = github.GithubObject.NotSet self._name = github.GithubObject.NotSet self._owned_private_repos = github.GithubObject.NotSet self._plan = github.GithubObject.NotSet self._private_gists = github.GithubObject.NotSet self._public_gists = github.GithubObject.NotSet self._public_members_url = github.GithubObject.NotSet self._public_repos = github.GithubObject.NotSet self._repos_url = github.GithubObject.NotSet self._total_private_repos = github.GithubObject.NotSet self._type = github.GithubObject.NotSet self._updated_at = github.GithubObject.NotSet self._url = github.GithubObject.NotSet def _useAttributes(self, attributes): if "avatar_url" in attributes: # pragma no branch self._avatar_url = self._makeStringAttribute(attributes["avatar_url"]) if "billing_email" in attributes: # pragma no branch self._billing_email = self._makeStringAttribute(attributes["billing_email"]) if "blog" in attributes: # pragma no branch self._blog = self._makeStringAttribute(attributes["blog"]) if "collaborators" in attributes: # pragma no branch self._collaborators = self._makeIntAttribute(attributes["collaborators"]) if "company" in attributes: # pragma no branch self._company = self._makeStringAttribute(attributes["company"]) if "created_at" in attributes: # pragma no branch self._created_at = self._makeDatetimeAttribute(attributes["created_at"]) if "default_repository_permission" in attributes: # pragma no branch self._default_repository_permission = self._makeStringAttribute( attributes["default_repository_permission"] ) if "description" in attributes: # pragma no branch self._description = self._makeStringAttribute(attributes["description"]) if "disk_usage" in attributes: # pragma no branch self._disk_usage = self._makeIntAttribute(attributes["disk_usage"]) if "email" in attributes: # pragma no branch self._email = self._makeStringAttribute(attributes["email"]) if "events_url" in attributes: # pragma no branch self._events_url = self._makeStringAttribute(attributes["events_url"]) if "followers" in attributes: # pragma no branch self._followers = self._makeIntAttribute(attributes["followers"]) if "following" in attributes: # pragma no branch self._following = self._makeIntAttribute(attributes["following"]) if "gravatar_id" in attributes: # pragma no branch self._gravatar_id = self._makeStringAttribute(attributes["gravatar_id"]) if "has_organization_projects" in attributes: # pragma no branch self._has_organization_projects = self._makeBoolAttribute( attributes["has_organization_projects"] ) if "has_repository_projects" in attributes: # pragma no branch self._has_repository_projects = self._makeBoolAttribute( attributes["has_repository_projects"] ) if "hooks_url" in attributes: # pragma no branch self._hooks_url = self._makeStringAttribute(attributes["hooks_url"]) if "html_url" in attributes: # pragma no branch self._html_url = self._makeStringAttribute(attributes["html_url"]) if "id" in attributes: # pragma no branch self._id = self._makeIntAttribute(attributes["id"]) if "issues_url" in attributes: # pragma no branch self._issues_url = self._makeStringAttribute(attributes["issues_url"]) if "location" in attributes: # pragma no branch self._location = self._makeStringAttribute(attributes["location"]) if "login" in attributes: # pragma no branch self._login = self._makeStringAttribute(attributes["login"]) if "members_can_create_repositories" in attributes: # pragma no branch self._members_can_create_repositories = self._makeBoolAttribute( attributes["members_can_create_repositories"] ) if "members_url" in attributes: # pragma no branch self._members_url = self._makeStringAttribute(attributes["members_url"]) if "name" in attributes: # pragma no branch self._name = self._makeStringAttribute(attributes["name"]) if "owned_private_repos" in attributes: # pragma no branch self._owned_private_repos = self._makeIntAttribute( attributes["owned_private_repos"] ) if "plan" in attributes: # pragma no branch self._plan = self._makeClassAttribute(github.Plan.Plan, attributes["plan"]) if "private_gists" in attributes: # pragma no branch self._private_gists = self._makeIntAttribute(attributes["private_gists"]) if "public_gists" in attributes: # pragma no branch self._public_gists = self._makeIntAttribute(attributes["public_gists"]) if "public_members_url" in attributes: # pragma no branch self._public_members_url = self._makeStringAttribute( attributes["public_members_url"] ) if "public_repos" in attributes: # pragma no branch self._public_repos = self._makeIntAttribute(attributes["public_repos"]) if "repos_url" in attributes: # pragma no branch self._repos_url = self._makeStringAttribute(attributes["repos_url"]) if "total_private_repos" in attributes: # pragma no branch self._total_private_repos = self._makeIntAttribute( attributes["total_private_repos"] ) if "two_factor_requirement_enabled" in attributes: # pragma no branch self._two_factor_requirement_enabled = self._makeBoolAttribute( attributes["two_factor_requirement_enabled"] ) if "type" in attributes: # pragma no branch self._type = self._makeStringAttribute(attributes["type"]) if "updated_at" in attributes: # pragma no branch self._updated_at = self._makeDatetimeAttribute(attributes["updated_at"]) if "url" in attributes: # pragma no branch self._url = self._makeStringAttribute(attributes["url"]) ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1619412308.0 PyGithub-1.55/github/Organization.pyi0000644000175100001710000001655400000000000017223 0ustar00runnerdockerfrom datetime import datetime from typing import Any, Dict, List, Optional, Union from github.Event import Event from github.GithubObject import CompletableGithubObject, _NotSetType from github.Hook import Hook from github.Issue import Issue from github.Label import Label from github.Migration import Migration from github.Installation import Installation from github.NamedUser import NamedUser from github.PaginatedList import PaginatedList from github.Plan import Plan from github.Project import Project from github.Repository import Repository from github.Team import Team class Organization(CompletableGithubObject): def __repr__(self) -> str: ... def _initAttributes(self) -> None: ... def _useAttributes(self, attributes: Dict[str, Any]) -> None: ... def add_to_members( self, member: NamedUser, role: Union[_NotSetType, str] = ... ) -> None: ... def add_to_public_members(self, public_member: NamedUser) -> None: ... @property def avatar_url(self) -> str: ... @property def billing_email(self) -> str: ... @property def blog(self) -> Optional[str]: ... @property def collaborators(self) -> int: ... @property def company(self) -> Optional[str]: ... def convert_to_outside_collaborator(self, member: NamedUser) -> None: ... def create_fork(self, repo: Repository) -> Repository: ... def create_hook( self, name: str, config: Dict[str, str], events: Union[_NotSetType, List[str]] = ..., active: Union[bool, _NotSetType] = ..., ) -> Hook: ... def create_migration( self, repos: List[str], lock_repositories: Union[bool, _NotSetType] = ..., exclude_attachments: Union[bool, _NotSetType] = ..., ) -> Migration: ... def create_repo( self, name: str, description: Union[str, _NotSetType] = ..., homepage: Union[str, _NotSetType] = ..., private: Union[bool, _NotSetType] = ..., has_issues: Union[bool, _NotSetType] = ..., has_wiki: Union[bool, _NotSetType] = ..., has_downloads: Union[bool, _NotSetType] = ..., has_projects: Union[bool, _NotSetType] = ..., team_id: Union[int, _NotSetType] = ..., auto_init: Union[bool, _NotSetType] = ..., license_template: Union[str, _NotSetType] = ..., gitignore_template: Union[str, _NotSetType] = ..., allow_squash_merge: Union[bool, _NotSetType] = ..., allow_merge_commit: Union[bool, _NotSetType] = ..., allow_rebase_merge: Union[bool, _NotSetType] = ..., ) -> Repository: ... def create_team( self, name: str, repo_names: Union[List[Repository], _NotSetType] = ..., permission: Union[str, _NotSetType] = ..., privacy: Union[str, _NotSetType] = ..., description: Union[str, _NotSetType] = ..., ) -> Team: ... @property def created_at(self) -> datetime: ... def delete_hook(self, id: int) -> None: ... @property def default_repository_permission(self) -> str: ... @property def description(self) -> str: ... @property def disk_usage(self) -> int: ... def edit( self, billing_email: Union[str, _NotSetType] = ..., blog: Union[str, _NotSetType] = ..., company: Union[str, _NotSetType] = ..., description: Union[str, _NotSetType] = ..., email: Union[str, _NotSetType] = ..., location: Union[str, _NotSetType] = ..., name: Union[str, _NotSetType] = ..., ) -> None: ... def edit_hook( self, id: int, name: str, config: Dict[str, str], events: Union[_NotSetType, List[str]] = ..., active: Union[bool, _NotSetType] = ..., ) -> Hook: ... @property def email(self) -> Optional[str]: ... @property def events_url(self) -> str: ... @property def followers(self) -> int: ... @property def following(self) -> int: ... def get_events(self) -> PaginatedList[Event]: ... def get_hooks(self) -> PaginatedList[Hook]: ... def get_issues( self, filter: Union[str, _NotSetType] = ..., state: Union[str, _NotSetType] = ..., labels: Union[List[Label], _NotSetType] = ..., sort: Union[str, _NotSetType] = ..., direction: Union[str, _NotSetType] = ..., since: Union[_NotSetType, datetime] = ..., ) -> PaginatedList[Issue]: ... def get_members( self, filter_: Union[str, _NotSetType] = ..., role: Union[str, _NotSetType] = ..., ) -> PaginatedList[NamedUser]: ... def get_migrations(self) -> PaginatedList[Migration]: ... def get_installations(self) -> PaginatedList[Installation]: ... def get_outside_collaborators( self, filter_: Union[str, _NotSetType] = ... ) -> PaginatedList[NamedUser]: ... def get_projects( self, state: Union[_NotSetType, str] = ... ) -> PaginatedList[Project]: ... def get_public_members(self) -> PaginatedList[NamedUser]: ... def get_repo(self, name: str) -> Repository: ... def get_repos( self, type: Union[str, _NotSetType] = ..., sort: Union[str, _NotSetType] = ..., direction: Union[str, _NotSetType] = ..., ) -> PaginatedList[Repository]: ... def get_team(self, id: int) -> Team: ... def get_team_by_slug(self, slug: str) -> Team: ... def get_teams(self) -> PaginatedList[Team]: ... @property def gravatar_id(self) -> str: ... def has_in_members(self, member: NamedUser) -> bool: ... def has_in_public_members(self, public_member: NamedUser) -> bool: ... @property def has_organization_projects(self) -> bool: ... @property def has_repository_projects(self) -> bool: ... @property def hooks_url(self) -> str: ... @property def html_url(self) -> str: ... @property def id(self) -> int: ... @property def issues_url(self) -> str: ... def invitations(self) -> PaginatedList[NamedUser]: ... def invite_user( self, user: Union[_NotSetType, NamedUser] = ..., email: Union[str, _NotSetType] = ..., role: Union[str, _NotSetType] = ..., teams: Union[List[Team], _NotSetType] = ..., ) -> None: ... @property def location(self) -> str: ... @property def login(self) -> str: ... @property def members_can_create_repositories(self) -> bool: ... @property def members_url(self) -> str: ... @property def name(self) -> Optional[str]: ... @property def owned_private_repos(self) -> int: ... @property def plan(self) -> Plan: ... @property def private_gists(self) -> int: ... @property def public_gists(self) -> int: ... @property def public_members_url(self) -> str: ... @property def public_repos(self) -> int: ... def remove_from_members(self, member: NamedUser) -> None: ... def remove_from_membership(self, member: NamedUser) -> None: ... def remove_from_public_members(self, public_member: NamedUser) -> None: ... def remove_outside_collaborator(self, collaborator: NamedUser) -> None: ... @property def repos_url(self) -> str: ... @property def total_private_repos(self) -> int: ... @property def two_factor_requirement_enabled(self) -> bool: ... @property def type(self) -> str: ... @property def updated_at(self) -> datetime: ... @property def url(self) -> str: ... ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1619412308.0 PyGithub-1.55/github/PaginatedList.py0000644000175100001710000002321500000000000017126 0ustar00runnerdocker############################ Copyrights and license ############################ # # # Copyright 2012 Vincent Jacques # # Copyright 2012 Zearin # # Copyright 2013 AKFish # # Copyright 2013 Bill Mill # # Copyright 2013 Vincent Jacques # # Copyright 2013 davidbrai # # Copyright 2014 Thialfihar # # Copyright 2014 Vincent Jacques # # Copyright 2015 Dan Vanderkam # # Copyright 2015 Eliot Walker # # Copyright 2016 Peter Buckley # # Copyright 2017 Jannis Gebauer # # Copyright 2018 Gilad Shefer # # Copyright 2018 Joel Koglin # # Copyright 2018 Wan Liuyang # # Copyright 2018 sfdye # # # # This file is part of PyGithub. # # http://pygithub.readthedocs.io/ # # # # PyGithub is free software: you can redistribute it and/or modify it under # # the terms of the GNU Lesser General Public License as published by the Free # # Software Foundation, either version 3 of the License, or (at your option) # # any later version. # # # # PyGithub is distributed in the hope that it will be useful, but WITHOUT ANY # # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more # # details. # # # # You should have received a copy of the GNU Lesser General Public License # # along with PyGithub. If not, see . # # # ################################################################################ from urllib.parse import parse_qs class PaginatedListBase: def __init__(self): self.__elements = list() def __getitem__(self, index): assert isinstance(index, (int, slice)) if isinstance(index, int): self.__fetchToIndex(index) return self.__elements[index] else: return self._Slice(self, index) def __iter__(self): yield from self.__elements while self._couldGrow(): newElements = self._grow() yield from newElements def _isBiggerThan(self, index): return len(self.__elements) > index or self._couldGrow() def __fetchToIndex(self, index): while len(self.__elements) <= index and self._couldGrow(): self._grow() def _grow(self): newElements = self._fetchNextPage() self.__elements += newElements return newElements class _Slice: def __init__(self, theList, theSlice): self.__list = theList self.__start = theSlice.start or 0 self.__stop = theSlice.stop self.__step = theSlice.step or 1 def __iter__(self): index = self.__start while not self.__finished(index): if self.__list._isBiggerThan(index): yield self.__list[index] index += self.__step else: return def __finished(self, index): return self.__stop is not None and index >= self.__stop class PaginatedList(PaginatedListBase): """ This class abstracts the `pagination of the API `_. You can simply enumerate through instances of this class:: for repo in user.get_repos(): print(repo.name) If you want to know the total number of items in the list:: print(user.get_repos().totalCount) You can also index them or take slices:: second_repo = user.get_repos()[1] first_repos = user.get_repos()[:10] If you want to iterate in reversed order, just do:: for repo in user.get_repos().reversed: print(repo.name) And if you really need it, you can explicitly access a specific page:: some_repos = user.get_repos().get_page(0) some_other_repos = user.get_repos().get_page(3) """ def __init__( self, contentClass, requester, firstUrl, firstParams, headers=None, list_item="items", ): super().__init__() self.__requester = requester self.__contentClass = contentClass self.__firstUrl = firstUrl self.__firstParams = firstParams or () self.__nextUrl = firstUrl self.__nextParams = firstParams or {} self.__headers = headers self.__list_item = list_item if self.__requester.per_page != 30: self.__nextParams["per_page"] = self.__requester.per_page self._reversed = False self.__totalCount = None @property def totalCount(self): if not self.__totalCount: params = {} if self.__nextParams is None else self.__nextParams.copy() # set per_page = 1 so the totalCount is just the number of pages params.update({"per_page": 1}) headers, data = self.__requester.requestJsonAndCheck( "GET", self.__firstUrl, parameters=params, headers=self.__headers ) if "link" not in headers: if data and "total_count" in data: self.__totalCount = data["total_count"] elif data: self.__totalCount = len(data) else: self.__totalCount = 0 else: links = self.__parseLinkHeader(headers) lastUrl = links.get("last") if lastUrl: self.__totalCount = int(parse_qs(lastUrl)["page"][0]) else: self.__totalCount = 0 return self.__totalCount def _getLastPageUrl(self): headers, data = self.__requester.requestJsonAndCheck( "GET", self.__firstUrl, parameters=self.__nextParams, headers=self.__headers ) links = self.__parseLinkHeader(headers) lastUrl = links.get("last") return lastUrl @property def reversed(self): r = PaginatedList( self.__contentClass, self.__requester, self.__firstUrl, self.__firstParams, self.__headers, self.__list_item, ) r.__reverse() return r def __reverse(self): self._reversed = True lastUrl = self._getLastPageUrl() if lastUrl: self.__nextUrl = lastUrl def _couldGrow(self): return self.__nextUrl is not None def _fetchNextPage(self): headers, data = self.__requester.requestJsonAndCheck( "GET", self.__nextUrl, parameters=self.__nextParams, headers=self.__headers ) data = data if data else [] self.__nextUrl = None if len(data) > 0: links = self.__parseLinkHeader(headers) if self._reversed: if "prev" in links: self.__nextUrl = links["prev"] elif "next" in links: self.__nextUrl = links["next"] self.__nextParams = None if self.__list_item in data: self.__totalCount = data.get("total_count") data = data[self.__list_item] content = [ self.__contentClass(self.__requester, headers, element, completed=False) for element in data if element is not None ] if self._reversed: return content[::-1] return content def __parseLinkHeader(self, headers): links = {} if "link" in headers: linkHeaders = headers["link"].split(", ") for linkHeader in linkHeaders: url, rel, *rest = linkHeader.split("; ") url = url[1:-1] rel = rel[5:-1] links[rel] = url return links def get_page(self, page): params = dict(self.__firstParams) if page != 0: params["page"] = page + 1 if self.__requester.per_page != 30: params["per_page"] = self.__requester.per_page headers, data = self.__requester.requestJsonAndCheck( "GET", self.__firstUrl, parameters=params, headers=self.__headers ) if self.__list_item in data: self.__totalCount = data.get("total_count") data = data[self.__list_item] return [ self.__contentClass(self.__requester, headers, element, completed=False) for element in data ] ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1619412308.0 PyGithub-1.55/github/PaginatedList.pyi0000644000175100001710000000270600000000000017301 0ustar00runnerdockerfrom typing import Any, Dict, Generic, Iterator, List, Optional, Type, TypeVar, Union from github.ContentFile import ContentFile from github.GithubObject import GithubObject from github.Issue import Issue from github.NamedUser import NamedUser from github.Requester import Requester T = TypeVar("T", bound=GithubObject) class PaginatedListBase(Generic[T]): def __getitem__(self, index: Union[int, slice]) -> Any: ... def __init__(self) -> None: ... def __iter__(self) -> Iterator[T]: ... def _grow(self) -> Any: ... def _isBiggerThan(self, index: int) -> bool: ... class _Slice: def __init__(self, theList: PaginatedList[T], theSlice: slice) -> None: ... def __iter__(self) -> Iterator[T]: ... def __finished(self, index: int) -> bool: ... class PaginatedList(PaginatedListBase[T]): def __init__( self, contentClass: Type[T], requester: Requester, firstUrl: str, firstParams: Any, headers: Optional[Dict[str, str]] = ..., list_item: str = ..., ) -> None: ... def __reverse(self) -> None: ... def __parseLinkHeader(self, headers: Dict[str, str]) -> None: ... def _couldGrow(self) -> bool: ... def _fetchNextPage(self) -> Any: ... def _getLastPageUrl(self) -> Optional[str]: ... def get_page(self, page: int) -> List[Any]: ... @property def reversed(self) -> PaginatedList[T]: ... @property def totalCount(self) -> int: ... ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1619412308.0 PyGithub-1.55/github/Path.py0000644000175100001710000000733400000000000015276 0ustar00runnerdocker############################ Copyrights and license ############################ # # # Copyright 2018 Justin Kufro # # Copyright 2018 Ivan Minno # # Copyright 2018 Zilei Gu # # Copyright 2018 Yves Zumbach # # Copyright 2018 Leying Chen # # # # This file is part of PyGithub. # # http://pygithub.readthedocs.io/ # # # # PyGithub is free software: you can redistribute it and/or modify it under # # the terms of the GNU Lesser General Public License as published by the Free # # Software Foundation, either version 3 of the License, or (at your option) # # any later version. # # # # PyGithub is distributed in the hope that it will be useful, but WITHOUT ANY # # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more # # details. # # # # You should have received a copy of the GNU Lesser General Public License # # along with PyGithub. If not, see . # # # ################################################################################ import github.GithubObject class Path(github.GithubObject.NonCompletableGithubObject): """ This class represents a popular Path for a GitHub repository. The reference can be found here https://docs.github.com/en/rest/reference/repos#traffic """ def __repr__(self): return self.get__repr__( { "path": self._path.value, "title": self._title.value, "count": self._count.value, "uniques": self._uniques.value, } ) @property def path(self): """ :type: string """ return self._path.value @property def title(self): """ :type: string """ return self._title.value @property def count(self): """ :type: integer """ return self._count.value @property def uniques(self): """ :type: integer """ return self._uniques.value def _initAttributes(self): self._path = github.GithubObject.NotSet self._title = github.GithubObject.NotSet self._count = github.GithubObject.NotSet self._uniques = github.GithubObject.NotSet def _useAttributes(self, attributes): if "path" in attributes: # pragma no branch self._path = self._makeStringAttribute(attributes["path"]) if "title" in attributes: # pragma no branch self._title = self._makeStringAttribute(attributes["title"]) if "count" in attributes: # pragma no branch self._count = self._makeIntAttribute(attributes["count"]) if "uniques" in attributes: # pragma no branch self._uniques = self._makeIntAttribute(attributes["uniques"]) ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1619412308.0 PyGithub-1.55/github/Path.pyi0000644000175100001710000000071700000000000015445 0ustar00runnerdockerfrom typing import Any, Dict from github.GithubObject import NonCompletableGithubObject class Path(NonCompletableGithubObject): def __repr__(self) -> str: ... def _initAttributes(self) -> None: ... def _useAttributes(self, attributes: Dict[str, Any]) -> None: ... @property def count(self) -> int: ... @property def path(self) -> str: ... @property def title(self) -> str: ... @property def uniques(self) -> int: ... ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1619412308.0 PyGithub-1.55/github/Permissions.py0000644000175100001710000001036600000000000016714 0ustar00runnerdocker############################ Copyrights and license ############################ # # # Copyright 2012 Vincent Jacques # # Copyright 2012 Zearin # # Copyright 2013 AKFish # # Copyright 2013 Vincent Jacques # # Copyright 2014 Vincent Jacques # # Copyright 2016 Jannis Gebauer # # Copyright 2016 Peter Buckley # # Copyright 2018 Wan Liuyang # # Copyright 2018 sfdye # # # # This file is part of PyGithub. # # http://pygithub.readthedocs.io/ # # # # PyGithub is free software: you can redistribute it and/or modify it under # # the terms of the GNU Lesser General Public License as published by the Free # # Software Foundation, either version 3 of the License, or (at your option) # # any later version. # # # # PyGithub is distributed in the hope that it will be useful, but WITHOUT ANY # # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more # # details. # # # # You should have received a copy of the GNU Lesser General Public License # # along with PyGithub. If not, see . # # # ################################################################################ import github.GithubObject class Permissions(github.GithubObject.NonCompletableGithubObject): """ This class represents Permissions """ def __repr__(self): return self.get__repr__( { "admin": self._admin.value, "maintain": self._maintain.value, "pull": self._pull.value, "push": self._push.value, "triage": self._triage.value, } ) @property def admin(self): """ :type: bool """ return self._admin.value @property def maintain(self): """ :type: bool """ return self._maintain.value @property def pull(self): """ :type: bool """ return self._pull.value @property def push(self): """ :type: bool """ return self._push.value @property def triage(self): """ :type: bool """ return self._triage.value def _initAttributes(self): self._admin = github.GithubObject.NotSet self._maintain = github.GithubObject.NotSet self._pull = github.GithubObject.NotSet self._push = github.GithubObject.NotSet self._triage = github.GithubObject.NotSet def _useAttributes(self, attributes): if "admin" in attributes: # pragma no branch self._admin = self._makeBoolAttribute(attributes["admin"]) if "maintain" in attributes: # pragma no branch self._maintain = self._makeBoolAttribute(attributes["maintain"]) if "pull" in attributes: # pragma no branch self._pull = self._makeBoolAttribute(attributes["pull"]) if "push" in attributes: # pragma no branch self._push = self._makeBoolAttribute(attributes["push"]) if "triage" in attributes: # pragma no branch self._triage = self._makeBoolAttribute(attributes["triage"]) ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1619412308.0 PyGithub-1.55/github/Permissions.pyi0000644000175100001710000000101200000000000017051 0ustar00runnerdockerfrom typing import Any, Dict from github.GithubObject import NonCompletableGithubObject class Permissions(NonCompletableGithubObject): def __repr__(self) -> str: ... def _initAttributes(self) -> None: ... def _useAttributes(self, attributes: Dict[str, Any]) -> None: ... @property def admin(self) -> bool: ... @property def maintain(self) -> bool: ... @property def pull(self) -> bool: ... @property def push(self) -> bool: ... @property def triage(self) -> bool: ... ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1619412308.0 PyGithub-1.55/github/Plan.py0000644000175100001710000001064300000000000015271 0ustar00runnerdocker############################ Copyrights and license ############################ # # # Copyright 2012 Vincent Jacques # # Copyright 2012 Zearin # # Copyright 2013 AKFish # # Copyright 2013 Vincent Jacques # # Copyright 2014 Vincent Jacques # # Copyright 2016 Jannis Gebauer # # Copyright 2016 Peter Buckley # # Copyright 2018 Wan Liuyang # # Copyright 2018 sfdye # # # # This file is part of PyGithub. # # http://pygithub.readthedocs.io/ # # # # PyGithub is free software: you can redistribute it and/or modify it under # # the terms of the GNU Lesser General Public License as published by the Free # # Software Foundation, either version 3 of the License, or (at your option) # # any later version. # # # # PyGithub is distributed in the hope that it will be useful, but WITHOUT ANY # # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more # # details. # # # # You should have received a copy of the GNU Lesser General Public License # # along with PyGithub. If not, see . # # # ################################################################################ import github.GithubObject class Plan(github.GithubObject.NonCompletableGithubObject): """ This class represents Plans """ def __repr__(self): return self.get__repr__({"name": self._name.value}) @property def collaborators(self): """ :type: integer """ return self._collaborators.value @property def name(self): """ :type: string """ return self._name.value @property def private_repos(self): """ :type: integer """ return self._private_repos.value @property def space(self): """ :type: integer """ return self._space.value @property def filled_seats(self): """ :type: integer """ return self._filled_seats.value @property def seats(self): """ :type: integer """ return self._seats.value def _initAttributes(self): self._collaborators = github.GithubObject.NotSet self._name = github.GithubObject.NotSet self._private_repos = github.GithubObject.NotSet self._space = github.GithubObject.NotSet self._filled_seats = github.GithubObject.NotSet self._seats = github.GithubObject.NotSet def _useAttributes(self, attributes): if "collaborators" in attributes: # pragma no branch self._collaborators = self._makeIntAttribute(attributes["collaborators"]) if "name" in attributes: # pragma no branch self._name = self._makeStringAttribute(attributes["name"]) if "private_repos" in attributes: # pragma no branch self._private_repos = self._makeIntAttribute(attributes["private_repos"]) if "space" in attributes: # pragma no branch self._space = self._makeIntAttribute(attributes["space"]) if "seats" in attributes: # pragma no branch self._seats = self._makeIntAttribute(attributes["seats"]) if "filled_seats" in attributes: # pragma no branch self._filled_seats = self._makeIntAttribute(attributes["filled_seats"]) ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1619412308.0 PyGithub-1.55/github/Plan.pyi0000644000175100001710000000074400000000000015443 0ustar00runnerdockerfrom typing import Any, Dict, Union from github.GithubObject import NonCompletableGithubObject class Plan(NonCompletableGithubObject): def __repr__(self) -> str: ... def _initAttributes(self) -> None: ... def _useAttributes(self, attributes: Dict[str, Any]) -> None: ... @property def collaborators(self) -> int: ... @property def name(self) -> str: ... @property def private_repos(self) -> int: ... @property def space(self) -> int: ... ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1619412308.0 PyGithub-1.55/github/Project.py0000644000175100001710000002375200000000000016012 0ustar00runnerdocker############################ Copyrights and license ############################ # # # Copyright 2018 bbi-yggy # # # # This file is part of PyGithub. # # http://pygithub.readthedocs.io/ # # # # PyGithub is free software: you can redistribute it and/or modify it under # # the terms of the GNU Lesser General Public License as published by the Free # # Software Foundation, either version 3 of the License, or (at your option) # # any later version. # # # # PyGithub is distributed in the hope that it will be useful, but WITHOUT ANY # # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more # # details. # # # # You should have received a copy of the GNU Lesser General Public License # # along with PyGithub. If not, see . # # # ################################################################################ import github.GithubObject import github.ProjectColumn from . import Consts class Project(github.GithubObject.CompletableGithubObject): """ This class represents Projects. The reference can be found here http://docs.github.com/en/rest/reference/projects """ def __repr__(self): return self.get__repr__({"name": self._name.value}) @property def body(self): """ :type: string """ self._completeIfNotSet(self._body) return self._body.value @property def columns_url(self): """ :type: string """ self._completeIfNotSet(self._columns_url) return self._columns_url.value @property def created_at(self): """ :type: datetime.datetime """ self._completeIfNotSet(self._created_at) return self._created_at.value @property def creator(self): """ :type: :class:`github.NamedUser.NamedUser` """ self._completeIfNotSet(self._creator) return self._creator.value @property def html_url(self): """ :type: string """ self._completeIfNotSet(self._html_url) return self._html_url.value @property def id(self): """ :type: integer """ self._completeIfNotSet(self._id) return self._id.value @property def name(self): """ :type: string """ self._completeIfNotSet(self._name) return self._name.value @property def node_id(self): """ :type: string """ self._completeIfNotSet(self._node_id) return self._node_id.value @property def number(self): """ :type: integer """ self._completeIfNotSet(self._number) return self._number.value @property def owner_url(self): """ :type: string """ self._completeIfNotSet(self._owner_url) return self._owner_url.value @property def state(self): """ :type: string """ self._completeIfNotSet(self._state) return self._state.value @property def updated_at(self): """ :type: datetime.datetime """ self._completeIfNotSet(self._updated_at) return self._updated_at.value @property def url(self): """ :type: string """ self._completeIfNotSet(self._url) return self._url.value def delete(self): """ :calls: `DELETE /projects/{project_id} `_ :rtype: None """ headers, data = self._requester.requestJsonAndCheck( "DELETE", self.url, headers={"Accept": Consts.mediaTypeProjectsPreview} ) def edit( self, name=github.GithubObject.NotSet, body=github.GithubObject.NotSet, state=github.GithubObject.NotSet, organization_permission=github.GithubObject.NotSet, private=github.GithubObject.NotSet, ): """ :calls: `PATCH /projects/{project_id} `_ :param name: string :param body: string :param state: string :param organization_permission: string :param private: bool :rtype: None """ assert name is github.GithubObject.NotSet or isinstance(name, str), name assert body is github.GithubObject.NotSet or isinstance(body, str), body assert state is github.GithubObject.NotSet or isinstance(state, str), state assert organization_permission is github.GithubObject.NotSet or isinstance( organization_permission, str ), organization_permission assert private is github.GithubObject.NotSet or isinstance( private, bool ), private patch_parameters = dict() if name is not github.GithubObject.NotSet: patch_parameters["name"] = name if body is not github.GithubObject.NotSet: patch_parameters["body"] = body if state is not github.GithubObject.NotSet: patch_parameters["state"] = state if organization_permission is not github.GithubObject.NotSet: patch_parameters["organization_permission"] = organization_permission if private is not github.GithubObject.NotSet: patch_parameters["private"] = private headers, data = self._requester.requestJsonAndCheck( "PATCH", self.url, input=patch_parameters, headers={"Accept": Consts.mediaTypeProjectsPreview}, ) self._useAttributes(data) def get_columns(self): """ :calls: `GET /projects/{project_id}/columns `_ :rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.ProjectColumn.ProjectColumn` """ return github.PaginatedList.PaginatedList( github.ProjectColumn.ProjectColumn, self._requester, self.columns_url, None, {"Accept": Consts.mediaTypeProjectsPreview}, ) def create_column(self, name): """ calls: `POST /projects/{project_id}/columns `_ :param name: string """ assert isinstance(name, str), name post_parameters = {"name": name} import_header = {"Accept": Consts.mediaTypeProjectsPreview} headers, data = self._requester.requestJsonAndCheck( "POST", f"{self.url}/columns", headers=import_header, input=post_parameters ) return github.ProjectColumn.ProjectColumn( self._requester, headers, data, completed=True ) def _initAttributes(self): self._body = github.GithubObject.NotSet self._columns_url = github.GithubObject.NotSet self._created_at = github.GithubObject.NotSet self._creator = github.GithubObject.NotSet self._html_url = github.GithubObject.NotSet self._id = github.GithubObject.NotSet self._name = github.GithubObject.NotSet self._node_id = github.GithubObject.NotSet self._number = github.GithubObject.NotSet self._owner_url = github.GithubObject.NotSet self._state = github.GithubObject.NotSet self._updated_at = github.GithubObject.NotSet self._url = github.GithubObject.NotSet def _useAttributes(self, attributes): if "body" in attributes: # pragma no branch self._body = self._makeStringAttribute(attributes["body"]) if "columns_url" in attributes: # pragma no branch self._columns_url = self._makeStringAttribute(attributes["columns_url"]) if "created_at" in attributes: # pragma no branch self._created_at = self._makeDatetimeAttribute(attributes["created_at"]) if "creator" in attributes: # pragma no branch self._creator = self._makeClassAttribute( github.NamedUser.NamedUser, attributes["creator"] ) if "html_url" in attributes: # pragma no branch self._html_url = self._makeStringAttribute(attributes["html_url"]) if "id" in attributes: # pragma no branch self._id = self._makeIntAttribute(attributes["id"]) if "name" in attributes: # pragma no branch self._name = self._makeStringAttribute(attributes["name"]) if "node_id" in attributes: # pragma no branch self._node_id = self._makeStringAttribute(attributes["node_id"]) if "number" in attributes: # pragma no branch self._number = self._makeIntAttribute(attributes["number"]) if "owner_url" in attributes: # pragma no branch self._owner_url = self._makeStringAttribute(attributes["owner_url"]) if "state" in attributes: # pragma no branch self._state = self._makeStringAttribute(attributes["state"]) if "updated_at" in attributes: # pragma no branch self._updated_at = self._makeDatetimeAttribute(attributes["updated_at"]) if "url" in attributes: # pragma no branch self._url = self._makeStringAttribute(attributes["url"]) ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1619412308.0 PyGithub-1.55/github/Project.pyi0000644000175100001710000000225500000000000016156 0ustar00runnerdockerfrom datetime import datetime from typing import Any, Dict from github.GithubObject import CompletableGithubObject from github.NamedUser import NamedUser from github.PaginatedList import PaginatedList from github.ProjectColumn import ProjectColumn class Project(CompletableGithubObject): def __repr__(self) -> str: ... def _initAttributes(self) -> None: ... def _useAttributes(self, attributes: Dict[str, Any]) -> None: ... @property def body(self) -> str: ... @property def columns_url(self) -> str: ... def create_column(self, name: str) -> ProjectColumn: ... @property def created_at(self) -> datetime: ... @property def creator(self) -> NamedUser: ... def get_columns(self) -> PaginatedList[ProjectColumn]: ... @property def html_url(self) -> str: ... @property def id(self) -> int: ... @property def name(self) -> str: ... @property def node_id(self) -> str: ... @property def number(self) -> int: ... @property def owner_url(self) -> str: ... @property def state(self) -> str: ... @property def updated_at(self) -> datetime: ... @property def url(self) -> str: ... ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1619412308.0 PyGithub-1.55/github/ProjectCard.py0000644000175100001710000002212500000000000016575 0ustar00runnerdocker############################ Copyrights and license ############################ # # # Copyright 2018 bbi-yggy # # # # This file is part of PyGithub. # # http://pygithub.readthedocs.io/ # # # # PyGithub is free software: you can redistribute it and/or modify it under # # the terms of the GNU Lesser General Public License as published by the Free # # Software Foundation, either version 3 of the License, or (at your option) # # any later version. # # # # PyGithub is distributed in the hope that it will be useful, but WITHOUT ANY # # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more # # details. # # # # You should have received a copy of the GNU Lesser General Public License # # along with PyGithub. If not, see . # # # ################################################################################ import github.GithubObject from . import Consts # NOTE: There is currently no way to get cards "in triage" for a project. # https://platform.github.community/t/moving-github-project-cards-that-are-in-triage/3784 # # See also https://developer.github.com/v4/object/projectcard for the next generation GitHub API, # which may point the way to where the API is likely headed and what might come back to v3. E.g. ProjectCard.content member. class ProjectCard(github.GithubObject.CompletableGithubObject): """ This class represents Project Cards. The reference can be found here https://docs.github.com/en/rest/reference/projects#cards """ def __repr__(self): return self.get__repr__({"id": self._id.value}) @property def archived(self): """ :type: bool """ return self._archived.value @property def column_url(self): """ :type: string """ return self._column_url.value @property def content_url(self): """ :type: string """ return self._content_url.value @property def created_at(self): """ :type: datetime.datetime """ return self._created_at.value @property def creator(self): """ :type: :class:`github.NamedUser.NamedUser` """ return self._creator.value @property def id(self): """ :type: integer """ return self._id.value @property def node_id(self): """ :type: string """ return self._node_id.value @property def note(self): """ :type: string """ return self._note.value @property def updated_at(self): """ :type: datetime.datetime """ return self._updated_at.value @property def url(self): """ :type: string """ return self._url.value # Note that the content_url for any card will be an "issue" URL, from # which you can retrieve either an Issue or a PullRequest. Unfortunately # the API doesn't make it clear which you are dealing with. def get_content(self, content_type=github.GithubObject.NotSet): """ :calls: `GET /repos/{owner}/{repo}/pulls/{number} `_ :param content_type: string, optional :rtype: :class:`github.PullRequest.PullRequest` or :class:`github.Issue.Issue` """ assert content_type is github.GithubObject.NotSet or isinstance( content_type, str ), content_type if self.content_url is None: return None if content_type == "PullRequest": url = self.content_url.replace("issues", "pulls") retclass = github.PullRequest.PullRequest elif content_type is github.GithubObject.NotSet or content_type == "Issue": url = self.content_url retclass = github.Issue.Issue else: raise ValueError(f"Unknown content type: {content_type}") headers, data = self._requester.requestJsonAndCheck("GET", url) return retclass(self._requester, headers, data, completed=True) def move(self, position, column): """ :calls: `POST /projects/columns/cards/{card_id}/moves `_ :param position: string :param column: :class:`github.ProjectColumn.ProjectColumn` or int :rtype: bool """ assert isinstance(position, str), position assert isinstance(column, github.ProjectColumn.ProjectColumn) or isinstance( column, int ), column post_parameters = { "position": position, "column_id": column.id if isinstance(column, github.ProjectColumn.ProjectColumn) else column, } status, _, _ = self._requester.requestJson( "POST", f"{self.url}/moves", input=post_parameters, headers={"Accept": Consts.mediaTypeProjectsPreview}, ) return status == 201 def delete(self): """ :calls: `DELETE /projects/columns/cards/{card_id} `_ :rtype: bool """ status, _, _ = self._requester.requestJson( "DELETE", self.url, headers={"Accept": Consts.mediaTypeProjectsPreview}, ) return status == 204 def edit( self, note=github.GithubObject.NotSet, archived=github.GithubObject.NotSet ): """ :calls: `PATCH /projects/columns/cards/{card_id} `_ :param note: string :param archived: bool :rtype: None """ assert note is github.GithubObject.NotSet or isinstance(note, str), note assert archived is github.GithubObject.NotSet or isinstance( archived, bool ), archived patch_parameters = dict() if note is not github.GithubObject.NotSet: patch_parameters["note"] = note if archived is not github.GithubObject.NotSet: patch_parameters["archived"] = archived headers, data = self._requester.requestJsonAndCheck( "PATCH", self.url, input=patch_parameters, headers={"Accept": Consts.mediaTypeProjectsPreview}, ) self._useAttributes(data) def _initAttributes(self): self._archived = github.GithubObject.NotSet self._column_url = github.GithubObject.NotSet self._content_url = github.GithubObject.NotSet self._created_at = github.GithubObject.NotSet self._creator = github.GithubObject.NotSet self._id = github.GithubObject.NotSet self._node_id = github.GithubObject.NotSet self._note = github.GithubObject.NotSet self._updated_at = github.GithubObject.NotSet self._url = github.GithubObject.NotSet def _useAttributes(self, attributes): if "archived" in attributes: # pragma no branch self._archived = self._makeBoolAttribute(attributes["archived"]) if "column_url" in attributes: # pragma no branch self._column_url = self._makeStringAttribute(attributes["column_url"]) if "content_url" in attributes: # pragma no branch self._content_url = self._makeStringAttribute(attributes["content_url"]) if "created_at" in attributes: # pragma no branch self._created_at = self._makeDatetimeAttribute(attributes["created_at"]) if "creator" in attributes: # pragma no branch self._creator = self._makeClassAttribute( github.NamedUser.NamedUser, attributes["creator"] ) if "id" in attributes: # pragma no branch self._id = self._makeIntAttribute(attributes["id"]) if "node_id" in attributes: # pragma no branch self._node_id = self._makeStringAttribute(attributes["node_id"]) if "note" in attributes: # pragma no branch self._note = self._makeStringAttribute(attributes["note"]) if "updated_at" in attributes: # pragma no branch self._updated_at = self._makeDatetimeAttribute(attributes["updated_at"]) if "url" in attributes: # pragma no branch self._url = self._makeStringAttribute(attributes["url"]) ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1619412308.0 PyGithub-1.55/github/ProjectCard.pyi0000644000175100001710000000210100000000000016736 0ustar00runnerdockerfrom datetime import datetime from typing import Any, Dict, Optional, Union from github.GithubObject import CompletableGithubObject, _NotSetType from github.Issue import Issue from github.NamedUser import NamedUser from github.PullRequest import PullRequest class ProjectCard(CompletableGithubObject): def _repr__(self) -> str: ... def _initAttributes(self) -> None: ... def _useAttributes(self, attributes: Dict[str, Any]) -> None: ... @property def archived(self) -> bool: ... @property def column_url(self) -> str: ... @property def content_url(self) -> Optional[str]: ... @property def created_at(self) -> datetime: ... @property def creator(self) -> NamedUser: ... def get_content( self, content_type: Union[_NotSetType, str] = ... ) -> Optional[Union[PullRequest, Issue]]: ... @property def id(self) -> int: ... @property def node_id(self) -> str: ... @property def note(self) -> str: ... @property def updated_at(self) -> datetime: ... @property def url(self) -> str: ... ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1619412308.0 PyGithub-1.55/github/ProjectColumn.py0000644000175100001710000002043500000000000017163 0ustar00runnerdocker############################ Copyrights and license ############################ # # # Copyright 2018 bbi-yggy # # # # This file is part of PyGithub. # # http://pygithub.readthedocs.io/ # # # # PyGithub is free software: you can redistribute it and/or modify it under # # the terms of the GNU Lesser General Public License as published by the Free # # Software Foundation, either version 3 of the License, or (at your option) # # any later version. # # # # PyGithub is distributed in the hope that it will be useful, but WITHOUT ANY # # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more # # details. # # # # You should have received a copy of the GNU Lesser General Public License # # along with PyGithub. If not, see . # # # ################################################################################ import github.GithubObject import github.Project import github.ProjectCard from . import Consts class ProjectColumn(github.GithubObject.CompletableGithubObject): """ This class represents Project Columns. The reference can be found here http://docs.github.com/en/rest/reference/projects#columns """ def __repr__(self): return self.get__repr__({"name": self._name.value}) @property def cards_url(self): """ :type: string """ return self._cards_url.value @property def created_at(self): """ :type: datetime.datetime """ return self._created_at.value @property def id(self): """ :type: integer """ return self._id.value @property def name(self): """ :type: string """ return self._name.value @property def node_id(self): """ :type: string """ return self._node_id.value @property def project_url(self): """ :type: string """ return self._project_url.value @property def updated_at(self): """ :type: datetime.datetime """ return self._updated_at.value @property def url(self): """ :type: string """ return self._url.value def get_cards(self, archived_state=github.GithubObject.NotSet): """ :calls: `GET /projects/columns/{column_id}/cards `_ :rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.ProjectCard.ProjectCard` :param archived_state: string """ assert archived_state is github.GithubObject.NotSet or isinstance( archived_state, str ), archived_state url_parameters = dict() if archived_state is not github.GithubObject.NotSet: url_parameters["archived_state"] = archived_state return github.PaginatedList.PaginatedList( github.ProjectCard.ProjectCard, self._requester, f"{self.url}/cards", url_parameters, {"Accept": Consts.mediaTypeProjectsPreview}, ) def create_card( self, note=github.GithubObject.NotSet, content_id=github.GithubObject.NotSet, content_type=github.GithubObject.NotSet, ): """ :calls: `POST /projects/columns/{column_id}/cards `_ :param note: string :param content_id: integer :param content_type: string :rtype: :class:`github.ProjectCard.ProjectCard`: """ if isinstance(note, str): assert content_id is github.GithubObject.NotSet, content_id assert content_type is github.GithubObject.NotSet, content_type post_parameters = {"note": note} else: assert note is github.GithubObject.NotSet, note assert isinstance(content_id, int), content_id assert isinstance(content_type, str), content_type post_parameters = {"content_id": content_id, "content_type": content_type} import_header = {"Accept": Consts.mediaTypeProjectsPreview} headers, data = self._requester.requestJsonAndCheck( "POST", f"{self.url}/cards", headers=import_header, input=post_parameters ) return github.ProjectCard.ProjectCard( self._requester, headers, data, completed=True ) def move(self, position): """ :calls: `POST POST /projects/columns/{column_id}/moves `_ :param position: string :rtype: bool """ assert isinstance(position, str), position post_parameters = {"position": position} status, _, _ = self._requester.requestJson( "POST", f"{self.url}/moves", input=post_parameters, headers={"Accept": Consts.mediaTypeProjectsPreview}, ) return status == 201 def delete(self): """ :calls: `DELETE /projects/columns/{column_id} `_ :rtype: bool """ status, _, _ = self._requester.requestJson( "DELETE", self.url, headers={"Accept": Consts.mediaTypeProjectsPreview}, ) return status == 204 def edit(self, name): """ :calls: `PATCH /projects/columns/{column_id} `_ :param name: string :rtype: None """ assert isinstance(name, str), name patch_parameters = {"name": name} headers, data = self._requester.requestJsonAndCheck( "PATCH", self.url, input=patch_parameters, headers={"Accept": Consts.mediaTypeProjectsPreview}, ) self._useAttributes(data) def _initAttributes(self): self._cards_url = github.GithubObject.NotSet self._created_at = github.GithubObject.NotSet self._id = github.GithubObject.NotSet self._name = github.GithubObject.NotSet self._node_id = github.GithubObject.NotSet self._project_url = github.GithubObject.NotSet self._updated_at = github.GithubObject.NotSet self._url = github.GithubObject.NotSet def _useAttributes(self, attributes): if "cards_url" in attributes: # pragma no branch self._cards_url = self._makeStringAttribute(attributes["cards_url"]) if "created_at" in attributes: # pragma no branch self._created_at = self._makeDatetimeAttribute(attributes["created_at"]) if "id" in attributes: # pragma no branch self._id = self._makeIntAttribute(attributes["id"]) if "name" in attributes: # pragma no branch self._name = self._makeStringAttribute(attributes["name"]) if "node_id" in attributes: # pragma no branch self._node_id = self._makeStringAttribute(attributes["node_id"]) if "project_url" in attributes: # pragma no branch self._project_url = self._makeStringAttribute(attributes["project_url"]) if "updated_at" in attributes: # pragma no branch self._updated_at = self._makeDatetimeAttribute(attributes["updated_at"]) if "url" in attributes: # pragma no branch self._url = self._makeStringAttribute(attributes["url"]) ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1619412308.0 PyGithub-1.55/github/ProjectColumn.pyi0000644000175100001710000000236600000000000017337 0ustar00runnerdockerfrom datetime import datetime from typing import Any, Dict, Union from github.GithubObject import CompletableGithubObject, _NotSetType from github.PaginatedList import PaginatedList from github.ProjectCard import ProjectCard class ProjectColumn(CompletableGithubObject): def __repr__(self) -> str: ... def _initAttributes(self) -> None: ... def _useAttributes(self, attributes: Dict[str, Any]) -> None: ... @property def cards_url(self) -> str: ... def create_card( self, note: Union[_NotSetType, str] = ..., content_id: Union[int, _NotSetType] = ..., content_type: Union[_NotSetType, str] = ..., ) -> ProjectCard: ... @property def created_at(self) -> datetime: ... def get_cards( self, archived_state: Union[_NotSetType, str] = ... ) -> PaginatedList[ProjectCard]: ... @property def id(self) -> int: ... @property def name(self) -> str: ... @property def node_id(self) -> str: ... @property def project_url(self) -> str: ... @property def updated_at(self) -> datetime: ... @property def url(self) -> str: ... def move(self, position: str) -> bool: ... def delete(self) -> bool: ... def edit(self, name: str) -> None: ... ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1619412308.0 PyGithub-1.55/github/PublicKey.py0000644000175100001710000001043400000000000016264 0ustar00runnerdocker############################ Copyrights and license ############################ # # # Copyright 2012 Vincent Jacques # # Copyright 2012 Zearin # # Copyright 2013 AKFish # # Copyright 2013 Vincent Jacques # # Copyright 2014 Vincent Jacques # # Copyright 2016 Jannis Gebauer # # Copyright 2016 Peter Buckley # # Copyright 2018 Wan Liuyang # # Copyright 2018 sfdye # # # # This file is part of PyGithub. # # http://pygithub.readthedocs.io/ # # # # PyGithub is free software: you can redistribute it and/or modify it under # # the terms of the GNU Lesser General Public License as published by the Free # # Software Foundation, either version 3 of the License, or (at your option) # # any later version. # # # # PyGithub is distributed in the hope that it will be useful, but WITHOUT ANY # # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more # # details. # # # # You should have received a copy of the GNU Lesser General Public License # # along with PyGithub. If not, see . # # # ################################################################################ # https://docs.github.com/en/rest/reference/actions#example-encrypting-a-secret-using-python from base64 import b64encode from nacl import encoding, public import github.GithubObject def encrypt(public_key: str, secret_value: str) -> str: """Encrypt a Unicode string using the public key.""" public_key = public.PublicKey(public_key.encode("utf-8"), encoding.Base64Encoder()) sealed_box = public.SealedBox(public_key) encrypted = sealed_box.encrypt(secret_value.encode("utf-8")) return b64encode(encrypted).decode("utf-8") class PublicKey(github.GithubObject.CompletableGithubObject): """ This class represents either an organization public key or a repository public key. The reference can be found here https://docs.github.com/en/rest/reference/actions#get-an-organization-public-key or here https://docs.github.com/en/rest/reference/actions#get-a-repository-public-key """ def __repr__(self): return self.get__repr__({"key_id": self._key_id.value, "key": self._key.value}) @property def key(self): """ :type: string """ self._completeIfNotSet(self._key) return self._key.value @property def key_id(self): """ :type: string or int """ self._completeIfNotSet(self._key_id) return self._key_id.value def _initAttributes(self): self._key = github.GithubObject.NotSet self._key_id = github.GithubObject.NotSet def _useAttributes(self, attributes): if "key" in attributes: # pragma no branch self._key = self._makeStringAttribute(attributes["key"]) if "key_id" in attributes: # pragma no branch if type(attributes["key_id"]) == str: self._key_id = self._makeStringAttribute(attributes["key_id"]) else: self._key_id = self._makeIntAttribute(attributes["key_id"]) def encrypt(self, unencrypted_value): return encrypt(self._key.value, unencrypted_value) ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1619412308.0 PyGithub-1.55/github/PublicKey.pyi0000644000175100001710000000067500000000000016443 0ustar00runnerdockerfrom typing import Any, Dict, Union from github.GithubObject import CompletableGithubObject class PublicKey(CompletableGithubObject): def __repr__(self) -> str: ... def _initAttributes(self) -> None: ... def _useAttributes(self, attributes: Dict[str, Any]) -> None: ... @property def key_id(self) -> Union[str, int]: ... @property def key(self) -> str: ... def encrypt(self, unencrypted_value: str) -> str: ... ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1619412308.0 PyGithub-1.55/github/PullRequest.py0000644000175100001710000012511100000000000016661 0ustar00runnerdocker############################ Copyrights and license ############################ # # # Copyright 2012 Michael Stead # # Copyright 2012 Vincent Jacques # # Copyright 2012 Zearin # # Copyright 2013 AKFish # # Copyright 2013 Vincent Jacques # # Copyright 2013 martinqt # # Copyright 2014 Vincent Jacques # # Copyright 2016 @tmshn # # Copyright 2016 Jannis Gebauer # # Copyright 2016 Peter Buckley # # Copyright 2017 Aaron Levine # # Copyright 2017 Simon # # Copyright 2018 Ben Yohay # # Copyright 2018 Gilad Shefer # # Copyright 2018 Martin Monperrus # # Copyright 2018 Matt Babineau <9685860+babineaum@users.noreply.github.com> # # Copyright 2018 Shinichi TAMURA # # Copyright 2018 Steve Kowalik # # Copyright 2018 Thibault Jamet # # Copyright 2018 per1234 # # Copyright 2018 sfdye # # # # This file is part of PyGithub. # # http://pygithub.readthedocs.io/ # # # # PyGithub is free software: you can redistribute it and/or modify it under # # the terms of the GNU Lesser General Public License as published by the Free # # Software Foundation, either version 3 of the License, or (at your option) # # any later version. # # # # PyGithub is distributed in the hope that it will be useful, but WITHOUT ANY # # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more # # details. # # # # You should have received a copy of the GNU Lesser General Public License # # along with PyGithub. If not, see . # # # ################################################################################ import datetime import urllib.parse import github.Commit import github.File import github.GithubObject import github.IssueComment import github.NamedUser import github.PaginatedList import github.PullRequestComment import github.PullRequestMergeStatus import github.PullRequestPart import github.PullRequestReview from . import Consts class PullRequest(github.GithubObject.CompletableGithubObject): """ This class represents PullRequests. The reference can be found here http://docs.github.com/en/rest/reference/pulls """ def __repr__(self): return self.get__repr__( {"number": self._number.value, "title": self._title.value} ) @property def additions(self): """ :type: integer """ self._completeIfNotSet(self._additions) return self._additions.value @property def assignee(self): """ :type: :class:`github.NamedUser.NamedUser` """ self._completeIfNotSet(self._assignee) return self._assignee.value @property def assignees(self): """ :type: list of :class:`github.NamedUser.NamedUser` """ self._completeIfNotSet(self._assignees) return self._assignees.value @property def base(self): """ :type: :class:`github.PullRequestPart.PullRequestPart` """ self._completeIfNotSet(self._base) return self._base.value @property def body(self): """ :type: string """ self._completeIfNotSet(self._body) return self._body.value @property def changed_files(self): """ :type: integer """ self._completeIfNotSet(self._changed_files) return self._changed_files.value @property def closed_at(self): """ :type: datetime.datetime """ self._completeIfNotSet(self._closed_at) return self._closed_at.value @property def comments(self): """ :type: integer """ self._completeIfNotSet(self._comments) return self._comments.value @property def comments_url(self): """ :type: string """ self._completeIfNotSet(self._comments_url) return self._comments_url.value @property def commits(self): """ :type: integer """ self._completeIfNotSet(self._commits) return self._commits.value @property def commits_url(self): """ :type: string """ self._completeIfNotSet(self._commits_url) return self._commits_url.value @property def created_at(self): """ :type: datetime.datetime """ self._completeIfNotSet(self._created_at) return self._created_at.value @property def deletions(self): """ :type: integer """ self._completeIfNotSet(self._deletions) return self._deletions.value @property def diff_url(self): """ :type: string """ self._completeIfNotSet(self._diff_url) return self._diff_url.value @property def draft(self): """ :type: bool """ self._completeIfNotSet(self._draft) return self._draft.value @property def head(self): """ :type: :class:`github.PullRequestPart.PullRequestPart` """ self._completeIfNotSet(self._head) return self._head.value @property def html_url(self): """ :type: string """ self._completeIfNotSet(self._html_url) return self._html_url.value @property def id(self): """ :type: integer """ self._completeIfNotSet(self._id) return self._id.value @property def issue_url(self): """ :type: string """ self._completeIfNotSet(self._issue_url) return self._issue_url.value @property def labels(self): """ :type: list of :class:`github.Label.Label` """ self._completeIfNotSet(self._labels) return self._labels.value @property def merge_commit_sha(self): """ :type: string """ self._completeIfNotSet(self._merge_commit_sha) return self._merge_commit_sha.value @property def mergeable(self): """ :type: bool """ self._completeIfNotSet(self._mergeable) return self._mergeable.value @property def mergeable_state(self): """ :type: string """ self._completeIfNotSet(self._mergeable_state) return self._mergeable_state.value @property def merged(self): """ :type: bool """ self._completeIfNotSet(self._merged) return self._merged.value @property def merged_at(self): """ :type: datetime.datetime """ self._completeIfNotSet(self._merged_at) return self._merged_at.value @property def merged_by(self): """ :type: :class:`github.NamedUser.NamedUser` """ self._completeIfNotSet(self._merged_by) return self._merged_by.value @property def milestone(self): """ :type: :class:`github.Milestone.Milestone` """ self._completeIfNotSet(self._milestone) return self._milestone.value @property def number(self): """ :type: integer """ self._completeIfNotSet(self._number) return self._number.value @property def patch_url(self): """ :type: string """ self._completeIfNotSet(self._patch_url) return self._patch_url.value @property def rebaseable(self): """ :type: bool """ self._completeIfNotSet(self._rebaseable) return self._rebaseable.value @property def review_comment_url(self): """ :type: string """ self._completeIfNotSet(self._review_comment_url) return self._review_comment_url.value @property def review_comments(self): """ :type: integer """ self._completeIfNotSet(self._review_comments) return self._review_comments.value @property def review_comments_url(self): """ :type: string """ self._completeIfNotSet(self._review_comments_url) return self._review_comments_url.value @property def state(self): """ :type: string """ self._completeIfNotSet(self._state) return self._state.value @property def title(self): """ :type: string """ self._completeIfNotSet(self._title) return self._title.value @property def updated_at(self): """ :type: datetime.datetime """ self._completeIfNotSet(self._updated_at) return self._updated_at.value @property def url(self): """ :type: string """ self._completeIfNotSet(self._url) return self._url.value @property def user(self): """ :type: :class:`github.NamedUser.NamedUser` """ self._completeIfNotSet(self._user) return self._user.value @property def maintainer_can_modify(self): """ :type: bool """ self._completeIfNotSet(self._maintainer_can_modify) return self._maintainer_can_modify.value def as_issue(self): """ :calls: `GET /repos/{owner}/{repo}/issues/{number} `_ :rtype: :class:`github.Issue.Issue` """ headers, data = self._requester.requestJsonAndCheck("GET", self.issue_url) return github.Issue.Issue(self._requester, headers, data, completed=True) def create_comment(self, body, commit_id, path, position): """ :calls: `POST /repos/{owner}/{repo}/pulls/{number}/comments `_ :param body: string :param commit_id: :class:`github.Commit.Commit` :param path: string :param position: integer :rtype: :class:`github.PullRequestComment.PullRequestComment` """ return self.create_review_comment(body, commit_id, path, position) def create_review_comment(self, body, commit_id, path, position): """ :calls: `POST /repos/{owner}/{repo}/pulls/{number}/comments `_ :param body: string :param commit_id: :class:`github.Commit.Commit` :param path: string :param position: integer :rtype: :class:`github.PullRequestComment.PullRequestComment` """ assert isinstance(body, str), body assert isinstance(commit_id, github.Commit.Commit), commit_id assert isinstance(path, str), path assert isinstance(position, int), position post_parameters = { "body": body, "commit_id": commit_id._identity, "path": path, "position": position, } headers, data = self._requester.requestJsonAndCheck( "POST", f"{self.url}/comments", input=post_parameters ) return github.PullRequestComment.PullRequestComment( self._requester, headers, data, completed=True ) def create_review_comment_reply(self, comment_id, body): """ :calls: `POST /repos/{owner}/{repo}/pulls/{pull_number}/comments/{comment_id}/replies `_ :param comment_id: int :param body: string :rtype: :class:`github.PullRequestComment.PullRequestComment` """ assert isinstance(comment_id, int), comment_id assert isinstance(body, str), body post_parameters = {"body": body} headers, data = self._requester.requestJsonAndCheck( "POST", f"{self.url}/comments/{comment_id}/replies", input=post_parameters, ) return github.PullRequestComment.PullRequestComment( self._requester, headers, data, completed=True ) def create_issue_comment(self, body): """ :calls: `POST /repos/{owner}/{repo}/issues/{number}/comments `_ :param body: string :rtype: :class:`github.IssueComment.IssueComment` """ assert isinstance(body, str), body post_parameters = { "body": body, } headers, data = self._requester.requestJsonAndCheck( "POST", f"{self.issue_url}/comments", input=post_parameters ) return github.IssueComment.IssueComment( self._requester, headers, data, completed=True ) def create_review( self, commit=github.GithubObject.NotSet, body=github.GithubObject.NotSet, event=github.GithubObject.NotSet, comments=github.GithubObject.NotSet, ): """ :calls: `POST /repos/{owner}/{repo}/pulls/{number}/reviews `_ :param commit: github.Commit.Commit :param body: string :param event: string :param comments: list :rtype: :class:`github.PullRequestReview.PullRequestReview` """ assert commit is github.GithubObject.NotSet or isinstance( commit, github.Commit.Commit ), commit assert body is github.GithubObject.NotSet or isinstance(body, str), body assert event is github.GithubObject.NotSet or isinstance(event, str), event assert comments is github.GithubObject.NotSet or isinstance( comments, list ), comments post_parameters = dict() if commit is not github.GithubObject.NotSet: post_parameters["commit_id"] = commit.sha if body is not github.GithubObject.NotSet: post_parameters["body"] = body post_parameters["event"] = ( "COMMENT" if event == github.GithubObject.NotSet else event ) if comments is github.GithubObject.NotSet: post_parameters["comments"] = [] else: post_parameters["comments"] = comments headers, data = self._requester.requestJsonAndCheck( "POST", f"{self.url}/reviews", input=post_parameters ) return github.PullRequestReview.PullRequestReview( self._requester, headers, data, completed=True ) def create_review_request( self, reviewers=github.GithubObject.NotSet, team_reviewers=github.GithubObject.NotSet, ): """ :calls: `POST /repos/{owner}/{repo}/pulls/{number}/requested_reviewers `_ :param reviewers: list of strings :param team_reviewers: list of strings :rtype: None """ post_parameters = dict() if reviewers is not github.GithubObject.NotSet: assert all(isinstance(element, str) for element in reviewers), reviewers post_parameters["reviewers"] = reviewers if team_reviewers is not github.GithubObject.NotSet: assert all( isinstance(element, str) for element in team_reviewers ), team_reviewers post_parameters["team_reviewers"] = team_reviewers headers, data = self._requester.requestJsonAndCheck( "POST", f"{self.url}/requested_reviewers", input=post_parameters ) def delete_review_request( self, reviewers=github.GithubObject.NotSet, team_reviewers=github.GithubObject.NotSet, ): """ :calls: `DELETE /repos/{owner}/{repo}/pulls/{number}/requested_reviewers `_ :param reviewers: list of strings :param team_reviewers: list of strings :rtype: None """ post_parameters = dict() if reviewers is not github.GithubObject.NotSet: assert all(isinstance(element, str) for element in reviewers), reviewers post_parameters["reviewers"] = reviewers if team_reviewers is not github.GithubObject.NotSet: assert all( isinstance(element, str) for element in team_reviewers ), team_reviewers post_parameters["team_reviewers"] = team_reviewers headers, data = self._requester.requestJsonAndCheck( "DELETE", f"{self.url}/requested_reviewers", input=post_parameters ) def edit( self, title=github.GithubObject.NotSet, body=github.GithubObject.NotSet, state=github.GithubObject.NotSet, base=github.GithubObject.NotSet, maintainer_can_modify=github.GithubObject.NotSet, ): """ :calls: `PATCH /repos/{owner}/{repo}/pulls/{number} `_ :param title: string :param body: string :param state: string :param base: string :param maintainer_can_modify: bool :rtype: None """ assert title is github.GithubObject.NotSet or isinstance(title, str), title assert body is github.GithubObject.NotSet or isinstance(body, str), body assert state is github.GithubObject.NotSet or isinstance(state, str), state assert base is github.GithubObject.NotSet or isinstance(base, str), base assert maintainer_can_modify is github.GithubObject.NotSet or isinstance( maintainer_can_modify, bool ), maintainer_can_modify post_parameters = dict() if title is not github.GithubObject.NotSet: post_parameters["title"] = title if body is not github.GithubObject.NotSet: post_parameters["body"] = body if state is not github.GithubObject.NotSet: post_parameters["state"] = state if base is not github.GithubObject.NotSet: post_parameters["base"] = base if maintainer_can_modify is not github.GithubObject.NotSet: post_parameters["maintainer_can_modify"] = maintainer_can_modify headers, data = self._requester.requestJsonAndCheck( "PATCH", self.url, input=post_parameters ) self._useAttributes(data) def get_comment(self, id): """ :calls: `GET /repos/{owner}/{repo}/pulls/comments/{number} `_ :param id: integer :rtype: :class:`github.PullRequestComment.PullRequestComment` """ return self.get_review_comment(id) def get_review_comment(self, id): """ :calls: `GET /repos/{owner}/{repo}/pulls/comments/{number} `_ :param id: integer :rtype: :class:`github.PullRequestComment.PullRequestComment` """ assert isinstance(id, int), id headers, data = self._requester.requestJsonAndCheck( "GET", f"{self._parentUrl(self.url)}/comments/{id}" ) return github.PullRequestComment.PullRequestComment( self._requester, headers, data, completed=True ) def get_comments(self): """ Warning: this only returns review comments. For normal conversation comments, use get_issue_comments. :calls: `GET /repos/{owner}/{repo}/pulls/{number}/comments `_ :rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.PullRequestComment.PullRequestComment` """ return self.get_review_comments() def get_review_comments(self, since=github.GithubObject.NotSet): """ :calls: `GET /repos/{owner}/{repo}/pulls/{number}/comments `_ :param since: datetime.datetime format YYYY-MM-DDTHH:MM:SSZ :rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.PullRequestComment.PullRequestComment` """ assert since is github.GithubObject.NotSet or isinstance( since, datetime.datetime ), since url_parameters = dict() if since is not github.GithubObject.NotSet: url_parameters["since"] = since.strftime("%Y-%m-%dT%H:%M:%SZ") return github.PaginatedList.PaginatedList( github.PullRequestComment.PullRequestComment, self._requester, f"{self.url}/comments", url_parameters, ) def get_single_review_comments(self, id): """ :calls: `GET /repos/{owner}/{repo}/pulls/{number}/review/{id}/comments `_ :param id: integer :rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.PullRequestComment.PullRequestComment` """ assert isinstance(id, int), id return github.PaginatedList.PaginatedList( github.PullRequestComment.PullRequestComment, self._requester, f"{self.url}/reviews/{id}/comments", None, ) def get_commits(self): """ :calls: `GET /repos/{owner}/{repo}/pulls/{number}/commits `_ :rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.Commit.Commit` """ return github.PaginatedList.PaginatedList( github.Commit.Commit, self._requester, f"{self.url}/commits", None ) def get_files(self): """ :calls: `GET /repos/{owner}/{repo}/pulls/{number}/files `_ :rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.File.File` """ return github.PaginatedList.PaginatedList( github.File.File, self._requester, f"{self.url}/files", None ) def get_issue_comment(self, id): """ :calls: `GET /repos/{owner}/{repo}/issues/comments/{id} `_ :param id: integer :rtype: :class:`github.IssueComment.IssueComment` """ assert isinstance(id, int), id headers, data = self._requester.requestJsonAndCheck( "GET", f"{self._parentUrl(self.issue_url)}/comments/{id}" ) return github.IssueComment.IssueComment( self._requester, headers, data, completed=True ) def get_issue_comments(self): """ :calls: `GET /repos/{owner}/{repo}/issues/{number}/comments `_ :rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.IssueComment.IssueComment` """ return github.PaginatedList.PaginatedList( github.IssueComment.IssueComment, self._requester, f"{self.issue_url}/comments", None, ) def get_issue_events(self): """ :calls: `GET /repos/{owner}/{repo}/issues/{issue_number}/events `_ :rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.IssueEvent.IssueEvent` """ return github.PaginatedList.PaginatedList( github.IssueEvent.IssueEvent, self._requester, f"{self.issue_url}/events", None, headers={"Accept": Consts.mediaTypeLockReasonPreview}, ) def get_review(self, id): """ :calls: `GET /repos/{owner}/{repo}/pulls/{number}/reviews/{id} `_ :param id: integer :rtype: :class:`github.PullRequestReview.PullRequestReview` """ assert isinstance(id, int), id headers, data = self._requester.requestJsonAndCheck( "GET", f"{self.url}/reviews/{id}", ) return github.PullRequestReview.PullRequestReview( self._requester, headers, data, completed=True ) def get_reviews(self): """ :calls: `GET /repos/{owner}/{repo}/pulls/{number}/reviews `_ :rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.PullRequestReview.PullRequestReview` """ return github.PaginatedList.PaginatedList( github.PullRequestReview.PullRequestReview, self._requester, f"{self.url}/reviews", None, ) def get_review_requests(self): """ :calls: `GET /repos/{owner}/{repo}/pulls/{number}/requested_reviewers `_ :rtype: tuple of :class:`github.PaginatedList.PaginatedList` of :class:`github.NamedUser.NamedUser` and of :class:`github.PaginatedList.PaginatedList` of :class:`github.Team.Team` """ return ( github.PaginatedList.PaginatedList( github.NamedUser.NamedUser, self._requester, f"{self.url}/requested_reviewers", None, list_item="users", ), github.PaginatedList.PaginatedList( github.Team.Team, self._requester, f"{self.url}/requested_reviewers", None, list_item="teams", ), ) def get_labels(self): """ :calls: `GET /repos/{owner}/{repo}/issues/{number}/labels `_ :rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.Label.Label` """ return github.PaginatedList.PaginatedList( github.Label.Label, self._requester, f"{self.issue_url}/labels", None ) def add_to_labels(self, *labels): """ :calls: `POST /repos/{owner}/{repo}/issues/{number}/labels `_ :param label: :class:`github.Label.Label` or string :rtype: None """ assert all( isinstance(element, (github.Label.Label, str)) for element in labels ), labels post_parameters = [ label.name if isinstance(label, github.Label.Label) else label for label in labels ] headers, data = self._requester.requestJsonAndCheck( "POST", f"{self.issue_url}/labels", input=post_parameters ) def delete_labels(self): """ :calls: `DELETE /repos/{owner}/{repo}/issues/{number}/labels `_ :rtype: None """ headers, data = self._requester.requestJsonAndCheck( "DELETE", f"{self.issue_url}/labels" ) def remove_from_labels(self, label): """ :calls: `DELETE /repos/{owner}/{repo}/issues/{number}/labels/{name} `_ :param label: :class:`github.Label.Label` or string :rtype: None """ assert isinstance(label, (github.Label.Label, str)), label if isinstance(label, github.Label.Label): label = label._identity else: label = urllib.parse.quote(label) headers, data = self._requester.requestJsonAndCheck( "DELETE", f"{self.issue_url}/labels/{label}" ) def set_labels(self, *labels): """ :calls: `PUT /repos/{owner}/{repo}/issues/{number}/labels `_ :param labels: list of :class:`github.Label.Label` or strings :rtype: None """ assert all( isinstance(element, (github.Label.Label, str)) for element in labels ), labels post_parameters = [ label.name if isinstance(label, github.Label.Label) else label for label in labels ] headers, data = self._requester.requestJsonAndCheck( "PUT", f"{self.issue_url}/labels", input=post_parameters ) def is_merged(self): """ :calls: `GET /repos/{owner}/{repo}/pulls/{number}/merge `_ :rtype: bool """ status, headers, data = self._requester.requestJson("GET", f"{self.url}/merge") return status == 204 def merge( self, commit_message=github.GithubObject.NotSet, commit_title=github.GithubObject.NotSet, merge_method=github.GithubObject.NotSet, sha=github.GithubObject.NotSet, ): """ :calls: `PUT /repos/{owner}/{repo}/pulls/{number}/merge `_ :param commit_message: string :param commit_title: string :param merge_method: string :param sha: string :rtype: :class:`github.PullRequestMergeStatus.PullRequestMergeStatus` """ assert commit_message is github.GithubObject.NotSet or isinstance( commit_message, str ), commit_message assert commit_title is github.GithubObject.NotSet or isinstance( commit_title, str ), commit_title assert merge_method is github.GithubObject.NotSet or isinstance( merge_method, str ), merge_method assert sha is github.GithubObject.NotSet or isinstance(sha, str), sha post_parameters = dict() if commit_message is not github.GithubObject.NotSet: post_parameters["commit_message"] = commit_message if commit_title is not github.GithubObject.NotSet: post_parameters["commit_title"] = commit_title if merge_method is not github.GithubObject.NotSet: post_parameters["merge_method"] = merge_method if sha is not github.GithubObject.NotSet: post_parameters["sha"] = sha headers, data = self._requester.requestJsonAndCheck( "PUT", f"{self.url}/merge", input=post_parameters ) return github.PullRequestMergeStatus.PullRequestMergeStatus( self._requester, headers, data, completed=True ) def add_to_assignees(self, *assignees): """ :calls: `POST /repos/{owner}/{repo}/issues/{number}/assignees `_ :param assignees: list of :class:`github.NamedUser.NamedUser` or string :rtype: None """ assert all( isinstance(element, (github.NamedUser.NamedUser, str)) for element in assignees ), assignees post_parameters = { "assignees": [ assignee.login if isinstance(assignee, github.NamedUser.NamedUser) else assignee for assignee in assignees ] } headers, data = self._requester.requestJsonAndCheck( "POST", f"{self.issue_url}/assignees", input=post_parameters ) # Only use the assignees attribute, since we call this PR as an issue self._useAttributes({"assignees": data["assignees"]}) def remove_from_assignees(self, *assignees): """ :calls: `DELETE /repos/{owner}/{repo}/issues/{number}/assignees `_ :param assignees: list of :class:`github.NamedUser.NamedUser` or string :rtype: None """ assert all( isinstance(element, (github.NamedUser.NamedUser, str)) for element in assignees ), assignees post_parameters = { "assignees": [ assignee.login if isinstance(assignee, github.NamedUser.NamedUser) else assignee for assignee in assignees ] } headers, data = self._requester.requestJsonAndCheck( "DELETE", f"{self.issue_url}/assignees", input=post_parameters ) # Only use the assignees attribute, since we call this PR as an issue self._useAttributes({"assignees": data["assignees"]}) def update_branch(self, expected_head_sha=github.GithubObject.NotSet): """ :calls `PUT /repos/{owner}/{repo}/pulls/{pull_number}/update-branch `_ :param expected_head_sha: string :rtype: bool """ assert expected_head_sha is github.GithubObject.NotSet or isinstance( expected_head_sha, str ), expected_head_sha post_parameters = {} if expected_head_sha is not github.GithubObject.NotSet: post_parameters["expected_head_sha"] = expected_head_sha status, headers, data = self._requester.requestJson( "PUT", f"{self.url}/update-branch", input=post_parameters, headers={"Accept": Consts.updateBranchPreview}, ) return status == 202 def _initAttributes(self): self._additions = github.GithubObject.NotSet self._assignee = github.GithubObject.NotSet self._assignees = github.GithubObject.NotSet self._base = github.GithubObject.NotSet self._body = github.GithubObject.NotSet self._changed_files = github.GithubObject.NotSet self._closed_at = github.GithubObject.NotSet self._comments = github.GithubObject.NotSet self._comments_url = github.GithubObject.NotSet self._commits = github.GithubObject.NotSet self._commits_url = github.GithubObject.NotSet self._created_at = github.GithubObject.NotSet self._deletions = github.GithubObject.NotSet self._diff_url = github.GithubObject.NotSet self._draft = github.GithubObject.NotSet self._head = github.GithubObject.NotSet self._html_url = github.GithubObject.NotSet self._id = github.GithubObject.NotSet self._issue_url = github.GithubObject.NotSet self._labels = github.GithubObject.NotSet self._maintainer_can_modify = github.GithubObject.NotSet self._merge_commit_sha = github.GithubObject.NotSet self._mergeable = github.GithubObject.NotSet self._mergeable_state = github.GithubObject.NotSet self._merged = github.GithubObject.NotSet self._merged_at = github.GithubObject.NotSet self._merged_by = github.GithubObject.NotSet self._milestone = github.GithubObject.NotSet self._number = github.GithubObject.NotSet self._patch_url = github.GithubObject.NotSet self._rebaseable = github.GithubObject.NotSet self._review_comment_url = github.GithubObject.NotSet self._review_comments = github.GithubObject.NotSet self._review_comments_url = github.GithubObject.NotSet self._state = github.GithubObject.NotSet self._title = github.GithubObject.NotSet self._updated_at = github.GithubObject.NotSet self._url = github.GithubObject.NotSet self._user = github.GithubObject.NotSet def _useAttributes(self, attributes): if "additions" in attributes: # pragma no branch self._additions = self._makeIntAttribute(attributes["additions"]) if "assignee" in attributes: # pragma no branch self._assignee = self._makeClassAttribute( github.NamedUser.NamedUser, attributes["assignee"] ) if "assignees" in attributes: # pragma no branch self._assignees = self._makeListOfClassesAttribute( github.NamedUser.NamedUser, attributes["assignees"] ) elif "assignee" in attributes: if attributes["assignee"] is not None: self._assignees = self._makeListOfClassesAttribute( github.NamedUser.NamedUser, [attributes["assignee"]] ) else: self._assignees = self._makeListOfClassesAttribute( github.NamedUser.NamedUser, [] ) if "base" in attributes: # pragma no branch self._base = self._makeClassAttribute( github.PullRequestPart.PullRequestPart, attributes["base"] ) if "body" in attributes: # pragma no branch self._body = self._makeStringAttribute(attributes["body"]) if "changed_files" in attributes: # pragma no branch self._changed_files = self._makeIntAttribute(attributes["changed_files"]) if "closed_at" in attributes: # pragma no branch self._closed_at = self._makeDatetimeAttribute(attributes["closed_at"]) if "comments" in attributes: # pragma no branch self._comments = self._makeIntAttribute(attributes["comments"]) if "comments_url" in attributes: # pragma no branch self._comments_url = self._makeStringAttribute(attributes["comments_url"]) if "commits" in attributes: # pragma no branch self._commits = self._makeIntAttribute(attributes["commits"]) if "commits_url" in attributes: # pragma no branch self._commits_url = self._makeStringAttribute(attributes["commits_url"]) if "created_at" in attributes: # pragma no branch self._created_at = self._makeDatetimeAttribute(attributes["created_at"]) if "deletions" in attributes: # pragma no branch self._deletions = self._makeIntAttribute(attributes["deletions"]) if "diff_url" in attributes: # pragma no branch self._diff_url = self._makeStringAttribute(attributes["diff_url"]) if "draft" in attributes: # pragma no branch self._draft = self._makeBoolAttribute(attributes["draft"]) if "head" in attributes: # pragma no branch self._head = self._makeClassAttribute( github.PullRequestPart.PullRequestPart, attributes["head"] ) if "html_url" in attributes: # pragma no branch self._html_url = self._makeStringAttribute(attributes["html_url"]) if "id" in attributes: # pragma no branch self._id = self._makeIntAttribute(attributes["id"]) if "issue_url" in attributes: # pragma no branch self._issue_url = self._makeStringAttribute(attributes["issue_url"]) if "labels" in attributes: # pragma no branch self._labels = self._makeListOfClassesAttribute( github.Label.Label, attributes["labels"] ) if "maintainer_can_modify" in attributes: # pragma no branch self._maintainer_can_modify = self._makeBoolAttribute( attributes["maintainer_can_modify"] ) if "merge_commit_sha" in attributes: # pragma no branch self._merge_commit_sha = self._makeStringAttribute( attributes["merge_commit_sha"] ) if "mergeable" in attributes: # pragma no branch self._mergeable = self._makeBoolAttribute(attributes["mergeable"]) if "mergeable_state" in attributes: # pragma no branch self._mergeable_state = self._makeStringAttribute( attributes["mergeable_state"] ) if "merged" in attributes: # pragma no branch self._merged = self._makeBoolAttribute(attributes["merged"]) if "merged_at" in attributes: # pragma no branch self._merged_at = self._makeDatetimeAttribute(attributes["merged_at"]) if "merged_by" in attributes: # pragma no branch self._merged_by = self._makeClassAttribute( github.NamedUser.NamedUser, attributes["merged_by"] ) if "milestone" in attributes: # pragma no branch self._milestone = self._makeClassAttribute( github.Milestone.Milestone, attributes["milestone"] ) if "number" in attributes: # pragma no branch self._number = self._makeIntAttribute(attributes["number"]) if "patch_url" in attributes: # pragma no branch self._patch_url = self._makeStringAttribute(attributes["patch_url"]) if "rebaseable" in attributes: # pragma no branch self._rebaseable = self._makeBoolAttribute(attributes["rebaseable"]) if "review_comment_url" in attributes: # pragma no branch self._review_comment_url = self._makeStringAttribute( attributes["review_comment_url"] ) if "review_comments" in attributes: # pragma no branch self._review_comments = self._makeIntAttribute( attributes["review_comments"] ) if "review_comments_url" in attributes: # pragma no branch self._review_comments_url = self._makeStringAttribute( attributes["review_comments_url"] ) if "state" in attributes: # pragma no branch self._state = self._makeStringAttribute(attributes["state"]) if "title" in attributes: # pragma no branch self._title = self._makeStringAttribute(attributes["title"]) if "updated_at" in attributes: # pragma no branch self._updated_at = self._makeDatetimeAttribute(attributes["updated_at"]) if "url" in attributes: # pragma no branch self._url = self._makeStringAttribute(attributes["url"]) if "user" in attributes: # pragma no branch self._user = self._makeClassAttribute( github.NamedUser.NamedUser, attributes["user"] ) ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1619412308.0 PyGithub-1.55/github/PullRequest.pyi0000644000175100001710000001331400000000000017033 0ustar00runnerdockerfrom datetime import datetime from typing import Any, Dict, List, Optional, Tuple, Union from github.Commit import Commit from github.File import File from github.GithubObject import CompletableGithubObject, _NotSetType from github.Issue import Issue from github.IssueComment import IssueComment from github.IssueEvent import IssueEvent from github.Label import Label from github.Milestone import Milestone from github.NamedUser import NamedUser from github.PaginatedList import PaginatedList from github.PullRequestComment import PullRequestComment from github.PullRequestMergeStatus import PullRequestMergeStatus from github.PullRequestPart import PullRequestPart from github.PullRequestReview import PullRequestReview from github.Team import Team class PullRequest(CompletableGithubObject): def _initAttributes(self) -> None: ... def _useAttributes(self, attributes: Dict[str, Any]) -> None: ... def add_to_labels(self, *labels: Union[Label, str]) -> None: ... def add_to_assignees(self, *assignees: Union[NamedUser, str]) -> None: ... @property def additions(self) -> int: ... def as_issue(self) -> Issue: ... @property def assignee(self) -> NamedUser: ... @property def assignees(self) -> List[NamedUser]: ... @property def base(self) -> PullRequestPart: ... @property def body(self) -> str: ... @property def changed_files(self) -> int: ... @property def closed_at(self) -> Optional[datetime]: ... @property def comments(self) -> int: ... @property def comments_url(self) -> str: ... @property def commits(self) -> int: ... @property def commits_url(self) -> str: ... def create_comment( self, body: str, commit_id: Commit, path: str, position: int ) -> PullRequestComment: ... def create_issue_comment(self, body: str) -> IssueComment: ... def create_review( self, commit: Commit = ..., body: Union[_NotSetType, str] = ..., event: Union[_NotSetType, str] = ..., comments: Union[_NotSetType, str] = ..., ) -> PullRequestReview: ... def create_review_comment( self, body: str, commit_id: Commit, path: str, position: int ) -> PullRequestComment: ... def create_review_request( self, reviewers: Union[_NotSetType, List[str]] = ..., team_reviewers: Union[_NotSetType, List[str]] = ..., ) -> None: ... @property def created_at(self) -> datetime: ... def delete_labels(self) -> None: ... def delete_review_request( self, reviewers: Union[_NotSetType, List[str]] = ..., team_reviewers: Union[_NotSetType, List[str]] = ..., ) -> None: ... @property def deletions(self) -> int: ... @property def diff_url(self) -> str: ... @property def draft(self) -> bool: ... def edit( self, title: Union[str, _NotSetType] = ..., body: Union[str, _NotSetType] = ..., state: Union[str, _NotSetType] = ..., base: Union[_NotSetType, str] = ..., ) -> None: ... def get_comment(self, id: int) -> PullRequestComment: ... def get_comments(self) -> PaginatedList[PullRequestComment]: ... def get_commits(self) -> PaginatedList[Commit]: ... def get_files(self) -> PaginatedList[File]: ... def get_issue_comment(self, id: int) -> IssueComment: ... def get_issue_comments(self) -> PaginatedList[IssueComment]: ... def get_issue_events(self) -> PaginatedList[IssueEvent]: ... def get_labels(self) -> PaginatedList[Label]: ... def get_review(self, id: int) -> PullRequestReview: ... def get_review_comment(self, id: int) -> PullRequestComment: ... def get_review_comments( self, since: Union[_NotSetType, datetime] = ... ) -> PaginatedList[PullRequestComment]: ... def get_single_review_comments( self, id: int ) -> PaginatedList[PullRequestComment]: ... def get_review_requests( self, ) -> Tuple[PaginatedList[NamedUser], PaginatedList[Team]]: ... def get_reviews(self) -> PaginatedList[PullRequestReview]: ... @property def head(self) -> PullRequestPart: ... @property def html_url(self) -> str: ... @property def id(self) -> int: ... def is_merged(self) -> bool: ... @property def issue_url(self) -> str: ... @property def labels(self) -> List[Label]: ... @property def maintainer_can_modify(self) -> bool: ... def merge( self, commit_message: Union[str, _NotSetType] = ..., commit_title: Union[str, _NotSetType] = ..., merge_method: Union[str, _NotSetType] = ..., sha: Union[str, _NotSetType] = ..., ) -> PullRequestMergeStatus: ... @property def merge_commit_sha(self) -> str: ... @property def mergeable(self) -> Optional[bool]: ... @property def mergeable_state(self) -> str: ... @property def merged(self) -> bool: ... @property def merged_at(self) -> datetime: ... @property def merged_by(self) -> NamedUser: ... @property def milestone(self) -> Milestone: ... @property def number(self) -> int: ... @property def patch_url(self) -> str: ... @property def rebaseable(self) -> bool: ... def remove_from_labels(self, label: Union[Label, str]) -> None: ... @property def review_comment_url(self) -> str: ... @property def review_comments(self) -> int: ... @property def review_comments_url(self) -> str: ... def set_labels(self, *labels: Union[Label, str]) -> None: ... @property def state(self) -> str: ... @property def title(self) -> str: ... @property def updated_at(self) -> datetime: ... @property def url(self) -> str: ... @property def user(self) -> NamedUser: ... ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1619412308.0 PyGithub-1.55/github/PullRequestComment.py0000644000175100001710000002665600000000000020222 0ustar00runnerdocker############################ Copyrights and license ############################ # # # Copyright 2012 Vincent Jacques # # Copyright 2012 Zearin # # Copyright 2013 AKFish # # Copyright 2013 Michael Stead # # Copyright 2013 Vincent Jacques # # Copyright 2013 martinqt # # Copyright 2014 Vincent Jacques # # Copyright 2016 Jannis Gebauer # # Copyright 2016 Peter Buckley # # Copyright 2017 Nicolas Agustín Torres # # Copyright 2018 Jess Morgan <979404+JessMorgan@users.noreply.github.com> # # Copyright 2018 per1234 # # Copyright 2018 sfdye # # Copyright 2020 Huan-Cheng Chang # # # # This file is part of PyGithub. # # http://pygithub.readthedocs.io/ # # # # PyGithub is free software: you can redistribute it and/or modify it under # # the terms of the GNU Lesser General Public License as published by the Free # # Software Foundation, either version 3 of the License, or (at your option) # # any later version. # # # # PyGithub is distributed in the hope that it will be useful, but WITHOUT ANY # # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more # # details. # # # # You should have received a copy of the GNU Lesser General Public License # # along with PyGithub. If not, see . # # # ################################################################################ import github.GithubObject import github.NamedUser from . import Consts class PullRequestComment(github.GithubObject.CompletableGithubObject): """ This class represents PullRequestComments. The reference can be found here http://docs.github.com/en/rest/reference/pulls#comments """ def __repr__(self): return self.get__repr__({"id": self._id.value, "user": self._user.value}) @property def body(self): """ :type: string """ self._completeIfNotSet(self._body) return self._body.value @property def commit_id(self): """ :type: string """ self._completeIfNotSet(self._commit_id) return self._commit_id.value @property def created_at(self): """ :type: datetime.datetime """ self._completeIfNotSet(self._created_at) return self._created_at.value @property def diff_hunk(self): """ :type: string """ self._completeIfNotSet(self._diff_hunk) return self._diff_hunk.value @property def id(self): """ :type: integer """ self._completeIfNotSet(self._id) return self._id.value @property def in_reply_to_id(self): """ :type: integer """ self._completeIfNotSet(self._in_reply_to_id) return self._in_reply_to_id.value @property def original_commit_id(self): """ :type: string """ self._completeIfNotSet(self._original_commit_id) return self._original_commit_id.value @property def original_position(self): """ :type: integer """ self._completeIfNotSet(self._original_position) return self._original_position.value @property def path(self): """ :type: string """ self._completeIfNotSet(self._path) return self._path.value @property def position(self): """ :type: integer """ self._completeIfNotSet(self._position) return self._position.value @property def pull_request_url(self): """ :type: string """ self._completeIfNotSet(self._pull_request_url) return self._pull_request_url.value @property def updated_at(self): """ :type: datetime.datetime """ self._completeIfNotSet(self._updated_at) return self._updated_at.value @property def url(self): """ :type: string """ self._completeIfNotSet(self._url) return self._url.value @property def html_url(self): """ :type: string """ self._completeIfNotSet(self._html_url) return self._html_url.value @property def user(self): """ :type: :class:`github.NamedUser.NamedUser` """ self._completeIfNotSet(self._user) return self._user.value def delete(self): """ :calls: `DELETE /repos/{owner}/{repo}/pulls/comments/{number} `_ :rtype: None """ headers, data = self._requester.requestJsonAndCheck("DELETE", self.url) def edit(self, body): """ :calls: `PATCH /repos/{owner}/{repo}/pulls/comments/{number} `_ :param body: string :rtype: None """ assert isinstance(body, str), body post_parameters = { "body": body, } headers, data = self._requester.requestJsonAndCheck( "PATCH", self.url, input=post_parameters ) self._useAttributes(data) def get_reactions(self): """ :calls: `GET /repos/{owner}/{repo}/pulls/comments/{number}/reactions `_ :return: :class: :class:`github.PaginatedList.PaginatedList` of :class:`github.Reaction.Reaction` """ return github.PaginatedList.PaginatedList( github.Reaction.Reaction, self._requester, f"{self.url}/reactions", None, headers={"Accept": Consts.mediaTypeReactionsPreview}, ) def create_reaction(self, reaction_type): """ :calls: `POST /repos/{owner}/{repo}/pulls/comments/{number}/reactions `_ :param reaction_type: string :rtype: :class:`github.Reaction.Reaction` """ assert isinstance(reaction_type, str), reaction_type post_parameters = { "content": reaction_type, } headers, data = self._requester.requestJsonAndCheck( "POST", f"{self.url}/reactions", input=post_parameters, headers={"Accept": Consts.mediaTypeReactionsPreview}, ) return github.Reaction.Reaction(self._requester, headers, data, completed=True) def delete_reaction(self, reaction_id): """ :calls: `DELETE /repos/{owner}/{repo}/pulls/comments/{comment_id}/reactions/{reaction_id} `_ :param reaction_id: integer :rtype: bool """ assert isinstance(reaction_id, int), reaction_id status, _, _ = self._requester.requestJson( "DELETE", f"{self.url}/reactions/{reaction_id}", headers={"Accept": Consts.mediaTypeReactionsPreview}, ) return status == 204 def _initAttributes(self): self._body = github.GithubObject.NotSet self._commit_id = github.GithubObject.NotSet self._created_at = github.GithubObject.NotSet self._diff_hunk = github.GithubObject.NotSet self._id = github.GithubObject.NotSet self._in_reply_to_id = github.GithubObject.NotSet self._original_commit_id = github.GithubObject.NotSet self._original_position = github.GithubObject.NotSet self._path = github.GithubObject.NotSet self._position = github.GithubObject.NotSet self._pull_request_url = github.GithubObject.NotSet self._updated_at = github.GithubObject.NotSet self._url = github.GithubObject.NotSet self._html_url = github.GithubObject.NotSet self._user = github.GithubObject.NotSet def _useAttributes(self, attributes): if "body" in attributes: # pragma no branch self._body = self._makeStringAttribute(attributes["body"]) if "commit_id" in attributes: # pragma no branch self._commit_id = self._makeStringAttribute(attributes["commit_id"]) if "created_at" in attributes: # pragma no branch self._created_at = self._makeDatetimeAttribute(attributes["created_at"]) if "diff_hunk" in attributes: # pragma no branch self._diff_hunk = self._makeStringAttribute(attributes["diff_hunk"]) if "id" in attributes: # pragma no branch self._id = self._makeIntAttribute(attributes["id"]) if "in_reply_to_id" in attributes: # pragma no branch self._in_reply_to_id = self._makeIntAttribute(attributes["in_reply_to_id"]) if "original_commit_id" in attributes: # pragma no branch self._original_commit_id = self._makeStringAttribute( attributes["original_commit_id"] ) if "original_position" in attributes: # pragma no branch self._original_position = self._makeIntAttribute( attributes["original_position"] ) if "path" in attributes: # pragma no branch self._path = self._makeStringAttribute(attributes["path"]) if "position" in attributes: # pragma no branch self._position = self._makeIntAttribute(attributes["position"]) if "pull_request_url" in attributes: # pragma no branch self._pull_request_url = self._makeStringAttribute( attributes["pull_request_url"] ) if "updated_at" in attributes: # pragma no branch self._updated_at = self._makeDatetimeAttribute(attributes["updated_at"]) if "url" in attributes: # pragma no branch self._url = self._makeStringAttribute(attributes["url"]) if "html_url" in attributes: # pragma no branch self._html_url = self._makeStringAttribute(attributes["html_url"]) if "user" in attributes: # pragma no branch self._user = self._makeClassAttribute( github.NamedUser.NamedUser, attributes["user"] ) ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1619412308.0 PyGithub-1.55/github/PullRequestComment.pyi0000644000175100001710000000267700000000000020370 0ustar00runnerdockerfrom datetime import datetime from typing import Any, Dict from github.GithubObject import CompletableGithubObject from github.NamedUser import NamedUser from github.PaginatedList import PaginatedList from github.Reaction import Reaction class PullRequestComment(CompletableGithubObject): def __repr__(self) -> str: ... def _initAttributes(self) -> None: ... def _useAttributes(self, attributes: Dict[str, Any]) -> None: ... @property def body(self) -> str: ... @property def commit_id(self) -> str: ... def create_reaction(self, reaction_type: str) -> Reaction: ... @property def created_at(self) -> datetime: ... def delete(self) -> None: ... def delete_reaction(self, reaction_id: int) -> bool: ... @property def diff_hunk(self) -> str: ... def edit(self, body: str) -> None: ... def get_reactions(self) -> PaginatedList[Reaction]: ... @property def html_url(self) -> str: ... @property def id(self) -> int: ... @property def in_reply_to_id(self) -> int: ... @property def original_commit_id(self) -> str: ... @property def original_position(self) -> int: ... @property def path(self) -> str: ... @property def position(self) -> int: ... @property def pull_request_url(self) -> str: ... @property def updated_at(self) -> datetime: ... @property def url(self) -> str: ... @property def user(self) -> NamedUser: ... ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1619412308.0 PyGithub-1.55/github/PullRequestMergeStatus.py0000644000175100001710000000731200000000000021047 0ustar00runnerdocker############################ Copyrights and license ############################ # # # Copyright 2012 Vincent Jacques # # Copyright 2012 Zearin # # Copyright 2013 AKFish # # Copyright 2013 Vincent Jacques # # Copyright 2013 martinqt # # Copyright 2014 Vincent Jacques # # Copyright 2016 Jannis Gebauer # # Copyright 2016 Peter Buckley # # Copyright 2018 Wan Liuyang # # Copyright 2018 sfdye # # # # This file is part of PyGithub. # # http://pygithub.readthedocs.io/ # # # # PyGithub is free software: you can redistribute it and/or modify it under # # the terms of the GNU Lesser General Public License as published by the Free # # Software Foundation, either version 3 of the License, or (at your option) # # any later version. # # # # PyGithub is distributed in the hope that it will be useful, but WITHOUT ANY # # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more # # details. # # # # You should have received a copy of the GNU Lesser General Public License # # along with PyGithub. If not, see . # # # ################################################################################ import github.GithubObject class PullRequestMergeStatus(github.GithubObject.NonCompletableGithubObject): """ This class represents PullRequestMergeStatuses. The reference can be found here http://docs.github.com/en/rest/reference/pulls#get-if-a-pull-request-has-been-merged """ def __repr__(self): return self.get__repr__({"sha": self._sha.value, "merged": self._merged.value}) @property def merged(self): """ :type: bool """ return self._merged.value @property def message(self): """ :type: string """ return self._message.value @property def sha(self): """ :type: string """ return self._sha.value def _initAttributes(self): self._merged = github.GithubObject.NotSet self._message = github.GithubObject.NotSet self._sha = github.GithubObject.NotSet def _useAttributes(self, attributes): if "merged" in attributes: # pragma no branch self._merged = self._makeBoolAttribute(attributes["merged"]) if "message" in attributes: # pragma no branch self._message = self._makeStringAttribute(attributes["message"]) if "sha" in attributes: # pragma no branch self._sha = self._makeStringAttribute(attributes["sha"]) ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1619412308.0 PyGithub-1.55/github/PullRequestMergeStatus.pyi0000644000175100001710000000066400000000000021223 0ustar00runnerdockerfrom typing import Any, Dict from github.GithubObject import NonCompletableGithubObject class PullRequestMergeStatus(NonCompletableGithubObject): def __repr__(self) -> str: ... def _initAttributes(self) -> None: ... def _useAttributes(self, attributes: Dict[str, Any]) -> None: ... @property def merged(self) -> bool: ... @property def message(self) -> str: ... @property def sha(self) -> str: ... ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1619412308.0 PyGithub-1.55/github/PullRequestPart.py0000644000175100001710000001032700000000000017512 0ustar00runnerdocker############################ Copyrights and license ############################ # # # Copyright 2012 Vincent Jacques # # Copyright 2012 Zearin # # Copyright 2013 AKFish # # Copyright 2013 Vincent Jacques # # Copyright 2014 Vincent Jacques # # Copyright 2016 Jannis Gebauer # # Copyright 2016 Peter Buckley # # Copyright 2018 Wan Liuyang # # Copyright 2018 sfdye # # # # This file is part of PyGithub. # # http://pygithub.readthedocs.io/ # # # # PyGithub is free software: you can redistribute it and/or modify it under # # the terms of the GNU Lesser General Public License as published by the Free # # Software Foundation, either version 3 of the License, or (at your option) # # any later version. # # # # PyGithub is distributed in the hope that it will be useful, but WITHOUT ANY # # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more # # details. # # # # You should have received a copy of the GNU Lesser General Public License # # along with PyGithub. If not, see . # # # ################################################################################ import github.GithubObject import github.NamedUser import github.Repository class PullRequestPart(github.GithubObject.NonCompletableGithubObject): """ This class represents PullRequestParts """ def __repr__(self): return self.get__repr__({"sha": self._sha.value}) @property def label(self): """ :type: string """ return self._label.value @property def ref(self): """ :type: string """ return self._ref.value @property def repo(self): """ :type: :class:`github.Repository.Repository` """ return self._repo.value @property def sha(self): """ :type: string """ return self._sha.value @property def user(self): """ :type: :class:`github.NamedUser.NamedUser` """ return self._user.value def _initAttributes(self): self._label = github.GithubObject.NotSet self._ref = github.GithubObject.NotSet self._repo = github.GithubObject.NotSet self._sha = github.GithubObject.NotSet self._user = github.GithubObject.NotSet def _useAttributes(self, attributes): if "label" in attributes: # pragma no branch self._label = self._makeStringAttribute(attributes["label"]) if "ref" in attributes: # pragma no branch self._ref = self._makeStringAttribute(attributes["ref"]) if "repo" in attributes: # pragma no branch self._repo = self._makeClassAttribute( github.Repository.Repository, attributes["repo"] ) if "sha" in attributes: # pragma no branch self._sha = self._makeStringAttribute(attributes["sha"]) if "user" in attributes: # pragma no branch self._user = self._makeClassAttribute( github.NamedUser.NamedUser, attributes["user"] ) ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1619412308.0 PyGithub-1.55/github/PullRequestPart.pyi0000644000175100001710000000116200000000000017660 0ustar00runnerdockerfrom typing import Any, Dict, Optional from github.GithubObject import NonCompletableGithubObject from github.NamedUser import NamedUser from github.Repository import Repository class PullRequestPart(NonCompletableGithubObject): def __repr__(self) -> str: ... def _initAttributes(self) -> None: ... def _useAttributes(self, attributes: Dict[str, Any]) -> None: ... @property def label(self) -> str: ... @property def ref(self) -> str: ... @property def repo(self) -> Repository: ... @property def sha(self) -> str: ... @property def user(self) -> Optional[NamedUser]: ... ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1619412308.0 PyGithub-1.55/github/PullRequestReview.py0000644000175100001710000001271000000000000020043 0ustar00runnerdocker############################ Copyrights and license ############################ # # # Copyright 2017 Aaron Levine # # Copyright 2017 Mike Miller # # Copyright 2018 Darragh Bailey # # Copyright 2018 Wan Liuyang # # Copyright 2018 sfdye # # # # This file is part of PyGithub. # # http://pygithub.readthedocs.io/ # # # # PyGithub is free software: you can redistribute it and/or modify it under # # the terms of the GNU Lesser General Public License as published by the Free # # Software Foundation, either version 3 of the License, or (at your option) # # any later version. # # # # PyGithub is distributed in the hope that it will be useful, but WITHOUT ANY # # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more # # details. # # # # You should have received a copy of the GNU Lesser General Public License # # along with PyGithub. If not, see . # # # ################################################################################ import github.GithubObject import github.NamedUser class PullRequestReview(github.GithubObject.NonCompletableGithubObject): """ This class represents PullRequestReviews. The reference can be found here https://docs.github.com/en/rest/reference/pulls#reviews """ def __repr__(self): return self.get__repr__({"id": self._id.value, "user": self._user.value}) @property def id(self): """ :type: integer """ return self._id.value @property def user(self): """ :type: :class:`github.NamedUser.NamedUser` """ return self._user.value @property def body(self): """ :type: string """ return self._body.value @property def commit_id(self): """ :type: string """ return self._commit_id.value @property def state(self): """ :type: string """ return self._state.value @property def html_url(self): """ :type: string """ return self._html_url.value @property def pull_request_url(self): """ :type: string """ return self._pull_request_url.value @property def submitted_at(self): """ :type: datetime.datetime """ return self._submitted_at.value def dismiss(self, message): """ :calls: `PUT /repos/{owner}/{repo}/pulls/{number}/reviews/{review_id}/dismissals `_ :rtype: None """ assert isinstance(message, str), message post_parameters = {"message": message} headers, data = self._requester.requestJsonAndCheck( "PUT", f"{self.pull_request_url}/reviews/{self.id}/dismissals", input=post_parameters, ) def _initAttributes(self): self._id = github.GithubObject.NotSet self._user = github.GithubObject.NotSet self._body = github.GithubObject.NotSet self._commit_id = github.GithubObject.NotSet self._state = github.GithubObject.NotSet self._html_url = github.GithubObject.NotSet self._pull_request_url = github.GithubObject.NotSet self._submitted_at = github.GithubObject.NotSet def _useAttributes(self, attributes): if "id" in attributes: # pragma no branch self._id = self._makeIntAttribute(attributes["id"]) if "user" in attributes: # pragma no branch self._user = self._makeClassAttribute( github.NamedUser.NamedUser, attributes["user"] ) if "body" in attributes: # pragma no branch self._body = self._makeStringAttribute(attributes["body"]) if "commit_id" in attributes: # pragma no branch self._commit_id = self._makeStringAttribute(attributes["commit_id"]) if "state" in attributes: # pragma no branch self._state = self._makeStringAttribute(attributes["state"]) if "html_url" in attributes: # pragma no branch self._html_url = self._makeStringAttribute(attributes["html_url"]) if "pull_request_url" in attributes: # pragma no branch self._pull_request_url = self._makeStringAttribute( attributes["pull_request_url"] ) if "submitted_at" in attributes: # pragma no branch self._submitted_at = self._makeDatetimeAttribute(attributes["submitted_at"]) ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1619412308.0 PyGithub-1.55/github/PullRequestReview.pyi0000644000175100001710000000151600000000000020216 0ustar00runnerdockerfrom datetime import datetime from typing import Any, Dict from github.GithubObject import CompletableGithubObject from github.NamedUser import NamedUser class PullRequestReview(CompletableGithubObject): def __repr__(self) -> str: ... def _initAttributes(self) -> None: ... def _useAttributes(self, attributes: Dict[str, Any]) -> None: ... @property def body(self) -> str: ... @property def commit_id(self) -> str: ... def dismiss(self, message: str) -> None: ... @property def html_url(self) -> str: ... @property def id(self) -> int: ... @property def pull_request_url(self) -> str: ... @property def state(self) -> str: ... @property def submitted_at(self) -> datetime: ... @property def url(self) -> str: ... @property def user(self) -> NamedUser: ... ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1619412308.0 PyGithub-1.55/github/Rate.py0000644000175100001710000000673300000000000015277 0ustar00runnerdocker############################ Copyrights and license ############################ # # # Copyright 2013 Vincent Jacques # # Copyright 2014 Vincent Jacques # # Copyright 2016 Jannis Gebauer # # Copyright 2016 Peter Buckley # # Copyright 2018 Wan Liuyang # # Copyright 2018 sfdye # # # # This file is part of PyGithub. # # http://pygithub.readthedocs.io/ # # # # PyGithub is free software: you can redistribute it and/or modify it under # # the terms of the GNU Lesser General Public License as published by the Free # # Software Foundation, either version 3 of the License, or (at your option) # # any later version. # # # # PyGithub is distributed in the hope that it will be useful, but WITHOUT ANY # # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more # # details. # # # # You should have received a copy of the GNU Lesser General Public License # # along with PyGithub. If not, see . # # # ################################################################################ import github.GithubObject class Rate(github.GithubObject.NonCompletableGithubObject): """ This class represents Rates. The reference can be found here http://docs.github.com/en/rest/reference/rate_limit """ def __repr__(self): return self.get__repr__( { "limit": self._limit.value, "remaining": self._remaining.value, "reset": self._reset.value, } ) @property def limit(self): """ :type: integer """ return self._limit.value @property def remaining(self): """ :type: integer """ return self._remaining.value @property def reset(self): """ :type: datetime.datetime """ return self._reset.value def _initAttributes(self): self._limit = github.GithubObject.NotSet self._remaining = github.GithubObject.NotSet self._reset = github.GithubObject.NotSet def _useAttributes(self, attributes): if "limit" in attributes: # pragma no branch self._limit = self._makeIntAttribute(attributes["limit"]) if "remaining" in attributes: # pragma no branch self._remaining = self._makeIntAttribute(attributes["remaining"]) if "reset" in attributes: # pragma no branch self._reset = self._makeTimestampAttribute(attributes["reset"]) ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1619412308.0 PyGithub-1.55/github/Rate.pyi0000644000175100001710000000070700000000000015443 0ustar00runnerdockerfrom datetime import datetime from typing import Any, Dict from github.GithubObject import NonCompletableGithubObject class Rate(NonCompletableGithubObject): def __repr__(self) -> str: ... def _initAttributes(self) -> None: ... def _useAttributes(self, attributes: Dict[str, Any]) -> None: ... @property def limit(self) -> int: ... @property def remaining(self) -> int: ... @property def reset(self) -> datetime: ... ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1619412308.0 PyGithub-1.55/github/RateLimit.py0000644000175100001710000000722100000000000016267 0ustar00runnerdocker############################ Copyrights and license ############################ # # # Copyright 2013 Vincent Jacques # # Copyright 2014 Vincent Jacques # # Copyright 2016 Jannis Gebauer # # Copyright 2016 Peter Buckley # # Copyright 2018 Wan Liuyang # # Copyright 2018 sfdye # # # # This file is part of PyGithub. # # http://pygithub.readthedocs.io/ # # # # PyGithub is free software: you can redistribute it and/or modify it under # # the terms of the GNU Lesser General Public License as published by the Free # # Software Foundation, either version 3 of the License, or (at your option) # # any later version. # # # # PyGithub is distributed in the hope that it will be useful, but WITHOUT ANY # # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more # # details. # # # # You should have received a copy of the GNU Lesser General Public License # # along with PyGithub. If not, see . # # # ################################################################################ import github.GithubObject import github.Rate class RateLimit(github.GithubObject.NonCompletableGithubObject): """ This class represents RateLimits. The reference can be found here http://docs.github.com/en/rest/reference/rate_limit """ def __repr__(self): return self.get__repr__({"core": self._core.value}) @property def core(self): """ Rate limit for the non-search-related API :type: class:`github.Rate.Rate` """ return self._core.value @property def search(self): """ Rate limit for the Search API. :type: class:`github.Rate.Rate` """ return self._search.value @property def graphql(self): """ (Experimental) Rate limit for GraphQL API, use with caution. :type: class:`github.Rate.Rate` """ return self._graphql.value def _initAttributes(self): self._core = github.GithubObject.NotSet self._search = github.GithubObject.NotSet self._graphql = github.GithubObject.NotSet def _useAttributes(self, attributes): if "core" in attributes: # pragma no branch self._core = self._makeClassAttribute(github.Rate.Rate, attributes["core"]) if "search" in attributes: # pragma no branch self._search = self._makeClassAttribute( github.Rate.Rate, attributes["search"] ) if "graphql" in attributes: # pragma no branch self._graphql = self._makeClassAttribute( github.Rate.Rate, attributes["graphql"] ) ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1619412308.0 PyGithub-1.55/github/RateLimit.pyi0000644000175100001710000000076500000000000016446 0ustar00runnerdockerfrom typing import Any, Dict from github.GithubObject import NonCompletableGithubObject from github.Rate import Rate class RateLimit(NonCompletableGithubObject): def __repr__(self) -> str: ... def _initAttributes(self) -> None: ... def _useAttributes(self, attributes: Dict[str, Any]) -> None: ... @property def core(self) -> Rate: ... @property def graphql(self) -> Rate: ... @property def rate(self) -> Rate: ... @property def search(self) -> Rate: ... ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1619412308.0 PyGithub-1.55/github/Reaction.py0000644000175100001710000001010000000000000016127 0ustar00runnerdocker############################ Copyrights and license ############################ # # # Copyright 2017 Nicolas Agustín Torres # # Copyright 2018 Wan Liuyang # # Copyright 2018 sfdye # # # # This file is part of PyGithub. # # http://pygithub.readthedocs.io/ # # # # PyGithub is free software: you can redistribute it and/or modify it under # # the terms of the GNU Lesser General Public License as published by the Free # # Software Foundation, either version 3 of the License, or (at your option) # # any later version. # # # # PyGithub is distributed in the hope that it will be useful, but WITHOUT ANY # # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more # # details. # # # # You should have received a copy of the GNU Lesser General Public License # # along with PyGithub. If not, see . # # # ################################################################################ import github.GithubObject import github.NamedUser from . import Consts class Reaction(github.GithubObject.CompletableGithubObject): """ This class represents Reactions. The reference can be found here https://docs.github.com/en/rest/reference/reactions """ def __repr__(self): return self.get__repr__({"id": self._id.value, "user": self._user.value}) @property def content(self): """ :type: string """ self._completeIfNotSet(self._content) return self._content.value @property def created_at(self): """ :type: datetime.datetime """ self._completeIfNotSet(self._created_at) return self._created_at.value @property def id(self): """ :type: integer """ self._completeIfNotSet(self._id) return self._id.value @property def user(self): """ :type: :class:`github.NamedUser.NamedUser` """ self._completeIfNotSet(self._user) return self._user.value def delete(self): """ :calls: `DELETE /reactions/{id} `_ :rtype: None """ self._requester.requestJsonAndCheck( "DELETE", f"{self._parentUrl('')}/reactions/{self.id}", headers={"Accept": Consts.mediaTypeReactionsPreview}, ) def _initAttributes(self): self._content = github.GithubObject.NotSet self._created_at = github.GithubObject.NotSet self._id = github.GithubObject.NotSet self._user = github.GithubObject.NotSet def _useAttributes(self, attributes): if "content" in attributes: # pragma no branch self._content = self._makeStringAttribute(attributes["content"]) if "created_at" in attributes: # pragma no branch self._created_at = self._makeDatetimeAttribute(attributes["created_at"]) if "id" in attributes: # pragma no branch self._id = self._makeIntAttribute(attributes["id"]) if "user" in attributes: # pragma no branch self._user = self._makeClassAttribute( github.NamedUser.NamedUser, attributes["user"] ) ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1619412308.0 PyGithub-1.55/github/Reaction.pyi0000644000175100001710000000110100000000000016301 0ustar00runnerdockerfrom datetime import datetime from typing import Any, Dict from github.GithubObject import CompletableGithubObject from github.NamedUser import NamedUser class Reaction(CompletableGithubObject): def __repr__(self) -> str: ... def _initAttributes(self) -> None: ... def _useAttributes(self, attributes: Dict[str, Any]) -> None: ... @property def content(self) -> str: ... @property def created_at(self) -> datetime: ... def delete(self) -> None: ... @property def id(self) -> int: ... @property def user(self) -> NamedUser: ... ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1619412308.0 PyGithub-1.55/github/Referrer.py0000644000175100001710000000666500000000000016164 0ustar00runnerdocker############################ Copyrights and license ############################ # # # Copyright 2018 Justin Kufro # # Copyright 2018 Ivan Minno # # Copyright 2018 Zilei Gu # # Copyright 2018 Yves Zumbach # # Copyright 2018 Leying Chen # # # # This file is part of PyGithub. # # http://pygithub.readthedocs.io/ # # # # PyGithub is free software: you can redistribute it and/or modify it under # # the terms of the GNU Lesser General Public License as published by the Free # # Software Foundation, either version 3 of the License, or (at your option) # # any later version. # # # # PyGithub is distributed in the hope that it will be useful, but WITHOUT ANY # # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more # # details. # # # # You should have received a copy of the GNU Lesser General Public License # # along with PyGithub. If not, see . # # # ################################################################################ import github.GithubObject class Referrer(github.GithubObject.NonCompletableGithubObject): """ This class represents a popylar Referrer for a GitHub repository. The reference can be found here https://docs.github.com/en/rest/reference/repos#traffic """ def __repr__(self): return self.get__repr__( { "referrer": self._referrer.value, "count": self._count.value, "uniques": self._uniques.value, } ) @property def referrer(self): """ :type: string """ return self._referrer.value @property def count(self): """ :type: integer """ return self._count.value @property def uniques(self): """ :type: integer """ return self._uniques.value def _initAttributes(self): self._referrer = github.GithubObject.NotSet self._count = github.GithubObject.NotSet self._uniques = github.GithubObject.NotSet def _useAttributes(self, attributes): if "referrer" in attributes: # pragma no branch self._referrer = self._makeStringAttribute(attributes["referrer"]) if "count" in attributes: # pragma no branch self._count = self._makeIntAttribute(attributes["count"]) if "uniques" in attributes: # pragma no branch self._uniques = self._makeIntAttribute(attributes["uniques"]) ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1619412308.0 PyGithub-1.55/github/Referrer.pyi0000644000175100001710000000065100000000000016322 0ustar00runnerdockerfrom typing import Any, Dict from github.GithubObject import NonCompletableGithubObject class Referrer(NonCompletableGithubObject): def __repr__(self) -> str: ... def _initAttributes(self) -> None: ... def _useAttributes(self, attributes: Dict[str, Any]) -> None: ... @property def count(self) -> str: ... @property def referrer(self) -> str: ... @property def uniques(self) -> int: ... ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1619412308.0 PyGithub-1.55/github/Repository.py0000644000175100001710000046574700000000000016601 0ustar00runnerdocker############################ Copyrights and license ############################ # # # Copyright 2012 Christopher Gilbert # # Copyright 2012 Steve English # # Copyright 2012 Vincent Jacques # # Copyright 2012 Zearin # # Copyright 2013 AKFish # # Copyright 2013 Adrian Petrescu # # Copyright 2013 Cameron White # # Copyright 2013 David Farr # # Copyright 2013 Mark Roddy # # Copyright 2013 Vincent Jacques # # Copyright 2013 martinqt # # Copyright 2014 Vincent Jacques # # Copyright 2015 Aaron Levine # # Copyright 2015 Christopher Wilcox # # Copyright 2015 Dan Vanderkam # # Copyright 2015 Ed Holland # # Copyright 2015 Enix Yu # # Copyright 2015 Jay # # Copyright 2015 Jimmy Zelinskie # # Copyright 2015 Jonathan Debonis # # Copyright 2015 Kevin Lewandowski # # Copyright 2015 Kyle Hornberg # # Copyright 2015 edhollandAL # # Copyright 2016 @tmshn # # Copyright 2016 Dustin Spicuzza # # Copyright 2016 Enix Yu # # Copyright 2016 Jannis Gebauer # # Copyright 2016 Per Øyvind Karlsen # # Copyright 2016 Peter Buckley # # Copyright 2016 Sylvus # # Copyright 2016 fukatani # # Copyright 2016 ghfan # # Copyright 2017 Andreas Lutro # # Copyright 2017 Ben Firshman # # Copyright 2017 Chris McBride # # Copyright 2017 Hugo # # Copyright 2017 Jannis Gebauer # # Copyright 2017 Jason White # # Copyright 2017 Jimmy Zelinskie # # Copyright 2017 Nhomar Hernández [Vauxoo] # # Copyright 2017 Simon # # Copyright 2018 Andrew Smith # # Copyright 2018 Brian Torres-Gil # # Copyright 2018 Hayden Fuss # # Copyright 2018 Ilya Konstantinov # # Copyright 2018 Jacopo Notarstefano # # Copyright 2018 John Hui # # Copyright 2018 Mateusz Loskot # # Copyright 2018 Michael Behrisch # # Copyright 2018 Nicholas Buse # # Copyright 2018 Raihaan <31362124+res0nance@users.noreply.github.com> # # Copyright 2018 Shinichi TAMURA # # Copyright 2018 Steve Kowalik # # Copyright 2018 Wan Liuyang # # Copyright 2018 Will Yardley # # Copyright 2018 per1234 # # Copyright 2018 sechastain # # Copyright 2018 sfdye # # Copyright 2018 Vinay Hegde # # Copyright 2018 Justin Kufro # # Copyright 2018 Ivan Minno # # Copyright 2018 Zilei Gu # # Copyright 2018 Yves Zumbach # # Copyright 2018 Leying Chen # # Copyright 2020 Pascal Hofmann # # # # This file is part of PyGithub. # # http://pygithub.readthedocs.io/ # # # # PyGithub is free software: you can redistribute it and/or modify it under # # the terms of the GNU Lesser General Public License as published by the Free # # Software Foundation, either version 3 of the License, or (at your option) # # any later version. # # # # PyGithub is distributed in the hope that it will be useful, but WITHOUT ANY # # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more # # details. # # # # You should have received a copy of the GNU Lesser General Public License # # along with PyGithub. If not, see . # # # ################################################################################ import collections import datetime import urllib.parse from base64 import b64encode from deprecated import deprecated import github.Branch import github.CheckRun import github.CheckSuite import github.Clones import github.Commit import github.CommitComment import github.Comparison import github.ContentFile import github.Deployment import github.Download import github.Event import github.GitBlob import github.GitCommit import github.GithubObject import github.GitRef import github.GitRelease import github.GitReleaseAsset import github.GitTag import github.GitTree import github.Hook import github.Invitation import github.Issue import github.IssueEvent import github.Label import github.Milestone import github.NamedUser import github.Organization import github.PaginatedList import github.Path import github.Permissions import github.Project import github.PublicKey import github.PullRequest import github.Referrer import github.Repository import github.RepositoryKey import github.RepositoryPreferences import github.SelfHostedActionsRunner import github.SourceImport import github.Stargazer import github.StatsCodeFrequency import github.StatsCommitActivity import github.StatsContributor import github.StatsParticipation import github.StatsPunchCard import github.Tag import github.Team import github.View import github.Workflow import github.WorkflowRun from . import Consts class Repository(github.GithubObject.CompletableGithubObject): """ This class represents Repositories. The reference can be found here http://docs.github.com/en/rest/reference/repos """ def __repr__(self): return self.get__repr__({"full_name": self._full_name.value}) @property def allow_merge_commit(self): """ :type: bool """ self._completeIfNotSet(self._allow_merge_commit) return self._allow_merge_commit.value @property def allow_rebase_merge(self): """ :type: bool """ self._completeIfNotSet(self._allow_rebase_merge) return self._allow_rebase_merge.value @property def allow_squash_merge(self): """ :type: bool """ self._completeIfNotSet(self._allow_squash_merge) return self._allow_squash_merge.value @property def archived(self): """ :type: bool """ self._completeIfNotSet(self._archived) return self._archived.value @property def archive_url(self): """ :type: string """ self._completeIfNotSet(self._archive_url) return self._archive_url.value @property def assignees_url(self): """ :type: string """ self._completeIfNotSet(self._assignees_url) return self._assignees_url.value @property def blobs_url(self): """ :type: string """ self._completeIfNotSet(self._blobs_url) return self._blobs_url.value @property def branches_url(self): """ :type: string """ self._completeIfNotSet(self._branches_url) return self._branches_url.value @property def clone_url(self): """ :type: string """ self._completeIfNotSet(self._clone_url) return self._clone_url.value @property def collaborators_url(self): """ :type: string """ self._completeIfNotSet(self._collaborators_url) return self._collaborators_url.value @property def comments_url(self): """ :type: string """ self._completeIfNotSet(self._comments_url) return self._comments_url.value @property def commits_url(self): """ :type: string """ self._completeIfNotSet(self._commits_url) return self._commits_url.value @property def compare_url(self): """ :type: string """ self._completeIfNotSet(self._compare_url) return self._compare_url.value @property def contents_url(self): """ :type: string """ self._completeIfNotSet(self._contents_url) return self._contents_url.value @property def contributors_url(self): """ :type: string """ self._completeIfNotSet(self._contributors_url) return self._contributors_url.value @property def created_at(self): """ :type: datetime.datetime """ self._completeIfNotSet(self._created_at) return self._created_at.value @property def default_branch(self): """ :type: string """ self._completeIfNotSet(self._default_branch) return self._default_branch.value @property def delete_branch_on_merge(self): """ :type: bool """ self._completeIfNotSet(self._delete_branch_on_merge) return self._delete_branch_on_merge.value @property def deployments_url(self): """ :type: string """ self._completeIfNotSet(self._deployments_url) return self._deployments_url.value @property def description(self): """ :type: string """ self._completeIfNotSet(self._description) return self._description.value @property def downloads_url(self): """ :type: string """ self._completeIfNotSet(self._downloads_url) return self._downloads_url.value @property def events_url(self): """ :type: string """ self._completeIfNotSet(self._events_url) return self._events_url.value @property def fork(self): """ :type: bool """ self._completeIfNotSet(self._fork) return self._fork.value @property def forks(self): """ :type: integer """ self._completeIfNotSet(self._forks) return self._forks.value @property def forks_count(self): """ :type: integer """ self._completeIfNotSet(self._forks_count) return self._forks_count.value @property def forks_url(self): """ :type: string """ self._completeIfNotSet(self._forks_url) return self._forks_url.value @property def full_name(self): """ :type: string """ self._completeIfNotSet(self._full_name) return self._full_name.value @property def git_commits_url(self): """ :type: string """ self._completeIfNotSet(self._git_commits_url) return self._git_commits_url.value @property def git_refs_url(self): """ :type: string """ self._completeIfNotSet(self._git_refs_url) return self._git_refs_url.value @property def git_tags_url(self): """ :type: string """ self._completeIfNotSet(self._git_tags_url) return self._git_tags_url.value @property def git_url(self): """ :type: string """ self._completeIfNotSet(self._git_url) return self._git_url.value @property def has_downloads(self): """ :type: bool """ self._completeIfNotSet(self._has_downloads) return self._has_downloads.value @property def has_issues(self): """ :type: bool """ self._completeIfNotSet(self._has_issues) return self._has_issues.value @property def has_pages(self): """ :type: bool """ self._completeIfNotSet(self._has_pages) return self._has_pages.value @property def has_projects(self): """ :type: bool """ self._completeIfNotSet(self._has_projects) return self._has_projects.value @property def has_wiki(self): """ :type: bool """ self._completeIfNotSet(self._has_wiki) return self._has_wiki.value @property def homepage(self): """ :type: string """ self._completeIfNotSet(self._homepage) return self._homepage.value @property def hooks_url(self): """ :type: string """ self._completeIfNotSet(self._hooks_url) return self._hooks_url.value @property def html_url(self): """ :type: string """ self._completeIfNotSet(self._html_url) return self._html_url.value @property def id(self): """ :type: integer """ self._completeIfNotSet(self._id) return self._id.value @property def issue_comment_url(self): """ :type: string """ self._completeIfNotSet(self._issue_comment_url) return self._issue_comment_url.value @property def issue_events_url(self): """ :type: string """ self._completeIfNotSet(self._issue_events_url) return self._issue_events_url.value @property def issues_url(self): """ :type: string """ self._completeIfNotSet(self._issues_url) return self._issues_url.value @property def keys_url(self): """ :type: string """ self._completeIfNotSet(self._keys_url) return self._keys_url.value @property def labels_url(self): """ :type: string """ self._completeIfNotSet(self._labels_url) return self._labels_url.value @property def language(self): """ :type: string """ self._completeIfNotSet(self._language) return self._language.value @property def languages_url(self): """ :type: string """ self._completeIfNotSet(self._languages_url) return self._languages_url.value @property def master_branch(self): """ :type: string """ self._completeIfNotSet(self._master_branch) return self._master_branch.value @property def merges_url(self): """ :type: string """ self._completeIfNotSet(self._merges_url) return self._merges_url.value @property def milestones_url(self): """ :type: string """ self._completeIfNotSet(self._milestones_url) return self._milestones_url.value @property def mirror_url(self): """ :type: string """ self._completeIfNotSet(self._mirror_url) return self._mirror_url.value @property def name(self): """ :type: string """ self._completeIfNotSet(self._name) return self._name.value @property def network_count(self): """ :type: integer """ self._completeIfNotSet(self._network_count) return self._network_count.value @property def notifications_url(self): """ :type: string """ self._completeIfNotSet(self._notifications_url) return self._notifications_url.value @property def open_issues(self): """ :type: integer """ self._completeIfNotSet(self._open_issues) return self._open_issues.value @property def open_issues_count(self): """ :type: integer """ self._completeIfNotSet(self._open_issues_count) return self._open_issues_count.value @property def organization(self): """ :type: :class:`github.Organization.Organization` """ self._completeIfNotSet(self._organization) return self._organization.value @property def owner(self): """ :type: :class:`github.NamedUser.NamedUser` """ self._completeIfNotSet(self._owner) return self._owner.value @property def parent(self): """ :type: :class:`github.Repository.Repository` """ self._completeIfNotSet(self._parent) return self._parent.value @property def permissions(self): """ :type: :class:`github.Permissions.Permissions` """ self._completeIfNotSet(self._permissions) return self._permissions.value @property def private(self): """ :type: bool """ self._completeIfNotSet(self._private) return self._private.value @property def pulls_url(self): """ :type: string """ self._completeIfNotSet(self._pulls_url) return self._pulls_url.value @property def pushed_at(self): """ :type: datetime.datetime """ self._completeIfNotSet(self._pushed_at) return self._pushed_at.value @property def releases_url(self): """ :type: string """ self._completeIfNotSet(self._releases_url) return self._releases_url.value @property def size(self): """ :type: integer """ self._completeIfNotSet(self._size) return self._size.value @property def source(self): """ :type: :class:`github.Repository.Repository` """ self._completeIfNotSet(self._source) return self._source.value @property def ssh_url(self): """ :type: string """ self._completeIfNotSet(self._ssh_url) return self._ssh_url.value @property def stargazers_count(self): """ :type: integer """ self._completeIfNotSet( self._stargazers_count ) # pragma no cover (Should be covered) return self._stargazers_count.value # pragma no cover (Should be covered) @property def stargazers_url(self): """ :type: string """ self._completeIfNotSet(self._stargazers_url) return self._stargazers_url.value @property def statuses_url(self): """ :type: string """ self._completeIfNotSet(self._statuses_url) return self._statuses_url.value @property def subscribers_url(self): """ :type: string """ self._completeIfNotSet(self._subscribers_url) return self._subscribers_url.value @property def subscribers_count(self): """ :type: integer """ self._completeIfNotSet(self._subscribers_count) return self._subscribers_count.value @property def subscription_url(self): """ :type: string """ self._completeIfNotSet(self._subscription_url) return self._subscription_url.value @property def svn_url(self): """ :type: string """ self._completeIfNotSet(self._svn_url) return self._svn_url.value @property def tags_url(self): """ :type: string """ self._completeIfNotSet(self._tags_url) return self._tags_url.value @property def teams_url(self): """ :type: string """ self._completeIfNotSet(self._teams_url) return self._teams_url.value @property def trees_url(self): """ :type: string """ self._completeIfNotSet(self._trees_url) return self._trees_url.value @property def updated_at(self): """ :type: datetime.datetime """ self._completeIfNotSet(self._updated_at) return self._updated_at.value @property def url(self): """ :type: string """ self._completeIfNotSet(self._url) return self._url.value @property def watchers(self): """ :type: integer """ self._completeIfNotSet(self._watchers) return self._watchers.value @property def watchers_count(self): """ :type: integer """ self._completeIfNotSet(self._watchers_count) return self._watchers_count.value def add_to_collaborators(self, collaborator, permission=github.GithubObject.NotSet): """ :calls: `PUT /repos/{owner}/{repo}/collaborators/{user} `_ :param collaborator: string or :class:`github.NamedUser.NamedUser` :param permission: string 'pull', 'push' or 'admin' :rtype: None """ assert isinstance(collaborator, github.NamedUser.NamedUser) or isinstance( collaborator, str ), collaborator assert permission is github.GithubObject.NotSet or isinstance( permission, str ), permission if isinstance(collaborator, github.NamedUser.NamedUser): collaborator = collaborator._identity if permission is not github.GithubObject.NotSet: put_parameters = {"permission": permission} else: put_parameters = None headers, data = self._requester.requestJsonAndCheck( "PUT", f"{self.url}/collaborators/{collaborator}", input=put_parameters ) # return an invitation object if there's data returned by the API. If data is empty # there's a pending invitation for the given user. return ( github.Invitation.Invitation(self._requester, headers, data, completed=True) if data is not None else None ) def get_collaborator_permission(self, collaborator): """ :calls: `GET /repos/{owner}/{repo}/collaborators/{username}/permission `_ :param collaborator: string or :class:`github.NamedUser.NamedUser` :rtype: string """ assert isinstance(collaborator, github.NamedUser.NamedUser) or isinstance( collaborator, str ), collaborator if isinstance(collaborator, github.NamedUser.NamedUser): collaborator = collaborator._identity headers, data = self._requester.requestJsonAndCheck( "GET", f"{self.url}/collaborators/{collaborator}/permission", ) return data["permission"] def get_pending_invitations(self): """ :calls: `GET /repos/{owner}/{repo}/invitations `_ :rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.Invitation.Invitation` """ return github.PaginatedList.PaginatedList( github.Invitation.Invitation, self._requester, f"{self.url}/invitations", None, ) def remove_invitation(self, invite_id): """ :calls: `DELETE /repos/{owner}/{repo}/invitations/{invitation_id} `_ :rtype: None """ assert isinstance(invite_id, int), invite_id headers, data = self._requester.requestJsonAndCheck( "DELETE", f"{self.url}/invitations/{invite_id}" ) def compare(self, base, head): """ :calls: `GET /repos/{owner}/{repo}/compare/{base...:head} `_ :param base: string :param head: string :rtype: :class:`github.Comparison.Comparison` """ assert isinstance(base, str), base assert isinstance(head, str), head headers, data = self._requester.requestJsonAndCheck( "GET", f"{self.url}/compare/{base}...{head}" ) return github.Comparison.Comparison( self._requester, headers, data, completed=True ) def create_git_blob(self, content, encoding): """ :calls: `POST /repos/{owner}/{repo}/git/blobs `_ :param content: string :param encoding: string :rtype: :class:`github.GitBlob.GitBlob` """ assert isinstance(content, str), content assert isinstance(encoding, str), encoding post_parameters = { "content": content, "encoding": encoding, } headers, data = self._requester.requestJsonAndCheck( "POST", f"{self.url}/git/blobs", input=post_parameters ) return github.GitBlob.GitBlob(self._requester, headers, data, completed=True) def create_git_commit( self, message, tree, parents, author=github.GithubObject.NotSet, committer=github.GithubObject.NotSet, ): """ :calls: `POST /repos/{owner}/{repo}/git/commits `_ :param message: string :param tree: :class:`github.GitTree.GitTree` :param parents: list of :class:`github.GitCommit.GitCommit` :param author: :class:`github.InputGitAuthor.InputGitAuthor` :param committer: :class:`github.InputGitAuthor.InputGitAuthor` :rtype: :class:`github.GitCommit.GitCommit` """ assert isinstance(message, str), message assert isinstance(tree, github.GitTree.GitTree), tree assert all( isinstance(element, github.GitCommit.GitCommit) for element in parents ), parents assert author is github.GithubObject.NotSet or isinstance( author, github.InputGitAuthor ), author assert committer is github.GithubObject.NotSet or isinstance( committer, github.InputGitAuthor ), committer post_parameters = { "message": message, "tree": tree._identity, "parents": [element._identity for element in parents], } if author is not github.GithubObject.NotSet: post_parameters["author"] = author._identity if committer is not github.GithubObject.NotSet: post_parameters["committer"] = committer._identity headers, data = self._requester.requestJsonAndCheck( "POST", f"{self.url}/git/commits", input=post_parameters ) return github.GitCommit.GitCommit( self._requester, headers, data, completed=True ) def create_git_ref(self, ref, sha): """ :calls: `POST /repos/{owner}/{repo}/git/refs `_ :param ref: string :param sha: string :rtype: :class:`github.GitRef.GitRef` """ assert isinstance(ref, str), ref assert isinstance(sha, str), sha post_parameters = { "ref": ref, "sha": sha, } headers, data = self._requester.requestJsonAndCheck( "POST", f"{self.url}/git/refs", input=post_parameters ) return github.GitRef.GitRef(self._requester, headers, data, completed=True) def create_git_tag_and_release( self, tag, tag_message, release_name, release_message, object, type, tagger=github.GithubObject.NotSet, draft=False, prerelease=False, ): """ Convenience function that calls :meth:`Repository.create_git_tag` and :meth:`Repository.create_git_release`. :param tag: string :param tag_message: string :param release_name: string :param release_message: string :param object: string :param type: string :param tagger: :class:github.InputGitAuthor.InputGitAuthor :param draft: bool :param prerelease: bool :rtype: :class:`github.GitRelease.GitRelease` """ self.create_git_tag(tag, tag_message, object, type, tagger) return self.create_git_release( tag, release_name, release_message, draft, prerelease, target_commitish=object, ) def create_git_release( self, tag, name, message, draft=False, prerelease=False, target_commitish=github.GithubObject.NotSet, ): """ :calls: `POST /repos/{owner}/{repo}/releases `_ :param tag: string :param name: string :param message: string :param draft: bool :param prerelease: bool :param target_commitish: string or :class:`github.Branch.Branch` or :class:`github.Commit.Commit` or :class:`github.GitCommit.GitCommit` :rtype: :class:`github.GitRelease.GitRelease` """ assert isinstance(tag, str), tag assert isinstance(name, str), name assert isinstance(message, str), message assert isinstance(draft, bool), draft assert isinstance(prerelease, bool), prerelease assert target_commitish is github.GithubObject.NotSet or isinstance( target_commitish, ( str, github.Branch.Branch, github.Commit.Commit, github.GitCommit.GitCommit, ), ), target_commitish post_parameters = { "tag_name": tag, "name": name, "body": message, "draft": draft, "prerelease": prerelease, } if isinstance(target_commitish, str): post_parameters["target_commitish"] = target_commitish elif isinstance(target_commitish, github.Branch.Branch): post_parameters["target_commitish"] = target_commitish.name elif isinstance( target_commitish, (github.Commit.Commit, github.GitCommit.GitCommit) ): post_parameters["target_commitish"] = target_commitish.sha headers, data = self._requester.requestJsonAndCheck( "POST", f"{self.url}/releases", input=post_parameters ) return github.GitRelease.GitRelease( self._requester, headers, data, completed=True ) def create_git_tag( self, tag, message, object, type, tagger=github.GithubObject.NotSet ): """ :calls: `POST /repos/{owner}/{repo}/git/tags `_ :param tag: string :param message: string :param object: string :param type: string :param tagger: :class:`github.InputGitAuthor.InputGitAuthor` :rtype: :class:`github.GitTag.GitTag` """ assert isinstance(tag, str), tag assert isinstance(message, str), message assert isinstance(object, str), object assert isinstance(type, str), type assert tagger is github.GithubObject.NotSet or isinstance( tagger, github.InputGitAuthor ), tagger post_parameters = { "tag": tag, "message": message, "object": object, "type": type, } if tagger is not github.GithubObject.NotSet: post_parameters["tagger"] = tagger._identity headers, data = self._requester.requestJsonAndCheck( "POST", f"{self.url}/git/tags", input=post_parameters ) return github.GitTag.GitTag(self._requester, headers, data, completed=True) def create_git_tree(self, tree, base_tree=github.GithubObject.NotSet): """ :calls: `POST /repos/{owner}/{repo}/git/trees `_ :param tree: list of :class:`github.InputGitTreeElement.InputGitTreeElement` :param base_tree: :class:`github.GitTree.GitTree` :rtype: :class:`github.GitTree.GitTree` """ assert all( isinstance(element, github.InputGitTreeElement) for element in tree ), tree assert base_tree is github.GithubObject.NotSet or isinstance( base_tree, github.GitTree.GitTree ), base_tree post_parameters = { "tree": [element._identity for element in tree], } if base_tree is not github.GithubObject.NotSet: post_parameters["base_tree"] = base_tree._identity headers, data = self._requester.requestJsonAndCheck( "POST", f"{self.url}/git/trees", input=post_parameters ) return github.GitTree.GitTree(self._requester, headers, data, completed=True) def create_hook( self, name, config, events=github.GithubObject.NotSet, active=github.GithubObject.NotSet, ): """ :calls: `POST /repos/{owner}/{repo}/hooks `_ :param name: string :param config: dict :param events: list of string :param active: bool :rtype: :class:`github.Hook.Hook` """ assert isinstance(name, str), name assert isinstance(config, dict), config assert events is github.GithubObject.NotSet or all( isinstance(element, str) for element in events ), events assert active is github.GithubObject.NotSet or isinstance(active, bool), active post_parameters = { "name": name, "config": config, } if events is not github.GithubObject.NotSet: post_parameters["events"] = events if active is not github.GithubObject.NotSet: post_parameters["active"] = active headers, data = self._requester.requestJsonAndCheck( "POST", f"{self.url}/hooks", input=post_parameters ) return github.Hook.Hook(self._requester, headers, data, completed=True) def create_issue( self, title, body=github.GithubObject.NotSet, assignee=github.GithubObject.NotSet, milestone=github.GithubObject.NotSet, labels=github.GithubObject.NotSet, assignees=github.GithubObject.NotSet, ): """ :calls: `POST /repos/{owner}/{repo}/issues `_ :param title: string :param body: string :param assignee: string or :class:`github.NamedUser.NamedUser` :param assignees: list of string or :class:`github.NamedUser.NamedUser` :param milestone: :class:`github.Milestone.Milestone` :param labels: list of :class:`github.Label.Label` :rtype: :class:`github.Issue.Issue` """ assert isinstance(title, str), title assert body is github.GithubObject.NotSet or isinstance(body, str), body assert ( assignee is github.GithubObject.NotSet or isinstance(assignee, github.NamedUser.NamedUser) or isinstance(assignee, str) ), assignee assert assignees is github.GithubObject.NotSet or all( isinstance(element, github.NamedUser.NamedUser) or isinstance(element, str) for element in assignees ), assignees assert milestone is github.GithubObject.NotSet or isinstance( milestone, github.Milestone.Milestone ), milestone assert labels is github.GithubObject.NotSet or all( isinstance(element, github.Label.Label) or isinstance(element, str) for element in labels ), labels post_parameters = { "title": title, } if body is not github.GithubObject.NotSet: post_parameters["body"] = body if assignee is not github.GithubObject.NotSet: if isinstance(assignee, str): post_parameters["assignee"] = assignee else: post_parameters["assignee"] = assignee._identity if assignees is not github.GithubObject.NotSet: post_parameters["assignees"] = [ element._identity if isinstance(element, github.NamedUser.NamedUser) else element for element in assignees ] if milestone is not github.GithubObject.NotSet: post_parameters["milestone"] = milestone._identity if labels is not github.GithubObject.NotSet: post_parameters["labels"] = [ element.name if isinstance(element, github.Label.Label) else element for element in labels ] headers, data = self._requester.requestJsonAndCheck( "POST", f"{self.url}/issues", input=post_parameters ) return github.Issue.Issue(self._requester, headers, data, completed=True) def create_key(self, title, key, read_only=False): """ :calls: `POST /repos/{owner}/{repo}/keys `_ :param title: string :param key: string :param read_only: bool :rtype: :class:`github.RepositoryKey.RepositoryKey` """ assert isinstance(title, str), title assert isinstance(key, str), key assert isinstance(read_only, bool), read_only post_parameters = { "title": title, "key": key, "read_only": read_only, } headers, data = self._requester.requestJsonAndCheck( "POST", f"{self.url}/keys", input=post_parameters ) return github.RepositoryKey.RepositoryKey( self._requester, headers, data, completed=True ) def create_label(self, name, color, description=github.GithubObject.NotSet): """ :calls: `POST /repos/{owner}/{repo}/labels `_ :param name: string :param color: string :param description: string :rtype: :class:`github.Label.Label` """ assert isinstance(name, str), name assert isinstance(color, str), color assert description is github.GithubObject.NotSet or isinstance( description, str ), description post_parameters = { "name": name, "color": color, } if description is not github.GithubObject.NotSet: post_parameters["description"] = description headers, data = self._requester.requestJsonAndCheck( "POST", f"{self.url}/labels", input=post_parameters, headers={"Accept": Consts.mediaTypeLabelDescriptionSearchPreview}, ) return github.Label.Label(self._requester, headers, data, completed=True) def create_milestone( self, title, state=github.GithubObject.NotSet, description=github.GithubObject.NotSet, due_on=github.GithubObject.NotSet, ): """ :calls: `POST /repos/{owner}/{repo}/milestones `_ :param title: string :param state: string :param description: string :param due_on: datetime :rtype: :class:`github.Milestone.Milestone` """ assert isinstance(title, str), title assert state is github.GithubObject.NotSet or isinstance(state, str), state assert description is github.GithubObject.NotSet or isinstance( description, str ), description assert due_on is github.GithubObject.NotSet or isinstance( due_on, (datetime.datetime, datetime.date) ), due_on post_parameters = { "title": title, } if state is not github.GithubObject.NotSet: post_parameters["state"] = state if description is not github.GithubObject.NotSet: post_parameters["description"] = description if due_on is not github.GithubObject.NotSet: if isinstance(due_on, datetime.date): post_parameters["due_on"] = due_on.strftime("%Y-%m-%dT%H:%M:%SZ") else: post_parameters["due_on"] = due_on.isoformat() headers, data = self._requester.requestJsonAndCheck( "POST", f"{self.url}/milestones", input=post_parameters ) return github.Milestone.Milestone( self._requester, headers, data, completed=True ) def create_project(self, name, body=github.GithubObject.NotSet): """ :calls: `POST /repos/{owner}/{repo}/projects `_ :param name: string :param body: string :rtype: :class:`github.Project.Project` """ assert isinstance(name, str), name assert body is github.GithubObject.NotSet or isinstance(body, str), body post_parameters = { "name": name, } import_header = {"Accept": Consts.mediaTypeProjectsPreview} if body is not github.GithubObject.NotSet: post_parameters["body"] = body headers, data = self._requester.requestJsonAndCheck( "POST", f"{self.url}/projects", headers=import_header, input=post_parameters ) return github.Project.Project(self._requester, headers, data, completed=True) def create_pull(self, *args, **kwds): """ :calls: `POST /repos/{owner}/{repo}/pulls `_ :param title: string :param body: string :param issue: :class:`github.Issue.Issue` :param base: string :param head: string :param draft: bool :param maintainer_can_modify: bool :rtype: :class:`github.PullRequest.PullRequest` """ if len(args) + len(kwds) >= 4: return self.__create_pull_1(*args, **kwds) else: return self.__create_pull_2(*args, **kwds) def __create_pull_1( self, title, body, base, head, maintainer_can_modify=github.GithubObject.NotSet, draft=False, ): assert isinstance(title, str), title assert isinstance(body, str), body assert isinstance(base, str), base assert isinstance(head, str), head assert maintainer_can_modify is github.GithubObject.NotSet or isinstance( maintainer_can_modify, bool ), maintainer_can_modify assert isinstance(draft, bool), draft if maintainer_can_modify is not github.GithubObject.NotSet: return self.__create_pull( title=title, body=body, base=base, head=head, maintainer_can_modify=maintainer_can_modify, draft=draft, ) else: return self.__create_pull( title=title, body=body, base=base, head=head, draft=draft ) def __create_pull_2(self, issue, base, head): assert isinstance(issue, github.Issue.Issue), issue assert isinstance(base, str), base assert isinstance(head, str), head return self.__create_pull(issue=issue._identity, base=base, head=head) def __create_pull(self, **kwds): post_parameters = kwds headers, data = self._requester.requestJsonAndCheck( "POST", f"{self.url}/pulls", input=post_parameters ) return github.PullRequest.PullRequest( self._requester, headers, data, completed=True ) def create_repository_dispatch( self, event_type, client_payload=github.GithubObject.NotSet ): """ :calls: POST /repos/{owner}/{repo}/dispatches :param event_type: string :param client_payload: dict :rtype: bool """ assert isinstance(event_type, str), event_type assert client_payload is github.GithubObject.NotSet or isinstance( client_payload, dict ), client_payload post_parameters = {"event_type": event_type} if client_payload is not github.GithubObject.NotSet: post_parameters["client_payload"] = client_payload status, headers, data = self._requester.requestJson( "POST", f"{self.url}/dispatches", input=post_parameters ) return status == 204 def create_secret(self, secret_name, unencrypted_value): """ :calls: `PUT /repos/{owner}/{repo}/actions/secrets/{secret_name} `_ :param secret_name: string :param unencrypted_value: string :rtype: bool """ assert isinstance(secret_name, str), secret_name assert isinstance(unencrypted_value, str), unencrypted_value public_key = self.get_public_key() payload = public_key.encrypt(unencrypted_value) put_parameters = { "key_id": public_key.key_id, "encrypted_value": payload, } status, headers, data = self._requester.requestJson( "PUT", f"{self.url}/actions/secrets/{secret_name}", input=put_parameters ) return status == 201 def delete_secret(self, secret_name): """ :calls: `DELETE /repos/{owner}/{repo}/actions/secrets/{secret_name} `_ :param secret_name: string :rtype: bool """ assert isinstance(secret_name, str), secret_name status, headers, data = self._requester.requestJson( "DELETE", f"{self.url}/actions/secrets/{secret_name}" ) return status == 204 def create_source_import( self, vcs, vcs_url, vcs_username=github.GithubObject.NotSet, vcs_password=github.GithubObject.NotSet, ): """ :calls: `PUT /repos/{owner}/{repo}/import `_ :param vcs: string :param vcs_url: string :param vcs_username: string :param vcs_password: string :rtype: :class:`github.SourceImport.SourceImport` """ assert isinstance(vcs, str), vcs assert isinstance(vcs_url, str), vcs_url assert vcs_username is github.GithubObject.NotSet or isinstance( vcs_username, str ), vcs_username assert vcs_password is github.GithubObject.NotSet or isinstance( vcs_password, str ), vcs_password put_parameters = {"vcs": vcs, "vcs_url": vcs_url} if vcs_username is not github.GithubObject.NotSet: put_parameters["vcs_username"] = vcs_username if vcs_password is not github.GithubObject.NotSet: put_parameters["vcs_password"] = vcs_password import_header = {"Accept": Consts.mediaTypeImportPreview} headers, data = self._requester.requestJsonAndCheck( "PUT", f"{self.url}/import", headers=import_header, input=put_parameters ) return github.SourceImport.SourceImport( self._requester, headers, data, completed=False ) def delete(self): """ :calls: `DELETE /repos/{owner}/{repo} `_ :rtype: None """ headers, data = self._requester.requestJsonAndCheck("DELETE", self.url) def edit( self, name=None, description=github.GithubObject.NotSet, homepage=github.GithubObject.NotSet, private=github.GithubObject.NotSet, has_issues=github.GithubObject.NotSet, has_projects=github.GithubObject.NotSet, has_wiki=github.GithubObject.NotSet, has_downloads=github.GithubObject.NotSet, default_branch=github.GithubObject.NotSet, allow_squash_merge=github.GithubObject.NotSet, allow_merge_commit=github.GithubObject.NotSet, allow_rebase_merge=github.GithubObject.NotSet, delete_branch_on_merge=github.GithubObject.NotSet, archived=github.GithubObject.NotSet, ): """ :calls: `PATCH /repos/{owner}/{repo} `_ :param name: string :param description: string :param homepage: string :param private: bool :param has_issues: bool :param has_projects: bool :param has_wiki: bool :param has_downloads: bool :param default_branch: string :param allow_squash_merge: bool :param allow_merge_commit: bool :param allow_rebase_merge: bool :param delete_branch_on_merge: bool :param archived: bool. Unarchiving repositories is currently not supported through API (https://docs.github.com/en/rest/reference/repos#edit) :rtype: None """ if name is None: name = self.name assert isinstance(name, str), name assert description is github.GithubObject.NotSet or isinstance( description, str ), description assert homepage is github.GithubObject.NotSet or isinstance( homepage, str ), homepage assert private is github.GithubObject.NotSet or isinstance( private, bool ), private assert has_issues is github.GithubObject.NotSet or isinstance( has_issues, bool ), has_issues assert has_projects is github.GithubObject.NotSet or isinstance( has_projects, bool ), has_projects assert has_wiki is github.GithubObject.NotSet or isinstance( has_wiki, bool ), has_wiki assert has_downloads is github.GithubObject.NotSet or isinstance( has_downloads, bool ), has_downloads assert default_branch is github.GithubObject.NotSet or isinstance( default_branch, str ), default_branch assert allow_squash_merge is github.GithubObject.NotSet or isinstance( allow_squash_merge, bool ), allow_squash_merge assert allow_merge_commit is github.GithubObject.NotSet or isinstance( allow_merge_commit, bool ), allow_merge_commit assert allow_rebase_merge is github.GithubObject.NotSet or isinstance( allow_rebase_merge, bool ), allow_rebase_merge assert delete_branch_on_merge is github.GithubObject.NotSet or isinstance( delete_branch_on_merge, bool ), delete_branch_on_merge assert archived is github.GithubObject.NotSet or ( isinstance(archived, bool) and archived is True ), archived post_parameters = { "name": name, } if description is not github.GithubObject.NotSet: post_parameters["description"] = description if homepage is not github.GithubObject.NotSet: post_parameters["homepage"] = homepage if private is not github.GithubObject.NotSet: post_parameters["private"] = private if has_issues is not github.GithubObject.NotSet: post_parameters["has_issues"] = has_issues if has_projects is not github.GithubObject.NotSet: post_parameters["has_projects"] = has_projects if has_wiki is not github.GithubObject.NotSet: post_parameters["has_wiki"] = has_wiki if has_downloads is not github.GithubObject.NotSet: post_parameters["has_downloads"] = has_downloads if default_branch is not github.GithubObject.NotSet: post_parameters["default_branch"] = default_branch if allow_squash_merge is not github.GithubObject.NotSet: post_parameters["allow_squash_merge"] = allow_squash_merge if allow_merge_commit is not github.GithubObject.NotSet: post_parameters["allow_merge_commit"] = allow_merge_commit if allow_rebase_merge is not github.GithubObject.NotSet: post_parameters["allow_rebase_merge"] = allow_rebase_merge if delete_branch_on_merge is not github.GithubObject.NotSet: post_parameters["delete_branch_on_merge"] = delete_branch_on_merge if archived is not github.GithubObject.NotSet: post_parameters["archived"] = archived headers, data = self._requester.requestJsonAndCheck( "PATCH", self.url, input=post_parameters ) self._useAttributes(data) def get_archive_link(self, archive_format, ref=github.GithubObject.NotSet): """ :calls: `GET /repos/{owner}/{repo}/{archive_format}/{ref} `_ :param archive_format: string :param ref: string :rtype: string """ assert isinstance(archive_format, str), archive_format assert ref is github.GithubObject.NotSet or isinstance(ref, str), ref url = f"{self.url}/{archive_format}" if ref is not github.GithubObject.NotSet: url += f"/{ref}" headers, data = self._requester.requestJsonAndCheck("GET", url) return headers["location"] def get_assignees(self): """ :calls: `GET /repos/{owner}/{repo}/assignees `_ :rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.NamedUser.NamedUser` """ return github.PaginatedList.PaginatedList( github.NamedUser.NamedUser, self._requester, f"{self.url}/assignees", None ) def get_branch(self, branch): """ :calls: `GET /repos/{owner}/{repo}/branches/{branch} `_ :param branch: string :rtype: :class:`github.Branch.Branch` """ assert isinstance(branch, str), branch headers, data = self._requester.requestJsonAndCheck( "GET", f"{self.url}/branches/{branch}" ) return github.Branch.Branch(self._requester, headers, data, completed=True) def get_branches(self): """ :calls: `GET /repos/{owner}/{repo}/branches `_ :rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.Branch.Branch` """ return github.PaginatedList.PaginatedList( github.Branch.Branch, self._requester, f"{self.url}/branches", None ) def get_collaborators(self, affiliation=github.GithubObject.NotSet): """ :calls: `GET /repos/{owner}/{repo}/collaborators `_ :param affiliation: string :rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.NamedUser.NamedUser` """ url_parameters = dict() allowed_affiliations = ["outside", "direct", "all"] if affiliation is not github.GithubObject.NotSet: assert isinstance(affiliation, str), affiliation assert ( affiliation in allowed_affiliations ), f"Affiliation can be one of {', '.join(allowed_affiliations)}" url_parameters["affiliation"] = affiliation return github.PaginatedList.PaginatedList( github.NamedUser.NamedUser, self._requester, f"{self.url}/collaborators", url_parameters, ) def get_comment(self, id): """ :calls: `GET /repos/{owner}/{repo}/comments/{id} `_ :param id: integer :rtype: :class:`github.CommitComment.CommitComment` """ assert isinstance(id, int), id headers, data = self._requester.requestJsonAndCheck( "GET", f"{self.url}/comments/{id}" ) return github.CommitComment.CommitComment( self._requester, headers, data, completed=True ) def get_comments(self): """ :calls: `GET /repos/{owner}/{repo}/comments `_ :rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.CommitComment.CommitComment` """ return github.PaginatedList.PaginatedList( github.CommitComment.CommitComment, self._requester, f"{self.url}/comments", None, ) def get_commit(self, sha): """ :calls: `GET /repos/{owner}/{repo}/commits/{sha} `_ :param sha: string :rtype: :class:`github.Commit.Commit` """ assert isinstance(sha, str), sha headers, data = self._requester.requestJsonAndCheck( "GET", f"{self.url}/commits/{sha}" ) return github.Commit.Commit(self._requester, headers, data, completed=True) def get_commits( self, sha=github.GithubObject.NotSet, path=github.GithubObject.NotSet, since=github.GithubObject.NotSet, until=github.GithubObject.NotSet, author=github.GithubObject.NotSet, ): """ :calls: `GET /repos/{owner}/{repo}/commits `_ :param sha: string :param path: string :param since: datetime.datetime :param until: datetime.datetime :param author: string or :class:`github.NamedUser.NamedUser` or :class:`github.AuthenticatedUser.AuthenticatedUser` :rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.Commit.Commit` """ assert sha is github.GithubObject.NotSet or isinstance(sha, str), sha assert path is github.GithubObject.NotSet or isinstance(path, str), path assert since is github.GithubObject.NotSet or isinstance( since, datetime.datetime ), since assert until is github.GithubObject.NotSet or isinstance( until, datetime.datetime ), until assert author is github.GithubObject.NotSet or isinstance( author, ( str, github.NamedUser.NamedUser, github.AuthenticatedUser.AuthenticatedUser, ), ), author url_parameters = dict() if sha is not github.GithubObject.NotSet: url_parameters["sha"] = sha if path is not github.GithubObject.NotSet: url_parameters["path"] = path if since is not github.GithubObject.NotSet: url_parameters["since"] = since.strftime("%Y-%m-%dT%H:%M:%SZ") if until is not github.GithubObject.NotSet: url_parameters["until"] = until.strftime("%Y-%m-%dT%H:%M:%SZ") if author is not github.GithubObject.NotSet: if isinstance( author, ( github.NamedUser.NamedUser, github.AuthenticatedUser.AuthenticatedUser, ), ): url_parameters["author"] = author.login else: url_parameters["author"] = author return github.PaginatedList.PaginatedList( github.Commit.Commit, self._requester, f"{self.url}/commits", url_parameters ) def get_contents(self, path, ref=github.GithubObject.NotSet): """ :calls: `GET /repos/{owner}/{repo}/contents/{path} `_ :param path: string :param ref: string :rtype: :class:`github.ContentFile.ContentFile` or a list of them """ assert isinstance(path, str), path assert ref is github.GithubObject.NotSet or isinstance(ref, str), ref # Path of '/' should be the empty string. if path == "/": path = "" url_parameters = dict() if ref is not github.GithubObject.NotSet: url_parameters["ref"] = ref headers, data = self._requester.requestJsonAndCheck( "GET", f"{self.url}/contents/{urllib.parse.quote(path)}", parameters=url_parameters, ) # Handle 302 redirect response if headers.get("status") == "302 Found" and headers.get("location"): headers, data = self._requester.requestJsonAndCheck( "GET", headers["location"], parameters=url_parameters ) if isinstance(data, list): return [ # Lazy completion only makes sense for files. See discussion # here: https://github.com/jacquev6/PyGithub/issues/140#issuecomment-13481130 github.ContentFile.ContentFile( self._requester, headers, item, completed=(item["type"] != "file") ) for item in data ] return github.ContentFile.ContentFile( self._requester, headers, data, completed=True ) def get_deployments( self, sha=github.GithubObject.NotSet, ref=github.GithubObject.NotSet, task=github.GithubObject.NotSet, environment=github.GithubObject.NotSet, ): """ :calls: `GET /repos/{owner}/{repo}/deployments `_ :param: sha: string :param: ref: string :param: task: string :param: environment: string :rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.Deployment.Deployment` """ assert sha is github.GithubObject.NotSet or isinstance(sha, str), sha assert ref is github.GithubObject.NotSet or isinstance(ref, str), ref assert task is github.GithubObject.NotSet or isinstance(task, str), task assert environment is github.GithubObject.NotSet or isinstance( environment, str ), environment parameters = {} if sha is not github.GithubObject.NotSet: parameters["sha"] = sha if ref is not github.GithubObject.NotSet: parameters["ref"] = ref if task is not github.GithubObject.NotSet: parameters["task"] = task if environment is not github.GithubObject.NotSet: parameters["environment"] = environment return github.PaginatedList.PaginatedList( github.Deployment.Deployment, self._requester, f"{self.url}/deployments", parameters, headers={"Accept": Consts.deploymentEnhancementsPreview}, ) def get_deployment(self, id_): """ :calls: `GET /repos/{owner}/{repo}/deployments/{deployment_id} `_ :param: id_: int :rtype: :class:`github.Deployment.Deployment` """ assert isinstance(id_, int), id_ headers, data = self._requester.requestJsonAndCheck( "GET", f"{self.url}/deployments/{id_}", headers={"Accept": Consts.deploymentEnhancementsPreview}, ) return github.Deployment.Deployment( self._requester, headers, data, completed=True ) def create_deployment( self, ref, task=github.GithubObject.NotSet, auto_merge=github.GithubObject.NotSet, required_contexts=github.GithubObject.NotSet, payload=github.GithubObject.NotSet, environment=github.GithubObject.NotSet, description=github.GithubObject.NotSet, transient_environment=github.GithubObject.NotSet, production_environment=github.GithubObject.NotSet, ): """ :calls: `POST /repos/{owner}/{repo}/deployments `_ :param: ref: string :param: task: string :param: auto_merge: bool :param: required_contexts: list of status contexts :param: payload: dict :param: environment: string :param: description: string :param: transient_environment: bool :param: production_environment: bool :rtype: :class:`github.Deployment.Deployment` """ assert isinstance(ref, str), ref assert task is github.GithubObject.NotSet or isinstance(task, str), task assert auto_merge is github.GithubObject.NotSet or isinstance( auto_merge, bool ), auto_merge assert required_contexts is github.GithubObject.NotSet or isinstance( required_contexts, list ), required_contexts # need to do better checking here assert payload is github.GithubObject.NotSet or isinstance( payload, dict ), payload assert environment is github.GithubObject.NotSet or isinstance( environment, str ), environment assert description is github.GithubObject.NotSet or isinstance( description, str ), description assert transient_environment is github.GithubObject.NotSet or isinstance( transient_environment, bool ), transient_environment assert production_environment is github.GithubObject.NotSet or isinstance( production_environment, bool ), production_environment post_parameters = {"ref": ref} if task is not github.GithubObject.NotSet: post_parameters["task"] = task if auto_merge is not github.GithubObject.NotSet: post_parameters["auto_merge"] = auto_merge if required_contexts is not github.GithubObject.NotSet: post_parameters["required_contexts"] = required_contexts if payload is not github.GithubObject.NotSet: post_parameters["payload"] = payload if environment is not github.GithubObject.NotSet: post_parameters["environment"] = environment if description is not github.GithubObject.NotSet: post_parameters["description"] = description if transient_environment is not github.GithubObject.NotSet: post_parameters["transient_environment"] = transient_environment if production_environment is not github.GithubObject.NotSet: post_parameters["production_environment"] = production_environment headers, data = self._requester.requestJsonAndCheck( "POST", f"{self.url}/deployments", input=post_parameters, headers={"Accept": Consts.deploymentEnhancementsPreview}, ) return github.Deployment.Deployment( self._requester, headers, data, completed=True ) def get_top_referrers(self): """ :calls: `GET /repos/{owner}/{repo}/traffic/popular/referrers `_ :rtype: :class:`list` of :class:`github.Referrer.Referrer` """ headers, data = self._requester.requestJsonAndCheck( "GET", f"{self.url}/traffic/popular/referrers" ) if isinstance(data, list): return [ github.Referrer.Referrer(self._requester, headers, item, completed=True) for item in data ] def get_top_paths(self): """ :calls: `GET /repos/{owner}/{repo}/traffic/popular/paths `_ :rtype: :class:`list` of :class:`github.Path.Path` """ headers, data = self._requester.requestJsonAndCheck( "GET", f"{self.url}/traffic/popular/paths" ) if isinstance(data, list): return [ github.Path.Path(self._requester, headers, item, completed=True) for item in data ] def get_views_traffic(self, per=github.GithubObject.NotSet): """ :calls: `GET /repos/{owner}/{repo}/traffic/views `_ :param per: string, must be one of day or week, day by default :rtype: None or list of :class:`github.View.View` """ assert per is github.GithubObject.NotSet or ( isinstance(per, str) and (per == "day" or per == "week") ), "per must be day or week, day by default" url_parameters = dict() if per is not github.GithubObject.NotSet: url_parameters["per"] = per headers, data = self._requester.requestJsonAndCheck( "GET", f"{self.url}/traffic/views", parameters=url_parameters ) if ( (isinstance(data, dict)) and ("views" in data) and (isinstance(data["views"], list)) ): data["views"] = [ github.View.View(self._requester, headers, item, completed=True) for item in data["views"] ] return data def get_clones_traffic(self, per=github.GithubObject.NotSet): """ :calls: `GET /repos/{owner}/{repo}/traffic/clones `_ :param per: string, must be one of day or week, day by default :rtype: None or list of :class:`github.Clones.Clones` """ assert per is github.GithubObject.NotSet or ( isinstance(per, str) and (per == "day" or per == "week") ), "per must be day or week, day by default" url_parameters = dict() if per is not github.GithubObject.NotSet: url_parameters["per"] = per headers, data = self._requester.requestJsonAndCheck( "GET", f"{self.url}/traffic/clones", parameters=url_parameters ) if ( (isinstance(data, dict)) and ("clones" in data) and (isinstance(data["clones"], list)) ): data["clones"] = [ github.Clones.Clones(self._requester, headers, item, completed=True) for item in data["clones"] ] return data def get_projects(self, state=github.GithubObject.NotSet): """ :calls: `GET /repos/{owner}/{repo}/projects `_ :rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.Project.Project` :param state: string """ url_parameters = dict() if state is not github.GithubObject.NotSet: url_parameters["state"] = state return github.PaginatedList.PaginatedList( github.Project.Project, self._requester, f"{self.url}/projects", url_parameters, {"Accept": Consts.mediaTypeProjectsPreview}, ) def create_file( self, path, message, content, branch=github.GithubObject.NotSet, committer=github.GithubObject.NotSet, author=github.GithubObject.NotSet, ): """Create a file in this repository. :calls: `PUT /repos/{owner}/{repo}/contents/{path} `_ :param path: string, (required), path of the file in the repository :param message: string, (required), commit message :param content: string, (required), the actual data in the file :param branch: string, (optional), branch to create the commit on. Defaults to the default branch of the repository :param committer: InputGitAuthor, (optional), if no information is given the authenticated user's information will be used. You must specify both a name and email. :param author: InputGitAuthor, (optional), if omitted this will be filled in with committer information. If passed, you must specify both a name and email. :rtype: { 'content': :class:`ContentFile `:, 'commit': :class:`Commit `} """ assert isinstance(path, str) assert isinstance(message, str) assert isinstance(content, (str, bytes)) assert branch is github.GithubObject.NotSet or isinstance(branch, str) assert author is github.GithubObject.NotSet or isinstance( author, github.InputGitAuthor ) assert committer is github.GithubObject.NotSet or isinstance( committer, github.InputGitAuthor ) if not isinstance(content, bytes): content = content.encode("utf-8") content = b64encode(content).decode("utf-8") put_parameters = {"message": message, "content": content} if branch is not github.GithubObject.NotSet: put_parameters["branch"] = branch if author is not github.GithubObject.NotSet: put_parameters["author"] = author._identity if committer is not github.GithubObject.NotSet: put_parameters["committer"] = committer._identity headers, data = self._requester.requestJsonAndCheck( "PUT", f"{self.url}/contents/{urllib.parse.quote(path)}", input=put_parameters, ) return { "content": github.ContentFile.ContentFile( self._requester, headers, data["content"], completed=False ), "commit": github.Commit.Commit( self._requester, headers, data["commit"], completed=True ), } def update_file( self, path, message, content, sha, branch=github.GithubObject.NotSet, committer=github.GithubObject.NotSet, author=github.GithubObject.NotSet, ): """This method updates a file in a repository :calls: `PUT /repos/{owner}/{repo}/contents/{path} `_ :param path: string, Required. The content path. :param message: string, Required. The commit message. :param content: string, Required. The updated file content, either base64 encoded, or ready to be encoded. :param sha: string, Required. The blob SHA of the file being replaced. :param branch: string. The branch name. Default: the repository’s default branch (usually master) :param committer: InputGitAuthor, (optional), if no information is given the authenticated user's information will be used. You must specify both a name and email. :param author: InputGitAuthor, (optional), if omitted this will be filled in with committer information. If passed, you must specify both a name and email. :rtype: { 'content': :class:`ContentFile `:, 'commit': :class:`Commit `} """ assert isinstance(path, str) assert isinstance(message, str) assert isinstance(content, (str, bytes)) assert isinstance(sha, str) assert branch is github.GithubObject.NotSet or isinstance(branch, str) assert author is github.GithubObject.NotSet or isinstance( author, github.InputGitAuthor ) assert committer is github.GithubObject.NotSet or isinstance( committer, github.InputGitAuthor ) if not isinstance(content, bytes): content = content.encode("utf-8") content = b64encode(content).decode("utf-8") put_parameters = {"message": message, "content": content, "sha": sha} if branch is not github.GithubObject.NotSet: put_parameters["branch"] = branch if author is not github.GithubObject.NotSet: put_parameters["author"] = author._identity if committer is not github.GithubObject.NotSet: put_parameters["committer"] = committer._identity headers, data = self._requester.requestJsonAndCheck( "PUT", f"{self.url}/contents/{urllib.parse.quote(path)}", input=put_parameters, ) return { "commit": github.Commit.Commit( self._requester, headers, data["commit"], completed=True ), "content": github.ContentFile.ContentFile( self._requester, headers, data["content"], completed=False ), } def delete_file( self, path, message, sha, branch=github.GithubObject.NotSet, committer=github.GithubObject.NotSet, author=github.GithubObject.NotSet, ): """This method deletes a file in a repository :calls: `DELETE /repos/{owner}/{repo}/contents/{path} `_ :param path: string, Required. The content path. :param message: string, Required. The commit message. :param sha: string, Required. The blob SHA of the file being replaced. :param branch: string. The branch name. Default: the repository’s default branch (usually master) :param committer: InputGitAuthor, (optional), if no information is given the authenticated user's information will be used. You must specify both a name and email. :param author: InputGitAuthor, (optional), if omitted this will be filled in with committer information. If passed, you must specify both a name and email. :rtype: { 'content': :class:`null `:, 'commit': :class:`Commit `} """ assert isinstance(path, str), "path must be str/unicode object" assert isinstance(message, str), "message must be str/unicode object" assert isinstance(sha, str), "sha must be a str/unicode object" assert branch is github.GithubObject.NotSet or isinstance( branch, str ), "branch must be a str/unicode object" assert author is github.GithubObject.NotSet or isinstance( author, github.InputGitAuthor ), "author must be a github.InputGitAuthor object" assert committer is github.GithubObject.NotSet or isinstance( committer, github.InputGitAuthor ), "committer must be a github.InputGitAuthor object" url_parameters = {"message": message, "sha": sha} if branch is not github.GithubObject.NotSet: url_parameters["branch"] = branch if author is not github.GithubObject.NotSet: url_parameters["author"] = author._identity if committer is not github.GithubObject.NotSet: url_parameters["committer"] = committer._identity headers, data = self._requester.requestJsonAndCheck( "DELETE", f"{self.url}/contents/{urllib.parse.quote(path)}", input=url_parameters, ) return { "commit": github.Commit.Commit( self._requester, headers, data["commit"], completed=True ), "content": github.GithubObject.NotSet, } @deprecated( reason=""" Repository.get_dir_contents() is deprecated, use Repository.get_contents() instead. """ ) def get_dir_contents(self, path, ref=github.GithubObject.NotSet): """ :calls: `GET /repos/{owner}/{repo}/contents/{path} `_ :param path: string :param ref: string :rtype: list of :class:`github.ContentFile.ContentFile` """ return self.get_contents(path, ref=ref) def get_contributors(self, anon=github.GithubObject.NotSet): """ :calls: `GET /repos/{owner}/{repo}/contributors `_ :param anon: string :rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.NamedUser.NamedUser` """ url_parameters = dict() if anon is not github.GithubObject.NotSet: url_parameters["anon"] = anon return github.PaginatedList.PaginatedList( github.NamedUser.NamedUser, self._requester, f"{self.url}/contributors", url_parameters, ) def get_download(self, id): """ :calls: `GET /repos/{owner}/{repo}/downloads/{id} `_ :param id: integer :rtype: :class:`github.Download.Download` """ assert isinstance(id, int), id headers, data = self._requester.requestJsonAndCheck( "GET", f"{self.url}/downloads/{id}" ) return github.Download.Download(self._requester, headers, data, completed=True) def get_downloads(self): """ :calls: `GET /repos/{owner}/{repo}/downloads `_ :rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.Download.Download` """ return github.PaginatedList.PaginatedList( github.Download.Download, self._requester, f"{self.url}/downloads", None ) def get_events(self): """ :calls: `GET /repos/{owner}/{repo}/events `_ :rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.Event.Event` """ return github.PaginatedList.PaginatedList( github.Event.Event, self._requester, f"{self.url}/events", None ) def get_forks(self): """ :calls: `GET /repos/{owner}/{repo}/forks `_ :rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.Repository.Repository` """ return github.PaginatedList.PaginatedList( Repository, self._requester, f"{self.url}/forks", None ) def create_fork(self, organization=github.GithubObject.NotSet): """ :calls: `POST /repos/{owner}/{repo}/forks `_ :param organization: string or "none" or "*" :rtype: :class:`github.Repository.Repository` """ assert organization is github.GithubObject.NotSet or isinstance( organization, str ), organization post_parameters = {} if organization is not github.GithubObject.NotSet: post_parameters["organization"] = organization headers, data = self._requester.requestJsonAndCheck( "POST", f"{self.url}/forks", input=post_parameters, ) return Repository(self._requester, headers, data, completed=True) def get_git_blob(self, sha): """ :calls: `GET /repos/{owner}/{repo}/git/blobs/{sha} `_ :param sha: string :rtype: :class:`github.GitBlob.GitBlob` """ assert isinstance(sha, str), sha headers, data = self._requester.requestJsonAndCheck( "GET", f"{self.url}/git/blobs/{sha}" ) return github.GitBlob.GitBlob(self._requester, headers, data, completed=True) def get_git_commit(self, sha): """ :calls: `GET /repos/{owner}/{repo}/git/commits/{sha} `_ :param sha: string :rtype: :class:`github.GitCommit.GitCommit` """ assert isinstance(sha, str), sha headers, data = self._requester.requestJsonAndCheck( "GET", f"{self.url}/git/commits/{sha}" ) return github.GitCommit.GitCommit( self._requester, headers, data, completed=True ) def get_git_ref(self, ref): """ :calls: `GET /repos/{owner}/{repo}/git/refs/{ref} `_ :param ref: string :rtype: :class:`github.GitRef.GitRef` """ prefix = "/git/refs/" if not self._requester.FIX_REPO_GET_GIT_REF: prefix = "/git/" assert isinstance(ref, str), ref headers, data = self._requester.requestJsonAndCheck( "GET", f"{self.url}{prefix}{ref}" ) return github.GitRef.GitRef(self._requester, headers, data, completed=True) def get_git_refs(self): """ :calls: `GET /repos/{owner}/{repo}/git/refs `_ :rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.GitRef.GitRef` """ return github.PaginatedList.PaginatedList( github.GitRef.GitRef, self._requester, f"{self.url}/git/refs", None ) def get_git_matching_refs(self, ref): """ :calls: `GET /repos/{owner}/{repo}/git/matching-refs/{ref} ` :rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.GitRef.GitRef` """ assert isinstance(ref, str), ref return github.PaginatedList.PaginatedList( github.GitRef.GitRef, self._requester, f"{self.url}/git/matching-refs/{ref}", None, ) def get_git_tag(self, sha): """ :calls: `GET /repos/{owner}/{repo}/git/tags/{sha} `_ :param sha: string :rtype: :class:`github.GitTag.GitTag` """ assert isinstance(sha, str), sha headers, data = self._requester.requestJsonAndCheck( "GET", f"{self.url}/git/tags/{sha}" ) return github.GitTag.GitTag(self._requester, headers, data, completed=True) def get_git_tree(self, sha, recursive=github.GithubObject.NotSet): """ :calls: `GET /repos/{owner}/{repo}/git/trees/{sha} `_ :param sha: string :param recursive: bool :rtype: :class:`github.GitTree.GitTree` """ assert isinstance(sha, str), sha assert recursive is github.GithubObject.NotSet or isinstance( recursive, bool ), recursive url_parameters = dict() if recursive is not github.GithubObject.NotSet and recursive: # GitHub API requires the recursive parameter be set to 1. url_parameters["recursive"] = 1 headers, data = self._requester.requestJsonAndCheck( "GET", f"{self.url}/git/trees/{sha}", parameters=url_parameters ) return github.GitTree.GitTree(self._requester, headers, data, completed=True) def get_hook(self, id): """ :calls: `GET /repos/{owner}/{repo}/hooks/{id} `_ :param id: integer :rtype: :class:`github.Hook.Hook` """ assert isinstance(id, int), id headers, data = self._requester.requestJsonAndCheck( "GET", f"{self.url}/hooks/{id}" ) return github.Hook.Hook(self._requester, headers, data, completed=True) def get_hooks(self): """ :calls: `GET /repos/{owner}/{repo}/hooks `_ :rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.Hook.Hook` """ return github.PaginatedList.PaginatedList( github.Hook.Hook, self._requester, f"{self.url}/hooks", None ) def get_issue(self, number): """ :calls: `GET /repos/{owner}/{repo}/issues/{number} `_ :param number: integer :rtype: :class:`github.Issue.Issue` """ assert isinstance(number, int), number headers, data = self._requester.requestJsonAndCheck( "GET", f"{self.url}/issues/{number}" ) return github.Issue.Issue(self._requester, headers, data, completed=True) def get_issues( self, milestone=github.GithubObject.NotSet, state=github.GithubObject.NotSet, assignee=github.GithubObject.NotSet, mentioned=github.GithubObject.NotSet, labels=github.GithubObject.NotSet, sort=github.GithubObject.NotSet, direction=github.GithubObject.NotSet, since=github.GithubObject.NotSet, creator=github.GithubObject.NotSet, ): """ :calls: `GET /repos/{owner}/{repo}/issues `_ :param milestone: :class:`github.Milestone.Milestone` or "none" or "*" :param state: string. `open`, `closed`, or `all`. If this is not set the GitHub API default behavior will be used. At the moment this is to return only open issues. This might change anytime on GitHub API side and it could be clever to explicitly specify the state value. :param assignee: string or :class:`github.NamedUser.NamedUser` or "none" or "*" :param mentioned: :class:`github.NamedUser.NamedUser` :param labels: list of string or :class:`github.Label.Label` :param sort: string :param direction: string :param since: datetime.datetime :param creator: string or :class:`github.NamedUser.NamedUser` :rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.Issue.Issue` """ assert ( milestone is github.GithubObject.NotSet or milestone == "*" or milestone == "none" or isinstance(milestone, github.Milestone.Milestone) ), milestone assert state is github.GithubObject.NotSet or isinstance(state, str), state assert ( assignee is github.GithubObject.NotSet or isinstance(assignee, github.NamedUser.NamedUser) or isinstance(assignee, str) ), assignee assert mentioned is github.GithubObject.NotSet or isinstance( mentioned, github.NamedUser.NamedUser ), mentioned assert labels is github.GithubObject.NotSet or all( isinstance(element, github.Label.Label) or isinstance(element, str) for element in labels ), labels assert sort is github.GithubObject.NotSet or isinstance(sort, str), sort assert direction is github.GithubObject.NotSet or isinstance( direction, str ), direction assert since is github.GithubObject.NotSet or isinstance( since, datetime.datetime ), since assert ( creator is github.GithubObject.NotSet or isinstance(creator, github.NamedUser.NamedUser) or isinstance(creator, str) ), creator url_parameters = dict() if milestone is not github.GithubObject.NotSet: if isinstance(milestone, str): url_parameters["milestone"] = milestone else: url_parameters["milestone"] = milestone._identity if state is not github.GithubObject.NotSet: url_parameters["state"] = state if assignee is not github.GithubObject.NotSet: if isinstance(assignee, str): url_parameters["assignee"] = assignee else: url_parameters["assignee"] = assignee._identity if mentioned is not github.GithubObject.NotSet: url_parameters["mentioned"] = mentioned._identity if labels is not github.GithubObject.NotSet: url_parameters["labels"] = ",".join( [ label.name if isinstance(label, github.Label.Label) else label for label in labels ] ) if sort is not github.GithubObject.NotSet: url_parameters["sort"] = sort if direction is not github.GithubObject.NotSet: url_parameters["direction"] = direction if since is not github.GithubObject.NotSet: url_parameters["since"] = since.strftime("%Y-%m-%dT%H:%M:%SZ") if creator is not github.GithubObject.NotSet: if isinstance(creator, str): url_parameters["creator"] = creator else: url_parameters["creator"] = creator._identity return github.PaginatedList.PaginatedList( github.Issue.Issue, self._requester, f"{self.url}/issues", url_parameters ) def get_issues_comments( self, sort=github.GithubObject.NotSet, direction=github.GithubObject.NotSet, since=github.GithubObject.NotSet, ): """ :calls: `GET /repos/{owner}/{repo}/issues/comments `_ :param sort: string :param direction: string :param since: datetime.datetime :rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.IssueComment.IssueComment` """ assert sort is github.GithubObject.NotSet or isinstance(sort, str), sort assert direction is github.GithubObject.NotSet or isinstance( direction, str ), direction assert since is github.GithubObject.NotSet or isinstance( since, datetime.datetime ), since url_parameters = dict() if sort is not github.GithubObject.NotSet: url_parameters["sort"] = sort if direction is not github.GithubObject.NotSet: url_parameters["direction"] = direction if since is not github.GithubObject.NotSet: url_parameters["since"] = since.strftime("%Y-%m-%dT%H:%M:%SZ") return github.PaginatedList.PaginatedList( github.IssueComment.IssueComment, self._requester, f"{self.url}/issues/comments", url_parameters, ) def get_issues_event(self, id): """ :calls: `GET /repos/{owner}/{repo}/issues/events/{id} `_ :param id: integer :rtype: :class:`github.IssueEvent.IssueEvent` """ assert isinstance(id, int), id headers, data = self._requester.requestJsonAndCheck( "GET", f"{self.url}/issues/events/{id}", headers={"Accept": Consts.mediaTypeLockReasonPreview}, ) return github.IssueEvent.IssueEvent( self._requester, headers, data, completed=True ) def get_issues_events(self): """ :calls: `GET /repos/{owner}/{repo}/issues/events `_ :rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.IssueEvent.IssueEvent` """ return github.PaginatedList.PaginatedList( github.IssueEvent.IssueEvent, self._requester, f"{self.url}/issues/events", None, headers={"Accept": Consts.mediaTypeLockReasonPreview}, ) def get_key(self, id): """ :calls: `GET /repos/{owner}/{repo}/keys/{id} `_ :param id: integer :rtype: :class:`github.RepositoryKey.RepositoryKey` """ assert isinstance(id, int), id headers, data = self._requester.requestJsonAndCheck( "GET", f"{self.url}/keys/{id}" ) return github.RepositoryKey.RepositoryKey( self._requester, headers, data, completed=True ) def get_keys(self): """ :calls: `GET /repos/{owner}/{repo}/keys `_ :rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.RepositoryKey.RepositoryKey` """ return github.PaginatedList.PaginatedList( github.RepositoryKey.RepositoryKey, self._requester, f"{self.url}/keys", None, ) def get_label(self, name): """ :calls: `GET /repos/{owner}/{repo}/labels/{name} `_ :param name: string :rtype: :class:`github.Label.Label` """ assert isinstance(name, str), name headers, data = self._requester.requestJsonAndCheck( "GET", f"{self.url}/labels/{urllib.parse.quote(name)}" ) return github.Label.Label(self._requester, headers, data, completed=True) def get_labels(self): """ :calls: `GET /repos/{owner}/{repo}/labels `_ :rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.Label.Label` """ return github.PaginatedList.PaginatedList( github.Label.Label, self._requester, f"{self.url}/labels", None ) def get_languages(self): """ :calls: `GET /repos/{owner}/{repo}/languages `_ :rtype: dict of string to integer """ headers, data = self._requester.requestJsonAndCheck( "GET", f"{self.url}/languages" ) return data def get_license(self): """ :calls: `GET /repos/{owner}/{repo}/license `_ :rtype: :class:`github.ContentFile.ContentFile` """ headers, data = self._requester.requestJsonAndCheck( "GET", f"{self.url}/license" ) return github.ContentFile.ContentFile( self._requester, headers, data, completed=True ) def get_milestone(self, number): """ :calls: `GET /repos/{owner}/{repo}/milestones/{number} `_ :param number: integer :rtype: :class:`github.Milestone.Milestone` """ assert isinstance(number, int), number headers, data = self._requester.requestJsonAndCheck( "GET", f"{self.url}/milestones/{number}" ) return github.Milestone.Milestone( self._requester, headers, data, completed=True ) def get_milestones( self, state=github.GithubObject.NotSet, sort=github.GithubObject.NotSet, direction=github.GithubObject.NotSet, ): """ :calls: `GET /repos/{owner}/{repo}/milestones `_ :param state: string :param sort: string :param direction: string :rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.Milestone.Milestone` """ assert state is github.GithubObject.NotSet or isinstance(state, str), state assert sort is github.GithubObject.NotSet or isinstance(sort, str), sort assert direction is github.GithubObject.NotSet or isinstance( direction, str ), direction url_parameters = dict() if state is not github.GithubObject.NotSet: url_parameters["state"] = state if sort is not github.GithubObject.NotSet: url_parameters["sort"] = sort if direction is not github.GithubObject.NotSet: url_parameters["direction"] = direction return github.PaginatedList.PaginatedList( github.Milestone.Milestone, self._requester, f"{self.url}/milestones", url_parameters, ) def get_network_events(self): """ :calls: `GET /networks/{owner}/{repo}/events `_ :rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.Event.Event` """ return github.PaginatedList.PaginatedList( github.Event.Event, self._requester, f"/networks/{self.owner.login}/{self.name}/events", None, ) def get_public_key(self): """ :calls: `GET /repos/{owner}/{repo}/actions/secrets/public-key `_ :rtype: :class:`github.PublicKey.PublicKey` """ headers, data = self._requester.requestJsonAndCheck( "GET", f"{self.url}/actions/secrets/public-key" ) return github.PublicKey.PublicKey( self._requester, headers, data, completed=True ) def get_pull(self, number): """ :calls: `GET /repos/{owner}/{repo}/pulls/{number} `_ :param number: integer :rtype: :class:`github.PullRequest.PullRequest` """ assert isinstance(number, int), number headers, data = self._requester.requestJsonAndCheck( "GET", f"{self.url}/pulls/{number}" ) return github.PullRequest.PullRequest( self._requester, headers, data, completed=True ) def get_pulls( self, state=github.GithubObject.NotSet, sort=github.GithubObject.NotSet, direction=github.GithubObject.NotSet, base=github.GithubObject.NotSet, head=github.GithubObject.NotSet, ): """ :calls: `GET /repos/{owner}/{repo}/pulls `_ :param state: string :param sort: string :param direction: string :param base: string :param head: string :rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.PullRequest.PullRequest` """ assert state is github.GithubObject.NotSet or isinstance(state, str), state assert sort is github.GithubObject.NotSet or isinstance(sort, str), sort assert direction is github.GithubObject.NotSet or isinstance( direction, str ), direction assert base is github.GithubObject.NotSet or isinstance(base, str), base assert head is github.GithubObject.NotSet or isinstance(head, str), head url_parameters = dict() if state is not github.GithubObject.NotSet: url_parameters["state"] = state if sort is not github.GithubObject.NotSet: url_parameters["sort"] = sort if direction is not github.GithubObject.NotSet: url_parameters["direction"] = direction if base is not github.GithubObject.NotSet: url_parameters["base"] = base if head is not github.GithubObject.NotSet: url_parameters["head"] = head return github.PaginatedList.PaginatedList( github.PullRequest.PullRequest, self._requester, f"{self.url}/pulls", url_parameters, ) def get_pulls_comments( self, sort=github.GithubObject.NotSet, direction=github.GithubObject.NotSet, since=github.GithubObject.NotSet, ): """ :calls: `GET /repos/{owner}/{repo}/pulls/comments `_ :param sort: string :param direction: string :param since: datetime.datetime :rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.PullRequestComment.PullRequestComment` """ return self.get_pulls_review_comments(sort, direction, since) def get_pulls_review_comments( self, sort=github.GithubObject.NotSet, direction=github.GithubObject.NotSet, since=github.GithubObject.NotSet, ): """ :calls: `GET /repos/{owner}/{repo}/pulls/comments `_ :param sort: string :param direction: string :param since: datetime.datetime :rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.PullRequestComment.PullRequestComment` """ assert sort is github.GithubObject.NotSet or isinstance(sort, str), sort assert direction is github.GithubObject.NotSet or isinstance( direction, str ), direction assert since is github.GithubObject.NotSet or isinstance( since, datetime.datetime ), since url_parameters = dict() if sort is not github.GithubObject.NotSet: url_parameters["sort"] = sort if direction is not github.GithubObject.NotSet: url_parameters["direction"] = direction if since is not github.GithubObject.NotSet: url_parameters["since"] = since.strftime("%Y-%m-%dT%H:%M:%SZ") return github.PaginatedList.PaginatedList( github.PullRequestComment.PullRequestComment, self._requester, f"{self.url}/pulls/comments", url_parameters, ) def get_readme(self, ref=github.GithubObject.NotSet): """ :calls: `GET /repos/{owner}/{repo}/readme `_ :param ref: string :rtype: :class:`github.ContentFile.ContentFile` """ assert ref is github.GithubObject.NotSet or isinstance(ref, str), ref url_parameters = dict() if ref is not github.GithubObject.NotSet: url_parameters["ref"] = ref headers, data = self._requester.requestJsonAndCheck( "GET", f"{self.url}/readme", parameters=url_parameters ) return github.ContentFile.ContentFile( self._requester, headers, data, completed=True ) def get_self_hosted_runner(self, runner_id): """ :calls: `GET /repos/{owner}/{repo}/actions/runners/{id} `_ :param runner_id: int :rtype: :class:`github.SelfHostedActionsRunner.SelfHostedActionsRunner` """ assert isinstance(runner_id, int), runner_id headers, data = self._requester.requestJsonAndCheck( "GET", f"{self.url}/actions/runners/{runner_id}" ) return github.SelfHostedActionsRunner.SelfHostedActionsRunner( self._requester, headers, data, completed=True ) def get_self_hosted_runners(self): """ :calls: `GET /repos/{owner}/{repo}/actions/runners `_ :rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.SelfHostedActionsRunner.SelfHostedActionsRunner` """ return github.PaginatedList.PaginatedList( github.SelfHostedActionsRunner.SelfHostedActionsRunner, self._requester, f"{self.url}/actions/runners", None, list_item="runners", ) def get_source_import(self): """ :calls: `GET /repos/{owner}/{repo}/import `_ :rtype: :class:`github.SourceImport.SourceImport` """ import_header = {"Accept": Consts.mediaTypeImportPreview} headers, data = self._requester.requestJsonAndCheck( "GET", f"{self.url}/import", headers=import_header, ) if not data: return None else: return github.SourceImport.SourceImport( self._requester, headers, data, completed=True ) def get_stargazers(self): """ :calls: `GET /repos/{owner}/{repo}/stargazers `_ :rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.NamedUser.NamedUser` """ return github.PaginatedList.PaginatedList( github.NamedUser.NamedUser, self._requester, f"{self.url}/stargazers", None ) def get_stargazers_with_dates(self): """ :calls: `GET /repos/{owner}/{repo}/stargazers `_ :rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.Stargazer.Stargazer` """ return github.PaginatedList.PaginatedList( github.Stargazer.Stargazer, self._requester, f"{self.url}/stargazers", None, headers={"Accept": Consts.mediaTypeStarringPreview}, ) def get_stats_contributors(self): """ :calls: `GET /repos/{owner}/{repo}/stats/contributors `_ :rtype: None or list of :class:`github.StatsContributor.StatsContributor` """ headers, data = self._requester.requestJsonAndCheck( "GET", f"{self.url}/stats/contributors" ) if not data: return None else: return [ github.StatsContributor.StatsContributor( self._requester, headers, attributes, completed=True ) for attributes in data ] def get_stats_commit_activity(self): """ :calls: `GET /repos/{owner}/{repo}/stats/commit_activity `_ :rtype: None or list of :class:`github.StatsCommitActivity.StatsCommitActivity` """ headers, data = self._requester.requestJsonAndCheck( "GET", f"{self.url}/stats/commit_activity" ) if not data: return None else: return [ github.StatsCommitActivity.StatsCommitActivity( self._requester, headers, attributes, completed=True ) for attributes in data ] def get_stats_code_frequency(self): """ :calls: `GET /repos/{owner}/{repo}/stats/code_frequency `_ :rtype: None or list of :class:`github.StatsCodeFrequency.StatsCodeFrequency` """ headers, data = self._requester.requestJsonAndCheck( "GET", f"{self.url}/stats/code_frequency" ) if not data: return None else: return [ github.StatsCodeFrequency.StatsCodeFrequency( self._requester, headers, attributes, completed=True ) for attributes in data ] def get_stats_participation(self): """ :calls: `GET /repos/{owner}/{repo}/stats/participation `_ :rtype: None or :class:`github.StatsParticipation.StatsParticipation` """ headers, data = self._requester.requestJsonAndCheck( "GET", f"{self.url}/stats/participation" ) if not data: return None else: return github.StatsParticipation.StatsParticipation( self._requester, headers, data, completed=True ) def get_stats_punch_card(self): """ :calls: `GET /repos/{owner}/{repo}/stats/punch_card `_ :rtype: None or :class:`github.StatsPunchCard.StatsPunchCard` """ headers, data = self._requester.requestJsonAndCheck( "GET", f"{self.url}/stats/punch_card" ) if not data: return None else: return github.StatsPunchCard.StatsPunchCard( self._requester, headers, data, completed=True ) def get_subscribers(self): """ :calls: `GET /repos/{owner}/{repo}/subscribers `_ :rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.NamedUser.NamedUser` """ return github.PaginatedList.PaginatedList( github.NamedUser.NamedUser, self._requester, f"{self.url}/subscribers", None ) def get_tags(self): """ :calls: `GET /repos/{owner}/{repo}/tags `_ :rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.Tag.Tag` """ return github.PaginatedList.PaginatedList( github.Tag.Tag, self._requester, f"{self.url}/tags", None ) def get_releases(self): """ :calls: `GET /repos/{owner}/{repo}/releases `_ :rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.GitRelease.GitRelease` """ return github.PaginatedList.PaginatedList( github.GitRelease.GitRelease, self._requester, f"{self.url}/releases", None ) def get_release(self, id): """ :calls: `GET /repos/{owner}/{repo}/releases/{id} `_ :param id: int (release id), str (tag name) :rtype: None or :class:`github.GitRelease.GitRelease` """ if isinstance(id, int): headers, data = self._requester.requestJsonAndCheck( "GET", f"{self.url}/releases/{id}" ) return github.GitRelease.GitRelease( self._requester, headers, data, completed=True ) elif isinstance(id, str): headers, data = self._requester.requestJsonAndCheck( "GET", f"{self.url}/releases/tags/{id}" ) return github.GitRelease.GitRelease( self._requester, headers, data, completed=True ) def get_latest_release(self): """ :calls: `GET /repos/{owner}/{repo}/releases/latest `_ :rtype: :class:`github.GitRelease.GitRelease` """ headers, data = self._requester.requestJsonAndCheck( "GET", f"{self.url}/releases/latest" ) return github.GitRelease.GitRelease( self._requester, headers, data, completed=True ) def get_teams(self): """ :calls: `GET /repos/{owner}/{repo}/teams `_ :rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.Team.Team` """ return github.PaginatedList.PaginatedList( github.Team.Team, self._requester, f"{self.url}/teams", None ) def get_topics(self): """ :calls: `GET /repos/{owner}/{repo}/topics `_ :rtype: list of strings """ headers, data = self._requester.requestJsonAndCheck( "GET", f"{self.url}/topics", headers={"Accept": Consts.mediaTypeTopicsPreview}, ) return data["names"] def get_watchers(self): """ :calls: `GET /repos/{owner}/{repo}/watchers `_ :rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.NamedUser.NamedUser` """ return github.PaginatedList.PaginatedList( github.NamedUser.NamedUser, self._requester, f"{self.url}/watchers", None ) def get_workflows(self): """ :calls: `GET /repos/{owner}/{repo}/actions/workflows `_ :rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.Workflow.Workflow` """ return github.PaginatedList.PaginatedList( github.Workflow.Workflow, self._requester, f"{self.url}/actions/workflows", None, list_item="workflows", ) def get_workflow(self, id_or_name): """ :calls: `GET /repos/{owner}/{repo}/actions/workflows/{workflow_id} `_ :param id_or_name: int or string :rtype: :class:`github.Workflow.Workflow` """ assert isinstance(id_or_name, int) or isinstance(id_or_name, str), id_or_name headers, data = self._requester.requestJsonAndCheck( "GET", f"{self.url}/actions/workflows/{id_or_name}" ) return github.Workflow.Workflow(self._requester, headers, data, completed=True) def get_workflow_runs( self, actor=github.GithubObject.NotSet, branch=github.GithubObject.NotSet, event=github.GithubObject.NotSet, status=github.GithubObject.NotSet, ): """ :calls: `GET /repos/{owner}/{repo}/actions/runs `_ :param actor: :class:`github.NamedUser.NamedUser` or string :param branch: :class:`github.Branch.Branch` or string :param event: string :param status: string `queued`, `in_progress`, `completed`, `success`, `failure`, `neutral`, `cancelled`, `skipped`, `timed_out`, or `action_required` :rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.WorkflowRun.WorkflowRun` """ assert ( actor is github.GithubObject.NotSet or isinstance(actor, github.NamedUser.NamedUser) or isinstance(actor, str) ), actor assert ( branch is github.GithubObject.NotSet or isinstance(branch, github.Branch.Branch) or isinstance(branch, str) ), branch assert event is github.GithubObject.NotSet or isinstance(event, str), event assert status is github.GithubObject.NotSet or isinstance(status, str), status url_parameters = dict() if actor is not github.GithubObject.NotSet: if isinstance(actor, github.NamedUser.NamedUser): url_parameters["actor"] = actor._identity else: url_parameters["actor"] = actor if branch is not github.GithubObject.NotSet: if isinstance(branch, github.Branch.Branch): url_parameters["branch"] = branch.name else: url_parameters["branch"] = branch if event is not github.GithubObject.NotSet: url_parameters["event"] = event if status is not github.GithubObject.NotSet: url_parameters["status"] = status return github.PaginatedList.PaginatedList( github.WorkflowRun.WorkflowRun, self._requester, f"{self.url}/actions/runs", url_parameters, list_item="workflow_runs", ) def get_workflow_run(self, id_): """ :calls: `GET /repos/{owner}/{repo}/actions/runs/{run_id} `_ :param id_: int :rtype: :class:`github.WorkflowRun.WorkflowRun` """ assert isinstance(id_, int) headers, data = self._requester.requestJsonAndCheck( "GET", f"{self.url}/actions/runs/{id_}" ) return github.WorkflowRun.WorkflowRun( self._requester, headers, data, completed=True ) def has_in_assignees(self, assignee): """ :calls: `GET /repos/{owner}/{repo}/assignees/{assignee} `_ :param assignee: string or :class:`github.NamedUser.NamedUser` :rtype: bool """ assert isinstance(assignee, github.NamedUser.NamedUser) or isinstance( assignee, str ), assignee if isinstance(assignee, github.NamedUser.NamedUser): assignee = assignee._identity status, headers, data = self._requester.requestJson( "GET", f"{self.url}/assignees/{assignee}" ) return status == 204 def has_in_collaborators(self, collaborator): """ :calls: `GET /repos/{owner}/{repo}/collaborators/{user} `_ :param collaborator: string or :class:`github.NamedUser.NamedUser` :rtype: bool """ assert isinstance(collaborator, github.NamedUser.NamedUser) or isinstance( collaborator, str ), collaborator if isinstance(collaborator, github.NamedUser.NamedUser): collaborator = collaborator._identity status, headers, data = self._requester.requestJson( "GET", f"{self.url}/collaborators/{collaborator}" ) return status == 204 def _legacy_convert_issue(self, attributes): convertedAttributes = { "number": attributes["number"], "url": f"/repos{urllib.parse.urlparse(attributes['html_url']).path}", "user": { "login": attributes["user"], "url": f"/users/{attributes['user']}", }, } if "labels" in attributes: # pragma no branch convertedAttributes["labels"] = [ {"name": label} for label in attributes["labels"] ] for attr in ("title", "created_at", "comments", "body", "updated_at", "state"): if attr in attributes: # pragma no branch convertedAttributes[attr] = attributes[attr] return convertedAttributes def legacy_search_issues(self, state, keyword): """ :calls: `GET /legacy/issues/search/{owner}/{repository}/{state}/{keyword} `_ :param state: "open" or "closed" :param keyword: string :rtype: List of :class:`github.Issue.Issue` """ assert state in ["open", "closed"], state assert isinstance(keyword, str), keyword headers, data = self._requester.requestJsonAndCheck( "GET", f"/legacy/issues/search/{self.owner.login}/{self.name}/{state}/{urllib.parse.quote(keyword)}", ) return [ github.Issue.Issue( self._requester, headers, self._legacy_convert_issue(element), completed=False, ) for element in data["issues"] ] def get_notifications( self, all=github.GithubObject.NotSet, participating=github.GithubObject.NotSet, since=github.GithubObject.NotSet, before=github.GithubObject.NotSet, ): """ :calls: `GET /repos/{owner}/{repo}/notifications `_ :param all: bool :param participating: bool :param since: datetime.datetime :param before: datetime.datetime :rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.Notification.Notification` """ assert all is github.GithubObject.NotSet or isinstance(all, bool), all assert participating is github.GithubObject.NotSet or isinstance( participating, bool ), participating assert since is github.GithubObject.NotSet or isinstance( since, datetime.datetime ), since assert before is github.GithubObject.NotSet or isinstance( before, datetime.datetime ), before params = dict() if all is not github.GithubObject.NotSet: params["all"] = all if participating is not github.GithubObject.NotSet: params["participating"] = participating if since is not github.GithubObject.NotSet: params["since"] = since.strftime("%Y-%m-%dT%H:%M:%SZ") if before is not github.GithubObject.NotSet: params["before"] = before.strftime("%Y-%m-%dT%H:%M:%SZ") return github.PaginatedList.PaginatedList( github.Notification.Notification, self._requester, f"{self.url}/notifications", params, ) def mark_notifications_as_read(self, last_read_at=datetime.datetime.utcnow()): """ :calls: `PUT /repos/{owner}/{repo}/notifications `_ :param last_read_at: datetime """ assert isinstance(last_read_at, datetime.datetime) put_parameters = {"last_read_at": last_read_at.strftime("%Y-%m-%dT%H:%M:%SZ")} headers, data = self._requester.requestJsonAndCheck( "PUT", f"{self.url}/notifications", input=put_parameters ) def merge(self, base, head, commit_message=github.GithubObject.NotSet): """ :calls: `POST /repos/{owner}/{repo}/merges `_ :param base: string :param head: string :param commit_message: string :rtype: :class:`github.Commit.Commit` """ assert isinstance(base, str), base assert isinstance(head, str), head assert commit_message is github.GithubObject.NotSet or isinstance( commit_message, str ), commit_message post_parameters = { "base": base, "head": head, } if commit_message is not github.GithubObject.NotSet: post_parameters["commit_message"] = commit_message headers, data = self._requester.requestJsonAndCheck( "POST", f"{self.url}/merges", input=post_parameters ) if data is None: return None else: return github.Commit.Commit(self._requester, headers, data, completed=True) def replace_topics(self, topics): """ :calls: `PUT /repos/{owner}/{repo}/topics `_ :param topics: list of strings :rtype: None """ post_parameters = {"names": topics} headers, data = self._requester.requestJsonAndCheck( "PUT", f"{self.url}/topics", headers={"Accept": Consts.mediaTypeTopicsPreview}, input=post_parameters, ) def get_vulnerability_alert(self): """ :calls: `GET /repos/{owner}/{repo}/vulnerability-alerts `_ :rtype: bool """ status, _, _ = self._requester.requestJson( "GET", f"{self.url}/vulnerability-alerts", headers={"Accept": Consts.vulnerabilityAlertsPreview}, ) return status == 204 def enable_vulnerability_alert(self): """ :calls: `PUT /repos/{owner}/{repo}/vulnerability-alerts `_ :rtype: bool """ status, _, _ = self._requester.requestJson( "PUT", f"{self.url}/vulnerability-alerts", headers={"Accept": Consts.vulnerabilityAlertsPreview}, ) return status == 204 def disable_vulnerability_alert(self): """ :calls: `DELETE /repos/{owner}/{repo}/vulnerability-alerts `_ :rtype: bool """ status, _, _ = self._requester.requestJson( "DELETE", f"{self.url}/vulnerability-alerts", headers={"Accept": Consts.vulnerabilityAlertsPreview}, ) return status == 204 def enable_automated_security_fixes(self): """ :calls: `PUT /repos/{owner}/{repo}/automated-security-fixes `_ :rtype: bool """ status, _, _ = self._requester.requestJson( "PUT", f"{self.url}/automated-security-fixes", headers={"Accept": Consts.automatedSecurityFixes}, ) return status == 204 def disable_automated_security_fixes(self): """ :calls: `DELETE /repos/{owner}/{repo}/automated-security-fixes `_ :rtype: bool """ status, _, _ = self._requester.requestJson( "DELETE", f"{self.url}/automated-security-fixes", headers={"Accept": Consts.automatedSecurityFixes}, ) return status == 204 def remove_from_collaborators(self, collaborator): """ :calls: `DELETE /repos/{owner}/{repo}/collaborators/{user} `_ :param collaborator: string or :class:`github.NamedUser.NamedUser` :rtype: None """ assert isinstance(collaborator, github.NamedUser.NamedUser) or isinstance( collaborator, str ), collaborator if isinstance(collaborator, github.NamedUser.NamedUser): collaborator = collaborator._identity headers, data = self._requester.requestJsonAndCheck( "DELETE", f"{self.url}/collaborators/{collaborator}" ) def remove_self_hosted_runner(self, runner): """ :calls: `DELETE /repos/{owner}/{repo}/actions/runners/{runner_id} `_ :param runner: int or :class:`github.SelfHostedActionsRunner.SelfHostedActionsRunner` :rtype: bool """ assert isinstance( runner, github.SelfHostedActionsRunner.SelfHostedActionsRunner ) or isinstance(runner, int), runner if isinstance(runner, github.SelfHostedActionsRunner.SelfHostedActionsRunner): runner = runner.id status, _, _ = self._requester.requestJson( "DELETE", f"{self.url}/actions/runners/{runner}" ) return status == 204 def subscribe_to_hub(self, event, callback, secret=github.GithubObject.NotSet): """ :calls: `POST /hub `_ :param event: string :param callback: string :param secret: string :rtype: None """ return self._hub("subscribe", event, callback, secret) def unsubscribe_from_hub(self, event, callback): """ :calls: `POST /hub `_ :param event: string :param callback: string :param secret: string :rtype: None """ return self._hub("unsubscribe", event, callback, github.GithubObject.NotSet) def create_check_suite(self, head_sha): """ :calls: `POST /repos/{owner}/{repo}/check-suites `_ :param head_sha: string :rtype: :class:`github.CheckSuite.CheckSuite` """ assert isinstance(head_sha, str), head_sha headers, data = self._requester.requestJsonAndCheck( "POST", f"{self.url}/check-suites", input={"head_sha": head_sha}, ) return github.CheckSuite.CheckSuite( self._requester, headers, data, completed=True ) def get_check_suite(self, check_suite_id): """ :calls: `GET /repos/{owner}/{repo}/check-suites/{check_suite_id} `_ :param check_suite_id: int :rtype: :class:`github.CheckSuite.CheckSuite` """ assert isinstance(check_suite_id, int), check_suite_id requestHeaders = {"Accept": "application/vnd.github.v3+json"} headers, data = self._requester.requestJsonAndCheck( "GET", f"{self.url}/check-suites/{check_suite_id}", headers=requestHeaders, ) return github.CheckSuite.CheckSuite( self._requester, headers, data, completed=True ) def update_check_suites_preferences(self, auto_trigger_checks): """ :calls: `PATCH /repos/{owner}/{repo}/check-suites/preferences `_ :param auto_trigger_checks: list of dict :rtype: :class:`github.RepositoryPreferences.RepositoryPreferences` """ assert all( isinstance(element, dict) for element in auto_trigger_checks ), auto_trigger_checks headers, data = self._requester.requestJsonAndCheck( "PATCH", f"{self.url}/check-suites/preferences", input={"auto_trigger_checks": auto_trigger_checks}, ) return github.RepositoryPreferences.RepositoryPreferences( self._requester, headers, data, completed=True ) def _hub(self, mode, event, callback, secret): assert isinstance(mode, str), mode assert isinstance(event, str), event assert isinstance(callback, str), callback assert secret is github.GithubObject.NotSet or isinstance(secret, str), secret post_parameters = collections.OrderedDict() post_parameters["hub.callback"] = callback post_parameters[ "hub.topic" ] = f"https://github.com/{self.full_name}/events/{event}" post_parameters["hub.mode"] = mode if secret is not github.GithubObject.NotSet: post_parameters["hub.secret"] = secret headers, output = self._requester.requestMultipartAndCheck( "POST", "/hub", input=post_parameters ) @property def _identity(self): return f"{self.owner.login}/{self.name}" def get_release_asset(self, id): assert isinstance(id, (int)), id resp_headers, data = self._requester.requestJsonAndCheck( "GET", f"{self.url}/releases/assets/{id}" ) return github.GitReleaseAsset.GitReleaseAsset( self._requester, resp_headers, data, completed=True ) def create_check_run( self, name, head_sha, details_url=github.GithubObject.NotSet, external_id=github.GithubObject.NotSet, status=github.GithubObject.NotSet, started_at=github.GithubObject.NotSet, conclusion=github.GithubObject.NotSet, completed_at=github.GithubObject.NotSet, output=github.GithubObject.NotSet, actions=github.GithubObject.NotSet, ): """ :calls: `POST /repos/{owner}/{repo}/check-runs `_ :param name: string :param head_sha: string :param details_url: string :param external_id: string :param status: string :param started_at: datetime.datetime :param conclusion: string :param completed_at: datetime.datetime :param output: dict :param actions: list of dict :rtype: :class:`github.CheckRun.CheckRun` """ assert isinstance(name, str), name assert isinstance(head_sha, str), head_sha assert details_url is github.GithubObject.NotSet or isinstance( details_url, str ), details_url assert external_id is github.GithubObject.NotSet or isinstance( external_id, str ), external_id assert status is github.GithubObject.NotSet or isinstance(status, str), status assert started_at is github.GithubObject.NotSet or isinstance( started_at, datetime.datetime ), started_at assert conclusion is github.GithubObject.NotSet or isinstance( conclusion, str ), conclusion assert completed_at is github.GithubObject.NotSet or isinstance( completed_at, datetime.datetime ), completed_at assert output is github.GithubObject.NotSet or isinstance(output, dict), output assert actions is github.GithubObject.NotSet or all( isinstance(element, dict) for element in actions ), actions post_parameters = { "name": name, "head_sha": head_sha, } if details_url is not github.GithubObject.NotSet: post_parameters["details_url"] = details_url if external_id is not github.GithubObject.NotSet: post_parameters["external_id"] = external_id if status is not github.GithubObject.NotSet: post_parameters["status"] = status if started_at is not github.GithubObject.NotSet: post_parameters["started_at"] = started_at.strftime("%Y-%m-%dT%H:%M:%SZ") if completed_at is not github.GithubObject.NotSet: post_parameters["completed_at"] = completed_at.strftime( "%Y-%m-%dT%H:%M:%SZ" ) if conclusion is not github.GithubObject.NotSet: post_parameters["conclusion"] = conclusion if output is not github.GithubObject.NotSet: post_parameters["output"] = output if actions is not github.GithubObject.NotSet: post_parameters["actions"] = actions headers, data = self._requester.requestJsonAndCheck( "POST", f"{self.url}/check-runs", input=post_parameters, ) return github.CheckRun.CheckRun(self._requester, headers, data, completed=True) def get_check_run(self, check_run_id): """ :calls: `GET /repos/{owner}/{repo}/check-runs/{check_run_id} `_ :param check_run_id: int :rtype: :class:`github.CheckRun.CheckRun` """ assert isinstance(check_run_id, int), check_run_id headers, data = self._requester.requestJsonAndCheck( "GET", f"{self.url}/check-runs/{check_run_id}" ) return github.CheckRun.CheckRun(self._requester, headers, data, completed=True) def _initAttributes(self): self._allow_merge_commit = github.GithubObject.NotSet self._allow_rebase_merge = github.GithubObject.NotSet self._allow_squash_merge = github.GithubObject.NotSet self._archived = github.GithubObject.NotSet self._archive_url = github.GithubObject.NotSet self._assignees_url = github.GithubObject.NotSet self._blobs_url = github.GithubObject.NotSet self._branches_url = github.GithubObject.NotSet self._clone_url = github.GithubObject.NotSet self._collaborators_url = github.GithubObject.NotSet self._comments_url = github.GithubObject.NotSet self._commits_url = github.GithubObject.NotSet self._compare_url = github.GithubObject.NotSet self._contents_url = github.GithubObject.NotSet self._contributors_url = github.GithubObject.NotSet self._created_at = github.GithubObject.NotSet self._default_branch = github.GithubObject.NotSet self._delete_branch_on_merge = github.GithubObject.NotSet self._deployments_url = github.GithubObject.NotSet self._description = github.GithubObject.NotSet self._downloads_url = github.GithubObject.NotSet self._events_url = github.GithubObject.NotSet self._fork = github.GithubObject.NotSet self._forks = github.GithubObject.NotSet self._forks_count = github.GithubObject.NotSet self._forks_url = github.GithubObject.NotSet self._full_name = github.GithubObject.NotSet self._git_commits_url = github.GithubObject.NotSet self._git_refs_url = github.GithubObject.NotSet self._git_tags_url = github.GithubObject.NotSet self._git_url = github.GithubObject.NotSet self._has_downloads = github.GithubObject.NotSet self._has_issues = github.GithubObject.NotSet self._has_pages = github.GithubObject.NotSet self._has_projects = github.GithubObject.NotSet self._has_wiki = github.GithubObject.NotSet self._homepage = github.GithubObject.NotSet self._hooks_url = github.GithubObject.NotSet self._html_url = github.GithubObject.NotSet self._id = github.GithubObject.NotSet self._issue_comment_url = github.GithubObject.NotSet self._issue_events_url = github.GithubObject.NotSet self._issues_url = github.GithubObject.NotSet self._keys_url = github.GithubObject.NotSet self._labels_url = github.GithubObject.NotSet self._language = github.GithubObject.NotSet self._languages_url = github.GithubObject.NotSet self._master_branch = github.GithubObject.NotSet self._merges_url = github.GithubObject.NotSet self._milestones_url = github.GithubObject.NotSet self._mirror_url = github.GithubObject.NotSet self._name = github.GithubObject.NotSet self._network_count = github.GithubObject.NotSet self._notifications_url = github.GithubObject.NotSet self._open_issues = github.GithubObject.NotSet self._open_issues_count = github.GithubObject.NotSet self._organization = github.GithubObject.NotSet self._owner = github.GithubObject.NotSet self._parent = github.GithubObject.NotSet self._permissions = github.GithubObject.NotSet self._private = github.GithubObject.NotSet self._pulls_url = github.GithubObject.NotSet self._pushed_at = github.GithubObject.NotSet self._releases_url = github.GithubObject.NotSet self._size = github.GithubObject.NotSet self._source = github.GithubObject.NotSet self._ssh_url = github.GithubObject.NotSet self._stargazers_count = github.GithubObject.NotSet self._stargazers_url = github.GithubObject.NotSet self._statuses_url = github.GithubObject.NotSet self._subscribers_url = github.GithubObject.NotSet self._subscribers_count = github.GithubObject.NotSet self._subscription_url = github.GithubObject.NotSet self._svn_url = github.GithubObject.NotSet self._tags_url = github.GithubObject.NotSet self._teams_url = github.GithubObject.NotSet self._trees_url = github.GithubObject.NotSet self._updated_at = github.GithubObject.NotSet self._url = github.GithubObject.NotSet self._watchers = github.GithubObject.NotSet self._watchers_count = github.GithubObject.NotSet def _useAttributes(self, attributes): if "allow_merge_commit" in attributes: # pragma no branch self._allow_merge_commit = self._makeBoolAttribute( attributes["allow_merge_commit"] ) if "allow_rebase_merge" in attributes: # pragma no branch self._allow_rebase_merge = self._makeBoolAttribute( attributes["allow_rebase_merge"] ) if "allow_squash_merge" in attributes: # pragma no branch self._allow_squash_merge = self._makeBoolAttribute( attributes["allow_squash_merge"] ) if "archived" in attributes: # pragma no branch self._archived = self._makeBoolAttribute(attributes["archived"]) if "archive_url" in attributes: # pragma no branch self._archive_url = self._makeStringAttribute(attributes["archive_url"]) if "assignees_url" in attributes: # pragma no branch self._assignees_url = self._makeStringAttribute(attributes["assignees_url"]) if "blobs_url" in attributes: # pragma no branch self._blobs_url = self._makeStringAttribute(attributes["blobs_url"]) if "branches_url" in attributes: # pragma no branch self._branches_url = self._makeStringAttribute(attributes["branches_url"]) if "clone_url" in attributes: # pragma no branch self._clone_url = self._makeStringAttribute(attributes["clone_url"]) if "collaborators_url" in attributes: # pragma no branch self._collaborators_url = self._makeStringAttribute( attributes["collaborators_url"] ) if "comments_url" in attributes: # pragma no branch self._comments_url = self._makeStringAttribute(attributes["comments_url"]) if "commits_url" in attributes: # pragma no branch self._commits_url = self._makeStringAttribute(attributes["commits_url"]) if "compare_url" in attributes: # pragma no branch self._compare_url = self._makeStringAttribute(attributes["compare_url"]) if "contents_url" in attributes: # pragma no branch self._contents_url = self._makeStringAttribute(attributes["contents_url"]) if "contributors_url" in attributes: # pragma no branch self._contributors_url = self._makeStringAttribute( attributes["contributors_url"] ) if "created_at" in attributes: # pragma no branch self._created_at = self._makeDatetimeAttribute(attributes["created_at"]) if "default_branch" in attributes: # pragma no branch self._default_branch = self._makeStringAttribute( attributes["default_branch"] ) if "delete_branch_on_merge" in attributes: # pragma no branch self._delete_branch_on_merge = self._makeBoolAttribute( attributes["delete_branch_on_merge"] ) if "deployments_url" in attributes: # pragma no branch self._deployments_url = self._makeStringAttribute( attributes["deployments_url"] ) if "description" in attributes: # pragma no branch self._description = self._makeStringAttribute(attributes["description"]) if "downloads_url" in attributes: # pragma no branch self._downloads_url = self._makeStringAttribute(attributes["downloads_url"]) if "events_url" in attributes: # pragma no branch self._events_url = self._makeStringAttribute(attributes["events_url"]) if "fork" in attributes: # pragma no branch self._fork = self._makeBoolAttribute(attributes["fork"]) if "forks" in attributes: # pragma no branch self._forks = self._makeIntAttribute(attributes["forks"]) if "forks_count" in attributes: # pragma no branch self._forks_count = self._makeIntAttribute(attributes["forks_count"]) if "forks_url" in attributes: # pragma no branch self._forks_url = self._makeStringAttribute(attributes["forks_url"]) if "full_name" in attributes: # pragma no branch self._full_name = self._makeStringAttribute(attributes["full_name"]) if "git_commits_url" in attributes: # pragma no branch self._git_commits_url = self._makeStringAttribute( attributes["git_commits_url"] ) if "git_refs_url" in attributes: # pragma no branch self._git_refs_url = self._makeStringAttribute(attributes["git_refs_url"]) if "git_tags_url" in attributes: # pragma no branch self._git_tags_url = self._makeStringAttribute(attributes["git_tags_url"]) if "git_url" in attributes: # pragma no branch self._git_url = self._makeStringAttribute(attributes["git_url"]) if "has_downloads" in attributes: # pragma no branch self._has_downloads = self._makeBoolAttribute(attributes["has_downloads"]) if "has_issues" in attributes: # pragma no branch self._has_issues = self._makeBoolAttribute(attributes["has_issues"]) if "has_pages" in attributes: # pragma no branch self._has_pages = self._makeBoolAttribute(attributes["has_pages"]) if "has_projects" in attributes: # pragma no branch self._has_projects = self._makeBoolAttribute(attributes["has_projects"]) if "has_wiki" in attributes: # pragma no branch self._has_wiki = self._makeBoolAttribute(attributes["has_wiki"]) if "homepage" in attributes: # pragma no branch self._homepage = self._makeStringAttribute(attributes["homepage"]) if "hooks_url" in attributes: # pragma no branch self._hooks_url = self._makeStringAttribute(attributes["hooks_url"]) if "html_url" in attributes: # pragma no branch self._html_url = self._makeStringAttribute(attributes["html_url"]) if "id" in attributes: # pragma no branch self._id = self._makeIntAttribute(attributes["id"]) if "issue_comment_url" in attributes: # pragma no branch self._issue_comment_url = self._makeStringAttribute( attributes["issue_comment_url"] ) if "issue_events_url" in attributes: # pragma no branch self._issue_events_url = self._makeStringAttribute( attributes["issue_events_url"] ) if "issues_url" in attributes: # pragma no branch self._issues_url = self._makeStringAttribute(attributes["issues_url"]) if "keys_url" in attributes: # pragma no branch self._keys_url = self._makeStringAttribute(attributes["keys_url"]) if "labels_url" in attributes: # pragma no branch self._labels_url = self._makeStringAttribute(attributes["labels_url"]) if "language" in attributes: # pragma no branch self._language = self._makeStringAttribute(attributes["language"]) if "languages_url" in attributes: # pragma no branch self._languages_url = self._makeStringAttribute(attributes["languages_url"]) if "master_branch" in attributes: # pragma no branch self._master_branch = self._makeStringAttribute(attributes["master_branch"]) if "merges_url" in attributes: # pragma no branch self._merges_url = self._makeStringAttribute(attributes["merges_url"]) if "milestones_url" in attributes: # pragma no branch self._milestones_url = self._makeStringAttribute( attributes["milestones_url"] ) if "mirror_url" in attributes: # pragma no branch self._mirror_url = self._makeStringAttribute(attributes["mirror_url"]) if "name" in attributes: # pragma no branch self._name = self._makeStringAttribute(attributes["name"]) if "network_count" in attributes: # pragma no branch self._network_count = self._makeIntAttribute(attributes["network_count"]) if "notifications_url" in attributes: # pragma no branch self._notifications_url = self._makeStringAttribute( attributes["notifications_url"] ) if "open_issues" in attributes: # pragma no branch self._open_issues = self._makeIntAttribute(attributes["open_issues"]) if "open_issues_count" in attributes: # pragma no branch self._open_issues_count = self._makeIntAttribute( attributes["open_issues_count"] ) if "organization" in attributes: # pragma no branch self._organization = self._makeClassAttribute( github.Organization.Organization, attributes["organization"] ) if "owner" in attributes: # pragma no branch self._owner = self._makeClassAttribute( github.NamedUser.NamedUser, attributes["owner"] ) if "parent" in attributes: # pragma no branch self._parent = self._makeClassAttribute(Repository, attributes["parent"]) if "permissions" in attributes: # pragma no branch self._permissions = self._makeClassAttribute( github.Permissions.Permissions, attributes["permissions"] ) if "private" in attributes: # pragma no branch self._private = self._makeBoolAttribute(attributes["private"]) if "pulls_url" in attributes: # pragma no branch self._pulls_url = self._makeStringAttribute(attributes["pulls_url"]) if "pushed_at" in attributes: # pragma no branch self._pushed_at = self._makeDatetimeAttribute(attributes["pushed_at"]) if "releases_url" in attributes: # pragma no branch self._releases_url = self._makeStringAttribute(attributes["releases_url"]) if "size" in attributes: # pragma no branch self._size = self._makeIntAttribute(attributes["size"]) if "source" in attributes: # pragma no branch self._source = self._makeClassAttribute(Repository, attributes["source"]) if "ssh_url" in attributes: # pragma no branch self._ssh_url = self._makeStringAttribute(attributes["ssh_url"]) if "stargazers_count" in attributes: # pragma no branch self._stargazers_count = self._makeIntAttribute( attributes["stargazers_count"] ) if "stargazers_url" in attributes: # pragma no branch self._stargazers_url = self._makeStringAttribute( attributes["stargazers_url"] ) if "statuses_url" in attributes: # pragma no branch self._statuses_url = self._makeStringAttribute(attributes["statuses_url"]) if "subscribers_url" in attributes: # pragma no branch self._subscribers_url = self._makeStringAttribute( attributes["subscribers_url"] ) if "subscribers_count" in attributes: # pragma no branch self._subscribers_count = self._makeIntAttribute( attributes["subscribers_count"] ) if "subscription_url" in attributes: # pragma no branch self._subscription_url = self._makeStringAttribute( attributes["subscription_url"] ) if "svn_url" in attributes: # pragma no branch self._svn_url = self._makeStringAttribute(attributes["svn_url"]) if "tags_url" in attributes: # pragma no branch self._tags_url = self._makeStringAttribute(attributes["tags_url"]) if "teams_url" in attributes: # pragma no branch self._teams_url = self._makeStringAttribute(attributes["teams_url"]) if "trees_url" in attributes: # pragma no branch self._trees_url = self._makeStringAttribute(attributes["trees_url"]) if "updated_at" in attributes: # pragma no branch self._updated_at = self._makeDatetimeAttribute(attributes["updated_at"]) if "url" in attributes: # pragma no branch self._url = self._makeStringAttribute(attributes["url"]) if "watchers" in attributes: # pragma no branch self._watchers = self._makeIntAttribute(attributes["watchers"]) if "watchers_count" in attributes: # pragma no branch self._watchers_count = self._makeIntAttribute(attributes["watchers_count"]) ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1619412308.0 PyGithub-1.55/github/Repository.pyi0000644000175100001710000005463100000000000016734 0ustar00runnerdockerfrom datetime import date, datetime from typing import Any, Dict, List, Optional, Union, overload from github.AuthenticatedUser import AuthenticatedUser from github.Branch import Branch from github.CheckRun import CheckRun from github.CheckSuite import CheckSuite from github.Clones import Clones from github.Commit import Commit from github.CommitComment import CommitComment from github.Comparison import Comparison from github.ContentFile import ContentFile from github.Deployment import Deployment from github.Download import Download from github.Event import Event from github.GitBlob import GitBlob from github.GitCommit import GitCommit from github.GithubObject import CompletableGithubObject, _NotSetType from github.GitRef import GitRef from github.GitRelease import GitRelease from github.GitReleaseAsset import GitReleaseAsset from github.GitTag import GitTag from github.GitTree import GitTree from github.Hook import Hook from github.InputGitAuthor import InputGitAuthor from github.InputGitTreeElement import InputGitTreeElement from github.Invitation import Invitation from github.Issue import Issue from github.IssueComment import IssueComment from github.IssueEvent import IssueEvent from github.Label import Label from github.Milestone import Milestone from github.NamedUser import NamedUser from github.Notification import Notification from github.Organization import Organization from github.PaginatedList import PaginatedList from github.Path import Path from github.Permissions import Permissions from github.Project import Project from github.PublicKey import PublicKey from github.PullRequest import PullRequest from github.PullRequestComment import PullRequestComment from github.Referrer import Referrer from github.RepositoryKey import RepositoryKey from github.RepositoryPreferences import RepositoryPreferences from github.SelfHostedActionsRunner import SelfHostedActionsRunner from github.SourceImport import SourceImport from github.Stargazer import Stargazer from github.StatsCodeFrequency import StatsCodeFrequency from github.StatsCommitActivity import StatsCommitActivity from github.StatsContributor import StatsContributor from github.StatsParticipation import StatsParticipation from github.StatsPunchCard import StatsPunchCard from github.Tag import Tag from github.Team import Team from github.View import View from github.Workflow import Workflow from github.WorkflowRun import WorkflowRun class Repository(CompletableGithubObject): def __repr__(self) -> str: ... def _hub( self, mode: str, event: str, callback: str, secret: Union[str, _NotSetType] ) -> None: ... @property def _identity(self) -> str: ... def _initAttributes(self) -> None: ... def _legacy_convert_issue(self, attributes: Dict[str, Any]) -> Dict[str, Any]: ... def _useAttributes(self, attributes: Dict[str, Any]) -> None: ... @property def allow_merge_commit(self) -> bool: ... @property def allow_rebase_merge(self) -> bool: ... @property def allow_squash_merge(self) -> bool: ... @property def archived(self) -> bool: ... def add_to_collaborators( self, collaborator: Union[str, NamedUser], permission: Union[str, _NotSetType] = ..., ) -> None: ... @property def archive_url(self) -> str: ... @property def assignees_url(self) -> str: ... @property def blobs_url(self) -> str: ... @property def branches_url(self) -> str: ... @property def clone_url(self) -> str: ... @property def collaborators_url(self) -> str: ... @property def comments_url(self) -> str: ... @property def commits_url(self) -> str: ... def compare(self, base: str, head: str) -> Comparison: ... @property def compare_url(self) -> str: ... @property def contents_url(self) -> str: ... @property def contributors_url(self) -> str: ... def create_check_run( self, name: str = ..., head_sha: str = ..., details_url: Union[_NotSetType, str] = ..., external_id: Union[_NotSetType, str] = ..., status: Union[_NotSetType, str] = ..., started_at: Union[_NotSetType, datetime] = ..., conclusion: Union[_NotSetType, str] = ..., completed_at: Union[_NotSetType, datetime] = ..., output: Union[ _NotSetType, Dict[str, Union[str, List[Dict[str, Union[str, int]]]]] ] = ..., actions: Union[_NotSetType, List[Dict[str, str]]] = ..., ) -> CheckRun: ... def create_check_suite(self, head_sha: str) -> CheckSuite: ... def create_deployment( self, ref: str, task: Union[str, _NotSetType] = ..., auto_merge: Union[bool, _NotSetType] = ..., required_contexts: Union[List[str], _NotSetType] = ..., payload: Union[Dict[str, Any], _NotSetType] = ..., environment: Union[str, _NotSetType] = ..., description: Union[str, _NotSetType] = ..., transient_environment: Union[bool, _NotSetType] = ..., production_environment: Union[bool, _NotSetType] = ..., ) -> Deployment: ... def create_file( self, path: str, message: str, content: str, branch: Union[str, _NotSetType] = ..., committer: Union[InputGitAuthor, _NotSetType] = ..., author: Union[InputGitAuthor, _NotSetType] = ..., ) -> Dict[str, Union[ContentFile, Commit]]: ... def create_git_blob(self, content: str, encoding: str) -> GitBlob: ... def create_git_commit( self, message: str, tree: GitTree, parents: List[GitCommit], author: Union[InputGitAuthor, _NotSetType] = ..., committer: Union[InputGitAuthor, _NotSetType] = ..., ) -> GitCommit: ... def create_git_ref(self, ref: str, sha: str) -> GitRef: ... def create_git_release( self, tag: str, name: str, message: str, draft: bool = ..., prerelease: bool = ..., target_commitish: Union[str, _NotSetType] = ..., ) -> GitRelease: ... def create_git_tag( self, tag: str, message: str, object: str, type: str, tagger: Union[InputGitAuthor, _NotSetType] = ..., ) -> GitTag: ... def create_git_tag_and_release( self, tag: str, tag_message: str, release_name: str, release_message: str, object: str, type: str, tagger: Union[InputGitAuthor, _NotSetType] = ..., draft: bool = ..., prerelease: bool = ..., ) -> GitRelease: ... def create_git_tree( self, tree: List[InputGitTreeElement], base_tree: Union[GitTree, _NotSetType] = ..., ) -> GitTree: ... def create_hook( self, name: str, config: Dict[str, str], events: Union[_NotSetType, List[str]] = ..., active: Union[bool, _NotSetType] = ..., ) -> Hook: ... def create_issue( self, title: str, body: Union[str, _NotSetType] = ..., assignee: Union[NamedUser, str, _NotSetType] = ..., milestone: Union[Milestone, _NotSetType] = ..., labels: Union[List[Label], _NotSetType, List[str]] = ..., assignees: Union[_NotSetType, List[str], List[NamedUser]] = ..., ) -> Issue: ... def create_key( self, title: str, key: str, read_only: bool = ... ) -> RepositoryKey: ... def create_label( self, name: str, color: str, description: Union[str, _NotSetType] = ... ) -> Label: ... def create_milestone( self, title: str, state: Union[str, _NotSetType] = ..., description: Union[str, _NotSetType] = ..., due_on: Union[date, _NotSetType] = ..., ) -> Milestone: ... def create_project(self, name: str, body: str = ...) -> Project: ... @overload def create_pull( self, title: str, body: str, base: str, head: str, maintainer_can_modify: Union[bool, _NotSetType] = _NotSetType(), draft: bool = False, issue: _NotSetType = _NotSetType(), ) -> PullRequest: ... @overload def create_pull( self, title: _NotSetType, body: _NotSetType, base: str, head: str, maintainer_can_modify: _NotSetType, issue: Issue, ) -> PullRequest: ... def create_repository_dispatch( self, event_type: str, client_payload: Dict[str, Any] ) -> bool: ... def create_secret(self, secret_name: str, unencrypted_value: str) -> bool: ... def delete_secret(self, secret_name: str) -> bool: ... def create_source_import( self, vcs: str, vcs_url: str, vcs_username: Union[str, _NotSetType] = ..., vcs_password: Union[str, _NotSetType] = ..., ) -> SourceImport: ... @property def created_at(self) -> datetime: ... @property def default_branch(self) -> str: ... def delete(self) -> None: ... def delete_file( self, path: str, message: str, sha: str, branch: Union[str, _NotSetType] = ..., committer: Union[InputGitAuthor, _NotSetType] = ..., author: Union[InputGitAuthor, _NotSetType] = ..., ) -> Dict[str, Union[Commit, _NotSetType]]: ... @property def delete_branch_on_merge(self) -> bool: ... @property def deployments_url(self) -> str: ... @property def description(self) -> str: ... def disable_automated_security_fixes(self) -> bool: ... def disable_vulnerability_alert(self) -> bool: ... @property def downloads_url(self) -> str: ... def edit( self, name: Optional[str] = ..., description: Union[str, _NotSetType] = ..., homepage: Union[str, _NotSetType] = ..., private: Union[bool, _NotSetType] = ..., has_issues: Union[bool, _NotSetType] = ..., has_projects: Union[bool, _NotSetType] = ..., has_wiki: Union[bool, _NotSetType] = ..., has_downloads: Union[bool, _NotSetType] = ..., default_branch: Union[str, _NotSetType] = ..., allow_squash_merge: Union[bool, _NotSetType] = ..., allow_merge_commit: Union[bool, _NotSetType] = ..., allow_rebase_merge: Union[bool, _NotSetType] = ..., delete_branch_on_merge: Union[bool, _NotSetType] = ..., archived: Union[bool, _NotSetType] = ..., ) -> None: ... def enable_automated_security_fixes(self) -> bool: ... def enable_vulnerability_alert(self) -> bool: ... @property def events_url(self) -> str: ... @property def fork(self) -> bool: ... @property def forks(self) -> int: ... @property def forks_count(self) -> int: ... @property def forks_url(self) -> str: ... @property def full_name(self) -> str: ... def get_archive_link( self, archive_format: str, ref: Union[str, _NotSetType] = ... ) -> str: ... def get_assignees(self) -> PaginatedList[NamedUser]: ... def get_branch(self, branch: str) -> Branch: ... def get_branches(self) -> PaginatedList[Branch]: ... def get_check_run(self, check_run_id: int) -> CheckRun: ... def get_check_suite(self, check_suite_id: int) -> CheckSuite: ... def get_clones_traffic( self, per: Union[str, _NotSetType] = ... ) -> Dict[str, Union[int, List[Clones]]]: ... def get_collaborator_permission( self, collaborator: Union[str, NamedUser] ) -> str: ... def get_collaborators( self, affiliation: Union[str, _NotSetType] = ... ) -> PaginatedList[NamedUser]: ... def get_comment(self, id: int) -> CommitComment: ... def get_comments(self) -> PaginatedList[CommitComment]: ... def get_commit(self, sha: str) -> Commit: ... def get_commits( self, sha: Union[str, _NotSetType] = ..., path: Union[str, _NotSetType] = ..., since: Union[_NotSetType, datetime] = ..., until: Union[_NotSetType, datetime] = ..., author: Union[AuthenticatedUser, NamedUser, str, _NotSetType] = ..., ) -> PaginatedList[Commit]: ... def get_contents( self, path: str, ref: Union[str, _NotSetType] = ... ) -> Union[List[ContentFile], ContentFile]: ... def get_contributors( self, anon: Union[str, _NotSetType] = ... ) -> PaginatedList[NamedUser]: ... def get_deployment(self, id_: int) -> Deployment: ... def get_deployments( self, sha: Union[str, _NotSetType] = ..., ref: Union[str, _NotSetType] = ..., task: Union[str, _NotSetType] = ..., environment: Union[str, _NotSetType] = ..., ) -> PaginatedList[Deployment]: ... def get_dir_contents( self, path: str, ref: Union[str, _NotSetType] = ... ) -> List[ContentFile]: ... def get_download(self, id: int) -> Download: ... def get_downloads(self) -> PaginatedList[Download]: ... def get_events(self) -> PaginatedList[Event]: ... def get_forks(self) -> PaginatedList[Repository]: ... def create_fork( self, organization: Union[str, _NotSetType] = ... ) -> Repository: ... def get_git_blob(self, sha: str) -> GitBlob: ... def get_git_commit(self, sha: str) -> GitCommit: ... def get_git_matching_refs(self, ref: str) -> PaginatedList[GitRef]: ... def get_git_ref(self, ref: str) -> GitRef: ... def get_git_refs(self) -> PaginatedList[GitRef]: ... def get_git_tag(self, sha: str) -> GitTag: ... def get_git_tree( self, sha: str, recursive: Union[bool, _NotSetType] = ... ) -> GitTree: ... def get_hook(self, id: int) -> Hook: ... def get_hooks(self) -> PaginatedList[Hook]: ... def get_issue(self, number: int) -> Issue: ... def get_issues( self, milestone: Union[Milestone, str, _NotSetType] = ..., state: Union[str, _NotSetType] = ..., assignee: Union[NamedUser, str, _NotSetType] = ..., mentioned: Union[_NotSetType, NamedUser] = ..., labels: Union[List[str], List[Label], _NotSetType] = ..., sort: Union[str, _NotSetType] = ..., direction: Union[str, _NotSetType] = ..., since: Union[_NotSetType, datetime] = ..., creator: Union[NamedUser, _NotSetType] = ..., ) -> PaginatedList[Issue]: ... def get_issues_comments( self, sort: Union[str, _NotSetType] = ..., direction: Union[str, _NotSetType] = ..., since: Union[_NotSetType, datetime] = ..., ) -> PaginatedList[IssueComment]: ... def get_issues_event(self, id: int) -> IssueEvent: ... def get_issues_events(self) -> PaginatedList[IssueEvent]: ... def get_key(self, id: int) -> RepositoryKey: ... def get_keys(self) -> PaginatedList[RepositoryKey]: ... def get_label(self, name: str) -> Label: ... def get_labels(self) -> PaginatedList[Label]: ... def get_languages(self) -> Dict[str, int]: ... def get_latest_release(self) -> GitRelease: ... def get_license(self) -> ContentFile: ... def get_milestone(self, number: int) -> Milestone: ... def get_milestones( self, state: Union[str, _NotSetType] = ..., sort: Union[str, _NotSetType] = ..., direction: Union[str, _NotSetType] = ..., ) -> PaginatedList[Milestone]: ... def get_network_events(self) -> PaginatedList[Event]: ... def get_notifications( self, all: Union[bool, _NotSetType] = ..., participating: Union[bool, _NotSetType] = ..., since: Union[datetime, _NotSetType] = ..., before: Union[datetime, _NotSetType] = ..., ) -> PaginatedList[Notification]: ... def get_pending_invitations(self) -> PaginatedList[Invitation]: ... def get_projects( self, state: Union[str, _NotSetType] = ... ) -> PaginatedList[Project]: ... def get_public_key(self) -> PublicKey: ... def get_pull(self, number: int) -> PullRequest: ... def get_pulls( self, state: Union[str, _NotSetType] = ..., sort: Union[str, _NotSetType] = ..., direction: Union[str, _NotSetType] = ..., base: Union[str, _NotSetType] = ..., head: Union[str, _NotSetType] = ..., ) -> PaginatedList[PullRequest]: ... def get_pulls_comments( self, sort: Union[str, _NotSetType] = ..., direction: Union[str, _NotSetType] = ..., since: Union[_NotSetType, datetime] = ..., ) -> PaginatedList[PullRequestComment]: ... def get_pulls_review_comments( self, sort: Union[str, _NotSetType] = ..., direction: Union[str, _NotSetType] = ..., since: Union[_NotSetType, datetime] = ..., ) -> PaginatedList[PullRequestComment]: ... def get_readme(self, ref: Union[str, _NotSetType] = ...) -> ContentFile: ... def get_release(self, id: Union[int, str]) -> GitRelease: ... def get_release_asset(self, id: int) -> GitReleaseAsset: ... def get_releases(self) -> PaginatedList[GitRelease]: ... def get_self_hosted_runner(self, runner_id: int) -> SelfHostedActionsRunner: ... def get_self_hosted_runners(self) -> PaginatedList[SelfHostedActionsRunner]: ... def get_source_import(self) -> SourceImport: ... def get_stargazers(self) -> PaginatedList[NamedUser]: ... def get_stargazers_with_dates(self) -> PaginatedList[Stargazer]: ... def get_stats_code_frequency(self) -> Optional[List[StatsCodeFrequency]]: ... def get_stats_commit_activity(self) -> Optional[List[StatsCommitActivity]]: ... def get_stats_contributors(self) -> Optional[List[StatsContributor]]: ... def get_stats_participation(self) -> Optional[StatsParticipation]: ... def get_stats_punch_card(self) -> Optional[StatsPunchCard]: ... def get_subscribers(self) -> PaginatedList[NamedUser]: ... def get_tags(self) -> PaginatedList[Tag]: ... def get_teams(self) -> PaginatedList[Team]: ... def get_top_paths(self) -> List[Path]: ... def get_top_referrers(self) -> List[Referrer]: ... def get_topics(self) -> List[str]: ... def get_views_traffic( self, per: Union[str, _NotSetType] = ... ) -> Dict[str, Union[int, List[View]]]: ... def get_vulnerability_alert(self) -> bool: ... def get_watchers(self) -> PaginatedList[NamedUser]: ... def get_workflow(self, id_or_name: Union[str, int]) -> Workflow: ... def get_workflows(self) -> PaginatedList[Workflow]: ... def get_workflow_run(self, id_: int) -> WorkflowRun: ... def get_workflow_runs(self) -> PaginatedList[WorkflowRun]: ... def update_check_suites_preferences( self, auto_trigger_checks: List[Dict[str, Union[bool, int]]] ) -> RepositoryPreferences: ... @property def git_commits_url(self) -> str: ... @property def git_refs_url(self) -> str: ... @property def git_tags_url(self) -> str: ... @property def git_url(self) -> str: ... @property def has_downloads(self) -> bool: ... def has_in_assignees(self, assignee: Union[str, NamedUser]) -> bool: ... def has_in_collaborators(self, collaborator: Union[str, NamedUser]) -> bool: ... @property def has_issues(self) -> bool: ... @property def has_pages(self) -> bool: ... @property def has_projects(self) -> bool: ... @property def has_wiki(self) -> bool: ... @property def homepage(self) -> str: ... @property def hooks_url(self) -> str: ... @property def html_url(self) -> str: ... @property def id(self) -> int: ... @property def issue_comment_url(self) -> str: ... @property def issue_events_url(self) -> str: ... @property def issues_url(self) -> str: ... @property def keys_url(self) -> str: ... @property def labels_url(self) -> str: ... @property def language(self) -> str: ... @property def languages_url(self) -> str: ... def legacy_search_issues(self, state: str, keyword: str) -> List[Issue]: ... def mark_notifications_as_read(self, last_read_at: datetime = ...) -> None: ... @property def master_branch(self) -> Optional[str]: ... def merge( self, base: str, head: str, commit_message: Union[str, _NotSetType] = ... ) -> Optional[Commit]: ... @property def merges_url(self) -> str: ... @property def milestones_url(self) -> str: ... @property def mirror_url(self) -> str: ... @property def name(self) -> str: ... @property def network_count(self) -> int: ... @property def notifications_url(self) -> str: ... @property def open_issues(self) -> int: ... @property def open_issues_count(self) -> int: ... @property def organization(self) -> Organization: ... @property def owner(self) -> NamedUser: ... @property def parent(self) -> Repository: ... @property def permissions(self) -> Permissions: ... @property def private(self) -> bool: ... @property def pulls_url(self) -> str: ... @property def pushed_at(self) -> datetime: ... @property def releases_url(self) -> str: ... def remove_from_collaborators( self, collaborator: Union[str, NamedUser] ) -> None: ... def remove_self_hosted_runner( self, runner: Union[SelfHostedActionsRunner, int] ) -> bool: ... def remove_invitation(self, invite_id: int) -> None: ... def replace_topics(self, topics: List[str]) -> None: ... @property def size(self) -> int: ... @property def source(self) -> Optional[Repository]: ... @property def ssh_url(self) -> str: ... @property def stargazers_count(self) -> int: ... @property def stargazers_url(self) -> str: ... @property def statuses_url(self) -> str: ... def subscribe_to_hub( self, event: str, callback: str, secret: Union[str, _NotSetType] = ... ) -> None: ... @property def subscribers_count(self) -> int: ... @property def subscribers_url(self) -> str: ... @property def subscription_url(self) -> str: ... @property def svn_url(self) -> str: ... @property def tags_url(self) -> str: ... @property def teams_url(self) -> str: ... @property def trees_url(self) -> str: ... def unsubscribe_from_hub(self, event: str, callback: str) -> None: ... def update_file( self, path: str, message: str, content: Union[bytes, str], sha: str, branch: Union[_NotSetType, str] = ..., committer: Union[_NotSetType, InputGitAuthor] = ..., author: Union[_NotSetType, InputGitAuthor] = ..., ) -> Dict[str, Union[ContentFile, Commit]]: ... @property def updated_at(self) -> datetime: ... @property def url(self) -> str: ... @property def watchers(self) -> int: ... @property def watchers_count(self) -> int: ... ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1619412308.0 PyGithub-1.55/github/RepositoryKey.py0000644000175100001710000001331100000000000017222 0ustar00runnerdocker############################ Copyrights and license ############################ # # # Copyright 2012 Vincent Jacques # # Copyright 2012 Zearin # # Copyright 2013 AKFish # # Copyright 2013 Srijan Choudhary # # Copyright 2013 Vincent Jacques # # Copyright 2013 martinqt # # Copyright 2014 Vincent Jacques # # Copyright 2016 Jannis Gebauer # # Copyright 2016 Peter Buckley # # Copyright 2017 Jimmy Zelinskie # # Copyright 2017 Simon # # Copyright 2018 Laurent Raufaste # # Copyright 2018 Wan Liuyang # # Copyright 2018 sfdye # # # # This file is part of PyGithub. # # http://pygithub.readthedocs.io/ # # # # PyGithub is free software: you can redistribute it and/or modify it under # # the terms of the GNU Lesser General Public License as published by the Free # # Software Foundation, either version 3 of the License, or (at your option) # # any later version. # # # # PyGithub is distributed in the hope that it will be useful, but WITHOUT ANY # # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more # # details. # # # # You should have received a copy of the GNU Lesser General Public License # # along with PyGithub. If not, see . # # # ################################################################################ import github.GithubObject class RepositoryKey(github.GithubObject.CompletableGithubObject): """ This class represents RepositoryKeys. The reference can be found here http://docs.github.com/en/rest/reference/repos#deploy-keys """ def __repr__(self): return self.get__repr__({"id": self._id.value, "title": self._title.value}) @property def created_at(self): """ :type: datetime.datetime """ self._completeIfNotSet(self._created_at) return self._created_at.value @property def id(self): """ :type: integer """ self._completeIfNotSet(self._id) return self._id.value @property def key(self): """ :type: string """ self._completeIfNotSet(self._key) return self._key.value @property def title(self): """ :type: string """ self._completeIfNotSet(self._title) return self._title.value @property def url(self): """ :type: string """ self._completeIfNotSet(self._url) return self._url.value @property def verified(self): """ :type: bool """ self._completeIfNotSet(self._verified) return self._verified.value @property def read_only(self): """ :type: bool """ self._completeIfNotSet(self._read_only) return self._read_only.value def delete(self): """ :calls: `DELETE /repos/{owner}/{repo}/keys/{id} `_ :rtype: None """ headers, data = self._requester.requestJsonAndCheck("DELETE", self.url) def _initAttributes(self): self._created_at = github.GithubObject.NotSet self._id = github.GithubObject.NotSet self._key = github.GithubObject.NotSet self._title = github.GithubObject.NotSet self._url = github.GithubObject.NotSet self._verified = github.GithubObject.NotSet self._read_only = github.GithubObject.NotSet def _useAttributes(self, attributes): if "created_at" in attributes: # pragma no branch self._created_at = self._makeDatetimeAttribute(attributes["created_at"]) if "id" in attributes: # pragma no branch self._id = self._makeIntAttribute(attributes["id"]) if "key" in attributes: # pragma no branch self._key = self._makeStringAttribute(attributes["key"]) if "title" in attributes: # pragma no branch self._title = self._makeStringAttribute(attributes["title"]) if "url" in attributes: # pragma no branch self._url = self._makeStringAttribute(attributes["url"]) if "verified" in attributes: # pragma no branch self._verified = self._makeBoolAttribute(attributes["verified"]) if "read_only" in attributes: # pragma no branch self._read_only = self._makeBoolAttribute(attributes["read_only"]) ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1619412308.0 PyGithub-1.55/github/RepositoryKey.pyi0000644000175100001710000000124700000000000017400 0ustar00runnerdockerfrom datetime import datetime from typing import Any, Dict from github.GithubObject import CompletableGithubObject class RepositoryKey(CompletableGithubObject): def __repr__(self) -> str: ... def _initAttributes(self) -> None: ... def _useAttributes(self, attributes: Dict[str, Any]) -> None: ... @property def created_at(self) -> datetime: ... def delete(self) -> None: ... @property def id(self) -> int: ... @property def key(self) -> str: ... @property def read_only(self) -> bool: ... @property def title(self) -> str: ... @property def url(self) -> str: ... @property def verified(self) -> bool: ... ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1619412308.0 PyGithub-1.55/github/RepositoryPreferences.py0000644000175100001710000000545500000000000020745 0ustar00runnerdocker############################ Copyrights and license ############################ # # # Copyright 2020 Dhruv Manilawala # # # # This file is part of PyGithub. # # http://pygithub.readthedocs.io/ # # # # PyGithub is free software: you can redistribute it and/or modify it under # # the terms of the GNU Lesser General Public License as published by the Free # # Software Foundation, either version 3 of the License, or (at your option) # # any later version. # # # # PyGithub is distributed in the hope that it will be useful, but WITHOUT ANY # # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more # # details. # # # # You should have received a copy of the GNU Lesser General Public License # # along with PyGithub. If not, see . # # # ################################################################################ import github.GithubObject import github.Repository class RepositoryPreferences(github.GithubObject.NonCompletableGithubObject): """ This class represents repository preferences. The reference can be found here https://docs.github.com/en/free-pro-team@latest/rest/reference/checks#update-repository-preferences-for-check-suites """ @property def preferences(self): """ :type: dict """ return self._preferences.value @property def repository(self): """ :type: :class:`github.Repository.Repository` """ return self._repository.value def _initAttributes(self): self._preferences = github.GithubObject.NotSet self._repository = github.GithubObject.NotSet def _useAttributes(self, attributes): if "preferences" in attributes: # pragma no branch self._preferences = self._makeDictAttribute(attributes["preferences"]) if "repository" in attributes: # pragma no branch self._repository = self._makeClassAttribute( github.Repository.Repository, attributes["repository"] ) ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1619412308.0 PyGithub-1.55/github/RepositoryPreferences.pyi0000644000175100001710000000072100000000000021105 0ustar00runnerdockerfrom typing import Any, Dict, List, Union from github.GithubObject import NonCompletableGithubObject from github.Repository import Repository class RepositoryPreferences(NonCompletableGithubObject): def _initAttributes(self) -> None: ... def _useAttributes(self, attributes: Dict[str, Any]) -> None: ... @property def preferences(self) -> Dict[str, List[Dict[str, Union[bool, int]]]]: ... @property def repository(self) -> Repository: ... ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1619412308.0 PyGithub-1.55/github/Requester.py0000644000175100001710000005744200000000000016366 0ustar00runnerdocker############################ Copyrights and license ############################ # # # Copyright 2012 Andrew Bettison # # Copyright 2012 Dima Kukushkin # # Copyright 2012 Michael Woodworth # # Copyright 2012 Petteri Muilu # # Copyright 2012 Steve English # # Copyright 2012 Vincent Jacques # # Copyright 2012 Zearin # # Copyright 2013 AKFish # # Copyright 2013 Cameron White # # Copyright 2013 Ed Jackson # # Copyright 2013 Jonathan J Hunt # # Copyright 2013 Mark Roddy # # Copyright 2013 Vincent Jacques # # Copyright 2014 Jimmy Zelinskie # # Copyright 2014 Vincent Jacques # # Copyright 2015 Brian Eugley # # Copyright 2015 Daniel Pocock # # Copyright 2015 Jimmy Zelinskie # # Copyright 2016 Denis K # # Copyright 2016 Jared K. Smith # # Copyright 2016 Jimmy Zelinskie # # Copyright 2016 Mathieu Mitchell # # Copyright 2016 Peter Buckley # # Copyright 2017 Chris McBride # # Copyright 2017 Hugo # # Copyright 2017 Simon # # Copyright 2018 Dylan # # Copyright 2018 Maarten Fonville # # Copyright 2018 Mike Miller # # Copyright 2018 R1kk3r # # Copyright 2018 sfdye # # # # This file is part of PyGithub. # # http://pygithub.readthedocs.io/ # # # # PyGithub is free software: you can redistribute it and/or modify it under # # the terms of the GNU Lesser General Public License as published by the Free # # Software Foundation, either version 3 of the License, or (at your option) # # any later version. # # # # PyGithub is distributed in the hope that it will be useful, but WITHOUT ANY # # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more # # details. # # # # You should have received a copy of the GNU Lesser General Public License # # along with PyGithub. If not, see . # # # ################################################################################ import base64 import json import logging import mimetypes import os import re import time import urllib from io import IOBase import requests from . import Consts, GithubException class RequestsResponse: # mimic the httplib response object def __init__(self, r): self.status = r.status_code self.headers = r.headers self.text = r.text def getheaders(self): return self.headers.items() def read(self): return self.text class HTTPSRequestsConnectionClass: # mimic the httplib connection object def __init__( self, host, port=None, strict=False, timeout=None, retry=None, pool_size=None, **kwargs, ): self.port = port if port else 443 self.host = host self.protocol = "https" self.timeout = timeout self.verify = kwargs.get("verify", True) self.session = requests.Session() if retry is None: self.retry = requests.adapters.DEFAULT_RETRIES else: self.retry = retry if pool_size is None: self.pool_size = requests.adapters.DEFAULT_POOLSIZE else: self.pool_size = pool_size self.adapter = requests.adapters.HTTPAdapter( max_retries=self.retry, pool_connections=self.pool_size, pool_maxsize=self.pool_size, ) self.session.mount("https://", self.adapter) def request(self, verb, url, input, headers): self.verb = verb self.url = url self.input = input self.headers = headers def getresponse(self): verb = getattr(self.session, self.verb.lower()) url = f"{self.protocol}://{self.host}:{self.port}{self.url}" r = verb( url, headers=self.headers, data=self.input, timeout=self.timeout, verify=self.verify, allow_redirects=False, ) return RequestsResponse(r) def close(self): return class HTTPRequestsConnectionClass: # mimic the httplib connection object def __init__( self, host, port=None, strict=False, timeout=None, retry=None, pool_size=None, **kwargs, ): self.port = port if port else 80 self.host = host self.protocol = "http" self.timeout = timeout self.verify = kwargs.get("verify", True) self.session = requests.Session() if retry is None: self.retry = requests.adapters.DEFAULT_RETRIES else: self.retry = retry if pool_size is None: self.pool_size = requests.adapters.DEFAULT_POOLSIZE else: self.pool_size = pool_size self.adapter = requests.adapters.HTTPAdapter( max_retries=self.retry, pool_connections=self.pool_size, pool_maxsize=self.pool_size, ) self.session.mount("http://", self.adapter) def request(self, verb, url, input, headers): self.verb = verb self.url = url self.input = input self.headers = headers def getresponse(self): verb = getattr(self.session, self.verb.lower()) url = f"{self.protocol}://{self.host}:{self.port}{self.url}" r = verb( url, headers=self.headers, data=self.input, timeout=self.timeout, verify=self.verify, allow_redirects=False, ) return RequestsResponse(r) def close(self): return class Requester: __httpConnectionClass = HTTPRequestsConnectionClass __httpsConnectionClass = HTTPSRequestsConnectionClass __connection = None __persist = True __logger = None @classmethod def injectConnectionClasses(cls, httpConnectionClass, httpsConnectionClass): cls.__persist = False cls.__httpConnectionClass = httpConnectionClass cls.__httpsConnectionClass = httpsConnectionClass @classmethod def resetConnectionClasses(cls): cls.__persist = True cls.__httpConnectionClass = HTTPRequestsConnectionClass cls.__httpsConnectionClass = HTTPSRequestsConnectionClass @classmethod def injectLogger(cls, logger): cls.__logger = logger @classmethod def resetLogger(cls): cls.__logger = None ############################################################# # For Debug @classmethod def setDebugFlag(cls, flag): cls.DEBUG_FLAG = flag @classmethod def setOnCheckMe(cls, onCheckMe): cls.ON_CHECK_ME = onCheckMe DEBUG_FLAG = False DEBUG_FRAME_BUFFER_SIZE = 1024 DEBUG_HEADER_KEY = "DEBUG_FRAME" ON_CHECK_ME = None def NEW_DEBUG_FRAME(self, requestHeader): """ Initialize a debug frame with requestHeader Frame count is updated and will be attached to respond header The structure of a frame: [requestHeader, statusCode, responseHeader, raw_data] Some of them may be None """ if self.DEBUG_FLAG: # pragma no branch (Flag always set in tests) new_frame = [requestHeader, None, None, None] if ( self._frameCount < self.DEBUG_FRAME_BUFFER_SIZE - 1 ): # pragma no branch (Should be covered) self._frameBuffer.append(new_frame) else: self._frameBuffer[0] = new_frame # pragma no cover (Should be covered) self._frameCount = len(self._frameBuffer) - 1 def DEBUG_ON_RESPONSE(self, statusCode, responseHeader, data): """ Update current frame with response Current frame index will be attached to responseHeader """ if self.DEBUG_FLAG: # pragma no branch (Flag always set in tests) self._frameBuffer[self._frameCount][1:4] = [ statusCode, responseHeader, data, ] responseHeader[self.DEBUG_HEADER_KEY] = self._frameCount def check_me(self, obj): if ( self.DEBUG_FLAG and self.ON_CHECK_ME is not None ): # pragma no branch (Flag always set in tests) frame = None if self.DEBUG_HEADER_KEY in obj._headers: frame_index = obj._headers[self.DEBUG_HEADER_KEY] frame = self._frameBuffer[frame_index] self.ON_CHECK_ME(obj, frame) def _initializeDebugFeature(self): self._frameCount = 0 self._frameBuffer = [] ############################################################# def __init__( self, login_or_token, password, jwt, base_url, timeout, user_agent, per_page, verify, retry, pool_size, ): self._initializeDebugFeature() if password is not None: login = login_or_token b64 = ( base64.b64encode((f"{login}:{password}").encode("utf-8")) .decode("utf-8") .replace("\n", "") ) self.__authorizationHeader = f"Basic {b64}" elif login_or_token is not None: token = login_or_token self.__authorizationHeader = f"token {token}" elif jwt is not None: self.__authorizationHeader = f"Bearer {jwt}" else: self.__authorizationHeader = None self.__base_url = base_url o = urllib.parse.urlparse(base_url) self.__hostname = o.hostname self.__port = o.port self.__prefix = o.path self.__timeout = timeout self.__retry = retry # NOTE: retry can be either int or an urllib3 Retry object self.__pool_size = pool_size self.__scheme = o.scheme if o.scheme == "https": self.__connectionClass = self.__httpsConnectionClass elif o.scheme == "http": self.__connectionClass = self.__httpConnectionClass else: assert False, "Unknown URL scheme" self.rate_limiting = (-1, -1) self.rate_limiting_resettime = 0 self.FIX_REPO_GET_GIT_REF = True self.per_page = per_page self.oauth_scopes = None assert user_agent is not None, ( "github now requires a user-agent. " "See http://docs.github.com/en/rest/reference/#user-agent-required" ) self.__userAgent = user_agent self.__verify = verify def requestJsonAndCheck(self, verb, url, parameters=None, headers=None, input=None): return self.__check( *self.requestJson( verb, url, parameters, headers, input, self.__customConnection(url) ) ) def requestMultipartAndCheck( self, verb, url, parameters=None, headers=None, input=None ): return self.__check( *self.requestMultipart( verb, url, parameters, headers, input, self.__customConnection(url) ) ) def requestBlobAndCheck(self, verb, url, parameters=None, headers=None, input=None): return self.__check( *self.requestBlob( verb, url, parameters, headers, input, self.__customConnection(url) ) ) def __check(self, status, responseHeaders, output): output = self.__structuredFromJson(output) if status >= 400: raise self.__createException(status, responseHeaders, output) return responseHeaders, output def __customConnection(self, url): cnx = None if not url.startswith("/"): o = urllib.parse.urlparse(url) if ( o.hostname != self.__hostname or (o.port and o.port != self.__port) or ( o.scheme != self.__scheme and not (o.scheme == "https" and self.__scheme == "http") ) ): # issue80 if o.scheme == "http": cnx = self.__httpConnectionClass( o.hostname, o.port, retry=self.__retry, pool_size=self.__pool_size, ) elif o.scheme == "https": cnx = self.__httpsConnectionClass( o.hostname, o.port, retry=self.__retry, pool_size=self.__pool_size, ) return cnx def __createException(self, status, headers, output): if status == 401 and output.get("message") == "Bad credentials": cls = GithubException.BadCredentialsException elif ( status == 401 and Consts.headerOTP in headers and re.match(r".*required.*", headers[Consts.headerOTP]) ): cls = GithubException.TwoFactorException elif status == 403 and output.get("message").startswith( "Missing or invalid User Agent string" ): cls = GithubException.BadUserAgentException elif status == 403 and ( output.get("message").lower().startswith("api rate limit exceeded") or output.get("message") .lower() .endswith("please wait a few minutes before you try again.") ): cls = GithubException.RateLimitExceededException elif status == 404 and output.get("message") == "Not Found": cls = GithubException.UnknownObjectException else: cls = GithubException.GithubException return cls(status, output, headers) def __structuredFromJson(self, data): if len(data) == 0: return None else: if isinstance(data, bytes): data = data.decode("utf-8") try: return json.loads(data) except ValueError: if data.startswith("{") or data.startswith("["): raise return {"data": data} def requestJson( self, verb, url, parameters=None, headers=None, input=None, cnx=None ): def encode(input): return "application/json", json.dumps(input) return self.__requestEncode(cnx, verb, url, parameters, headers, input, encode) def requestMultipart( self, verb, url, parameters=None, headers=None, input=None, cnx=None ): def encode(input): boundary = "----------------------------3c3ba8b523b2" eol = "\r\n" encoded_input = "" for name, value in input.items(): encoded_input += f"--{boundary}{eol}" encoded_input += f'Content-Disposition: form-data; name="{name}"{eol}' encoded_input += eol encoded_input += value + eol encoded_input += f"--{boundary}--{eol}" return f"multipart/form-data; boundary={boundary}", encoded_input return self.__requestEncode(cnx, verb, url, parameters, headers, input, encode) def requestBlob(self, verb, url, parameters={}, headers={}, input=None, cnx=None): def encode(local_path): if "Content-Type" in headers: mime_type = headers["Content-Type"] else: guessed_type = mimetypes.guess_type(input) mime_type = ( guessed_type[0] if guessed_type[0] is not None else Consts.defaultMediaType ) f = open(local_path, "rb") return mime_type, f if input: headers["Content-Length"] = str(os.path.getsize(input)) return self.__requestEncode(cnx, verb, url, parameters, headers, input, encode) def requestMemoryBlobAndCheck( self, verb, url, parameters, headers, file_like, cnx=None ): # The expected signature of encode means that the argument is ignored. def encode(_): return headers["Content-Type"], file_like if not cnx: cnx = self.__customConnection(url) return self.__check( *self.__requestEncode( cnx, verb, url, parameters, headers, file_like, encode ) ) def __requestEncode( self, cnx, verb, url, parameters, requestHeaders, input, encode ): assert verb in ["HEAD", "GET", "POST", "PATCH", "PUT", "DELETE"] if parameters is None: parameters = dict() if requestHeaders is None: requestHeaders = dict() self.__authenticate(url, requestHeaders, parameters) requestHeaders["User-Agent"] = self.__userAgent url = self.__makeAbsoluteUrl(url) url = self.__addParametersToUrl(url, parameters) encoded_input = None if input is not None: requestHeaders["Content-Type"], encoded_input = encode(input) self.NEW_DEBUG_FRAME(requestHeaders) status, responseHeaders, output = self.__requestRaw( cnx, verb, url, requestHeaders, encoded_input ) if ( Consts.headerRateRemaining in responseHeaders and Consts.headerRateLimit in responseHeaders ): self.rate_limiting = ( int(responseHeaders[Consts.headerRateRemaining]), int(responseHeaders[Consts.headerRateLimit]), ) if Consts.headerRateReset in responseHeaders: self.rate_limiting_resettime = int(responseHeaders[Consts.headerRateReset]) if Consts.headerOAuthScopes in responseHeaders: self.oauth_scopes = responseHeaders[Consts.headerOAuthScopes].split(", ") self.DEBUG_ON_RESPONSE(status, responseHeaders, output) return status, responseHeaders, output def __requestRaw(self, cnx, verb, url, requestHeaders, input): original_cnx = cnx if cnx is None: cnx = self.__createConnection() cnx.request(verb, url, input, requestHeaders) response = cnx.getresponse() status = response.status responseHeaders = {k.lower(): v for k, v in response.getheaders()} output = response.read() cnx.close() if input: if isinstance(input, IOBase): input.close() self.__log(verb, url, requestHeaders, input, status, responseHeaders, output) if status == 202 and ( verb == "GET" or verb == "HEAD" ): # only for requests that are considered 'safe' in RFC 2616 time.sleep(Consts.PROCESSING_202_WAIT_TIME) return self.__requestRaw(original_cnx, verb, url, requestHeaders, input) if status == 301 and "location" in responseHeaders: o = urllib.parse.urlparse(responseHeaders["location"]) return self.__requestRaw(original_cnx, verb, o.path, requestHeaders, input) return status, responseHeaders, output def __authenticate(self, url, requestHeaders, parameters): if self.__authorizationHeader is not None: requestHeaders["Authorization"] = self.__authorizationHeader def __makeAbsoluteUrl(self, url): # URLs generated locally will be relative to __base_url # URLs returned from the server will start with __base_url if url.startswith("/"): url = f"{self.__prefix}{url}" else: o = urllib.parse.urlparse(url) assert o.hostname in [ self.__hostname, "uploads.github.com", "status.github.com", "github.com", ], o.hostname assert o.path.startswith((self.__prefix, "/api/")) assert o.port == self.__port url = o.path if o.query != "": url += f"?{o.query}" return url def __addParametersToUrl(self, url, parameters): if len(parameters) == 0: return url else: return f"{url}?{urllib.parse.urlencode(parameters)}" def __createConnection(self): kwds = {} kwds["timeout"] = self.__timeout kwds["verify"] = self.__verify if self.__persist and self.__connection is not None: return self.__connection self.__connection = self.__connectionClass( self.__hostname, self.__port, retry=self.__retry, pool_size=self.__pool_size, **kwds, ) return self.__connection def __log(self, verb, url, requestHeaders, input, status, responseHeaders, output): if self.__logger is None: self.__logger = logging.getLogger(__name__) if self.__logger.isEnabledFor(logging.DEBUG): if "Authorization" in requestHeaders: if requestHeaders["Authorization"].startswith("Basic"): requestHeaders[ "Authorization" ] = "Basic (login and password removed)" elif requestHeaders["Authorization"].startswith("token"): requestHeaders["Authorization"] = "token (oauth token removed)" elif requestHeaders["Authorization"].startswith("Bearer"): requestHeaders["Authorization"] = "Bearer (jwt removed)" else: # pragma no cover (Cannot happen, but could if we add an authentication method => be prepared) requestHeaders[ "Authorization" ] = "(unknown auth removed)" # pragma no cover (Cannot happen, but could if we add an authentication method => be prepared) self.__logger.debug( "%s %s://%s%s %s %s ==> %i %s %s", verb, self.__scheme, self.__hostname, url, requestHeaders, input, status, responseHeaders, output, ) ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1619412308.0 PyGithub-1.55/github/Requester.pyi0000644000175100001710000001355700000000000016536 0ustar00runnerdockerfrom collections import OrderedDict from io import BufferedReader from typing import Any, Callable, Dict, Iterator, Optional, Tuple, Union from requests.models import Response from github.GithubObject import GithubObject # from urllib3.util.retry import Retry class HTTPRequestsConnectionClass: def __init__( self, host: str, port: Optional[int] = ..., strict: bool = ..., timeout: Optional[int] = ..., retry: Any = ..., **kwargs: str ) -> None: ... def close(self) -> None: ... def getresponse(self) -> RequestsResponse: ... def request( self, verb: str, url: str, input: None, headers: Dict[str, str] ) -> None: ... class HTTPSRequestsConnectionClass: def __init__( self, host: str, port: Optional[int] = ..., strict: bool = ..., timeout: Optional[int] = ..., retry: Any = ..., **kwargs: str ) -> None: ... def close(self) -> None: ... def getresponse(self) -> RequestsResponse: ... def request( self, verb: str, url: str, input: Optional[Union[str, BufferedReader]], headers: Dict[str, str], ) -> None: ... class Requester: def DEBUG_ON_RESPONSE( self, statusCode: int, responseHeader: Dict[str, str], data: str ) -> None: ... def NEW_DEBUG_FRAME(self, requestHeader: Dict[str, str]) -> None: ... def __check( self, status: int, responseHeader: Dict[str, Any], output: str, ) -> Tuple[Dict[str, Any], Dict[str, Any]]: ... def __addParametersToUrl(self, url: str, parameters: Dict[str, Any],) -> str: ... def __authenticate( self, url: str, responseHeader: Dict[str, Any], parameters: Dict[str, Any], ) -> None: ... def __customConnection( self, url: str, ) -> Optional[Union[HTTPRequestsConnectionClass, HTTPSRequestsConnectionClass]]: ... def __createConnection( self, ) -> Union[HTTPRequestsConnectionClass, HTTPSRequestsConnectionClass]: ... def __createException( self, status: int, headers: Dict[str, Any], output: str, ) -> Any: ... def __log( self, verb: str, url: str, requestHeaders: Dict[str, str], input: Optional[str], status: Optional[int], responseHeader: Dict[str, Any], output: Optional[str], ) -> None: ... def __makeAbsoluteUrl(self, url: str) -> str: ... def __structuredFromJson(self, data: str) -> Optional[Dict[str, Any]]: ... def __requestEncode( self, verb: str, url: str, parameters: Dict[str, str] = ..., headers: Dict[str, str] = ..., input: Optional[str] = ..., encode: Callable[[str], str] = ..., ) -> Tuple[int, Dict[str, Any], str]: ... def __requestRaw( self, verb: str, url: str, parameters: Dict[str, str] = ..., headers: Dict[str, str] = ..., input: Optional[str] = ..., ) -> Tuple[int, Dict[str, Any], str]: ... def __init__( self, login_or_token: Optional[str], password: Optional[str], jwt: Optional[str], base_url: str, timeout: int, client_id: Optional[str], client_secret: Optional[str], user_agent: str, per_page: int, verify: bool, retry: Any, ) -> None: ... def _initializeDebugFeature(self) -> None: ... def check_me(self, obj: GithubObject) -> None: ... @classmethod def injectConnectionClasses( cls, httpConnectionClass: Callable, httpsConnectionClass: Callable ) -> None: ... def requestBlob( self, verb: str, url: str, parameters: Dict[str, str] = ..., headers: Dict[str, str] = ..., input: Optional[str] = ..., cnx: Optional[ Union[HTTPRequestsConnectionClass, HTTPSRequestsConnectionClass] ] = ..., ) -> Tuple[int, Dict[str, Any], str]: ... def requestBlobAndCheck( self, verb: str, url: str, parameters: Optional[Dict[str, Any]] = ..., headers: Optional[Dict[str, Any]] = ..., input: Optional[str] = ..., ) -> Tuple[Dict[str, Any], Optional[Dict[str, Any]]]: ... def requestJson( self, verb: str, url: str, parameters: Optional[Dict[str, Any]] = ..., headers: Optional[Dict[str, Any]] = ..., input: Optional[Any] = ..., cnx: Optional[ Union[HTTPRequestsConnectionClass, HTTPSRequestsConnectionClass] ] = ..., ) -> Tuple[int, Dict[str, Any], str]: ... def requestJsonAndCheck( self, verb: str, url: str, parameters: Optional[Dict[str, Any]] = ..., headers: Optional[Dict[str, str]] = ..., input: Optional[Any] = ..., ) -> Tuple[Dict[str, Any], Optional[Dict[str, Any]]]: ... def requestMultipart( self, verb: str, url: str, parameters: Optional[Dict[str, Any]] = ..., headers: Optional[Dict[str, Any]] = ..., input: Optional[OrderedDict] = ..., cnx: Optional[ Union[HTTPRequestsConnectionClass, HTTPSRequestsConnectionClass] ] = ..., ) -> Tuple[int, Dict[str, Any], str]: ... def requestMultipartAndCheck( self, verb: str, url: str, parameters: Optional[Dict[str, Any]] = ..., headers: Optional[Dict[str, Any]] = ..., input: Optional[OrderedDict] = ..., ) -> Tuple[Dict[str, Any], Optional[Dict[str, Any]]]: ... @classmethod def resetConnectionClasses(cls) -> None: ... @classmethod def setDebugFlag(cls, flag: bool) -> None: ... @classmethod def setOnCheckMe(cls, onCheckMe: Callable) -> None: ... class RequestsResponse: def __init__(self, r: Response) -> None: ... def getheaders(self) -> Iterator[Any]: ... def read(self) -> str: ... ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1619412308.0 PyGithub-1.55/github/RequiredPullRequestReviews.py0000644000175100001710000001231200000000000021725 0ustar00runnerdocker############################ Copyrights and license ############################ # # # Copyright 2018 Steve Kowalik # # # # This file is part of PyGithub. # # http://pygithub.readthedocs.io/ # # # # PyGithub is free software: you can redistribute it and/or modify it under # # the terms of the GNU Lesser General Public License as published by the Free # # Software Foundation, either version 3 of the License, or (at your option) # # any later version. # # # # PyGithub is distributed in the hope that it will be useful, but WITHOUT ANY # # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more # # details. # # # # You should have received a copy of the GNU Lesser General Public License # # along with PyGithub. If not, see . # # # ################################################################################ import github.GithubObject import github.NamedUser import github.Team class RequiredPullRequestReviews(github.GithubObject.CompletableGithubObject): """ This class represents Required Pull Request Reviews. The reference can be found here https://docs.github.com/en/rest/reference/repos/branches#get-pull-request-review-enforcement-of-protected-branch """ def __repr__(self): return self.get__repr__( { "url": self._url.value, "dismiss_stale_reviews": self._dismiss_stale_reviews.value, "require_code_owner_reviews": self._require_code_owner_reviews.value, } ) @property def dismiss_stale_reviews(self): """ :type: bool """ self._completeIfNotSet(self._dismiss_stale_reviews) return self._dismiss_stale_reviews.value @property def require_code_owner_reviews(self): """ :type: bool """ self._completeIfNotSet(self._require_code_owner_reviews) return self._require_code_owner_reviews.value @property def required_approving_review_count(self): """ :type: int """ self._completeIfNotSet(self._required_approving_review_count) return self._required_approving_review_count.value @property def url(self): """ :type: string """ self._completeIfNotSet(self._url) return self._url.value @property def dismissal_users(self): """ :type: list of :class:`github.NamedUser.NamedUser` """ self._completeIfNotSet(self._users) return self._users.value @property def dismissal_teams(self): """ :type: list of :class:`github.Team.Team` """ self._completeIfNotSet(self._teams) return self._teams.value def _initAttributes(self): self._dismiss_stale_reviews = github.GithubObject.NotSet self._require_code_owner_reviews = github.GithubObject.NotSet self._required_approving_review_count = github.GithubObject.NotSet self._users = github.GithubObject.NotSet self._teams = github.GithubObject.NotSet def _useAttributes(self, attributes): if "dismissal_restrictions" in attributes: # pragma no branch if "users" in attributes["dismissal_restrictions"]: self._users = self._makeListOfClassesAttribute( github.NamedUser.NamedUser, attributes["dismissal_restrictions"]["users"], ) if "teams" in attributes["dismissal_restrictions"]: # pragma no branch self._teams = self._makeListOfClassesAttribute( github.Team.Team, attributes["dismissal_restrictions"]["teams"] ) if "dismiss_stale_reviews" in attributes: # pragma no branch self._dismiss_stale_reviews = self._makeBoolAttribute( attributes["dismiss_stale_reviews"] ) if "require_code_owner_reviews" in attributes: # pragma no branch self._require_code_owner_reviews = self._makeBoolAttribute( attributes["require_code_owner_reviews"] ) if "required_approving_review_count" in attributes: # pragma no branch self._required_approving_review_count = self._makeIntAttribute( attributes["required_approving_review_count"] ) if "url" in attributes: # pragma no branch self._url = self._makeStringAttribute(attributes["url"]) ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1619412308.0 PyGithub-1.55/github/RequiredPullRequestReviews.pyi0000644000175100001710000000141000000000000022073 0ustar00runnerdockerfrom typing import Any, Dict, List, Optional from github.GithubObject import CompletableGithubObject from github.NamedUser import NamedUser from github.Team import Team class RequiredPullRequestReviews(CompletableGithubObject): def __repr__(self) -> str: ... def _initAttributes(self) -> None: ... def _useAttributes(self, attributes: Dict[str, Any]) -> None: ... @property def dismiss_stale_reviews(self) -> bool: ... @property def dismissal_teams(self) -> Optional[List[Team]]: ... @property def dismissal_users(self) -> Optional[List[NamedUser]]: ... @property def require_code_owner_reviews(self) -> bool: ... @property def required_approving_review_count(self) -> int: ... @property def url(self) -> int: ... ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1619412308.0 PyGithub-1.55/github/RequiredStatusChecks.py0000644000175100001710000000623000000000000020501 0ustar00runnerdocker############################ Copyrights and license ############################ # # # Copyright 2018 Steve Kowalik # # # # This file is part of PyGithub. # # http://pygithub.readthedocs.io/ # # # # PyGithub is free software: you can redistribute it and/or modify it under # # the terms of the GNU Lesser General Public License as published by the Free # # Software Foundation, either version 3 of the License, or (at your option) # # any later version. # # # # PyGithub is distributed in the hope that it will be useful, but WITHOUT ANY # # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more # # details. # # # # You should have received a copy of the GNU Lesser General Public License # # along with PyGithub. If not, see . # # # ################################################################################ import github.GithubObject class RequiredStatusChecks(github.GithubObject.CompletableGithubObject): """ This class represents Required Status Checks. The reference can be found here https://docs.github.com/en/rest/reference/repos/branches#get-required-status-checks-of-protected-branch """ def __repr__(self): return self.get__repr__({"strict": self._strict.value, "url": self._url.value}) @property def strict(self): """ :type: bool """ self._completeIfNotSet(self._strict) return self._strict.value @property def contexts(self): """ :type: list of string """ self._completeIfNotSet(self._contexts) return self._contexts.value @property def url(self): """ :type: string """ self._completeIfNotSet(self._url) return self._url.value def _initAttributes(self): self._strict = github.GithubObject.NotSet self._contexts = github.GithubObject.NotSet self._url = github.GithubObject.NotSet def _useAttributes(self, attributes): if "strict" in attributes: # pragma no branch self._strict = self._makeBoolAttribute(attributes["strict"]) if "contexts" in attributes: # pragma no branch self._contexts = self._makeListOfStringsAttribute(attributes["contexts"]) if "url" in attributes: # pragma no branch self._url = self._makeStringAttribute(attributes["url"]) ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1619412308.0 PyGithub-1.55/github/RequiredStatusChecks.pyi0000644000175100001710000000067100000000000020655 0ustar00runnerdockerfrom typing import Any, Dict, List from github.GithubObject import CompletableGithubObject class RequiredStatusChecks(CompletableGithubObject): def __repr__(self) -> str: ... def _initAttributes(self) -> None: ... def _useAttributes(self, attributes: Dict[str, Any]) -> None: ... @property def contexts(self) -> List[str]: ... @property def strict(self) -> bool: ... @property def url(self) -> str: ... ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1619412308.0 PyGithub-1.55/github/SelfHostedActionsRunner.py0000644000175100001710000000747400000000000021162 0ustar00runnerdocker############################ Copyrights and license ############################ # # # Copyright 2020 Victor Zeng # # # # This file is part of PyGithub. # # http://pygithub.readthedocs.io/ # # # # PyGithub is free software: you can redistribute it and/or modify it under # # the terms of the GNU Lesser General Public License as published by the Free # # Software Foundation, either version 3 of the License, or (at your option) # # any later version. # # # # PyGithub is distributed in the hope that it will be useful, but WITHOUT ANY # # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more # # details. # # # # You should have received a copy of the GNU Lesser General Public License # # along with PyGithub. If not, see . # # # ################################################################################ import github.GithubObject class SelfHostedActionsRunner(github.GithubObject.NonCompletableGithubObject): """ This class represents Self-hosted GitHub Actions Runners. The reference can be found at https://docs.github.com/en/free-pro-team@latest/rest/reference/actions#self-hosted-runners """ def __repr__(self): return self.get__repr__({"name": self._name.value}) @property def id(self): """ :type: int """ return self._id.value @property def name(self): """ :type: string """ return self._name.value @property def os(self): """ :type: string """ return self._os.value @property def status(self): """ :type: str """ return self._status.value @property def busy(self): """ :type: bool """ return self._busy.value def labels(self): """ :type: list of dicts """ return self._labels.value def _initAttributes(self): self._id = github.GithubObject.NotSet self._name = github.GithubObject.NotSet self._os = github.GithubObject.NotSet self._status = github.GithubObject.NotSet self._busy = github.GithubObject.NotSet self._labels = [] def _useAttributes(self, attributes): if "id" in attributes: # pragma no branch self._id = self._makeIntAttribute(attributes["id"]) if "name" in attributes: # pragma no branch self._name = self._makeStringAttribute(attributes["name"]) if "os" in attributes: # pragma no branch self._os = self._makeStringAttribute(attributes["os"]) if "status" in attributes: # pragma no branch self._status = self._makeStringAttribute(attributes["status"]) if "busy" in attributes: self._busy = self._makeBoolAttribute(attributes["busy"]) if "labels" in attributes: self._labels = self._makeListOfDictsAttribute(attributes["labels"]) ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1619412308.0 PyGithub-1.55/github/SelfHostedActionsRunner.pyi0000644000175100001710000000114700000000000021322 0ustar00runnerdockerfrom typing import Any, Dict, List, Union from github.GithubObject import NonCompletableGithubObject class SelfHostedActionsRunner(NonCompletableGithubObject): def __repr__(self) -> str: ... def _initAttributes(self) -> None: ... def _useAttributes(self, attributes: Dict[str, Any]) -> None: ... @property def id(self) -> int: ... @property def name(self) -> str: ... @property def os(self) -> str: ... @property def status(self) -> str: ... @property def busy(self) -> bool: ... def labels(self) -> List[Dict[str, Union[str, int]]]: ... ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1619412308.0 PyGithub-1.55/github/SourceImport.py0000644000175100001710000001640100000000000017030 0ustar00runnerdocker############################ Copyrights and license ############################ # # # Copyright 2018 Hayden Fuss # # # # This file is part of PyGithub. # # http://pygithub.readthedocs.io/ # # # # PyGithub is free software: you can redistribute it and/or modify it under # # the terms of the GNU Lesser General Public License as published by the Free # # Software Foundation, either version 3 of the License, or (at your option) # # any later version. # # # # PyGithub is distributed in the hope that it will be useful, but WITHOUT ANY # # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more # # details. # # # # You should have received a copy of the GNU Lesser General Public License # # along with PyGithub. If not, see . # # # ################################################################################ import github.GithubObject from github import Consts class SourceImport(github.GithubObject.CompletableGithubObject): """ This class represents SourceImports. The reference can be found here https://docs.github.com/en/rest/reference/migration#source_imports """ def __repr__(self): return self.get__repr__( { "vcs_url": self._vcs_url.value, "repository_url": self._repository_url.value, "status": self._status.value, "url": self._url.value, } ) @property def authors_count(self): """ :type: integer """ self._completeIfNotSet(self._authors_count) return self._authors_count.value @property def authors_url(self): """ :type: string """ self._completeIfNotSet(self._authors_url) return self._authors_url.value @property def has_large_files(self): """ :type: bool """ self._completeIfNotSet(self._has_large_files) return self._has_large_files.value @property def html_url(self): """ :type: string """ self._completeIfNotSet(self._html_url) return self._html_url.value @property def large_files_count(self): """ :type: integer """ self._completeIfNotSet(self._large_files_count) return self._large_files_count.value @property def large_files_size(self): """ :type: integer """ self._completeIfNotSet(self._large_files_size) return self._large_files_size.value @property def repository_url(self): """ :type: string """ self._completeIfNotSet(self._repository_url) return self._repository_url.value @property def status(self): """ :type: string """ self._completeIfNotSet(self._status) return self._status.value @property def status_text(self): """ :type: string """ self._completeIfNotSet(self._status_text) return self._status_text.value @property def url(self): """ :type: string """ self._completeIfNotSet(self._url) return self._url.value @property def use_lfs(self): """ :type: string """ self._completeIfNotSet(self._use_lfs) return self._use_lfs.value @property def vcs(self): """ :type: string """ self._completeIfNotSet(self._vcs) return self._vcs.value @property def vcs_url(self): """ :type: string """ self._completeIfNotSet(self._vcs_url) return self._vcs_url.value def update(self): import_header = {"Accept": Consts.mediaTypeImportPreview} return super().update(additional_headers=import_header) def _initAttributes(self): self._authors_count = github.GithubObject.NotSet self._authors_url = github.GithubObject.NotSet self._has_large_files = github.GithubObject.NotSet self._html_url = github.GithubObject.NotSet self._large_files_count = github.GithubObject.NotSet self._large_files_size = github.GithubObject.NotSet self._repository_url = github.GithubObject.NotSet self._status = github.GithubObject.NotSet self._status_text = github.GithubObject.NotSet self._url = github.GithubObject.NotSet self._use_lsf = github.GithubObject.NotSet self._vcs = github.GithubObject.NotSet self._vcs_url = github.GithubObject.NotSet def _useAttributes(self, attributes): if "authors_count" in attributes: # pragma no branch self._authors_count = self._makeIntAttribute(attributes["authors_count"]) if "authors_url" in attributes: # pragma no branch self._authors_url = self._makeStringAttribute(attributes["authors_url"]) if "has_large_files" in attributes: # pragma no branch self._has_large_files = self._makeBoolAttribute( attributes["has_large_files"] ) if "html_url" in attributes: # pragma no branch self._html_url = self._makeStringAttribute(attributes["html_url"]) if "large_files_count" in attributes: # pragma no branch self._large_files_count = self._makeIntAttribute( attributes["large_files_count"] ) if "large_files_size" in attributes: # pragma no branch self._large_files_size = self._makeIntAttribute( attributes["large_files_size"] ) if "repository_url" in attributes: # pragma no branch self._repository_url = self._makeStringAttribute( attributes["repository_url"] ) if "status" in attributes: # pragma no branch self._status = self._makeStringAttribute(attributes["status"]) if "status_text" in attributes: # pragma no branch self._status_text = self._makeStringAttribute(attributes["status_text"]) if "url" in attributes: # pragma no branch self._url = self._makeStringAttribute(attributes["url"]) if "use_lfs" in attributes: # pragma no branch self._use_lfs = self._makeStringAttribute(attributes["use_lfs"]) if "vcs" in attributes: # pragma no branch self._vcs = self._makeStringAttribute(attributes["vcs"]) if "vcs_url" in attributes: # pragma no branch self._vcs_url = self._makeStringAttribute(attributes["vcs_url"]) ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1619412308.0 PyGithub-1.55/github/SourceImport.pyi0000644000175100001710000000167300000000000017206 0ustar00runnerdockerfrom typing import Any, Dict, Optional from github.GithubObject import CompletableGithubObject class SourceImport(CompletableGithubObject): def __repr__(self) -> str: ... def _initAttributes(self) -> None: ... def _useAttributes(self, attributes: Dict[str, Any]) -> None: ... @property def authors_count(self) -> int: ... @property def authors_url(self) -> str: ... @property def has_large_files(self) -> bool: ... @property def html_url(self) -> str: ... @property def large_files_count(self) -> int: ... @property def large_files_size(self) -> int: ... @property def repository_url(self) -> str: ... @property def status(self) -> str: ... @property def status_text(self) -> str: ... @property def url(self) -> str: ... @property def use_lfs(self) -> str: ... @property def vcs(self) -> str: ... @property def vcs_url(self) -> str: ... ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1619412308.0 PyGithub-1.55/github/Stargazer.py0000644000175100001710000000615300000000000016342 0ustar00runnerdocker############################ Copyrights and license ############################ # # # Copyright 2015 Dan Vanderkam # # Copyright 2016 Jannis Gebauer # # Copyright 2016 Peter Buckley # # Copyright 2018 Wan Liuyang # # Copyright 2018 sfdye # # # # This file is part of PyGithub. # # http://pygithub.readthedocs.io/ # # # # PyGithub is free software: you can redistribute it and/or modify it under # # the terms of the GNU Lesser General Public License as published by the Free # # Software Foundation, either version 3 of the License, or (at your option) # # any later version. # # # # PyGithub is distributed in the hope that it will be useful, but WITHOUT ANY # # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more # # details. # # # # You should have received a copy of the GNU Lesser General Public License # # along with PyGithub. If not, see . # # # ################################################################################ import github class Stargazer(github.GithubObject.NonCompletableGithubObject): """ This class represents Stargazers. The reference can be found here https://docs.github.com/en/rest/reference/activity/starring#alternative-response-with-star-creation-timestamps """ def __repr__(self): return self.get__repr__({"user": self._user.value._login.value}) @property def starred_at(self): """ :type: datetime.datetime """ return self._starred_at.value @property def user(self): """ :type: :class:`github.NamedUser` """ return self._user.value def _initAttributes(self): self._starred_at = github.GithubObject.NotSet self._user = github.GithubObject.NotSet self._url = github.GithubObject.NotSet def _useAttributes(self, attributes): if "starred_at" in attributes: self._starred_at = self._makeDatetimeAttribute(attributes["starred_at"]) if "user" in attributes: self._user = self._makeClassAttribute( github.NamedUser.NamedUser, attributes["user"] ) ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1619412308.0 PyGithub-1.55/github/Stargazer.pyi0000644000175100001710000000071300000000000016507 0ustar00runnerdockerfrom datetime import datetime from typing import Any, Dict from github.GithubObject import NonCompletableGithubObject from github.NamedUser import NamedUser class Stargazer(NonCompletableGithubObject): def __repr__(self) -> str: ... def _initAttributes(self) -> None: ... def _useAttributes(self, attributes: Dict[str, Any]) -> None: ... @property def starred_at(self) -> datetime: ... @property def user(self) -> NamedUser: ... ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1619412308.0 PyGithub-1.55/github/StatsCodeFrequency.py0000755000175100001710000000607600000000000020162 0ustar00runnerdocker############################ Copyrights and license ############################ # # # Copyright 2013 Vincent Jacques # # Copyright 2014 Vincent Jacques # # Copyright 2016 Peter Buckley # # Copyright 2018 Wan Liuyang # # Copyright 2018 sfdye # # # # This file is part of PyGithub. # # http://pygithub.readthedocs.io/ # # # # PyGithub is free software: you can redistribute it and/or modify it under # # the terms of the GNU Lesser General Public License as published by the Free # # Software Foundation, either version 3 of the License, or (at your option) # # any later version. # # # # PyGithub is distributed in the hope that it will be useful, but WITHOUT ANY # # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more # # details. # # # # You should have received a copy of the GNU Lesser General Public License # # along with PyGithub. If not, see . # # # ################################################################################ import github.GithubObject class StatsCodeFrequency(github.GithubObject.NonCompletableGithubObject): """ This class represents statistics of StatsCodeFrequencies. The reference can be found here http://docs.github.com/en/rest/reference/repos/statistics#get-the-number-of-additions-and-deletions-per-week """ @property def week(self): """ :type: datetime.datetime """ return self._week.value @property def additions(self): """ :type: int """ return self._additions.value @property def deletions(self): """ :type: int """ return self._deletions.value def _initAttributes(self): self._week = github.GithubObject.NotSet self._additions = github.GithubObject.NotSet self._deletions = github.GithubObject.NotSet def _useAttributes(self, attributes): self._week = self._makeTimestampAttribute(attributes[0]) self._additions = self._makeIntAttribute(attributes[1]) self._deletions = self._makeIntAttribute(attributes[2]) ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1619412308.0 PyGithub-1.55/github/StatsCodeFrequency.pyi0000644000175100001710000000065300000000000020323 0ustar00runnerdockerfrom datetime import datetime from typing import List from github.GithubObject import NonCompletableGithubObject class StatsCodeFrequency(NonCompletableGithubObject): def _initAttributes(self) -> None: ... def _useAttributes(self, attributes: List[int]) -> None: ... @property def additions(self) -> int: ... @property def deletions(self) -> int: ... @property def week(self) -> datetime: ... ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1619412308.0 PyGithub-1.55/github/StatsCommitActivity.py0000755000175100001710000000632000000000000020363 0ustar00runnerdocker############################ Copyrights and license ############################ # # # Copyright 2013 Vincent Jacques # # Copyright 2014 Vincent Jacques # # Copyright 2016 Peter Buckley # # Copyright 2018 Wan Liuyang # # Copyright 2018 sfdye # # # # This file is part of PyGithub. # # http://pygithub.readthedocs.io/ # # # # PyGithub is free software: you can redistribute it and/or modify it under # # the terms of the GNU Lesser General Public License as published by the Free # # Software Foundation, either version 3 of the License, or (at your option) # # any later version. # # # # PyGithub is distributed in the hope that it will be useful, but WITHOUT ANY # # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more # # details. # # # # You should have received a copy of the GNU Lesser General Public License # # along with PyGithub. If not, see . # # # ################################################################################ import github.GithubObject class StatsCommitActivity(github.GithubObject.NonCompletableGithubObject): """ This class represents StatsCommitActivities. The reference can be found here http://docs.github.com/en/rest/reference/repos/statistics#get-the-last-year-of-commit-activity-data """ @property def week(self): """ :type: datetime.datetime """ return self._week.value @property def total(self): """ :type: int """ return self._total.value @property def days(self): """ :type: list of int """ return self._days.value def _initAttributes(self): self._week = github.GithubObject.NotSet self._total = github.GithubObject.NotSet self._days = github.GithubObject.NotSet def _useAttributes(self, attributes): if "week" in attributes: # pragma no branch self._week = self._makeTimestampAttribute(attributes["week"]) if "total" in attributes: # pragma no branch self._total = self._makeIntAttribute(attributes["total"]) if "days" in attributes: # pragma no branch self._days = self._makeListOfIntsAttribute(attributes["days"]) ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1619412308.0 PyGithub-1.55/github/StatsCommitActivity.pyi0000644000175100001710000000067100000000000020534 0ustar00runnerdockerfrom datetime import datetime from typing import Any, Dict, List from github.GithubObject import NonCompletableGithubObject class StatsCommitActivity(NonCompletableGithubObject): def _initAttributes(self) -> None: ... def _useAttributes(self, attributes: Dict[str, Any]) -> None: ... @property def days(self) -> List[int]: ... @property def total(self) -> int: ... @property def week(self) -> datetime: ... ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1619412308.0 PyGithub-1.55/github/StatsContributor.py0000755000175100001710000001145700000000000017737 0ustar00runnerdocker############################ Copyrights and license ############################ # # # Copyright 2013 Vincent Jacques # # Copyright 2014 Vincent Jacques # # Copyright 2016 Peter Buckley # # Copyright 2018 Wan Liuyang # # Copyright 2018 sfdye # # # # This file is part of PyGithub. # # http://pygithub.readthedocs.io/ # # # # PyGithub is free software: you can redistribute it and/or modify it under # # the terms of the GNU Lesser General Public License as published by the Free # # Software Foundation, either version 3 of the License, or (at your option) # # any later version. # # # # PyGithub is distributed in the hope that it will be useful, but WITHOUT ANY # # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more # # details. # # # # You should have received a copy of the GNU Lesser General Public License # # along with PyGithub. If not, see . # # # ################################################################################ import github.GithubObject import github.NamedUser class StatsContributor(github.GithubObject.NonCompletableGithubObject): """ This class represents StatsContributors. The reference can be found here http://docs.github.com/en/rest/reference/repos/statistics#get-contributors-list-with-additions-deletions-and-commit-counts """ class Week(github.GithubObject.NonCompletableGithubObject): """ This class represents weekly statistics of a contributor. """ @property def w(self): """ :type: datetime.datetime """ return self._w.value @property def a(self): """ :type: int """ return self._a.value @property def d(self): """ :type: int """ return self._d.value @property def c(self): """ :type: int """ return self._c.value def _initAttributes(self): self._w = github.GithubObject.NotSet self._a = github.GithubObject.NotSet self._d = github.GithubObject.NotSet self._c = github.GithubObject.NotSet def _useAttributes(self, attributes): if "w" in attributes: # pragma no branch self._w = self._makeTimestampAttribute(attributes["w"]) if "a" in attributes: # pragma no branch self._a = self._makeIntAttribute(attributes["a"]) if "d" in attributes: # pragma no branch self._d = self._makeIntAttribute(attributes["d"]) if "c" in attributes: # pragma no branch self._c = self._makeIntAttribute(attributes["c"]) @property def author(self): """ :type: :class:`github.NamedUser.NamedUser` """ return self._author.value @property def total(self): """ :type: int """ return self._total.value @property def weeks(self): """ :type: list of :class:`.Week` """ return self._weeks.value def _initAttributes(self): self._author = github.GithubObject.NotSet self._total = github.GithubObject.NotSet self._weeks = github.GithubObject.NotSet def _useAttributes(self, attributes): if "author" in attributes: # pragma no branch self._author = self._makeClassAttribute( github.NamedUser.NamedUser, attributes["author"] ) if "total" in attributes: # pragma no branch self._total = self._makeIntAttribute(attributes["total"]) if "weeks" in attributes: # pragma no branch self._weeks = self._makeListOfClassesAttribute( self.Week, attributes["weeks"] ) ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1619412308.0 PyGithub-1.55/github/StatsContributor.pyi0000644000175100001710000000153600000000000020102 0ustar00runnerdockerfrom datetime import datetime from typing import Any, Dict, List, Optional from github.GithubObject import NonCompletableGithubObject from github.NamedUser import NamedUser class StatsContributor(NonCompletableGithubObject): def _initAttributes(self) -> None: ... def _useAttributes(self, attributes: Dict[str, Any]) -> None: ... @property def author(self) -> NamedUser: ... @property def total(self) -> int: ... @property def weeks(self) -> List[Week]: ... class Week(NonCompletableGithubObject): def _initAttributes(self) -> None: ... def _useAttributes(self, attributes: Dict[str, int]) -> None: ... @property def a(self) -> int: ... @property def c(self) -> int: ... @property def d(self) -> int: ... @property def w(self) -> datetime: ... ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1619412308.0 PyGithub-1.55/github/StatsParticipation.py0000755000175100001710000000570200000000000020227 0ustar00runnerdocker############################ Copyrights and license ############################ # # # Copyright 2013 Vincent Jacques # # Copyright 2014 Vincent Jacques # # Copyright 2016 Peter Buckley # # Copyright 2018 Wan Liuyang # # Copyright 2018 sfdye # # # # This file is part of PyGithub. # # http://pygithub.readthedocs.io/ # # # # PyGithub is free software: you can redistribute it and/or modify it under # # the terms of the GNU Lesser General Public License as published by the Free # # Software Foundation, either version 3 of the License, or (at your option) # # any later version. # # # # PyGithub is distributed in the hope that it will be useful, but WITHOUT ANY # # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more # # details. # # # # You should have received a copy of the GNU Lesser General Public License # # along with PyGithub. If not, see . # # # ################################################################################ import github.GithubObject class StatsParticipation(github.GithubObject.NonCompletableGithubObject): """ This class represents StatsParticipations. The reference can be found here http://docs.github.com/en/rest/reference/repos/statistics#get-the-weekly-commit-count-for-the-repo-owner-and-everyone-else """ @property def all(self): """ :type: list of int """ return self._all.value @property def owner(self): """ :type: list of int """ return self._owner.value def _initAttributes(self): self._all = github.GithubObject.NotSet self._owner = github.GithubObject.NotSet def _useAttributes(self, attributes): if "all" in attributes: # pragma no branch self._all = self._makeListOfIntsAttribute(attributes["all"]) if "owner" in attributes: # pragma no branch self._owner = self._makeListOfIntsAttribute(attributes["owner"]) ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1619412308.0 PyGithub-1.55/github/StatsParticipation.pyi0000644000175100001710000000055600000000000020377 0ustar00runnerdockerfrom typing import Dict, List from github.GithubObject import NonCompletableGithubObject class StatsParticipation(NonCompletableGithubObject): def _initAttributes(self) -> None: ... def _useAttributes(self, attributes: Dict[str, List[int]]) -> None: ... @property def all(self) -> List[int]: ... @property def owner(self) -> List[int]: ... ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1619412308.0 PyGithub-1.55/github/StatsPunchCard.py0000755000175100001710000000530100000000000017263 0ustar00runnerdocker############################ Copyrights and license ############################ # # # Copyright 2013 Vincent Jacques # # Copyright 2014 Vincent Jacques # # Copyright 2016 Peter Buckley # # Copyright 2018 Wan Liuyang # # Copyright 2018 sfdye # # # # This file is part of PyGithub. # # http://pygithub.readthedocs.io/ # # # # PyGithub is free software: you can redistribute it and/or modify it under # # the terms of the GNU Lesser General Public License as published by the Free # # Software Foundation, either version 3 of the License, or (at your option) # # any later version. # # # # PyGithub is distributed in the hope that it will be useful, but WITHOUT ANY # # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more # # details. # # # # You should have received a copy of the GNU Lesser General Public License # # along with PyGithub. If not, see . # # # ################################################################################ import github.GithubObject import github.NamedUser # TODO remove unused class StatsPunchCard(github.GithubObject.NonCompletableGithubObject): """ This class represents StatsPunchCards. The reference can be found here http://docs.github.com/en/rest/reference/repos/statistics#get-the-number-of-commits-per-hour-in-each-day """ def get(self, day, hour): """ Get a specific element :param day: int :param hour: int :rtype: int """ return self._dict[(day, hour)] def _initAttributes(self): self._dict = {} def _useAttributes(self, attributes): for day, hour, commits in attributes: self._dict[(day, hour)] = commits ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1619412308.0 PyGithub-1.55/github/StatsPunchCard.pyi0000644000175100001710000000045400000000000017435 0ustar00runnerdockerfrom typing import List from github.GithubObject import NonCompletableGithubObject class StatsPunchCard(NonCompletableGithubObject): def _initAttributes(self) -> None: ... def _useAttributes(self, attributes: List[List[int]]) -> None: ... def get(self, day: int, hour: int) -> int: ... ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1619412308.0 PyGithub-1.55/github/Tag.py0000644000175100001710000001015000000000000015103 0ustar00runnerdocker############################ Copyrights and license ############################ # # # Copyright 2012 Vincent Jacques # # Copyright 2012 Zearin # # Copyright 2013 AKFish # # Copyright 2013 Vincent Jacques # # Copyright 2013 martinqt # # Copyright 2014 Vincent Jacques # # Copyright 2016 Jannis Gebauer # # Copyright 2016 Peter Buckley # # Copyright 2018 Wan Liuyang # # Copyright 2018 sfdye # # # # This file is part of PyGithub. # # http://pygithub.readthedocs.io/ # # # # PyGithub is free software: you can redistribute it and/or modify it under # # the terms of the GNU Lesser General Public License as published by the Free # # Software Foundation, either version 3 of the License, or (at your option) # # any later version. # # # # PyGithub is distributed in the hope that it will be useful, but WITHOUT ANY # # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more # # details. # # # # You should have received a copy of the GNU Lesser General Public License # # along with PyGithub. If not, see . # # # ################################################################################ import github.Commit import github.GithubObject class Tag(github.GithubObject.NonCompletableGithubObject): """ This class represents Tags. The reference can be found here https://docs.github.com/en/rest/reference/repos#list-tags """ def __repr__(self): return self.get__repr__( {"name": self._name.value, "commit": self._commit.value} ) @property def commit(self): """ :type: :class:`github.Commit.Commit` """ return self._commit.value @property def name(self): """ :type: string """ return self._name.value @property def tarball_url(self): """ :type: string """ return self._tarball_url.value @property def zipball_url(self): """ :type: string """ return self._zipball_url.value def _initAttributes(self): self._commit = github.GithubObject.NotSet self._name = github.GithubObject.NotSet self._tarball_url = github.GithubObject.NotSet self._zipball_url = github.GithubObject.NotSet def _useAttributes(self, attributes): if "commit" in attributes: # pragma no branch self._commit = self._makeClassAttribute( github.Commit.Commit, attributes["commit"] ) if "name" in attributes: # pragma no branch self._name = self._makeStringAttribute(attributes["name"]) if "tarball_url" in attributes: # pragma no branch self._tarball_url = self._makeStringAttribute(attributes["tarball_url"]) if "zipball_url" in attributes: # pragma no branch self._zipball_url = self._makeStringAttribute(attributes["zipball_url"]) ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1619412308.0 PyGithub-1.55/github/Tag.pyi0000644000175100001710000000077500000000000015270 0ustar00runnerdockerfrom typing import Any, Dict from github.Commit import Commit from github.GithubObject import NonCompletableGithubObject class Tag(NonCompletableGithubObject): def __repr__(self) -> str: ... def _initAttributes(self) -> None: ... def _useAttributes(self, attributes: Dict[str, Any]) -> None: ... @property def commit(self) -> Commit: ... @property def name(self) -> str: ... @property def tarball_url(self) -> str: ... @property def zipball_url(self) -> str: ... ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1619412308.0 PyGithub-1.55/github/Team.py0000644000175100001710000005075100000000000015271 0ustar00runnerdocker############################ Copyrights and license ############################ # # # Copyright 2012 Vincent Jacques # # Copyright 2012 Zearin # # Copyright 2013 AKFish # # Copyright 2013 Vincent Jacques # # Copyright 2013 martinqt # # Copyright 2014 Jan Orel # # Copyright 2014 Vincent Jacques # # Copyright 2015 Aron Culotta # # Copyright 2016 Jannis Gebauer # # Copyright 2016 Peter Buckley # # Copyright 2016 mattjmorrison # # Copyright 2018 Isuru Fernando # # Copyright 2018 Jacopo Notarstefano # # Copyright 2018 James D'Amato # # Copyright 2018 Maarten Fonville # # Copyright 2018 Manu Hortet # # Copyright 2018 Michał Górny # # Copyright 2018 Steve Kowalik # # Copyright 2018 Tim Boring # # Copyright 2018 sfdye # # # # This file is part of PyGithub. # # http://pygithub.readthedocs.io/ # # # # PyGithub is free software: you can redistribute it and/or modify it under # # the terms of the GNU Lesser General Public License as published by the Free # # Software Foundation, either version 3 of the License, or (at your option) # # any later version. # # # # PyGithub is distributed in the hope that it will be useful, but WITHOUT ANY # # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more # # details. # # # # You should have received a copy of the GNU Lesser General Public License # # along with PyGithub. If not, see . # # # ################################################################################ from deprecated import deprecated import github.GithubObject import github.NamedUser import github.Organization import github.PaginatedList import github.Repository import github.TeamDiscussion from github.GithubException import UnknownObjectException from . import Consts class Team(github.GithubObject.CompletableGithubObject): """ This class represents Teams. The reference can be found here http://docs.github.com/en/rest/reference/teams """ def __repr__(self): return self.get__repr__({"id": self._id.value, "name": self._name.value}) @property def id(self): """ :type: integer """ self._completeIfNotSet(self._id) return self._id.value @property def members_count(self): """ :type: integer """ self._completeIfNotSet(self._members_count) return self._members_count.value @property def members_url(self): """ :type: string """ self._completeIfNotSet(self._members_url) return self._members_url.value @property def name(self): """ :type: string """ self._completeIfNotSet(self._name) return self._name.value @property def description(self): """ :type: string """ self._completeIfNotSet(self._description) return self._description.value @property def permission(self): """ :type: string """ self._completeIfNotSet(self._permission) return self._permission.value @property def repos_count(self): """ :type: integer """ self._completeIfNotSet(self._repos_count) return self._repos_count.value @property def repositories_url(self): """ :type: string """ self._completeIfNotSet(self._repositories_url) return self._repositories_url.value @property def slug(self): """ :type: string """ self._completeIfNotSet(self._slug) return self._slug.value @property def url(self): """ :type: string """ self._completeIfNotSet(self._url) return self._url.value @property def organization(self): """ :type: :class:`github.Organization.Organization` """ self._completeIfNotSet(self._organization) return self._organization.value @property def privacy(self): """ :type: string """ self._completeIfNotSet(self._privacy) return self._privacy.value @property def parent(self): """ :type: string """ self._completeIfNotSet(self._parent) return self._parent.value def add_to_members(self, member): """ This API call is deprecated. Use `add_membership` instead. https://docs.github.com/en/rest/reference/teams#add-or-update-team-membership-for-a-user-legacy :calls: `PUT /teams/{id}/members/{user} `_ :param member: :class:`github.NamedUser.NamedUser` :rtype: None """ assert isinstance(member, github.NamedUser.NamedUser), member headers, data = self._requester.requestJsonAndCheck( "PUT", f"{self.url}/members/{member._identity}" ) def add_membership(self, member, role=github.GithubObject.NotSet): """ :calls: `PUT /teams/{id}/memberships/{user} `_ :param member: :class:`github.Nameduser.NamedUser` :param role: string :rtype: None """ assert isinstance(member, github.NamedUser.NamedUser), member assert role is github.GithubObject.NotSet or isinstance(role, str), role if role is not github.GithubObject.NotSet: assert role in ["member", "maintainer"] put_parameters = { "role": role, } else: put_parameters = { "role": "member", } headers, data = self._requester.requestJsonAndCheck( "PUT", f"{self.url}/memberships/{member._identity}", input=put_parameters ) def get_team_membership(self, member): """ :calls: `GET /orgs/{org}/memberships/team/{team_id}/{username} `_ :param member: string or :class:`github.NamedUser.NamedUser` :rtype: :class:`github.Membership.Membership` """ assert isinstance(member, str) or isinstance( member, github.NamedUser.NamedUser ), member if isinstance(member, github.NamedUser.NamedUser): member = member._identity headers, data = self._requester.requestJsonAndCheck( "GET", f"{self.url}/memberships/{member}" ) return github.Membership.Membership( self._requester, headers, data, completed=True ) def add_to_repos(self, repo): """ :calls: `PUT /teams/{id}/repos/{org}/{repo} `_ :param repo: :class:`github.Repository.Repository` :rtype: None """ assert isinstance(repo, github.Repository.Repository), repo headers, data = self._requester.requestJsonAndCheck( "PUT", f"{self.url}/repos/{repo._identity}" ) def get_repo_permission(self, repo): """ :calls: `GET /teams/{id}/repos/{org}/{repo} `_ :param repo: string or :class:`github.Repository.Repository` :rtype: None or :class:`github.Permissions.Permissions` """ assert isinstance(repo, github.Repository.Repository) or isinstance( repo, str ), repo if isinstance(repo, github.Repository.Repository): repo = repo._identity try: headers, data = self._requester.requestJsonAndCheck( "GET", f"{self.url}/repos/{repo}", headers={"Accept": Consts.teamRepositoryPermissions}, ) return github.Permissions.Permissions( self._requester, headers, data["permissions"], completed=True ) except UnknownObjectException: return None @deprecated( reason=""" Team.set_repo_permission() is deprecated, use Team.update_team_repository() instead. """ ) def set_repo_permission(self, repo, permission): """ :calls: `PUT /teams/{id}/repos/{org}/{repo} `_ :param repo: :class:`github.Repository.Repository` :param permission: string :rtype: None """ assert isinstance(repo, github.Repository.Repository), repo put_parameters = { "permission": permission, } headers, data = self._requester.requestJsonAndCheck( "PUT", f"{self.url}/repos/{repo._identity}", input=put_parameters ) def update_team_repository(self, repo, permission): """ :calls: `PUT /orgs/{org}/teams/{team_slug}/repos/{owner}/{repo} `_ :param repo: string or :class:`github.Repository.Repository` :param permission: string :rtype: bool """ assert isinstance(repo, github.Repository.Repository) or isinstance( repo, str ), repo assert isinstance(permission, str), permission repo_url_param = repo if isinstance(repo, github.Repository.Repository): repo_url_param = repo._identity put_parameters = { "permission": permission, } status, _, _ = self._requester.requestJson( "PUT", f"{self.organization.url}/teams/{self.slug}/repos/{repo_url_param}", input=put_parameters, ) return status == 204 def delete(self): """ :calls: `DELETE /teams/{id} `_ :rtype: None """ headers, data = self._requester.requestJsonAndCheck("DELETE", self.url) def edit( self, name, description=github.GithubObject.NotSet, permission=github.GithubObject.NotSet, privacy=github.GithubObject.NotSet, ): """ :calls: `PATCH /teams/{id} `_ :param name: string :param description: string :param permission: string :param privacy: string :rtype: None """ assert isinstance(name, str), name assert description is github.GithubObject.NotSet or isinstance( description, str ), description assert permission is github.GithubObject.NotSet or isinstance( permission, str ), permission assert privacy is github.GithubObject.NotSet or isinstance( privacy, str ), privacy post_parameters = { "name": name, } if description is not github.GithubObject.NotSet: post_parameters["description"] = description if permission is not github.GithubObject.NotSet: post_parameters["permission"] = permission if privacy is not github.GithubObject.NotSet: post_parameters["privacy"] = privacy headers, data = self._requester.requestJsonAndCheck( "PATCH", self.url, input=post_parameters ) self._useAttributes(data) def get_teams(self): """ :calls: `GET /teams/{id}/teams `_ :rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.Team.Team` """ return github.PaginatedList.PaginatedList( github.Team.Team, self._requester, f"{self.url}/teams", None, ) def get_discussions(self): """ :calls: `GET /teams/{id}/discussions `_ :rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.TeamDiscussion.TeamDiscussion` """ return github.PaginatedList.PaginatedList( github.TeamDiscussion.TeamDiscussion, self._requester, f"{self.url}/discussions", None, headers={"Accept": Consts.mediaTypeTeamDiscussionsPreview}, ) def get_members(self, role=github.GithubObject.NotSet): """ :calls: `GET /teams/{id}/members `_ :param role: string :rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.NamedUser.NamedUser` """ assert role is github.GithubObject.NotSet or isinstance(role, str), role url_parameters = dict() if role is not github.GithubObject.NotSet: assert role in ["member", "maintainer", "all"] url_parameters["role"] = role return github.PaginatedList.PaginatedList( github.NamedUser.NamedUser, self._requester, f"{self.url}/members", url_parameters, ) def get_repos(self): """ :calls: `GET /teams/{id}/repos `_ :rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.Repository.Repository` """ return github.PaginatedList.PaginatedList( github.Repository.Repository, self._requester, f"{self.url}/repos", None ) def invitations(self): """ :calls: `GET /teams/{id}/invitations `_ :rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.NamedUser.NamedUser` """ return github.PaginatedList.PaginatedList( github.NamedUser.NamedUser, self._requester, f"{self.url}/invitations", None, headers={"Accept": Consts.mediaTypeOrganizationInvitationPreview}, ) def has_in_members(self, member): """ :calls: `GET /teams/{id}/members/{user} `_ :param member: :class:`github.NamedUser.NamedUser` :rtype: bool """ assert isinstance(member, github.NamedUser.NamedUser), member status, headers, data = self._requester.requestJson( "GET", f"{self.url}/members/{member._identity}" ) return status == 204 def has_in_repos(self, repo): """ :calls: `GET /teams/{id}/repos/{owner}/{repo} `_ :param repo: :class:`github.Repository.Repository` :rtype: bool """ assert isinstance(repo, github.Repository.Repository), repo status, headers, data = self._requester.requestJson( "GET", f"{self.url}/repos/{repo._identity}" ) return status == 204 def remove_membership(self, member): """ :calls: `DELETE /teams/{team_id}/memberships/{username} ` :param member: :return: """ assert isinstance(member, github.NamedUser.NamedUser), member headers, data = self._requester.requestJsonAndCheck( "DELETE", f"{self.url}/memberships/{member._identity}" ) def remove_from_members(self, member): """ This API call is deprecated. Use `remove_membership` instead: https://docs.github.com/en/rest/reference/teams#add-or-update-team-membership-for-a-user-legacy :calls: `DELETE /teams/{id}/members/{user} `_ :param member: :class:`github.NamedUser.NamedUser` :rtype: None """ assert isinstance(member, github.NamedUser.NamedUser), member headers, data = self._requester.requestJsonAndCheck( "DELETE", f"{self.url}/members/{member._identity}" ) def remove_from_repos(self, repo): """ :calls: `DELETE /teams/{id}/repos/{owner}/{repo} `_ :param repo: :class:`github.Repository.Repository` :rtype: None """ assert isinstance(repo, github.Repository.Repository), repo headers, data = self._requester.requestJsonAndCheck( "DELETE", f"{self.url}/repos/{repo._identity}" ) @property def _identity(self): return self.id def _initAttributes(self): self._id = github.GithubObject.NotSet self._members_count = github.GithubObject.NotSet self._members_url = github.GithubObject.NotSet self._name = github.GithubObject.NotSet self._description = github.GithubObject.NotSet self._permission = github.GithubObject.NotSet self._repos_count = github.GithubObject.NotSet self._repositories_url = github.GithubObject.NotSet self._slug = github.GithubObject.NotSet self._url = github.GithubObject.NotSet self._organization = github.GithubObject.NotSet self._privacy = github.GithubObject.NotSet self._parent = github.GithubObject.NotSet def _useAttributes(self, attributes): if "id" in attributes: # pragma no branch self._id = self._makeIntAttribute(attributes["id"]) if "members_count" in attributes: # pragma no branch self._members_count = self._makeIntAttribute(attributes["members_count"]) if "members_url" in attributes: # pragma no branch self._members_url = self._makeStringAttribute(attributes["members_url"]) if "name" in attributes: # pragma no branch self._name = self._makeStringAttribute(attributes["name"]) if "description" in attributes: # pragma no branch self._description = self._makeStringAttribute(attributes["description"]) if "permission" in attributes: # pragma no branch self._permission = self._makeStringAttribute(attributes["permission"]) if "repos_count" in attributes: # pragma no branch self._repos_count = self._makeIntAttribute(attributes["repos_count"]) if "repositories_url" in attributes: # pragma no branch self._repositories_url = self._makeStringAttribute( attributes["repositories_url"] ) if "slug" in attributes: # pragma no branch self._slug = self._makeStringAttribute(attributes["slug"]) if "url" in attributes: # pragma no branch self._url = self._makeStringAttribute(attributes["url"]) if "organization" in attributes: # pragma no branch self._organization = self._makeClassAttribute( github.Organization.Organization, attributes["organization"] ) if "privacy" in attributes: # pragma no branch self._privacy = self._makeStringAttribute(attributes["privacy"]) if "parent" in attributes: # pragma no branch self._parent = self._makeClassAttribute( github.Team.Team, attributes["parent"] ) ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1619412308.0 PyGithub-1.55/github/Team.pyi0000644000175100001710000000464000000000000015436 0ustar00runnerdockerfrom typing import Any, Dict, Union from github.GithubObject import CompletableGithubObject, _NotSetType from github.NamedUser import NamedUser from github.Organization import Organization from github.Membership import Membership from github.PaginatedList import PaginatedList from github.Repository import Repository from github.TeamDiscussion import TeamDiscussion class Team(CompletableGithubObject): def __repr__(self) -> str: ... @property def _identity(self) -> int: ... def _initAttributes(self) -> None: ... def _useAttributes(self, attributes: Dict[str, Any]) -> None: ... def add_membership( self, member: NamedUser, role: Union[str, _NotSetType] = ... ) -> None: ... def add_to_members(self, member: NamedUser) -> None: ... def get_team_membership(self, member: Union[str, NamedUser]) -> Membership: ... def add_to_repos(self, repo: Repository) -> None: ... def delete(self) -> None: ... @property def description(self) -> str: ... def edit( self, name: str, description: Union[str, _NotSetType] = ..., permission: Union[str, _NotSetType] = ..., privacy: Union[str, _NotSetType] = ..., ) -> None: ... def get_discussions(self) -> PaginatedList[TeamDiscussion]: ... def get_members( self, role: Union[str, _NotSetType] = ... ) -> PaginatedList[NamedUser]: ... def get_repos(self) -> PaginatedList[Repository]: ... def has_in_members(self, member: NamedUser) -> bool: ... def has_in_repos(self, repo: Repository) -> bool: ... @property def id(self) -> int: ... def invitations(self) -> PaginatedList[NamedUser]: ... @property def members_count(self) -> int: ... @property def members_url(self) -> str: ... @property def name(self) -> str: ... @property def organization(self) -> Organization: ... @property def permission(self) -> str: ... @property def privacy(self) -> str: ... def remove_from_members(self, member: NamedUser) -> None: ... def remove_from_repos(self, repo: Repository) -> None: ... def remove_membership(self, member: NamedUser) -> None: ... @property def repos_count(self) -> int: ... @property def repositories_url(self) -> str: ... def set_repo_permission(self, repo: Repository, permission: str) -> None: ... @property def slug(self) -> str: ... @property def url(self) -> str: ... ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1619412308.0 PyGithub-1.55/github/TeamDiscussion.py0000644000175100001710000002031600000000000017327 0ustar00runnerdocker############################ Copyrights and license ############################ # # # Copyright 2019 Adam Baratz # # # # This file is part of PyGithub. # # http://pygithub.readthedocs.io/ # # # # PyGithub is free software: you can redistribute it and/or modify it under # # the terms of the GNU Lesser General Public License as published by the Free # # Software Foundation, either version 3 of the License, or (at your option) # # any later version. # # # # PyGithub is distributed in the hope that it will be useful, but WITHOUT ANY # # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more # # details. # # # # You should have received a copy of the GNU Lesser General Public License # # along with PyGithub. If not, see . # # # ################################################################################ import github.GithubObject import github.NamedUser class TeamDiscussion(github.GithubObject.CompletableGithubObject): """ This class represents TeamDiscussions. The reference can be found here https://docs.github.com/en/rest/reference/teams#discussions """ def __repr__(self): return self.get__repr__( {"number": self._number.value, "title": self._title.value} ) @property def author(self): """ :type: :class:`github.NamedUser.NamedUser` """ self._completeIfNotSet(self._author) return self._author.value @property def body(self): """ :type: string """ self._completeIfNotSet(self._body) return self._body.value @property def body_html(self): """ :type: string """ self._completeIfNotSet(self._body_html) return self._body_html.value @property def body_version(self): """ :type: string """ self._completeIfNotSet(self._body_version) return self._body_version.value @property def comments_count(self): """ :type: integer """ self._completeIfNotSet(self._comments_count) return self._comments_count.value @property def comments_url(self): """ :type: string """ self._completeIfNotSet(self._comments_url) return self._comments_url.value @property def created_at(self): """ :type: datetime.datetime """ self._completeIfNotSet(self._created_at) return self._created_at.value @property def html_url(self): """ :type: string """ self._completeIfNotSet(self._html_url) return self._html_url.value @property def last_edited_at(self): """ :type: datetime.datetime """ self._completeIfNotSet(self._last_edited_at) return self._last_edited_at.value @property def node_id(self): """ :type: string """ self._completeIfNotSet(self._node_id) return self._node_id.value @property def number(self): """ :type: integer """ self._completeIfNotSet(self._number) return self._number.value @property def pinned(self): """ :type: bool """ self._completeIfNotSet(self._pinned) return self._pinned.value @property def private(self): """ :type: bool """ self._completeIfNotSet(self._private) return self._private.value @property def team_url(self): """ :type: string """ self._completeIfNotSet(self._team_url) return self._team_url.value @property def title(self): """ :type: string """ self._completeIfNotSet(self._title) return self._title.value @property def updated_at(self): """ :type: datetime.datetime """ self._completeIfNotSet(self._updated_at) return self._updated_at.value @property def url(self): """ :type: string """ self._completeIfNotSet(self._url) return self._url.value def _initAttributes(self): self._author = github.GithubObject.NotSet self._body = github.GithubObject.NotSet self._body_html = github.GithubObject.NotSet self._body_version = github.GithubObject.NotSet self._comments_count = github.GithubObject.NotSet self._comments_url = github.GithubObject.NotSet self._created_at = github.GithubObject.NotSet self._html_url = github.GithubObject.NotSet self._last_edited_at = github.GithubObject.NotSet self._node_id = github.GithubObject.NotSet self._number = github.GithubObject.NotSet self._pinned = github.GithubObject.NotSet self._private = github.GithubObject.NotSet self._team_url = github.GithubObject.NotSet self._title = github.GithubObject.NotSet self._updated_at = github.GithubObject.NotSet self._url = github.GithubObject.NotSet def _useAttributes(self, attributes): if "author" in attributes: # pragma no branch self._author = self._makeClassAttribute( github.NamedUser.NamedUser, attributes["author"] ) if "body" in attributes: # pragma no branch self._body = self._makeStringAttribute(attributes["body"]) if "body_html" in attributes: # pragma no branch self._body_html = self._makeStringAttribute(attributes["body_html"]) if "body_version" in attributes: # pragma no branch self._body_version = self._makeStringAttribute(attributes["body_version"]) if "comments_count" in attributes: # pragma no branch self._comments_count = self._makeIntAttribute(attributes["comments_count"]) if "comments_url" in attributes: # pragma no branch self._comments_url = self._makeStringAttribute(attributes["comments_url"]) if "created_at" in attributes: # pragma no branch self._created_at = self._makeDatetimeAttribute(attributes["created_at"]) if "html_url" in attributes: # pragma no branch self._html_url = self._makeStringAttribute(attributes["html_url"]) if "last_edited_at" in attributes: # pragma no branch self._last_edited_at = self._makeDatetimeAttribute( attributes["last_edited_at"] ) if "node_id" in attributes: # pragma no branch self._node_id = self._makeStringAttribute(attributes["node_id"]) if "number" in attributes: # pragma no branch self._number = self._makeIntAttribute(attributes["number"]) if "pinned" in attributes: # pragma no branch self._pinned = self._makeBoolAttribute(attributes["pinned"]) if "private" in attributes: # pragma no branch self._private = self._makeBoolAttribute(attributes["private"]) if "team_url" in attributes: # pragma no branch self._team_url = self._makeStringAttribute(attributes["team_url"]) if "title" in attributes: self._title = self._makeStringAttribute(attributes["title"]) if "updated_at" in attributes: # pragma no branch self._updated_at = self._makeDatetimeAttribute(attributes["updated_at"]) if "url" in attributes: # pragma no branch self._url = self._makeStringAttribute(attributes["url"]) ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1619412308.0 PyGithub-1.55/github/TeamDiscussion.pyi0000644000175100001710000000227400000000000017503 0ustar00runnerdockerfrom datetime import datetime from typing import Any, Dict from github.GithubObject import CompletableGithubObject from github.NamedUser import NamedUser class TeamDiscussion(CompletableGithubObject): def __repr__(self) -> str: ... def _initAttributes(self) -> None: ... def _useAttributes(self, attributes: Dict[str, Any]) -> None: ... @property def author(self) -> NamedUser: ... @property def body(self) -> str: ... @property def body_html(self) -> str: ... @property def body_version(self) -> str: ... @property def comments_count(self) -> int: ... @property def comments_url(self) -> str: ... @property def created_at(self) -> datetime: ... @property def html_url(self) -> str: ... @property def last_edited_at(self) -> datetime: ... @property def node_id(self) -> str: ... @property def number(self) -> int: ... @property def pinned(self) -> bool: ... @property def private(self) -> bool: ... @property def team_url(self) -> str: ... @property def title(self) -> str: ... @property def updated_at(self) -> datetime: ... @property def url(self) -> str: ... ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1619412308.0 PyGithub-1.55/github/TimelineEvent.py0000644000175100001710000001414600000000000017151 0ustar00runnerdocker############################ Copyrights and license ############################ # # # Copyright 2019 Nick Campbell # # # # This file is part of PyGithub. # # http://pygithub.readthedocs.io/ # # # # PyGithub is free software: you can redistribute it and/or modify it under # # the terms of the GNU Lesser General Public License as published by the Free # # Software Foundation, either version 3 of the License, or (at your option) # # any later version. # # # # PyGithub is distributed in the hope that it will be useful, but WITHOUT ANY # # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more # # details. # # # # You should have received a copy of the GNU Lesser General Public License # # along with PyGithub. If not, see . # # # ################################################################################ import github.GithubObject import github.NamedUser import github.TimelineEventSource class TimelineEvent(github.GithubObject.NonCompletableGithubObject): """ This class represents IssueTimelineEvents. The reference can be found here https://docs.github.com/en/rest/reference/issues#timeline """ def __repr__(self): return self.get__repr__({"id": self._id.value}) @property def actor(self): """ :type: :class:`github.NamedUser.NamedUser` """ return self._actor.value @property def commit_id(self): """ :type: string """ return self._commit_id.value @property def created_at(self): """ :type: datetime.datetime """ return self._created_at.value @property def event(self): """ :type: string """ return self._event.value @property def id(self): """ :type: integer """ return self._id.value @property def node_id(self): """ :type: string """ return self._node_id.value @property def commit_url(self): """ :type: string """ return self._commit_url.value @property def source(self): """ :type: :class:`github.TimelineEventSource.TimelineEventSource` """ # only available on `cross-referenced` events. if ( self.event == "cross-referenced" and self._source is not github.GithubObject.NotSet ): return self._source.value return None @property def body(self): """ :type string """ if self.event == "commented" and self._body is not github.GithubObject.NotSet: return self._body.value return None @property def author_association(self): """ :type string """ if ( self.event == "commented" and self._author_association is not github.GithubObject.NotSet ): return self._author_association.value return None @property def url(self): """ :type: string """ return self._url.value def _initAttributes(self): self._actor = github.GithubObject.NotSet self._commit_id = github.GithubObject.NotSet self._created_at = github.GithubObject.NotSet self._event = github.GithubObject.NotSet self._id = github.GithubObject.NotSet self._node_id = github.GithubObject.NotSet self._commit_url = github.GithubObject.NotSet self._source = github.GithubObject.NotSet self._body = github.GithubObject.NotSet self._author_association = github.GithubObject.NotSet self._url = github.GithubObject.NotSet def _useAttributes(self, attributes): if "actor" in attributes: # pragma no branch self._actor = self._makeClassAttribute( github.NamedUser.NamedUser, attributes["actor"] ) if "commit_id" in attributes: # pragma no branch self._commit_id = self._makeStringAttribute(attributes["commit_id"]) if "created_at" in attributes: # pragma no branch self._created_at = self._makeDatetimeAttribute(attributes["created_at"]) if "event" in attributes: # pragma no branch self._event = self._makeStringAttribute(attributes["event"]) if "id" in attributes: # pragma no branch self._id = self._makeIntAttribute(attributes["id"]) if "node_id" in attributes: # pragma no branch self._node_id = self._makeStringAttribute(attributes["node_id"]) if "commit_url" in attributes: # pragma no branch self._commit_url = self._makeStringAttribute(attributes["commit_url"]) if "source" in attributes: # pragma no branch self._source = self._makeClassAttribute( github.TimelineEventSource.TimelineEventSource, attributes["source"] ) if "body" in attributes: # pragma no branch self._body = self._makeStringAttribute(attributes["body"]) if "author_association" in attributes: # pragma no branch self._author_association = self._makeStringAttribute( attributes["author_association"] ) if "url" in attributes: # pragma no branch self._url = self._makeStringAttribute(attributes["url"]) ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1619412308.0 PyGithub-1.55/github/TimelineEvent.pyi0000644000175100001710000000175500000000000017324 0ustar00runnerdockerfrom datetime import datetime from typing import Any, Dict from github.GithubObject import NonCompletableGithubObject from github.NamedUser import NamedUser from github.TimelineEventSource import TimelineEventSource class TimelineEvent(NonCompletableGithubObject): def __repr__(self) -> str: ... def _initAttributes(self) -> None: ... def _useAttributes(self, attributes: Dict[str, Any]) -> None: ... @property def actor(self) -> NamedUser: ... @property def commit_id(self) -> str: ... @property def created_at(self) -> datetime: ... @property def event(self) -> str: ... @property def id(self) -> int: ... @property def node_id(self) -> str: ... @property def commit_url(self) -> str: ... @property def source(self) -> Any[TimelineEventSource, None]: ... @property def body(self) -> Any[str, None]: ... @property def author_association(self) -> Any[str, None]: ... @property def url(self) -> str: ... ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1619412308.0 PyGithub-1.55/github/TimelineEventSource.py0000644000175100001710000000534600000000000020334 0ustar00runnerdocker############################ Copyrights and license ############################ # # # Copyright 2019 Nick Campbell # # # # This file is part of PyGithub. # # http://pygithub.readthedocs.io/ # # # # PyGithub is free software: you can redistribute it and/or modify it under # # the terms of the GNU Lesser General Public License as published by the Free # # Software Foundation, either version 3 of the License, or (at your option) # # any later version. # # # # PyGithub is distributed in the hope that it will be useful, but WITHOUT ANY # # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more # # details. # # # # You should have received a copy of the GNU Lesser General Public License # # along with PyGithub. If not, see . # # # ################################################################################ import github.GithubObject import github.Issue class TimelineEventSource(github.GithubObject.NonCompletableGithubObject): """ This class represents IssueTimelineEventSource. The reference can be found here https://docs.github.com/en/rest/reference/issues#timeline """ def __repr__(self): return self.get__repr__({"type": self._type.value}) @property def type(self): """ :type: string """ return self._type.value @property def issue(self): """ :type: :class:`github.Issue.Issue` """ return self._issue.value def _initAttributes(self): self._type = github.GithubObject.NotSet self._issue = github.GithubObject.NotSet def _useAttributes(self, attributes): if "type" in attributes: # pragma no branch self._type = self._makeStringAttribute(attributes["type"]) if "issue" in attributes: # pragma no branch self._issue = self._makeClassAttribute( github.Issue.Issue, attributes["issue"] ) ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1619412308.0 PyGithub-1.55/github/TimelineEventSource.pyi0000644000175100001710000000064100000000000020476 0ustar00runnerdockerfrom typing import Any, Dict from github.GithubObject import NonCompletableGithubObject from github.Issue import Issue class TimelineEventSource(NonCompletableGithubObject): def __repr__(self) -> str: ... def _initAttributes(self) -> None: ... def _useAttributes(self, attributes: Dict[str, Any]) -> None: ... @property def type(self) -> str: ... @property def issue(self) -> Issue: ... ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1619412308.0 PyGithub-1.55/github/Topic.py0000644000175100001710000001304600000000000015455 0ustar00runnerdocker############################ Copyrights and license ############################ # # # Copyright 2018 Steve Kowalik # # # # This file is part of PyGithub. # # http://pygithub.readthedocs.io/ # # # # PyGithub is free software: you can redistribute it and/or modify it under # # the terms of the GNU Lesser General Public License as published by the Free # # Software Foundation, either version 3 of the License, or (at your option) # # any later version. # # # # PyGithub is distributed in the hope that it will be useful, but WITHOUT ANY # # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more # # details. # # # # You should have received a copy of the GNU Lesser General Public License # # along with PyGithub. If not, see . # # # ################################################################################ import github.GithubObject class Topic(github.GithubObject.NonCompletableGithubObject): """ This class represents topics as used by https://github.com/topics. The object reference can be found here https://docs.github.com/en/rest/reference/search#search-topics """ def __repr__(self): return self.get__repr__({"name": self._name.value}) @property def name(self): """ :type: string """ return self._name.value @property def display_name(self): """ :type: string """ return self._display_name.value @property def short_description(self): """ :type: string """ return self._short_description.value @property def description(self): """ :type: string """ return self._description.value @property def created_by(self): """ :type: string """ return self._created_by.value @property def released(self): """ :type: string """ return self._released.value @property def created_at(self): """ :type: datetime.datetime """ return self._created_at.value @property def updated_at(self): """ :type: datetime.datetime """ return self._updated_at.value @property def featured(self): """ :type: bool """ return self._featured.value @property def curated(self): """ :type: bool """ return self._curated.value @property def score(self): """ :type: float """ return self._score.value def _initAttributes(self): self._name = github.GithubObject.NotSet self._display_name = github.GithubObject.NotSet self._short_description = github.GithubObject.NotSet self._description = github.GithubObject.NotSet self._created_by = github.GithubObject.NotSet self._released = github.GithubObject.NotSet self._created_at = github.GithubObject.NotSet self._updated_at = github.GithubObject.NotSet self._featured = github.GithubObject.NotSet self._curated = github.GithubObject.NotSet self._score = github.GithubObject.NotSet def _useAttributes(self, attributes): if "name" in attributes: # pragma no branch self._name = self._makeStringAttribute(attributes["name"]) if "display_name" in attributes: # pragma no branch self._display_name = self._makeStringAttribute(attributes["display_name"]) if "short_description" in attributes: # pragma no branch self._short_description = self._makeStringAttribute( attributes["short_description"] ) if "description" in attributes: # pragma no branch self._description = self._makeStringAttribute(attributes["description"]) if "created_by" in attributes: # pragma no branch self._created_by = self._makeStringAttribute(attributes["created_by"]) if "released" in attributes: # pragma no branch self._released = self._makeStringAttribute(attributes["released"]) if "created_at" in attributes: # pragma no branch self._created_at = self._makeDatetimeAttribute(attributes["created_at"]) if "updated_at" in attributes: # pragma no branch self._updated_at = self._makeDatetimeAttribute(attributes["updated_at"]) if "featured" in attributes: # pragma no branch self._featured = self._makeBoolAttribute(attributes["featured"]) if "curated" in attributes: # pragma no branch self._curated = self._makeBoolAttribute(attributes["curated"]) if "score" in attributes: # pragma no branch self._score = self._makeFloatAttribute(attributes["score"]) ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1619412308.0 PyGithub-1.55/github/Topic.pyi0000644000175100001710000000074700000000000015632 0ustar00runnerdockerfrom typing import Any, Dict from github.GithubObject import NonCompletableGithubObject class Topic(NonCompletableGithubObject): def __repr__(self) -> str: ... def _initAttributes(self) -> None: ... def _useAttributes(self, attributes: Dict[str, Any]) -> None: ... @property def description(self) -> str: ... @property def display_name(self) -> str: ... @property def name(self) -> str: ... @property def short_description(self) -> str: ... ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1619412308.0 PyGithub-1.55/github/UserKey.py0000644000175100001710000001116500000000000015766 0ustar00runnerdocker############################ Copyrights and license ############################ # # # Copyright 2012 Vincent Jacques # # Copyright 2012 Zearin # # Copyright 2013 AKFish # # Copyright 2013 Vincent Jacques # # Copyright 2013 martinqt # # Copyright 2014 Vincent Jacques # # Copyright 2016 Jannis Gebauer # # Copyright 2016 Peter Buckley # # Copyright 2018 Wan Liuyang # # Copyright 2018 sfdye # # # # This file is part of PyGithub. # # http://pygithub.readthedocs.io/ # # # # PyGithub is free software: you can redistribute it and/or modify it under # # the terms of the GNU Lesser General Public License as published by the Free # # Software Foundation, either version 3 of the License, or (at your option) # # any later version. # # # # PyGithub is distributed in the hope that it will be useful, but WITHOUT ANY # # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more # # details. # # # # You should have received a copy of the GNU Lesser General Public License # # along with PyGithub. If not, see . # # # ################################################################################ import github.GithubObject class UserKey(github.GithubObject.CompletableGithubObject): """ This class represents UserKeys. The reference can be found here http://docs.github.com/en/rest/reference/users#keys """ def __repr__(self): return self.get__repr__({"id": self._id.value, "title": self._title.value}) @property def id(self): """ :type: integer """ self._completeIfNotSet(self._id) return self._id.value @property def key(self): """ :type: string """ self._completeIfNotSet(self._key) return self._key.value @property def title(self): """ :type: string """ self._completeIfNotSet(self._title) return self._title.value @property def url(self): """ :type: string """ self._completeIfNotSet(self._url) return self._url.value @property def verified(self): """ :type: bool """ self._completeIfNotSet(self._verified) return self._verified.value def delete(self): """ :calls: `DELETE /user/keys/{id} `_ :rtype: None """ headers, data = self._requester.requestJsonAndCheck("DELETE", self.url) def _initAttributes(self): self._id = github.GithubObject.NotSet self._key = github.GithubObject.NotSet self._title = github.GithubObject.NotSet self._url = github.GithubObject.NotSet self._verified = github.GithubObject.NotSet def _useAttributes(self, attributes): if "id" in attributes: # pragma no branch self._id = self._makeIntAttribute(attributes["id"]) if "key" in attributes: # pragma no branch self._key = self._makeStringAttribute(attributes["key"]) if "title" in attributes: # pragma no branch self._title = self._makeStringAttribute(attributes["title"]) if "url" in attributes: # pragma no branch self._url = self._makeStringAttribute(attributes["url"]) if "verified" in attributes: # pragma no branch self._verified = self._makeBoolAttribute(attributes["verified"]) ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1619412308.0 PyGithub-1.55/github/UserKey.pyi0000644000175100001710000000103000000000000016125 0ustar00runnerdockerfrom typing import Any, Dict from github.GithubObject import CompletableGithubObject class UserKey(CompletableGithubObject): def __repr__(self) -> str: ... def _initAttributes(self) -> None: ... def _useAttributes(self, attributes: Dict[str, Any]) -> None: ... def delete(self) -> None: ... @property def id(self) -> int: ... @property def key(self) -> str: ... @property def title(self) -> str: ... @property def url(self) -> str: ... @property def verified(self) -> bool: ... ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1619412308.0 PyGithub-1.55/github/View.py0000644000175100001710000000670200000000000015312 0ustar00runnerdocker############################ Copyrights and license ############################ # # # Copyright 2018 Justin Kufro # # Copyright 2018 Ivan Minno # # Copyright 2018 Zilei Gu # # Copyright 2018 Yves Zumbach # # Copyright 2018 Leying Chen # # # # This file is part of PyGithub. # # http://pygithub.readthedocs.io/ # # # # PyGithub is free software: you can redistribute it and/or modify it under # # the terms of the GNU Lesser General Public License as published by the Free # # Software Foundation, either version 3 of the License, or (at your option) # # any later version. # # # # PyGithub is distributed in the hope that it will be useful, but WITHOUT ANY # # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more # # details. # # # # You should have received a copy of the GNU Lesser General Public License # # along with PyGithub. If not, see . # # # ################################################################################ import github.GithubObject class View(github.GithubObject.NonCompletableGithubObject): """ This class represents a popular Path for a GitHub repository. The reference can be found here https://docs.github.com/en/rest/reference/repos#traffic """ def __repr__(self): return self.get__repr__( { "timestamp": self._timestamp.value, "count": self._count.value, "uniques": self._uniques.value, } ) @property def timestamp(self): """ :type: datetime.datetime """ return self._timestamp.value @property def count(self): """ :type: integer """ return self._count.value @property def uniques(self): """ :type: integer """ return self._uniques.value def _initAttributes(self): self._timestamp = github.GithubObject.NotSet self._count = github.GithubObject.NotSet self._uniques = github.GithubObject.NotSet def _useAttributes(self, attributes): if "timestamp" in attributes: # pragma no branch self._timestamp = self._makeDatetimeAttribute(attributes["timestamp"]) if "count" in attributes: # pragma no branch self._count = self._makeIntAttribute(attributes["count"]) if "uniques" in attributes: # pragma no branch self._uniques = self._makeIntAttribute(attributes["uniques"]) ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1619412308.0 PyGithub-1.55/github/View.pyi0000644000175100001710000000071100000000000015455 0ustar00runnerdockerfrom datetime import datetime from typing import Any, Dict from github.GithubObject import NonCompletableGithubObject class View(NonCompletableGithubObject): def __repr__(self) -> str: ... def _initAttributes(self) -> None: ... def _useAttributes(self, attributes: Dict[str, Any]) -> None: ... @property def timestamp(self) -> datetime: ... @property def count(self) -> int: ... @property def uniques(self) -> int: ... ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1619412308.0 PyGithub-1.55/github/Workflow.py0000644000175100001710000002060200000000000016205 0ustar00runnerdocker############################ Copyrights and license ############################ # # # Copyright 2020 Steve Kowalik # # # # This file is part of PyGithub. # # http://pygithub.readthedocs.io/ # # # # PyGithub is free software: you can redistribute it and/or modify it under # # the terms of the GNU Lesser General Public License as published by the Free # # Software Foundation, either version 3 of the License, or (at your option) # # any later version. # # # # PyGithub is distributed in the hope that it will be useful, but WITHOUT ANY # # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more # # details. # # # # You should have received a copy of the GNU Lesser General Public License # # along with PyGithub. If not, see . # # # ################################################################################ import github.GithubObject import github.WorkflowRun class Workflow(github.GithubObject.CompletableGithubObject): """ This class represents Workflows. The reference can be found here https://docs.github.com/en/rest/reference/actions#workflows """ def __repr__(self): return self.get__repr__({"name": self._name.value, "url": self._url.value}) @property def id(self): """ :type: int """ self._completeIfNotSet(self._id) return self._id.value @property def name(self): """ :type: string """ self._completeIfNotSet(self._name) return self._name.value @property def path(self): """ :type: string """ self._completeIfNotSet(self._path) return self._path.value @property def state(self): """ :type: string """ self._completeIfNotSet(self._state) return self._state.value @property def created_at(self): """ :type: datetime.datetime """ self._completeIfNotSet(self._created_at) return self._created_at.value @property def updated_at(self): """ :type: datetime.datetime """ self._completeIfNotSet(self._updated_at) return self._updated_at.value @property def url(self): """ :type: string """ self._completeIfNotSet(self._url) return self._url.value @property def html_url(self): """ :type: string """ self._completeIfNotSet(self._html_url) return self._html_url.value @property def badge_url(self): """ :type: string """ self._completeIfNotSet(self._badge_url) return self._badge_url.value def create_dispatch(self, ref, inputs=github.GithubObject.NotSet): """ :calls: `POST /repos/{owner}/{repo}/actions/workflows/{workflow_id}/dispatches `_ :param ref: :class:`github.Branch.Branch` or :class:`github.Tag.Tag` or :class:`github.Commit.Commit` or string :param inputs: dict :rtype: bool """ assert ( isinstance(ref, github.Branch.Branch) or isinstance(ref, github.Tag.Tag) or isinstance(ref, github.Commit.Commit) or isinstance(ref, str) ), ref assert inputs is github.GithubObject.NotSet or isinstance(inputs, dict), inputs if isinstance(ref, github.Branch.Branch): ref = ref.name elif isinstance(ref, github.Commit.Commit): ref = ref.sha elif isinstance(ref, github.Tag.Tag): ref = ref.name if inputs is github.GithubObject.NotSet: inputs = {} status, _, _ = self._requester.requestJson( "POST", f"{self.url}/dispatches", input={"ref": ref, "inputs": inputs} ) return status == 204 def get_runs( self, actor=github.GithubObject.NotSet, branch=github.GithubObject.NotSet, event=github.GithubObject.NotSet, status=github.GithubObject.NotSet, ): """ :calls: `GET /repos/{owner}/{repo}/actions/workflows/{workflow_id}/runs `_ :param actor: :class:`github.NamedUser.NamedUser` or string :param branch: :class:`github.Branch.Branch` or string :param event: string :param status: string :rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.WorkflowRun.WorkflowRun` """ assert ( actor is github.GithubObject.NotSet or isinstance(actor, github.NamedUser.NamedUser) or isinstance(actor, str) ), actor assert ( branch is github.GithubObject.NotSet or isinstance(branch, github.Branch.Branch) or isinstance(branch, str) ), branch assert event is github.GithubObject.NotSet or isinstance(event, str), event assert status is github.GithubObject.NotSet or isinstance(status, str), status url_parameters = dict() if actor is not github.GithubObject.NotSet: url_parameters["actor"] = ( actor._identity if isinstance(actor, github.NamedUser.NamedUser) else actor ) if branch is not github.GithubObject.NotSet: url_parameters["branch"] = ( branch.name if isinstance(branch, github.Branch.Branch) else branch ) if event is not github.GithubObject.NotSet: url_parameters["event"] = event if status is not github.GithubObject.NotSet: url_parameters["status"] = status return github.PaginatedList.PaginatedList( github.WorkflowRun.WorkflowRun, self._requester, f"{self.url}/runs", url_parameters, None, list_item="workflow_runs", ) def _initAttributes(self): self._id = github.GithubObject.NotSet self._name = github.GithubObject.NotSet self._path = github.GithubObject.NotSet self._state = github.GithubObject.NotSet self._created_at = github.GithubObject.NotSet self._updated_at = github.GithubObject.NotSet self._url = github.GithubObject.NotSet self._html_url = github.GithubObject.NotSet self._badge_url = github.GithubObject.NotSet def _useAttributes(self, attributes): if "id" in attributes: # pragma no branch self._id = self._makeIntAttribute(attributes["id"]) if "name" in attributes: # pragma no branch self._name = self._makeStringAttribute(attributes["name"]) if "path" in attributes: # pragma no branch self._path = self._makeStringAttribute(attributes["path"]) if "state" in attributes: # pragma no branch self._state = self._makeStringAttribute(attributes["state"]) if "created_at" in attributes: # pragma no branch self._created_at = self._makeDatetimeAttribute(attributes["created_at"]) if "updated_at" in attributes: # pragma no branch self._updated_at = self._makeDatetimeAttribute(attributes["updated_at"]) if "url" in attributes: # pragma no branch self._url = self._makeStringAttribute(attributes["url"]) if "html_url" in attributes: # pragma no branch self._html_url = self._makeStringAttribute(attributes["html_url"]) if "badge_url" in attributes: # pragma no branch self._badge_url = self._makeStringAttribute(attributes["badge_url"]) ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1619412308.0 PyGithub-1.55/github/Workflow.pyi0000644000175100001710000000264100000000000016361 0ustar00runnerdockerfrom datetime import datetime from typing import Any, Dict, Union from github.Branch import Branch from github.Commit import Commit from github.GithubObject import CompletableGithubObject, _NotSetType from github.NamedUser import NamedUser from github.PaginatedList import PaginatedList from github.Tag import Tag from github.WorkflowRun import WorkflowRun class Workflow(CompletableGithubObject): def __repr__(self) -> str: ... def _initAttributes(self) -> None: ... def _useAttributes(self, attributes: Dict[str, Any]) -> None: ... def create_dispatch( self, ref: Union[str, Branch, Commit, Tag], inputs: Union[Dict[str, Union[str, int, float]], _NotSetType] = ..., ) -> bool: ... def get_runs( self, actor: Union[str, NamedUser, _NotSetType] = ..., branch: Union[str, Branch, _NotSetType] = ..., event: Union[str, _NotSetType] = ..., status: Union[str, _NotSetType] = ..., ) -> PaginatedList[WorkflowRun]: ... @property def id(self) -> int: ... @property def name(self) -> str: ... @property def path(self) -> str: ... @property def state(self) -> str: ... @property def created_at(self) -> datetime: ... @property def updated_at(self) -> datetime: ... @property def url(self) -> str: ... @property def html_url(self) -> str: ... @property def badge_url(self) -> str: ... ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1619412308.0 PyGithub-1.55/github/WorkflowRun.py0000644000175100001710000002751200000000000016701 0ustar00runnerdocker############################ Copyrights and license ############################ # # # Copyright 2020 Steve Kowalik # # # # This file is part of PyGithub. # # http://pygithub.readthedocs.io/ # # # # PyGithub is free software: you can redistribute it and/or modify it under # # the terms of the GNU Lesser General Public License as published by the Free # # Software Foundation, either version 3 of the License, or (at your option) # # any later version. # # # # PyGithub is distributed in the hope that it will be useful, but WITHOUT ANY # # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more # # details. # # # # You should have received a copy of the GNU Lesser General Public License # # along with PyGithub. If not, see . # # # ################################################################################ from collections import namedtuple import github.GithubObject import github.PullRequest class WorkflowRun(github.GithubObject.CompletableGithubObject): """ This class represents Workflow Runs. The reference can be found here https://docs.github.com/en/rest/reference/actions#workflow-runs """ def __repr__(self): return self.get__repr__({"id": self._id.value, "url": self._url.value}) @property def id(self): """ :type: int """ self._completeIfNotSet(self._id) return self._id.value @property def head_branch(self): """ :type: string """ self._completeIfNotSet(self._head_branch) return self._head_branch.value @property def head_sha(self): """ :type: string """ self._completeIfNotSet(self._head_sha) return self._head_sha.value @property def run_number(self): """ :type: int """ self._completeIfNotSet(self._run_number) return self._run_number.value @property def event(self): """ :type: string """ self._completeIfNotSet(self._event) return self._event.value @property def status(self): """ :type: string """ self._completeIfNotSet(self._status) return self._status.value @property def conclusion(self): """ :type: string """ self._completeIfNotSet(self._conclusion) return self._conclusion.value @property def workflow_id(self): """ :type: int """ self._completeIfNotSet(self._workflow_id) return self._workflow_id.value @property def url(self): """ :type: string """ self._completeIfNotSet(self._url) return self._url.value @property def html_url(self): """ :type: string """ self._completeIfNotSet(self._html_url) return self._html_url.value @property def pull_requests(self): """ :type: list of :class:`github.PullRequest.PullRequest` """ self._completeIfNotSet(self._pull_requests) return self._pull_requests.value @property def created_at(self): """ :type: datetime.datetime """ self._completeIfNotSet(self._created_at) return self._created_at.value @property def updated_at(self): """ :type: datetime.datetime """ self._completeIfNotSet(self._updated_at) return self._updated_at.value @property def jobs_url(self): """ :type: string """ self._completeIfNotSet(self._jobs_url) return self._jobs_url.value @property def logs_url(self): """ :type: string """ self._completeIfNotSet(self._logs_url) return self._logs_url.value @property def check_suite_url(self): """ :type: string """ self._completeIfNotSet(self._check_suite_url) return self._check_suite_url.value @property def artifacts_url(self): """ :type: string """ self._completeIfNotSet(self._artifacts_url) return self._artifacts_url.value @property def cancel_url(self): """ :type: string """ self._completeIfNotSet(self._cancel_url) return self._cancel_url.value @property def rerun_url(self): """ :type: string """ self._completeIfNotSet(self._rerun_url) return self._rerun_url.value @property def workflow_url(self): """ :type: string """ self._completeIfNotSet(self._workflow_url) return self._workflow_url.value @property def head_commit(self): """ :type: :class:`github.GitCommit.GitCommit` """ self._completeIfNotSet(self._head_commit) return self._head_commit.value @property def repository(self): """ :type: :class:`github.Repository.Repository` """ self._completeIfNotSet(self._repository) return self._repository.value @property def head_repository(self): """ :type: :class:`github.Repository.Repository` """ self._completeIfNotSet(self._head_repository) return self._head_repository.value def cancel(self): """ :calls: `POST /repos/{owner}/{repo}/actions/runs/{run_id}/cancel `_ :rtype: bool """ status, _, _ = self._requester.requestJson("POST", self.cancel_url) return status == 202 def rerun(self): """ :calls: `POST /repos/{owner}/{repo}/actions/runs/{run_id}/rerun `_ :rtype: bool """ status, _, _ = self._requester.requestJson("POST", self.rerun_url) return status == 201 def timing(self): """ :calls: `GET /repos/{owner}/{repo}/actions/runs/{run_id}/timing `_ :rtype: namedtuple with billable and run_duration_ms members """ headers, data = self._requester.requestJsonAndCheck("GET", f"{self.url}/timing") timingdata = namedtuple("TimingData", data.keys()) return timingdata._make(data.values()) def _initAttributes(self): self._id = github.GithubObject.NotSet self._head_branch = github.GithubObject.NotSet self._head_sha = github.GithubObject.NotSet self._run_number = github.GithubObject.NotSet self._event = github.GithubObject.NotSet self._status = github.GithubObject.NotSet self._conclusion = github.GithubObject.NotSet self._workflow_id = github.GithubObject.NotSet self._url = github.GithubObject.NotSet self._html_url = github.GithubObject.NotSet self._pull_requests = github.GithubObject.NotSet self._created_at = github.GithubObject.NotSet self._updated_at = github.GithubObject.NotSet self._jobs_url = github.GithubObject.NotSet self._logs_url = github.GithubObject.NotSet self._check_suite_url = github.GithubObject.NotSet self._artifacts_url = github.GithubObject.NotSet self._cancel_url = github.GithubObject.NotSet self._rerun_url = github.GithubObject.NotSet self._workflow_url = github.GithubObject.NotSet self._head_commit = github.GithubObject.NotSet self._repository = github.GithubObject.NotSet self._head_repository = github.GithubObject.NotSet def _useAttributes(self, attributes): if "id" in attributes: # pragma no branch self._id = self._makeIntAttribute(attributes["id"]) if "head_branch" in attributes: # pragma no branch self._head_branch = self._makeStringAttribute(attributes["head_branch"]) if "head_sha" in attributes: # pragma no branch self._head_sha = self._makeStringAttribute(attributes["head_sha"]) if "run_number" in attributes: # pragma no branch self._run_number = self._makeIntAttribute(attributes["run_number"]) if "event" in attributes: # pragma no branch self._event = self._makeStringAttribute(attributes["event"]) if "status" in attributes: # pragma no branch self._status = self._makeStringAttribute(attributes["status"]) if "conclusion" in attributes: # pragma no branch self._conclusion = self._makeStringAttribute(attributes["conclusion"]) if "workflow_id" in attributes: # pragma no branch self._workflow_id = self._makeIntAttribute(attributes["workflow_id"]) if "url" in attributes: # pragma no branch self._url = self._makeStringAttribute(attributes["url"]) if "html_url" in attributes: # pragma no branch self._html_url = self._makeStringAttribute(attributes["html_url"]) if "pull_requests" in attributes: # pragma no branch self._pull_requests = self._makeListOfClassesAttribute( github.PullRequest.PullRequest, attributes["pull_requests"] ) if "created_at" in attributes: # pragma no branch self._created_at = self._makeDatetimeAttribute(attributes["created_at"]) if "updated_at" in attributes: # pragma no branch self._updated_at = self._makeDatetimeAttribute(attributes["updated_at"]) if "jobs_url" in attributes: # pragma no branch self._jobs_url = self._makeStringAttribute(attributes["jobs_url"]) if "logs_url" in attributes: # pragma no branch self._logs_url = self._makeStringAttribute(attributes["logs_url"]) if "check_suite_url" in attributes: # pragma no branch self._check_suite_url = self._makeStringAttribute( attributes["check_suite_url"] ) if "artifacts_url" in attributes: # pragma no branch self._artifacts_url = self._makeStringAttribute(attributes["artifacts_url"]) if "cancel_url" in attributes: # pragma no branch self._cancel_url = self._makeStringAttribute(attributes["cancel_url"]) if "rerun_url" in attributes: # pragma no branch self._rerun_url = self._makeStringAttribute(attributes["rerun_url"]) if "workflow_url" in attributes: # pragma no branch self._workflow_url = self._makeStringAttribute(attributes["workflow_url"]) if "head_commit" in attributes: # pragma no branch self._head_commit = self._makeClassAttribute( github.GitCommit.GitCommit, attributes["head_commit"] ) if "repository" in attributes: # pragma no branch self._repository = self._makeClassAttribute( github.Repository.Repository, attributes["repository"] ) if "head_repository" in attributes: # pragma no branch self._head_repository = self._makeClassAttribute( github.Repository.Repository, attributes["head_repository"] ) ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1619412308.0 PyGithub-1.55/github/WorkflowRun.pyi0000644000175100001710000000350200000000000017043 0ustar00runnerdockerfrom datetime import datetime from typing import Any, Dict, NamedTuple, List from github.GitCommit import GitCommit from github.GithubObject import CompletableGithubObject from github.PullRequest import PullRequest from github.Repository import Repository class TimingData(NamedTuple): billable: Dict[str, Dict[str, int]] run_duration_ms: int class WorkflowRun(CompletableGithubObject): def __repr__(self) -> str: ... def _initAttributes(self) -> None: ... def _useAttributes(self, attributes: Dict[str, Any]) -> None: ... @property def id(self) -> int: ... @property def head_branch(self) -> str: ... @property def head_sha(self) -> str: ... @property def run_number(self) -> int: ... @property def event(self) -> str: ... @property def status(self) -> str: ... @property def conclusion(self) -> str: ... @property def workflow_id(self) -> int: ... @property def url(self) -> str: ... @property def html_url(self) -> str: ... @property def pull_requests(self) -> List[PullRequest]: ... @property def created_at(self) -> datetime: ... @property def updated_at(self) -> datetime: ... @property def jobs_url(self) -> str: ... @property def logs_url(self) -> str: ... @property def check_suite_url(self) -> str: ... @property def artifacts_url(self) -> str: ... @property def cancel_url(self) -> str: ... @property def rerun_url(self) -> str: ... @property def workflow_url(self) -> str: ... @property def head_commit(self) -> GitCommit: ... @property def repository(self) -> Repository: ... @property def head_repository(self) -> Repository: ... def cancel(self) -> bool: ... def rerun(self) -> bool: ... def timing(self) -> TimingData: ... ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1619412308.0 PyGithub-1.55/github/__init__.py0000644000175100001710000000736100000000000016141 0ustar00runnerdocker############################ Copyrights and license ############################ # # # Copyright 2012 Vincent Jacques # # Copyright 2012 Zearin # # Copyright 2013 Vincent Jacques # # Copyright 2014 Vincent Jacques # # Copyright 2016 Jannis Gebauer # # Copyright 2016 Peter Buckley # # Copyright 2017 sharkykh # # Copyright 2018 sfdye # # # # This file is part of PyGithub. # # http://pygithub.readthedocs.io/ # # # # PyGithub is free software: you can redistribute it and/or modify it under # # the terms of the GNU Lesser General Public License as published by the Free # # Software Foundation, either version 3 of the License, or (at your option) # # any later version. # # # # PyGithub is distributed in the hope that it will be useful, but WITHOUT ANY # # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more # # details. # # # # You should have received a copy of the GNU Lesser General Public License # # along with PyGithub. If not, see . # # # ################################################################################ """ The primary class you will instantiate is :class:`github.MainClass.Github`. From its ``get_``, ``create_`` methods, you will obtain instances of all Github objects like :class:`github.NamedUser.NamedUser` or :class:`github.Repository.Repository`. All classes inherit from :class:`github.GithubObject.GithubObject`. """ __all__ = [ "BadAttributeException", "BadCredentialsException", "BadUserAgentException", "enable_console_debug_logging", "Github", "GithubException", "GithubIntegration", "IncompletableObject", "InputFileContent", "InputGitAuthor", "InputGitTreeElement", "RateLimitExceededException", "TwoFactorException", "UnknownObjectException", ] import logging from github.MainClass import Github, GithubIntegration from .GithubException import ( BadAttributeException, BadCredentialsException, BadUserAgentException, GithubException, IncompletableObject, RateLimitExceededException, TwoFactorException, UnknownObjectException, ) from .InputFileContent import InputFileContent from .InputGitAuthor import InputGitAuthor from .InputGitTreeElement import InputGitTreeElement def enable_console_debug_logging(): # pragma no cover (Function useful only outside test environment) """ This function sets up a very simple logging configuration (log everything on standard output) that is useful for troubleshooting. """ logger = logging.getLogger("github") logger.setLevel(logging.DEBUG) logger.addHandler(logging.StreamHandler()) ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1619412308.0 PyGithub-1.55/github/__init__.pyi0000644000175100001710000000171300000000000016305 0ustar00runnerdockerfrom github.MainClass import Github as Github from github.MainClass import GithubIntegration as GithubIntegration from .GithubException import BadAttributeException as BadAttributeException from .GithubException import BadCredentialsException as BadCredentialsException from .GithubException import BadUserAgentException as BadUserAgentException from .GithubException import GithubException as GithubException from .GithubException import IncompletableObject as IncompleteableObject from .GithubException import RateLimitExceededException as RateLimitExceededException from .GithubException import TwoFactorException as TwoFactorException from .GithubException import UnknownObjectException as UnknownObjectException from .InputFileContent import InputFileContent as InputFileContent from .InputGitAuthor import InputGitAuthor as InputGitAuthor from .InputGitTreeElement import InputGitTreeElement as InputGitTreeElement def enable_console_debug_logging() -> None: ... ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1619412308.0 PyGithub-1.55/github/py.typed0000644000175100001710000000000000000000000015506 0ustar00runnerdocker././@PaxHeader0000000000000000000000000000003400000000000010212 xustar0028 mtime=1619412318.9267669 PyGithub-1.55/setup.cfg0000644000175100001710000000004600000000000014360 0ustar00runnerdocker[egg_info] tag_build = tag_date = 0 ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1619412308.0 PyGithub-1.55/setup.py0000755000175100001710000001270500000000000014261 0ustar00runnerdocker#!/usr/bin/env python ############################ Copyrights and license ############################ # # # Copyright 2012 Vincent Jacques # # Copyright 2012 Zearin # # Copyright 2013 Vincent Jacques # # Copyright 2014 Tomas Radej # # Copyright 2014 Vincent Jacques # # Copyright 2015 Jimmy Zelinskie # # Copyright 2016 Felix Yan # # Copyright 2016 Jakub Wilk # # Copyright 2016 Jannis Gebauer # # Copyright 2016 Peter Buckley # # Copyright 2017 Hugo # # Copyright 2017 Jannis Gebauer # # Copyright 2017 Jannis Gebauer # # Copyright 2017 Nhomar Hernandez # # Copyright 2017 Paul Ortman # # Copyright 2018 Jason White # # Copyright 2018 Mike Miller # # Copyright 2018 Wan Liuyang # # Copyright 2018 sfdye # # # # This file is part of PyGithub. # # http://pygithub.readthedocs.io/ # # # # PyGithub is free software: you can redistribute it and/or modify it under # # the terms of the GNU Lesser General Public License as published by the Free # # Software Foundation, either version 3 of the License, or (at your option) # # any later version. # # # # PyGithub is distributed in the hope that it will be useful, but WITHOUT ANY # # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more # # details. # # # # You should have received a copy of the GNU Lesser General Public License # # along with PyGithub. If not, see . # # # ################################################################################ import textwrap import setuptools version = "1.55" if __name__ == "__main__": setuptools.setup( name="PyGithub", version=version, description="Use the full Github API v3", author="Vincent Jacques", author_email="vincent@vincent-jacques.net", url="https://github.com/pygithub/pygithub", project_urls={ "Documentation": "http://pygithub.readthedocs.io/en/latest/", "Source": "https://github.com/pygithub/pygithub", "Tracker": "https://github.com/pygithub/pygithub/issues", }, long_description=textwrap.dedent( """\ (Very short) Tutorial ===================== First create a Github instance:: from github import Github # using username and password g = Github("user", "password") # or using an access token g = Github("access_token") Then play with your Github objects:: for repo in g.get_user().get_repos(): print(repo.name) repo.edit(has_wiki=False) Reference documentation ======================= See http://pygithub.readthedocs.io/en/latest/""" ), packages=["github"], package_data={"github": ["py.typed", "*.pyi"]}, classifiers=[ "Development Status :: 5 - Production/Stable", "Environment :: Web Environment", "Intended Audience :: Developers", "License :: OSI Approved :: GNU Library or Lesser General Public License (LGPL)", "Operating System :: OS Independent", "Programming Language :: Python", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7", "Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.9", "Topic :: Software Development", ], python_requires=">=3.6", install_requires=[ "deprecated", "pyjwt>=2.0", "pynacl>=1.4.0", "requests>=2.14.0", ], extras_require={"integrations": ["cryptography"]}, tests_require=["cryptography", "httpretty>=1.0.3"], )