PyGithub-1.43.7/0000775000372000037200000000000013455250700010262 5ustar PyGithub-1.43.7/COPYING0000664000372000037200000010451313455250617011330 0ustar 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 . PyGithub-1.43.7/setup.py0000775000372000037200000001255613455250617012017 0ustar #!/usr/bin/env python # -*- coding: utf-8 -*- ############################ 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 setuptools import textwrap version = "1.43.7" 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="http://pygithub.readthedocs.io/en/latest/", 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={}, 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 :: 2", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7", "Topic :: Software Development", ], test_suite="tests.AllTests", use_2to3=True, python_requires=">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*", install_requires=[ "deprecated", "pyjwt", "requests>=2.14.0" ], extras_require={ "integrations": ["cryptography"] }, tests_require=[ "cryptography", "httpretty==0.9.6" ] ) PyGithub-1.43.7/setup.cfg0000664000372000037200000000004613455250700012103 0ustar [egg_info] tag_build = tag_date = 0 PyGithub-1.43.7/README.md0000664000372000037200000000471213455250617011554 0ustar # PyGitHub [![PyPI](https://img.shields.io/pypi/v/PyGithub.svg)](https://pypi.python.org/pypi/PyGithub) [![Build Status](https://travis-ci.org/PyGithub/PyGithub.svg?branch=master)](https://travis-ci.org/PyGithub/PyGithub) [![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) [![Join the chat at https://gitter.im/PyGithub/PyGithub](https://badges.gitter.im/PyGithub/PyGithub.svg)](https://gitter.im/PyGithub/PyGithub?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) [![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) PyGitHub is a Python (2 and 3) library to access the [GitHub API v3] and [Github Enterprise API v3]. This library enables you to manage [GitHub] resources such as repositories, user profiles, and organizations in your Python applications. [GitHub API v3]: https://developer.github.com/v3 [Github Enterprise API v3]: https://developer.github.com/enterprise/2.13/v3/ [GitHub]: https://github.com ## Install ```bash $ pip install PyGithub ``` ## Simple Demo ```python from github import Github # First create a Github instance: # using username and password g = Github("user", "password") # or 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. PyGithub-1.43.7/PyGithub.egg-info/0000775000372000037200000000000013455250700013507 5ustar PyGithub-1.43.7/PyGithub.egg-info/dependency_links.txt0000664000372000037200000000000113455250700017555 0ustar PyGithub-1.43.7/PyGithub.egg-info/SOURCES.txt0000664000372000037200000000427113455250700015377 0ustar COPYING 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/AuthenticatedUser.py github/Authorization.py github/AuthorizationApplication.py github/Branch.py github/BranchProtection.py github/Clones.py github/Commit.py github/CommitCombinedStatus.py github/CommitComment.py github/CommitStats.py github/CommitStatus.py github/Comparison.py github/Consts.py github/ContentFile.py github/Download.py github/Event.py github/File.py github/Gist.py github/GistComment.py github/GistFile.py github/GistHistoryState.py github/GitAuthor.py github/GitBlob.py github/GitCommit.py github/GitObject.py github/GitRef.py github/GitRelease.py github/GitReleaseAsset.py github/GitTag.py github/GitTree.py github/GitTreeElement.py github/GithubException.py github/GithubObject.py github/GitignoreTemplate.py github/Hook.py github/HookDescription.py github/HookResponse.py github/InputFileContent.py github/InputGitAuthor.py github/InputGitTreeElement.py github/Installation.py github/InstallationAuthorization.py github/Invitation.py github/Issue.py github/IssueComment.py github/IssueEvent.py github/IssuePullRequest.py github/Label.py github/Legacy.py github/License.py github/MainClass.py github/Migration.py github/Milestone.py github/NamedUser.py github/Notification.py github/NotificationSubject.py github/Organization.py github/PaginatedList.py github/Path.py github/Permissions.py github/Plan.py github/Project.py github/ProjectCard.py github/ProjectColumn.py github/PullRequest.py github/PullRequestComment.py github/PullRequestMergeStatus.py github/PullRequestPart.py github/PullRequestReview.py github/Rate.py github/RateLimit.py github/Reaction.py github/Referrer.py github/Repository.py github/RepositoryKey.py github/Requester.py github/RequiredPullRequestReviews.py github/RequiredStatusChecks.py github/SourceImport.py github/Stargazer.py github/StatsCodeFrequency.py github/StatsCommitActivity.py github/StatsContributor.py github/StatsParticipation.py github/StatsPunchCard.py github/Tag.py github/Team.py github/Topic.py github/UserKey.py github/View.py github/__init__.pyPyGithub-1.43.7/PyGithub.egg-info/PKG-INFO0000664000372000037200000000320513455250700014604 0ustar Metadata-Version: 2.1 Name: PyGithub Version: 1.43.7 Summary: Use the full Github API v3 Home-page: http://pygithub.readthedocs.io/en/latest/ Author: Vincent Jacques Author-email: vincent@vincent-jacques.net License: UNKNOWN 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 :: 2 Classifier: Programming Language :: Python :: 2.7 Classifier: Programming Language :: Python :: 3 Classifier: Programming Language :: Python :: 3.5 Classifier: Programming Language :: Python :: 3.6 Classifier: Programming Language :: Python :: 3.7 Classifier: Topic :: Software Development Requires-Python: >=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.* Provides-Extra: integrations PyGithub-1.43.7/PyGithub.egg-info/requires.txt0000664000372000037200000000007713455250700016113 0ustar deprecated pyjwt requests>=2.14.0 [integrations] cryptography PyGithub-1.43.7/PyGithub.egg-info/top_level.txt0000664000372000037200000000000713455250700016236 0ustar github PyGithub-1.43.7/github/0000775000372000037200000000000013455250700011544 5ustar PyGithub-1.43.7/github/RepositoryKey.py0000664000372000037200000001334013455250617014756 0ustar # -*- coding: utf-8 -*- ############################ 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://developer.github.com/v3/repos/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"]) PyGithub-1.43.7/github/InputGitAuthor.py0000664000372000037200000000640213455250617015055 0ustar # -*- coding: utf-8 -*- ############################ 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(object): """ 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, unicode)), name assert isinstance(email, (str, unicode)), email assert date is github.GithubObject.NotSet or isinstance(date, (str, unicode)), date # @todo Datetime? self.__name = name self.__email = email self.__date = date def __repr__(self): return 'InputGitAuthor(name="{}")'.format(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 PyGithub-1.43.7/github/__init__.py0000664000372000037200000000650413455250617013671 0ustar # -*- coding: utf-8 -*- ############################ 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 instanciate 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`. """ import logging from github.MainClass import Github, GithubIntegration from GithubException import GithubException, BadCredentialsException, UnknownObjectException, BadUserAgentException, RateLimitExceededException, BadAttributeException, TwoFactorException 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()) PyGithub-1.43.7/github/GithubObject.py0000664000372000037200000002640513455250617014505 0ustar # -*- coding: utf-8 -*- ############################ 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 sys import datetime from operator import itemgetter import GithubException import Consts atLeastPython3 = sys.hexversion >= 0x03000000 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(object): """ 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, e: return _BadAttribute(value, type, e) else: return _BadAttribute(value, type) @staticmethod def _makeStringAttribute(value): return GithubObject.__makeSimpleAttribute(value, (str, unicode)) @staticmethod def _makeIntAttribute(value): return GithubObject.__makeSimpleAttribute(value, (int, long)) @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, long), 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, unicode), 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, unicode)) @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, unicode)) and isinstance(element, dict) for key, element in value.iteritems()): return _ValuedAttribute(dict((key, klass(self._requester, self._headers, element, completed=False)) for key, element in value.iteritems())) else: return _BadAttribute(value, {(str, unicode): 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): if atLeastPython3: items = params.items() else: items = list(params.items()) for k, v in sorted(items, key=itemgetter(0), reverse=True): isText = isinstance(v, (str, unicode)) if isText and not atLeastPython3: v = v.encode('utf-8') yield '{k}="{v}"'.format(k=k, v=v) if isText else '{k}={v}'.format(k=k, v=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): GithubObject.__init__(self, 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 __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): headers, data = self._requester.requestJsonAndCheck( "GET", self._url.value ) self._storeAndUseAttributes(headers, data) self.__completed = True def update(self): ''' 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 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 PyGithub-1.43.7/github/GistComment.py0000664000372000037200000001311513455250617014357 0ustar # -*- coding: utf-8 -*- ############################ 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://developer.github.com/v3/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, unicode)), 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"]) PyGithub-1.43.7/github/MainClass.py0000664000372000037200000007600113455250617014003 0ustar # -*- coding: utf-8 -*- ############################ 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 # # # # 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 import pickle import time import sys import requests import jwt import urllib3 from Requester import Requester import AuthenticatedUser import NamedUser import Organization import Gist import github.PaginatedList import Repository import Installation import Legacy import License import Topic import github.GithubObject import HookDescription import GitignoreTemplate import RateLimit import InstallationAuthorization import GithubException import Invitation import Consts atLeastPython3 = sys.hexversion >= 0x03000000 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(object): """ 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, client_id=None, client_secret=None, user_agent='PyGithub/Python', per_page=DEFAULT_PER_PAGE, api_preview=False, verify=True, retry=None): """ :param login_or_token: string :param password: string :param base_url: string :param timeout: integer :param client_id: string :param client_secret: string :param user_agent: string :param per_page: int :param verify: boolean or string :param retry: int or urllib3.util.retry.Retry object """ assert login_or_token is None or isinstance(login_or_token, (str, unicode)), login_or_token assert password is None or isinstance(password, (str, unicode)), password assert jwt is None or isinstance(jwt, (str, unicode)), jwt assert isinstance(base_url, (str, unicode)), base_url assert isinstance(timeout, (int, long)), timeout assert client_id is None or isinstance(client_id, (str, unicode)), client_id assert client_secret is None or isinstance(client_secret, (str, unicode)), client_secret assert user_agent is None or isinstance(user_agent, (str, unicode)), user_agent assert isinstance(api_preview, (bool)) assert retry is None or isinstance(retry, (int)) or isinstance(retry, (urllib3.util.Retry)) self.__requester = Requester(login_or_token, password, jwt, base_url, timeout, client_id, client_secret, user_agent, per_page, api_preview, verify, retry) def __get_FIX_REPO_GET_GIT_REF(self): """ :type: bool """ return self.__requester.FIX_REPO_GET_GIT_REF def __set_FIX_REPO_GET_GIT_REF(self, value): self.__requester.FIX_REPO_GET_GIT_REF = value FIX_REPO_GET_GIT_REF = property(__get_FIX_REPO_GET_GIT_REF, __set_FIX_REPO_GET_GIT_REF) def __get_per_page(self): """ :type: int """ return self.__requester.per_page def __set_per_page(self, value): self.__requester.per_page = value # v2: Remove this property? Why should it be necessary to read/modify it after construction per_page = property(__get_per_page, __set_per_page) # 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, unicode)), key headers, data = self.__requester.requestJsonAndCheck( "GET", "/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_user(self, login=github.GithubObject.NotSet): """ :calls: `GET /users/:user `_ or `GET /user `_ :param login: string :rtype: :class:`github.NamedUser.NamedUser` """ assert login is github.GithubObject.NotSet or isinstance(login, (str, unicode)), login if login is github.GithubObject.NotSet: return AuthenticatedUser.AuthenticatedUser(self.__requester, {}, {"url": "/user"}, completed=False) else: headers, data = self.__requester.requestJsonAndCheck( "GET", "/users/" + login ) 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, long)), 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, unicode)), login headers, data = self.__requester.requestJsonAndCheck( "GET", "/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, long)), since url_parameters = dict() if since is not github.GithubObject.NotSet: url_parameters["since"] = since return github.PaginatedList.PaginatedList( github.NamedUser.NamedUser, 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, unicode, int, long)), full_name_or_id url_base = "/repositories/" if isinstance(full_name_or_id, int) or isinstance(full_name_or_id, long) else "/repos/" url = "%s%s" % (url_base, full_name_or_id) if lazy: return Repository.Repository(self.__requester, {}, {"url": url}, completed=False) headers, data = self.__requester.requestJsonAndCheck( "GET", "%s%s" % (url_base, full_name_or_id) ) return Repository.Repository(self.__requester, headers, data, completed=True) def get_repos(self, since=github.GithubObject.NotSet): """ :calls: `GET /repositories `_ :param since: integer :rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.Repository.Repository` """ assert since is github.GithubObject.NotSet or isinstance(since, (int, long)), since url_parameters = dict() if since is not github.GithubObject.NotSet: url_parameters["since"] = since 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_gist(self, id): """ :calls: `GET /gists/:id `_ :param id: string :rtype: :class:`github.Gist.Gist` """ assert isinstance(id, (str, unicode)), id headers, data = self.__requester.requestJsonAndCheck( "GET", "/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, unicode)), 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("%s:%s" % (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, unicode)), 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("%s:%s" % (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, unicode)), 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("%s:%s" % (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, unicode)), 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("%s:%s" % (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, unicode)), 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("%s:%s" % (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, unicode)), 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("%s:%s" % (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, unicode)), 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, unicode)), name headers, attributes = self.__requester.requestJsonAndCheck( "GET", "/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, unicode)), name headers, attributes = self.__requester.requestJsonAndCheck( "GET", "/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 optionaly 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 informations 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_installation(self, id): """ :param id: :return: """ return Installation.Installation(self.__requester, headers={}, attributes={"id": id}, completed=True) class GithubIntegration(object): """ Main class to obtain tokens for a GitHub integration. """ def __init__(self, integration_id, private_key): """ :param integration_id: int :param private_key: string """ self.integration_id = integration_id self.private_key = private_key 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: """ 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 atLeastPython3: 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( "https://api.github.com/app/installations/{}/access_tokens".format(installation_id), headers={ "Authorization": "Bearer {}".format(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 ) PyGithub-1.43.7/github/GitObject.py0000664000372000037200000000670313455250617014005 0ustar # -*- coding: utf-8 -*- ############################ 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"]) PyGithub-1.43.7/github/Team.py0000664000372000037200000003731413455250617013023 0ustar # -*- coding: utf-8 -*- ############################ 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 . # # # ################################################################################ import github.GithubObject import github.PaginatedList import github.Repository import github.NamedUser import github.Organization class Team(github.GithubObject.CompletableGithubObject): """ This class represents Teams. The reference can be found here http://developer.github.com/v3/orgs/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 def add_to_members(self, member): """ This API call is deprecated. Use `add_membership` instead. https://developer.github.com/v3/teams/members/#deprecation-notice-1 :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", 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, unicode)), 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", self.url + "/memberships/" + member._identity, input=put_parameters ) 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", self.url + "/repos/" + repo._identity ) 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", self.url + "/repos/" + repo._identity, input=put_parameters ) 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, unicode)), name assert description is github.GithubObject.NotSet or isinstance(description, (str, unicode)), description assert permission is github.GithubObject.NotSet or isinstance(permission, (str, unicode)), permission assert privacy is github.GithubObject.NotSet or isinstance(privacy, (str, unicode)), 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_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, unicode)), 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, 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, self.url + "/repos", None ) 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", 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", 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", self.url + "/memberships/" + member._identity ) def remove_from_members(self, member): """ This API call is deprecated. Use `remove_membership` instead: https://developer.github.com/v3/teams/members/#deprecation-notice-2 :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", 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", 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 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"]) PyGithub-1.43.7/github/IssueComment.py0000664000372000037200000002014213455250617014537 0ustar # -*- coding: utf-8 -*- ############################ 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 # # # # 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 Consts class IssueComment(github.GithubObject.CompletableGithubObject): """ This class represents IssueComments. The reference can be found here https://developer.github.com/v3/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, unicode)), 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, 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, unicode)), "reaction type should be a string" assert reaction_type in ["+1", "-1", "laugh", "confused", "heart", "hooray"], \ "Invalid reaction type (https://developer.github.com/v3/reactions/#reaction-types)" post_parameters = { "content": reaction_type, } headers, data = self._requester.requestJsonAndCheck( "POST", self.url + "/reactions", input=post_parameters, headers={'Accept': Consts.mediaTypeReactionsPreview} ) return github.Reaction.Reaction(self._requester, headers, data, completed=True) 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"]) PyGithub-1.43.7/github/Authorization.py0000664000372000037200000001775513455250617015004 0ustar # -*- coding: utf-8 -*- ############################ 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.AuthorizationApplication class Authorization(github.GithubObject.CompletableGithubObject): """ This class represents Authorizations. The reference can be found here https://developer.github.com/v3/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, unicode)) for element in scopes), scopes assert add_scopes is github.GithubObject.NotSet or all(isinstance(element, (str, unicode)) for element in add_scopes), add_scopes assert remove_scopes is github.GithubObject.NotSet or all(isinstance(element, (str, unicode)) for element in remove_scopes), remove_scopes assert note is github.GithubObject.NotSet or isinstance(note, (str, unicode)), note assert note_url is github.GithubObject.NotSet or isinstance(note_url, (str, unicode)), 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"]) PyGithub-1.43.7/github/View.py0000664000372000037200000000665313455250617013051 0ustar # -*- coding: utf-8 -*- ############################ 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://developer.github.com/v3/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"]) PyGithub-1.43.7/github/NamedUser.py0000664000372000037200000006346313455250617014024 0ustar # -*- coding: utf-8 -*- ############################ 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.GithubObject import github.PaginatedList import github.Gist import github.Repository import github.NamedUser import github.Permissions import github.Plan import github.Organization import github.Event class NamedUser(github.GithubObject.CompletableGithubObject): """ This class represents NamedUsers. The reference can be found here https://developer.github.com/v3/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 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 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 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 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, 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, 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, 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, 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, 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, self.url + "/orgs", None ) 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, 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, 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, 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, unicode)), name headers, data = self._requester.requestJsonAndCheck( "GET", "/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, unicode)), type assert sort is github.GithubObject.NotSet or isinstance(sort, (str, unicode)), sort assert direction is github.GithubObject.NotSet or isinstance(direction, (str, unicode)), 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, 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, 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, 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, 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", self.url + "/following/" + following._identity ) return status == 204 @property def _identity(self): return self.login 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._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._site_admin = github.GithubObject.NotSet self._starred_url = github.GithubObject.NotSet self._subscriptions_url = github.GithubObject.NotSet self._suspended_at = 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 "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 "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 "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 "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"]) PyGithub-1.43.7/github/InputGitTreeElement.py0000664000372000037200000000666713455250617016041 0ustar # -*- coding: utf-8 -*- ############################ 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(object): """ 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 """ assert isinstance(path, (str, unicode)), path assert isinstance(mode, (str, unicode)), mode assert isinstance(type, (str, unicode)), type assert content is github.GithubObject.NotSet or isinstance(content, (str, unicode)), content assert sha is github.GithubObject.NotSet or isinstance(sha, (str, unicode)), 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 PyGithub-1.43.7/github/Branch.py0000664000372000037200000005142613455250617013332 0ustar # -*- coding: utf-8 -*- ############################ 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.GithubObject import github.BranchProtection import github.Commit import github.RequiredPullRequestReviews import github.RequiredStatusChecks import Consts class Branch(github.GithubObject.NonCompletableGithubObject): """ This class represents Branches. The reference can be found here https://developer.github.com/v3/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, unicode)) or isinstance(element, (str, unicode)) 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, unicode)) or isinstance(element, (str, unicode)) for element in dismissal_users), dismissal_users assert dismissal_teams is github.GithubObject.NotSet or all(isinstance(element, (str, unicode)) or isinstance(element, (str, unicode)) 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", 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, unicode)) or isinstance(element, (str, unicode)) 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", 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", 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", 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, unicode)) or isinstance(element, (str, unicode)) for element in dismissal_users), dismissal_users assert dismissal_teams is github.GithubObject.NotSet or all(isinstance(element, (str, unicode)) or isinstance(element, (str, unicode)) 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", 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", 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", 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", 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", 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, 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, self.protection_url + "/restrictions/teams", None ) def edit_user_push_restrictions(self, *users): """ :calls: `POST /repos/:owner/:repo/branches/:branch/protection/restrictions `_ :users: list of strings """ assert all(isinstance(element, (str, unicode)) or isinstance(element, (str, unicode)) for element in users), users headers, data = self._requester.requestJsonAndCheck( "POST", self.protection_url + "/restrictions/users", input=users ) def edit_team_push_restrictions(self, *teams): """ :calls: `POST /repos/:owner/:repo/branches/:branch/protection/restrictions `_ :teams: list of strings """ assert all(isinstance(element, (str, unicode)) or isinstance(element, (str, unicode)) for element in teams), teams headers, data = self._requester.requestJsonAndCheck( "POST", 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", 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", 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", 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", self.protection_url + "/required_signatures", headers={'Accept': Consts.signaturesProtectedBranchesPreview} ) PyGithub-1.43.7/github/ProjectColumn.py0000664000372000037200000001546613455250617014725 0ustar # -*- coding: utf-8 -*- ############################ 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 json import github.GithubObject import github.Project import github.ProjectCard import Consts class ProjectColumn(github.GithubObject.CompletableGithubObject): """ This class represents Project Columns. The reference can be found here http://developer.github.com/v3/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, unicode)), 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, 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 """ post_parameters = {} if isinstance(note, (str, unicode)): 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, unicode)), content_type post_parameters = {"content_id": content_id, "content_type": content_type} import_header = {"Accept": Consts.mediaTypeProjectsPreview} headers, data = self._requester.requestJsonAndCheck( "POST", self.url + "/cards", headers=import_header, input=post_parameters ) return github.ProjectCard.ProjectCard(self._requester, headers, data, completed=True) 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"]) PyGithub-1.43.7/github/Tag.py0000664000372000037200000001014713455250617012643 0ustar # -*- coding: utf-8 -*- ############################ 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 import github.Commit class Tag(github.GithubObject.NonCompletableGithubObject): """ This class represents Tags. The reference can be found here https://developer.github.com/v3/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"]) PyGithub-1.43.7/github/IssueEvent.py0000664000372000037200000002331513455250617014223 0ustar # -*- coding: utf-8 -*- ############################ 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://developer.github.com/v3/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 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"]) PyGithub-1.43.7/github/PullRequestMergeStatus.py0000664000372000037200000000733213455250617016603 0ustar # -*- coding: utf-8 -*- ############################ 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://developer.github.com/v3/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"]) PyGithub-1.43.7/github/GitRelease.py0000664000372000037200000002733413455250617014162 0ustar # -*- coding: utf-8 -*- ############################ 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.NamedUser import github.GitReleaseAsset class GitRelease(github.GithubObject.CompletableGithubObject): """ This class represents GitReleases. The reference can be found here https://developer.github.com/v3/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 `_ :rtype: :class:`github.GitRelease.GitRelease` """ assert tag_name is github.GithubObject.NotSet \ or isinstance(tag_name, (str, unicode)), \ 'tag_name must be a str/unicode object' assert target_commitish is github.GithubObject.NotSet \ or isinstance(target_commitish, (str, unicode)), \ 'target_commitish must be a str/unicode object' assert isinstance(name, (str, unicode)), name assert isinstance(message, (str, unicode)), 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 ommited, just don't send it # alltogether 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=""): """ :calls: `POST https:///repos/:owner/:repo/releases/:release_id/assets?name=foo.zip `_ :rtype: :class:`github.GitReleaseAsset.GitReleaseAsset` """ assert isinstance(path, (str, unicode)), path assert isinstance(label, (str, unicode)), label post_parameters = { "name": basename(path), "label": label } headers = {} if len(content_type) > 0: 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 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, 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"]) PyGithub-1.43.7/github/Permissions.py0000664000372000037200000000706213455250617014445 0ustar # -*- coding: utf-8 -*- ############################ 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, "pull": self._pull.value, "push": self._push.value }) @property def admin(self): """ :type: bool """ return self._admin.value @property def pull(self): """ :type: bool """ return self._pull.value @property def push(self): """ :type: bool """ return self._push.value def _initAttributes(self): self._admin = github.GithubObject.NotSet self._pull = github.GithubObject.NotSet self._push = github.GithubObject.NotSet def _useAttributes(self, attributes): if "admin" in attributes: # pragma no branch self._admin = self._makeBoolAttribute(attributes["admin"]) 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"]) PyGithub-1.43.7/github/Legacy.py0000664000372000037200000001662413455250617013342 0ustar # -*- coding: utf-8 -*- ############################ 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 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 urlparse import github.PaginatedList class PaginatedList(github.PaginatedList.PaginatedListBase): def __init__(self, url, args, requester, key, convert, contentClass): github.PaginatedList.PaginatedListBase.__init__(self) self.__url = url self.__args = args self.__requester = requester self.__key = key self.__convert = convert self.__contentClass = contentClass self.__nextPage = 0 self.__continue = True def _couldGrow(self): return self.__continue def _fetchNextPage(self): page = self.__nextPage self.__nextPage += 1 return self.get_page(page) def get_page(self, page): assert isinstance(page, (int, long)), page args = dict(self.__args) if page != 0: args["start_page"] = page + 1 headers, data = self.__requester.requestJsonAndCheck( "GET", self.__url, parameters=args ) self.__continue = len(data[self.__key]) > 0 return [ self.__contentClass(self.__requester, headers, self.__convert(element), completed=False) for element in data[self.__key] ] def convertUser(attributes): convertedAttributes = { "login": attributes["login"], "url": "/users/" + attributes["login"], } if "gravatar_id" in attributes: # pragma no branch convertedAttributes["gravatar_id"] = attributes["gravatar_id"] if "followers" in attributes: # pragma no branch convertedAttributes["followers"] = attributes["followers"] if "repos" in attributes: # pragma no branch convertedAttributes["public_repos"] = attributes["repos"] if "name" in attributes: # pragma no branch convertedAttributes["name"] = attributes["name"] if "created_at" in attributes: # pragma no branch convertedAttributes["created_at"] = attributes["created_at"] if "location" in attributes: # pragma no branch convertedAttributes["location"] = attributes["location"] return convertedAttributes def convertRepo(attributes): convertedAttributes = { "owner": {"login": attributes["owner"], "url": "/users/" + attributes["owner"]}, "url": "/repos/" + attributes["owner"] + "/" + attributes["name"], } if "pushed_at" in attributes: # pragma no branch convertedAttributes["pushed_at"] = attributes["pushed_at"] if "homepage" in attributes: # pragma no branch convertedAttributes["homepage"] = attributes["homepage"] if "created_at" in attributes: # pragma no branch convertedAttributes["created_at"] = attributes["created_at"] if "watchers" in attributes: # pragma no branch convertedAttributes["watchers"] = attributes["watchers"] if "has_downloads" in attributes: # pragma no branch convertedAttributes["has_downloads"] = attributes["has_downloads"] if "fork" in attributes: # pragma no branch convertedAttributes["fork"] = attributes["fork"] if "has_issues" in attributes: # pragma no branch convertedAttributes["has_issues"] = attributes["has_issues"] if "has_wiki" in attributes: # pragma no branch convertedAttributes["has_wiki"] = attributes["has_wiki"] if "forks" in attributes: # pragma no branch convertedAttributes["forks"] = attributes["forks"] if "size" in attributes: # pragma no branch convertedAttributes["size"] = attributes["size"] if "private" in attributes: # pragma no branch convertedAttributes["private"] = attributes["private"] if "open_issues" in attributes: # pragma no branch convertedAttributes["open_issues"] = attributes["open_issues"] if "description" in attributes: # pragma no branch convertedAttributes["description"] = attributes["description"] if "language" in attributes: # pragma no branch convertedAttributes["language"] = attributes["language"] if "name" in attributes: # pragma no branch convertedAttributes["name"] = attributes["name"] return convertedAttributes def convertIssue(attributes): convertedAttributes = { "number": attributes["number"], "url": "/repos" + urlparse.urlparse(attributes["html_url"]).path, "user": {"login": attributes["user"], "url": "/users/" + attributes["user"]}, } if "labels" in attributes: # pragma no branch convertedAttributes["labels"] = [{"name": label} for label in attributes["labels"]] if "title" in attributes: # pragma no branch convertedAttributes["title"] = attributes["title"] if "created_at" in attributes: # pragma no branch convertedAttributes["created_at"] = attributes["created_at"] if "comments" in attributes: # pragma no branch convertedAttributes["comments"] = attributes["comments"] if "body" in attributes: # pragma no branch convertedAttributes["body"] = attributes["body"] if "updated_at" in attributes: # pragma no branch convertedAttributes["updated_at"] = attributes["updated_at"] if "state" in attributes: # pragma no branch convertedAttributes["state"] = attributes["state"] return convertedAttributes PyGithub-1.43.7/github/CommitCombinedStatus.py0000664000372000037200000001134113455250617016222 0ustar # -*- coding: utf-8 -*- ############################ 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.GithubObject import github.CommitStatus import github.Repository class CommitCombinedStatus(github.GithubObject.NonCompletableGithubObject): """ This class represents CommitCombinedStatuses. The reference can be found here https://developer.github.com/v3/repos/statuses/#get-the-combined-status-for-a-specific-ref """ 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"]) PyGithub-1.43.7/github/GitCommit.py0000664000372000037200000001326213455250617014025 0ustar # -*- coding: utf-8 -*- ############################ 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.GitAuthor import github.GitTree class GitCommit(github.GithubObject.CompletableGithubObject): """ This class represents GitCommits. The reference can be found here https://developer.github.com/v3/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"]) PyGithub-1.43.7/github/GistHistoryState.py0000664000372000037200000002440513455250617015423 0ustar # -*- coding: utf-8 -*- ############################ 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 import github.NamedUser import github.CommitStats import github.Gist 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"]) PyGithub-1.43.7/github/Stargazer.py0000664000372000037200000000613513455250617014074 0ustar # -*- coding: utf-8 -*- ############################ 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://developer.github.com/v3/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']) PyGithub-1.43.7/github/Label.py0000664000372000037200000001273413455250617013153 0ustar # -*- coding: utf-8 -*- ############################ 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 import github.GithubObject import Consts class Label(github.GithubObject.CompletableGithubObject): """ This class represents Labels. The reference can be found here http://developer.github.com/v3/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, unicode)), name assert isinstance(color, (str, unicode)), color assert description is github.GithubObject.NotSet or isinstance(description, (str, unicode)), description post_parameters = { "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.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"]) PyGithub-1.43.7/github/RequiredPullRequestReviews.py0000664000372000037200000001171313455250617017463 0ustar # -*- coding: utf-8 -*- ############################ 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://developer.github.com/v3/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"]) PyGithub-1.43.7/github/Topic.py0000664000372000037200000000711713455250617013211 0ustar # -*- coding: utf-8 -*- ############################ 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.CompletableGithubObject): """ This class represents topics as used by https://github.com/topics. The object refereence can be found here https://developer.github.com/v3/search/#search-topics """ 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 display_name(self): """ :type: string """ self._completeIfNotSet(self._display_name) return self._display_name.value @property def short_description(self): """ :type: string """ self._completeIfNotSet(self._short_description) return self._short_description.value @property def description(self): """ :type: string """ self._completeIfNotSet(self._description) return self._description.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 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"]) PyGithub-1.43.7/github/GitReleaseAsset.py0000664000372000037200000001731113455250617015154 0ustar # -*- coding: utf-8 -*- ############################ 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://developer.github.com/v3/repos/releases/#get-a-single-release-asset """ 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 @name.setter def name(self, value): """ :type: string """ self._completeIfNotSet(self._name) self._name.value = value @property def label(self): """ :type: string """ self._completeIfNotSet(self._label) return self._label.value @label.setter def label(self, value): """ :type: string """ self._completeIfNotSet(self._label) self._label.value = 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, unicode)), name assert isinstance(label, (str, unicode)), 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"]) PyGithub-1.43.7/github/CommitComment.py0000664000372000037200000002173513455250617014710 0ustar # -*- coding: utf-8 -*- ############################ 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 # # # # 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 Consts class CommitComment(github.GithubObject.CompletableGithubObject): """ This class represents CommitComments. The reference can be found here https://developer.github.com/v3/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, unicode)), 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, 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, unicode)), "reaction type should be a string" assert reaction_type in ["+1", "-1", "laugh", "confused", "heart", "hooray"], \ "Invalid reaction type (https://developer.github.com/v3/reactions/#reaction-types)" post_parameters = { "content": reaction_type, } headers, data = self._requester.requestJsonAndCheck( "POST", self.url + "/reactions", input=post_parameters, headers={'Accept': Consts.mediaTypeReactionsPreview} ) return github.Reaction.Reaction(self._requester, headers, data, completed=True) 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"]) PyGithub-1.43.7/github/GithubException.py0000664000372000037200000001153213455250617015230 0ustar # -*- coding: utf-8 -*- ############################ 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 . # # # ################################################################################ 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): Exception.__init__(self) self.__status = status self.__data = data self.args = [status, data] @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 def __str__(self): return str(self.status) + " " + str(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 """ PyGithub-1.43.7/github/GitTag.py0000664000372000037200000001147713455250617013316 0ustar # -*- coding: utf-8 -*- ############################ 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.GitAuthor import github.GitObject class GitTag(github.GithubObject.CompletableGithubObject): """ This class represents GitTags. The reference can be found here https://developer.github.com/v3/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"]) PyGithub-1.43.7/github/Consts.py0000664000372000037200000001253513455250617013404 0ustar # -*- coding: utf-8 -*- ############################ 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 # # # # 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-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://developer.github.com/v3/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" PyGithub-1.43.7/github/AuthorizationApplication.py0000664000372000037200000000643613455250617017162 0ustar # -*- coding: utf-8 -*- ############################ 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"]) PyGithub-1.43.7/github/GitAuthor.py0000664000372000037200000000674413455250617014046 0ustar # -*- coding: utf-8 -*- ############################ 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"]) PyGithub-1.43.7/github/PullRequestReview.py0000664000372000037200000001411713455250617015600 0ustar # -*- coding: utf-8 -*- ############################ 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.CompletableGithubObject): """ This class represents PullRequestReviews. The reference can be found here https://developer.github.com/v3/pulls/reviews/ """ def __repr__(self): return self.get__repr__({"id": self._id.value, "user": self._user.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 @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 state(self): """ :type: string """ self._completeIfNotSet(self._state) return self._state.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_request_url(self): """ :type: string """ self._completeIfNotSet(self._pull_request_url) return self._pull_request_url.value @property def submitted_at(self): """ :type: datetime.datetime """ self._completeIfNotSet(self._submitted_at) 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, unicode)), message post_parameters = {'message': message} headers, data = self._requester.requestJsonAndCheck( "PUT", self.pull_request_url + "/reviews/%s/dismissals" % self.id, 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._url = 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 "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_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"]) PyGithub-1.43.7/github/UserKey.py0000664000372000037200000001123413455250617013515 0ustar # -*- coding: utf-8 -*- ############################ 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://developer.github.com/v3/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"]) PyGithub-1.43.7/github/PullRequestPart.py0000664000372000037200000001026513455250617015245 0ustar # -*- coding: utf-8 -*- ############################ 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.Repository import github.NamedUser 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"]) PyGithub-1.43.7/github/CommitStatus.py0000664000372000037200000001336513455250617014571 0ustar # -*- coding: utf-8 -*- ############################ 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://developer.github.com/v3/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"]) PyGithub-1.43.7/github/Download.py0000664000372000037200000002537313455250617013706 0ustar # -*- coding: utf-8 -*- ############################ 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://developer.github.com/v3/repos/downloads/ """ 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"]) PyGithub-1.43.7/github/GitignoreTemplate.py0000664000372000037200000000631313455250617015553 0ustar # -*- coding: utf-8 -*- ############################ 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://developer.github.com/v3/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"]) PyGithub-1.43.7/github/Gist.py0000664000372000037200000003405713455250617013044 0ustar # -*- coding: utf-8 -*- ############################ 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.GithubObject import github.PaginatedList import github.GistComment import github.NamedUser import github.GistFile import github.GistHistoryState class Gist(github.GithubObject.CompletableGithubObject): """ This class represents Gists. The reference can be found here https://developer.github.com/v3/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, unicode)), body post_parameters = { "body": body, } headers, data = self._requester.requestJsonAndCheck( "POST", 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", 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, unicode)), description assert files is github.GithubObject.NotSet or all(element is None or isinstance(element, github.InputFileContent) for element in files.itervalues()), 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.iteritems()} 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, long)), id headers, data = self._requester.requestJsonAndCheck( "GET", self.url + "/comments/" + str(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, self.url + "/comments", None ) def is_starred(self): """ :calls: `GET /gists/:id/star `_ :rtype: bool """ status, headers, data = self._requester.requestJson( "GET", self.url + "/star" ) return status == 204 def reset_starred(self): """ :calls: `DELETE /gists/:id/star `_ :rtype: None """ headers, data = self._requester.requestJsonAndCheck( "DELETE", self.url + "/star" ) def set_starred(self): """ :calls: `PUT /gists/:id/star `_ :rtype: None """ headers, data = self._requester.requestJsonAndCheck( "PUT", 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"]) PyGithub-1.43.7/github/GitTreeElement.py0000664000372000037200000001047413455250617015010 0ustar # -*- coding: utf-8 -*- ############################ 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"]) PyGithub-1.43.7/github/StatsCommitActivity.py0000775000372000037200000000634013455250617016117 0ustar # -*- coding: utf-8 -*- ############################ 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://developer.github.com/v3/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"]) PyGithub-1.43.7/github/StatsParticipation.py0000775000372000037200000000575313455250617015767 0ustar # -*- coding: utf-8 -*- ############################ 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 StatsParticipation(github.GithubObject.NonCompletableGithubObject): """ This class represents StatsParticipations. The reference can be found here http://developer.github.com/v3/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"]) PyGithub-1.43.7/github/Reaction.py0000664000372000037200000001004613455250617013672 0ustar # -*- coding: utf-8 -*- ############################ 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 import Consts class Reaction(github.GithubObject.CompletableGithubObject): """ This class represents Reactions. The reference can be found here https://developer.github.com/v3/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", self._parentUrl("") + "/reactions/" + str(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"]) PyGithub-1.43.7/github/PullRequestComment.py0000664000372000037200000002555013455250617015744 0ustar # -*- coding: utf-8 -*- ############################ 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 # # # # 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 Consts class PullRequestComment(github.GithubObject.CompletableGithubObject): """ This class represents PullRequestComments. The reference can be found here http://developer.github.com/v3/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, unicode)), 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, 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, unicode)), "reaction type should be a string" assert reaction_type in ["+1", "-1", "laugh", "confused", "heart", "hooray"], \ "Invalid reaction type (https://developer.github.com/v3/reactions/#reaction-types)" post_parameters = { "content": reaction_type, } headers, data = self._requester.requestJsonAndCheck( "POST", self.url + "/reactions", input=post_parameters, headers={'Accept': Consts.mediaTypeReactionsPreview} ) return github.Reaction.Reaction(self._requester, headers, data, completed=True) 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"]) PyGithub-1.43.7/github/Commit.py0000664000372000037200000002614413455250617013364 0ustar # -*- coding: utf-8 -*- ############################ 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.PaginatedList import github.GitCommit import github.NamedUser import github.CommitStatus import github.CommitCombinedStatus import github.File import github.CommitStats import github.CommitComment class Commit(github.GithubObject.CompletableGithubObject): """ This class represents Commits. The reference can be found here http://developer.github.com/v3/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, unicode)), body assert line is github.GithubObject.NotSet or isinstance(line, (int, long)), line assert path is github.GithubObject.NotSet or isinstance(path, (str, unicode)), path assert position is github.GithubObject.NotSet or isinstance(position, (int, long)), 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", 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, unicode)), state assert target_url is github.GithubObject.NotSet or isinstance(target_url, (str, unicode)), target_url assert description is github.GithubObject.NotSet or isinstance(description, (str, unicode)), description assert context is github.GithubObject.NotSet or isinstance(context, (str, unicode)), 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", 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, 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, 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", self.url + "/status" ) return github.CommitCombinedStatus.CommitCombinedStatus(self._requester, headers, data, completed=True) @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"]) PyGithub-1.43.7/github/Hook.py0000664000372000037200000002246613455250617013037 0ustar # -*- coding: utf-8 -*- ############################ 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://developer.github.com/v3/repos/hooks """ 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, unicode)), name assert isinstance(config, dict), config assert events is github.GithubObject.NotSet or all(isinstance(element, (str, unicode)) for element in events), events assert add_events is github.GithubObject.NotSet or all(isinstance(element, (str, unicode)) for element in add_events), add_events assert remove_events is github.GithubObject.NotSet or all(isinstance(element, (str, unicode)) 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", self.url + "/tests" ) def ping(self): """ :calls: `POST /repos/:owner/:repo/hooks/:id/pings `_ :rtype: None """ headers, data = self._requester.requestJsonAndCheck( "POST", 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"]) PyGithub-1.43.7/github/StatsPunchCard.py0000775000372000037200000000527313455250617015025 0ustar # -*- coding: utf-8 -*- ############################ 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 StatsPunchCard(github.GithubObject.NonCompletableGithubObject): """ This class represents StatsPunchCards. The reference can be found here http://developer.github.com/v3/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 PyGithub-1.43.7/github/ProjectCard.py0000664000372000037200000001540013455250617014325 0ustar # -*- coding: utf-8 -*- ############################ 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 json import github.GithubObject # 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://developer.github.com/v3/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. Unforunately # 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 `_ :rtype: :class:`github.PullRequest.PullRequest` or :class:`github.Issue.Issue` """ if self.content_url == None: return None if content_type == "PullRequest": headers, data = self._requester.requestJsonAndCheck( "GET", self.content_url.replace("issues", "pulls") ) return github.PullRequest.PullRequest(self._requester, headers, data, completed=True) elif content_type is github.GithubObject.NotSet or content_type == "Issue": headers, data = self._requester.requestJsonAndCheck( "GET", self.content_url ) return github.Issue.Issue(self._requester, headers, data, completed=True) else: assert False, "Unknown content type: %s" % content_type 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"]) PyGithub-1.43.7/github/IssuePullRequest.py0000664000372000037200000000660713455250617015434 0ustar # -*- coding: utf-8 -*- ############################ 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"]) PyGithub-1.43.7/github/RateLimit.py0000664000372000037200000001024213455250617014016 0ustar # -*- coding: utf-8 -*- ############################ 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 from deprecated import deprecated class RateLimit(github.GithubObject.NonCompletableGithubObject): """ This class represents RateLimits. The reference can be found here http://developer.github.com/v3/rate_limit """ def __repr__(self): return self.get__repr__({"core": self._core.value}) @property @deprecated(reason=""" The rate object is deprecated. If you're writing new API client code or updating existing code, you should use the core object instead of the rate object. The core object contains the same information that is present in the rate object. """) def rate(self): """ (Deprecated) Rate limit for non-search-related API, use `core` instead :type: class:`github.Rate.Rate` """ return 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"]) PyGithub-1.43.7/github/Repository.py0000664000372000037200000037064513455250617014323 0ustar # -*- coding: utf-8 -*- ############################ 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 # # # # 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 sys import urllib import datetime from base64 import b64encode import github.GithubObject import github.PaginatedList import github.Branch import github.IssueEvent import github.ContentFile import github.Label import github.GitBlob import github.Organization import github.GitRef import github.GitRelease import github.GitReleaseAsset import github.Issue import github.Repository import github.PullRequest import github.RepositoryKey import github.NamedUser import github.Milestone import github.Project import github.Comparison import github.CommitComment import github.GitCommit import github.Team import github.Commit import github.GitTree import github.Hook import github.Tag import github.GitTag import github.Download import github.Permissions import github.Event import github.Legacy import github.SourceImport import github.StatsContributor import github.StatsCommitActivity import github.StatsCodeFrequency import github.StatsParticipation import github.StatsPunchCard import github.Stargazer import github.Referrer import github.Path import github.Clones import github.View import Consts atLeastPython3 = sys.hexversion >= 0x03000000 class Repository(github.GithubObject.CompletableGithubObject): """ This class represents Repositories. The reference can be found here http://developer.github.com/v3/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 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_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 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 topics(self): """ :type: list of strings """ self._completeIfNotSet(self._topics) return self._topics.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, unicode)), collaborator assert permission is github.GithubObject.NotSet or isinstance(permission, (str, unicode)), 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", 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, unicode)), collaborator if isinstance(collaborator, github.NamedUser.NamedUser): collaborator = collaborator._identity headers, data = self._requester.requestJsonAndCheck( "GET", self.url + "/collaborators/" + collaborator + "/permission", ) return data["permission"] 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, unicode)), base assert isinstance(head, (str, unicode)), head headers, data = self._requester.requestJsonAndCheck( "GET", 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, unicode)), content assert isinstance(encoding, (str, unicode)), encoding post_parameters = { "content": content, "encoding": encoding, } headers, data = self._requester.requestJsonAndCheck( "POST", 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, unicode)), 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", 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, unicode)), ref assert isinstance(sha, (str, unicode)), sha post_parameters = { "ref": ref, "sha": sha, } headers, data = self._requester.requestJsonAndCheck( "POST", 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): self.create_git_tag(tag, tag_message, object, type, tagger) return self.create_git_release(tag, release_name, release_message, draft, prerelease) 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, unicode)), tag assert isinstance(name, (str, unicode)), name assert isinstance(message, (str, unicode)), message assert isinstance(draft, bool), draft assert isinstance(prerelease, bool), prerelease assert target_commitish is github.GithubObject.NotSet or isinstance(target_commitish, (str, unicode, 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, unicode)): 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", 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, unicode)), tag assert isinstance(message, (str, unicode)), message assert isinstance(object, (str, unicode)), object assert isinstance(type, (str, unicode)), 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", 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", 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, unicode)), name assert isinstance(config, dict), config assert events is github.GithubObject.NotSet or all(isinstance(element, (str, unicode)) 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", 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, unicode)), title assert body is github.GithubObject.NotSet or isinstance(body, (str, unicode)), body assert assignee is github.GithubObject.NotSet or isinstance(assignee, github.NamedUser.NamedUser) or isinstance(assignee, (str, unicode)), assignee assert assignees is github.GithubObject.NotSet or all(isinstance(element, github.NamedUser.NamedUser) or isinstance(element, (str, unicode)) 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, unicode)) 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, unicode)): 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", 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, unicode)), title assert isinstance(key, (str, unicode)), key assert isinstance(read_only, bool), read_only post_parameters = { "title": title, "key": key, "read_only": read_only, } headers, data = self._requester.requestJsonAndCheck( "POST", 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, unicode)), name assert isinstance(color, (str, unicode)), color assert description is github.GithubObject.NotSet or isinstance(description, (str, unicode)), description post_parameters = { "name": name, "color": color, } if description is not github.GithubObject.NotSet: post_parameters["description"] = description headers, data = self._requester.requestJsonAndCheck( "POST", 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, unicode)), title assert state is github.GithubObject.NotSet or isinstance(state, (str, unicode)), state assert description is github.GithubObject.NotSet or isinstance(description, (str, unicode)), 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", 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 """ assert isinstance(name, (str, unicode)), name assert body is github.GithubObject.NotSet or isinstance(body, (str, unicode)), body post_parameters = { "name": name, "body": body, } import_header = {"Accept": Consts.mediaTypeProjectsPreview} if body is not github.GithubObject.NotSet: post_parameters['body'] = body headers, data = self._requester.requestJsonAndCheck( "POST", 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 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): assert isinstance(title, (str, unicode)), title assert isinstance(body, (str, unicode)), body assert isinstance(base, (str, unicode)), base assert isinstance(head, (str, unicode)), head assert maintainer_can_modify is github.GithubObject.NotSet or isinstance(maintainer_can_modify, bool), maintainer_can_modify 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) else: return self.__create_pull(title=title, body=body, base=base, head=head) def __create_pull_2(self, issue, base, head): assert isinstance(issue, github.Issue.Issue), issue assert isinstance(base, (str, unicode)), base assert isinstance(head, (str, unicode)), 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", self.url + "/pulls", input=post_parameters ) return github.PullRequest.PullRequest(self._requester, headers, data, completed=True) 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, unicode)), vcs assert isinstance(vcs_url, (str, unicode)), vcs_url assert vcs_username is github.GithubObject.NotSet or isinstance(vcs_username, (str, unicode)), vcs_username assert vcs_password is github.GithubObject.NotSet or isinstance(vcs_password, (str, unicode)), 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", 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, 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 archived: bool. Unarchiving repositories is currently not supported through API (https://developer.github.com/v3/repos/#edit) :rtype: None """ if name is None: name = self.name assert isinstance(name, (str, unicode)), name assert description is github.GithubObject.NotSet or isinstance(description, (str, unicode)), description assert homepage is github.GithubObject.NotSet or isinstance(homepage, (str, unicode)), 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, unicode)), 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 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 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, unicode)), archive_format assert ref is github.GithubObject.NotSet or isinstance(ref, (str, unicode)), ref url = self.url + "/" + archive_format if ref is not github.GithubObject.NotSet: url += "/" + 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, 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, unicode)), branch headers, data = self._requester.requestJsonAndCheck( "GET", 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, 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, \ 'Affiliation can be one of ' + ', '.join(allowed_affiliations) url_parameters['affiliation'] = affiliation return github.PaginatedList.PaginatedList( github.NamedUser.NamedUser, self._requester, 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, long)), id headers, data = self._requester.requestJsonAndCheck( "GET", self.url + "/comments/" + str(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, 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, unicode)), sha headers, data = self._requester.requestJsonAndCheck( "GET", 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, unicode)), sha assert path is github.GithubObject.NotSet or isinstance(path, (str, unicode)), 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, unicode, 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, 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` """ return self.get_file_contents(path, ref) def get_file_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` """ assert isinstance(path, (str, unicode)), path assert ref is github.GithubObject.NotSet or isinstance(ref, (str, unicode)), ref url_parameters = dict() if ref is not github.GithubObject.NotSet: url_parameters["ref"] = ref headers, data = self._requester.requestJsonAndCheck( "GET", self.url + "/contents/" + urllib.quote(path), parameters=url_parameters ) if isinstance(data, list): return [ github.ContentFile.ContentFile(self._requester, headers, item, completed=False) for item in data ] return github.ContentFile.ContentFile(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", 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", 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, unicode)) 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", 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.Clone.Clone` """ assert per is github.GithubObject.NotSet or (isinstance(per, (str, unicode)) 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", 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, 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, unicode)), \ 'path must be str/unicode object' assert isinstance(message, (str, unicode)), \ 'message must be str/unicode object' assert isinstance(content, (str, unicode, bytes)), \ 'content must be a str/unicode object' assert branch is github.GithubObject.NotSet \ or isinstance(branch, (str, unicode)), \ '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' if atLeastPython3: if isinstance(content, str): content = content.encode('utf-8') content = b64encode(content).decode('utf-8') else: if isinstance(content, unicode): content = content.encode('utf-8') content = b64encode(content) 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", self.url + "/contents/" + urllib.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, Base64 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, unicode)), \ 'path must be str/unicode object' assert isinstance(message, (str, unicode)), \ 'message must be str/unicode object' assert isinstance(content, (str, unicode, bytes)), \ 'content must be a str/unicode object' assert isinstance(sha, (str, unicode)), \ 'sha must be a str/unicode object' assert branch is github.GithubObject.NotSet \ or isinstance(branch, (str, unicode)), \ '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' if atLeastPython3: if isinstance(content, str): content = content.encode('utf-8') content = b64encode(content).decode('utf-8') else: if isinstance(content, unicode): content = content.encode('utf-8') content = b64encode(content) 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", self.url + "/contents/" + urllib.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, unicode)), \ 'path must be str/unicode object' assert isinstance(message, (str, unicode)), \ 'message must be str/unicode object' assert isinstance(sha, (str, unicode)), \ 'sha must be a str/unicode object' assert branch is github.GithubObject.NotSet \ or isinstance(branch, (str, unicode)), \ '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", self.url + "/contents/" + urllib.quote(path), input=url_parameters ) return {'commit': github.Commit.Commit(self._requester, headers, data["commit"], completed=True), 'content': github.GithubObject.NotSet} 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` """ assert isinstance(path, (str, unicode)), path assert ref is github.GithubObject.NotSet or isinstance(ref, (str, unicode)), ref url_parameters = dict() if ref is not github.GithubObject.NotSet: url_parameters["ref"] = ref headers, data = self._requester.requestJsonAndCheck( "GET", self.url + "/contents/" + urllib.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 ) return [ github.ContentFile.ContentFile(self._requester, headers, attributes, completed=(attributes["type"] != "file")) # Lazy completion only makes sense for files. See discussion here: https://github.com/jacquev6/PyGithub/issues/140#issuecomment-13481130 for attributes in data ] 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, 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, long)), id headers, data = self._requester.requestJsonAndCheck( "GET", self.url + "/downloads/" + str(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, 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, 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, self.url + "/forks", None ) 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, unicode)), sha headers, data = self._requester.requestJsonAndCheck( "GET", 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, unicode)), sha headers, data = self._requester.requestJsonAndCheck( "GET", 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, unicode)), ref headers, data = self._requester.requestJsonAndCheck( "GET", 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, self.url + "/git/refs", 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, unicode)), sha headers, data = self._requester.requestJsonAndCheck( "GET", 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, unicode)), 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", 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, long)), id headers, data = self._requester.requestJsonAndCheck( "GET", self.url + "/hooks/" + str(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, 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, long)), number headers, data = self._requester.requestJsonAndCheck( "GET", self.url + "/issues/" + str(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 :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, unicode)), state assert assignee is github.GithubObject.NotSet or isinstance(assignee, github.NamedUser.NamedUser) or isinstance(assignee, (str, unicode)), 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) for element in labels), labels assert sort is github.GithubObject.NotSet or isinstance(sort, (str, unicode)), sort assert direction is github.GithubObject.NotSet or isinstance(direction, (str, unicode)), 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, unicode)), creator url_parameters = dict() if milestone is not github.GithubObject.NotSet: if isinstance(milestone, (str, unicode)): 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, unicode)): 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 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, unicode)): url_parameters["creator"] = creator else: url_parameters["creator"] = creator._identity return github.PaginatedList.PaginatedList( github.Issue.Issue, self._requester, 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, unicode)), sort assert direction is github.GithubObject.NotSet or isinstance(direction, (str, unicode)), 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, 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, long)), id headers, data = self._requester.requestJsonAndCheck( "GET", self.url + "/issues/events/" + str(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, 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, long)), id headers, data = self._requester.requestJsonAndCheck( "GET", self.url + "/keys/" + str(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, 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, unicode)), name headers, data = self._requester.requestJsonAndCheck( "GET", self.url + "/labels/" + urllib.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, 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", 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", 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, long)), number headers, data = self._requester.requestJsonAndCheck( "GET", self.url + "/milestones/" + str(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, unicode)), state assert sort is github.GithubObject.NotSet or isinstance(sort, (str, unicode)), sort assert direction is github.GithubObject.NotSet or isinstance(direction, (str, unicode)), 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, 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, "/networks/" + self.owner.login + "/" + self.name + "/events", None ) def get_pull(self, number): """ :calls: `GET /repos/:owner/:repo/pulls/:number `_ :param number: integer :rtype: :class:`github.PullRequest.PullRequest` """ assert isinstance(number, (int, long)), number headers, data = self._requester.requestJsonAndCheck( "GET", self.url + "/pulls/" + str(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, unicode)), state assert sort is github.GithubObject.NotSet or isinstance(sort, (str, unicode)), sort assert direction is github.GithubObject.NotSet or isinstance(direction, (str, unicode)), direction assert base is github.GithubObject.NotSet or isinstance(base, (str, unicode)), base assert head is github.GithubObject.NotSet or isinstance(head, (str, unicode)), 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, 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, unicode)), sort assert direction is github.GithubObject.NotSet or isinstance(direction, (str, unicode)), 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, 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, unicode)), ref url_parameters = dict() if ref is not github.GithubObject.NotSet: url_parameters["ref"] = ref headers, data = self._requester.requestJsonAndCheck( "GET", self.url + "/readme", parameters=url_parameters ) return github.ContentFile.ContentFile(self._requester, headers, data, completed=True) 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", 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, 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, 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", 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", 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", 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", 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", 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, 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, 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, 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", self.url + "/releases/" + str(id) ) return github.GitRelease.GitRelease(self._requester, headers, data, completed=True) elif isinstance(id, (str, unicode)): headers, data = self._requester.requestJsonAndCheck( "GET", 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", 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, self.url + "/teams", None ) def get_topics(self): """ :calls: `GET /repos/:owner/:repo/topics `_ :rtype: list of strings """ headers, data = self._requester.requestJsonAndCheck( "GET", 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, self.url + "/watchers", None ) 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, unicode)), assignee if isinstance(assignee, github.NamedUser.NamedUser): assignee = assignee._identity status, headers, data = self._requester.requestJson( "GET", 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, unicode)), collaborator if isinstance(collaborator, github.NamedUser.NamedUser): collaborator = collaborator._identity status, headers, data = self._requester.requestJson( "GET", self.url + "/collaborators/" + collaborator ) return status == 204 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: :class:`github.PaginatedList.PaginatedList` of :class:`github.Issue.Issue` """ assert state in ["open", "closed"], state assert isinstance(keyword, (str, unicode)), keyword headers, data = self._requester.requestJsonAndCheck( "GET", "/legacy/issues/search/" + self.owner.login + "/" + self.name + "/" + state + "/" + urllib.quote(keyword) ) return [ github.Issue.Issue(self._requester, headers, github.Legacy.convertIssue(element), completed=False) for element in data["issues"] ] 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", 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, unicode)), base assert isinstance(head, (str, unicode)), head assert commit_message is github.GithubObject.NotSet or isinstance(commit_message, (str, unicode)), 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", 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", self.url + "/topics", headers={'Accept': Consts.mediaTypeTopicsPreview}, input=post_parameters ) 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, unicode)), collaborator if isinstance(collaborator, github.NamedUser.NamedUser): collaborator = collaborator._identity headers, data = self._requester.requestJsonAndCheck( "DELETE", self.url + "/collaborators/" + collaborator ) 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 _hub(self, mode, event, callback, secret): assert isinstance(mode, (str, unicode)), mode assert isinstance(event, (str, unicode)), event assert isinstance(callback, (str, unicode)), callback assert secret is github.GithubObject.NotSet or isinstance(secret, (str, unicode)), secret post_parameters = { "hub.mode": mode, "hub.topic": "https://github.com/" + self.full_name + "/events/" + event, "hub.callback": callback, } 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 self.owner.login + "/" + self.name def get_release_asset(self, id): assert isinstance(id, (int)), id resp_headers, data = self._requester.requestJsonAndCheck( "GET", self.url + "/releases/assets/" + str(id) ) return github.GitReleaseAsset.GitReleaseAsset(self._requester, resp_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._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_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._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._topics = 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 "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_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 "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 "topics" in attributes: # pragma no branch self._topics = self._makeListOfStringsAttribute(attributes["topics"]) 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"]) PyGithub-1.43.7/github/Requester.py0000664000372000037200000005335013455250617014112 0ustar # -*- coding: utf-8 -*- ############################ 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 requests import sys import time import urllib import urlparse from io import IOBase import Consts import GithubException atLeastPython3 = sys.hexversion >= 0x03000000 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): if atLeastPython3: return self.headers.items() else: return self.headers.iteritems() def read(self): return self.text class HTTPSRequestsConnectionClass(object): # mimic the httplib connection object def __init__(self, host, port=None, strict=False, timeout=None, retry=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() # Code to support retries if retry: self.retry = retry self.adapter = requests.adapters.HTTPAdapter(max_retries=self.retry) 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 = "%s://%s:%s%s" % (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(object): # mimic the httplib connection object def __init__(self, host, port=None, strict=False, timeout=None, retry=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() # Code to support retries if retry: self.retry = retry self.adapter = requests.adapters.HTTPAdapter(max_retries=self.retry) 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 = "%s://%s:%s%s" % (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 @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 ############################################################# # 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, client_id, client_secret, user_agent, per_page, api_preview, verify, retry): self._initializeDebugFeature() if password is not None: login = login_or_token if atLeastPython3: self.__authorizationHeader = "Basic " + base64.b64encode((login + ":" + password).encode("utf-8")).decode("utf-8").replace('\n', '') # pragma no cover (Covered by Authentication.testAuthorizationHeaderWithXxx with Python 3) else: self.__authorizationHeader = "Basic " + base64.b64encode(login + ":" + password).replace('\n', '') elif login_or_token is not None: token = login_or_token self.__authorizationHeader = "token " + token elif jwt is not None: self.__authorizationHeader = "Bearer " + jwt else: self.__authorizationHeader = None self.__base_url = base_url o = urlparse.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.__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 self.__clientId = client_id self.__clientSecret = client_secret assert user_agent is not None, 'github now requires a user-agent. ' \ 'See http://developer.github.com/v3/#user-agent-required' self.__userAgent = user_agent self.__apiPreview = api_preview 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 = urlparse.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) elif o.scheme == 'https': cnx = self.__httpsConnectionClass(o.hostname, o.port, retry = self.__retry) 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 # pragma no cover (Should be covered) 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) def __structuredFromJson(self, data): if len(data) == 0: return None else: if atLeastPython3 and isinstance(data, bytes): # pragma no branch (Covered by Issue142.testDecodeJson with Python 3) data = data.decode("utf-8") # pragma no cover (Covered by Issue142.testDecodeJson with Python 3) try: return json.loads(data) except ValueError, e: 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.iteritems(): encoded_input += "--" + boundary + eol encoded_input += "Content-Disposition: form-data; name=\"" + name + "\"" + eol encoded_input += eol encoded_input += value + eol encoded_input += "--" + boundary + "--" + eol return "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 __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 if self.__apiPreview: requestHeaders["Accept"] = "application/vnd.github.moondragon+json" 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 = dict((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 = urlparse.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.__clientId and self.__clientSecret and "client_id=" not in url: parameters["client_id"] = self.__clientId parameters["client_secret"] = self.__clientSecret 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 = self.__prefix + url else: o = urlparse.urlparse(url) assert o.hostname in [self.__hostname, "uploads.github.com", "status.github.com"], o.hostname assert o.path.startswith((self.__prefix, "/api/")) assert o.port == self.__port url = o.path if o.query != "": url += "?" + o.query return url def __addParametersToUrl(self, url, parameters): if len(parameters) == 0: return url else: return url + "?" + urllib.urlencode(parameters) def __createConnection(self): kwds = {} if not atLeastPython3: # pragma no branch (Branch useful only with Python 3) kwds["strict"] = True # Useless in Python3, would generate a deprecation warning 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, **kwds) return self.__connection def __log(self, verb, url, requestHeaders, input, status, responseHeaders, output): logger = logging.getLogger(__name__) if 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) logger.debug("%s %s://%s%s %s %s ==> %i %s %s", verb, self.__scheme, self.__hostname, url, requestHeaders, input, status, responseHeaders, output) PyGithub-1.43.7/github/Clones.py0000664000372000037200000000665513455250617013364 0ustar # -*- coding: utf-8 -*- ############################ 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://developer.github.com/v3/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"]) PyGithub-1.43.7/github/Migration.py0000664000372000037200000002001213455250617014051 0ustar # -*- coding: utf-8 -*- ############################ 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.PaginatedList import github.NamedUser import Consts class Migration(github.GithubObject.CompletableGithubObject): """ This class represents Migrations. The reference can be found here http://developer.github.com/v3/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", 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", 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, unicode)), repo_name headers, data = self._requester.requestJsonAndCheck( "DELETE", 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"]) PyGithub-1.43.7/github/CommitStats.py0000664000372000037200000000655513455250617014407 0ustar # -*- coding: utf-8 -*- ############################ 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"]) PyGithub-1.43.7/github/Notification.py0000664000372000037200000001436413455250617014563 0ustar # -*- coding: utf-8 -*- ############################ 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.Repository import github.NotificationSubject class Notification(github.GithubObject.CompletableGithubObject): """ This class represents Notifications. The reference can be found here http://developer.github.com/v3/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 _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"]) PyGithub-1.43.7/github/AuthenticatedUser.py0000664000372000037200000015356113455250617015561 0ustar # -*- coding: utf-8 -*- ############################ 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 datetime import github.GithubObject import github.PaginatedList import github.Gist import github.Repository import github.NamedUser import github.Plan import github.Organization import github.UserKey import github.Issue import github.Event import github.Authorization import github.Notification import github.Migration import Consts class AuthenticatedUser(github.GithubObject.CompletableGithubObject): """ This class represents AuthenticatedUsers as returned by https://developer.github.com/v3/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, unicode)) for element in emails), emails post_parameters = 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", "/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", "/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", "/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", "/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, unicode)) for element in scopes), scopes assert note is github.GithubObject.NotSet or isinstance(note, (str, unicode)), note assert note_url is github.GithubObject.NotSet or isinstance(note_url, (str, unicode)), note_url assert client_id is github.GithubObject.NotSet or isinstance(client_id, (str, unicode)), client_id assert client_secret is github.GithubObject.NotSet or isinstance(client_secret, (str, unicode)), client_secret assert onetime_password is None or isinstance(onetime_password, (str, unicode)), 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", "/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.itervalues()), files assert description is github.GithubObject.NotSet or isinstance(description, (str, unicode)), description post_parameters = { "public": public, "files": {key: value._identity for key, value in files.iteritems()}, } 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, unicode)), title assert isinstance(key, (str, unicode)), 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_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): """ :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 :rtype: :class:`github.Repository.Repository` """ assert isinstance(name, (str, unicode)), name assert description is github.GithubObject.NotSet or isinstance(description, (str, unicode)), description assert homepage is github.GithubObject.NotSet or isinstance(homepage, (str, unicode)), 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, unicode)), license_template assert gitignore_template is github.GithubObject.NotSet or isinstance(gitignore_template, (str, unicode)), 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 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 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, unicode)), name assert email is github.GithubObject.NotSet or isinstance(email, (str, unicode)), email assert blog is github.GithubObject.NotSet or isinstance(blog, (str, unicode)), blog assert company is github.GithubObject.NotSet or isinstance(company, (str, unicode)), company assert location is github.GithubObject.NotSet or isinstance(location, (str, unicode)), location assert hireable is github.GithubObject.NotSet or isinstance(hireable, bool), hireable assert bio is github.GithubObject.NotSet or isinstance(bio, (str, unicode)), 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, long)), id headers, data = self._requester.requestJsonAndCheck( "GET", "/authorizations/" + str(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 string """ headers, data = self._requester.requestJsonAndCheck( "GET", "/user/emails" ) return 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, unicode)), filter assert state is github.GithubObject.NotSet or isinstance(state, (str, unicode)), 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, unicode)), sort assert direction is github.GithubObject.NotSet or isinstance(direction, (str, unicode)), 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, unicode)), filter assert state is github.GithubObject.NotSet or isinstance(state, (str, unicode)), 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, unicode)), sort assert direction is github.GithubObject.NotSet or isinstance(direction, (str, unicode)), 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_key(self, id): """ :calls: `GET /user/keys/:id `_ :param id: integer :rtype: :class:`github.UserKey.UserKey` """ assert isinstance(id, (int, long)), id headers, data = self._requester.requestJsonAndCheck( "GET", "/user/keys/" + str(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, unicode)), id headers, data = self._requester.requestJsonAndCheck( "GET", "/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, "/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, unicode)), name headers, data = self._requester.requestJsonAndCheck( "GET", "/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, unicode)), visibility assert affiliation is github.GithubObject.NotSet or isinstance(affiliation, (str, unicode)), affiliation assert type is github.GithubObject.NotSet or isinstance(type, (str, unicode)), type assert sort is github.GithubObject.NotSet or isinstance(sort, (str, unicode)), sort assert direction is github.GithubObject.NotSet or isinstance(direction, (str, unicode)), 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 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", "/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", "/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", "/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", "/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, unicode)) for element in emails), emails post_parameters = 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", "/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", "/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", "/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", "/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", "/user/repository_invitations/" + str(invitation), input={} ) 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, unicode)) 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 _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"]) PyGithub-1.43.7/github/NotificationSubject.py0000664000372000037200000000745313455250617016104 0ustar # -*- coding: utf-8 -*- ############################ 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://developer.github.com/v3/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"]) PyGithub-1.43.7/github/StatsContributor.py0000775000372000037200000001140313455250617015460 0ustar # -*- coding: utf-8 -*- ############################ 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://developer.github.com/v3/repos/statistics/#get-contributors-list-with-additions-deletions-and-commit-counts """ class Week(github.GithubObject.NonCompletableGithubObject): """ This class represents weekly statistics of a contibutor. """ @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"]) PyGithub-1.43.7/github/RequiredStatusChecks.py0000664000372000037200000000625013455250617016235 0ustar # -*- coding: utf-8 -*- ############################ 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://developer.github.com/v3/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"]) PyGithub-1.43.7/github/Organization.py0000664000372000037200000012700413455250617014575 0ustar # -*- coding: utf-8 -*- ############################ 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 json import github.GithubObject import github.PaginatedList import github.Plan import github.Team import github.Event import github.Repository import github.Project import github.NamedUser import Consts class Organization(github.GithubObject.CompletableGithubObject): """ This class represents Organizations. The reference can be found here http://developer.github.com/v3/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 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 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 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 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 isinstance(role, (str, unicode)), 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", 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", 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", "/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, unicode)), name assert isinstance(config, dict), config assert events is github.GithubObject.NotSet or all(isinstance(element, (str, unicode)) 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", self.url + "/hooks", input=post_parameters ) return github.Hook.Hook(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): """ :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 :rtype: :class:`github.Repository.Repository` """ assert isinstance(name, (str, unicode)), name assert description is github.GithubObject.NotSet or isinstance(description, (str, unicode)), description assert homepage is github.GithubObject.NotSet or isinstance(homepage, (str, unicode)), 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, long)), 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, unicode)), license_template assert gitignore_template is github.GithubObject.NotSet or isinstance(gitignore_template, (str, unicode)), 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 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 headers, data = self._requester.requestJsonAndCheck( "POST", 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): """ :calls: `POST /orgs/:org/teams `_ :param name: string :param repo_names: list of :class:`github.Repository.Repository` :param permission: string :param privacy: string :rtype: :class:`github.Team.Team` """ assert isinstance(name, (str, unicode)), 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, unicode)), permission assert privacy is github.GithubObject.NotSet or isinstance(privacy, (str, unicode)), privacy 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 headers, data = self._requester.requestJsonAndCheck( "POST", 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, long)), id headers, data = self._requester.requestJsonAndCheck( "DELETE", self.url + "/hooks/" + str(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, unicode)), billing_email assert blog is github.GithubObject.NotSet or isinstance(blog, (str, unicode)), blog assert company is github.GithubObject.NotSet or isinstance(company, (str, unicode)), company assert description is github.GithubObject.NotSet or isinstance(description, (str, unicode)), description assert email is github.GithubObject.NotSet or isinstance(email, (str, unicode)), email assert location is github.GithubObject.NotSet or isinstance(location, (str, unicode)), location assert name is github.GithubObject.NotSet or isinstance(name, (str, unicode)), 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, long)), id assert isinstance(name, (str, unicode)), name assert isinstance(config, dict), config assert events is github.GithubObject.NotSet or all(isinstance(element, (str, unicode)) 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", self.url + "/hooks/" + str(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, 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, long)), id headers, data = self._requester.requestJsonAndCheck( "GET", self.url + "/hooks/" + str(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, 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, unicode)), filter assert state is github.GithubObject.NotSet or isinstance(state, (str, unicode)), 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, unicode)), sort assert direction is github.GithubObject.NotSet or isinstance(direction, (str, unicode)), 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, 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, unicode))), filter_ assert (role is github.GithubObject.NotSet or isinstance(role, (str, unicode))), 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, 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, 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, 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, unicode))), filter_ url_parameters = {} if filter_ is not github.GithubObject.NotSet: url_parameters["filter"] = filter_ return github.PaginatedList.PaginatedList( github.NamedUser.NamedUser, self._requester, 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", 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", 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, unicode)), name headers, data = self._requester.requestJsonAndCheck( "GET", "/repos/" + self.login + "/" + name ) return github.Repository.Repository(self._requester, headers, data, completed=True) def get_repos(self, type=github.GithubObject.NotSet): """ :calls: `GET /orgs/:org/repos `_ :param type: string ('all', 'public', 'private', 'forks', 'sources', 'member') :rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.Repository.Repository` """ assert type is github.GithubObject.NotSet or isinstance(type, (str, unicode)), type url_parameters = dict() if type is not github.GithubObject.NotSet: url_parameters["type"] = type return github.PaginatedList.PaginatedList( github.Repository.Repository, self._requester, 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, long)), id headers, data = self._requester.requestJsonAndCheck( "GET", "/teams/" + str(id) ) 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, self.url + "/teams", None ) 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, unicode)), 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, unicode)), 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", 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", 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", 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", 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", 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", 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, unicode)) 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", "/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, "/orgs/" + self.login + "/migrations", None, headers={ "Accept": Consts.mediaTypeMigrationPreview } ) def _initAttributes(self): 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 "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 "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 "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 "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"]) PyGithub-1.43.7/github/PaginatedList.py0000664000372000037200000002341513455250617014662 0ustar # -*- coding: utf-8 -*- ############################ 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 . # # # ################################################################################ try: from urllib.parse import parse_qs except ImportError: from urlparse import parse_qs import github.GithubObject class PaginatedListBase: def __init__(self): self.__elements = list() def __getitem__(self, index): assert isinstance(index, (int, slice)) if isinstance(index, (int, long)): self.__fetchToIndex(index) return self.__elements[index] else: return self._Slice(self, index) def __iter__(self): for element in self.__elements: yield element while self._couldGrow(): newElements = self._grow() for element in newElements: yield element 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) print(len(user.get_repos())) 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"): PaginatedListBase.__init__(self) 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") self.__totalCount = int(parse_qs(lastUrl)['page'][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) = 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 ] PyGithub-1.43.7/github/GitRef.py0000664000372000037200000001227713455250617013316 0ustar # -*- coding: utf-8 -*- ############################ 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://developer.github.com/v3/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, unicode)), 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 get_statuses(self): """ https://developer.github.com/v3/repos/statuses/#list-statuses-for-a-specific-ref :calls: `GET /repos/:owner/:repo/commits/:ref/statuses` :return: """ pass def get_status(self): """ https://developer.github.com/v3/repos/statuses/#get-the-combined-status-for-a-specific-ref :calls: `GET /repos/:owner/:repo/commits/:ref/status` :return: """ pass 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"]) PyGithub-1.43.7/github/Issue.py0000664000372000037200000006004513455250617013222 0ustar # -*- coding: utf-8 -*- ############################ 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 # # # # 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 datetime import github.GithubObject import github.PaginatedList import github.Repository import github.IssueEvent import github.Label import github.NamedUser import github.Milestone import github.IssueComment import github.IssuePullRequest import github.Reaction import Consts class Issue(github.GithubObject.CompletableGithubObject): """ This class represents Issues. The reference can be found here https://developer.github.com/v3/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 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, unicode)) 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", 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, unicode)) 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", 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, unicode)), body post_parameters = { "body": body, } headers, data = self._requester.requestJsonAndCheck( "POST", 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", 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, unicode)), title assert body is github.GithubObject.NotSet or isinstance(body, (str, unicode)), body assert assignee is github.GithubObject.NotSet or assignee is None or isinstance(assignee, github.NamedUser.NamedUser) or isinstance(assignee, (str, unicode)), assignee assert assignees is github.GithubObject.NotSet or all(isinstance(element, github.NamedUser.NamedUser) or isinstance(element, (str, unicode)) for element in assignees), assignees assert state is github.GithubObject.NotSet or isinstance(state, (str, unicode)), 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, unicode)) 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, unicode)): 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 get_comment(self, id): """ :calls: `GET /repos/:owner/:repo/issues/comments/:id `_ :param id: integer :rtype: :class:`github.IssueComment.IssueComment` """ assert isinstance(id, (int, long)), id headers, data = self._requester.requestJsonAndCheck( "GET", self._parentUrl(self.url) + "/comments/" + str(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, 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, 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, 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, unicode)) 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", 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, unicode)), label if isinstance(label, github.Label.Label): label = label._identity else: label = urllib.quote(label) headers, data = self._requester.requestJsonAndCheck( "DELETE", 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, unicode)) 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", 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, 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, unicode)), "reaction type should be a string" assert reaction_type in ["+1", "-1", "laugh", "confused", "heart", "hooray"], \ "Invalid reaction type (https://developer.github.com/v3/reactions/#reaction-types)" post_parameters = { "content": reaction_type, } headers, data = self._requester.requestJsonAndCheck( "POST", self.url + "/reactions", input=post_parameters, headers={'Accept': Consts.mediaTypeReactionsPreview} ) return github.Reaction.Reaction(self._requester, headers, data, completed=True) @property def _identity(self): return self.number def _initAttributes(self): 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._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 "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 "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"]) PyGithub-1.43.7/github/GistFile.py0000664000372000037200000001060013455250617013630 0ustar # -*- coding: utf-8 -*- ############################ 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"]) PyGithub-1.43.7/github/ContentFile.py0000664000372000037200000002066413455250617014347 0ustar # -*- coding: utf-8 -*- ############################ 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 sys import github.GithubObject import github.Repository atLeastPython3 = sys.hexversion >= 0x03000000 class ContentFile(github.GithubObject.CompletableGithubObject): """ This class represents ContentFiles. The reference can be found here https://developer.github.com/v3/repos/contents/#get-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): assert self.encoding == "base64", "unsupported encoding: %s" % self.encoding if atLeastPython3: content = bytearray(self.content, "utf-8") # pragma no cover (covered by tests with Python 3.2) else: content = self.content return base64.b64decode(content) @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"]) PyGithub-1.43.7/github/Installation.py0000664000372000037200000000677513455250617014605 0ustar # -*- coding: utf-8 -*- ############################ Copyrights and license ############################ # # # Copyright 2017 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.PaginatedList import github.Gist import github.Repository import github.NamedUser import github.Plan import github.Organization import github.UserKey import github.Issue import github.Event import github.Authorization import github.Notification import Consts INTEGRATION_PREVIEW_HEADERS = {"Accept": Consts.mediaTypeIntegrationPreview} class Installation(github.GithubObject.NonCompletableGithubObject): """ This class represents Installations. The reference can be found here https://developer.github.com/v3/apps/installations/ """ def __repr__(self): return self.get__repr__({"id": self._id.value}) @property def id(self): return self._id 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 def _useAttributes(self, attributes): if "id" in attributes: # pragma no branch self._id = self._makeIntAttribute(attributes["id"]) PyGithub-1.43.7/github/Project.py0000664000372000037200000001736213455250617013544 0ustar # -*- coding: utf-8 -*- ############################ 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 datetime import json import github.GithubObject import github.ProjectColumn import Consts class Project(github.GithubObject.CompletableGithubObject): """ This class represents Projects. The reference can be found here http://developer.github.com/v3/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 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 https://developer.github.com/v3/projects/columns/#create-a-project-column>`_ :param name: string """ assert isinstance(name, (str, unicode)), name post_parameters = {"name": name} import_header = {"Accept": Consts.mediaTypeProjectsPreview} headers, data = self._requester.requestJsonAndCheck( "POST", 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"]) PyGithub-1.43.7/github/Path.py0000664000372000037200000000730113455250617013022 0ustar # -*- coding: utf-8 -*- ############################ 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://developer.github.com/v3/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"]) PyGithub-1.43.7/github/License.py0000664000372000037200000001372613455250617013520 0ustar # -*- coding: utf-8 -*- ############################ 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 import github.PaginatedList import github.NamedUser class License(github.GithubObject.CompletableGithubObject): """ This class represents Licenses. The reference can be found here https://developer.github.com/v3/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"]) PyGithub-1.43.7/github/Rate.py0000664000372000037200000000661113455250617013024 0ustar # -*- coding: utf-8 -*- ############################ 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 datetime class Rate(github.GithubObject.NonCompletableGithubObject): """ This class represents Rates. The reference can be found here http://developer.github.com/v3/rate_limit """ def __repr__(self): return self.get__repr__({"limit": self._limit.value, "remaining": self._remaining.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"]) PyGithub-1.43.7/github/InstallationAuthorization.py0000664000372000037200000000650313455250617017353 0ustar # -*- coding: utf-8 -*- ############################ 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 datetime import github.GithubObject import github.PaginatedList import github.NamedUser 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"]) PyGithub-1.43.7/github/PullRequest.py0000664000372000037200000010763113455250617014422 0ustar # -*- coding: utf-8 -*- ############################ 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 import github.GithubObject import github.PaginatedList import github.PullRequestMergeStatus import github.NamedUser import github.PullRequestPart import github.PullRequestComment import github.File import github.IssueComment import github.Commit import github.PullRequestReview class PullRequest(github.GithubObject.CompletableGithubObject): """ This class represents PullRequests. The reference can be found here http://developer.github.com/v3/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 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 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 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, unicode)), body assert isinstance(commit_id, github.Commit.Commit), commit_id assert isinstance(path, (str, unicode)), path assert isinstance(position, (int, long)), position post_parameters = { "body": body, "commit_id": commit_id._identity, "path": path, "position": position, } headers, data = self._requester.requestJsonAndCheck( "POST", self.url + "/comments", 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, unicode)), body post_parameters = { "body": body, } headers, data = self._requester.requestJsonAndCheck( "POST", 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=None, 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 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 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", self.url + "/reviews", input=post_parameters ) self._useAttributes(data) 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, unicode)) for element in reviewers), reviewers post_parameters["reviewers"] = reviewers if team_reviewers is not github.GithubObject.NotSet: assert all(isinstance(element, (str, unicode)) for element in team_reviewers), team_reviewers post_parameters["team_reviewers"] = team_reviewers headers, data = self._requester.requestJsonAndCheck( "POST", 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, unicode)) for element in reviewers), reviewers post_parameters["reviewers"] = reviewers if team_reviewers is not github.GithubObject.NotSet: assert all(isinstance(element, (str, unicode)) for element in team_reviewers), team_reviewers post_parameters["team_reviewers"] = team_reviewers headers, data = self._requester.requestJsonAndCheck( "DELETE", 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): """ :calls: `PATCH /repos/:owner/:repo/pulls/:number `_ :param title: string :param body: string :param state: string :param base: string :rtype: None """ assert title is github.GithubObject.NotSet or isinstance(title, (str, unicode)), title assert body is github.GithubObject.NotSet or isinstance(body, (str, unicode)), body assert state is github.GithubObject.NotSet or isinstance(state, (str, unicode)), state assert base is github.GithubObject.NotSet or isinstance(base, (str, unicode)), base 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 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, long)), id headers, data = self._requester.requestJsonAndCheck( "GET", self._parentUrl(self.url) + "/comments/" + str(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, 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, long)), id return github.PaginatedList.PaginatedList( github.PullRequestComment.PullRequestComment, self._requester, self.url + "/reviews/" + str(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, 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, 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, long)), id headers, data = self._requester.requestJsonAndCheck( "GET", self._parentUrl(self.issue_url) + "/comments/" + str(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, self.issue_url + "/comments", None ) 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, long)), id headers, data = self._requester.requestJsonAndCheck( "GET", self.url + "/reviews/" + str(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, 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, self.url + "/requested_reviewers", None, list_item='users' ), github.PaginatedList.PaginatedList( github.Team.Team, self._requester, 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, 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, unicode)) 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", 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", 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, unicode)), label if isinstance(label, github.Label.Label): label = label._identity else: label = urllib.quote(label) headers, data = self._requester.requestJsonAndCheck( "DELETE", 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, unicode)) 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", 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", 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 :rtype: :class:`github.PullRequestMergeStatus.PullRequestMergeStatus` """ assert commit_message is github.GithubObject.NotSet or isinstance(commit_message, (str, unicode)), commit_message assert commit_title is github.GithubObject.NotSet or isinstance(commit_title, (str, unicode)), commit_title assert merge_method is github.GithubObject.NotSet or isinstance(merge_method, (str, unicode)), merge_method assert sha is github.GithubObject.NotSet or isinstance(sha, (str, unicode)), 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", self.url + "/merge", input=post_parameters ) return github.PullRequestMergeStatus.PullRequestMergeStatus(self._requester, headers, data, completed=True) 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._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._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._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 "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 "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 "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"]) PyGithub-1.43.7/github/GitTree.py0000664000372000037200000000750113455250617013473 0ustar # -*- coding: utf-8 -*- ############################ 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://developer.github.com/v3/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"]) PyGithub-1.43.7/github/Comparison.py0000664000372000037200000001645513455250617014252 0ustar # -*- coding: utf-8 -*- ############################ 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 import github.Commit import github.File 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"]) PyGithub-1.43.7/github/HookDescription.py0000664000372000037200000000762513455250617015243 0ustar # -*- coding: utf-8 -*- ############################ 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"]) PyGithub-1.43.7/github/HookResponse.py0000664000372000037200000000676713455250617014564 0ustar # -*- coding: utf-8 -*- ############################ 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"]) PyGithub-1.43.7/github/Plan.py0000664000372000037200000000752013455250617013023 0ustar # -*- coding: utf-8 -*- ############################ 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 def _initAttributes(self): self._collaborators = github.GithubObject.NotSet self._name = github.GithubObject.NotSet self._private_repos = github.GithubObject.NotSet self._space = 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"]) PyGithub-1.43.7/github/Invitation.py0000664000372000037200000001053013455250617014250 0ustar # -*- coding: utf-8 -*- ############################ 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 urllib import github.GithubObject class Invitation(github.GithubObject.CompletableGithubObject): """ This class represents repository invitations. The reference can be found here https://developer.github.com/v3/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 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._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._assignee = self._makeClassAttribute(github.Repository.Repository, attributes["repository"]) if "created_at" in attributes: # pragma no branch self._closed_at = self._makeDatetimeAttribute(attributes["created_at"]) 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"]) PyGithub-1.43.7/github/SourceImport.py0000664000372000037200000001567313455250617014574 0ustar # -*- coding: utf-8 -*- ############################ 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 class SourceImport(github.GithubObject.CompletableGithubObject): """ This class represents SourceImports. The reference can be found here https://developer.github.com/v3/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 _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"]) PyGithub-1.43.7/github/Event.py0000664000372000037200000001240113455250617013204 0ustar # -*- coding: utf-8 -*- ############################ 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.Organization import github.Repository import github.NamedUser class Event(github.GithubObject.NonCompletableGithubObject): """ This class represents Events. The reference can be found here http://developer.github.com/v3/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"]) PyGithub-1.43.7/github/File.py0000664000372000037200000001420513455250617013006 0ustar # -*- coding: utf-8 -*- ############################ 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"]) PyGithub-1.43.7/github/StatsCodeFrequency.py0000775000372000037200000000611613455250617015707 0ustar # -*- coding: utf-8 -*- ############################ 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://developer.github.com/v3/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]) PyGithub-1.43.7/github/BranchProtection.py0000664000372000037200000001244413455250617015376 0ustar # -*- coding: utf-8 -*- ############################ 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://developer.github.com/v3/repos/branches/#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"] PyGithub-1.43.7/github/Milestone.py0000664000372000037200000002277013455250617014074 0ustar # -*- coding: utf-8 -*- ############################ 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.PaginatedList import github.NamedUser import github.Label class Milestone(github.GithubObject.CompletableGithubObject): """ This class represents Milestones. The reference can be found here http://developer.github.com/v3/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, unicode)), title assert state is github.GithubObject.NotSet or isinstance(state, (str, unicode)), state assert description is github.GithubObject.NotSet or isinstance(description, (str, unicode)), 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, 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"]) PyGithub-1.43.7/github/InputFileContent.py0000664000372000037200000000563113455250617015364 0ustar # -*- coding: utf-8 -*- ############################ 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(object): """ This class represents InputFileContents """ def __init__(self, content, new_name=github.GithubObject.NotSet): """ :param content: string :param new_name: string """ assert isinstance(content, (str, unicode)), content assert new_name is github.GithubObject.NotSet or isinstance(new_name, (str, unicode)), 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 PyGithub-1.43.7/github/GitBlob.py0000664000372000037200000001050613455250617013451 0ustar # -*- coding: utf-8 -*- ############################ 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://developer.github.com/v3/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"]) PyGithub-1.43.7/github/Referrer.py0000664000372000037200000000663613455250617013714 0ustar # -*- coding: utf-8 -*- ############################ 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://developer.github.com/v3/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"]) PyGithub-1.43.7/COPYING.LESSER0000664000372000037200000001674313455250617012333 0ustar 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. PyGithub-1.43.7/MANIFEST.in0000664000372000037200000000004313455250617012024 0ustar include COPYING* include README.md PyGithub-1.43.7/PKG-INFO0000664000372000037200000000320513455250700011357 0ustar Metadata-Version: 2.1 Name: PyGithub Version: 1.43.7 Summary: Use the full Github API v3 Home-page: http://pygithub.readthedocs.io/en/latest/ Author: Vincent Jacques Author-email: vincent@vincent-jacques.net License: UNKNOWN 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 :: 2 Classifier: Programming Language :: Python :: 2.7 Classifier: Programming Language :: Python :: 3 Classifier: Programming Language :: Python :: 3.5 Classifier: Programming Language :: Python :: 3.6 Classifier: Programming Language :: Python :: 3.7 Classifier: Topic :: Software Development Requires-Python: >=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.* Provides-Extra: integrations