1.0
This commit is contained in:
parent
829f991f35
commit
8af59a8246
1
Lib/site-packages/Markdown-3.6.dist-info/INSTALLER
Normal file
1
Lib/site-packages/Markdown-3.6.dist-info/INSTALLER
Normal file
@ -0,0 +1 @@
|
||||
pip
|
30
Lib/site-packages/Markdown-3.6.dist-info/LICENSE.md
Normal file
30
Lib/site-packages/Markdown-3.6.dist-info/LICENSE.md
Normal file
@ -0,0 +1,30 @@
|
||||
BSD 3-Clause License
|
||||
|
||||
Copyright 2007, 2008 The Python Markdown Project (v. 1.7 and later)
|
||||
Copyright 2004, 2005, 2006 Yuri Takhteyev (v. 0.2-1.6b)
|
||||
Copyright 2004 Manfred Stienstra (the original version)
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice, this
|
||||
list of conditions and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
|
||||
3. Neither the name of the copyright holder nor the names of its
|
||||
contributors may be used to endorse or promote products derived from
|
||||
this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
146
Lib/site-packages/Markdown-3.6.dist-info/METADATA
Normal file
146
Lib/site-packages/Markdown-3.6.dist-info/METADATA
Normal file
@ -0,0 +1,146 @@
|
||||
Metadata-Version: 2.1
|
||||
Name: Markdown
|
||||
Version: 3.6
|
||||
Summary: Python implementation of John Gruber's Markdown.
|
||||
Author: Manfred Stienstra, Yuri Takhteyev
|
||||
Author-email: Waylan limberg <python.markdown@gmail.com>
|
||||
Maintainer: Isaac Muse
|
||||
Maintainer-email: Waylan Limberg <python.markdown@gmail.com>
|
||||
License: BSD 3-Clause License
|
||||
|
||||
Copyright 2007, 2008 The Python Markdown Project (v. 1.7 and later)
|
||||
Copyright 2004, 2005, 2006 Yuri Takhteyev (v. 0.2-1.6b)
|
||||
Copyright 2004 Manfred Stienstra (the original version)
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice, this
|
||||
list of conditions and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
|
||||
3. Neither the name of the copyright holder nor the names of its
|
||||
contributors may be used to endorse or promote products derived from
|
||||
this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
Project-URL: Homepage, https://Python-Markdown.github.io/
|
||||
Project-URL: Documentation, https://Python-Markdown.github.io/
|
||||
Project-URL: Repository, https://github.com/Python-Markdown/markdown
|
||||
Project-URL: Issue Tracker, https://github.com/Python-Markdown/markdown/issues
|
||||
Project-URL: Changelog, https://python-markdown.github.io/changelog/
|
||||
Keywords: markdown,markdown-parser,python-markdown,markdown-to-html
|
||||
Classifier: Development Status :: 5 - Production/Stable
|
||||
Classifier: License :: OSI Approved :: BSD License
|
||||
Classifier: Operating System :: OS Independent
|
||||
Classifier: Programming Language :: Python
|
||||
Classifier: Programming Language :: Python :: 3
|
||||
Classifier: Programming Language :: Python :: 3.8
|
||||
Classifier: Programming Language :: Python :: 3.9
|
||||
Classifier: Programming Language :: Python :: 3.10
|
||||
Classifier: Programming Language :: Python :: 3.11
|
||||
Classifier: Programming Language :: Python :: 3.12
|
||||
Classifier: Programming Language :: Python :: 3 :: Only
|
||||
Classifier: Programming Language :: Python :: Implementation :: CPython
|
||||
Classifier: Programming Language :: Python :: Implementation :: PyPy
|
||||
Classifier: Topic :: Communications :: Email :: Filters
|
||||
Classifier: Topic :: Internet :: WWW/HTTP :: Dynamic Content :: CGI Tools/Libraries
|
||||
Classifier: Topic :: Internet :: WWW/HTTP :: Site Management
|
||||
Classifier: Topic :: Software Development :: Documentation
|
||||
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
||||
Classifier: Topic :: Text Processing :: Filters
|
||||
Classifier: Topic :: Text Processing :: Markup :: HTML
|
||||
Classifier: Topic :: Text Processing :: Markup :: Markdown
|
||||
Requires-Python: >=3.8
|
||||
Description-Content-Type: text/markdown
|
||||
License-File: LICENSE.md
|
||||
Requires-Dist: importlib-metadata >=4.4 ; python_version < "3.10"
|
||||
Provides-Extra: docs
|
||||
Requires-Dist: mkdocs >=1.5 ; extra == 'docs'
|
||||
Requires-Dist: mkdocs-nature >=0.6 ; extra == 'docs'
|
||||
Requires-Dist: mdx-gh-links >=0.2 ; extra == 'docs'
|
||||
Requires-Dist: mkdocstrings[python] ; extra == 'docs'
|
||||
Requires-Dist: mkdocs-gen-files ; extra == 'docs'
|
||||
Requires-Dist: mkdocs-section-index ; extra == 'docs'
|
||||
Requires-Dist: mkdocs-literate-nav ; extra == 'docs'
|
||||
Provides-Extra: testing
|
||||
Requires-Dist: coverage ; extra == 'testing'
|
||||
Requires-Dist: pyyaml ; extra == 'testing'
|
||||
|
||||
[Python-Markdown][]
|
||||
===================
|
||||
|
||||
[![Build Status][build-button]][build]
|
||||
[![Coverage Status][codecov-button]][codecov]
|
||||
[![Latest Version][mdversion-button]][md-pypi]
|
||||
[![Python Versions][pyversion-button]][md-pypi]
|
||||
[![BSD License][bsdlicense-button]][bsdlicense]
|
||||
[![Code of Conduct][codeofconduct-button]][Code of Conduct]
|
||||
|
||||
[build-button]: https://github.com/Python-Markdown/markdown/workflows/CI/badge.svg?event=push
|
||||
[build]: https://github.com/Python-Markdown/markdown/actions?query=workflow%3ACI+event%3Apush
|
||||
[codecov-button]: https://codecov.io/gh/Python-Markdown/markdown/branch/master/graph/badge.svg
|
||||
[codecov]: https://codecov.io/gh/Python-Markdown/markdown
|
||||
[mdversion-button]: https://img.shields.io/pypi/v/Markdown.svg
|
||||
[md-pypi]: https://pypi.org/project/Markdown/
|
||||
[pyversion-button]: https://img.shields.io/pypi/pyversions/Markdown.svg
|
||||
[bsdlicense-button]: https://img.shields.io/badge/license-BSD-yellow.svg
|
||||
[bsdlicense]: https://opensource.org/licenses/BSD-3-Clause
|
||||
[codeofconduct-button]: https://img.shields.io/badge/code%20of%20conduct-contributor%20covenant-green.svg?style=flat-square
|
||||
[Code of Conduct]: https://github.com/Python-Markdown/markdown/blob/master/CODE_OF_CONDUCT.md
|
||||
|
||||
This is a Python implementation of John Gruber's [Markdown][].
|
||||
It is almost completely compliant with the reference implementation,
|
||||
though there are a few known issues. See [Features][] for information
|
||||
on what exactly is supported and what is not. Additional features are
|
||||
supported by the [Available Extensions][].
|
||||
|
||||
[Python-Markdown]: https://Python-Markdown.github.io/
|
||||
[Markdown]: https://daringfireball.net/projects/markdown/
|
||||
[Features]: https://Python-Markdown.github.io#Features
|
||||
[Available Extensions]: https://Python-Markdown.github.io/extensions
|
||||
|
||||
Documentation
|
||||
-------------
|
||||
|
||||
```bash
|
||||
pip install markdown
|
||||
```
|
||||
```python
|
||||
import markdown
|
||||
html = markdown.markdown(your_text_string)
|
||||
```
|
||||
|
||||
For more advanced [installation] and [usage] documentation, see the `docs/` directory
|
||||
of the distribution or the project website at <https://Python-Markdown.github.io/>.
|
||||
|
||||
[installation]: https://python-markdown.github.io/install/
|
||||
[usage]: https://python-markdown.github.io/reference/
|
||||
|
||||
See the change log at <https://python-markdown.github.io/changelog/>.
|
||||
|
||||
Support
|
||||
-------
|
||||
|
||||
You may report bugs, ask for help, and discuss various other issues on the [bug tracker][].
|
||||
|
||||
[bug tracker]: https://github.com/Python-Markdown/markdown/issues
|
||||
|
||||
Code of Conduct
|
||||
---------------
|
||||
|
||||
Everyone interacting in the Python-Markdown project's code bases, issue trackers,
|
||||
and mailing lists is expected to follow the [Code of Conduct].
|
74
Lib/site-packages/Markdown-3.6.dist-info/RECORD
Normal file
74
Lib/site-packages/Markdown-3.6.dist-info/RECORD
Normal file
@ -0,0 +1,74 @@
|
||||
../../Scripts/markdown_py.exe,sha256=oyzRuTfpmvyLeljsFBt_JQ9l3i5j64Gl5yrqOP4ZSw0,108386
|
||||
Markdown-3.6.dist-info/INSTALLER,sha256=zuuue4knoyJ-UwPPXg8fezS7VCrXJQrAP7zeNuwvFQg,4
|
||||
Markdown-3.6.dist-info/LICENSE.md,sha256=e6TrbRCzKy0R3OE4ITQDUc27swuozMZ4Qdsv_Ybnmso,1650
|
||||
Markdown-3.6.dist-info/METADATA,sha256=8_ETqzTxcOemQXj7ujUabMFcDBDGtsRrccFDr1-XWvc,7040
|
||||
Markdown-3.6.dist-info/RECORD,,
|
||||
Markdown-3.6.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
|
||||
Markdown-3.6.dist-info/entry_points.txt,sha256=lMEyiiA_ZZyfPCBlDviBl-SiU0cfoeuEKpwxw361sKQ,1102
|
||||
Markdown-3.6.dist-info/top_level.txt,sha256=IAxs8x618RXoH1uCqeLLxXsDefJvE_mIibr_M4sOlyk,9
|
||||
markdown/__init__.py,sha256=dfzwwdpG9L8QLEPBpLFPIHx_BN056aZXp9xZifTxYIU,1777
|
||||
markdown/__main__.py,sha256=innFBxRqwPBNxG1zhKktJji4bnRKtVyYYd30ID13Tcw,5859
|
||||
markdown/__meta__.py,sha256=DqtqnYYLznrkvI1G4JalBc4WpgOp48naNoG9zlMWZas,1712
|
||||
markdown/__pycache__/__init__.cpython-311.pyc,,
|
||||
markdown/__pycache__/__main__.cpython-311.pyc,,
|
||||
markdown/__pycache__/__meta__.cpython-311.pyc,,
|
||||
markdown/__pycache__/blockparser.cpython-311.pyc,,
|
||||
markdown/__pycache__/blockprocessors.cpython-311.pyc,,
|
||||
markdown/__pycache__/core.cpython-311.pyc,,
|
||||
markdown/__pycache__/htmlparser.cpython-311.pyc,,
|
||||
markdown/__pycache__/inlinepatterns.cpython-311.pyc,,
|
||||
markdown/__pycache__/postprocessors.cpython-311.pyc,,
|
||||
markdown/__pycache__/preprocessors.cpython-311.pyc,,
|
||||
markdown/__pycache__/serializers.cpython-311.pyc,,
|
||||
markdown/__pycache__/test_tools.cpython-311.pyc,,
|
||||
markdown/__pycache__/treeprocessors.cpython-311.pyc,,
|
||||
markdown/__pycache__/util.cpython-311.pyc,,
|
||||
markdown/blockparser.py,sha256=j4CQImVpiq7g9pz8wCxvzT61X_T2iSAjXupHJk8P3eA,5728
|
||||
markdown/blockprocessors.py,sha256=koY5rq8DixzBCHcquvZJp6x2JYyBGjrwxMWNZhd6D2U,27013
|
||||
markdown/core.py,sha256=DyyzDsmd-KcuEp8ZWUKJAeUCt7B7G3J3NeqZqp3LphI,21335
|
||||
markdown/extensions/__init__.py,sha256=9z1khsdKCVrmrJ_2GfxtPAdjD3FyMe5vhC7wmM4O9m0,4822
|
||||
markdown/extensions/__pycache__/__init__.cpython-311.pyc,,
|
||||
markdown/extensions/__pycache__/abbr.cpython-311.pyc,,
|
||||
markdown/extensions/__pycache__/admonition.cpython-311.pyc,,
|
||||
markdown/extensions/__pycache__/attr_list.cpython-311.pyc,,
|
||||
markdown/extensions/__pycache__/codehilite.cpython-311.pyc,,
|
||||
markdown/extensions/__pycache__/def_list.cpython-311.pyc,,
|
||||
markdown/extensions/__pycache__/extra.cpython-311.pyc,,
|
||||
markdown/extensions/__pycache__/fenced_code.cpython-311.pyc,,
|
||||
markdown/extensions/__pycache__/footnotes.cpython-311.pyc,,
|
||||
markdown/extensions/__pycache__/legacy_attrs.cpython-311.pyc,,
|
||||
markdown/extensions/__pycache__/legacy_em.cpython-311.pyc,,
|
||||
markdown/extensions/__pycache__/md_in_html.cpython-311.pyc,,
|
||||
markdown/extensions/__pycache__/meta.cpython-311.pyc,,
|
||||
markdown/extensions/__pycache__/nl2br.cpython-311.pyc,,
|
||||
markdown/extensions/__pycache__/sane_lists.cpython-311.pyc,,
|
||||
markdown/extensions/__pycache__/smarty.cpython-311.pyc,,
|
||||
markdown/extensions/__pycache__/tables.cpython-311.pyc,,
|
||||
markdown/extensions/__pycache__/toc.cpython-311.pyc,,
|
||||
markdown/extensions/__pycache__/wikilinks.cpython-311.pyc,,
|
||||
markdown/extensions/abbr.py,sha256=JqFOfU7JlhIFY06-nZnSU0wDqneFKKWMe95eXB-iLtc,3250
|
||||
markdown/extensions/admonition.py,sha256=Hqcn3I8JG0i-OPWdoqI189TmlQRgH6bs5PmpCANyLlg,6547
|
||||
markdown/extensions/attr_list.py,sha256=t3PrgAr5Ebldnq3nJNbteBt79bN0ccXS5RemmQfUZ9g,7820
|
||||
markdown/extensions/codehilite.py,sha256=ChlmpM6S--j-UK7t82859UpYjm8EftdiLqmgDnknyes,13503
|
||||
markdown/extensions/def_list.py,sha256=J3NVa6CllfZPsboJCEycPyRhtjBHnOn8ET6omEvVlDo,4029
|
||||
markdown/extensions/extra.py,sha256=1vleT284kued4HQBtF83IjSumJVo0q3ng6MjTkVNfNQ,2163
|
||||
markdown/extensions/fenced_code.py,sha256=-fYSmRZ9DTYQ8HO9b_78i47kVyVu6mcVJlqVTMdzvo4,8300
|
||||
markdown/extensions/footnotes.py,sha256=bRFlmIBOKDI5efG1jZfDkMoV2osfqWip1rN1j2P-mMg,16710
|
||||
markdown/extensions/legacy_attrs.py,sha256=oWcyNrfP0F6zsBoBOaD5NiwrJyy4kCpgQLl12HA7JGU,2788
|
||||
markdown/extensions/legacy_em.py,sha256=-Z_w4PEGSS-Xg-2-BtGAnXwwy5g5GDgv2tngASnPgxg,1693
|
||||
markdown/extensions/md_in_html.py,sha256=y4HEWEnkvfih22fojcaJeAmjx1AtF8N-a_jb6IDFfts,16546
|
||||
markdown/extensions/meta.py,sha256=v_4Uq7nbcQ76V1YAvqVPiNLbRLIQHJsnfsk-tN70RmY,2600
|
||||
markdown/extensions/nl2br.py,sha256=9KKcrPs62c3ENNnmOJZs0rrXXqUtTCfd43j1_OPpmgU,1090
|
||||
markdown/extensions/sane_lists.py,sha256=ogAKcm7gEpcXV7fSTf8JZH5YdKAssPCEOUzdGM3C9Tw,2150
|
||||
markdown/extensions/smarty.py,sha256=yqT0OiE2AqYrqqZtcUFFmp2eJsQHomiKzgyG2JFb9rI,11048
|
||||
markdown/extensions/tables.py,sha256=oTDvGD1qp9xjVWPGYNgDBWe9NqsX5gS6UU5wUsQ1bC8,8741
|
||||
markdown/extensions/toc.py,sha256=PGg-EqbBubm3n0b633r8Xa9kc6JIdbo20HGAOZ6GEl8,18322
|
||||
markdown/extensions/wikilinks.py,sha256=j7D2sozica6sqXOUa_GuAXqIzxp-7Hi60bfXymiuma8,3285
|
||||
markdown/htmlparser.py,sha256=dEr6IE7i9b6Tc1gdCLZGeWw6g6-E-jK1Z4KPj8yGk8Q,14332
|
||||
markdown/inlinepatterns.py,sha256=7_HF5nTOyQag_CyBgU4wwmuI6aMjtadvGadyS9IP21w,38256
|
||||
markdown/postprocessors.py,sha256=eYi6eW0mGudmWpmsW45hduLwX66Zr8Bf44WyU9vKp-I,4807
|
||||
markdown/preprocessors.py,sha256=pq5NnHKkOSVQeIo-ajC-Yt44kvyMV97D04FBOQXctJM,3224
|
||||
markdown/serializers.py,sha256=YtAFYQoOdp_TAmYGow6nBo0eB6I-Sl4PTLdLDfQJHwQ,7174
|
||||
markdown/test_tools.py,sha256=MtN4cf3ZPDtb83wXLTol-3q3aIGRIkJ2zWr6fd-RgVE,8662
|
||||
markdown/treeprocessors.py,sha256=o4dnoZZsIeVV8qR45Njr8XgwKleWYDS5pv8dKQhJvv8,17651
|
||||
markdown/util.py,sha256=vJ1E0xjMzDAlTqLUSJWgdEvxdQfLXDEYUssOQMw9kPQ,13929
|
5
Lib/site-packages/Markdown-3.6.dist-info/WHEEL
Normal file
5
Lib/site-packages/Markdown-3.6.dist-info/WHEEL
Normal file
@ -0,0 +1,5 @@
|
||||
Wheel-Version: 1.0
|
||||
Generator: bdist_wheel (0.43.0)
|
||||
Root-Is-Purelib: true
|
||||
Tag: py3-none-any
|
||||
|
22
Lib/site-packages/Markdown-3.6.dist-info/entry_points.txt
Normal file
22
Lib/site-packages/Markdown-3.6.dist-info/entry_points.txt
Normal file
@ -0,0 +1,22 @@
|
||||
[console_scripts]
|
||||
markdown_py = markdown.__main__:run
|
||||
|
||||
[markdown.extensions]
|
||||
abbr = markdown.extensions.abbr:AbbrExtension
|
||||
admonition = markdown.extensions.admonition:AdmonitionExtension
|
||||
attr_list = markdown.extensions.attr_list:AttrListExtension
|
||||
codehilite = markdown.extensions.codehilite:CodeHiliteExtension
|
||||
def_list = markdown.extensions.def_list:DefListExtension
|
||||
extra = markdown.extensions.extra:ExtraExtension
|
||||
fenced_code = markdown.extensions.fenced_code:FencedCodeExtension
|
||||
footnotes = markdown.extensions.footnotes:FootnoteExtension
|
||||
legacy_attrs = markdown.extensions.legacy_attrs:LegacyAttrExtension
|
||||
legacy_em = markdown.extensions.legacy_em:LegacyEmExtension
|
||||
md_in_html = markdown.extensions.md_in_html:MarkdownInHtmlExtension
|
||||
meta = markdown.extensions.meta:MetaExtension
|
||||
nl2br = markdown.extensions.nl2br:Nl2BrExtension
|
||||
sane_lists = markdown.extensions.sane_lists:SaneListExtension
|
||||
smarty = markdown.extensions.smarty:SmartyExtension
|
||||
tables = markdown.extensions.tables:TableExtension
|
||||
toc = markdown.extensions.toc:TocExtension
|
||||
wikilinks = markdown.extensions.wikilinks:WikiLinkExtension
|
1
Lib/site-packages/Markdown-3.6.dist-info/top_level.txt
Normal file
1
Lib/site-packages/Markdown-3.6.dist-info/top_level.txt
Normal file
@ -0,0 +1 @@
|
||||
markdown
|
1
Lib/site-packages/MarkupSafe-2.1.5.dist-info/INSTALLER
Normal file
1
Lib/site-packages/MarkupSafe-2.1.5.dist-info/INSTALLER
Normal file
@ -0,0 +1 @@
|
||||
pip
|
28
Lib/site-packages/MarkupSafe-2.1.5.dist-info/LICENSE.rst
Normal file
28
Lib/site-packages/MarkupSafe-2.1.5.dist-info/LICENSE.rst
Normal file
@ -0,0 +1,28 @@
|
||||
Copyright 2010 Pallets
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are
|
||||
met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
|
||||
3. Neither the name of the copyright holder nor the names of its
|
||||
contributors may be used to endorse or promote products derived from
|
||||
this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
|
||||
PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
|
||||
TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
93
Lib/site-packages/MarkupSafe-2.1.5.dist-info/METADATA
Normal file
93
Lib/site-packages/MarkupSafe-2.1.5.dist-info/METADATA
Normal file
@ -0,0 +1,93 @@
|
||||
Metadata-Version: 2.1
|
||||
Name: MarkupSafe
|
||||
Version: 2.1.5
|
||||
Summary: Safely add untrusted strings to HTML/XML markup.
|
||||
Home-page: https://palletsprojects.com/p/markupsafe/
|
||||
Maintainer: Pallets
|
||||
Maintainer-email: contact@palletsprojects.com
|
||||
License: BSD-3-Clause
|
||||
Project-URL: Donate, https://palletsprojects.com/donate
|
||||
Project-URL: Documentation, https://markupsafe.palletsprojects.com/
|
||||
Project-URL: Changes, https://markupsafe.palletsprojects.com/changes/
|
||||
Project-URL: Source Code, https://github.com/pallets/markupsafe/
|
||||
Project-URL: Issue Tracker, https://github.com/pallets/markupsafe/issues/
|
||||
Project-URL: Chat, https://discord.gg/pallets
|
||||
Classifier: Development Status :: 5 - Production/Stable
|
||||
Classifier: Environment :: Web Environment
|
||||
Classifier: Intended Audience :: Developers
|
||||
Classifier: License :: OSI Approved :: BSD License
|
||||
Classifier: Operating System :: OS Independent
|
||||
Classifier: Programming Language :: Python
|
||||
Classifier: Topic :: Internet :: WWW/HTTP :: Dynamic Content
|
||||
Classifier: Topic :: Text Processing :: Markup :: HTML
|
||||
Requires-Python: >=3.7
|
||||
Description-Content-Type: text/x-rst
|
||||
License-File: LICENSE.rst
|
||||
|
||||
MarkupSafe
|
||||
==========
|
||||
|
||||
MarkupSafe implements a text object that escapes characters so it is
|
||||
safe to use in HTML and XML. Characters that have special meanings are
|
||||
replaced so that they display as the actual characters. This mitigates
|
||||
injection attacks, meaning untrusted user input can safely be displayed
|
||||
on a page.
|
||||
|
||||
|
||||
Installing
|
||||
----------
|
||||
|
||||
Install and update using `pip`_:
|
||||
|
||||
.. code-block:: text
|
||||
|
||||
pip install -U MarkupSafe
|
||||
|
||||
.. _pip: https://pip.pypa.io/en/stable/getting-started/
|
||||
|
||||
|
||||
Examples
|
||||
--------
|
||||
|
||||
.. code-block:: pycon
|
||||
|
||||
>>> from markupsafe import Markup, escape
|
||||
|
||||
>>> # escape replaces special characters and wraps in Markup
|
||||
>>> escape("<script>alert(document.cookie);</script>")
|
||||
Markup('<script>alert(document.cookie);</script>')
|
||||
|
||||
>>> # wrap in Markup to mark text "safe" and prevent escaping
|
||||
>>> Markup("<strong>Hello</strong>")
|
||||
Markup('<strong>hello</strong>')
|
||||
|
||||
>>> escape(Markup("<strong>Hello</strong>"))
|
||||
Markup('<strong>hello</strong>')
|
||||
|
||||
>>> # Markup is a str subclass
|
||||
>>> # methods and operators escape their arguments
|
||||
>>> template = Markup("Hello <em>{name}</em>")
|
||||
>>> template.format(name='"World"')
|
||||
Markup('Hello <em>"World"</em>')
|
||||
|
||||
|
||||
Donate
|
||||
------
|
||||
|
||||
The Pallets organization develops and supports MarkupSafe and other
|
||||
popular packages. In order to grow the community of contributors and
|
||||
users, and allow the maintainers to devote more time to the projects,
|
||||
`please donate today`_.
|
||||
|
||||
.. _please donate today: https://palletsprojects.com/donate
|
||||
|
||||
|
||||
Links
|
||||
-----
|
||||
|
||||
- Documentation: https://markupsafe.palletsprojects.com/
|
||||
- Changes: https://markupsafe.palletsprojects.com/changes/
|
||||
- PyPI Releases: https://pypi.org/project/MarkupSafe/
|
||||
- Source Code: https://github.com/pallets/markupsafe/
|
||||
- Issue Tracker: https://github.com/pallets/markupsafe/issues/
|
||||
- Chat: https://discord.gg/pallets
|
14
Lib/site-packages/MarkupSafe-2.1.5.dist-info/RECORD
Normal file
14
Lib/site-packages/MarkupSafe-2.1.5.dist-info/RECORD
Normal file
@ -0,0 +1,14 @@
|
||||
MarkupSafe-2.1.5.dist-info/INSTALLER,sha256=zuuue4knoyJ-UwPPXg8fezS7VCrXJQrAP7zeNuwvFQg,4
|
||||
MarkupSafe-2.1.5.dist-info/LICENSE.rst,sha256=RjHsDbX9kKVH4zaBcmTGeYIUM4FG-KyUtKV_lu6MnsQ,1503
|
||||
MarkupSafe-2.1.5.dist-info/METADATA,sha256=icNlaniV7YIQZ1BScCVqNaRtm7MAgfw8d3OBmoSVyAY,3096
|
||||
MarkupSafe-2.1.5.dist-info/RECORD,,
|
||||
MarkupSafe-2.1.5.dist-info/WHEEL,sha256=ircjsfhzblqgSzO8ow7-0pXK-RVqDqNRGQ8F650AUNM,102
|
||||
MarkupSafe-2.1.5.dist-info/top_level.txt,sha256=qy0Plje5IJuvsCBjejJyhDCjEAdcDLK_2agVcex8Z6U,11
|
||||
markupsafe/__init__.py,sha256=m1ysNeqf55zbEoJtaovca40ivrkEFolPlw5bGoC5Gi4,11290
|
||||
markupsafe/__pycache__/__init__.cpython-311.pyc,,
|
||||
markupsafe/__pycache__/_native.cpython-311.pyc,,
|
||||
markupsafe/_native.py,sha256=_Q7UsXCOvgdonCgqG3l5asANI6eo50EKnDM-mlwEC5M,1776
|
||||
markupsafe/_speedups.c,sha256=n3jzzaJwXcoN8nTFyA53f3vSqsWK2vujI-v6QYifjhQ,7403
|
||||
markupsafe/_speedups.cp311-win_amd64.pyd,sha256=MEqnkyBOHmstwQr50hKitovHjrHhMJ0gYmya4Fu1DK0,15872
|
||||
markupsafe/_speedups.pyi,sha256=f5QtwIOP0eLrxh2v5p6SmaYmlcHIGIfmz0DovaqL0OU,238
|
||||
markupsafe/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
5
Lib/site-packages/MarkupSafe-2.1.5.dist-info/WHEEL
Normal file
5
Lib/site-packages/MarkupSafe-2.1.5.dist-info/WHEEL
Normal file
@ -0,0 +1,5 @@
|
||||
Wheel-Version: 1.0
|
||||
Generator: bdist_wheel (0.42.0)
|
||||
Root-Is-Purelib: false
|
||||
Tag: cp311-cp311-win_amd64
|
||||
|
@ -0,0 +1 @@
|
||||
markupsafe
|
BIN
Lib/site-packages/__pycache__/_virtualenv.cpython-311.pyc
Normal file
BIN
Lib/site-packages/__pycache__/_virtualenv.cpython-311.pyc
Normal file
Binary file not shown.
BIN
Lib/site-packages/__pycache__/six.cpython-311.pyc
Normal file
BIN
Lib/site-packages/__pycache__/six.cpython-311.pyc
Normal file
Binary file not shown.
BIN
Lib/site-packages/__pycache__/threadpoolctl.cpython-311.pyc
Normal file
BIN
Lib/site-packages/__pycache__/threadpoolctl.cpython-311.pyc
Normal file
Binary file not shown.
BIN
Lib/site-packages/__pycache__/typing_extensions.cpython-311.pyc
Normal file
BIN
Lib/site-packages/__pycache__/typing_extensions.cpython-311.pyc
Normal file
Binary file not shown.
222
Lib/site-packages/_distutils_hack/__init__.py
Normal file
222
Lib/site-packages/_distutils_hack/__init__.py
Normal file
@ -0,0 +1,222 @@
|
||||
# don't import any costly modules
|
||||
import sys
|
||||
import os
|
||||
|
||||
|
||||
is_pypy = '__pypy__' in sys.builtin_module_names
|
||||
|
||||
|
||||
def warn_distutils_present():
|
||||
if 'distutils' not in sys.modules:
|
||||
return
|
||||
if is_pypy and sys.version_info < (3, 7):
|
||||
# PyPy for 3.6 unconditionally imports distutils, so bypass the warning
|
||||
# https://foss.heptapod.net/pypy/pypy/-/blob/be829135bc0d758997b3566062999ee8b23872b4/lib-python/3/site.py#L250
|
||||
return
|
||||
import warnings
|
||||
|
||||
warnings.warn(
|
||||
"Distutils was imported before Setuptools, but importing Setuptools "
|
||||
"also replaces the `distutils` module in `sys.modules`. This may lead "
|
||||
"to undesirable behaviors or errors. To avoid these issues, avoid "
|
||||
"using distutils directly, ensure that setuptools is installed in the "
|
||||
"traditional way (e.g. not an editable install), and/or make sure "
|
||||
"that setuptools is always imported before distutils."
|
||||
)
|
||||
|
||||
|
||||
def clear_distutils():
|
||||
if 'distutils' not in sys.modules:
|
||||
return
|
||||
import warnings
|
||||
|
||||
warnings.warn("Setuptools is replacing distutils.")
|
||||
mods = [
|
||||
name
|
||||
for name in sys.modules
|
||||
if name == "distutils" or name.startswith("distutils.")
|
||||
]
|
||||
for name in mods:
|
||||
del sys.modules[name]
|
||||
|
||||
|
||||
def enabled():
|
||||
"""
|
||||
Allow selection of distutils by environment variable.
|
||||
"""
|
||||
which = os.environ.get('SETUPTOOLS_USE_DISTUTILS', 'local')
|
||||
return which == 'local'
|
||||
|
||||
|
||||
def ensure_local_distutils():
|
||||
import importlib
|
||||
|
||||
clear_distutils()
|
||||
|
||||
# With the DistutilsMetaFinder in place,
|
||||
# perform an import to cause distutils to be
|
||||
# loaded from setuptools._distutils. Ref #2906.
|
||||
with shim():
|
||||
importlib.import_module('distutils')
|
||||
|
||||
# check that submodules load as expected
|
||||
core = importlib.import_module('distutils.core')
|
||||
assert '_distutils' in core.__file__, core.__file__
|
||||
assert 'setuptools._distutils.log' not in sys.modules
|
||||
|
||||
|
||||
def do_override():
|
||||
"""
|
||||
Ensure that the local copy of distutils is preferred over stdlib.
|
||||
|
||||
See https://github.com/pypa/setuptools/issues/417#issuecomment-392298401
|
||||
for more motivation.
|
||||
"""
|
||||
if enabled():
|
||||
warn_distutils_present()
|
||||
ensure_local_distutils()
|
||||
|
||||
|
||||
class _TrivialRe:
|
||||
def __init__(self, *patterns):
|
||||
self._patterns = patterns
|
||||
|
||||
def match(self, string):
|
||||
return all(pat in string for pat in self._patterns)
|
||||
|
||||
|
||||
class DistutilsMetaFinder:
|
||||
def find_spec(self, fullname, path, target=None):
|
||||
# optimization: only consider top level modules and those
|
||||
# found in the CPython test suite.
|
||||
if path is not None and not fullname.startswith('test.'):
|
||||
return
|
||||
|
||||
method_name = 'spec_for_{fullname}'.format(**locals())
|
||||
method = getattr(self, method_name, lambda: None)
|
||||
return method()
|
||||
|
||||
def spec_for_distutils(self):
|
||||
if self.is_cpython():
|
||||
return
|
||||
|
||||
import importlib
|
||||
import importlib.abc
|
||||
import importlib.util
|
||||
|
||||
try:
|
||||
mod = importlib.import_module('setuptools._distutils')
|
||||
except Exception:
|
||||
# There are a couple of cases where setuptools._distutils
|
||||
# may not be present:
|
||||
# - An older Setuptools without a local distutils is
|
||||
# taking precedence. Ref #2957.
|
||||
# - Path manipulation during sitecustomize removes
|
||||
# setuptools from the path but only after the hook
|
||||
# has been loaded. Ref #2980.
|
||||
# In either case, fall back to stdlib behavior.
|
||||
return
|
||||
|
||||
class DistutilsLoader(importlib.abc.Loader):
|
||||
def create_module(self, spec):
|
||||
mod.__name__ = 'distutils'
|
||||
return mod
|
||||
|
||||
def exec_module(self, module):
|
||||
pass
|
||||
|
||||
return importlib.util.spec_from_loader(
|
||||
'distutils', DistutilsLoader(), origin=mod.__file__
|
||||
)
|
||||
|
||||
@staticmethod
|
||||
def is_cpython():
|
||||
"""
|
||||
Suppress supplying distutils for CPython (build and tests).
|
||||
Ref #2965 and #3007.
|
||||
"""
|
||||
return os.path.isfile('pybuilddir.txt')
|
||||
|
||||
def spec_for_pip(self):
|
||||
"""
|
||||
Ensure stdlib distutils when running under pip.
|
||||
See pypa/pip#8761 for rationale.
|
||||
"""
|
||||
if self.pip_imported_during_build():
|
||||
return
|
||||
clear_distutils()
|
||||
self.spec_for_distutils = lambda: None
|
||||
|
||||
@classmethod
|
||||
def pip_imported_during_build(cls):
|
||||
"""
|
||||
Detect if pip is being imported in a build script. Ref #2355.
|
||||
"""
|
||||
import traceback
|
||||
|
||||
return any(
|
||||
cls.frame_file_is_setup(frame) for frame, line in traceback.walk_stack(None)
|
||||
)
|
||||
|
||||
@staticmethod
|
||||
def frame_file_is_setup(frame):
|
||||
"""
|
||||
Return True if the indicated frame suggests a setup.py file.
|
||||
"""
|
||||
# some frames may not have __file__ (#2940)
|
||||
return frame.f_globals.get('__file__', '').endswith('setup.py')
|
||||
|
||||
def spec_for_sensitive_tests(self):
|
||||
"""
|
||||
Ensure stdlib distutils when running select tests under CPython.
|
||||
|
||||
python/cpython#91169
|
||||
"""
|
||||
clear_distutils()
|
||||
self.spec_for_distutils = lambda: None
|
||||
|
||||
sensitive_tests = (
|
||||
[
|
||||
'test.test_distutils',
|
||||
'test.test_peg_generator',
|
||||
'test.test_importlib',
|
||||
]
|
||||
if sys.version_info < (3, 10)
|
||||
else [
|
||||
'test.test_distutils',
|
||||
]
|
||||
)
|
||||
|
||||
|
||||
for name in DistutilsMetaFinder.sensitive_tests:
|
||||
setattr(
|
||||
DistutilsMetaFinder,
|
||||
f'spec_for_{name}',
|
||||
DistutilsMetaFinder.spec_for_sensitive_tests,
|
||||
)
|
||||
|
||||
|
||||
DISTUTILS_FINDER = DistutilsMetaFinder()
|
||||
|
||||
|
||||
def add_shim():
|
||||
DISTUTILS_FINDER in sys.meta_path or insert_shim()
|
||||
|
||||
|
||||
class shim:
|
||||
def __enter__(self):
|
||||
insert_shim()
|
||||
|
||||
def __exit__(self, exc, value, tb):
|
||||
remove_shim()
|
||||
|
||||
|
||||
def insert_shim():
|
||||
sys.meta_path.insert(0, DISTUTILS_FINDER)
|
||||
|
||||
|
||||
def remove_shim():
|
||||
try:
|
||||
sys.meta_path.remove(DISTUTILS_FINDER)
|
||||
except ValueError:
|
||||
pass
|
Binary file not shown.
Binary file not shown.
1
Lib/site-packages/_distutils_hack/override.py
Normal file
1
Lib/site-packages/_distutils_hack/override.py
Normal file
@ -0,0 +1 @@
|
||||
__import__('_distutils_hack').do_override()
|
1
Lib/site-packages/_virtualenv.pth
Normal file
1
Lib/site-packages/_virtualenv.pth
Normal file
@ -0,0 +1 @@
|
||||
import _virtualenv
|
130
Lib/site-packages/_virtualenv.py
Normal file
130
Lib/site-packages/_virtualenv.py
Normal file
@ -0,0 +1,130 @@
|
||||
"""Patches that are applied at runtime to the virtual environment"""
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import os
|
||||
import sys
|
||||
|
||||
VIRTUALENV_PATCH_FILE = os.path.join(__file__)
|
||||
|
||||
|
||||
def patch_dist(dist):
|
||||
"""
|
||||
Distutils allows user to configure some arguments via a configuration file:
|
||||
https://docs.python.org/3/install/index.html#distutils-configuration-files
|
||||
|
||||
Some of this arguments though don't make sense in context of the virtual environment files, let's fix them up.
|
||||
"""
|
||||
# we cannot allow some install config as that would get packages installed outside of the virtual environment
|
||||
old_parse_config_files = dist.Distribution.parse_config_files
|
||||
|
||||
def parse_config_files(self, *args, **kwargs):
|
||||
result = old_parse_config_files(self, *args, **kwargs)
|
||||
install = self.get_option_dict("install")
|
||||
|
||||
if "prefix" in install: # the prefix governs where to install the libraries
|
||||
install["prefix"] = VIRTUALENV_PATCH_FILE, os.path.abspath(sys.prefix)
|
||||
for base in ("purelib", "platlib", "headers", "scripts", "data"):
|
||||
key = "install_{}".format(base)
|
||||
if key in install: # do not allow global configs to hijack venv paths
|
||||
install.pop(key, None)
|
||||
return result
|
||||
|
||||
dist.Distribution.parse_config_files = parse_config_files
|
||||
|
||||
|
||||
# Import hook that patches some modules to ignore configuration values that break package installation in case
|
||||
# of virtual environments.
|
||||
_DISTUTILS_PATCH = "distutils.dist", "setuptools.dist"
|
||||
if sys.version_info > (3, 4):
|
||||
# https://docs.python.org/3/library/importlib.html#setting-up-an-importer
|
||||
|
||||
class _Finder:
|
||||
"""A meta path finder that allows patching the imported distutils modules"""
|
||||
|
||||
fullname = None
|
||||
|
||||
# lock[0] is threading.Lock(), but initialized lazily to avoid importing threading very early at startup,
|
||||
# because there are gevent-based applications that need to be first to import threading by themselves.
|
||||
# See https://github.com/pypa/virtualenv/issues/1895 for details.
|
||||
lock = []
|
||||
|
||||
def find_spec(self, fullname, path, target=None): # noqa: U100
|
||||
if fullname in _DISTUTILS_PATCH and self.fullname is None:
|
||||
# initialize lock[0] lazily
|
||||
if len(self.lock) == 0:
|
||||
import threading
|
||||
|
||||
lock = threading.Lock()
|
||||
# there is possibility that two threads T1 and T2 are simultaneously running into find_spec,
|
||||
# observing .lock as empty, and further going into hereby initialization. However due to the GIL,
|
||||
# list.append() operation is atomic and this way only one of the threads will "win" to put the lock
|
||||
# - that every thread will use - into .lock[0].
|
||||
# https://docs.python.org/3/faq/library.html#what-kinds-of-global-value-mutation-are-thread-safe
|
||||
self.lock.append(lock)
|
||||
|
||||
from functools import partial
|
||||
from importlib.util import find_spec
|
||||
|
||||
with self.lock[0]:
|
||||
self.fullname = fullname
|
||||
try:
|
||||
spec = find_spec(fullname, path)
|
||||
if spec is not None:
|
||||
# https://www.python.org/dev/peps/pep-0451/#how-loading-will-work
|
||||
is_new_api = hasattr(spec.loader, "exec_module")
|
||||
func_name = "exec_module" if is_new_api else "load_module"
|
||||
old = getattr(spec.loader, func_name)
|
||||
func = self.exec_module if is_new_api else self.load_module
|
||||
if old is not func:
|
||||
try:
|
||||
setattr(spec.loader, func_name, partial(func, old))
|
||||
except AttributeError:
|
||||
pass # C-Extension loaders are r/o such as zipimporter with <python 3.7
|
||||
return spec
|
||||
finally:
|
||||
self.fullname = None
|
||||
|
||||
@staticmethod
|
||||
def exec_module(old, module):
|
||||
old(module)
|
||||
if module.__name__ in _DISTUTILS_PATCH:
|
||||
patch_dist(module)
|
||||
|
||||
@staticmethod
|
||||
def load_module(old, name):
|
||||
module = old(name)
|
||||
if module.__name__ in _DISTUTILS_PATCH:
|
||||
patch_dist(module)
|
||||
return module
|
||||
|
||||
sys.meta_path.insert(0, _Finder())
|
||||
else:
|
||||
# https://www.python.org/dev/peps/pep-0302/
|
||||
from imp import find_module
|
||||
from pkgutil import ImpImporter, ImpLoader
|
||||
|
||||
class _VirtualenvImporter(object, ImpImporter):
|
||||
def __init__(self, path=None):
|
||||
object.__init__(self)
|
||||
ImpImporter.__init__(self, path)
|
||||
|
||||
def find_module(self, fullname, path=None):
|
||||
if fullname in _DISTUTILS_PATCH:
|
||||
try:
|
||||
return _VirtualenvLoader(fullname, *find_module(fullname.split(".")[-1], path))
|
||||
except ImportError:
|
||||
pass
|
||||
return None
|
||||
|
||||
class _VirtualenvLoader(object, ImpLoader):
|
||||
def __init__(self, fullname, file, filename, etc):
|
||||
object.__init__(self)
|
||||
ImpLoader.__init__(self, fullname, file, filename, etc)
|
||||
|
||||
def load_module(self, fullname):
|
||||
module = super(_VirtualenvLoader, self).load_module(fullname)
|
||||
patch_dist(module)
|
||||
module.__loader__ = None # distlib fallback
|
||||
return module
|
||||
|
||||
sys.meta_path.append(_VirtualenvImporter())
|
13
Lib/site-packages/absl/__init__.py
Normal file
13
Lib/site-packages/absl/__init__.py
Normal file
@ -0,0 +1,13 @@
|
||||
# Copyright 2017 The Abseil Authors.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
BIN
Lib/site-packages/absl/__pycache__/__init__.cpython-311.pyc
Normal file
BIN
Lib/site-packages/absl/__pycache__/__init__.cpython-311.pyc
Normal file
Binary file not shown.
BIN
Lib/site-packages/absl/__pycache__/app.cpython-311.pyc
Normal file
BIN
Lib/site-packages/absl/__pycache__/app.cpython-311.pyc
Normal file
Binary file not shown.
BIN
Lib/site-packages/absl/__pycache__/command_name.cpython-311.pyc
Normal file
BIN
Lib/site-packages/absl/__pycache__/command_name.cpython-311.pyc
Normal file
Binary file not shown.
480
Lib/site-packages/absl/app.py
Normal file
480
Lib/site-packages/absl/app.py
Normal file
@ -0,0 +1,480 @@
|
||||
# Copyright 2017 The Abseil Authors.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
"""Generic entry point for Abseil Python applications.
|
||||
|
||||
To use this module, define a ``main`` function with a single ``argv`` argument
|
||||
and call ``app.run(main)``. For example::
|
||||
|
||||
def main(argv):
|
||||
if len(argv) > 1:
|
||||
raise app.UsageError('Too many command-line arguments.')
|
||||
|
||||
if __name__ == '__main__':
|
||||
app.run(main)
|
||||
"""
|
||||
|
||||
import collections
|
||||
import errno
|
||||
import os
|
||||
import pdb
|
||||
import sys
|
||||
import textwrap
|
||||
import traceback
|
||||
|
||||
from absl import command_name
|
||||
from absl import flags
|
||||
from absl import logging
|
||||
|
||||
try:
|
||||
import faulthandler
|
||||
except ImportError:
|
||||
faulthandler = None
|
||||
|
||||
FLAGS = flags.FLAGS
|
||||
|
||||
flags.DEFINE_boolean('run_with_pdb', False, 'Set to true for PDB debug mode')
|
||||
flags.DEFINE_boolean('pdb_post_mortem', False,
|
||||
'Set to true to handle uncaught exceptions with PDB '
|
||||
'post mortem.')
|
||||
flags.DEFINE_alias('pdb', 'pdb_post_mortem')
|
||||
flags.DEFINE_boolean('run_with_profiling', False,
|
||||
'Set to true for profiling the script. '
|
||||
'Execution will be slower, and the output format might '
|
||||
'change over time.')
|
||||
flags.DEFINE_string('profile_file', None,
|
||||
'Dump profile information to a file (for python -m '
|
||||
'pstats). Implies --run_with_profiling.')
|
||||
flags.DEFINE_boolean('use_cprofile_for_profiling', True,
|
||||
'Use cProfile instead of the profile module for '
|
||||
'profiling. This has no effect unless '
|
||||
'--run_with_profiling is set.')
|
||||
flags.DEFINE_boolean('only_check_args', False,
|
||||
'Set to true to validate args and exit.',
|
||||
allow_hide_cpp=True)
|
||||
|
||||
|
||||
# If main() exits via an abnormal exception, call into these
|
||||
# handlers before exiting.
|
||||
EXCEPTION_HANDLERS = []
|
||||
|
||||
|
||||
class Error(Exception):
|
||||
pass
|
||||
|
||||
|
||||
class UsageError(Error):
|
||||
"""Exception raised when the arguments supplied by the user are invalid.
|
||||
|
||||
Raise this when the arguments supplied are invalid from the point of
|
||||
view of the application. For example when two mutually exclusive
|
||||
flags have been supplied or when there are not enough non-flag
|
||||
arguments. It is distinct from flags.Error which covers the lower
|
||||
level of parsing and validating individual flags.
|
||||
"""
|
||||
|
||||
def __init__(self, message, exitcode=1):
|
||||
super(UsageError, self).__init__(message)
|
||||
self.exitcode = exitcode
|
||||
|
||||
|
||||
class HelpFlag(flags.BooleanFlag):
|
||||
"""Special boolean flag that displays usage and raises SystemExit."""
|
||||
NAME = 'help'
|
||||
SHORT_NAME = '?'
|
||||
|
||||
def __init__(self):
|
||||
super(HelpFlag, self).__init__(
|
||||
self.NAME, False, 'show this help',
|
||||
short_name=self.SHORT_NAME, allow_hide_cpp=True)
|
||||
|
||||
def parse(self, arg):
|
||||
if self._parse(arg):
|
||||
usage(shorthelp=True, writeto_stdout=True)
|
||||
# Advertise --helpfull on stdout, since usage() was on stdout.
|
||||
print()
|
||||
print('Try --helpfull to get a list of all flags.')
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
class HelpshortFlag(HelpFlag):
|
||||
"""--helpshort is an alias for --help."""
|
||||
NAME = 'helpshort'
|
||||
SHORT_NAME = None
|
||||
|
||||
|
||||
class HelpfullFlag(flags.BooleanFlag):
|
||||
"""Display help for flags in the main module and all dependent modules."""
|
||||
|
||||
def __init__(self):
|
||||
super(HelpfullFlag, self).__init__(
|
||||
'helpfull', False, 'show full help', allow_hide_cpp=True)
|
||||
|
||||
def parse(self, arg):
|
||||
if self._parse(arg):
|
||||
usage(writeto_stdout=True)
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
class HelpXMLFlag(flags.BooleanFlag):
|
||||
"""Similar to HelpfullFlag, but generates output in XML format."""
|
||||
|
||||
def __init__(self):
|
||||
super(HelpXMLFlag, self).__init__(
|
||||
'helpxml', False, 'like --helpfull, but generates XML output',
|
||||
allow_hide_cpp=True)
|
||||
|
||||
def parse(self, arg):
|
||||
if self._parse(arg):
|
||||
flags.FLAGS.write_help_in_xml_format(sys.stdout)
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
def parse_flags_with_usage(args):
|
||||
"""Tries to parse the flags, print usage, and exit if unparsable.
|
||||
|
||||
Args:
|
||||
args: [str], a non-empty list of the command line arguments including
|
||||
program name.
|
||||
|
||||
Returns:
|
||||
[str], a non-empty list of remaining command line arguments after parsing
|
||||
flags, including program name.
|
||||
"""
|
||||
try:
|
||||
return FLAGS(args)
|
||||
except flags.Error as error:
|
||||
message = str(error)
|
||||
if '\n' in message:
|
||||
final_message = 'FATAL Flags parsing error:\n%s\n' % textwrap.indent(
|
||||
message, ' ')
|
||||
else:
|
||||
final_message = 'FATAL Flags parsing error: %s\n' % message
|
||||
sys.stderr.write(final_message)
|
||||
sys.stderr.write('Pass --helpshort or --helpfull to see help on flags.\n')
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
_define_help_flags_called = False
|
||||
|
||||
|
||||
def define_help_flags():
|
||||
"""Registers help flags. Idempotent."""
|
||||
# Use a global to ensure idempotence.
|
||||
global _define_help_flags_called
|
||||
|
||||
if not _define_help_flags_called:
|
||||
flags.DEFINE_flag(HelpFlag())
|
||||
flags.DEFINE_flag(HelpshortFlag()) # alias for --help
|
||||
flags.DEFINE_flag(HelpfullFlag())
|
||||
flags.DEFINE_flag(HelpXMLFlag())
|
||||
_define_help_flags_called = True
|
||||
|
||||
|
||||
def _register_and_parse_flags_with_usage(
|
||||
argv=None,
|
||||
flags_parser=parse_flags_with_usage,
|
||||
):
|
||||
"""Registers help flags, parses arguments and shows usage if appropriate.
|
||||
|
||||
This also calls sys.exit(0) if flag --only_check_args is True.
|
||||
|
||||
Args:
|
||||
argv: [str], a non-empty list of the command line arguments including
|
||||
program name, sys.argv is used if None.
|
||||
flags_parser: Callable[[List[Text]], Any], the function used to parse flags.
|
||||
The return value of this function is passed to `main` untouched.
|
||||
It must guarantee FLAGS is parsed after this function is called.
|
||||
|
||||
Returns:
|
||||
The return value of `flags_parser`. When using the default `flags_parser`,
|
||||
it returns the following:
|
||||
[str], a non-empty list of remaining command line arguments after parsing
|
||||
flags, including program name.
|
||||
|
||||
Raises:
|
||||
Error: Raised when flags_parser is called, but FLAGS is not parsed.
|
||||
SystemError: Raised when it's called more than once.
|
||||
"""
|
||||
if _register_and_parse_flags_with_usage.done:
|
||||
raise SystemError('Flag registration can be done only once.')
|
||||
|
||||
define_help_flags()
|
||||
|
||||
original_argv = sys.argv if argv is None else argv
|
||||
args_to_main = flags_parser(original_argv)
|
||||
if not FLAGS.is_parsed():
|
||||
raise Error('FLAGS must be parsed after flags_parser is called.')
|
||||
|
||||
# Exit when told so.
|
||||
if FLAGS.only_check_args:
|
||||
sys.exit(0)
|
||||
# Immediately after flags are parsed, bump verbosity to INFO if the flag has
|
||||
# not been set.
|
||||
if FLAGS['verbosity'].using_default_value:
|
||||
FLAGS.verbosity = 0
|
||||
_register_and_parse_flags_with_usage.done = True
|
||||
|
||||
return args_to_main
|
||||
|
||||
_register_and_parse_flags_with_usage.done = False
|
||||
|
||||
|
||||
def _run_main(main, argv):
|
||||
"""Calls main, optionally with pdb or profiler."""
|
||||
if FLAGS.run_with_pdb:
|
||||
sys.exit(pdb.runcall(main, argv))
|
||||
elif FLAGS.run_with_profiling or FLAGS.profile_file:
|
||||
# Avoid import overhead since most apps (including performance-sensitive
|
||||
# ones) won't be run with profiling.
|
||||
# pylint: disable=g-import-not-at-top
|
||||
import atexit
|
||||
if FLAGS.use_cprofile_for_profiling:
|
||||
import cProfile as profile
|
||||
else:
|
||||
import profile
|
||||
profiler = profile.Profile()
|
||||
if FLAGS.profile_file:
|
||||
atexit.register(profiler.dump_stats, FLAGS.profile_file)
|
||||
else:
|
||||
atexit.register(profiler.print_stats)
|
||||
sys.exit(profiler.runcall(main, argv))
|
||||
else:
|
||||
sys.exit(main(argv))
|
||||
|
||||
|
||||
def _call_exception_handlers(exception):
|
||||
"""Calls any installed exception handlers."""
|
||||
for handler in EXCEPTION_HANDLERS:
|
||||
try:
|
||||
if handler.wants(exception):
|
||||
handler.handle(exception)
|
||||
except: # pylint: disable=bare-except
|
||||
try:
|
||||
# We don't want to stop for exceptions in the exception handlers but
|
||||
# we shouldn't hide them either.
|
||||
logging.error(traceback.format_exc())
|
||||
except: # pylint: disable=bare-except
|
||||
# In case even the logging statement fails, ignore.
|
||||
pass
|
||||
|
||||
|
||||
def run(
|
||||
main,
|
||||
argv=None,
|
||||
flags_parser=parse_flags_with_usage,
|
||||
):
|
||||
"""Begins executing the program.
|
||||
|
||||
Args:
|
||||
main: The main function to execute. It takes an single argument "argv",
|
||||
which is a list of command line arguments with parsed flags removed.
|
||||
The return value is passed to `sys.exit`, and so for example
|
||||
a return value of 0 or None results in a successful termination, whereas
|
||||
a return value of 1 results in abnormal termination.
|
||||
For more details, see https://docs.python.org/3/library/sys#sys.exit
|
||||
argv: A non-empty list of the command line arguments including program name,
|
||||
sys.argv is used if None.
|
||||
flags_parser: Callable[[List[Text]], Any], the function used to parse flags.
|
||||
The return value of this function is passed to `main` untouched.
|
||||
It must guarantee FLAGS is parsed after this function is called.
|
||||
Should be passed as a keyword-only arg which will become mandatory in a
|
||||
future release.
|
||||
- Parses command line flags with the flag module.
|
||||
- If there are any errors, prints usage().
|
||||
- Calls main() with the remaining arguments.
|
||||
- If main() raises a UsageError, prints usage and the error message.
|
||||
"""
|
||||
try:
|
||||
args = _run_init(
|
||||
sys.argv if argv is None else argv,
|
||||
flags_parser,
|
||||
)
|
||||
while _init_callbacks:
|
||||
callback = _init_callbacks.popleft()
|
||||
callback()
|
||||
try:
|
||||
_run_main(main, args)
|
||||
except UsageError as error:
|
||||
usage(shorthelp=True, detailed_error=error, exitcode=error.exitcode)
|
||||
except:
|
||||
exc = sys.exc_info()[1]
|
||||
# Don't try to post-mortem debug successful SystemExits, since those
|
||||
# mean there wasn't actually an error. In particular, the test framework
|
||||
# raises SystemExit(False) even if all tests passed.
|
||||
if isinstance(exc, SystemExit) and not exc.code:
|
||||
raise
|
||||
|
||||
# Check the tty so that we don't hang waiting for input in an
|
||||
# non-interactive scenario.
|
||||
if FLAGS.pdb_post_mortem and sys.stdout.isatty():
|
||||
traceback.print_exc()
|
||||
print()
|
||||
print(' *** Entering post-mortem debugging ***')
|
||||
print()
|
||||
pdb.post_mortem()
|
||||
raise
|
||||
except Exception as e:
|
||||
_call_exception_handlers(e)
|
||||
raise
|
||||
|
||||
# Callbacks which have been deferred until after _run_init has been called.
|
||||
_init_callbacks = collections.deque()
|
||||
|
||||
|
||||
def call_after_init(callback):
|
||||
"""Calls the given callback only once ABSL has finished initialization.
|
||||
|
||||
If ABSL has already finished initialization when ``call_after_init`` is
|
||||
called then the callback is executed immediately, otherwise `callback` is
|
||||
stored to be executed after ``app.run`` has finished initializing (aka. just
|
||||
before the main function is called).
|
||||
|
||||
If called after ``app.run``, this is equivalent to calling ``callback()`` in
|
||||
the caller thread. If called before ``app.run``, callbacks are run
|
||||
sequentially (in an undefined order) in the same thread as ``app.run``.
|
||||
|
||||
Args:
|
||||
callback: a callable to be called once ABSL has finished initialization.
|
||||
This may be immediate if initialization has already finished. It
|
||||
takes no arguments and returns nothing.
|
||||
"""
|
||||
if _run_init.done:
|
||||
callback()
|
||||
else:
|
||||
_init_callbacks.append(callback)
|
||||
|
||||
|
||||
def _run_init(
|
||||
argv,
|
||||
flags_parser,
|
||||
):
|
||||
"""Does one-time initialization and re-parses flags on rerun."""
|
||||
if _run_init.done:
|
||||
return flags_parser(argv)
|
||||
command_name.make_process_name_useful()
|
||||
# Set up absl logging handler.
|
||||
logging.use_absl_handler()
|
||||
args = _register_and_parse_flags_with_usage(
|
||||
argv=argv,
|
||||
flags_parser=flags_parser,
|
||||
)
|
||||
if faulthandler:
|
||||
try:
|
||||
faulthandler.enable()
|
||||
except Exception: # pylint: disable=broad-except
|
||||
# Some tests verify stderr output very closely, so don't print anything.
|
||||
# Disabled faulthandler is a low-impact error.
|
||||
pass
|
||||
_run_init.done = True
|
||||
return args
|
||||
|
||||
|
||||
_run_init.done = False
|
||||
|
||||
|
||||
def usage(shorthelp=False, writeto_stdout=False, detailed_error=None,
|
||||
exitcode=None):
|
||||
"""Writes __main__'s docstring to stderr with some help text.
|
||||
|
||||
Args:
|
||||
shorthelp: bool, if True, prints only flags from the main module,
|
||||
rather than all flags.
|
||||
writeto_stdout: bool, if True, writes help message to stdout,
|
||||
rather than to stderr.
|
||||
detailed_error: str, additional detail about why usage info was presented.
|
||||
exitcode: optional integer, if set, exits with this status code after
|
||||
writing help.
|
||||
"""
|
||||
if writeto_stdout:
|
||||
stdfile = sys.stdout
|
||||
else:
|
||||
stdfile = sys.stderr
|
||||
|
||||
doc = sys.modules['__main__'].__doc__
|
||||
if not doc:
|
||||
doc = '\nUSAGE: %s [flags]\n' % sys.argv[0]
|
||||
doc = flags.text_wrap(doc, indent=' ', firstline_indent='')
|
||||
else:
|
||||
# Replace all '%s' with sys.argv[0], and all '%%' with '%'.
|
||||
num_specifiers = doc.count('%') - 2 * doc.count('%%')
|
||||
try:
|
||||
doc %= (sys.argv[0],) * num_specifiers
|
||||
except (OverflowError, TypeError, ValueError):
|
||||
# Just display the docstring as-is.
|
||||
pass
|
||||
if shorthelp:
|
||||
flag_str = FLAGS.main_module_help()
|
||||
else:
|
||||
flag_str = FLAGS.get_help()
|
||||
try:
|
||||
stdfile.write(doc)
|
||||
if flag_str:
|
||||
stdfile.write('\nflags:\n')
|
||||
stdfile.write(flag_str)
|
||||
stdfile.write('\n')
|
||||
if detailed_error is not None:
|
||||
stdfile.write('\n%s\n' % detailed_error)
|
||||
except IOError as e:
|
||||
# We avoid printing a huge backtrace if we get EPIPE, because
|
||||
# "foo.par --help | less" is a frequent use case.
|
||||
if e.errno != errno.EPIPE:
|
||||
raise
|
||||
if exitcode is not None:
|
||||
sys.exit(exitcode)
|
||||
|
||||
|
||||
class ExceptionHandler(object):
|
||||
"""Base exception handler from which other may inherit."""
|
||||
|
||||
def wants(self, exc):
|
||||
"""Returns whether this handler wants to handle the exception or not.
|
||||
|
||||
This base class returns True for all exceptions by default. Override in
|
||||
subclass if it wants to be more selective.
|
||||
|
||||
Args:
|
||||
exc: Exception, the current exception.
|
||||
"""
|
||||
del exc # Unused.
|
||||
return True
|
||||
|
||||
def handle(self, exc):
|
||||
"""Do something with the current exception.
|
||||
|
||||
Args:
|
||||
exc: Exception, the current exception
|
||||
|
||||
This method must be overridden.
|
||||
"""
|
||||
raise NotImplementedError()
|
||||
|
||||
|
||||
def install_exception_handler(handler):
|
||||
"""Installs an exception handler.
|
||||
|
||||
Args:
|
||||
handler: ExceptionHandler, the exception handler to install.
|
||||
|
||||
Raises:
|
||||
TypeError: Raised when the handler was not of the correct type.
|
||||
|
||||
All installed exception handlers will be called if main() exits via
|
||||
an abnormal exception, i.e. not one of SystemExit, KeyboardInterrupt,
|
||||
FlagsError or UsageError.
|
||||
"""
|
||||
if not isinstance(handler, ExceptionHandler):
|
||||
raise TypeError('handler of type %s does not inherit from ExceptionHandler'
|
||||
% type(handler))
|
||||
EXCEPTION_HANDLERS.append(handler)
|
99
Lib/site-packages/absl/app.pyi
Normal file
99
Lib/site-packages/absl/app.pyi
Normal file
@ -0,0 +1,99 @@
|
||||
|
||||
from typing import Any, Callable, Collection, Iterable, List, NoReturn, Optional, Text, TypeVar, Union, overload
|
||||
|
||||
from absl.flags import _flag
|
||||
|
||||
|
||||
_MainArgs = TypeVar('_MainArgs')
|
||||
_Exc = TypeVar('_Exc', bound=Exception)
|
||||
|
||||
|
||||
class ExceptionHandler():
|
||||
|
||||
def wants(self, exc: _Exc) -> bool:
|
||||
...
|
||||
|
||||
def handle(self, exc: _Exc):
|
||||
...
|
||||
|
||||
|
||||
EXCEPTION_HANDLERS: List[ExceptionHandler] = ...
|
||||
|
||||
|
||||
class HelpFlag(_flag.BooleanFlag):
|
||||
def __init__(self):
|
||||
...
|
||||
|
||||
|
||||
class HelpshortFlag(HelpFlag):
|
||||
...
|
||||
|
||||
|
||||
class HelpfullFlag(_flag.BooleanFlag):
|
||||
def __init__(self):
|
||||
...
|
||||
|
||||
|
||||
class HelpXMLFlag(_flag.BooleanFlag):
|
||||
def __init__(self):
|
||||
...
|
||||
|
||||
|
||||
def define_help_flags() -> None:
|
||||
...
|
||||
|
||||
|
||||
@overload
|
||||
def usage(shorthelp: Union[bool, int] = ...,
|
||||
writeto_stdout: Union[bool, int] = ...,
|
||||
detailed_error: Optional[Any] = ...,
|
||||
exitcode: None = ...) -> None:
|
||||
...
|
||||
|
||||
|
||||
@overload
|
||||
def usage(shorthelp: Union[bool, int] = ...,
|
||||
writeto_stdout: Union[bool, int] = ...,
|
||||
detailed_error: Optional[Any] = ...,
|
||||
exitcode: int = ...) -> NoReturn:
|
||||
...
|
||||
|
||||
|
||||
def install_exception_handler(handler: ExceptionHandler) -> None:
|
||||
...
|
||||
|
||||
|
||||
class Error(Exception):
|
||||
...
|
||||
|
||||
|
||||
class UsageError(Error):
|
||||
exitcode: int
|
||||
|
||||
|
||||
def parse_flags_with_usage(args: List[Text]) -> List[Text]:
|
||||
...
|
||||
|
||||
|
||||
def call_after_init(callback: Callable[[], Any]) -> None:
|
||||
...
|
||||
|
||||
|
||||
# Without the flag_parser argument, `main` should require a List[Text].
|
||||
@overload
|
||||
def run(
|
||||
main: Callable[[List[Text]], Any],
|
||||
argv: Optional[List[Text]] = ...,
|
||||
*,
|
||||
) -> NoReturn:
|
||||
...
|
||||
|
||||
|
||||
@overload
|
||||
def run(
|
||||
main: Callable[[_MainArgs], Any],
|
||||
argv: Optional[List[Text]] = ...,
|
||||
*,
|
||||
flags_parser: Callable[[List[Text]], _MainArgs],
|
||||
) -> NoReturn:
|
||||
...
|
63
Lib/site-packages/absl/command_name.py
Normal file
63
Lib/site-packages/absl/command_name.py
Normal file
@ -0,0 +1,63 @@
|
||||
# Copyright 2017 The Abseil Authors.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
"""A tiny stand alone library to change the kernel process name on Linux."""
|
||||
|
||||
import os
|
||||
import sys
|
||||
|
||||
# This library must be kept small and stand alone. It is used by small things
|
||||
# that require no extension modules.
|
||||
|
||||
|
||||
def make_process_name_useful():
|
||||
"""Sets the process name to something better than 'python' if possible."""
|
||||
set_kernel_process_name(os.path.basename(sys.argv[0]))
|
||||
|
||||
|
||||
def set_kernel_process_name(name):
|
||||
"""Changes the Kernel's /proc/self/status process name on Linux.
|
||||
|
||||
The kernel name is NOT what will be shown by the ps or top command.
|
||||
It is a 15 character string stored in the kernel's process table that
|
||||
is included in the kernel log when a process is OOM killed.
|
||||
The first 15 bytes of name are used. Non-ASCII unicode is replaced with '?'.
|
||||
|
||||
Does nothing if /proc/self/comm cannot be written or prctl() fails.
|
||||
|
||||
Args:
|
||||
name: bytes|unicode, the Linux kernel's command name to set.
|
||||
"""
|
||||
if not isinstance(name, bytes):
|
||||
name = name.encode('ascii', 'replace')
|
||||
try:
|
||||
# This is preferred to using ctypes to try and call prctl() when possible.
|
||||
with open('/proc/self/comm', 'wb') as proc_comm:
|
||||
proc_comm.write(name[:15])
|
||||
except EnvironmentError:
|
||||
try:
|
||||
import ctypes # pylint: disable=g-import-not-at-top
|
||||
except ImportError:
|
||||
return # No ctypes.
|
||||
try:
|
||||
libc = ctypes.CDLL('libc.so.6')
|
||||
except EnvironmentError:
|
||||
return # No libc.so.6.
|
||||
pr_set_name = ctypes.c_ulong(15) # linux/prctl.h PR_SET_NAME value.
|
||||
zero = ctypes.c_ulong(0)
|
||||
try:
|
||||
libc.prctl(pr_set_name, name, zero, zero, zero)
|
||||
# Ignore the prctl return value. Nothing we can do if it errored.
|
||||
except AttributeError:
|
||||
return # No prctl.
|
225
Lib/site-packages/absl/flags/__init__.py
Normal file
225
Lib/site-packages/absl/flags/__init__.py
Normal file