Add files using upload-large-folder tool
Browse filesThis view is limited to 50 files because it contains too many changes. See raw diff
- miniconda3/pkgs/distro-1.9.0-py313h06a4308_0/info/files +17 -0
- miniconda3/pkgs/distro-1.9.0-py313h06a4308_0/info/git +0 -0
- miniconda3/pkgs/distro-1.9.0-py313h06a4308_0/info/has_prefix +1 -0
- miniconda3/pkgs/distro-1.9.0-py313h06a4308_0/info/hash_input.json +4 -0
- miniconda3/pkgs/distro-1.9.0-py313h06a4308_0/info/index.json +16 -0
- miniconda3/pkgs/distro-1.9.0-py313h06a4308_0/info/licenses/LICENSE +202 -0
- miniconda3/pkgs/distro-1.9.0-py313h06a4308_0/info/paths.json +109 -0
- miniconda3/pkgs/distro-1.9.0-py313h06a4308_0/info/recipe/conda_build_config.yaml +108 -0
- miniconda3/pkgs/distro-1.9.0-py313h06a4308_0/info/recipe/meta.yaml +74 -0
- miniconda3/pkgs/distro-1.9.0-py313h06a4308_0/info/recipe/meta.yaml.template +52 -0
- miniconda3/pkgs/distro-1.9.0-py313h06a4308_0/info/repodata_record.json +23 -0
- miniconda3/pkgs/distro-1.9.0-py313h06a4308_0/info/test/run_test.py +3 -0
- miniconda3/pkgs/distro-1.9.0-py313h06a4308_0/info/test/run_test.sh +9 -0
- miniconda3/pkgs/distro-1.9.0-py313h06a4308_0/info/test/test_time_dependencies.json +1 -0
- miniconda3/pkgs/distro-1.9.0-py313h06a4308_0/lib/python3.13/site-packages/distro-1.9.0.dist-info/INSTALLER +1 -0
- miniconda3/pkgs/distro-1.9.0-py313h06a4308_0/lib/python3.13/site-packages/distro-1.9.0.dist-info/LICENSE +202 -0
- miniconda3/pkgs/distro-1.9.0-py313h06a4308_0/lib/python3.13/site-packages/distro-1.9.0.dist-info/METADATA +184 -0
- miniconda3/pkgs/distro-1.9.0-py313h06a4308_0/lib/python3.13/site-packages/distro-1.9.0.dist-info/RECORD +17 -0
- miniconda3/pkgs/distro-1.9.0-py313h06a4308_0/lib/python3.13/site-packages/distro-1.9.0.dist-info/REQUESTED +0 -0
- miniconda3/pkgs/distro-1.9.0-py313h06a4308_0/lib/python3.13/site-packages/distro-1.9.0.dist-info/WHEEL +5 -0
- miniconda3/pkgs/distro-1.9.0-py313h06a4308_0/lib/python3.13/site-packages/distro-1.9.0.dist-info/direct_url.json +1 -0
- miniconda3/pkgs/distro-1.9.0-py313h06a4308_0/lib/python3.13/site-packages/distro-1.9.0.dist-info/entry_points.txt +2 -0
- miniconda3/pkgs/distro-1.9.0-py313h06a4308_0/lib/python3.13/site-packages/distro-1.9.0.dist-info/top_level.txt +1 -0
- miniconda3/pkgs/distro-1.9.0-py313h06a4308_0/lib/python3.13/site-packages/distro/__init__.py +54 -0
- miniconda3/pkgs/distro-1.9.0-py313h06a4308_0/lib/python3.13/site-packages/distro/__main__.py +4 -0
- miniconda3/pkgs/distro-1.9.0-py313h06a4308_0/lib/python3.13/site-packages/distro/distro.py +1403 -0
- miniconda3/pkgs/distro-1.9.0-py313h06a4308_0/lib/python3.13/site-packages/distro/py.typed +0 -0
- miniconda3/pkgs/expat-2.7.4-h7354ed3_0/bin/xmlwf +0 -0
- miniconda3/pkgs/expat-2.7.4-h7354ed3_0/info/about.json +189 -0
- miniconda3/pkgs/expat-2.7.4-h7354ed3_0/info/files +2 -0
- miniconda3/pkgs/expat-2.7.4-h7354ed3_0/info/git +0 -0
- miniconda3/pkgs/expat-2.7.4-h7354ed3_0/info/hash_input.json +11 -0
- miniconda3/pkgs/expat-2.7.4-h7354ed3_0/info/index.json +18 -0
- miniconda3/pkgs/expat-2.7.4-h7354ed3_0/info/licenses/COPYING +21 -0
- miniconda3/pkgs/expat-2.7.4-h7354ed3_0/info/paths.json +17 -0
- miniconda3/pkgs/expat-2.7.4-h7354ed3_0/info/recipe/conda_build_config.yaml +33 -0
- miniconda3/pkgs/expat-2.7.4-h7354ed3_0/info/recipe/meta.yaml +82 -0
- miniconda3/pkgs/expat-2.7.4-h7354ed3_0/info/recipe/parent/bld.bat +38 -0
- miniconda3/pkgs/expat-2.7.4-h7354ed3_0/info/recipe/parent/build.sh +21 -0
- miniconda3/pkgs/expat-2.7.4-h7354ed3_0/info/recipe/parent/meta.yaml +108 -0
- miniconda3/pkgs/expat-2.7.4-h7354ed3_0/info/recipe/parent/stdbool.h +3 -0
- miniconda3/pkgs/expat-2.7.4-h7354ed3_0/info/repodata_record.json +25 -0
- miniconda3/pkgs/expat-2.7.4-h7354ed3_0/info/run_exports.json +1 -0
- miniconda3/pkgs/expat-2.7.4-h7354ed3_0/info/test/run_test.sh +8 -0
- miniconda3/pkgs/expat-2.7.4-h7354ed3_0/share/man/man1/xmlwf.1 +359 -0
- miniconda3/pkgs/fmt-11.2.0-hca5f364_0/include/fmt/args.h +220 -0
- miniconda3/pkgs/fmt-11.2.0-hca5f364_0/include/fmt/base.h +0 -0
- miniconda3/pkgs/fmt-11.2.0-hca5f364_0/include/fmt/chrono.h +2330 -0
- miniconda3/pkgs/fmt-11.2.0-hca5f364_0/include/fmt/color.h +637 -0
- miniconda3/pkgs/fmt-11.2.0-hca5f364_0/include/fmt/compile.h +539 -0
miniconda3/pkgs/distro-1.9.0-py313h06a4308_0/info/files
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
bin/distro
|
| 2 |
+
lib/python3.13/site-packages/distro-1.9.0.dist-info/INSTALLER
|
| 3 |
+
lib/python3.13/site-packages/distro-1.9.0.dist-info/LICENSE
|
| 4 |
+
lib/python3.13/site-packages/distro-1.9.0.dist-info/METADATA
|
| 5 |
+
lib/python3.13/site-packages/distro-1.9.0.dist-info/RECORD
|
| 6 |
+
lib/python3.13/site-packages/distro-1.9.0.dist-info/REQUESTED
|
| 7 |
+
lib/python3.13/site-packages/distro-1.9.0.dist-info/WHEEL
|
| 8 |
+
lib/python3.13/site-packages/distro-1.9.0.dist-info/direct_url.json
|
| 9 |
+
lib/python3.13/site-packages/distro-1.9.0.dist-info/entry_points.txt
|
| 10 |
+
lib/python3.13/site-packages/distro-1.9.0.dist-info/top_level.txt
|
| 11 |
+
lib/python3.13/site-packages/distro/__init__.py
|
| 12 |
+
lib/python3.13/site-packages/distro/__main__.py
|
| 13 |
+
lib/python3.13/site-packages/distro/__pycache__/__init__.cpython-313.pyc
|
| 14 |
+
lib/python3.13/site-packages/distro/__pycache__/__main__.cpython-313.pyc
|
| 15 |
+
lib/python3.13/site-packages/distro/__pycache__/distro.cpython-313.pyc
|
| 16 |
+
lib/python3.13/site-packages/distro/distro.py
|
| 17 |
+
lib/python3.13/site-packages/distro/py.typed
|
miniconda3/pkgs/distro-1.9.0-py313h06a4308_0/info/git
ADDED
|
File without changes
|
miniconda3/pkgs/distro-1.9.0-py313h06a4308_0/info/has_prefix
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
/work/perseverance-python-buildout/croot/distro_1728396110052/_h_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placeh text bin/distro
|
miniconda3/pkgs/distro-1.9.0-py313h06a4308_0/info/hash_input.json
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"target_platform": "linux-64",
|
| 3 |
+
"channel_targets": "defaults"
|
| 4 |
+
}
|
miniconda3/pkgs/distro-1.9.0-py313h06a4308_0/info/index.json
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"arch": "x86_64",
|
| 3 |
+
"build": "py313h06a4308_0",
|
| 4 |
+
"build_number": 0,
|
| 5 |
+
"depends": [
|
| 6 |
+
"python >=3.13,<3.14.0a0",
|
| 7 |
+
"python_abi 3.13.* *_cp313"
|
| 8 |
+
],
|
| 9 |
+
"license": "Apache-2.0",
|
| 10 |
+
"license_family": "Apache",
|
| 11 |
+
"name": "distro",
|
| 12 |
+
"platform": "linux",
|
| 13 |
+
"subdir": "linux-64",
|
| 14 |
+
"timestamp": 1728396132498,
|
| 15 |
+
"version": "1.9.0"
|
| 16 |
+
}
|
miniconda3/pkgs/distro-1.9.0-py313h06a4308_0/info/licenses/LICENSE
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
Apache License
|
| 2 |
+
Version 2.0, January 2004
|
| 3 |
+
http://www.apache.org/licenses/
|
| 4 |
+
|
| 5 |
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
| 6 |
+
|
| 7 |
+
1. Definitions.
|
| 8 |
+
|
| 9 |
+
"License" shall mean the terms and conditions for use, reproduction,
|
| 10 |
+
and distribution as defined by Sections 1 through 9 of this document.
|
| 11 |
+
|
| 12 |
+
"Licensor" shall mean the copyright owner or entity authorized by
|
| 13 |
+
the copyright owner that is granting the License.
|
| 14 |
+
|
| 15 |
+
"Legal Entity" shall mean the union of the acting entity and all
|
| 16 |
+
other entities that control, are controlled by, or are under common
|
| 17 |
+
control with that entity. For the purposes of this definition,
|
| 18 |
+
"control" means (i) the power, direct or indirect, to cause the
|
| 19 |
+
direction or management of such entity, whether by contract or
|
| 20 |
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
| 21 |
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
| 22 |
+
|
| 23 |
+
"You" (or "Your") shall mean an individual or Legal Entity
|
| 24 |
+
exercising permissions granted by this License.
|
| 25 |
+
|
| 26 |
+
"Source" form shall mean the preferred form for making modifications,
|
| 27 |
+
including but not limited to software source code, documentation
|
| 28 |
+
source, and configuration files.
|
| 29 |
+
|
| 30 |
+
"Object" form shall mean any form resulting from mechanical
|
| 31 |
+
transformation or translation of a Source form, including but
|
| 32 |
+
not limited to compiled object code, generated documentation,
|
| 33 |
+
and conversions to other media types.
|
| 34 |
+
|
| 35 |
+
"Work" shall mean the work of authorship, whether in Source or
|
| 36 |
+
Object form, made available under the License, as indicated by a
|
| 37 |
+
copyright notice that is included in or attached to the work
|
| 38 |
+
(an example is provided in the Appendix below).
|
| 39 |
+
|
| 40 |
+
"Derivative Works" shall mean any work, whether in Source or Object
|
| 41 |
+
form, that is based on (or derived from) the Work and for which the
|
| 42 |
+
editorial revisions, annotations, elaborations, or other modifications
|
| 43 |
+
represent, as a whole, an original work of authorship. For the purposes
|
| 44 |
+
of this License, Derivative Works shall not include works that remain
|
| 45 |
+
separable from, or merely link (or bind by name) to the interfaces of,
|
| 46 |
+
the Work and Derivative Works thereof.
|
| 47 |
+
|
| 48 |
+
"Contribution" shall mean any work of authorship, including
|
| 49 |
+
the original version of the Work and any modifications or additions
|
| 50 |
+
to that Work or Derivative Works thereof, that is intentionally
|
| 51 |
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
| 52 |
+
or by an individual or Legal Entity authorized to submit on behalf of
|
| 53 |
+
the copyright owner. For the purposes of this definition, "submitted"
|
| 54 |
+
means any form of electronic, verbal, or written communication sent
|
| 55 |
+
to the Licensor or its representatives, including but not limited to
|
| 56 |
+
communication on electronic mailing lists, source code control systems,
|
| 57 |
+
and issue tracking systems that are managed by, or on behalf of, the
|
| 58 |
+
Licensor for the purpose of discussing and improving the Work, but
|
| 59 |
+
excluding communication that is conspicuously marked or otherwise
|
| 60 |
+
designated in writing by the copyright owner as "Not a Contribution."
|
| 61 |
+
|
| 62 |
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
| 63 |
+
on behalf of whom a Contribution has been received by Licensor and
|
| 64 |
+
subsequently incorporated within the Work.
|
| 65 |
+
|
| 66 |
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
| 67 |
+
this License, each Contributor hereby grants to You a perpetual,
|
| 68 |
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
| 69 |
+
copyright license to reproduce, prepare Derivative Works of,
|
| 70 |
+
publicly display, publicly perform, sublicense, and distribute the
|
| 71 |
+
Work and such Derivative Works in Source or Object form.
|
| 72 |
+
|
| 73 |
+
3. Grant of Patent License. Subject to the terms and conditions of
|
| 74 |
+
this License, each Contributor hereby grants to You a perpetual,
|
| 75 |
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
| 76 |
+
(except as stated in this section) patent license to make, have made,
|
| 77 |
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
| 78 |
+
where such license applies only to those patent claims licensable
|
| 79 |
+
by such Contributor that are necessarily infringed by their
|
| 80 |
+
Contribution(s) alone or by combination of their Contribution(s)
|
| 81 |
+
with the Work to which such Contribution(s) was submitted. If You
|
| 82 |
+
institute patent litigation against any entity (including a
|
| 83 |
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
| 84 |
+
or a Contribution incorporated within the Work constitutes direct
|
| 85 |
+
or contributory patent infringement, then any patent licenses
|
| 86 |
+
granted to You under this License for that Work shall terminate
|
| 87 |
+
as of the date such litigation is filed.
|
| 88 |
+
|
| 89 |
+
4. Redistribution. You may reproduce and distribute copies of the
|
| 90 |
+
Work or Derivative Works thereof in any medium, with or without
|
| 91 |
+
modifications, and in Source or Object form, provided that You
|
| 92 |
+
meet the following conditions:
|
| 93 |
+
|
| 94 |
+
(a) You must give any other recipients of the Work or
|
| 95 |
+
Derivative Works a copy of this License; and
|
| 96 |
+
|
| 97 |
+
(b) You must cause any modified files to carry prominent notices
|
| 98 |
+
stating that You changed the files; and
|
| 99 |
+
|
| 100 |
+
(c) You must retain, in the Source form of any Derivative Works
|
| 101 |
+
that You distribute, all copyright, patent, trademark, and
|
| 102 |
+
attribution notices from the Source form of the Work,
|
| 103 |
+
excluding those notices that do not pertain to any part of
|
| 104 |
+
the Derivative Works; and
|
| 105 |
+
|
| 106 |
+
(d) If the Work includes a "NOTICE" text file as part of its
|
| 107 |
+
distribution, then any Derivative Works that You distribute must
|
| 108 |
+
include a readable copy of the attribution notices contained
|
| 109 |
+
within such NOTICE file, excluding those notices that do not
|
| 110 |
+
pertain to any part of the Derivative Works, in at least one
|
| 111 |
+
of the following places: within a NOTICE text file distributed
|
| 112 |
+
as part of the Derivative Works; within the Source form or
|
| 113 |
+
documentation, if provided along with the Derivative Works; or,
|
| 114 |
+
within a display generated by the Derivative Works, if and
|
| 115 |
+
wherever such third-party notices normally appear. The contents
|
| 116 |
+
of the NOTICE file are for informational purposes only and
|
| 117 |
+
do not modify the License. You may add Your own attribution
|
| 118 |
+
notices within Derivative Works that You distribute, alongside
|
| 119 |
+
or as an addendum to the NOTICE text from the Work, provided
|
| 120 |
+
that such additional attribution notices cannot be construed
|
| 121 |
+
as modifying the License.
|
| 122 |
+
|
| 123 |
+
You may add Your own copyright statement to Your modifications and
|
| 124 |
+
may provide additional or different license terms and conditions
|
| 125 |
+
for use, reproduction, or distribution of Your modifications, or
|
| 126 |
+
for any such Derivative Works as a whole, provided Your use,
|
| 127 |
+
reproduction, and distribution of the Work otherwise complies with
|
| 128 |
+
the conditions stated in this License.
|
| 129 |
+
|
| 130 |
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
| 131 |
+
any Contribution intentionally submitted for inclusion in the Work
|
| 132 |
+
by You to the Licensor shall be under the terms and conditions of
|
| 133 |
+
this License, without any additional terms or conditions.
|
| 134 |
+
Notwithstanding the above, nothing herein shall supersede or modify
|
| 135 |
+
the terms of any separate license agreement you may have executed
|
| 136 |
+
with Licensor regarding such Contributions.
|
| 137 |
+
|
| 138 |
+
6. Trademarks. This License does not grant permission to use the trade
|
| 139 |
+
names, trademarks, service marks, or product names of the Licensor,
|
| 140 |
+
except as required for reasonable and customary use in describing the
|
| 141 |
+
origin of the Work and reproducing the content of the NOTICE file.
|
| 142 |
+
|
| 143 |
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
| 144 |
+
agreed to in writing, Licensor provides the Work (and each
|
| 145 |
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
| 146 |
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
| 147 |
+
implied, including, without limitation, any warranties or conditions
|
| 148 |
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
| 149 |
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
| 150 |
+
appropriateness of using or redistributing the Work and assume any
|
| 151 |
+
risks associated with Your exercise of permissions under this License.
|
| 152 |
+
|
| 153 |
+
8. Limitation of Liability. In no event and under no legal theory,
|
| 154 |
+
whether in tort (including negligence), contract, or otherwise,
|
| 155 |
+
unless required by applicable law (such as deliberate and grossly
|
| 156 |
+
negligent acts) or agreed to in writing, shall any Contributor be
|
| 157 |
+
liable to You for damages, including any direct, indirect, special,
|
| 158 |
+
incidental, or consequential damages of any character arising as a
|
| 159 |
+
result of this License or out of the use or inability to use the
|
| 160 |
+
Work (including but not limited to damages for loss of goodwill,
|
| 161 |
+
work stoppage, computer failure or malfunction, or any and all
|
| 162 |
+
other commercial damages or losses), even if such Contributor
|
| 163 |
+
has been advised of the possibility of such damages.
|
| 164 |
+
|
| 165 |
+
9. Accepting Warranty or Additional Liability. While redistributing
|
| 166 |
+
the Work or Derivative Works thereof, You may choose to offer,
|
| 167 |
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
| 168 |
+
or other liability obligations and/or rights consistent with this
|
| 169 |
+
License. However, in accepting such obligations, You may act only
|
| 170 |
+
on Your own behalf and on Your sole responsibility, not on behalf
|
| 171 |
+
of any other Contributor, and only if You agree to indemnify,
|
| 172 |
+
defend, and hold each Contributor harmless for any liability
|
| 173 |
+
incurred by, or claims asserted against, such Contributor by reason
|
| 174 |
+
of your accepting any such warranty or additional liability.
|
| 175 |
+
|
| 176 |
+
END OF TERMS AND CONDITIONS
|
| 177 |
+
|
| 178 |
+
APPENDIX: How to apply the Apache License to your work.
|
| 179 |
+
|
| 180 |
+
To apply the Apache License to your work, attach the following
|
| 181 |
+
boilerplate notice, with the fields enclosed by brackets "{}"
|
| 182 |
+
replaced with your own identifying information. (Don't include
|
| 183 |
+
the brackets!) The text should be enclosed in the appropriate
|
| 184 |
+
comment syntax for the file format. We also recommend that a
|
| 185 |
+
file or class name and description of purpose be included on the
|
| 186 |
+
same "printed page" as the copyright notice for easier
|
| 187 |
+
identification within third-party archives.
|
| 188 |
+
|
| 189 |
+
Copyright {yyyy} {name of copyright owner}
|
| 190 |
+
|
| 191 |
+
Licensed under the Apache License, Version 2.0 (the "License");
|
| 192 |
+
you may not use this file except in compliance with the License.
|
| 193 |
+
You may obtain a copy of the License at
|
| 194 |
+
|
| 195 |
+
http://www.apache.org/licenses/LICENSE-2.0
|
| 196 |
+
|
| 197 |
+
Unless required by applicable law or agreed to in writing, software
|
| 198 |
+
distributed under the License is distributed on an "AS IS" BASIS,
|
| 199 |
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 200 |
+
See the License for the specific language governing permissions and
|
| 201 |
+
limitations under the License.
|
| 202 |
+
|
miniconda3/pkgs/distro-1.9.0-py313h06a4308_0/info/paths.json
ADDED
|
@@ -0,0 +1,109 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"paths": [
|
| 3 |
+
{
|
| 4 |
+
"_path": "bin/distro",
|
| 5 |
+
"file_mode": "text",
|
| 6 |
+
"path_type": "hardlink",
|
| 7 |
+
"prefix_placeholder": "/work/perseverance-python-buildout/croot/distro_1728396110052/_h_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placeh",
|
| 8 |
+
"sha256": "06deb672af80caaa59d4472bad88f761b41904614371ab924f4192457a063712",
|
| 9 |
+
"size_in_bytes": 466
|
| 10 |
+
},
|
| 11 |
+
{
|
| 12 |
+
"_path": "lib/python3.13/site-packages/distro-1.9.0.dist-info/INSTALLER",
|
| 13 |
+
"path_type": "hardlink",
|
| 14 |
+
"sha256": "d0edee15f91b406f3f99726e44eb990be6e34fd0345b52b910c568e0eef6a2a8",
|
| 15 |
+
"size_in_bytes": 5
|
| 16 |
+
},
|
| 17 |
+
{
|
| 18 |
+
"_path": "lib/python3.13/site-packages/distro-1.9.0.dist-info/LICENSE",
|
| 19 |
+
"path_type": "hardlink",
|
| 20 |
+
"sha256": "cb5e8e7e5f4a3988e1063c142c60dc2df75605f4c46515e776e3aca6df976e14",
|
| 21 |
+
"size_in_bytes": 11325
|
| 22 |
+
},
|
| 23 |
+
{
|
| 24 |
+
"_path": "lib/python3.13/site-packages/distro-1.9.0.dist-info/METADATA",
|
| 25 |
+
"path_type": "hardlink",
|
| 26 |
+
"sha256": "31632ab2de5591131091b3397bdcdf797718579d85a75186f06839dd0c09e81d",
|
| 27 |
+
"size_in_bytes": 6791
|
| 28 |
+
},
|
| 29 |
+
{
|
| 30 |
+
"_path": "lib/python3.13/site-packages/distro-1.9.0.dist-info/RECORD",
|
| 31 |
+
"path_type": "hardlink",
|
| 32 |
+
"sha256": "84144785c4668a5ded4e4911c565e6b439d697a9d1d832b5691bcc841751ac5a",
|
| 33 |
+
"size_in_bytes": 1259
|
| 34 |
+
},
|
| 35 |
+
{
|
| 36 |
+
"_path": "lib/python3.13/site-packages/distro-1.9.0.dist-info/REQUESTED",
|
| 37 |
+
"path_type": "hardlink",
|
| 38 |
+
"sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
|
| 39 |
+
"size_in_bytes": 0
|
| 40 |
+
},
|
| 41 |
+
{
|
| 42 |
+
"_path": "lib/python3.13/site-packages/distro-1.9.0.dist-info/WHEEL",
|
| 43 |
+
"path_type": "hardlink",
|
| 44 |
+
"sha256": "195f5a3138703ffe28342b6f102d9e737a9462eb6059e033925ae8ff49b85894",
|
| 45 |
+
"size_in_bytes": 91
|
| 46 |
+
},
|
| 47 |
+
{
|
| 48 |
+
"_path": "lib/python3.13/site-packages/distro-1.9.0.dist-info/direct_url.json",
|
| 49 |
+
"path_type": "hardlink",
|
| 50 |
+
"sha256": "bb7165150b083bc471abc8e9bcf6d0a29ce1702b5b6c77f7256c6c9e0534351e",
|
| 51 |
+
"size_in_bytes": 100
|
| 52 |
+
},
|
| 53 |
+
{
|
| 54 |
+
"_path": "lib/python3.13/site-packages/distro-1.9.0.dist-info/entry_points.txt",
|
| 55 |
+
"path_type": "hardlink",
|
| 56 |
+
"sha256": "dce6e3a9031b875c5e410c2c5ad81b7c33433030fe11b8204753a3ff3f2cf617",
|
| 57 |
+
"size_in_bytes": 46
|
| 58 |
+
},
|
| 59 |
+
{
|
| 60 |
+
"_path": "lib/python3.13/site-packages/distro-1.9.0.dist-info/top_level.txt",
|
| 61 |
+
"path_type": "hardlink",
|
| 62 |
+
"sha256": "8a475efd5fd711d481a9a19de6d12b88dff0cd81cb8135ffcd5b65b062c7bf04",
|
| 63 |
+
"size_in_bytes": 7
|
| 64 |
+
},
|
| 65 |
+
{
|
| 66 |
+
"_path": "lib/python3.13/site-packages/distro/__init__.py",
|
| 67 |
+
"path_type": "hardlink",
|
| 68 |
+
"sha256": "d9f1e317e49f80fbe3c8d67588787fc23a96751fd8a393831f0642d232c13e17",
|
| 69 |
+
"size_in_bytes": 981
|
| 70 |
+
},
|
| 71 |
+
{
|
| 72 |
+
"_path": "lib/python3.13/site-packages/distro/__main__.py",
|
| 73 |
+
"path_type": "hardlink",
|
| 74 |
+
"sha256": "6eef5ddd389fa0a72264572a441bb2815dc64ae4e19d50ff9b620ae1ccfde95b",
|
| 75 |
+
"size_in_bytes": 64
|
| 76 |
+
},
|
| 77 |
+
{
|
| 78 |
+
"_path": "lib/python3.13/site-packages/distro/__pycache__/__init__.cpython-313.pyc",
|
| 79 |
+
"path_type": "hardlink",
|
| 80 |
+
"sha256": "3a1a7f11d8932e4ad894a95e543044fe90b500b96ef1fb45e8bd38367142fca4",
|
| 81 |
+
"size_in_bytes": 914
|
| 82 |
+
},
|
| 83 |
+
{
|
| 84 |
+
"_path": "lib/python3.13/site-packages/distro/__pycache__/__main__.cpython-313.pyc",
|
| 85 |
+
"path_type": "hardlink",
|
| 86 |
+
"sha256": "83cf651bab0e70c7d19d807f1fa34c52b65f41698a6adc6f5d10b04eae835db9",
|
| 87 |
+
"size_in_bytes": 248
|
| 88 |
+
},
|
| 89 |
+
{
|
| 90 |
+
"_path": "lib/python3.13/site-packages/distro/__pycache__/distro.cpython-313.pyc",
|
| 91 |
+
"path_type": "hardlink",
|
| 92 |
+
"sha256": "9a16c14a4224504b30ffac3c379e4ca124865777ad604004ee571af1599b3407",
|
| 93 |
+
"size_in_bytes": 52095
|
| 94 |
+
},
|
| 95 |
+
{
|
| 96 |
+
"_path": "lib/python3.13/site-packages/distro/distro.py",
|
| 97 |
+
"path_type": "hardlink",
|
| 98 |
+
"sha256": "5ea6de7da7008434f8cebfedae76c0d79798f2f74ae064e08609af506ac433fe",
|
| 99 |
+
"size_in_bytes": 49430
|
| 100 |
+
},
|
| 101 |
+
{
|
| 102 |
+
"_path": "lib/python3.13/site-packages/distro/py.typed",
|
| 103 |
+
"path_type": "hardlink",
|
| 104 |
+
"sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
|
| 105 |
+
"size_in_bytes": 0
|
| 106 |
+
}
|
| 107 |
+
],
|
| 108 |
+
"paths_version": 1
|
| 109 |
+
}
|
miniconda3/pkgs/distro-1.9.0-py313h06a4308_0/info/recipe/conda_build_config.yaml
ADDED
|
@@ -0,0 +1,108 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
VERBOSE_AT: V=1
|
| 2 |
+
VERBOSE_CM: VERBOSE=1
|
| 3 |
+
blas_impl: openblas
|
| 4 |
+
boost: '1.82'
|
| 5 |
+
boost_cpp: '1.82'
|
| 6 |
+
bootsrap: 'yes'
|
| 7 |
+
bzip2: '1.0'
|
| 8 |
+
c_compiler: gcc
|
| 9 |
+
c_compiler_version: 11.2.0
|
| 10 |
+
cairo: '1.16'
|
| 11 |
+
cgo_compiler: go-cgo
|
| 12 |
+
cgo_compiler_version: '1.21'
|
| 13 |
+
channel_targets: defaults
|
| 14 |
+
clang_variant: clang
|
| 15 |
+
cpu_optimization_target: nocona
|
| 16 |
+
cran_mirror: https://mran.microsoft.com/snapshot/2018-01-01
|
| 17 |
+
cuda_compiler: cuda-nvcc
|
| 18 |
+
cuda_compiler_version: '12.4'
|
| 19 |
+
cxx_compiler: gxx
|
| 20 |
+
cxx_compiler_version: 11.2.0
|
| 21 |
+
cyrus_sasl: 2.1.28
|
| 22 |
+
dbus: '1'
|
| 23 |
+
expat: '2'
|
| 24 |
+
extend_keys:
|
| 25 |
+
- extend_keys
|
| 26 |
+
- ignore_version
|
| 27 |
+
- pin_run_as_build
|
| 28 |
+
- ignore_build_only_deps
|
| 29 |
+
fontconfig: '2.14'
|
| 30 |
+
fortran_compiler: gfortran
|
| 31 |
+
fortran_compiler_version: 11.2.0
|
| 32 |
+
freetype: '2.10'
|
| 33 |
+
g2clib: '1.6'
|
| 34 |
+
geos: 3.8.0
|
| 35 |
+
giflib: '5'
|
| 36 |
+
glib: '2'
|
| 37 |
+
gmp: '6.2'
|
| 38 |
+
gnu: 2.12.2
|
| 39 |
+
go_compiler: go-nocgo
|
| 40 |
+
go_compiler_version: '1.21'
|
| 41 |
+
gst_plugins_base: '1.14'
|
| 42 |
+
gstreamer: '1.14'
|
| 43 |
+
harfbuzz: 4.3.0
|
| 44 |
+
hdf4: '4.2'
|
| 45 |
+
hdf5: 1.12.1
|
| 46 |
+
hdfeos2: '2.20'
|
| 47 |
+
hdfeos5: '5.1'
|
| 48 |
+
icu: '73'
|
| 49 |
+
ignore_build_only_deps:
|
| 50 |
+
- numpy
|
| 51 |
+
- python
|
| 52 |
+
jpeg: '9'
|
| 53 |
+
libabseil: '20240116.2'
|
| 54 |
+
libcurl: 8.1.1
|
| 55 |
+
libdap4: '3.19'
|
| 56 |
+
libffi: '3.4'
|
| 57 |
+
libgd: 2.3.3
|
| 58 |
+
libgdal: 3.6.2
|
| 59 |
+
libgrpc: 1.62.2
|
| 60 |
+
libgsasl: '1.10'
|
| 61 |
+
libkml: '1.3'
|
| 62 |
+
libnetcdf: '4.8'
|
| 63 |
+
libpng: '1.6'
|
| 64 |
+
libprotobuf: 4.25.3
|
| 65 |
+
libtiff: 4.5.0
|
| 66 |
+
libwebp: 1.3.2
|
| 67 |
+
libxml2: '2.13'
|
| 68 |
+
libxslt: '1.1'
|
| 69 |
+
llvm_variant: llvm
|
| 70 |
+
lua: '5'
|
| 71 |
+
lzo: '2'
|
| 72 |
+
mkl: 2023.*
|
| 73 |
+
mpfr: '4'
|
| 74 |
+
numpy: '2.1'
|
| 75 |
+
openblas: 0.3.21
|
| 76 |
+
openjpeg: '2.3'
|
| 77 |
+
openssl: '3.0'
|
| 78 |
+
perl: '5.34'
|
| 79 |
+
pin_run_as_build:
|
| 80 |
+
python:
|
| 81 |
+
max_pin: x.x
|
| 82 |
+
min_pin: x.x
|
| 83 |
+
r-base:
|
| 84 |
+
max_pin: x.x
|
| 85 |
+
min_pin: x.x
|
| 86 |
+
libboost:
|
| 87 |
+
max_pin: x.x.x
|
| 88 |
+
pixman: '0.40'
|
| 89 |
+
proj: 9.3.1
|
| 90 |
+
proj4: 5.2.0
|
| 91 |
+
python: '3.13'
|
| 92 |
+
python_impl: cpython
|
| 93 |
+
python_implementation: cpython
|
| 94 |
+
r_base: '3.5'
|
| 95 |
+
r_implementation: r-base
|
| 96 |
+
r_version: 3.5.0
|
| 97 |
+
readline: '8.1'
|
| 98 |
+
rust_compiler: rust
|
| 99 |
+
rust_compiler_version: 1.71.1
|
| 100 |
+
sqlite: '3'
|
| 101 |
+
target_platform: linux-64
|
| 102 |
+
tk: '8.6'
|
| 103 |
+
xz: '5'
|
| 104 |
+
zip_keys:
|
| 105 |
+
- - python
|
| 106 |
+
- numpy
|
| 107 |
+
zlib: '1.2'
|
| 108 |
+
zstd: 1.5.2
|
miniconda3/pkgs/distro-1.9.0-py313h06a4308_0/info/recipe/meta.yaml
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# This file created by conda-build 24.1.2
|
| 2 |
+
# meta.yaml template originally from:
|
| 3 |
+
# /work/perseverance-python-buildout/aggregate/distro-feedstock/recipe, last modified Tue Oct 8 10:19:18 2024
|
| 4 |
+
# ------------------------------------------------
|
| 5 |
+
|
| 6 |
+
package:
|
| 7 |
+
name: distro
|
| 8 |
+
version: 1.9.0
|
| 9 |
+
source:
|
| 10 |
+
fn: distro-1.9.0.tar.gz
|
| 11 |
+
sha256: 2fa77c6fd8940f116ee1d6b94a2f90b13b5ea8d019b98bc8bafdcabcdd9bdbed
|
| 12 |
+
url: https://pypi.io/packages/source/d/distro/distro-1.9.0.tar.gz
|
| 13 |
+
build:
|
| 14 |
+
entry_points:
|
| 15 |
+
- distro = distro.distro:main
|
| 16 |
+
number: '0'
|
| 17 |
+
script: /work/perseverance-python-buildout/croot/distro_1728396110052/_h_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placeh/bin/python
|
| 18 |
+
-m pip install . --no-deps --ignore-installed --no-cache-dir -v --no-build-isolation
|
| 19 |
+
string: py313h06a4308_0
|
| 20 |
+
requirements:
|
| 21 |
+
host:
|
| 22 |
+
- _libgcc_mutex 0.1 main
|
| 23 |
+
- _openmp_mutex 5.1 1_gnu
|
| 24 |
+
- bzip2 1.0.8 h5eee18b_6
|
| 25 |
+
- ca-certificates 2024.9.24 h06a4308_0
|
| 26 |
+
- expat 2.6.3 h6a678d5_0
|
| 27 |
+
- ld_impl_linux-64 2.40 h12ee557_0
|
| 28 |
+
- libffi 3.4.4 h6a678d5_1
|
| 29 |
+
- libgcc-ng 11.2.0 h1234567_1
|
| 30 |
+
- libgomp 11.2.0 h1234567_1
|
| 31 |
+
- libmpdec 4.0.0 h5eee18b_0
|
| 32 |
+
- libstdcxx-ng 11.2.0 h1234567_1
|
| 33 |
+
- libuuid 1.41.5 h5eee18b_0
|
| 34 |
+
- ncurses 6.4 h6a678d5_0
|
| 35 |
+
- openssl 3.0.15 h5eee18b_0
|
| 36 |
+
- pip 24.2 py313h06a4308_0
|
| 37 |
+
- python 3.13.0 hf623796_100_cp313
|
| 38 |
+
- python_abi 3.13 0_cp313
|
| 39 |
+
- readline 8.2 h5eee18b_0
|
| 40 |
+
- setuptools 75.1.0 py313h06a4308_0
|
| 41 |
+
- sqlite 3.45.3 h5eee18b_0
|
| 42 |
+
- tk 8.6.14 h39e8969_0
|
| 43 |
+
- tzdata 2024b h04d1e81_0
|
| 44 |
+
- wheel 0.37.1 pyhd3eb1b0_0
|
| 45 |
+
- xz 5.4.6 h5eee18b_1
|
| 46 |
+
- zlib 1.2.13 h5eee18b_1
|
| 47 |
+
run:
|
| 48 |
+
- python >=3.13,<3.14.0a0
|
| 49 |
+
- python_abi 3.13.* *_cp313
|
| 50 |
+
test:
|
| 51 |
+
commands:
|
| 52 |
+
- pip check
|
| 53 |
+
- distro --help
|
| 54 |
+
imports:
|
| 55 |
+
- distro
|
| 56 |
+
requires:
|
| 57 |
+
- pip
|
| 58 |
+
about:
|
| 59 |
+
description: distro provides information about the OS distribution it runs on, such
|
| 60 |
+
as a reliable machine-readable ID, or version information.
|
| 61 |
+
dev_url: https://github.com/python-distro/distro
|
| 62 |
+
doc_url: https://distro.readthedocs.io
|
| 63 |
+
home: https://github.com/python-distro/distro
|
| 64 |
+
license: Apache-2.0
|
| 65 |
+
license_family: Apache
|
| 66 |
+
license_file: LICENSE
|
| 67 |
+
summary: A much more elaborate replacement for removed Python's 'platform.linux_distribution()'
|
| 68 |
+
method
|
| 69 |
+
extra:
|
| 70 |
+
copy_test_source_files: true
|
| 71 |
+
final: true
|
| 72 |
+
recipe-maintainers:
|
| 73 |
+
- abloemert
|
| 74 |
+
- windelbouwman
|
miniconda3/pkgs/distro-1.9.0-py313h06a4308_0/info/recipe/meta.yaml.template
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{% set name = "distro" %}
|
| 2 |
+
{% set version = "1.9.0" %}
|
| 3 |
+
{% set sha256 = "2fa77c6fd8940f116ee1d6b94a2f90b13b5ea8d019b98bc8bafdcabcdd9bdbed" %}
|
| 4 |
+
|
| 5 |
+
package:
|
| 6 |
+
name: {{ name|lower }}
|
| 7 |
+
version: {{ version }}
|
| 8 |
+
|
| 9 |
+
source:
|
| 10 |
+
fn: {{ name }}-{{ version }}.tar.gz
|
| 11 |
+
url: https://pypi.io/packages/source/{{ name[0] }}/{{ name }}/{{ name }}-{{ version }}.tar.gz
|
| 12 |
+
sha256: {{ sha256 }}
|
| 13 |
+
|
| 14 |
+
build:
|
| 15 |
+
number: 0
|
| 16 |
+
entry_points:
|
| 17 |
+
- distro = distro.distro:main
|
| 18 |
+
skip: true # [py<36]
|
| 19 |
+
script: {{ PYTHON }} -m pip install . --no-deps --ignore-installed --no-cache-dir -v --no-build-isolation
|
| 20 |
+
|
| 21 |
+
requirements:
|
| 22 |
+
host:
|
| 23 |
+
- python
|
| 24 |
+
- pip
|
| 25 |
+
- setuptools
|
| 26 |
+
- wheel
|
| 27 |
+
run:
|
| 28 |
+
- python
|
| 29 |
+
|
| 30 |
+
test:
|
| 31 |
+
requires:
|
| 32 |
+
- pip
|
| 33 |
+
commands:
|
| 34 |
+
- pip check
|
| 35 |
+
- distro --help
|
| 36 |
+
imports:
|
| 37 |
+
- distro
|
| 38 |
+
|
| 39 |
+
about:
|
| 40 |
+
home: https://github.com/python-distro/distro
|
| 41 |
+
license: Apache-2.0
|
| 42 |
+
license_family: Apache
|
| 43 |
+
license_file: LICENSE
|
| 44 |
+
summary: A much more elaborate replacement for removed Python's 'platform.linux_distribution()' method
|
| 45 |
+
description: distro provides information about the OS distribution it runs on, such as a reliable machine-readable ID, or version information.
|
| 46 |
+
doc_url: https://distro.readthedocs.io
|
| 47 |
+
dev_url: https://github.com/python-distro/distro
|
| 48 |
+
|
| 49 |
+
extra:
|
| 50 |
+
recipe-maintainers:
|
| 51 |
+
- windelbouwman
|
| 52 |
+
- abloemert
|
miniconda3/pkgs/distro-1.9.0-py313h06a4308_0/info/repodata_record.json
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"arch": "x86_64",
|
| 3 |
+
"build": "py313h06a4308_0",
|
| 4 |
+
"build_number": 0,
|
| 5 |
+
"channel": "https://repo.anaconda.com/pkgs/main/linux-64/",
|
| 6 |
+
"constrains": [],
|
| 7 |
+
"depends": [
|
| 8 |
+
"python >=3.13,<3.14.0a0",
|
| 9 |
+
"python_abi 3.13.* *_cp313"
|
| 10 |
+
],
|
| 11 |
+
"fn": "distro-1.9.0-py313h06a4308_0.conda",
|
| 12 |
+
"license": "Apache-2.0",
|
| 13 |
+
"license_family": "Apache",
|
| 14 |
+
"md5": "1fd7ab065e9958e7bbd4d3fbf175742b",
|
| 15 |
+
"name": "distro",
|
| 16 |
+
"platform": "linux",
|
| 17 |
+
"sha256": "57e25d204f2e891ab2f68a776b9e21cc681adfe089ea35a18aa05e5aa950a4c7",
|
| 18 |
+
"size": 37917,
|
| 19 |
+
"subdir": "linux-64",
|
| 20 |
+
"timestamp": 1728396132000,
|
| 21 |
+
"url": "https://repo.anaconda.com/pkgs/main/linux-64/distro-1.9.0-py313h06a4308_0.conda",
|
| 22 |
+
"version": "1.9.0"
|
| 23 |
+
}
|
miniconda3/pkgs/distro-1.9.0-py313h06a4308_0/info/test/run_test.py
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
print("import: 'distro'")
|
| 2 |
+
import distro
|
| 3 |
+
|
miniconda3/pkgs/distro-1.9.0-py313h06a4308_0/info/test/run_test.sh
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
|
| 3 |
+
set -ex
|
| 4 |
+
|
| 5 |
+
|
| 6 |
+
|
| 7 |
+
pip check
|
| 8 |
+
distro --help
|
| 9 |
+
exit 0
|
miniconda3/pkgs/distro-1.9.0-py313h06a4308_0/info/test/test_time_dependencies.json
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
["pip"]
|
miniconda3/pkgs/distro-1.9.0-py313h06a4308_0/lib/python3.13/site-packages/distro-1.9.0.dist-info/INSTALLER
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
conda
|
miniconda3/pkgs/distro-1.9.0-py313h06a4308_0/lib/python3.13/site-packages/distro-1.9.0.dist-info/LICENSE
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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+
"License" shall mean the terms and conditions for use, reproduction,
|
| 10 |
+
and distribution as defined by Sections 1 through 9 of this document.
|
| 11 |
+
|
| 12 |
+
"Licensor" shall mean the copyright owner or entity authorized by
|
| 13 |
+
the copyright owner that is granting the License.
|
| 14 |
+
|
| 15 |
+
"Legal Entity" shall mean the union of the acting entity and all
|
| 16 |
+
other entities that control, are controlled by, or are under common
|
| 17 |
+
control with that entity. For the purposes of this definition,
|
| 18 |
+
"control" means (i) the power, direct or indirect, to cause the
|
| 19 |
+
direction or management of such entity, whether by contract or
|
| 20 |
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
| 21 |
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
| 22 |
+
|
| 23 |
+
"You" (or "Your") shall mean an individual or Legal Entity
|
| 24 |
+
exercising permissions granted by this License.
|
| 25 |
+
|
| 26 |
+
"Source" form shall mean the preferred form for making modifications,
|
| 27 |
+
including but not limited to software source code, documentation
|
| 28 |
+
source, and configuration files.
|
| 29 |
+
|
| 30 |
+
"Object" form shall mean any form resulting from mechanical
|
| 31 |
+
transformation or translation of a Source form, including but
|
| 32 |
+
not limited to compiled object code, generated documentation,
|
| 33 |
+
and conversions to other media types.
|
| 34 |
+
|
| 35 |
+
"Work" shall mean the work of authorship, whether in Source or
|
| 36 |
+
Object form, made available under the License, as indicated by a
|
| 37 |
+
copyright notice that is included in or attached to the work
|
| 38 |
+
(an example is provided in the Appendix below).
|
| 39 |
+
|
| 40 |
+
"Derivative Works" shall mean any work, whether in Source or Object
|
| 41 |
+
form, that is based on (or derived from) the Work and for which the
|
| 42 |
+
editorial revisions, annotations, elaborations, or other modifications
|
| 43 |
+
represent, as a whole, an original work of authorship. For the purposes
|
| 44 |
+
of this License, Derivative Works shall not include works that remain
|
| 45 |
+
separable from, or merely link (or bind by name) to the interfaces of,
|
| 46 |
+
the Work and Derivative Works thereof.
|
| 47 |
+
|
| 48 |
+
"Contribution" shall mean any work of authorship, including
|
| 49 |
+
the original version of the Work and any modifications or additions
|
| 50 |
+
to that Work or Derivative Works thereof, that is intentionally
|
| 51 |
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
| 52 |
+
or by an individual or Legal Entity authorized to submit on behalf of
|
| 53 |
+
the copyright owner. For the purposes of this definition, "submitted"
|
| 54 |
+
means any form of electronic, verbal, or written communication sent
|
| 55 |
+
to the Licensor or its representatives, including but not limited to
|
| 56 |
+
communication on electronic mailing lists, source code control systems,
|
| 57 |
+
and issue tracking systems that are managed by, or on behalf of, the
|
| 58 |
+
Licensor for the purpose of discussing and improving the Work, but
|
| 59 |
+
excluding communication that is conspicuously marked or otherwise
|
| 60 |
+
designated in writing by the copyright owner as "Not a Contribution."
|
| 61 |
+
|
| 62 |
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
| 63 |
+
on behalf of whom a Contribution has been received by Licensor and
|
| 64 |
+
subsequently incorporated within the Work.
|
| 65 |
+
|
| 66 |
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
| 67 |
+
this License, each Contributor hereby grants to You a perpetual,
|
| 68 |
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
| 69 |
+
copyright license to reproduce, prepare Derivative Works of,
|
| 70 |
+
publicly display, publicly perform, sublicense, and distribute the
|
| 71 |
+
Work and such Derivative Works in Source or Object form.
|
| 72 |
+
|
| 73 |
+
3. Grant of Patent License. Subject to the terms and conditions of
|
| 74 |
+
this License, each Contributor hereby grants to You a perpetual,
|
| 75 |
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
| 76 |
+
(except as stated in this section) patent license to make, have made,
|
| 77 |
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
| 78 |
+
where such license applies only to those patent claims licensable
|
| 79 |
+
by such Contributor that are necessarily infringed by their
|
| 80 |
+
Contribution(s) alone or by combination of their Contribution(s)
|
| 81 |
+
with the Work to which such Contribution(s) was submitted. If You
|
| 82 |
+
institute patent litigation against any entity (including a
|
| 83 |
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
| 84 |
+
or a Contribution incorporated within the Work constitutes direct
|
| 85 |
+
or contributory patent infringement, then any patent licenses
|
| 86 |
+
granted to You under this License for that Work shall terminate
|
| 87 |
+
as of the date such litigation is filed.
|
| 88 |
+
|
| 89 |
+
4. Redistribution. You may reproduce and distribute copies of the
|
| 90 |
+
Work or Derivative Works thereof in any medium, with or without
|
| 91 |
+
modifications, and in Source or Object form, provided that You
|
| 92 |
+
meet the following conditions:
|
| 93 |
+
|
| 94 |
+
(a) You must give any other recipients of the Work or
|
| 95 |
+
Derivative Works a copy of this License; and
|
| 96 |
+
|
| 97 |
+
(b) You must cause any modified files to carry prominent notices
|
| 98 |
+
stating that You changed the files; and
|
| 99 |
+
|
| 100 |
+
(c) You must retain, in the Source form of any Derivative Works
|
| 101 |
+
that You distribute, all copyright, patent, trademark, and
|
| 102 |
+
attribution notices from the Source form of the Work,
|
| 103 |
+
excluding those notices that do not pertain to any part of
|
| 104 |
+
the Derivative Works; and
|
| 105 |
+
|
| 106 |
+
(d) If the Work includes a "NOTICE" text file as part of its
|
| 107 |
+
distribution, then any Derivative Works that You distribute must
|
| 108 |
+
include a readable copy of the attribution notices contained
|
| 109 |
+
within such NOTICE file, excluding those notices that do not
|
| 110 |
+
pertain to any part of the Derivative Works, in at least one
|
| 111 |
+
of the following places: within a NOTICE text file distributed
|
| 112 |
+
as part of the Derivative Works; within the Source form or
|
| 113 |
+
documentation, if provided along with the Derivative Works; or,
|
| 114 |
+
within a display generated by the Derivative Works, if and
|
| 115 |
+
wherever such third-party notices normally appear. The contents
|
| 116 |
+
of the NOTICE file are for informational purposes only and
|
| 117 |
+
do not modify the License. You may add Your own attribution
|
| 118 |
+
notices within Derivative Works that You distribute, alongside
|
| 119 |
+
or as an addendum to the NOTICE text from the Work, provided
|
| 120 |
+
that such additional attribution notices cannot be construed
|
| 121 |
+
as modifying the License.
|
| 122 |
+
|
| 123 |
+
You may add Your own copyright statement to Your modifications and
|
| 124 |
+
may provide additional or different license terms and conditions
|
| 125 |
+
for use, reproduction, or distribution of Your modifications, or
|
| 126 |
+
for any such Derivative Works as a whole, provided Your use,
|
| 127 |
+
reproduction, and distribution of the Work otherwise complies with
|
| 128 |
+
the conditions stated in this License.
|
| 129 |
+
|
| 130 |
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
| 131 |
+
any Contribution intentionally submitted for inclusion in the Work
|
| 132 |
+
by You to the Licensor shall be under the terms and conditions of
|
| 133 |
+
this License, without any additional terms or conditions.
|
| 134 |
+
Notwithstanding the above, nothing herein shall supersede or modify
|
| 135 |
+
the terms of any separate license agreement you may have executed
|
| 136 |
+
with Licensor regarding such Contributions.
|
| 137 |
+
|
| 138 |
+
6. Trademarks. This License does not grant permission to use the trade
|
| 139 |
+
names, trademarks, service marks, or product names of the Licensor,
|
| 140 |
+
except as required for reasonable and customary use in describing the
|
| 141 |
+
origin of the Work and reproducing the content of the NOTICE file.
|
| 142 |
+
|
| 143 |
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
| 144 |
+
agreed to in writing, Licensor provides the Work (and each
|
| 145 |
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
| 146 |
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
| 147 |
+
implied, including, without limitation, any warranties or conditions
|
| 148 |
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
| 149 |
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
| 150 |
+
appropriateness of using or redistributing the Work and assume any
|
| 151 |
+
risks associated with Your exercise of permissions under this License.
|
| 152 |
+
|
| 153 |
+
8. Limitation of Liability. In no event and under no legal theory,
|
| 154 |
+
whether in tort (including negligence), contract, or otherwise,
|
| 155 |
+
unless required by applicable law (such as deliberate and grossly
|
| 156 |
+
negligent acts) or agreed to in writing, shall any Contributor be
|
| 157 |
+
liable to You for damages, including any direct, indirect, special,
|
| 158 |
+
incidental, or consequential damages of any character arising as a
|
| 159 |
+
result of this License or out of the use or inability to use the
|
| 160 |
+
Work (including but not limited to damages for loss of goodwill,
|
| 161 |
+
work stoppage, computer failure or malfunction, or any and all
|
| 162 |
+
other commercial damages or losses), even if such Contributor
|
| 163 |
+
has been advised of the possibility of such damages.
|
| 164 |
+
|
| 165 |
+
9. Accepting Warranty or Additional Liability. While redistributing
|
| 166 |
+
the Work or Derivative Works thereof, You may choose to offer,
|
| 167 |
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
| 168 |
+
or other liability obligations and/or rights consistent with this
|
| 169 |
+
License. However, in accepting such obligations, You may act only
|
| 170 |
+
on Your own behalf and on Your sole responsibility, not on behalf
|
| 171 |
+
of any other Contributor, and only if You agree to indemnify,
|
| 172 |
+
defend, and hold each Contributor harmless for any liability
|
| 173 |
+
incurred by, or claims asserted against, such Contributor by reason
|
| 174 |
+
of your accepting any such warranty or additional liability.
|
| 175 |
+
|
| 176 |
+
END OF TERMS AND CONDITIONS
|
| 177 |
+
|
| 178 |
+
APPENDIX: How to apply the Apache License to your work.
|
| 179 |
+
|
| 180 |
+
To apply the Apache License to your work, attach the following
|
| 181 |
+
boilerplate notice, with the fields enclosed by brackets "{}"
|
| 182 |
+
replaced with your own identifying information. (Don't include
|
| 183 |
+
the brackets!) The text should be enclosed in the appropriate
|
| 184 |
+
comment syntax for the file format. We also recommend that a
|
| 185 |
+
file or class name and description of purpose be included on the
|
| 186 |
+
same "printed page" as the copyright notice for easier
|
| 187 |
+
identification within third-party archives.
|
| 188 |
+
|
| 189 |
+
Copyright {yyyy} {name of copyright owner}
|
| 190 |
+
|
| 191 |
+
Licensed under the Apache License, Version 2.0 (the "License");
|
| 192 |
+
you may not use this file except in compliance with the License.
|
| 193 |
+
You may obtain a copy of the License at
|
| 194 |
+
|
| 195 |
+
http://www.apache.org/licenses/LICENSE-2.0
|
| 196 |
+
|
| 197 |
+
Unless required by applicable law or agreed to in writing, software
|
| 198 |
+
distributed under the License is distributed on an "AS IS" BASIS,
|
| 199 |
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 200 |
+
See the License for the specific language governing permissions and
|
| 201 |
+
limitations under the License.
|
| 202 |
+
|
miniconda3/pkgs/distro-1.9.0-py313h06a4308_0/lib/python3.13/site-packages/distro-1.9.0.dist-info/METADATA
ADDED
|
@@ -0,0 +1,184 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
Metadata-Version: 2.1
|
| 2 |
+
Name: distro
|
| 3 |
+
Version: 1.9.0
|
| 4 |
+
Summary: Distro - an OS platform information API
|
| 5 |
+
Home-page: https://github.com/python-distro/distro
|
| 6 |
+
Author: Nir Cohen
|
| 7 |
+
Author-email: nir36g@gmail.com
|
| 8 |
+
License: Apache License, Version 2.0
|
| 9 |
+
Platform: All
|
| 10 |
+
Classifier: Development Status :: 5 - Production/Stable
|
| 11 |
+
Classifier: Intended Audience :: Developers
|
| 12 |
+
Classifier: Intended Audience :: System Administrators
|
| 13 |
+
Classifier: License :: OSI Approved :: Apache Software License
|
| 14 |
+
Classifier: Operating System :: POSIX :: Linux
|
| 15 |
+
Classifier: Operating System :: POSIX :: BSD
|
| 16 |
+
Classifier: Operating System :: POSIX :: BSD :: FreeBSD
|
| 17 |
+
Classifier: Operating System :: POSIX :: BSD :: NetBSD
|
| 18 |
+
Classifier: Operating System :: POSIX :: BSD :: OpenBSD
|
| 19 |
+
Classifier: Programming Language :: Python :: 3
|
| 20 |
+
Classifier: Programming Language :: Python :: 3 :: Only
|
| 21 |
+
Classifier: Programming Language :: Python :: 3.6
|
| 22 |
+
Classifier: Programming Language :: Python :: 3.7
|
| 23 |
+
Classifier: Programming Language :: Python :: 3.8
|
| 24 |
+
Classifier: Programming Language :: Python :: 3.9
|
| 25 |
+
Classifier: Programming Language :: Python :: 3.10
|
| 26 |
+
Classifier: Programming Language :: Python :: 3.11
|
| 27 |
+
Classifier: Programming Language :: Python :: 3.12
|
| 28 |
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
| 29 |
+
Classifier: Topic :: System :: Operating System
|
| 30 |
+
Requires-Python: >=3.6
|
| 31 |
+
Description-Content-Type: text/markdown
|
| 32 |
+
License-File: LICENSE
|
| 33 |
+
|
| 34 |
+
Distro - an OS platform information API
|
| 35 |
+
=======================================
|
| 36 |
+
|
| 37 |
+
[](https://github.com/python-distro/distro/actions/workflows/ci.yaml)
|
| 38 |
+
[](https://pypi.python.org/pypi/distro)
|
| 39 |
+
[](https://img.shields.io/pypi/pyversions/distro.svg)
|
| 40 |
+
[](https://codecov.io/github/python-distro/distro?branch=master)
|
| 41 |
+
[](https://pypi.python.org/pypi/distro)
|
| 42 |
+
[](http://distro.readthedocs.io/en/latest/)
|
| 43 |
+
|
| 44 |
+
`distro` provides information about the
|
| 45 |
+
OS distribution it runs on, such as a reliable machine-readable ID, or
|
| 46 |
+
version information.
|
| 47 |
+
|
| 48 |
+
It is the recommended replacement for Python's original
|
| 49 |
+
[`platform.linux_distribution`](https://docs.python.org/3.7/library/platform.html#platform.linux_distribution)
|
| 50 |
+
function (removed in Python 3.8). It also provides much more functionality
|
| 51 |
+
which isn't necessarily Python bound, like a command-line interface.
|
| 52 |
+
|
| 53 |
+
Distro currently supports Linux and BSD based systems but [Windows and OS X support](https://github.com/python-distro/distro/issues/177) is also planned.
|
| 54 |
+
|
| 55 |
+
For Python 2.6 support, see https://github.com/python-distro/distro/tree/python2.6-support
|
| 56 |
+
|
| 57 |
+
## Installation
|
| 58 |
+
|
| 59 |
+
Installation of the latest released version from PyPI:
|
| 60 |
+
|
| 61 |
+
```shell
|
| 62 |
+
pip install distro
|
| 63 |
+
```
|
| 64 |
+
|
| 65 |
+
Installation of the latest development version:
|
| 66 |
+
|
| 67 |
+
```shell
|
| 68 |
+
pip install https://github.com/python-distro/distro/archive/master.tar.gz
|
| 69 |
+
```
|
| 70 |
+
|
| 71 |
+
To use as a standalone script, download `distro.py` directly:
|
| 72 |
+
|
| 73 |
+
```shell
|
| 74 |
+
curl -O https://raw.githubusercontent.com/python-distro/distro/master/src/distro/distro.py
|
| 75 |
+
python distro.py
|
| 76 |
+
```
|
| 77 |
+
|
| 78 |
+
``distro`` is safe to vendor within projects that do not wish to add
|
| 79 |
+
dependencies.
|
| 80 |
+
|
| 81 |
+
```shell
|
| 82 |
+
cd myproject
|
| 83 |
+
curl -O https://raw.githubusercontent.com/python-distro/distro/master/src/distro/distro.py
|
| 84 |
+
```
|
| 85 |
+
|
| 86 |
+
## Usage
|
| 87 |
+
|
| 88 |
+
```bash
|
| 89 |
+
$ distro
|
| 90 |
+
Name: Antergos Linux
|
| 91 |
+
Version: 2015.10 (ISO-Rolling)
|
| 92 |
+
Codename: ISO-Rolling
|
| 93 |
+
|
| 94 |
+
$ distro -j
|
| 95 |
+
{
|
| 96 |
+
"codename": "ISO-Rolling",
|
| 97 |
+
"id": "antergos",
|
| 98 |
+
"like": "arch",
|
| 99 |
+
"version": "16.9",
|
| 100 |
+
"version_parts": {
|
| 101 |
+
"build_number": "",
|
| 102 |
+
"major": "16",
|
| 103 |
+
"minor": "9"
|
| 104 |
+
}
|
| 105 |
+
}
|
| 106 |
+
|
| 107 |
+
|
| 108 |
+
$ python
|
| 109 |
+
>>> import distro
|
| 110 |
+
>>> distro.name(pretty=True)
|
| 111 |
+
'CentOS Linux 8'
|
| 112 |
+
>>> distro.id()
|
| 113 |
+
'centos'
|
| 114 |
+
>>> distro.version(best=True)
|
| 115 |
+
'8.4.2105'
|
| 116 |
+
```
|
| 117 |
+
|
| 118 |
+
|
| 119 |
+
## Documentation
|
| 120 |
+
|
| 121 |
+
On top of the aforementioned API, several more functions are available. For a complete description of the
|
| 122 |
+
API, see the [latest API documentation](http://distro.readthedocs.org/en/latest/).
|
| 123 |
+
|
| 124 |
+
## Background
|
| 125 |
+
|
| 126 |
+
An alternative implementation became necessary because Python 3.5 deprecated
|
| 127 |
+
this function, and Python 3.8 removed it altogether. Its predecessor function
|
| 128 |
+
[`platform.dist`](https://docs.python.org/3.7/library/platform.html#platform.dist)
|
| 129 |
+
was already deprecated since Python 2.6 and removed in Python 3.8. Still, there
|
| 130 |
+
are many cases in which access to that information is needed. See [Python issue
|
| 131 |
+
1322](https://bugs.python.org/issue1322) for more information.
|
| 132 |
+
|
| 133 |
+
The `distro` package implements a robust and inclusive way of retrieving the
|
| 134 |
+
information about a distribution based on new standards and old methods,
|
| 135 |
+
namely from these data sources (from high to low precedence):
|
| 136 |
+
|
| 137 |
+
* The os-release file `/etc/os-release` if present, with a fall-back on `/usr/lib/os-release` if needed.
|
| 138 |
+
* The output of the `lsb_release` command, if available.
|
| 139 |
+
* The distro release file (`/etc/*(-|_)(release|version)`), if present.
|
| 140 |
+
* The `uname` command for BSD based distrubtions.
|
| 141 |
+
|
| 142 |
+
|
| 143 |
+
## Python and Distribution Support
|
| 144 |
+
|
| 145 |
+
`distro` is supported and tested on Python 3.6+ and PyPy and on any
|
| 146 |
+
distribution that provides one or more of the data sources covered.
|
| 147 |
+
|
| 148 |
+
This package is tested with test data that mimics the exact behavior of the data sources of [a number of Linux distributions](https://github.com/python-distro/distro/tree/master/tests/resources/distros).
|
| 149 |
+
|
| 150 |
+
|
| 151 |
+
## Testing
|
| 152 |
+
|
| 153 |
+
```shell
|
| 154 |
+
git clone git@github.com:python-distro/distro.git
|
| 155 |
+
cd distro
|
| 156 |
+
pip install tox
|
| 157 |
+
tox
|
| 158 |
+
```
|
| 159 |
+
|
| 160 |
+
|
| 161 |
+
## Contributions
|
| 162 |
+
|
| 163 |
+
Pull requests are always welcome to deal with specific distributions or just
|
| 164 |
+
for general merriment.
|
| 165 |
+
|
| 166 |
+
See [CONTRIBUTIONS](https://github.com/python-distro/distro/blob/master/CONTRIBUTING.md) for contribution info.
|
| 167 |
+
|
| 168 |
+
Reference implementations for supporting additional distributions and file
|
| 169 |
+
formats can be found here:
|
| 170 |
+
|
| 171 |
+
* https://github.com/saltstack/salt/blob/develop/salt/grains/core.py#L1172
|
| 172 |
+
* https://github.com/chef/ohai/blob/master/lib/ohai/plugins/linux/platform.rb
|
| 173 |
+
* https://github.com/ansible/ansible/blob/devel/lib/ansible/module_utils/facts/system/distribution.py
|
| 174 |
+
* https://github.com/puppetlabs/facter/blob/master/lib/src/facts/linux/os_linux.cc
|
| 175 |
+
|
| 176 |
+
## Package manager distributions
|
| 177 |
+
|
| 178 |
+
* https://src.fedoraproject.org/rpms/python-distro
|
| 179 |
+
* https://www.archlinux.org/packages/community/any/python-distro/
|
| 180 |
+
* https://launchpad.net/ubuntu/+source/python-distro
|
| 181 |
+
* https://packages.debian.org/stable/python3-distro
|
| 182 |
+
* https://packages.gentoo.org/packages/dev-python/distro
|
| 183 |
+
* https://pkgs.org/download/python3-distro
|
| 184 |
+
* https://slackbuilds.org/repository/14.2/python/python-distro/
|
miniconda3/pkgs/distro-1.9.0-py313h06a4308_0/lib/python3.13/site-packages/distro-1.9.0.dist-info/RECORD
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
../../../bin/distro,sha256=UXHAfdR5VOlXREzwoBb38jxyioPsouDus76jK9wirJE,495
|
| 2 |
+
distro-1.9.0.dist-info/INSTALLER,sha256=zuuue4knoyJ-UwPPXg8fezS7VCrXJQrAP7zeNuwvFQg,4
|
| 3 |
+
distro-1.9.0.dist-info/LICENSE,sha256=y16Ofl9KOYjhBjwULGDcLfdWBfTEZRXnduOspt-XbhQ,11325
|
| 4 |
+
distro-1.9.0.dist-info/METADATA,sha256=MWMqst5VkRMQkbM5e9zfeXcYV52Fp1GG8Gg53QwJ6B0,6791
|
| 5 |
+
distro-1.9.0.dist-info/RECORD,,
|
| 6 |
+
distro-1.9.0.dist-info/REQUESTED,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
| 7 |
+
distro-1.9.0.dist-info/WHEEL,sha256=GV9aMThwP_4oNCtvEC2ec3qUYutgWeAzklro_0m4WJQ,91
|
| 8 |
+
distro-1.9.0.dist-info/direct_url.json,sha256=u3FlFQsIO8Rxq8jpvPbQopzhcCtbbHf3JWxsngU0NR4,100
|
| 9 |
+
distro-1.9.0.dist-info/entry_points.txt,sha256=3ObjqQMbh1xeQQwsWtgbfDNDMDD-EbggR1Oj_z8s9hc,46
|
| 10 |
+
distro-1.9.0.dist-info/top_level.txt,sha256=ikde_V_XEdSBqaGd5tEriN_wzYHLgTX_zVtlsGLHvwQ,7
|
| 11 |
+
distro/__init__.py,sha256=2fHjF-SfgPvjyNZ1iHh_wjqWdR_Yo5ODHwZC0jLBPhc,981
|
| 12 |
+
distro/__main__.py,sha256=bu9d3TifoKciZFcqRBuygV3GSuThnVD_m2IK4cz96Vs,64
|
| 13 |
+
distro/__pycache__/__init__.cpython-313.pyc,,
|
| 14 |
+
distro/__pycache__/__main__.cpython-313.pyc,,
|
| 15 |
+
distro/__pycache__/distro.cpython-313.pyc,,
|
| 16 |
+
distro/distro.py,sha256=XqbefacAhDT4zr_trnbA15eY8vdK4GTghgmvUGrEM_4,49430
|
| 17 |
+
distro/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
miniconda3/pkgs/distro-1.9.0-py313h06a4308_0/lib/python3.13/site-packages/distro-1.9.0.dist-info/REQUESTED
ADDED
|
File without changes
|
miniconda3/pkgs/distro-1.9.0-py313h06a4308_0/lib/python3.13/site-packages/distro-1.9.0.dist-info/WHEEL
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
Wheel-Version: 1.0
|
| 2 |
+
Generator: setuptools (75.1.0)
|
| 3 |
+
Root-Is-Purelib: true
|
| 4 |
+
Tag: py3-none-any
|
| 5 |
+
|
miniconda3/pkgs/distro-1.9.0-py313h06a4308_0/lib/python3.13/site-packages/distro-1.9.0.dist-info/direct_url.json
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"dir_info": {}, "url": "file:///work/perseverance-python-buildout/croot/distro_1728396110052/work"}
|
miniconda3/pkgs/distro-1.9.0-py313h06a4308_0/lib/python3.13/site-packages/distro-1.9.0.dist-info/entry_points.txt
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
|
|
|
| 1 |
+
[console_scripts]
|
| 2 |
+
distro = distro.distro:main
|
miniconda3/pkgs/distro-1.9.0-py313h06a4308_0/lib/python3.13/site-packages/distro-1.9.0.dist-info/top_level.txt
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
distro
|
miniconda3/pkgs/distro-1.9.0-py313h06a4308_0/lib/python3.13/site-packages/distro/__init__.py
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from .distro import (
|
| 2 |
+
NORMALIZED_DISTRO_ID,
|
| 3 |
+
NORMALIZED_LSB_ID,
|
| 4 |
+
NORMALIZED_OS_ID,
|
| 5 |
+
LinuxDistribution,
|
| 6 |
+
__version__,
|
| 7 |
+
build_number,
|
| 8 |
+
codename,
|
| 9 |
+
distro_release_attr,
|
| 10 |
+
distro_release_info,
|
| 11 |
+
id,
|
| 12 |
+
info,
|
| 13 |
+
like,
|
| 14 |
+
linux_distribution,
|
| 15 |
+
lsb_release_attr,
|
| 16 |
+
lsb_release_info,
|
| 17 |
+
major_version,
|
| 18 |
+
minor_version,
|
| 19 |
+
name,
|
| 20 |
+
os_release_attr,
|
| 21 |
+
os_release_info,
|
| 22 |
+
uname_attr,
|
| 23 |
+
uname_info,
|
| 24 |
+
version,
|
| 25 |
+
version_parts,
|
| 26 |
+
)
|
| 27 |
+
|
| 28 |
+
__all__ = [
|
| 29 |
+
"NORMALIZED_DISTRO_ID",
|
| 30 |
+
"NORMALIZED_LSB_ID",
|
| 31 |
+
"NORMALIZED_OS_ID",
|
| 32 |
+
"LinuxDistribution",
|
| 33 |
+
"build_number",
|
| 34 |
+
"codename",
|
| 35 |
+
"distro_release_attr",
|
| 36 |
+
"distro_release_info",
|
| 37 |
+
"id",
|
| 38 |
+
"info",
|
| 39 |
+
"like",
|
| 40 |
+
"linux_distribution",
|
| 41 |
+
"lsb_release_attr",
|
| 42 |
+
"lsb_release_info",
|
| 43 |
+
"major_version",
|
| 44 |
+
"minor_version",
|
| 45 |
+
"name",
|
| 46 |
+
"os_release_attr",
|
| 47 |
+
"os_release_info",
|
| 48 |
+
"uname_attr",
|
| 49 |
+
"uname_info",
|
| 50 |
+
"version",
|
| 51 |
+
"version_parts",
|
| 52 |
+
]
|
| 53 |
+
|
| 54 |
+
__version__ = __version__
|
miniconda3/pkgs/distro-1.9.0-py313h06a4308_0/lib/python3.13/site-packages/distro/__main__.py
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from .distro import main
|
| 2 |
+
|
| 3 |
+
if __name__ == "__main__":
|
| 4 |
+
main()
|
miniconda3/pkgs/distro-1.9.0-py313h06a4308_0/lib/python3.13/site-packages/distro/distro.py
ADDED
|
@@ -0,0 +1,1403 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env python
|
| 2 |
+
# Copyright 2015-2021 Nir Cohen
|
| 3 |
+
#
|
| 4 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
| 5 |
+
# you may not use this file except in compliance with the License.
|
| 6 |
+
# You may obtain a copy of the License at
|
| 7 |
+
#
|
| 8 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
| 9 |
+
#
|
| 10 |
+
# Unless required by applicable law or agreed to in writing, software
|
| 11 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
| 12 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 13 |
+
# See the License for the specific language governing permissions and
|
| 14 |
+
# limitations under the License.
|
| 15 |
+
|
| 16 |
+
"""
|
| 17 |
+
The ``distro`` package (``distro`` stands for Linux Distribution) provides
|
| 18 |
+
information about the Linux distribution it runs on, such as a reliable
|
| 19 |
+
machine-readable distro ID, or version information.
|
| 20 |
+
|
| 21 |
+
It is the recommended replacement for Python's original
|
| 22 |
+
:py:func:`platform.linux_distribution` function, but it provides much more
|
| 23 |
+
functionality. An alternative implementation became necessary because Python
|
| 24 |
+
3.5 deprecated this function, and Python 3.8 removed it altogether. Its
|
| 25 |
+
predecessor function :py:func:`platform.dist` was already deprecated since
|
| 26 |
+
Python 2.6 and removed in Python 3.8. Still, there are many cases in which
|
| 27 |
+
access to OS distribution information is needed. See `Python issue 1322
|
| 28 |
+
<https://bugs.python.org/issue1322>`_ for more information.
|
| 29 |
+
"""
|
| 30 |
+
|
| 31 |
+
import argparse
|
| 32 |
+
import json
|
| 33 |
+
import logging
|
| 34 |
+
import os
|
| 35 |
+
import re
|
| 36 |
+
import shlex
|
| 37 |
+
import subprocess
|
| 38 |
+
import sys
|
| 39 |
+
import warnings
|
| 40 |
+
from typing import (
|
| 41 |
+
Any,
|
| 42 |
+
Callable,
|
| 43 |
+
Dict,
|
| 44 |
+
Iterable,
|
| 45 |
+
Optional,
|
| 46 |
+
Sequence,
|
| 47 |
+
TextIO,
|
| 48 |
+
Tuple,
|
| 49 |
+
Type,
|
| 50 |
+
)
|
| 51 |
+
|
| 52 |
+
try:
|
| 53 |
+
from typing import TypedDict
|
| 54 |
+
except ImportError:
|
| 55 |
+
# Python 3.7
|
| 56 |
+
TypedDict = dict
|
| 57 |
+
|
| 58 |
+
__version__ = "1.9.0"
|
| 59 |
+
|
| 60 |
+
|
| 61 |
+
class VersionDict(TypedDict):
|
| 62 |
+
major: str
|
| 63 |
+
minor: str
|
| 64 |
+
build_number: str
|
| 65 |
+
|
| 66 |
+
|
| 67 |
+
class InfoDict(TypedDict):
|
| 68 |
+
id: str
|
| 69 |
+
version: str
|
| 70 |
+
version_parts: VersionDict
|
| 71 |
+
like: str
|
| 72 |
+
codename: str
|
| 73 |
+
|
| 74 |
+
|
| 75 |
+
_UNIXCONFDIR = os.environ.get("UNIXCONFDIR", "/etc")
|
| 76 |
+
_UNIXUSRLIBDIR = os.environ.get("UNIXUSRLIBDIR", "/usr/lib")
|
| 77 |
+
_OS_RELEASE_BASENAME = "os-release"
|
| 78 |
+
|
| 79 |
+
#: Translation table for normalizing the "ID" attribute defined in os-release
|
| 80 |
+
#: files, for use by the :func:`distro.id` method.
|
| 81 |
+
#:
|
| 82 |
+
#: * Key: Value as defined in the os-release file, translated to lower case,
|
| 83 |
+
#: with blanks translated to underscores.
|
| 84 |
+
#:
|
| 85 |
+
#: * Value: Normalized value.
|
| 86 |
+
NORMALIZED_OS_ID = {
|
| 87 |
+
"ol": "oracle", # Oracle Linux
|
| 88 |
+
"opensuse-leap": "opensuse", # Newer versions of OpenSuSE report as opensuse-leap
|
| 89 |
+
}
|
| 90 |
+
|
| 91 |
+
#: Translation table for normalizing the "Distributor ID" attribute returned by
|
| 92 |
+
#: the lsb_release command, for use by the :func:`distro.id` method.
|
| 93 |
+
#:
|
| 94 |
+
#: * Key: Value as returned by the lsb_release command, translated to lower
|
| 95 |
+
#: case, with blanks translated to underscores.
|
| 96 |
+
#:
|
| 97 |
+
#: * Value: Normalized value.
|
| 98 |
+
NORMALIZED_LSB_ID = {
|
| 99 |
+
"enterpriseenterpriseas": "oracle", # Oracle Enterprise Linux 4
|
| 100 |
+
"enterpriseenterpriseserver": "oracle", # Oracle Linux 5
|
| 101 |
+
"redhatenterpriseworkstation": "rhel", # RHEL 6, 7 Workstation
|
| 102 |
+
"redhatenterpriseserver": "rhel", # RHEL 6, 7 Server
|
| 103 |
+
"redhatenterprisecomputenode": "rhel", # RHEL 6 ComputeNode
|
| 104 |
+
}
|
| 105 |
+
|
| 106 |
+
#: Translation table for normalizing the distro ID derived from the file name
|
| 107 |
+
#: of distro release files, for use by the :func:`distro.id` method.
|
| 108 |
+
#:
|
| 109 |
+
#: * Key: Value as derived from the file name of a distro release file,
|
| 110 |
+
#: translated to lower case, with blanks translated to underscores.
|
| 111 |
+
#:
|
| 112 |
+
#: * Value: Normalized value.
|
| 113 |
+
NORMALIZED_DISTRO_ID = {
|
| 114 |
+
"redhat": "rhel", # RHEL 6.x, 7.x
|
| 115 |
+
}
|
| 116 |
+
|
| 117 |
+
# Pattern for content of distro release file (reversed)
|
| 118 |
+
_DISTRO_RELEASE_CONTENT_REVERSED_PATTERN = re.compile(
|
| 119 |
+
r"(?:[^)]*\)(.*)\()? *(?:STL )?([\d.+\-a-z]*\d) *(?:esaeler *)?(.+)"
|
| 120 |
+
)
|
| 121 |
+
|
| 122 |
+
# Pattern for base file name of distro release file
|
| 123 |
+
_DISTRO_RELEASE_BASENAME_PATTERN = re.compile(r"(\w+)[-_](release|version)$")
|
| 124 |
+
|
| 125 |
+
# Base file names to be looked up for if _UNIXCONFDIR is not readable.
|
| 126 |
+
_DISTRO_RELEASE_BASENAMES = [
|
| 127 |
+
"SuSE-release",
|
| 128 |
+
"altlinux-release",
|
| 129 |
+
"arch-release",
|
| 130 |
+
"base-release",
|
| 131 |
+
"centos-release",
|
| 132 |
+
"fedora-release",
|
| 133 |
+
"gentoo-release",
|
| 134 |
+
"mageia-release",
|
| 135 |
+
"mandrake-release",
|
| 136 |
+
"mandriva-release",
|
| 137 |
+
"mandrivalinux-release",
|
| 138 |
+
"manjaro-release",
|
| 139 |
+
"oracle-release",
|
| 140 |
+
"redhat-release",
|
| 141 |
+
"rocky-release",
|
| 142 |
+
"sl-release",
|
| 143 |
+
"slackware-version",
|
| 144 |
+
]
|
| 145 |
+
|
| 146 |
+
# Base file names to be ignored when searching for distro release file
|
| 147 |
+
_DISTRO_RELEASE_IGNORE_BASENAMES = (
|
| 148 |
+
"debian_version",
|
| 149 |
+
"lsb-release",
|
| 150 |
+
"oem-release",
|
| 151 |
+
_OS_RELEASE_BASENAME,
|
| 152 |
+
"system-release",
|
| 153 |
+
"plesk-release",
|
| 154 |
+
"iredmail-release",
|
| 155 |
+
"board-release",
|
| 156 |
+
"ec2_version",
|
| 157 |
+
)
|
| 158 |
+
|
| 159 |
+
|
| 160 |
+
def linux_distribution(full_distribution_name: bool = True) -> Tuple[str, str, str]:
|
| 161 |
+
"""
|
| 162 |
+
.. deprecated:: 1.6.0
|
| 163 |
+
|
| 164 |
+
:func:`distro.linux_distribution()` is deprecated. It should only be
|
| 165 |
+
used as a compatibility shim with Python's
|
| 166 |
+
:py:func:`platform.linux_distribution()`. Please use :func:`distro.id`,
|
| 167 |
+
:func:`distro.version` and :func:`distro.name` instead.
|
| 168 |
+
|
| 169 |
+
Return information about the current OS distribution as a tuple
|
| 170 |
+
``(id_name, version, codename)`` with items as follows:
|
| 171 |
+
|
| 172 |
+
* ``id_name``: If *full_distribution_name* is false, the result of
|
| 173 |
+
:func:`distro.id`. Otherwise, the result of :func:`distro.name`.
|
| 174 |
+
|
| 175 |
+
* ``version``: The result of :func:`distro.version`.
|
| 176 |
+
|
| 177 |
+
* ``codename``: The extra item (usually in parentheses) after the
|
| 178 |
+
os-release version number, or the result of :func:`distro.codename`.
|
| 179 |
+
|
| 180 |
+
The interface of this function is compatible with the original
|
| 181 |
+
:py:func:`platform.linux_distribution` function, supporting a subset of
|
| 182 |
+
its parameters.
|
| 183 |
+
|
| 184 |
+
The data it returns may not exactly be the same, because it uses more data
|
| 185 |
+
sources than the original function, and that may lead to different data if
|
| 186 |
+
the OS distribution is not consistent across multiple data sources it
|
| 187 |
+
provides (there are indeed such distributions ...).
|
| 188 |
+
|
| 189 |
+
Another reason for differences is the fact that the :func:`distro.id`
|
| 190 |
+
method normalizes the distro ID string to a reliable machine-readable value
|
| 191 |
+
for a number of popular OS distributions.
|
| 192 |
+
"""
|
| 193 |
+
warnings.warn(
|
| 194 |
+
"distro.linux_distribution() is deprecated. It should only be used as a "
|
| 195 |
+
"compatibility shim with Python's platform.linux_distribution(). Please use "
|
| 196 |
+
"distro.id(), distro.version() and distro.name() instead.",
|
| 197 |
+
DeprecationWarning,
|
| 198 |
+
stacklevel=2,
|
| 199 |
+
)
|
| 200 |
+
return _distro.linux_distribution(full_distribution_name)
|
| 201 |
+
|
| 202 |
+
|
| 203 |
+
def id() -> str:
|
| 204 |
+
"""
|
| 205 |
+
Return the distro ID of the current distribution, as a
|
| 206 |
+
machine-readable string.
|
| 207 |
+
|
| 208 |
+
For a number of OS distributions, the returned distro ID value is
|
| 209 |
+
*reliable*, in the sense that it is documented and that it does not change
|
| 210 |
+
across releases of the distribution.
|
| 211 |
+
|
| 212 |
+
This package maintains the following reliable distro ID values:
|
| 213 |
+
|
| 214 |
+
============== =========================================
|
| 215 |
+
Distro ID Distribution
|
| 216 |
+
============== =========================================
|
| 217 |
+
"ubuntu" Ubuntu
|
| 218 |
+
"debian" Debian
|
| 219 |
+
"rhel" RedHat Enterprise Linux
|
| 220 |
+
"centos" CentOS
|
| 221 |
+
"fedora" Fedora
|
| 222 |
+
"sles" SUSE Linux Enterprise Server
|
| 223 |
+
"opensuse" openSUSE
|
| 224 |
+
"amzn" Amazon Linux
|
| 225 |
+
"arch" Arch Linux
|
| 226 |
+
"buildroot" Buildroot
|
| 227 |
+
"cloudlinux" CloudLinux OS
|
| 228 |
+
"exherbo" Exherbo Linux
|
| 229 |
+
"gentoo" GenToo Linux
|
| 230 |
+
"ibm_powerkvm" IBM PowerKVM
|
| 231 |
+
"kvmibm" KVM for IBM z Systems
|
| 232 |
+
"linuxmint" Linux Mint
|
| 233 |
+
"mageia" Mageia
|
| 234 |
+
"mandriva" Mandriva Linux
|
| 235 |
+
"parallels" Parallels
|
| 236 |
+
"pidora" Pidora
|
| 237 |
+
"raspbian" Raspbian
|
| 238 |
+
"oracle" Oracle Linux (and Oracle Enterprise Linux)
|
| 239 |
+
"scientific" Scientific Linux
|
| 240 |
+
"slackware" Slackware
|
| 241 |
+
"xenserver" XenServer
|
| 242 |
+
"openbsd" OpenBSD
|
| 243 |
+
"netbsd" NetBSD
|
| 244 |
+
"freebsd" FreeBSD
|
| 245 |
+
"midnightbsd" MidnightBSD
|
| 246 |
+
"rocky" Rocky Linux
|
| 247 |
+
"aix" AIX
|
| 248 |
+
"guix" Guix System
|
| 249 |
+
"altlinux" ALT Linux
|
| 250 |
+
============== =========================================
|
| 251 |
+
|
| 252 |
+
If you have a need to get distros for reliable IDs added into this set,
|
| 253 |
+
or if you find that the :func:`distro.id` function returns a different
|
| 254 |
+
distro ID for one of the listed distros, please create an issue in the
|
| 255 |
+
`distro issue tracker`_.
|
| 256 |
+
|
| 257 |
+
**Lookup hierarchy and transformations:**
|
| 258 |
+
|
| 259 |
+
First, the ID is obtained from the following sources, in the specified
|
| 260 |
+
order. The first available and non-empty value is used:
|
| 261 |
+
|
| 262 |
+
* the value of the "ID" attribute of the os-release file,
|
| 263 |
+
|
| 264 |
+
* the value of the "Distributor ID" attribute returned by the lsb_release
|
| 265 |
+
command,
|
| 266 |
+
|
| 267 |
+
* the first part of the file name of the distro release file,
|
| 268 |
+
|
| 269 |
+
The so determined ID value then passes the following transformations,
|
| 270 |
+
before it is returned by this method:
|
| 271 |
+
|
| 272 |
+
* it is translated to lower case,
|
| 273 |
+
|
| 274 |
+
* blanks (which should not be there anyway) are translated to underscores,
|
| 275 |
+
|
| 276 |
+
* a normalization of the ID is performed, based upon
|
| 277 |
+
`normalization tables`_. The purpose of this normalization is to ensure
|
| 278 |
+
that the ID is as reliable as possible, even across incompatible changes
|
| 279 |
+
in the OS distributions. A common reason for an incompatible change is
|
| 280 |
+
the addition of an os-release file, or the addition of the lsb_release
|
| 281 |
+
command, with ID values that differ from what was previously determined
|
| 282 |
+
from the distro release file name.
|
| 283 |
+
"""
|
| 284 |
+
return _distro.id()
|
| 285 |
+
|
| 286 |
+
|
| 287 |
+
def name(pretty: bool = False) -> str:
|
| 288 |
+
"""
|
| 289 |
+
Return the name of the current OS distribution, as a human-readable
|
| 290 |
+
string.
|
| 291 |
+
|
| 292 |
+
If *pretty* is false, the name is returned without version or codename.
|
| 293 |
+
(e.g. "CentOS Linux")
|
| 294 |
+
|
| 295 |
+
If *pretty* is true, the version and codename are appended.
|
| 296 |
+
(e.g. "CentOS Linux 7.1.1503 (Core)")
|
| 297 |
+
|
| 298 |
+
**Lookup hierarchy:**
|
| 299 |
+
|
| 300 |
+
The name is obtained from the following sources, in the specified order.
|
| 301 |
+
The first available and non-empty value is used:
|
| 302 |
+
|
| 303 |
+
* If *pretty* is false:
|
| 304 |
+
|
| 305 |
+
- the value of the "NAME" attribute of the os-release file,
|
| 306 |
+
|
| 307 |
+
- the value of the "Distributor ID" attribute returned by the lsb_release
|
| 308 |
+
command,
|
| 309 |
+
|
| 310 |
+
- the value of the "<name>" field of the distro release file.
|
| 311 |
+
|
| 312 |
+
* If *pretty* is true:
|
| 313 |
+
|
| 314 |
+
- the value of the "PRETTY_NAME" attribute of the os-release file,
|
| 315 |
+
|
| 316 |
+
- the value of the "Description" attribute returned by the lsb_release
|
| 317 |
+
command,
|
| 318 |
+
|
| 319 |
+
- the value of the "<name>" field of the distro release file, appended
|
| 320 |
+
with the value of the pretty version ("<version_id>" and "<codename>"
|
| 321 |
+
fields) of the distro release file, if available.
|
| 322 |
+
"""
|
| 323 |
+
return _distro.name(pretty)
|
| 324 |
+
|
| 325 |
+
|
| 326 |
+
def version(pretty: bool = False, best: bool = False) -> str:
|
| 327 |
+
"""
|
| 328 |
+
Return the version of the current OS distribution, as a human-readable
|
| 329 |
+
string.
|
| 330 |
+
|
| 331 |
+
If *pretty* is false, the version is returned without codename (e.g.
|
| 332 |
+
"7.0").
|
| 333 |
+
|
| 334 |
+
If *pretty* is true, the codename in parenthesis is appended, if the
|
| 335 |
+
codename is non-empty (e.g. "7.0 (Maipo)").
|
| 336 |
+
|
| 337 |
+
Some distributions provide version numbers with different precisions in
|
| 338 |
+
the different sources of distribution information. Examining the different
|
| 339 |
+
sources in a fixed priority order does not always yield the most precise
|
| 340 |
+
version (e.g. for Debian 8.2, or CentOS 7.1).
|
| 341 |
+
|
| 342 |
+
Some other distributions may not provide this kind of information. In these
|
| 343 |
+
cases, an empty string would be returned. This behavior can be observed
|
| 344 |
+
with rolling releases distributions (e.g. Arch Linux).
|
| 345 |
+
|
| 346 |
+
The *best* parameter can be used to control the approach for the returned
|
| 347 |
+
version:
|
| 348 |
+
|
| 349 |
+
If *best* is false, the first non-empty version number in priority order of
|
| 350 |
+
the examined sources is returned.
|
| 351 |
+
|
| 352 |
+
If *best* is true, the most precise version number out of all examined
|
| 353 |
+
sources is returned.
|
| 354 |
+
|
| 355 |
+
**Lookup hierarchy:**
|
| 356 |
+
|
| 357 |
+
In all cases, the version number is obtained from the following sources.
|
| 358 |
+
If *best* is false, this order represents the priority order:
|
| 359 |
+
|
| 360 |
+
* the value of the "VERSION_ID" attribute of the os-release file,
|
| 361 |
+
* the value of the "Release" attribute returned by the lsb_release
|
| 362 |
+
command,
|
| 363 |
+
* the version number parsed from the "<version_id>" field of the first line
|
| 364 |
+
of the distro release file,
|
| 365 |
+
* the version number parsed from the "PRETTY_NAME" attribute of the
|
| 366 |
+
os-release file, if it follows the format of the distro release files.
|
| 367 |
+
* the version number parsed from the "Description" attribute returned by
|
| 368 |
+
the lsb_release command, if it follows the format of the distro release
|
| 369 |
+
files.
|
| 370 |
+
"""
|
| 371 |
+
return _distro.version(pretty, best)
|
| 372 |
+
|
| 373 |
+
|
| 374 |
+
def version_parts(best: bool = False) -> Tuple[str, str, str]:
|
| 375 |
+
"""
|
| 376 |
+
Return the version of the current OS distribution as a tuple
|
| 377 |
+
``(major, minor, build_number)`` with items as follows:
|
| 378 |
+
|
| 379 |
+
* ``major``: The result of :func:`distro.major_version`.
|
| 380 |
+
|
| 381 |
+
* ``minor``: The result of :func:`distro.minor_version`.
|
| 382 |
+
|
| 383 |
+
* ``build_number``: The result of :func:`distro.build_number`.
|
| 384 |
+
|
| 385 |
+
For a description of the *best* parameter, see the :func:`distro.version`
|
| 386 |
+
method.
|
| 387 |
+
"""
|
| 388 |
+
return _distro.version_parts(best)
|
| 389 |
+
|
| 390 |
+
|
| 391 |
+
def major_version(best: bool = False) -> str:
|
| 392 |
+
"""
|
| 393 |
+
Return the major version of the current OS distribution, as a string,
|
| 394 |
+
if provided.
|
| 395 |
+
Otherwise, the empty string is returned. The major version is the first
|
| 396 |
+
part of the dot-separated version string.
|
| 397 |
+
|
| 398 |
+
For a description of the *best* parameter, see the :func:`distro.version`
|
| 399 |
+
method.
|
| 400 |
+
"""
|
| 401 |
+
return _distro.major_version(best)
|
| 402 |
+
|
| 403 |
+
|
| 404 |
+
def minor_version(best: bool = False) -> str:
|
| 405 |
+
"""
|
| 406 |
+
Return the minor version of the current OS distribution, as a string,
|
| 407 |
+
if provided.
|
| 408 |
+
Otherwise, the empty string is returned. The minor version is the second
|
| 409 |
+
part of the dot-separated version string.
|
| 410 |
+
|
| 411 |
+
For a description of the *best* parameter, see the :func:`distro.version`
|
| 412 |
+
method.
|
| 413 |
+
"""
|
| 414 |
+
return _distro.minor_version(best)
|
| 415 |
+
|
| 416 |
+
|
| 417 |
+
def build_number(best: bool = False) -> str:
|
| 418 |
+
"""
|
| 419 |
+
Return the build number of the current OS distribution, as a string,
|
| 420 |
+
if provided.
|
| 421 |
+
Otherwise, the empty string is returned. The build number is the third part
|
| 422 |
+
of the dot-separated version string.
|
| 423 |
+
|
| 424 |
+
For a description of the *best* parameter, see the :func:`distro.version`
|
| 425 |
+
method.
|
| 426 |
+
"""
|
| 427 |
+
return _distro.build_number(best)
|
| 428 |
+
|
| 429 |
+
|
| 430 |
+
def like() -> str:
|
| 431 |
+
"""
|
| 432 |
+
Return a space-separated list of distro IDs of distributions that are
|
| 433 |
+
closely related to the current OS distribution in regards to packaging
|
| 434 |
+
and programming interfaces, for example distributions the current
|
| 435 |
+
distribution is a derivative from.
|
| 436 |
+
|
| 437 |
+
**Lookup hierarchy:**
|
| 438 |
+
|
| 439 |
+
This information item is only provided by the os-release file.
|
| 440 |
+
For details, see the description of the "ID_LIKE" attribute in the
|
| 441 |
+
`os-release man page
|
| 442 |
+
<http://www.freedesktop.org/software/systemd/man/os-release.html>`_.
|
| 443 |
+
"""
|
| 444 |
+
return _distro.like()
|
| 445 |
+
|
| 446 |
+
|
| 447 |
+
def codename() -> str:
|
| 448 |
+
"""
|
| 449 |
+
Return the codename for the release of the current OS distribution,
|
| 450 |
+
as a string.
|
| 451 |
+
|
| 452 |
+
If the distribution does not have a codename, an empty string is returned.
|
| 453 |
+
|
| 454 |
+
Note that the returned codename is not always really a codename. For
|
| 455 |
+
example, openSUSE returns "x86_64". This function does not handle such
|
| 456 |
+
cases in any special way and just returns the string it finds, if any.
|
| 457 |
+
|
| 458 |
+
**Lookup hierarchy:**
|
| 459 |
+
|
| 460 |
+
* the codename within the "VERSION" attribute of the os-release file, if
|
| 461 |
+
provided,
|
| 462 |
+
|
| 463 |
+
* the value of the "Codename" attribute returned by the lsb_release
|
| 464 |
+
command,
|
| 465 |
+
|
| 466 |
+
* the value of the "<codename>" field of the distro release file.
|
| 467 |
+
"""
|
| 468 |
+
return _distro.codename()
|
| 469 |
+
|
| 470 |
+
|
| 471 |
+
def info(pretty: bool = False, best: bool = False) -> InfoDict:
|
| 472 |
+
"""
|
| 473 |
+
Return certain machine-readable information items about the current OS
|
| 474 |
+
distribution in a dictionary, as shown in the following example:
|
| 475 |
+
|
| 476 |
+
.. sourcecode:: python
|
| 477 |
+
|
| 478 |
+
{
|
| 479 |
+
'id': 'rhel',
|
| 480 |
+
'version': '7.0',
|
| 481 |
+
'version_parts': {
|
| 482 |
+
'major': '7',
|
| 483 |
+
'minor': '0',
|
| 484 |
+
'build_number': ''
|
| 485 |
+
},
|
| 486 |
+
'like': 'fedora',
|
| 487 |
+
'codename': 'Maipo'
|
| 488 |
+
}
|
| 489 |
+
|
| 490 |
+
The dictionary structure and keys are always the same, regardless of which
|
| 491 |
+
information items are available in the underlying data sources. The values
|
| 492 |
+
for the various keys are as follows:
|
| 493 |
+
|
| 494 |
+
* ``id``: The result of :func:`distro.id`.
|
| 495 |
+
|
| 496 |
+
* ``version``: The result of :func:`distro.version`.
|
| 497 |
+
|
| 498 |
+
* ``version_parts -> major``: The result of :func:`distro.major_version`.
|
| 499 |
+
|
| 500 |
+
* ``version_parts -> minor``: The result of :func:`distro.minor_version`.
|
| 501 |
+
|
| 502 |
+
* ``version_parts -> build_number``: The result of
|
| 503 |
+
:func:`distro.build_number`.
|
| 504 |
+
|
| 505 |
+
* ``like``: The result of :func:`distro.like`.
|
| 506 |
+
|
| 507 |
+
* ``codename``: The result of :func:`distro.codename`.
|
| 508 |
+
|
| 509 |
+
For a description of the *pretty* and *best* parameters, see the
|
| 510 |
+
:func:`distro.version` method.
|
| 511 |
+
"""
|
| 512 |
+
return _distro.info(pretty, best)
|
| 513 |
+
|
| 514 |
+
|
| 515 |
+
def os_release_info() -> Dict[str, str]:
|
| 516 |
+
"""
|
| 517 |
+
Return a dictionary containing key-value pairs for the information items
|
| 518 |
+
from the os-release file data source of the current OS distribution.
|
| 519 |
+
|
| 520 |
+
See `os-release file`_ for details about these information items.
|
| 521 |
+
"""
|
| 522 |
+
return _distro.os_release_info()
|
| 523 |
+
|
| 524 |
+
|
| 525 |
+
def lsb_release_info() -> Dict[str, str]:
|
| 526 |
+
"""
|
| 527 |
+
Return a dictionary containing key-value pairs for the information items
|
| 528 |
+
from the lsb_release command data source of the current OS distribution.
|
| 529 |
+
|
| 530 |
+
See `lsb_release command output`_ for details about these information
|
| 531 |
+
items.
|
| 532 |
+
"""
|
| 533 |
+
return _distro.lsb_release_info()
|
| 534 |
+
|
| 535 |
+
|
| 536 |
+
def distro_release_info() -> Dict[str, str]:
|
| 537 |
+
"""
|
| 538 |
+
Return a dictionary containing key-value pairs for the information items
|
| 539 |
+
from the distro release file data source of the current OS distribution.
|
| 540 |
+
|
| 541 |
+
See `distro release file`_ for details about these information items.
|
| 542 |
+
"""
|
| 543 |
+
return _distro.distro_release_info()
|
| 544 |
+
|
| 545 |
+
|
| 546 |
+
def uname_info() -> Dict[str, str]:
|
| 547 |
+
"""
|
| 548 |
+
Return a dictionary containing key-value pairs for the information items
|
| 549 |
+
from the distro release file data source of the current OS distribution.
|
| 550 |
+
"""
|
| 551 |
+
return _distro.uname_info()
|
| 552 |
+
|
| 553 |
+
|
| 554 |
+
def os_release_attr(attribute: str) -> str:
|
| 555 |
+
"""
|
| 556 |
+
Return a single named information item from the os-release file data source
|
| 557 |
+
of the current OS distribution.
|
| 558 |
+
|
| 559 |
+
Parameters:
|
| 560 |
+
|
| 561 |
+
* ``attribute`` (string): Key of the information item.
|
| 562 |
+
|
| 563 |
+
Returns:
|
| 564 |
+
|
| 565 |
+
* (string): Value of the information item, if the item exists.
|
| 566 |
+
The empty string, if the item does not exist.
|
| 567 |
+
|
| 568 |
+
See `os-release file`_ for details about these information items.
|
| 569 |
+
"""
|
| 570 |
+
return _distro.os_release_attr(attribute)
|
| 571 |
+
|
| 572 |
+
|
| 573 |
+
def lsb_release_attr(attribute: str) -> str:
|
| 574 |
+
"""
|
| 575 |
+
Return a single named information item from the lsb_release command output
|
| 576 |
+
data source of the current OS distribution.
|
| 577 |
+
|
| 578 |
+
Parameters:
|
| 579 |
+
|
| 580 |
+
* ``attribute`` (string): Key of the information item.
|
| 581 |
+
|
| 582 |
+
Returns:
|
| 583 |
+
|
| 584 |
+
* (string): Value of the information item, if the item exists.
|
| 585 |
+
The empty string, if the item does not exist.
|
| 586 |
+
|
| 587 |
+
See `lsb_release command output`_ for details about these information
|
| 588 |
+
items.
|
| 589 |
+
"""
|
| 590 |
+
return _distro.lsb_release_attr(attribute)
|
| 591 |
+
|
| 592 |
+
|
| 593 |
+
def distro_release_attr(attribute: str) -> str:
|
| 594 |
+
"""
|
| 595 |
+
Return a single named information item from the distro release file
|
| 596 |
+
data source of the current OS distribution.
|
| 597 |
+
|
| 598 |
+
Parameters:
|
| 599 |
+
|
| 600 |
+
* ``attribute`` (string): Key of the information item.
|
| 601 |
+
|
| 602 |
+
Returns:
|
| 603 |
+
|
| 604 |
+
* (string): Value of the information item, if the item exists.
|
| 605 |
+
The empty string, if the item does not exist.
|
| 606 |
+
|
| 607 |
+
See `distro release file`_ for details about these information items.
|
| 608 |
+
"""
|
| 609 |
+
return _distro.distro_release_attr(attribute)
|
| 610 |
+
|
| 611 |
+
|
| 612 |
+
def uname_attr(attribute: str) -> str:
|
| 613 |
+
"""
|
| 614 |
+
Return a single named information item from the distro release file
|
| 615 |
+
data source of the current OS distribution.
|
| 616 |
+
|
| 617 |
+
Parameters:
|
| 618 |
+
|
| 619 |
+
* ``attribute`` (string): Key of the information item.
|
| 620 |
+
|
| 621 |
+
Returns:
|
| 622 |
+
|
| 623 |
+
* (string): Value of the information item, if the item exists.
|
| 624 |
+
The empty string, if the item does not exist.
|
| 625 |
+
"""
|
| 626 |
+
return _distro.uname_attr(attribute)
|
| 627 |
+
|
| 628 |
+
|
| 629 |
+
try:
|
| 630 |
+
from functools import cached_property
|
| 631 |
+
except ImportError:
|
| 632 |
+
# Python < 3.8
|
| 633 |
+
class cached_property: # type: ignore
|
| 634 |
+
"""A version of @property which caches the value. On access, it calls the
|
| 635 |
+
underlying function and sets the value in `__dict__` so future accesses
|
| 636 |
+
will not re-call the property.
|
| 637 |
+
"""
|
| 638 |
+
|
| 639 |
+
def __init__(self, f: Callable[[Any], Any]) -> None:
|
| 640 |
+
self._fname = f.__name__
|
| 641 |
+
self._f = f
|
| 642 |
+
|
| 643 |
+
def __get__(self, obj: Any, owner: Type[Any]) -> Any:
|
| 644 |
+
assert obj is not None, f"call {self._fname} on an instance"
|
| 645 |
+
ret = obj.__dict__[self._fname] = self._f(obj)
|
| 646 |
+
return ret
|
| 647 |
+
|
| 648 |
+
|
| 649 |
+
class LinuxDistribution:
|
| 650 |
+
"""
|
| 651 |
+
Provides information about a OS distribution.
|
| 652 |
+
|
| 653 |
+
This package creates a private module-global instance of this class with
|
| 654 |
+
default initialization arguments, that is used by the
|
| 655 |
+
`consolidated accessor functions`_ and `single source accessor functions`_.
|
| 656 |
+
By using default initialization arguments, that module-global instance
|
| 657 |
+
returns data about the current OS distribution (i.e. the distro this
|
| 658 |
+
package runs on).
|
| 659 |
+
|
| 660 |
+
Normally, it is not necessary to create additional instances of this class.
|
| 661 |
+
However, in situations where control is needed over the exact data sources
|
| 662 |
+
that are used, instances of this class can be created with a specific
|
| 663 |
+
distro release file, or a specific os-release file, or without invoking the
|
| 664 |
+
lsb_release command.
|
| 665 |
+
"""
|
| 666 |
+
|
| 667 |
+
def __init__(
|
| 668 |
+
self,
|
| 669 |
+
include_lsb: Optional[bool] = None,
|
| 670 |
+
os_release_file: str = "",
|
| 671 |
+
distro_release_file: str = "",
|
| 672 |
+
include_uname: Optional[bool] = None,
|
| 673 |
+
root_dir: Optional[str] = None,
|
| 674 |
+
include_oslevel: Optional[bool] = None,
|
| 675 |
+
) -> None:
|
| 676 |
+
"""
|
| 677 |
+
The initialization method of this class gathers information from the
|
| 678 |
+
available data sources, and stores that in private instance attributes.
|
| 679 |
+
Subsequent access to the information items uses these private instance
|
| 680 |
+
attributes, so that the data sources are read only once.
|
| 681 |
+
|
| 682 |
+
Parameters:
|
| 683 |
+
|
| 684 |
+
* ``include_lsb`` (bool): Controls whether the
|
| 685 |
+
`lsb_release command output`_ is included as a data source.
|
| 686 |
+
|
| 687 |
+
If the lsb_release command is not available in the program execution
|
| 688 |
+
path, the data source for the lsb_release command will be empty.
|
| 689 |
+
|
| 690 |
+
* ``os_release_file`` (string): The path name of the
|
| 691 |
+
`os-release file`_ that is to be used as a data source.
|
| 692 |
+
|
| 693 |
+
An empty string (the default) will cause the default path name to
|
| 694 |
+
be used (see `os-release file`_ for details).
|
| 695 |
+
|
| 696 |
+
If the specified or defaulted os-release file does not exist, the
|
| 697 |
+
data source for the os-release file will be empty.
|
| 698 |
+
|
| 699 |
+
* ``distro_release_file`` (string): The path name of the
|
| 700 |
+
`distro release file`_ that is to be used as a data source.
|
| 701 |
+
|
| 702 |
+
An empty string (the default) will cause a default search algorithm
|
| 703 |
+
to be used (see `distro release file`_ for details).
|
| 704 |
+
|
| 705 |
+
If the specified distro release file does not exist, or if no default
|
| 706 |
+
distro release file can be found, the data source for the distro
|
| 707 |
+
release file will be empty.
|
| 708 |
+
|
| 709 |
+
* ``include_uname`` (bool): Controls whether uname command output is
|
| 710 |
+
included as a data source. If the uname command is not available in
|
| 711 |
+
the program execution path the data source for the uname command will
|
| 712 |
+
be empty.
|
| 713 |
+
|
| 714 |
+
* ``root_dir`` (string): The absolute path to the root directory to use
|
| 715 |
+
to find distro-related information files. Note that ``include_*``
|
| 716 |
+
parameters must not be enabled in combination with ``root_dir``.
|
| 717 |
+
|
| 718 |
+
* ``include_oslevel`` (bool): Controls whether (AIX) oslevel command
|
| 719 |
+
output is included as a data source. If the oslevel command is not
|
| 720 |
+
available in the program execution path the data source will be
|
| 721 |
+
empty.
|
| 722 |
+
|
| 723 |
+
Public instance attributes:
|
| 724 |
+
|
| 725 |
+
* ``os_release_file`` (string): The path name of the
|
| 726 |
+
`os-release file`_ that is actually used as a data source. The
|
| 727 |
+
empty string if no distro release file is used as a data source.
|
| 728 |
+
|
| 729 |
+
* ``distro_release_file`` (string): The path name of the
|
| 730 |
+
`distro release file`_ that is actually used as a data source. The
|
| 731 |
+
empty string if no distro release file is used as a data source.
|
| 732 |
+
|
| 733 |
+
* ``include_lsb`` (bool): The result of the ``include_lsb`` parameter.
|
| 734 |
+
This controls whether the lsb information will be loaded.
|
| 735 |
+
|
| 736 |
+
* ``include_uname`` (bool): The result of the ``include_uname``
|
| 737 |
+
parameter. This controls whether the uname information will
|
| 738 |
+
be loaded.
|
| 739 |
+
|
| 740 |
+
* ``include_oslevel`` (bool): The result of the ``include_oslevel``
|
| 741 |
+
parameter. This controls whether (AIX) oslevel information will be
|
| 742 |
+
loaded.
|
| 743 |
+
|
| 744 |
+
* ``root_dir`` (string): The result of the ``root_dir`` parameter.
|
| 745 |
+
The absolute path to the root directory to use to find distro-related
|
| 746 |
+
information files.
|
| 747 |
+
|
| 748 |
+
Raises:
|
| 749 |
+
|
| 750 |
+
* :py:exc:`ValueError`: Initialization parameters combination is not
|
| 751 |
+
supported.
|
| 752 |
+
|
| 753 |
+
* :py:exc:`OSError`: Some I/O issue with an os-release file or distro
|
| 754 |
+
release file.
|
| 755 |
+
|
| 756 |
+
* :py:exc:`UnicodeError`: A data source has unexpected characters or
|
| 757 |
+
uses an unexpected encoding.
|
| 758 |
+
"""
|
| 759 |
+
self.root_dir = root_dir
|
| 760 |
+
self.etc_dir = os.path.join(root_dir, "etc") if root_dir else _UNIXCONFDIR
|
| 761 |
+
self.usr_lib_dir = (
|
| 762 |
+
os.path.join(root_dir, "usr/lib") if root_dir else _UNIXUSRLIBDIR
|
| 763 |
+
)
|
| 764 |
+
|
| 765 |
+
if os_release_file:
|
| 766 |
+
self.os_release_file = os_release_file
|
| 767 |
+
else:
|
| 768 |
+
etc_dir_os_release_file = os.path.join(self.etc_dir, _OS_RELEASE_BASENAME)
|
| 769 |
+
usr_lib_os_release_file = os.path.join(
|
| 770 |
+
self.usr_lib_dir, _OS_RELEASE_BASENAME
|
| 771 |
+
)
|
| 772 |
+
|
| 773 |
+
# NOTE: The idea is to respect order **and** have it set
|
| 774 |
+
# at all times for API backwards compatibility.
|
| 775 |
+
if os.path.isfile(etc_dir_os_release_file) or not os.path.isfile(
|
| 776 |
+
usr_lib_os_release_file
|
| 777 |
+
):
|
| 778 |
+
self.os_release_file = etc_dir_os_release_file
|
| 779 |
+
else:
|
| 780 |
+
self.os_release_file = usr_lib_os_release_file
|
| 781 |
+
|
| 782 |
+
self.distro_release_file = distro_release_file or "" # updated later
|
| 783 |
+
|
| 784 |
+
is_root_dir_defined = root_dir is not None
|
| 785 |
+
if is_root_dir_defined and (include_lsb or include_uname or include_oslevel):
|
| 786 |
+
raise ValueError(
|
| 787 |
+
"Including subprocess data sources from specific root_dir is disallowed"
|
| 788 |
+
" to prevent false information"
|
| 789 |
+
)
|
| 790 |
+
self.include_lsb = (
|
| 791 |
+
include_lsb if include_lsb is not None else not is_root_dir_defined
|
| 792 |
+
)
|
| 793 |
+
self.include_uname = (
|
| 794 |
+
include_uname if include_uname is not None else not is_root_dir_defined
|
| 795 |
+
)
|
| 796 |
+
self.include_oslevel = (
|
| 797 |
+
include_oslevel if include_oslevel is not None else not is_root_dir_defined
|
| 798 |
+
)
|
| 799 |
+
|
| 800 |
+
def __repr__(self) -> str:
|
| 801 |
+
"""Return repr of all info"""
|
| 802 |
+
return (
|
| 803 |
+
"LinuxDistribution("
|
| 804 |
+
"os_release_file={self.os_release_file!r}, "
|
| 805 |
+
"distro_release_file={self.distro_release_file!r}, "
|
| 806 |
+
"include_lsb={self.include_lsb!r}, "
|
| 807 |
+
"include_uname={self.include_uname!r}, "
|
| 808 |
+
"include_oslevel={self.include_oslevel!r}, "
|
| 809 |
+
"root_dir={self.root_dir!r}, "
|
| 810 |
+
"_os_release_info={self._os_release_info!r}, "
|
| 811 |
+
"_lsb_release_info={self._lsb_release_info!r}, "
|
| 812 |
+
"_distro_release_info={self._distro_release_info!r}, "
|
| 813 |
+
"_uname_info={self._uname_info!r}, "
|
| 814 |
+
"_oslevel_info={self._oslevel_info!r})".format(self=self)
|
| 815 |
+
)
|
| 816 |
+
|
| 817 |
+
def linux_distribution(
|
| 818 |
+
self, full_distribution_name: bool = True
|
| 819 |
+
) -> Tuple[str, str, str]:
|
| 820 |
+
"""
|
| 821 |
+
Return information about the OS distribution that is compatible
|
| 822 |
+
with Python's :func:`platform.linux_distribution`, supporting a subset
|
| 823 |
+
of its parameters.
|
| 824 |
+
|
| 825 |
+
For details, see :func:`distro.linux_distribution`.
|
| 826 |
+
"""
|
| 827 |
+
return (
|
| 828 |
+
self.name() if full_distribution_name else self.id(),
|
| 829 |
+
self.version(),
|
| 830 |
+
self._os_release_info.get("release_codename") or self.codename(),
|
| 831 |
+
)
|
| 832 |
+
|
| 833 |
+
def id(self) -> str:
|
| 834 |
+
"""Return the distro ID of the OS distribution, as a string.
|
| 835 |
+
|
| 836 |
+
For details, see :func:`distro.id`.
|
| 837 |
+
"""
|
| 838 |
+
|
| 839 |
+
def normalize(distro_id: str, table: Dict[str, str]) -> str:
|
| 840 |
+
distro_id = distro_id.lower().replace(" ", "_")
|
| 841 |
+
return table.get(distro_id, distro_id)
|
| 842 |
+
|
| 843 |
+
distro_id = self.os_release_attr("id")
|
| 844 |
+
if distro_id:
|
| 845 |
+
return normalize(distro_id, NORMALIZED_OS_ID)
|
| 846 |
+
|
| 847 |
+
distro_id = self.lsb_release_attr("distributor_id")
|
| 848 |
+
if distro_id:
|
| 849 |
+
return normalize(distro_id, NORMALIZED_LSB_ID)
|
| 850 |
+
|
| 851 |
+
distro_id = self.distro_release_attr("id")
|
| 852 |
+
if distro_id:
|
| 853 |
+
return normalize(distro_id, NORMALIZED_DISTRO_ID)
|
| 854 |
+
|
| 855 |
+
distro_id = self.uname_attr("id")
|
| 856 |
+
if distro_id:
|
| 857 |
+
return normalize(distro_id, NORMALIZED_DISTRO_ID)
|
| 858 |
+
|
| 859 |
+
return ""
|
| 860 |
+
|
| 861 |
+
def name(self, pretty: bool = False) -> str:
|
| 862 |
+
"""
|
| 863 |
+
Return the name of the OS distribution, as a string.
|
| 864 |
+
|
| 865 |
+
For details, see :func:`distro.name`.
|
| 866 |
+
"""
|
| 867 |
+
name = (
|
| 868 |
+
self.os_release_attr("name")
|
| 869 |
+
or self.lsb_release_attr("distributor_id")
|
| 870 |
+
or self.distro_release_attr("name")
|
| 871 |
+
or self.uname_attr("name")
|
| 872 |
+
)
|
| 873 |
+
if pretty:
|
| 874 |
+
name = self.os_release_attr("pretty_name") or self.lsb_release_attr(
|
| 875 |
+
"description"
|
| 876 |
+
)
|
| 877 |
+
if not name:
|
| 878 |
+
name = self.distro_release_attr("name") or self.uname_attr("name")
|
| 879 |
+
version = self.version(pretty=True)
|
| 880 |
+
if version:
|
| 881 |
+
name = f"{name} {version}"
|
| 882 |
+
return name or ""
|
| 883 |
+
|
| 884 |
+
def version(self, pretty: bool = False, best: bool = False) -> str:
|
| 885 |
+
"""
|
| 886 |
+
Return the version of the OS distribution, as a string.
|
| 887 |
+
|
| 888 |
+
For details, see :func:`distro.version`.
|
| 889 |
+
"""
|
| 890 |
+
versions = [
|
| 891 |
+
self.os_release_attr("version_id"),
|
| 892 |
+
self.lsb_release_attr("release"),
|
| 893 |
+
self.distro_release_attr("version_id"),
|
| 894 |
+
self._parse_distro_release_content(self.os_release_attr("pretty_name")).get(
|
| 895 |
+
"version_id", ""
|
| 896 |
+
),
|
| 897 |
+
self._parse_distro_release_content(
|
| 898 |
+
self.lsb_release_attr("description")
|
| 899 |
+
).get("version_id", ""),
|
| 900 |
+
self.uname_attr("release"),
|
| 901 |
+
]
|
| 902 |
+
if self.uname_attr("id").startswith("aix"):
|
| 903 |
+
# On AIX platforms, prefer oslevel command output.
|
| 904 |
+
versions.insert(0, self.oslevel_info())
|
| 905 |
+
elif self.id() == "debian" or "debian" in self.like().split():
|
| 906 |
+
# On Debian-like, add debian_version file content to candidates list.
|
| 907 |
+
versions.append(self._debian_version)
|
| 908 |
+
version = ""
|
| 909 |
+
if best:
|
| 910 |
+
# This algorithm uses the last version in priority order that has
|
| 911 |
+
# the best precision. If the versions are not in conflict, that
|
| 912 |
+
# does not matter; otherwise, using the last one instead of the
|
| 913 |
+
# first one might be considered a surprise.
|
| 914 |
+
for v in versions:
|
| 915 |
+
if v.count(".") > version.count(".") or version == "":
|
| 916 |
+
version = v
|
| 917 |
+
else:
|
| 918 |
+
for v in versions:
|
| 919 |
+
if v != "":
|
| 920 |
+
version = v
|
| 921 |
+
break
|
| 922 |
+
if pretty and version and self.codename():
|
| 923 |
+
version = f"{version} ({self.codename()})"
|
| 924 |
+
return version
|
| 925 |
+
|
| 926 |
+
def version_parts(self, best: bool = False) -> Tuple[str, str, str]:
|
| 927 |
+
"""
|
| 928 |
+
Return the version of the OS distribution, as a tuple of version
|
| 929 |
+
numbers.
|
| 930 |
+
|
| 931 |
+
For details, see :func:`distro.version_parts`.
|
| 932 |
+
"""
|
| 933 |
+
version_str = self.version(best=best)
|
| 934 |
+
if version_str:
|
| 935 |
+
version_regex = re.compile(r"(\d+)\.?(\d+)?\.?(\d+)?")
|
| 936 |
+
matches = version_regex.match(version_str)
|
| 937 |
+
if matches:
|
| 938 |
+
major, minor, build_number = matches.groups()
|
| 939 |
+
return major, minor or "", build_number or ""
|
| 940 |
+
return "", "", ""
|
| 941 |
+
|
| 942 |
+
def major_version(self, best: bool = False) -> str:
|
| 943 |
+
"""
|
| 944 |
+
Return the major version number of the current distribution.
|
| 945 |
+
|
| 946 |
+
For details, see :func:`distro.major_version`.
|
| 947 |
+
"""
|
| 948 |
+
return self.version_parts(best)[0]
|
| 949 |
+
|
| 950 |
+
def minor_version(self, best: bool = False) -> str:
|
| 951 |
+
"""
|
| 952 |
+
Return the minor version number of the current distribution.
|
| 953 |
+
|
| 954 |
+
For details, see :func:`distro.minor_version`.
|
| 955 |
+
"""
|
| 956 |
+
return self.version_parts(best)[1]
|
| 957 |
+
|
| 958 |
+
def build_number(self, best: bool = False) -> str:
|
| 959 |
+
"""
|
| 960 |
+
Return the build number of the current distribution.
|
| 961 |
+
|
| 962 |
+
For details, see :func:`distro.build_number`.
|
| 963 |
+
"""
|
| 964 |
+
return self.version_parts(best)[2]
|
| 965 |
+
|
| 966 |
+
def like(self) -> str:
|
| 967 |
+
"""
|
| 968 |
+
Return the IDs of distributions that are like the OS distribution.
|
| 969 |
+
|
| 970 |
+
For details, see :func:`distro.like`.
|
| 971 |
+
"""
|
| 972 |
+
return self.os_release_attr("id_like") or ""
|
| 973 |
+
|
| 974 |
+
def codename(self) -> str:
|
| 975 |
+
"""
|
| 976 |
+
Return the codename of the OS distribution.
|
| 977 |
+
|
| 978 |
+
For details, see :func:`distro.codename`.
|
| 979 |
+
"""
|
| 980 |
+
try:
|
| 981 |
+
# Handle os_release specially since distros might purposefully set
|
| 982 |
+
# this to empty string to have no codename
|
| 983 |
+
return self._os_release_info["codename"]
|
| 984 |
+
except KeyError:
|
| 985 |
+
return (
|
| 986 |
+
self.lsb_release_attr("codename")
|
| 987 |
+
or self.distro_release_attr("codename")
|
| 988 |
+
or ""
|
| 989 |
+
)
|
| 990 |
+
|
| 991 |
+
def info(self, pretty: bool = False, best: bool = False) -> InfoDict:
|
| 992 |
+
"""
|
| 993 |
+
Return certain machine-readable information about the OS
|
| 994 |
+
distribution.
|
| 995 |
+
|
| 996 |
+
For details, see :func:`distro.info`.
|
| 997 |
+
"""
|
| 998 |
+
return InfoDict(
|
| 999 |
+
id=self.id(),
|
| 1000 |
+
version=self.version(pretty, best),
|
| 1001 |
+
version_parts=VersionDict(
|
| 1002 |
+
major=self.major_version(best),
|
| 1003 |
+
minor=self.minor_version(best),
|
| 1004 |
+
build_number=self.build_number(best),
|
| 1005 |
+
),
|
| 1006 |
+
like=self.like(),
|
| 1007 |
+
codename=self.codename(),
|
| 1008 |
+
)
|
| 1009 |
+
|
| 1010 |
+
def os_release_info(self) -> Dict[str, str]:
|
| 1011 |
+
"""
|
| 1012 |
+
Return a dictionary containing key-value pairs for the information
|
| 1013 |
+
items from the os-release file data source of the OS distribution.
|
| 1014 |
+
|
| 1015 |
+
For details, see :func:`distro.os_release_info`.
|
| 1016 |
+
"""
|
| 1017 |
+
return self._os_release_info
|
| 1018 |
+
|
| 1019 |
+
def lsb_release_info(self) -> Dict[str, str]:
|
| 1020 |
+
"""
|
| 1021 |
+
Return a dictionary containing key-value pairs for the information
|
| 1022 |
+
items from the lsb_release command data source of the OS
|
| 1023 |
+
distribution.
|
| 1024 |
+
|
| 1025 |
+
For details, see :func:`distro.lsb_release_info`.
|
| 1026 |
+
"""
|
| 1027 |
+
return self._lsb_release_info
|
| 1028 |
+
|
| 1029 |
+
def distro_release_info(self) -> Dict[str, str]:
|
| 1030 |
+
"""
|
| 1031 |
+
Return a dictionary containing key-value pairs for the information
|
| 1032 |
+
items from the distro release file data source of the OS
|
| 1033 |
+
distribution.
|
| 1034 |
+
|
| 1035 |
+
For details, see :func:`distro.distro_release_info`.
|
| 1036 |
+
"""
|
| 1037 |
+
return self._distro_release_info
|
| 1038 |
+
|
| 1039 |
+
def uname_info(self) -> Dict[str, str]:
|
| 1040 |
+
"""
|
| 1041 |
+
Return a dictionary containing key-value pairs for the information
|
| 1042 |
+
items from the uname command data source of the OS distribution.
|
| 1043 |
+
|
| 1044 |
+
For details, see :func:`distro.uname_info`.
|
| 1045 |
+
"""
|
| 1046 |
+
return self._uname_info
|
| 1047 |
+
|
| 1048 |
+
def oslevel_info(self) -> str:
|
| 1049 |
+
"""
|
| 1050 |
+
Return AIX' oslevel command output.
|
| 1051 |
+
"""
|
| 1052 |
+
return self._oslevel_info
|
| 1053 |
+
|
| 1054 |
+
def os_release_attr(self, attribute: str) -> str:
|
| 1055 |
+
"""
|
| 1056 |
+
Return a single named information item from the os-release file data
|
| 1057 |
+
source of the OS distribution.
|
| 1058 |
+
|
| 1059 |
+
For details, see :func:`distro.os_release_attr`.
|
| 1060 |
+
"""
|
| 1061 |
+
return self._os_release_info.get(attribute, "")
|
| 1062 |
+
|
| 1063 |
+
def lsb_release_attr(self, attribute: str) -> str:
|
| 1064 |
+
"""
|
| 1065 |
+
Return a single named information item from the lsb_release command
|
| 1066 |
+
output data source of the OS distribution.
|
| 1067 |
+
|
| 1068 |
+
For details, see :func:`distro.lsb_release_attr`.
|
| 1069 |
+
"""
|
| 1070 |
+
return self._lsb_release_info.get(attribute, "")
|
| 1071 |
+
|
| 1072 |
+
def distro_release_attr(self, attribute: str) -> str:
|
| 1073 |
+
"""
|
| 1074 |
+
Return a single named information item from the distro release file
|
| 1075 |
+
data source of the OS distribution.
|
| 1076 |
+
|
| 1077 |
+
For details, see :func:`distro.distro_release_attr`.
|
| 1078 |
+
"""
|
| 1079 |
+
return self._distro_release_info.get(attribute, "")
|
| 1080 |
+
|
| 1081 |
+
def uname_attr(self, attribute: str) -> str:
|
| 1082 |
+
"""
|
| 1083 |
+
Return a single named information item from the uname command
|
| 1084 |
+
output data source of the OS distribution.
|
| 1085 |
+
|
| 1086 |
+
For details, see :func:`distro.uname_attr`.
|
| 1087 |
+
"""
|
| 1088 |
+
return self._uname_info.get(attribute, "")
|
| 1089 |
+
|
| 1090 |
+
@cached_property
|
| 1091 |
+
def _os_release_info(self) -> Dict[str, str]:
|
| 1092 |
+
"""
|
| 1093 |
+
Get the information items from the specified os-release file.
|
| 1094 |
+
|
| 1095 |
+
Returns:
|
| 1096 |
+
A dictionary containing all information items.
|
| 1097 |
+
"""
|
| 1098 |
+
if os.path.isfile(self.os_release_file):
|
| 1099 |
+
with open(self.os_release_file, encoding="utf-8") as release_file:
|
| 1100 |
+
return self._parse_os_release_content(release_file)
|
| 1101 |
+
return {}
|
| 1102 |
+
|
| 1103 |
+
@staticmethod
|
| 1104 |
+
def _parse_os_release_content(lines: TextIO) -> Dict[str, str]:
|
| 1105 |
+
"""
|
| 1106 |
+
Parse the lines of an os-release file.
|
| 1107 |
+
|
| 1108 |
+
Parameters:
|
| 1109 |
+
|
| 1110 |
+
* lines: Iterable through the lines in the os-release file.
|
| 1111 |
+
Each line must be a unicode string or a UTF-8 encoded byte
|
| 1112 |
+
string.
|
| 1113 |
+
|
| 1114 |
+
Returns:
|
| 1115 |
+
A dictionary containing all information items.
|
| 1116 |
+
"""
|
| 1117 |
+
props = {}
|
| 1118 |
+
lexer = shlex.shlex(lines, posix=True)
|
| 1119 |
+
lexer.whitespace_split = True
|
| 1120 |
+
|
| 1121 |
+
tokens = list(lexer)
|
| 1122 |
+
for token in tokens:
|
| 1123 |
+
# At this point, all shell-like parsing has been done (i.e.
|
| 1124 |
+
# comments processed, quotes and backslash escape sequences
|
| 1125 |
+
# processed, multi-line values assembled, trailing newlines
|
| 1126 |
+
# stripped, etc.), so the tokens are now either:
|
| 1127 |
+
# * variable assignments: var=value
|
| 1128 |
+
# * commands or their arguments (not allowed in os-release)
|
| 1129 |
+
# Ignore any tokens that are not variable assignments
|
| 1130 |
+
if "=" in token:
|
| 1131 |
+
k, v = token.split("=", 1)
|
| 1132 |
+
props[k.lower()] = v
|
| 1133 |
+
|
| 1134 |
+
if "version" in props:
|
| 1135 |
+
# extract release codename (if any) from version attribute
|
| 1136 |
+
match = re.search(r"\((\D+)\)|,\s*(\D+)", props["version"])
|
| 1137 |
+
if match:
|
| 1138 |
+
release_codename = match.group(1) or match.group(2)
|
| 1139 |
+
props["codename"] = props["release_codename"] = release_codename
|
| 1140 |
+
|
| 1141 |
+
if "version_codename" in props:
|
| 1142 |
+
# os-release added a version_codename field. Use that in
|
| 1143 |
+
# preference to anything else Note that some distros purposefully
|
| 1144 |
+
# do not have code names. They should be setting
|
| 1145 |
+
# version_codename=""
|
| 1146 |
+
props["codename"] = props["version_codename"]
|
| 1147 |
+
elif "ubuntu_codename" in props:
|
| 1148 |
+
# Same as above but a non-standard field name used on older Ubuntus
|
| 1149 |
+
props["codename"] = props["ubuntu_codename"]
|
| 1150 |
+
|
| 1151 |
+
return props
|
| 1152 |
+
|
| 1153 |
+
@cached_property
|
| 1154 |
+
def _lsb_release_info(self) -> Dict[str, str]:
|
| 1155 |
+
"""
|
| 1156 |
+
Get the information items from the lsb_release command output.
|
| 1157 |
+
|
| 1158 |
+
Returns:
|
| 1159 |
+
A dictionary containing all information items.
|
| 1160 |
+
"""
|
| 1161 |
+
if not self.include_lsb:
|
| 1162 |
+
return {}
|
| 1163 |
+
try:
|
| 1164 |
+
cmd = ("lsb_release", "-a")
|
| 1165 |
+
stdout = subprocess.check_output(cmd, stderr=subprocess.DEVNULL)
|
| 1166 |
+
# Command not found or lsb_release returned error
|
| 1167 |
+
except (OSError, subprocess.CalledProcessError):
|
| 1168 |
+
return {}
|
| 1169 |
+
content = self._to_str(stdout).splitlines()
|
| 1170 |
+
return self._parse_lsb_release_content(content)
|
| 1171 |
+
|
| 1172 |
+
@staticmethod
|
| 1173 |
+
def _parse_lsb_release_content(lines: Iterable[str]) -> Dict[str, str]:
|
| 1174 |
+
"""
|
| 1175 |
+
Parse the output of the lsb_release command.
|
| 1176 |
+
|
| 1177 |
+
Parameters:
|
| 1178 |
+
|
| 1179 |
+
* lines: Iterable through the lines of the lsb_release output.
|
| 1180 |
+
Each line must be a unicode string or a UTF-8 encoded byte
|
| 1181 |
+
string.
|
| 1182 |
+
|
| 1183 |
+
Returns:
|
| 1184 |
+
A dictionary containing all information items.
|
| 1185 |
+
"""
|
| 1186 |
+
props = {}
|
| 1187 |
+
for line in lines:
|
| 1188 |
+
kv = line.strip("\n").split(":", 1)
|
| 1189 |
+
if len(kv) != 2:
|
| 1190 |
+
# Ignore lines without colon.
|
| 1191 |
+
continue
|
| 1192 |
+
k, v = kv
|
| 1193 |
+
props.update({k.replace(" ", "_").lower(): v.strip()})
|
| 1194 |
+
return props
|
| 1195 |
+
|
| 1196 |
+
@cached_property
|
| 1197 |
+
def _uname_info(self) -> Dict[str, str]:
|
| 1198 |
+
if not self.include_uname:
|
| 1199 |
+
return {}
|
| 1200 |
+
try:
|
| 1201 |
+
cmd = ("uname", "-rs")
|
| 1202 |
+
stdout = subprocess.check_output(cmd, stderr=subprocess.DEVNULL)
|
| 1203 |
+
except OSError:
|
| 1204 |
+
return {}
|
| 1205 |
+
content = self._to_str(stdout).splitlines()
|
| 1206 |
+
return self._parse_uname_content(content)
|
| 1207 |
+
|
| 1208 |
+
@cached_property
|
| 1209 |
+
def _oslevel_info(self) -> str:
|
| 1210 |
+
if not self.include_oslevel:
|
| 1211 |
+
return ""
|
| 1212 |
+
try:
|
| 1213 |
+
stdout = subprocess.check_output("oslevel", stderr=subprocess.DEVNULL)
|
| 1214 |
+
except (OSError, subprocess.CalledProcessError):
|
| 1215 |
+
return ""
|
| 1216 |
+
return self._to_str(stdout).strip()
|
| 1217 |
+
|
| 1218 |
+
@cached_property
|
| 1219 |
+
def _debian_version(self) -> str:
|
| 1220 |
+
try:
|
| 1221 |
+
with open(
|
| 1222 |
+
os.path.join(self.etc_dir, "debian_version"), encoding="ascii"
|
| 1223 |
+
) as fp:
|
| 1224 |
+
return fp.readline().rstrip()
|
| 1225 |
+
except FileNotFoundError:
|
| 1226 |
+
return ""
|
| 1227 |
+
|
| 1228 |
+
@staticmethod
|
| 1229 |
+
def _parse_uname_content(lines: Sequence[str]) -> Dict[str, str]:
|
| 1230 |
+
if not lines:
|
| 1231 |
+
return {}
|
| 1232 |
+
props = {}
|
| 1233 |
+
match = re.search(r"^([^\s]+)\s+([\d\.]+)", lines[0].strip())
|
| 1234 |
+
if match:
|
| 1235 |
+
name, version = match.groups()
|
| 1236 |
+
|
| 1237 |
+
# This is to prevent the Linux kernel version from
|
| 1238 |
+
# appearing as the 'best' version on otherwise
|
| 1239 |
+
# identifiable distributions.
|
| 1240 |
+
if name == "Linux":
|
| 1241 |
+
return {}
|
| 1242 |
+
props["id"] = name.lower()
|
| 1243 |
+
props["name"] = name
|
| 1244 |
+
props["release"] = version
|
| 1245 |
+
return props
|
| 1246 |
+
|
| 1247 |
+
@staticmethod
|
| 1248 |
+
def _to_str(bytestring: bytes) -> str:
|
| 1249 |
+
encoding = sys.getfilesystemencoding()
|
| 1250 |
+
return bytestring.decode(encoding)
|
| 1251 |
+
|
| 1252 |
+
@cached_property
|
| 1253 |
+
def _distro_release_info(self) -> Dict[str, str]:
|
| 1254 |
+
"""
|
| 1255 |
+
Get the information items from the specified distro release file.
|
| 1256 |
+
|
| 1257 |
+
Returns:
|
| 1258 |
+
A dictionary containing all information items.
|
| 1259 |
+
"""
|
| 1260 |
+
if self.distro_release_file:
|
| 1261 |
+
# If it was specified, we use it and parse what we can, even if
|
| 1262 |
+
# its file name or content does not match the expected pattern.
|
| 1263 |
+
distro_info = self._parse_distro_release_file(self.distro_release_file)
|
| 1264 |
+
basename = os.path.basename(self.distro_release_file)
|
| 1265 |
+
# The file name pattern for user-specified distro release files
|
| 1266 |
+
# is somewhat more tolerant (compared to when searching for the
|
| 1267 |
+
# file), because we want to use what was specified as best as
|
| 1268 |
+
# possible.
|
| 1269 |
+
match = _DISTRO_RELEASE_BASENAME_PATTERN.match(basename)
|
| 1270 |
+
else:
|
| 1271 |
+
try:
|
| 1272 |
+
basenames = [
|
| 1273 |
+
basename
|
| 1274 |
+
for basename in os.listdir(self.etc_dir)
|
| 1275 |
+
if basename not in _DISTRO_RELEASE_IGNORE_BASENAMES
|
| 1276 |
+
and os.path.isfile(os.path.join(self.etc_dir, basename))
|
| 1277 |
+
]
|
| 1278 |
+
# We sort for repeatability in cases where there are multiple
|
| 1279 |
+
# distro specific files; e.g. CentOS, Oracle, Enterprise all
|
| 1280 |
+
# containing `redhat-release` on top of their own.
|
| 1281 |
+
basenames.sort()
|
| 1282 |
+
except OSError:
|
| 1283 |
+
# This may occur when /etc is not readable but we can't be
|
| 1284 |
+
# sure about the *-release files. Check common entries of
|
| 1285 |
+
# /etc for information. If they turn out to not be there the
|
| 1286 |
+
# error is handled in `_parse_distro_release_file()`.
|
| 1287 |
+
basenames = _DISTRO_RELEASE_BASENAMES
|
| 1288 |
+
for basename in basenames:
|
| 1289 |
+
match = _DISTRO_RELEASE_BASENAME_PATTERN.match(basename)
|
| 1290 |
+
if match is None:
|
| 1291 |
+
continue
|
| 1292 |
+
filepath = os.path.join(self.etc_dir, basename)
|
| 1293 |
+
distro_info = self._parse_distro_release_file(filepath)
|
| 1294 |
+
# The name is always present if the pattern matches.
|
| 1295 |
+
if "name" not in distro_info:
|
| 1296 |
+
continue
|
| 1297 |
+
self.distro_release_file = filepath
|
| 1298 |
+
break
|
| 1299 |
+
else: # the loop didn't "break": no candidate.
|
| 1300 |
+
return {}
|
| 1301 |
+
|
| 1302 |
+
if match is not None:
|
| 1303 |
+
distro_info["id"] = match.group(1)
|
| 1304 |
+
|
| 1305 |
+
# CloudLinux < 7: manually enrich info with proper id.
|
| 1306 |
+
if "cloudlinux" in distro_info.get("name", "").lower():
|
| 1307 |
+
distro_info["id"] = "cloudlinux"
|
| 1308 |
+
|
| 1309 |
+
return distro_info
|
| 1310 |
+
|
| 1311 |
+
def _parse_distro_release_file(self, filepath: str) -> Dict[str, str]:
|
| 1312 |
+
"""
|
| 1313 |
+
Parse a distro release file.
|
| 1314 |
+
|
| 1315 |
+
Parameters:
|
| 1316 |
+
|
| 1317 |
+
* filepath: Path name of the distro release file.
|
| 1318 |
+
|
| 1319 |
+
Returns:
|
| 1320 |
+
A dictionary containing all information items.
|
| 1321 |
+
"""
|
| 1322 |
+
try:
|
| 1323 |
+
with open(filepath, encoding="utf-8") as fp:
|
| 1324 |
+
# Only parse the first line. For instance, on SLES there
|
| 1325 |
+
# are multiple lines. We don't want them...
|
| 1326 |
+
return self._parse_distro_release_content(fp.readline())
|
| 1327 |
+
except OSError:
|
| 1328 |
+
# Ignore not being able to read a specific, seemingly version
|
| 1329 |
+
# related file.
|
| 1330 |
+
# See https://github.com/python-distro/distro/issues/162
|
| 1331 |
+
return {}
|
| 1332 |
+
|
| 1333 |
+
@staticmethod
|
| 1334 |
+
def _parse_distro_release_content(line: str) -> Dict[str, str]:
|
| 1335 |
+
"""
|
| 1336 |
+
Parse a line from a distro release file.
|
| 1337 |
+
|
| 1338 |
+
Parameters:
|
| 1339 |
+
* line: Line from the distro release file. Must be a unicode string
|
| 1340 |
+
or a UTF-8 encoded byte string.
|
| 1341 |
+
|
| 1342 |
+
Returns:
|
| 1343 |
+
A dictionary containing all information items.
|
| 1344 |
+
"""
|
| 1345 |
+
matches = _DISTRO_RELEASE_CONTENT_REVERSED_PATTERN.match(line.strip()[::-1])
|
| 1346 |
+
distro_info = {}
|
| 1347 |
+
if matches:
|
| 1348 |
+
# regexp ensures non-None
|
| 1349 |
+
distro_info["name"] = matches.group(3)[::-1]
|
| 1350 |
+
if matches.group(2):
|
| 1351 |
+
distro_info["version_id"] = matches.group(2)[::-1]
|
| 1352 |
+
if matches.group(1):
|
| 1353 |
+
distro_info["codename"] = matches.group(1)[::-1]
|
| 1354 |
+
elif line:
|
| 1355 |
+
distro_info["name"] = line.strip()
|
| 1356 |
+
return distro_info
|
| 1357 |
+
|
| 1358 |
+
|
| 1359 |
+
_distro = LinuxDistribution()
|
| 1360 |
+
|
| 1361 |
+
|
| 1362 |
+
def main() -> None:
|
| 1363 |
+
logger = logging.getLogger(__name__)
|
| 1364 |
+
logger.setLevel(logging.DEBUG)
|
| 1365 |
+
logger.addHandler(logging.StreamHandler(sys.stdout))
|
| 1366 |
+
|
| 1367 |
+
parser = argparse.ArgumentParser(description="OS distro info tool")
|
| 1368 |
+
parser.add_argument(
|
| 1369 |
+
"--json", "-j", help="Output in machine readable format", action="store_true"
|
| 1370 |
+
)
|
| 1371 |
+
|
| 1372 |
+
parser.add_argument(
|
| 1373 |
+
"--root-dir",
|
| 1374 |
+
"-r",
|
| 1375 |
+
type=str,
|
| 1376 |
+
dest="root_dir",
|
| 1377 |
+
help="Path to the root filesystem directory (defaults to /)",
|
| 1378 |
+
)
|
| 1379 |
+
|
| 1380 |
+
args = parser.parse_args()
|
| 1381 |
+
|
| 1382 |
+
if args.root_dir:
|
| 1383 |
+
dist = LinuxDistribution(
|
| 1384 |
+
include_lsb=False,
|
| 1385 |
+
include_uname=False,
|
| 1386 |
+
include_oslevel=False,
|
| 1387 |
+
root_dir=args.root_dir,
|
| 1388 |
+
)
|
| 1389 |
+
else:
|
| 1390 |
+
dist = _distro
|
| 1391 |
+
|
| 1392 |
+
if args.json:
|
| 1393 |
+
logger.info(json.dumps(dist.info(), indent=4, sort_keys=True))
|
| 1394 |
+
else:
|
| 1395 |
+
logger.info("Name: %s", dist.name(pretty=True))
|
| 1396 |
+
distribution_version = dist.version(pretty=True)
|
| 1397 |
+
logger.info("Version: %s", distribution_version)
|
| 1398 |
+
distribution_codename = dist.codename()
|
| 1399 |
+
logger.info("Codename: %s", distribution_codename)
|
| 1400 |
+
|
| 1401 |
+
|
| 1402 |
+
if __name__ == "__main__":
|
| 1403 |
+
main()
|
miniconda3/pkgs/distro-1.9.0-py313h06a4308_0/lib/python3.13/site-packages/distro/py.typed
ADDED
|
File without changes
|
miniconda3/pkgs/expat-2.7.4-h7354ed3_0/bin/xmlwf
ADDED
|
Binary file (47.1 kB). View file
|
|
|
miniconda3/pkgs/expat-2.7.4-h7354ed3_0/info/about.json
ADDED
|
@@ -0,0 +1,189 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"channels": [
|
| 3 |
+
"https://repo.anaconda.com/pkgs/main",
|
| 4 |
+
"https://repo.anaconda.com/pkgs/r",
|
| 5 |
+
"https://repo.anaconda.com/pkgs/r"
|
| 6 |
+
],
|
| 7 |
+
"conda_build_version": "25.11.1",
|
| 8 |
+
"conda_version": "25.1.1",
|
| 9 |
+
"description": "Expat is a stream-oriented XML parser library written in C.\nExpat excels with files too large to fit RAM, and where performance\nand flexibility are crucial.\n",
|
| 10 |
+
"dev_url": "https://github.com/libexpat/libexpat",
|
| 11 |
+
"doc_url": "https://libexpat.github.io/doc",
|
| 12 |
+
"env_vars": {
|
| 13 |
+
"CIO_TEST": "<not set>"
|
| 14 |
+
},
|
| 15 |
+
"extra": {
|
| 16 |
+
"copy_test_source_files": true,
|
| 17 |
+
"final": true,
|
| 18 |
+
"parent_recipe": {
|
| 19 |
+
"name": "expat-split",
|
| 20 |
+
"path": "/home/task_177006210476465/expat-feedstock/recipe",
|
| 21 |
+
"version": "2.7.4"
|
| 22 |
+
},
|
| 23 |
+
"pbp_graph_uuid": "357eb72c-e51e-4011-b5ed-03ee225dfcbc",
|
| 24 |
+
"recipe-maintainers": [
|
| 25 |
+
"kwilcox",
|
| 26 |
+
"ocefpaf",
|
| 27 |
+
"pelson",
|
| 28 |
+
"mingwandroid",
|
| 29 |
+
"msarahan",
|
| 30 |
+
"scopatz"
|
| 31 |
+
],
|
| 32 |
+
"remote_url": "https://github.com/AnacondaRecipes/expat-feedstock",
|
| 33 |
+
"sha": "75551a24940eb30b246084f4d3af1d377b625365",
|
| 34 |
+
"task_id": "ef61zYeqSiKIenZ0NpLiGQ",
|
| 35 |
+
"task_run_id": "0"
|
| 36 |
+
},
|
| 37 |
+
"home": "https://libexpat.github.io",
|
| 38 |
+
"identifiers": [],
|
| 39 |
+
"keywords": [],
|
| 40 |
+
"license": "MIT",
|
| 41 |
+
"license_family": "MIT",
|
| 42 |
+
"license_file": "COPYING",
|
| 43 |
+
"root_pkgs": [
|
| 44 |
+
"_libgcc_mutex 0.1 main",
|
| 45 |
+
"ca-certificates 2025.12.2 h06a4308_0",
|
| 46 |
+
"ld_impl_linux-64 2.40 h12ee557_0",
|
| 47 |
+
"libstdcxx-ng 11.2.0 h1234567_1",
|
| 48 |
+
"nlohmann_json 3.11.2 h6a678d5_0",
|
| 49 |
+
"pybind11-abi 5 hd3eb1b0_0",
|
| 50 |
+
"tzdata 2025a h04d1e81_0",
|
| 51 |
+
"libgomp 11.2.0 h1234567_1",
|
| 52 |
+
"_openmp_mutex 5.1 1_gnu",
|
| 53 |
+
"libgcc-ng 11.2.0 h1234567_1",
|
| 54 |
+
"bzip2 1.0.8 h5eee18b_6",
|
| 55 |
+
"c-ares 1.19.1 h5eee18b_0",
|
| 56 |
+
"cpp-expected 1.1.0 hdb19cb5_0",
|
| 57 |
+
"expat 2.7.3 h3385a95_0",
|
| 58 |
+
"fmt 9.1.0 hdb19cb5_1",
|
| 59 |
+
"icu 73.1 h6a678d5_0",
|
| 60 |
+
"libev 4.33 h7f8727e_1",
|
| 61 |
+
"libffi 3.4.4 h6a678d5_1",
|
| 62 |
+
"libuuid 1.41.5 h5eee18b_0",
|
| 63 |
+
"lz4-c 1.9.4 h6a678d5_1",
|
| 64 |
+
"ncurses 6.4 h6a678d5_0",
|
| 65 |
+
"reproc 14.2.4 h6a678d5_2",
|
| 66 |
+
"simdjson 3.10.1 hdb19cb5_0",
|
| 67 |
+
"xz 5.4.6 h5eee18b_1",
|
| 68 |
+
"yaml-cpp 0.8.0 h6a678d5_1",
|
| 69 |
+
"zlib 1.2.13 h5eee18b_1",
|
| 70 |
+
"libedit 3.1.20230828 h5eee18b_0",
|
| 71 |
+
"libnghttp2 1.57.0 h2d74bed_0",
|
| 72 |
+
"libssh2 1.11.1 h251f7ec_0",
|
| 73 |
+
"libxml2 2.13.5 hfdd30dd_0",
|
| 74 |
+
"pcre2 10.42 hebb0a14_1",
|
| 75 |
+
"readline 8.2 h5eee18b_0",
|
| 76 |
+
"reproc-cpp 14.2.4 h6a678d5_2",
|
| 77 |
+
"spdlog 1.11.0 hdb19cb5_0",
|
| 78 |
+
"patch 2.8 hb25bd0a_0",
|
| 79 |
+
"zstd 1.5.6 hc292b87_0",
|
| 80 |
+
"krb5 1.20.1 h143b758_1",
|
| 81 |
+
"libarchive 3.7.7 hfab0078_0",
|
| 82 |
+
"libsolv 0.7.30 he621ea3_1",
|
| 83 |
+
"sqlite 3.45.3 h5eee18b_0",
|
| 84 |
+
"python 3.12.9 h5148396_0",
|
| 85 |
+
"libmamba 2.0.5 haf1ee3a_1",
|
| 86 |
+
"menuinst 2.2.0 py312h06a4308_1",
|
| 87 |
+
"anaconda-anon-usage 0.5.0 py312hfc0e8ea_100",
|
| 88 |
+
"annotated-types 0.6.0 py312h06a4308_0",
|
| 89 |
+
"archspec 0.2.3 pyhd3eb1b0_0",
|
| 90 |
+
"boltons 24.1.0 py312h06a4308_0",
|
| 91 |
+
"brotli-python 1.0.9 py312h6a678d5_9",
|
| 92 |
+
"charset-normalizer 3.3.2 pyhd3eb1b0_0",
|
| 93 |
+
"distro 1.9.0 py312h06a4308_0",
|
| 94 |
+
"frozendict 2.4.2 py312h06a4308_0",
|
| 95 |
+
"idna 3.7 py312h06a4308_0",
|
| 96 |
+
"jsonpointer 2.1 pyhd3eb1b0_0",
|
| 97 |
+
"libmambapy 2.0.5 py312hdb19cb5_1",
|
| 98 |
+
"mdurl 0.1.0 py312h06a4308_0",
|
| 99 |
+
"packaging 24.2 py312h06a4308_0",
|
| 100 |
+
"platformdirs 3.10.0 py312h06a4308_0",
|
| 101 |
+
"pluggy 1.5.0 py312h06a4308_0",
|
| 102 |
+
"pycosat 0.6.6 py312h5eee18b_2",
|
| 103 |
+
"pycparser 2.21 pyhd3eb1b0_0",
|
| 104 |
+
"pygments 2.15.1 py312h06a4308_1",
|
| 105 |
+
"pysocks 1.7.1 py312h06a4308_0",
|
| 106 |
+
"ruamel.yaml.clib 0.2.8 py312h5eee18b_0",
|
| 107 |
+
"setuptools 75.8.0 py312h06a4308_0",
|
| 108 |
+
"tqdm 4.67.1 py312he106c6f_0",
|
| 109 |
+
"truststore 0.10.0 py312h06a4308_0",
|
| 110 |
+
"typing_extensions 4.12.2 py312h06a4308_0",
|
| 111 |
+
"wheel 0.45.1 py312h06a4308_0",
|
| 112 |
+
"cffi 1.17.1 py312h1fdaa30_1",
|
| 113 |
+
"jsonpatch 1.33 py312h06a4308_1",
|
| 114 |
+
"markdown-it-py 2.2.0 py312h06a4308_1",
|
| 115 |
+
"pip 25.0 py312h06a4308_0",
|
| 116 |
+
"ruamel.yaml 0.18.6 py312h5eee18b_0",
|
| 117 |
+
"typing-extensions 4.12.2 py312h06a4308_0",
|
| 118 |
+
"urllib3 2.3.0 py312h06a4308_0",
|
| 119 |
+
"cryptography 43.0.3 py312h7825ff9_1",
|
| 120 |
+
"pydantic-core 2.27.1 py312h4aa5aa6_0",
|
| 121 |
+
"requests 2.32.3 py312h06a4308_1",
|
| 122 |
+
"rich 13.9.4 py312h06a4308_0",
|
| 123 |
+
"zstandard 0.23.0 py312h2c38b39_1",
|
| 124 |
+
"conda-content-trust 0.2.0 py312h06a4308_1",
|
| 125 |
+
"conda-package-streaming 0.11.0 py312h06a4308_0",
|
| 126 |
+
"pydantic 2.10.3 py312h06a4308_0",
|
| 127 |
+
"conda-package-handling 2.4.0 py312h06a4308_0",
|
| 128 |
+
"conda 25.1.1 py312h06a4308_0",
|
| 129 |
+
"conda-anaconda-tos 0.1.2 py312h06a4308_0",
|
| 130 |
+
"conda-libmamba-solver 25.1.1 pyhd3eb1b0_0",
|
| 131 |
+
"libiconv 1.16 h5eee18b_3",
|
| 132 |
+
"libsodium 1.0.20 heac8642_0",
|
| 133 |
+
"libunistring 1.3 hb25bd0a_0",
|
| 134 |
+
"mbedtls 3.5.1 h6a678d5_1",
|
| 135 |
+
"openssl 3.0.18 hd6dcaed_0",
|
| 136 |
+
"patchelf 0.17.2 h6a678d5_0",
|
| 137 |
+
"perl 5.40.2 0_h5eee18b_perl5",
|
| 138 |
+
"pthread-stubs 0.3 h0ce48e5_1",
|
| 139 |
+
"xorg-libxau 1.0.12 h9b100fa_0",
|
| 140 |
+
"xorg-libxdmcp 1.1.5 h9b100fa_0",
|
| 141 |
+
"xorg-xorgproto 2024.1 h5eee18b_1",
|
| 142 |
+
"yaml 0.2.5 h7b6447c_0",
|
| 143 |
+
"liblief 0.16.4 h6a678d5_0",
|
| 144 |
+
"libxcb 1.17.0 h9b100fa_0",
|
| 145 |
+
"gettext 0.21.0 hedfda30_2",
|
| 146 |
+
"xorg-libx11 1.8.12 h9b100fa_1",
|
| 147 |
+
"libidn2 2.3.8 hf80d704_0",
|
| 148 |
+
"tk 8.6.15 h54e0aa7_0",
|
| 149 |
+
"libcurl 8.16.0 heebcbe5_0",
|
| 150 |
+
"git 2.51.0 pl5382h000ed5b_0",
|
| 151 |
+
"argcomplete 3.6.2 py312h06a4308_0",
|
| 152 |
+
"attrs 25.4.0 py312h06a4308_2",
|
| 153 |
+
"certifi 2026.01.04 py312h06a4308_0",
|
| 154 |
+
"chardet 5.2.0 py312h06a4308_0",
|
| 155 |
+
"click 8.2.1 py312h06a4308_1",
|
| 156 |
+
"evalidate 2.0.3 py312h06a4308_0",
|
| 157 |
+
"filelock 3.20.0 py312h06a4308_0",
|
| 158 |
+
"jmespath 1.0.1 py312h06a4308_0",
|
| 159 |
+
"markupsafe 3.0.2 py312h5eee18b_0",
|
| 160 |
+
"msgpack-python 1.1.1 py312h6a678d5_0",
|
| 161 |
+
"pkginfo 1.12.1.2 py312h06a4308_0",
|
| 162 |
+
"psutil 7.0.0 py312hee96239_1",
|
| 163 |
+
"py-lief 0.16.4 py312h6a678d5_0",
|
| 164 |
+
"python-libarchive-c 5.1 pyhd3eb1b0_0",
|
| 165 |
+
"pytz 2025.2 py312h06a4308_0",
|
| 166 |
+
"pyyaml 6.0.2 py312h5eee18b_0",
|
| 167 |
+
"rpds-py 0.28.0 py312h498d7c9_0",
|
| 168 |
+
"six 1.17.0 py312h06a4308_0",
|
| 169 |
+
"soupsieve 2.5 py312h06a4308_0",
|
| 170 |
+
"tomlkit 0.13.3 py312h06a4308_0",
|
| 171 |
+
"xmltodict 0.14.2 py312h06a4308_0",
|
| 172 |
+
"jinja2 3.1.6 py312h06a4308_0",
|
| 173 |
+
"python-dateutil 2.9.0post0 py312h06a4308_2",
|
| 174 |
+
"referencing 0.37.0 py312h06a4308_0",
|
| 175 |
+
"yq 3.4.3 py312h06a4308_0",
|
| 176 |
+
"beautifulsoup4 4.14.2 py312h06a4308_0",
|
| 177 |
+
"botocore 1.42.19 py312h06a4308_0",
|
| 178 |
+
"jsonschema-specifications 2025.9.1 py312h06a4308_0",
|
| 179 |
+
"pynacl 1.6.0 py312h2630517_0",
|
| 180 |
+
"jsonschema 4.25.1 py312h06a4308_0",
|
| 181 |
+
"s3transfer 0.16.0 py312h06a4308_0",
|
| 182 |
+
"boto3 1.42.19 py312h06a4308_0",
|
| 183 |
+
"conda-anaconda-telemetry 0.3.0 pyhd3eb1b0_1",
|
| 184 |
+
"conda-index 0.7.0 py312h06a4308_0",
|
| 185 |
+
"conda-build 25.11.1 py312h76456e7_0"
|
| 186 |
+
],
|
| 187 |
+
"summary": "Expat XML parser library in C",
|
| 188 |
+
"tags": []
|
| 189 |
+
}
|
miniconda3/pkgs/expat-2.7.4-h7354ed3_0/info/files
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
|
|
|
| 1 |
+
bin/xmlwf
|
| 2 |
+
share/man/man1/xmlwf.1
|
miniconda3/pkgs/expat-2.7.4-h7354ed3_0/info/git
ADDED
|
File without changes
|
miniconda3/pkgs/expat-2.7.4-h7354ed3_0/info/hash_input.json
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"target_platform": "linux-64",
|
| 3 |
+
"c_compiler": "gcc",
|
| 4 |
+
"cxx_compiler": "gxx",
|
| 5 |
+
"cxx_compiler_version": "14.3.0",
|
| 6 |
+
"channel_targets": "defaults",
|
| 7 |
+
"c_stdlib_version": "2.28",
|
| 8 |
+
"c_stdlib": "sysroot",
|
| 9 |
+
"c_compiler_version": "14.3.0",
|
| 10 |
+
"__glibc": "__glibc >=2.28,<3.0.a0"
|
| 11 |
+
}
|
miniconda3/pkgs/expat-2.7.4-h7354ed3_0/info/index.json
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"arch": "x86_64",
|
| 3 |
+
"build": "h7354ed3_0",
|
| 4 |
+
"build_number": 0,
|
| 5 |
+
"depends": [
|
| 6 |
+
"__glibc >=2.28,<3.0.a0",
|
| 7 |
+
"libexpat 2.7.4 h7354ed3_0",
|
| 8 |
+
"libgcc >=14",
|
| 9 |
+
"libstdcxx >=14"
|
| 10 |
+
],
|
| 11 |
+
"license": "MIT",
|
| 12 |
+
"license_family": "MIT",
|
| 13 |
+
"name": "expat",
|
| 14 |
+
"platform": "linux",
|
| 15 |
+
"subdir": "linux-64",
|
| 16 |
+
"timestamp": 1770062547137,
|
| 17 |
+
"version": "2.7.4"
|
| 18 |
+
}
|
miniconda3/pkgs/expat-2.7.4-h7354ed3_0/info/licenses/COPYING
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
Copyright (c) 1998-2000 Thai Open Source Software Center Ltd and Clark Cooper
|
| 2 |
+
Copyright (c) 2001-2025 Expat maintainers
|
| 3 |
+
|
| 4 |
+
Permission is hereby granted, free of charge, to any person obtaining
|
| 5 |
+
a copy of this software and associated documentation files (the
|
| 6 |
+
"Software"), to deal in the Software without restriction, including
|
| 7 |
+
without limitation the rights to use, copy, modify, merge, publish,
|
| 8 |
+
distribute, sublicense, and/or sell copies of the Software, and to
|
| 9 |
+
permit persons to whom the Software is furnished to do so, subject to
|
| 10 |
+
the following conditions:
|
| 11 |
+
|
| 12 |
+
The above copyright notice and this permission notice shall be included
|
| 13 |
+
in all copies or substantial portions of the Software.
|
| 14 |
+
|
| 15 |
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
| 16 |
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
| 17 |
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
| 18 |
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
| 19 |
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
| 20 |
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
| 21 |
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
miniconda3/pkgs/expat-2.7.4-h7354ed3_0/info/paths.json
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"paths": [
|
| 3 |
+
{
|
| 4 |
+
"_path": "bin/xmlwf",
|
| 5 |
+
"path_type": "hardlink",
|
| 6 |
+
"sha256": "31b6ff9d2a3c442d5f5f8c52fcb9f6b1ec03050325ec555df0eb0d014a5f8385",
|
| 7 |
+
"size_in_bytes": 47104
|
| 8 |
+
},
|
| 9 |
+
{
|
| 10 |
+
"_path": "share/man/man1/xmlwf.1",
|
| 11 |
+
"path_type": "hardlink",
|
| 12 |
+
"sha256": "825f0d8a1e62cb022543bbc875dec92fbc3dfae874b0b68e481d53190aa96cc7",
|
| 13 |
+
"size_in_bytes": 11514
|
| 14 |
+
}
|
| 15 |
+
],
|
| 16 |
+
"paths_version": 1
|
| 17 |
+
}
|
miniconda3/pkgs/expat-2.7.4-h7354ed3_0/info/recipe/conda_build_config.yaml
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
c_compiler: gcc
|
| 2 |
+
c_compiler_version: 14.3.0
|
| 3 |
+
c_stdlib: sysroot
|
| 4 |
+
c_stdlib_version: '2.28'
|
| 5 |
+
channel_targets: defaults
|
| 6 |
+
cpu_optimization_target: nocona
|
| 7 |
+
cran_mirror: https://cran.r-project.org
|
| 8 |
+
cxx_compiler: gxx
|
| 9 |
+
cxx_compiler_version: 14.3.0
|
| 10 |
+
expat: '2'
|
| 11 |
+
extend_keys:
|
| 12 |
+
- ignore_version
|
| 13 |
+
- pin_run_as_build
|
| 14 |
+
- ignore_build_only_deps
|
| 15 |
+
- extend_keys
|
| 16 |
+
fortran_compiler: gfortran
|
| 17 |
+
ignore_build_only_deps:
|
| 18 |
+
- python
|
| 19 |
+
- numpy
|
| 20 |
+
lua: '5'
|
| 21 |
+
numpy: '1.26'
|
| 22 |
+
perl: 5.26.2
|
| 23 |
+
pin_run_as_build:
|
| 24 |
+
python:
|
| 25 |
+
max_pin: x.x
|
| 26 |
+
min_pin: x.x
|
| 27 |
+
r-base:
|
| 28 |
+
max_pin: x.x
|
| 29 |
+
min_pin: x.x
|
| 30 |
+
platform: linux-64
|
| 31 |
+
python: '3.11'
|
| 32 |
+
r_base: '3.5'
|
| 33 |
+
target_platform: linux-64
|
miniconda3/pkgs/expat-2.7.4-h7354ed3_0/info/recipe/meta.yaml
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# This file created by conda-build 25.11.1
|
| 2 |
+
# ------------------------------------------------
|
| 3 |
+
|
| 4 |
+
package:
|
| 5 |
+
name: expat
|
| 6 |
+
version: 2.7.4
|
| 7 |
+
source:
|
| 8 |
+
url: https://github.com/libexpat/libexpat/releases/download/R_2_7_4/expat-2.7.4.tar.bz2
|
| 9 |
+
sha256: e6af11b01e32e5ef64906a5cca8809eabc4beb7ff2f9a0e6aabbd42e825135d0
|
| 10 |
+
build:
|
| 11 |
+
number: '0'
|
| 12 |
+
run_exports:
|
| 13 |
+
- libexpat >=2.7.4,<3.0a0
|
| 14 |
+
noarch: false
|
| 15 |
+
noarch_python: false
|
| 16 |
+
python_version_independent: false
|
| 17 |
+
string: h7354ed3_0
|
| 18 |
+
requirements:
|
| 19 |
+
build:
|
| 20 |
+
- _libgcc_mutex 0.1 main
|
| 21 |
+
- _openmp_mutex 5.1 1_gnu
|
| 22 |
+
- binutils_impl_linux-64 2.44 h4b9a079_2
|
| 23 |
+
- binutils_linux-64 2.44 hc03a8fd_2
|
| 24 |
+
- gcc_impl_linux-64 14.3.0 h4943218_4
|
| 25 |
+
- gcc_linux-64 14.3.0 hda73cce_12
|
| 26 |
+
- gxx_impl_linux-64 14.3.0 he634eba_4
|
| 27 |
+
- gxx_linux-64 14.3.0 hca8765c_12
|
| 28 |
+
- kernel-headers_linux-64 4.18.0 h3108a97_1
|
| 29 |
+
- ld_impl_linux-64 2.44 h153f514_2
|
| 30 |
+
- libgcc 15.2.0 h69a1729_7
|
| 31 |
+
- libgcc-devel_linux-64 14.3.0 he7458c1_104
|
| 32 |
+
- libgomp 15.2.0 h4751f2c_7
|
| 33 |
+
- libsanitizer 14.3.0 hd4faa28_4
|
| 34 |
+
- libstdcxx 15.2.0 h39759b7_7
|
| 35 |
+
- libstdcxx-devel_linux-64 14.3.0 he7458c1_104
|
| 36 |
+
- sysroot_linux-64 2.28 h3108a97_1
|
| 37 |
+
- tzdata 2025c he532380_0
|
| 38 |
+
host:
|
| 39 |
+
- _libgcc_mutex 0.1 main
|
| 40 |
+
- _openmp_mutex 5.1 1_gnu
|
| 41 |
+
- libexpat 2.7.4 h7354ed3_0
|
| 42 |
+
- libgcc 15.2.0 h69a1729_7
|
| 43 |
+
- libgomp 15.2.0 h4751f2c_7
|
| 44 |
+
- libstdcxx 15.2.0 h39759b7_7
|
| 45 |
+
run:
|
| 46 |
+
- __glibc >=2.28,<3.0.a0
|
| 47 |
+
- libexpat 2.7.4 h7354ed3_0
|
| 48 |
+
- libgcc >=14
|
| 49 |
+
- libstdcxx >=14
|
| 50 |
+
test:
|
| 51 |
+
commands:
|
| 52 |
+
- xmlwf -h
|
| 53 |
+
about:
|
| 54 |
+
home: https://libexpat.github.io
|
| 55 |
+
license: MIT
|
| 56 |
+
license_family: MIT
|
| 57 |
+
license_file: COPYING
|
| 58 |
+
summary: Expat XML parser library in C
|
| 59 |
+
description: 'Expat is a stream-oriented XML parser library written in C.
|
| 60 |
+
|
| 61 |
+
Expat excels with files too large to fit RAM, and where performance
|
| 62 |
+
|
| 63 |
+
and flexibility are crucial.
|
| 64 |
+
|
| 65 |
+
'
|
| 66 |
+
dev_url: https://github.com/libexpat/libexpat
|
| 67 |
+
doc_url: https://libexpat.github.io/doc
|
| 68 |
+
extra:
|
| 69 |
+
recipe-maintainers:
|
| 70 |
+
- kwilcox
|
| 71 |
+
- mingwandroid
|
| 72 |
+
- msarahan
|
| 73 |
+
- ocefpaf
|
| 74 |
+
- pelson
|
| 75 |
+
- scopatz
|
| 76 |
+
final: true
|
| 77 |
+
copy_test_source_files: true
|
| 78 |
+
remote_url: https://github.com/AnacondaRecipes/expat-feedstock
|
| 79 |
+
sha: 75551a24940eb30b246084f4d3af1d377b625365
|
| 80 |
+
task_id: ef61zYeqSiKIenZ0NpLiGQ
|
| 81 |
+
task_run_id: '0'
|
| 82 |
+
pbp_graph_uuid: 357eb72c-e51e-4011-b5ed-03ee225dfcbc
|
miniconda3/pkgs/expat-2.7.4-h7354ed3_0/info/recipe/parent/bld.bat
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
:: Needed so we can find stdint.h from msinttypes.
|
| 2 |
+
set LIB=%LIBRARY_LIB%;%LIB%
|
| 3 |
+
set LIBPATH=%LIBRARY_LIB%;%LIBPATH%
|
| 4 |
+
set INCLUDE=%LIBRARY_INC%;%INCLUDE%
|
| 5 |
+
|
| 6 |
+
:: VS2008 doesn't have stdbool.h so copy in our own
|
| 7 |
+
:: to 'lib' where the other headers are so it gets picked up.
|
| 8 |
+
if "%VS_MAJOR%" == "9" (
|
| 9 |
+
copy %RECIPE_DIR%\stdbool.h lib\
|
| 10 |
+
copy %LIBRARY_INC%\stdint.h lib\
|
| 11 |
+
)
|
| 12 |
+
|
| 13 |
+
:: set cflags because NDEBUG is set in Release configuration, which errors out in test suite due to no assert
|
| 14 |
+
cmake -G "Ninja" ^
|
| 15 |
+
-D CMAKE_INSTALL_PREFIX=%LIBRARY_PREFIX% ^
|
| 16 |
+
-D CMAKE_C_FLAGS_RELEASE="%CFLAGS%" ^
|
| 17 |
+
-D CMAKE_CXX_FLAGS_RELEASE="%CXXFLAGS%" ^
|
| 18 |
+
-D CMAKE_BUILD_TYPE=Release ^
|
| 19 |
+
-D EXPAT_BUILD_TOOLS=ON ^
|
| 20 |
+
-D EXPAT_BUILD_PKGCONFIG=OFF ^
|
| 21 |
+
-D EXPAT_BUILD_TESTS=ON ^
|
| 22 |
+
-D EXPAT_BUILD_EXAMPLES=OFF ^
|
| 23 |
+
-D EXPAT_BUILD_DOCS=OFF ^
|
| 24 |
+
-D BUILD_SHARED_LIBS=ON ^
|
| 25 |
+
-S %SRC_DIR% ^
|
| 26 |
+
-B build
|
| 27 |
+
|
| 28 |
+
:: Build and install.
|
| 29 |
+
cmake --build build --config Release --parallel %CPU_COUNT% --target install
|
| 30 |
+
if errorlevel 1 exit 1
|
| 31 |
+
|
| 32 |
+
:: Test.
|
| 33 |
+
ctest -C Release --test-dir build
|
| 34 |
+
if errorlevel 1 exit 1
|
| 35 |
+
|
| 36 |
+
:: Workaround for package that got build with latet version that renamed these.
|
| 37 |
+
copy %LIBRARY_BIN%\\libexpat.dll %LIBRARY_BIN%\\expat.dll || exit 1
|
| 38 |
+
copy %LIBRARY_LIB%\\libexpat.lib %LIBRARY_LIB%\\expat.lib || exit 1
|
miniconda3/pkgs/expat-2.7.4-h7354ed3_0/info/recipe/parent/build.sh
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/bash
|
| 2 |
+
|
| 3 |
+
# Configure using CMake
|
| 4 |
+
cmake -G "Ninja" \
|
| 5 |
+
$CMAKE_ARGS \
|
| 6 |
+
-DEXPAT_BUILD_TOOLS=ON \
|
| 7 |
+
-DEXPAT_BUILD_PKGCONFIG=ON \
|
| 8 |
+
-DEXPAT_BUILD_TESTS=ON \
|
| 9 |
+
-DEXPAT_BUILD_EXAMPLES=OFF \
|
| 10 |
+
-DEXPAT_BUILD_DOCS=OFF \
|
| 11 |
+
-DCMAKE_BUILD_TYPE=Release \
|
| 12 |
+
-DBUILD_SHARED_LIBS=ON \
|
| 13 |
+
-DCMAKE_INSTALL_PREFIX=$PREFIX \
|
| 14 |
+
-S $SRC_DIR \
|
| 15 |
+
-B build
|
| 16 |
+
|
| 17 |
+
# Build and install
|
| 18 |
+
cmake --build build --config Release --parallel $CPU_COUNT --target install
|
| 19 |
+
|
| 20 |
+
# Run tests
|
| 21 |
+
ctest -C Release --test-dir build
|
miniconda3/pkgs/expat-2.7.4-h7354ed3_0/info/recipe/parent/meta.yaml
ADDED
|
@@ -0,0 +1,108 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{% set name = "expat" %}
|
| 2 |
+
{% set version = "2.7.4" %}
|
| 3 |
+
|
| 4 |
+
package:
|
| 5 |
+
name: {{ name }}-split
|
| 6 |
+
version: {{ version }}
|
| 7 |
+
|
| 8 |
+
source:
|
| 9 |
+
url: https://github.com/lib{{ name }}/lib{{ name }}/releases/download/R_{{ version|replace(".", "_") }}/{{ name }}-{{ version }}.tar.bz2
|
| 10 |
+
sha256: e6af11b01e32e5ef64906a5cca8809eabc4beb7ff2f9a0e6aabbd42e825135d0
|
| 11 |
+
|
| 12 |
+
build:
|
| 13 |
+
number: 0
|
| 14 |
+
|
| 15 |
+
requirements:
|
| 16 |
+
build:
|
| 17 |
+
- {{ stdlib('c') }}
|
| 18 |
+
- {{ compiler('c') }}
|
| 19 |
+
- {{ compiler('cxx') }}
|
| 20 |
+
- cmake
|
| 21 |
+
- ninja-base
|
| 22 |
+
|
| 23 |
+
outputs:
|
| 24 |
+
- name: lib{{ name }}
|
| 25 |
+
run_exports:
|
| 26 |
+
# changes soname at major versions, default settings OK
|
| 27 |
+
# https://abi-laboratory.pro/tracker/timeline/expat/
|
| 28 |
+
- {{ pin_subpackage('lib' + name) }}
|
| 29 |
+
ignore_run_exports_from:
|
| 30 |
+
# This package needs the compiler for the tests, but the library
|
| 31 |
+
# does not link to libstdc++.so
|
| 32 |
+
- {{ compiler('cxx') }}
|
| 33 |
+
files:
|
| 34 |
+
- include # [unix]
|
| 35 |
+
- lib/libexpat.* # [unix]
|
| 36 |
+
- lib/cmake # [unix]
|
| 37 |
+
- lib/pkgconfig # [unix]
|
| 38 |
+
- share/doc # [unix]
|
| 39 |
+
- Library/bin/*expat.dll # [win]
|
| 40 |
+
- Library/include # [win]
|
| 41 |
+
- Library/lib/*expat.lib # [win]
|
| 42 |
+
- Library/lib/cmake # [win]
|
| 43 |
+
- Library/share/doc # [win]
|
| 44 |
+
requirements:
|
| 45 |
+
build:
|
| 46 |
+
- {{ stdlib('c') }}
|
| 47 |
+
- {{ compiler('c') }}
|
| 48 |
+
- {{ compiler('cxx') }}
|
| 49 |
+
host:
|
| 50 |
+
run:
|
| 51 |
+
run_constrained:
|
| 52 |
+
- {{ name }} {{ version }}.*
|
| 53 |
+
test:
|
| 54 |
+
requires:
|
| 55 |
+
- pkg-config
|
| 56 |
+
commands:
|
| 57 |
+
- ls $PREFIX/lib/libexpat*${SHLIB_EXT}* > /dev/null 2>&1 # [unix]
|
| 58 |
+
- pkg-config --libs expat # [unix]
|
| 59 |
+
- if not exist %LIBRARY_BIN%\libexpat.dll exit 1 # [win]
|
| 60 |
+
|
| 61 |
+
- name: {{ name }}
|
| 62 |
+
run_exports:
|
| 63 |
+
# changes soname at major versions, default settings OK
|
| 64 |
+
# https://abi-laboratory.pro/tracker/timeline/expat/
|
| 65 |
+
- {{ pin_subpackage('lib' + name) }}
|
| 66 |
+
ignore_run_exports_from:
|
| 67 |
+
# This package needs the compiler for the tests, but the library
|
| 68 |
+
# does not link to libstdc++.so
|
| 69 |
+
- {{ compiler('cxx') }}
|
| 70 |
+
files:
|
| 71 |
+
- bin # [unix]
|
| 72 |
+
- share/man # [unix]
|
| 73 |
+
- Library/bin/*.exe # [win]
|
| 74 |
+
- Library/share/man # [win]
|
| 75 |
+
requirements:
|
| 76 |
+
build:
|
| 77 |
+
- {{ stdlib('c') }}
|
| 78 |
+
- {{ compiler('c') }}
|
| 79 |
+
- {{ compiler('cxx') }}
|
| 80 |
+
host:
|
| 81 |
+
- {{ pin_subpackage('lib' + name, exact=True) }}
|
| 82 |
+
run:
|
| 83 |
+
- {{ pin_subpackage('lib' + name, exact=True) }}
|
| 84 |
+
test:
|
| 85 |
+
commands:
|
| 86 |
+
- xmlwf -h
|
| 87 |
+
|
| 88 |
+
about:
|
| 89 |
+
home: https://libexpat.github.io
|
| 90 |
+
license: MIT
|
| 91 |
+
license_family: MIT
|
| 92 |
+
license_file: COPYING
|
| 93 |
+
summary: Expat XML parser library in C
|
| 94 |
+
description: |
|
| 95 |
+
Expat is a stream-oriented XML parser library written in C.
|
| 96 |
+
Expat excels with files too large to fit RAM, and where performance
|
| 97 |
+
and flexibility are crucial.
|
| 98 |
+
dev_url: https://github.com/libexpat/libexpat
|
| 99 |
+
doc_url: https://libexpat.github.io/doc
|
| 100 |
+
|
| 101 |
+
extra:
|
| 102 |
+
recipe-maintainers:
|
| 103 |
+
- kwilcox
|
| 104 |
+
- ocefpaf
|
| 105 |
+
- pelson
|
| 106 |
+
- mingwandroid
|
| 107 |
+
- msarahan
|
| 108 |
+
- scopatz
|
miniconda3/pkgs/expat-2.7.4-h7354ed3_0/info/recipe/parent/stdbool.h
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
typedef int bool;
|
| 2 |
+
#define false 0
|
| 3 |
+
#define true 1
|
miniconda3/pkgs/expat-2.7.4-h7354ed3_0/info/repodata_record.json
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"arch": "x86_64",
|
| 3 |
+
"build": "h7354ed3_0",
|
| 4 |
+
"build_number": 0,
|
| 5 |
+
"channel": "https://repo.anaconda.com/pkgs/main/linux-64/",
|
| 6 |
+
"constrains": [],
|
| 7 |
+
"depends": [
|
| 8 |
+
"__glibc >=2.28,<3.0.a0",
|
| 9 |
+
"libexpat 2.7.4 h7354ed3_0",
|
| 10 |
+
"libgcc >=14",
|
| 11 |
+
"libstdcxx >=14"
|
| 12 |
+
],
|
| 13 |
+
"fn": "expat-2.7.4-h7354ed3_0.conda",
|
| 14 |
+
"license": "MIT",
|
| 15 |
+
"license_family": "MIT",
|
| 16 |
+
"md5": "575218bf09aa99037a6e3bb1f43796a8",
|
| 17 |
+
"name": "expat",
|
| 18 |
+
"platform": "linux",
|
| 19 |
+
"sha256": "6dc018cce7a88683c5e9b8ed14906ff342e8fee7307205123c588f9775a1b026",
|
| 20 |
+
"size": 25302,
|
| 21 |
+
"subdir": "linux-64",
|
| 22 |
+
"timestamp": 1770062547000,
|
| 23 |
+
"url": "https://repo.anaconda.com/pkgs/main/linux-64/expat-2.7.4-h7354ed3_0.conda",
|
| 24 |
+
"version": "2.7.4"
|
| 25 |
+
}
|
miniconda3/pkgs/expat-2.7.4-h7354ed3_0/info/run_exports.json
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"weak": ["libexpat >=2.7.4,<3.0a0"]}
|
miniconda3/pkgs/expat-2.7.4-h7354ed3_0/info/test/run_test.sh
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
|
| 3 |
+
set -ex
|
| 4 |
+
|
| 5 |
+
|
| 6 |
+
|
| 7 |
+
xmlwf -h
|
| 8 |
+
exit 0
|
miniconda3/pkgs/expat-2.7.4-h7354ed3_0/share/man/man1/xmlwf.1
ADDED
|
@@ -0,0 +1,359 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
\\$2 \(la\\$1\(ra\\$3
|
| 6 |
+
..
|
| 7 |
+
.if \n(.g .mso www.tmac
|
| 8 |
+
.TH XMLWF 1 "January 31, 2026" "" ""
|
| 9 |
+
.SH NAME
|
| 10 |
+
xmlwf \- Determines if an XML document is well-formed
|
| 11 |
+
.SH SYNOPSIS
|
| 12 |
+
'nh
|
| 13 |
+
.fi
|
| 14 |
+
.ad l
|
| 15 |
+
\fBxmlwf\fR \kx
|
| 16 |
+
.if (\nx>(\n(.l/2)) .nr x (\n(.l/5)
|
| 17 |
+
'in \n(.iu+\nxu
|
| 18 |
+
[\fIOPTIONS\fR] [\fIFILE\fR ...]
|
| 19 |
+
'in \n(.iu-\nxu
|
| 20 |
+
.ad b
|
| 21 |
+
'hy
|
| 22 |
+
'nh
|
| 23 |
+
.fi
|
| 24 |
+
.ad l
|
| 25 |
+
\fBxmlwf\fR \kx
|
| 26 |
+
.if (\nx>(\n(.l/2)) .nr x (\n(.l/5)
|
| 27 |
+
'in \n(.iu+\nxu
|
| 28 |
+
\fB-h\fR | \fB--help\fR
|
| 29 |
+
'in \n(.iu-\nxu
|
| 30 |
+
.ad b
|
| 31 |
+
'hy
|
| 32 |
+
'nh
|
| 33 |
+
.fi
|
| 34 |
+
.ad l
|
| 35 |
+
\fBxmlwf\fR \kx
|
| 36 |
+
.if (\nx>(\n(.l/2)) .nr x (\n(.l/5)
|
| 37 |
+
'in \n(.iu+\nxu
|
| 38 |
+
\fB-v\fR | \fB--version\fR
|
| 39 |
+
'in \n(.iu-\nxu
|
| 40 |
+
.ad b
|
| 41 |
+
'hy
|
| 42 |
+
.SH DESCRIPTION
|
| 43 |
+
\fBxmlwf\fR uses the Expat library to
|
| 44 |
+
determine if an XML document is well-formed. It is
|
| 45 |
+
non-validating.
|
| 46 |
+
.PP
|
| 47 |
+
If you do not specify any files on the command-line, and you
|
| 48 |
+
have a recent version of \fBxmlwf\fR, the
|
| 49 |
+
input file will be read from standard input.
|
| 50 |
+
.SH "WELL-FORMED DOCUMENTS"
|
| 51 |
+
A well-formed document must adhere to the
|
| 52 |
+
following rules:
|
| 53 |
+
.TP 0.2i
|
| 54 |
+
\(bu
|
| 55 |
+
The file begins with an XML declaration. For instance,
|
| 56 |
+
\*(T<<?xml version="1.0" standalone="yes"?>\*(T>.
|
| 57 |
+
\fINOTE\fR:
|
| 58 |
+
\fBxmlwf\fR does not currently
|
| 59 |
+
check for a valid XML declaration.
|
| 60 |
+
.TP 0.2i
|
| 61 |
+
\(bu
|
| 62 |
+
Every start tag is either empty (<tag/>)
|
| 63 |
+
or has a corresponding end tag.
|
| 64 |
+
.TP 0.2i
|
| 65 |
+
\(bu
|
| 66 |
+
There is exactly one root element. This element must contain
|
| 67 |
+
all other elements in the document. Only comments, white
|
| 68 |
+
space, and processing instructions may come after the close
|
| 69 |
+
of the root element.
|
| 70 |
+
.TP 0.2i
|
| 71 |
+
\(bu
|
| 72 |
+
All elements nest properly.
|
| 73 |
+
.TP 0.2i
|
| 74 |
+
\(bu
|
| 75 |
+
All attribute values are enclosed in quotes (either single
|
| 76 |
+
or double).
|
| 77 |
+
.PP
|
| 78 |
+
If the document has a DTD, and it strictly complies with that
|
| 79 |
+
DTD, then the document is also considered \fIvalid\fR.
|
| 80 |
+
\fBxmlwf\fR is a non-validating parser --
|
| 81 |
+
it does not check the DTD. However, it does support
|
| 82 |
+
external entities (see the \*(T<\fB\-x\fR\*(T> option).
|
| 83 |
+
.SH OPTIONS
|
| 84 |
+
When an option includes an argument, you may specify the argument either
|
| 85 |
+
separately ("\*(T<\fB\-d\fR\*(T> \fIoutput\fR") or concatenated with the
|
| 86 |
+
option ("\*(T<\fB\-d\fR\*(T>\fIoutput\fR"). \fBxmlwf\fR
|
| 87 |
+
supports both.
|
| 88 |
+
.TP
|
| 89 |
+
\*(T<\fB\-a\fR\*(T> \fIfactor\fR
|
| 90 |
+
Sets the maximum tolerated amplification factor
|
| 91 |
+
for protection against amplification attacks
|
| 92 |
+
like the billion laughs attack
|
| 93 |
+
(default: 100.0
|
| 94 |
+
for the sum of direct and indirect output and also
|
| 95 |
+
for allocations of dynamic memory).
|
| 96 |
+
The amplification factor is calculated as ..
|
| 97 |
+
|
| 98 |
+
.nf
|
| 99 |
+
|
| 100 |
+
amplification := (direct + indirect) / direct
|
| 101 |
+
|
| 102 |
+
.fi
|
| 103 |
+
|
| 104 |
+
\&.. with regard to use of entities and ..
|
| 105 |
+
|
| 106 |
+
.nf
|
| 107 |
+
|
| 108 |
+
amplification := allocated / direct
|
| 109 |
+
|
| 110 |
+
.fi
|
| 111 |
+
|
| 112 |
+
\&.. with regard to dynamic memory while parsing.
|
| 113 |
+
<direct> is the number of bytes read
|
| 114 |
+
from the primary document in parsing,
|
| 115 |
+
<indirect> is the number of bytes
|
| 116 |
+
added by expanding entities and reading of external DTD files,
|
| 117 |
+
combined, and
|
| 118 |
+
<allocated> is the total number of bytes of dynamic memory
|
| 119 |
+
allocated (and not freed) per hierarchy of parsers.
|
| 120 |
+
|
| 121 |
+
\fINOTE\fR:
|
| 122 |
+
If you ever need to increase this value for non-attack payload,
|
| 123 |
+
please file a bug report.
|
| 124 |
+
.TP
|
| 125 |
+
\*(T<\fB\-b\fR\*(T> \fIbytes\fR
|
| 126 |
+
Sets the number of output bytes (including amplification)
|
| 127 |
+
needed to activate protection against amplification attacks
|
| 128 |
+
like billion laughs
|
| 129 |
+
(default: 8 MiB for the sum of direct and indirect output,
|
| 130 |
+
and 64 MiB for allocations of dynamic memory).
|
| 131 |
+
This can be thought of as an "activation threshold".
|
| 132 |
+
|
| 133 |
+
\fINOTE\fR:
|
| 134 |
+
If you ever need to increase this value for non-attack payload,
|
| 135 |
+
please file a bug report.
|
| 136 |
+
.TP
|
| 137 |
+
\*(T<\fB\-c\fR\*(T>
|
| 138 |
+
If the input file is well-formed and \fBxmlwf\fR
|
| 139 |
+
doesn't encounter any errors, the input file is simply copied to
|
| 140 |
+
the output directory unchanged.
|
| 141 |
+
This implies no namespaces (turns off \*(T<\fB\-n\fR\*(T>) and
|
| 142 |
+
requires \*(T<\fB\-d\fR\*(T> to specify an output directory.
|
| 143 |
+
.TP
|
| 144 |
+
\*(T<\fB\-d\fR\*(T> \fIoutput-dir\fR
|
| 145 |
+
Specifies a directory to contain transformed
|
| 146 |
+
representations of the input files.
|
| 147 |
+
By default, \*(T<\fB\-d\fR\*(T> outputs a canonical representation
|
| 148 |
+
(described below).
|
| 149 |
+
You can select different output formats using \*(T<\fB\-c\fR\*(T>,
|
| 150 |
+
\*(T<\fB\-m\fR\*(T> and \*(T<\fB\-N\fR\*(T>.
|
| 151 |
+
|
| 152 |
+
The output filenames will
|
| 153 |
+
be exactly the same as the input filenames or "STDIN" if the input is
|
| 154 |
+
coming from standard input. Therefore, you must be careful that the
|
| 155 |
+
output file does not go into the same directory as the input
|
| 156 |
+
file. Otherwise, \fBxmlwf\fR will delete the
|
| 157 |
+
input file before it generates the output file (just like running
|
| 158 |
+
\*(T<cat < file > file\*(T> in most shells).
|
| 159 |
+
|
| 160 |
+
Two structurally equivalent XML documents have a byte-for-byte
|
| 161 |
+
identical canonical XML representation.
|
| 162 |
+
Note that ignorable white space is considered significant and
|
| 163 |
+
is treated equivalently to data.
|
| 164 |
+
More on canonical XML can be found at
|
| 165 |
+
http://www.jclark.com/xml/canonxml.html .
|
| 166 |
+
.TP
|
| 167 |
+
\*(T<\fB\-e\fR\*(T> \fIencoding\fR
|
| 168 |
+
Specifies the character encoding for the document, overriding
|
| 169 |
+
any document encoding declaration. \fBxmlwf\fR
|
| 170 |
+
supports four built-in encodings:
|
| 171 |
+
\*(T<US\-ASCII\*(T>,
|
| 172 |
+
\*(T<UTF\-8\*(T>,
|
| 173 |
+
\*(T<UTF\-16\*(T>, and
|
| 174 |
+
\*(T<ISO\-8859\-1\*(T>.
|
| 175 |
+
Also see the \*(T<\fB\-w\fR\*(T> option.
|
| 176 |
+
.TP
|
| 177 |
+
\*(T<\fB\-g\fR\*(T> \fIbytes\fR
|
| 178 |
+
Sets the buffer size to request per call pair to
|
| 179 |
+
\*(T<\fBXML_GetBuffer\fR\*(T> and \*(T<\fBread\fR\*(T>
|
| 180 |
+
(default: 8 KiB).
|
| 181 |
+
.TP
|
| 182 |
+
\*(T<\fB\-h\fR\*(T>, \*(T<\fB\-\-help\fR\*(T>
|
| 183 |
+
Prints short usage information on command \fBxmlwf\fR,
|
| 184 |
+
and then exits.
|
| 185 |
+
Similar to this man page but more concise.
|
| 186 |
+
.TP
|
| 187 |
+
\*(T<\fB\-k\fR\*(T>
|
| 188 |
+
When processing multiple files, \fBxmlwf\fR
|
| 189 |
+
by default halts after the the first file with an error.
|
| 190 |
+
This tells \fBxmlwf\fR to report the error
|
| 191 |
+
but to keep processing.
|
| 192 |
+
This can be useful, for example, when testing a filter that converts
|
| 193 |
+
many files to XML and you want to quickly find out which conversions
|
| 194 |
+
failed.
|
| 195 |
+
.TP
|
| 196 |
+
\*(T<\fB\-m\fR\*(T>
|
| 197 |
+
Outputs some strange sort of XML file that completely
|
| 198 |
+
describes the input file, including character positions.
|
| 199 |
+
Requires \*(T<\fB\-d\fR\*(T> to specify an output file.
|
| 200 |
+
.TP
|
| 201 |
+
\*(T<\fB\-n\fR\*(T>
|
| 202 |
+
Turns on namespace processing. (describe namespaces)
|
| 203 |
+
\*(T<\fB\-c\fR\*(T> disables namespaces.
|
| 204 |
+
.TP
|
| 205 |
+
\*(T<\fB\-N\fR\*(T>
|
| 206 |
+
Adds a doctype and notation declarations to canonical XML output.
|
| 207 |
+
This matches the example output used by the formal XML test cases.
|
| 208 |
+
Requires \*(T<\fB\-d\fR\*(T> to specify an output file.
|
| 209 |
+
.TP
|
| 210 |
+
\*(T<\fB\-p\fR\*(T>
|
| 211 |
+
Tells \fBxmlwf\fR to process external DTDs and parameter
|
| 212 |
+
entities.
|
| 213 |
+
|
| 214 |
+
Normally \fBxmlwf\fR never parses parameter
|
| 215 |
+
entities. \*(T<\fB\-p\fR\*(T> tells it to always parse them.
|
| 216 |
+
\*(T<\fB\-p\fR\*(T> implies \*(T<\fB\-x\fR\*(T>.
|
| 217 |
+
.TP
|
| 218 |
+
\*(T<\fB\-q\fR\*(T>
|
| 219 |
+
Disable reparse deferral, and allow quadratic parse runtime
|
| 220 |
+
on large tokens (default: reparse deferral enabled).
|
| 221 |
+
.TP
|
| 222 |
+
\*(T<\fB\-r\fR\*(T>
|
| 223 |
+
Normally \fBxmlwf\fR memory-maps the XML file
|
| 224 |
+
before parsing; this can result in faster parsing on many
|
| 225 |
+
platforms.
|
| 226 |
+
\*(T<\fB\-r\fR\*(T> turns off memory-mapping and uses normal file
|
| 227 |
+
IO calls instead.
|
| 228 |
+
Of course, memory-mapping is automatically turned off
|
| 229 |
+
when reading from standard input.
|
| 230 |
+
|
| 231 |
+
Use of memory-mapping can cause some platforms to report
|
| 232 |
+
substantially higher memory usage for
|
| 233 |
+
\fBxmlwf\fR, but this appears to be a matter of
|
| 234 |
+
the operating system reporting memory in a strange way; there is
|
| 235 |
+
not a leak in \fBxmlwf\fR.
|
| 236 |
+
.TP
|
| 237 |
+
\*(T<\fB\-s\fR\*(T>
|
| 238 |
+
Prints an error if the document is not standalone.
|
| 239 |
+
A document is standalone if it has no external subset and no
|
| 240 |
+
references to parameter entities.
|
| 241 |
+
.TP
|
| 242 |
+
\*(T<\fB\-t\fR\*(T>
|
| 243 |
+
Turns on timings. This tells Expat to parse the entire file,
|
| 244 |
+
but not perform any processing.
|
| 245 |
+
This gives a fairly accurate idea of the raw speed of Expat itself
|
| 246 |
+
without client overhead.
|
| 247 |
+
\*(T<\fB\-t\fR\*(T> turns off most of the output options
|
| 248 |
+
(\*(T<\fB\-d\fR\*(T>, \*(T<\fB\-m\fR\*(T>, \*(T<\fB\-c\fR\*(T>, ...).
|
| 249 |
+
.TP
|
| 250 |
+
\*(T<\fB\-v\fR\*(T>, \*(T<\fB\-\-version\fR\*(T>
|
| 251 |
+
Prints the version of the Expat library being used, including some
|
| 252 |
+
information on the compile-time configuration of the library, and
|
| 253 |
+
then exits.
|
| 254 |
+
.TP
|
| 255 |
+
\*(T<\fB\-w\fR\*(T>
|
| 256 |
+
Enables support for Windows code pages.
|
| 257 |
+
Normally, \fBxmlwf\fR will throw an error if it
|
| 258 |
+
runs across an encoding that it is not equipped to handle itself. With
|
| 259 |
+
\*(T<\fB\-w\fR\*(T>, \fBxmlwf\fR will try to use a Windows code
|
| 260 |
+
page. See also \*(T<\fB\-e\fR\*(T>.
|
| 261 |
+
.TP
|
| 262 |
+
\*(T<\fB\-x\fR\*(T>
|
| 263 |
+
Turns on parsing external entities.
|
| 264 |
+
(CAREFUL! This makes xmlwf vulnerable to external entity attacks (XXE).)
|
| 265 |
+
|
| 266 |
+
Non-validating parsers are not required to resolve external
|
| 267 |
+
entities, or even expand entities at all.
|
| 268 |
+
Expat always expands internal entities (?),
|
| 269 |
+
but external entity parsing must be enabled explicitly.
|
| 270 |
+
|
| 271 |
+
External entities are simply entities that obtain their
|
| 272 |
+
data from outside the XML file currently being parsed.
|
| 273 |
+
|
| 274 |
+
This is an example of an internal entity:
|
| 275 |
+
|
| 276 |
+
.nf
|
| 277 |
+
|
| 278 |
+
<!ENTITY vers '1.0.2'>
|
| 279 |
+
|
| 280 |
+
.fi
|
| 281 |
+
|
| 282 |
+
And here are some examples of external entities:
|
| 283 |
+
|
| 284 |
+
.nf
|
| 285 |
+
|
| 286 |
+
<!ENTITY header SYSTEM "header\-&vers;.xml"> (parsed)
|
| 287 |
+
<!ENTITY logo SYSTEM "logo.png" PNG> (unparsed)
|
| 288 |
+
|
| 289 |
+
.fi
|
| 290 |
+
.TP
|
| 291 |
+
\*(T<\fB\-\-\fR\*(T>
|
| 292 |
+
(Two hyphens.)
|
| 293 |
+
Terminates the list of options. This is only needed if a filename
|
| 294 |
+
starts with a hyphen. For example:
|
| 295 |
+
|
| 296 |
+
.nf
|
| 297 |
+
|
| 298 |
+
xmlwf \-\- \-myfile.xml
|
| 299 |
+
|
| 300 |
+
.fi
|
| 301 |
+
|
| 302 |
+
will run \fBxmlwf\fR on the file
|
| 303 |
+
\*(T<\fI\-myfile.xml\fR\*(T>.
|
| 304 |
+
.PP
|
| 305 |
+
Older versions of \fBxmlwf\fR do not support
|
| 306 |
+
reading from standard input.
|
| 307 |
+
.SH OUTPUT
|
| 308 |
+
\fBxmlwf\fR outputs nothing for files which are problem-free.
|
| 309 |
+
If any input file is not well-formed, or if the output for any
|
| 310 |
+
input file cannot be opened, \fBxmlwf\fR prints a single
|
| 311 |
+
line describing the problem to standard output.
|
| 312 |
+
.PP
|
| 313 |
+
If the \*(T<\fB\-k\fR\*(T> option is not provided, \fBxmlwf\fR
|
| 314 |
+
halts upon encountering a well-formedness or output-file error.
|
| 315 |
+
If \*(T<\fB\-k\fR\*(T> is provided, \fBxmlwf\fR continues
|
| 316 |
+
processing the remaining input files, describing problems found with any of them.
|
| 317 |
+
.SH "EXIT STATUS"
|
| 318 |
+
For options \*(T<\fB\-v\fR\*(T>|\*(T<\fB\-\-version\fR\*(T> or \*(T<\fB\-h\fR\*(T>|\*(T<\fB\-\-help\fR\*(T>, \fBxmlwf\fR always exits with status code 0. For other cases, the following exit status codes are returned:
|
| 319 |
+
.TP
|
| 320 |
+
\*(T<\fB0\fR\*(T>
|
| 321 |
+
The input files are well-formed and the output (if requested) was written successfully.
|
| 322 |
+
.TP
|
| 323 |
+
\*(T<\fB1\fR\*(T>
|
| 324 |
+
An internal error occurred.
|
| 325 |
+
.TP
|
| 326 |
+
\*(T<\fB2\fR\*(T>
|
| 327 |
+
One or more input files were not well-formed or could not be parsed.
|
| 328 |
+
.TP
|
| 329 |
+
\*(T<\fB3\fR\*(T>
|
| 330 |
+
If using the \*(T<\fB\-d\fR\*(T> option, an error occurred opening an output file.
|
| 331 |
+
.TP
|
| 332 |
+
\*(T<\fB4\fR\*(T>
|
| 333 |
+
There was a command-line argument error in how \fBxmlwf\fR was invoked.
|
| 334 |
+
.SH BUGS
|
| 335 |
+
The errors should go to standard error, not standard output.
|
| 336 |
+
.PP
|
| 337 |
+
There should be a way to get \*(T<\fB\-d\fR\*(T> to send its
|
| 338 |
+
output to standard output rather than forcing the user to send
|
| 339 |
+
it to a file.
|
| 340 |
+
.PP
|
| 341 |
+
I have no idea why anyone would want to use the
|
| 342 |
+
\*(T<\fB\-d\fR\*(T>, \*(T<\fB\-c\fR\*(T>, and
|
| 343 |
+
\*(T<\fB\-m\fR\*(T> options. If someone could explain it to
|
| 344 |
+
me, I'd like to add this information to this manpage.
|
| 345 |
+
.SH "SEE ALSO"
|
| 346 |
+
.nf
|
| 347 |
+
|
| 348 |
+
The Expat home page: https://libexpat.github.io/
|
| 349 |
+
The W3 XML 1.0 specification (fourth edition): https://www.w3.org/TR/2006/REC\-xml\-20060816/
|
| 350 |
+
Billion laughs attack: https://en.wikipedia.org/wiki/Billion_laughs_attack
|
| 351 |
+
|
| 352 |
+
.fi
|
| 353 |
+
.SH AUTHOR
|
| 354 |
+
This manual page was originally written by Scott Bronson <\*(T<bronson@rinspin.com\*(T>>
|
| 355 |
+
in December 2001 for
|
| 356 |
+
the Debian GNU/Linux system (but may be used by others). Permission is
|
| 357 |
+
granted to copy, distribute and/or modify this document under
|
| 358 |
+
the terms of the GNU Free Documentation
|
| 359 |
+
License, Version 1.1.
|
miniconda3/pkgs/fmt-11.2.0-hca5f364_0/include/fmt/args.h
ADDED
|
@@ -0,0 +1,220 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
+
//
|
| 3 |
+
// Copyright (c) 2012 - present, Victor Zverovich
|
| 4 |
+
// All rights reserved.
|
| 5 |
+
//
|
| 6 |
+
// For the license information refer to format.h.
|
| 7 |
+
|
| 8 |
+
#ifndef FMT_ARGS_H_
|
| 9 |
+
#define FMT_ARGS_H_
|
| 10 |
+
|
| 11 |
+
#ifndef FMT_MODULE
|
| 12 |
+
# include <functional> // std::reference_wrapper
|
| 13 |
+
# include <memory> // std::unique_ptr
|
| 14 |
+
# include <vector>
|
| 15 |
+
#endif
|
| 16 |
+
|
| 17 |
+
#include "format.h" // std_string_view
|
| 18 |
+
|
| 19 |
+
FMT_BEGIN_NAMESPACE
|
| 20 |
+
namespace detail {
|
| 21 |
+
|
| 22 |
+
template <typename T> struct is_reference_wrapper : std::false_type {};
|
| 23 |
+
template <typename T>
|
| 24 |
+
struct is_reference_wrapper<std::reference_wrapper<T>> : std::true_type {};
|
| 25 |
+
|
| 26 |
+
template <typename T> auto unwrap(const T& v) -> const T& { return v; }
|
| 27 |
+
template <typename T>
|
| 28 |
+
auto unwrap(const std::reference_wrapper<T>& v) -> const T& {
|
| 29 |
+
return static_cast<const T&>(v);
|
| 30 |
+
}
|
| 31 |
+
|
| 32 |
+
// node is defined outside dynamic_arg_list to workaround a C2504 bug in MSVC
|
| 33 |
+
// 2022 (v17.10.0).
|
| 34 |
+
//
|
| 35 |
+
// Workaround for clang's -Wweak-vtables. Unlike for regular classes, for
|
| 36 |
+
// templates it doesn't complain about inability to deduce single translation
|
| 37 |
+
// unit for placing vtable. So node is made a fake template.
|
| 38 |
+
template <typename = void> struct node {
|
| 39 |
+
virtual ~node() = default;
|
| 40 |
+
std::unique_ptr<node<>> next;
|
| 41 |
+
};
|
| 42 |
+
|
| 43 |
+
class dynamic_arg_list {
|
| 44 |
+
template <typename T> struct typed_node : node<> {
|
| 45 |
+
T value;
|
| 46 |
+
|
| 47 |
+
template <typename Arg>
|
| 48 |
+
FMT_CONSTEXPR typed_node(const Arg& arg) : value(arg) {}
|
| 49 |
+
|
| 50 |
+
template <typename Char>
|
| 51 |
+
FMT_CONSTEXPR typed_node(const basic_string_view<Char>& arg)
|
| 52 |
+
: value(arg.data(), arg.size()) {}
|
| 53 |
+
};
|
| 54 |
+
|
| 55 |
+
std::unique_ptr<node<>> head_;
|
| 56 |
+
|
| 57 |
+
public:
|
| 58 |
+
template <typename T, typename Arg> auto push(const Arg& arg) -> const T& {
|
| 59 |
+
auto new_node = std::unique_ptr<typed_node<T>>(new typed_node<T>(arg));
|
| 60 |
+
auto& value = new_node->value;
|
| 61 |
+
new_node->next = std::move(head_);
|
| 62 |
+
head_ = std::move(new_node);
|
| 63 |
+
return value;
|
| 64 |
+
}
|
| 65 |
+
};
|
| 66 |
+
} // namespace detail
|
| 67 |
+
|
| 68 |
+
/**
|
| 69 |
+
* A dynamic list of formatting arguments with storage.
|
| 70 |
+
*
|
| 71 |
+
* It can be implicitly converted into `fmt::basic_format_args` for passing
|
| 72 |
+
* into type-erased formatting functions such as `fmt::vformat`.
|
| 73 |
+
*/
|
| 74 |
+
template <typename Context> class dynamic_format_arg_store {
|
| 75 |
+
private:
|
| 76 |
+
using char_type = typename Context::char_type;
|
| 77 |
+
|
| 78 |
+
template <typename T> struct need_copy {
|
| 79 |
+
static constexpr detail::type mapped_type =
|
| 80 |
+
detail::mapped_type_constant<T, char_type>::value;
|
| 81 |
+
|
| 82 |
+
enum {
|
| 83 |
+
value = !(detail::is_reference_wrapper<T>::value ||
|
| 84 |
+
std::is_same<T, basic_string_view<char_type>>::value ||
|
| 85 |
+
std::is_same<T, detail::std_string_view<char_type>>::value ||
|
| 86 |
+
(mapped_type != detail::type::cstring_type &&
|
| 87 |
+
mapped_type != detail::type::string_type &&
|
| 88 |
+
mapped_type != detail::type::custom_type))
|
| 89 |
+
};
|
| 90 |
+
};
|
| 91 |
+
|
| 92 |
+
template <typename T>
|
| 93 |
+
using stored_t = conditional_t<
|
| 94 |
+
std::is_convertible<T, std::basic_string<char_type>>::value &&
|
| 95 |
+
!detail::is_reference_wrapper<T>::value,
|
| 96 |
+
std::basic_string<char_type>, T>;
|
| 97 |
+
|
| 98 |
+
// Storage of basic_format_arg must be contiguous.
|
| 99 |
+
std::vector<basic_format_arg<Context>> data_;
|
| 100 |
+
std::vector<detail::named_arg_info<char_type>> named_info_;
|
| 101 |
+
|
| 102 |
+
// Storage of arguments not fitting into basic_format_arg must grow
|
| 103 |
+
// without relocation because items in data_ refer to it.
|
| 104 |
+
detail::dynamic_arg_list dynamic_args_;
|
| 105 |
+
|
| 106 |
+
friend class basic_format_args<Context>;
|
| 107 |
+
|
| 108 |
+
auto data() const -> const basic_format_arg<Context>* {
|
| 109 |
+
return named_info_.empty() ? data_.data() : data_.data() + 1;
|
| 110 |
+
}
|
| 111 |
+
|
| 112 |
+
template <typename T> void emplace_arg(const T& arg) {
|
| 113 |
+
data_.emplace_back(arg);
|
| 114 |
+
}
|
| 115 |
+
|
| 116 |
+
template <typename T>
|
| 117 |
+
void emplace_arg(const detail::named_arg<char_type, T>& arg) {
|
| 118 |
+
if (named_info_.empty())
|
| 119 |
+
data_.insert(data_.begin(), basic_format_arg<Context>(nullptr, 0));
|
| 120 |
+
data_.emplace_back(detail::unwrap(arg.value));
|
| 121 |
+
auto pop_one = [](std::vector<basic_format_arg<Context>>* data) {
|
| 122 |
+
data->pop_back();
|
| 123 |
+
};
|
| 124 |
+
std::unique_ptr<std::vector<basic_format_arg<Context>>, decltype(pop_one)>
|
| 125 |
+
guard{&data_, pop_one};
|
| 126 |
+
named_info_.push_back({arg.name, static_cast<int>(data_.size() - 2u)});
|
| 127 |
+
data_[0] = {named_info_.data(), named_info_.size()};
|
| 128 |
+
guard.release();
|
| 129 |
+
}
|
| 130 |
+
|
| 131 |
+
public:
|
| 132 |
+
constexpr dynamic_format_arg_store() = default;
|
| 133 |
+
|
| 134 |
+
operator basic_format_args<Context>() const {
|
| 135 |
+
return basic_format_args<Context>(data(), static_cast<int>(data_.size()),
|
| 136 |
+
!named_info_.empty());
|
| 137 |
+
}
|
| 138 |
+
|
| 139 |
+
/**
|
| 140 |
+
* Adds an argument into the dynamic store for later passing to a formatting
|
| 141 |
+
* function.
|
| 142 |
+
*
|
| 143 |
+
* Note that custom types and string types (but not string views) are copied
|
| 144 |
+
* into the store dynamically allocating memory if necessary.
|
| 145 |
+
*
|
| 146 |
+
* **Example**:
|
| 147 |
+
*
|
| 148 |
+
* fmt::dynamic_format_arg_store<fmt::format_context> store;
|
| 149 |
+
* store.push_back(42);
|
| 150 |
+
* store.push_back("abc");
|
| 151 |
+
* store.push_back(1.5f);
|
| 152 |
+
* std::string result = fmt::vformat("{} and {} and {}", store);
|
| 153 |
+
*/
|
| 154 |
+
template <typename T> void push_back(const T& arg) {
|
| 155 |
+
if (detail::const_check(need_copy<T>::value))
|
| 156 |
+
emplace_arg(dynamic_args_.push<stored_t<T>>(arg));
|
| 157 |
+
else
|
| 158 |
+
emplace_arg(detail::unwrap(arg));
|
| 159 |
+
}
|
| 160 |
+
|
| 161 |
+
/**
|
| 162 |
+
* Adds a reference to the argument into the dynamic store for later passing
|
| 163 |
+
* to a formatting function.
|
| 164 |
+
*
|
| 165 |
+
* **Example**:
|
| 166 |
+
*
|
| 167 |
+
* fmt::dynamic_format_arg_store<fmt::format_context> store;
|
| 168 |
+
* char band[] = "Rolling Stones";
|
| 169 |
+
* store.push_back(std::cref(band));
|
| 170 |
+
* band[9] = 'c'; // Changing str affects the output.
|
| 171 |
+
* std::string result = fmt::vformat("{}", store);
|
| 172 |
+
* // result == "Rolling Scones"
|
| 173 |
+
*/
|
| 174 |
+
template <typename T> void push_back(std::reference_wrapper<T> arg) {
|
| 175 |
+
static_assert(
|
| 176 |
+
need_copy<T>::value,
|
| 177 |
+
"objects of built-in types and string views are always copied");
|
| 178 |
+
emplace_arg(arg.get());
|
| 179 |
+
}
|
| 180 |
+
|
| 181 |
+
/**
|
| 182 |
+
* Adds named argument into the dynamic store for later passing to a
|
| 183 |
+
* formatting function. `std::reference_wrapper` is supported to avoid
|
| 184 |
+
* copying of the argument. The name is always copied into the store.
|
| 185 |
+
*/
|
| 186 |
+
template <typename T>
|
| 187 |
+
void push_back(const detail::named_arg<char_type, T>& arg) {
|
| 188 |
+
const char_type* arg_name =
|
| 189 |
+
dynamic_args_.push<std::basic_string<char_type>>(arg.name).c_str();
|
| 190 |
+
if (detail::const_check(need_copy<T>::value)) {
|
| 191 |
+
emplace_arg(
|
| 192 |
+
fmt::arg(arg_name, dynamic_args_.push<stored_t<T>>(arg.value)));
|
| 193 |
+
} else {
|
| 194 |
+
emplace_arg(fmt::arg(arg_name, arg.value));
|
| 195 |
+
}
|
| 196 |
+
}
|
| 197 |
+
|
| 198 |
+
/// Erase all elements from the store.
|
| 199 |
+
void clear() {
|
| 200 |
+
data_.clear();
|
| 201 |
+
named_info_.clear();
|
| 202 |
+
dynamic_args_ = {};
|
| 203 |
+
}
|
| 204 |
+
|
| 205 |
+
/// Reserves space to store at least `new_cap` arguments including
|
| 206 |
+
/// `new_cap_named` named arguments.
|
| 207 |
+
void reserve(size_t new_cap, size_t new_cap_named) {
|
| 208 |
+
FMT_ASSERT(new_cap >= new_cap_named,
|
| 209 |
+
"set of arguments includes set of named arguments");
|
| 210 |
+
data_.reserve(new_cap);
|
| 211 |
+
named_info_.reserve(new_cap_named);
|
| 212 |
+
}
|
| 213 |
+
|
| 214 |
+
/// Returns the number of elements in the store.
|
| 215 |
+
size_t size() const noexcept { return data_.size(); }
|
| 216 |
+
};
|
| 217 |
+
|
| 218 |
+
FMT_END_NAMESPACE
|
| 219 |
+
|
| 220 |
+
#endif // FMT_ARGS_H_
|
miniconda3/pkgs/fmt-11.2.0-hca5f364_0/include/fmt/base.h
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
miniconda3/pkgs/fmt-11.2.0-hca5f364_0/include/fmt/chrono.h
ADDED
|
@@ -0,0 +1,2330 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// Formatting library for C++ - chrono support
|
| 2 |
+
//
|
| 3 |
+
// Copyright (c) 2012 - present, Victor Zverovich
|
| 4 |
+
// All rights reserved.
|
| 5 |
+
//
|
| 6 |
+
// For the license information refer to format.h.
|
| 7 |
+
|
| 8 |
+
#ifndef FMT_CHRONO_H_
|
| 9 |
+
#define FMT_CHRONO_H_
|
| 10 |
+
|
| 11 |
+
#ifndef FMT_MODULE
|
| 12 |
+
# include <algorithm>
|
| 13 |
+
# include <chrono>
|
| 14 |
+
# include <cmath> // std::isfinite
|
| 15 |
+
# include <cstring> // std::memcpy
|
| 16 |
+
# include <ctime>
|
| 17 |
+
# include <iterator>
|
| 18 |
+
# include <locale>
|
| 19 |
+
# include <ostream>
|
| 20 |
+
# include <type_traits>
|
| 21 |
+
#endif
|
| 22 |
+
|
| 23 |
+
#include "format.h"
|
| 24 |
+
|
| 25 |
+
FMT_BEGIN_NAMESPACE
|
| 26 |
+
|
| 27 |
+
// Enable safe chrono durations, unless explicitly disabled.
|
| 28 |
+
#ifndef FMT_SAFE_DURATION_CAST
|
| 29 |
+
# define FMT_SAFE_DURATION_CAST 1
|
| 30 |
+
#endif
|
| 31 |
+
#if FMT_SAFE_DURATION_CAST
|
| 32 |
+
|
| 33 |
+
// For conversion between std::chrono::durations without undefined
|
| 34 |
+
// behaviour or erroneous results.
|
| 35 |
+
// This is a stripped down version of duration_cast, for inclusion in fmt.
|
| 36 |
+
// See https://github.com/pauldreik/safe_duration_cast
|
| 37 |
+
//
|
| 38 |
+
// Copyright Paul Dreik 2019
|
| 39 |
+
namespace safe_duration_cast {
|
| 40 |
+
|
| 41 |
+
template <typename To, typename From,
|
| 42 |
+
FMT_ENABLE_IF(!std::is_same<From, To>::value &&
|
| 43 |
+
std::numeric_limits<From>::is_signed ==
|
| 44 |
+
std::numeric_limits<To>::is_signed)>
|
| 45 |
+
FMT_CONSTEXPR auto lossless_integral_conversion(const From from, int& ec)
|
| 46 |
+
-> To {
|
| 47 |
+
ec = 0;
|
| 48 |
+
using F = std::numeric_limits<From>;
|
| 49 |
+
using T = std::numeric_limits<To>;
|
| 50 |
+
static_assert(F::is_integer, "From must be integral");
|
| 51 |
+
static_assert(T::is_integer, "To must be integral");
|
| 52 |
+
|
| 53 |
+
// A and B are both signed, or both unsigned.
|
| 54 |
+
if (detail::const_check(F::digits <= T::digits)) {
|
| 55 |
+
// From fits in To without any problem.
|
| 56 |
+
} else {
|
| 57 |
+
// From does not always fit in To, resort to a dynamic check.
|
| 58 |
+
if (from < (T::min)() || from > (T::max)()) {
|
| 59 |
+
// outside range.
|
| 60 |
+
ec = 1;
|
| 61 |
+
return {};
|
| 62 |
+
}
|
| 63 |
+
}
|
| 64 |
+
return static_cast<To>(from);
|
| 65 |
+
}
|
| 66 |
+
|
| 67 |
+
/// Converts From to To, without loss. If the dynamic value of from
|
| 68 |
+
/// can't be converted to To without loss, ec is set.
|
| 69 |
+
template <typename To, typename From,
|
| 70 |
+
FMT_ENABLE_IF(!std::is_same<From, To>::value &&
|
| 71 |
+
std::numeric_limits<From>::is_signed !=
|
| 72 |
+
std::numeric_limits<To>::is_signed)>
|
| 73 |
+
FMT_CONSTEXPR auto lossless_integral_conversion(const From from, int& ec)
|
| 74 |
+
-> To {
|
| 75 |
+
ec = 0;
|
| 76 |
+
using F = std::numeric_limits<From>;
|
| 77 |
+
using T = std::numeric_limits<To>;
|
| 78 |
+
static_assert(F::is_integer, "From must be integral");
|
| 79 |
+
static_assert(T::is_integer, "To must be integral");
|
| 80 |
+
|
| 81 |
+
if (detail::const_check(F::is_signed && !T::is_signed)) {
|
| 82 |
+
// From may be negative, not allowed!
|
| 83 |
+
if (fmt::detail::is_negative(from)) {
|
| 84 |
+
ec = 1;
|
| 85 |
+
return {};
|
| 86 |
+
}
|
| 87 |
+
// From is positive. Can it always fit in To?
|
| 88 |
+
if (detail::const_check(F::digits > T::digits) &&
|
| 89 |
+
from > static_cast<From>(detail::max_value<To>())) {
|
| 90 |
+
ec = 1;
|
| 91 |
+
return {};
|
| 92 |
+
}
|
| 93 |
+
}
|
| 94 |
+
|
| 95 |
+
if (detail::const_check(!F::is_signed && T::is_signed &&
|
| 96 |
+
F::digits >= T::digits) &&
|
| 97 |
+
from > static_cast<From>(detail::max_value<To>())) {
|
| 98 |
+
ec = 1;
|
| 99 |
+
return {};
|
| 100 |
+
}
|
| 101 |
+
return static_cast<To>(from); // Lossless conversion.
|
| 102 |
+
}
|
| 103 |
+
|
| 104 |
+
template <typename To, typename From,
|
| 105 |
+
FMT_ENABLE_IF(std::is_same<From, To>::value)>
|
| 106 |
+
FMT_CONSTEXPR auto lossless_integral_conversion(const From from, int& ec)
|
| 107 |
+
-> To {
|
| 108 |
+
ec = 0;
|
| 109 |
+
return from;
|
| 110 |
+
} // function
|
| 111 |
+
|
| 112 |
+
// clang-format off
|
| 113 |
+
/**
|
| 114 |
+
* converts From to To if possible, otherwise ec is set.
|
| 115 |
+
*
|
| 116 |
+
* input | output
|
| 117 |
+
* ---------------------------------|---------------
|
| 118 |
+
* NaN | NaN
|
| 119 |
+
* Inf | Inf
|
| 120 |
+
* normal, fits in output | converted (possibly lossy)
|
| 121 |
+
* normal, does not fit in output | ec is set
|
| 122 |
+
* subnormal | best effort
|
| 123 |
+
* -Inf | -Inf
|
| 124 |
+
*/
|
| 125 |
+
// clang-format on
|
| 126 |
+
template <typename To, typename From,
|
| 127 |
+
FMT_ENABLE_IF(!std::is_same<From, To>::value)>
|
| 128 |
+
FMT_CONSTEXPR auto safe_float_conversion(const From from, int& ec) -> To {
|
| 129 |
+
ec = 0;
|
| 130 |
+
using T = std::numeric_limits<To>;
|
| 131 |
+
static_assert(std::is_floating_point<From>::value, "From must be floating");
|
| 132 |
+
static_assert(std::is_floating_point<To>::value, "To must be floating");
|
| 133 |
+
|
| 134 |
+
// catch the only happy case
|
| 135 |
+
if (std::isfinite(from)) {
|
| 136 |
+
if (from >= T::lowest() && from <= (T::max)()) {
|
| 137 |
+
return static_cast<To>(from);
|
| 138 |
+
}
|
| 139 |
+
// not within range.
|
| 140 |
+
ec = 1;
|
| 141 |
+
return {};
|
| 142 |
+
}
|
| 143 |
+
|
| 144 |
+
// nan and inf will be preserved
|
| 145 |
+
return static_cast<To>(from);
|
| 146 |
+
} // function
|
| 147 |
+
|
| 148 |
+
template <typename To, typename From,
|
| 149 |
+
FMT_ENABLE_IF(std::is_same<From, To>::value)>
|
| 150 |
+
FMT_CONSTEXPR auto safe_float_conversion(const From from, int& ec) -> To {
|
| 151 |
+
ec = 0;
|
| 152 |
+
static_assert(std::is_floating_point<From>::value, "From must be floating");
|
| 153 |
+
return from;
|
| 154 |
+
}
|
| 155 |
+
|
| 156 |
+
/// Safe duration_cast between floating point durations
|
| 157 |
+
template <typename To, typename FromRep, typename FromPeriod,
|
| 158 |
+
FMT_ENABLE_IF(std::is_floating_point<FromRep>::value),
|
| 159 |
+
FMT_ENABLE_IF(std::is_floating_point<typename To::rep>::value)>
|
| 160 |
+
auto safe_duration_cast(std::chrono::duration<FromRep, FromPeriod> from,
|
| 161 |
+
int& ec) -> To {
|
| 162 |
+
using From = std::chrono::duration<FromRep, FromPeriod>;
|
| 163 |
+
ec = 0;
|
| 164 |
+
if (std::isnan(from.count())) {
|
| 165 |
+
// nan in, gives nan out. easy.
|
| 166 |
+
return To{std::numeric_limits<typename To::rep>::quiet_NaN()};
|
| 167 |
+
}
|
| 168 |
+
// maybe we should also check if from is denormal, and decide what to do about
|
| 169 |
+
// it.
|
| 170 |
+
|
| 171 |
+
// +-inf should be preserved.
|
| 172 |
+
if (std::isinf(from.count())) {
|
| 173 |
+
return To{from.count()};
|
| 174 |
+
}
|
| 175 |
+
|
| 176 |
+
// the basic idea is that we need to convert from count() in the from type
|
| 177 |
+
// to count() in the To type, by multiplying it with this:
|
| 178 |
+
struct Factor
|
| 179 |
+
: std::ratio_divide<typename From::period, typename To::period> {};
|
| 180 |
+
|
| 181 |
+
static_assert(Factor::num > 0, "num must be positive");
|
| 182 |
+
static_assert(Factor::den > 0, "den must be positive");
|
| 183 |
+
|
| 184 |
+
// the conversion is like this: multiply from.count() with Factor::num
|
| 185 |
+
// /Factor::den and convert it to To::rep, all this without
|
| 186 |
+
// overflow/underflow. let's start by finding a suitable type that can hold
|
| 187 |
+
// both To, From and Factor::num
|
| 188 |
+
using IntermediateRep =
|
| 189 |
+
typename std::common_type<typename From::rep, typename To::rep,
|
| 190 |
+
decltype(Factor::num)>::type;
|
| 191 |
+
|
| 192 |
+
// force conversion of From::rep -> IntermediateRep to be safe,
|
| 193 |
+
// even if it will never happen be narrowing in this context.
|
| 194 |
+
IntermediateRep count =
|
| 195 |
+
safe_float_conversion<IntermediateRep>(from.count(), ec);
|
| 196 |
+
if (ec) {
|
| 197 |
+
return {};
|
| 198 |
+
}
|
| 199 |
+
|
| 200 |
+
// multiply with Factor::num without overflow or underflow
|
| 201 |
+
if (detail::const_check(Factor::num != 1)) {
|
| 202 |
+
constexpr auto max1 = detail::max_value<IntermediateRep>() /
|
| 203 |
+
static_cast<IntermediateRep>(Factor::num);
|
| 204 |
+
if (count > max1) {
|
| 205 |
+
ec = 1;
|
| 206 |
+
return {};
|
| 207 |
+
}
|
| 208 |
+
constexpr auto min1 = std::numeric_limits<IntermediateRep>::lowest() /
|
| 209 |
+
static_cast<IntermediateRep>(Factor::num);
|
| 210 |
+
if (count < min1) {
|
| 211 |
+
ec = 1;
|
| 212 |
+
return {};
|
| 213 |
+
}
|
| 214 |
+
count *= static_cast<IntermediateRep>(Factor::num);
|
| 215 |
+
}
|
| 216 |
+
|
| 217 |
+
// this can't go wrong, right? den>0 is checked earlier.
|
| 218 |
+
if (detail::const_check(Factor::den != 1)) {
|
| 219 |
+
using common_t = typename std::common_type<IntermediateRep, intmax_t>::type;
|
| 220 |
+
count /= static_cast<common_t>(Factor::den);
|
| 221 |
+
}
|
| 222 |
+
|
| 223 |
+
// convert to the to type, safely
|
| 224 |
+
using ToRep = typename To::rep;
|
| 225 |
+
|
| 226 |
+
const ToRep tocount = safe_float_conversion<ToRep>(count, ec);
|
| 227 |
+
if (ec) {
|
| 228 |
+
return {};
|
| 229 |
+
}
|
| 230 |
+
return To{tocount};
|
| 231 |
+
}
|
| 232 |
+
} // namespace safe_duration_cast
|
| 233 |
+
#endif
|
| 234 |
+
|
| 235 |
+
namespace detail {
|
| 236 |
+
|
| 237 |
+
// Check if std::chrono::utc_time is available.
|
| 238 |
+
#ifdef FMT_USE_UTC_TIME
|
| 239 |
+
// Use the provided definition.
|
| 240 |
+
#elif defined(__cpp_lib_chrono)
|
| 241 |
+
# define FMT_USE_UTC_TIME (__cpp_lib_chrono >= 201907L)
|
| 242 |
+
#else
|
| 243 |
+
# define FMT_USE_UTC_TIME 0
|
| 244 |
+
#endif
|
| 245 |
+
#if FMT_USE_UTC_TIME
|
| 246 |
+
using utc_clock = std::chrono::utc_clock;
|
| 247 |
+
#else
|
| 248 |
+
struct utc_clock {
|
| 249 |
+
template <typename T> void to_sys(T);
|
| 250 |
+
};
|
| 251 |
+
#endif
|
| 252 |
+
|
| 253 |
+
// Check if std::chrono::local_time is available.
|
| 254 |
+
#ifdef FMT_USE_LOCAL_TIME
|
| 255 |
+
// Use the provided definition.
|
| 256 |
+
#elif defined(__cpp_lib_chrono)
|
| 257 |
+
# define FMT_USE_LOCAL_TIME (__cpp_lib_chrono >= 201907L)
|
| 258 |
+
#else
|
| 259 |
+
# define FMT_USE_LOCAL_TIME 0
|
| 260 |
+
#endif
|
| 261 |
+
#if FMT_USE_LOCAL_TIME
|
| 262 |
+
using local_t = std::chrono::local_t;
|
| 263 |
+
#else
|
| 264 |
+
struct local_t {};
|
| 265 |
+
#endif
|
| 266 |
+
|
| 267 |
+
} // namespace detail
|
| 268 |
+
|
| 269 |
+
template <typename Duration>
|
| 270 |
+
using sys_time = std::chrono::time_point<std::chrono::system_clock, Duration>;
|
| 271 |
+
|
| 272 |
+
template <typename Duration>
|
| 273 |
+
using utc_time = std::chrono::time_point<detail::utc_clock, Duration>;
|
| 274 |
+
|
| 275 |
+
template <class Duration>
|
| 276 |
+
using local_time = std::chrono::time_point<detail::local_t, Duration>;
|
| 277 |
+
|
| 278 |
+
namespace detail {
|
| 279 |
+
|
| 280 |
+
// Prevents expansion of a preceding token as a function-style macro.
|
| 281 |
+
// Usage: f FMT_NOMACRO()
|
| 282 |
+
#define FMT_NOMACRO
|
| 283 |
+
|
| 284 |
+
template <typename T = void> struct null {};
|
| 285 |
+
inline auto localtime_r FMT_NOMACRO(...) -> null<> { return null<>(); }
|
| 286 |
+
inline auto localtime_s(...) -> null<> { return null<>(); }
|
| 287 |
+
inline auto gmtime_r(...) -> null<> { return null<>(); }
|
| 288 |
+
inline auto gmtime_s(...) -> null<> { return null<>(); }
|
| 289 |
+
|
| 290 |
+
// It is defined here and not in ostream.h because the latter has expensive
|
| 291 |
+
// includes.
|
| 292 |
+
template <typename StreamBuf> class formatbuf : public StreamBuf {
|
| 293 |
+
private:
|
| 294 |
+
using char_type = typename StreamBuf::char_type;
|
| 295 |
+
using streamsize = decltype(std::declval<StreamBuf>().sputn(nullptr, 0));
|
| 296 |
+
using int_type = typename StreamBuf::int_type;
|
| 297 |
+
using traits_type = typename StreamBuf::traits_type;
|
| 298 |
+
|
| 299 |
+
buffer<char_type>& buffer_;
|
| 300 |
+
|
| 301 |
+
public:
|
| 302 |
+
explicit formatbuf(buffer<char_type>& buf) : buffer_(buf) {}
|
| 303 |
+
|
| 304 |
+
protected:
|
| 305 |
+
// The put area is always empty. This makes the implementation simpler and has
|
| 306 |
+
// the advantage that the streambuf and the buffer are always in sync and
|
| 307 |
+
// sputc never writes into uninitialized memory. A disadvantage is that each
|
| 308 |
+
// call to sputc always results in a (virtual) call to overflow. There is no
|
| 309 |
+
// disadvantage here for sputn since this always results in a call to xsputn.
|
| 310 |
+
|
| 311 |
+
auto overflow(int_type ch) -> int_type override {
|
| 312 |
+
if (!traits_type::eq_int_type(ch, traits_type::eof()))
|
| 313 |
+
buffer_.push_back(static_cast<char_type>(ch));
|
| 314 |
+
return ch;
|
| 315 |
+
}
|
| 316 |
+
|
| 317 |
+
auto xsputn(const char_type* s, streamsize count) -> streamsize override {
|
| 318 |
+
buffer_.append(s, s + count);
|
| 319 |
+
return count;
|
| 320 |
+
}
|
| 321 |
+
};
|
| 322 |
+
|
| 323 |
+
inline auto get_classic_locale() -> const std::locale& {
|
| 324 |
+
static const auto& locale = std::locale::classic();
|
| 325 |
+
return locale;
|
| 326 |
+
}
|
| 327 |
+
|
| 328 |
+
template <typename CodeUnit> struct codecvt_result {
|
| 329 |
+
static constexpr const size_t max_size = 32;
|
| 330 |
+
CodeUnit buf[max_size];
|
| 331 |
+
CodeUnit* end;
|
| 332 |
+
};
|
| 333 |
+
|
| 334 |
+
template <typename CodeUnit>
|
| 335 |
+
void write_codecvt(codecvt_result<CodeUnit>& out, string_view in,
|
| 336 |
+
const std::locale& loc) {
|
| 337 |
+
FMT_PRAGMA_CLANG(diagnostic push)
|
| 338 |
+
FMT_PRAGMA_CLANG(diagnostic ignored "-Wdeprecated")
|
| 339 |
+
auto& f = std::use_facet<std::codecvt<CodeUnit, char, std::mbstate_t>>(loc);
|
| 340 |
+
FMT_PRAGMA_CLANG(diagnostic pop)
|
| 341 |
+
auto mb = std::mbstate_t();
|
| 342 |
+
const char* from_next = nullptr;
|
| 343 |
+
auto result = f.in(mb, in.begin(), in.end(), from_next, std::begin(out.buf),
|
| 344 |
+
std::end(out.buf), out.end);
|
| 345 |
+
if (result != std::codecvt_base::ok)
|
| 346 |
+
FMT_THROW(format_error("failed to format time"));
|
| 347 |
+
}
|
| 348 |
+
|
| 349 |
+
template <typename OutputIt>
|
| 350 |
+
auto write_encoded_tm_str(OutputIt out, string_view in, const std::locale& loc)
|
| 351 |
+
-> OutputIt {
|
| 352 |
+
if (const_check(detail::use_utf8) && loc != get_classic_locale()) {
|
| 353 |
+
// char16_t and char32_t codecvts are broken in MSVC (linkage errors) and
|
| 354 |
+
// gcc-4.
|
| 355 |
+
#if FMT_MSC_VERSION != 0 || \
|
| 356 |
+
(defined(__GLIBCXX__) && \
|
| 357 |
+
(!defined(_GLIBCXX_USE_DUAL_ABI) || _GLIBCXX_USE_DUAL_ABI == 0))
|
| 358 |
+
// The _GLIBCXX_USE_DUAL_ABI macro is always defined in libstdc++ from gcc-5
|
| 359 |
+
// and newer.
|
| 360 |
+
using code_unit = wchar_t;
|
| 361 |
+
#else
|
| 362 |
+
using code_unit = char32_t;
|
| 363 |
+
#endif
|
| 364 |
+
|
| 365 |
+
using unit_t = codecvt_result<code_unit>;
|
| 366 |
+
unit_t unit;
|
| 367 |
+
write_codecvt(unit, in, loc);
|
| 368 |
+
// In UTF-8 is used one to four one-byte code units.
|
| 369 |
+
auto u =
|
| 370 |
+
to_utf8<code_unit, basic_memory_buffer<char, unit_t::max_size * 4>>();
|
| 371 |
+
if (!u.convert({unit.buf, to_unsigned(unit.end - unit.buf)}))
|
| 372 |
+
FMT_THROW(format_error("failed to format time"));
|
| 373 |
+
return copy<char>(u.c_str(), u.c_str() + u.size(), out);
|
| 374 |
+
}
|
| 375 |
+
return copy<char>(in.data(), in.data() + in.size(), out);
|
| 376 |
+
}
|
| 377 |
+
|
| 378 |
+
template <typename Char, typename OutputIt,
|
| 379 |
+
FMT_ENABLE_IF(!std::is_same<Char, char>::value)>
|
| 380 |
+
auto write_tm_str(OutputIt out, string_view sv, const std::locale& loc)
|
| 381 |
+
-> OutputIt {
|
| 382 |
+
codecvt_result<Char> unit;
|
| 383 |
+
write_codecvt(unit, sv, loc);
|
| 384 |
+
return copy<Char>(unit.buf, unit.end, out);
|
| 385 |
+
}
|
| 386 |
+
|
| 387 |
+
template <typename Char, typename OutputIt,
|
| 388 |
+
FMT_ENABLE_IF(std::is_same<Char, char>::value)>
|
| 389 |
+
auto write_tm_str(OutputIt out, string_view sv, const std::locale& loc)
|
| 390 |
+
-> OutputIt {
|
| 391 |
+
return write_encoded_tm_str(out, sv, loc);
|
| 392 |
+
}
|
| 393 |
+
|
| 394 |
+
template <typename Char>
|
| 395 |
+
inline void do_write(buffer<Char>& buf, const std::tm& time,
|
| 396 |
+
const std::locale& loc, char format, char modifier) {
|
| 397 |
+
auto&& format_buf = formatbuf<std::basic_streambuf<Char>>(buf);
|
| 398 |
+
auto&& os = std::basic_ostream<Char>(&format_buf);
|
| 399 |
+
os.imbue(loc);
|
| 400 |
+
const auto& facet = std::use_facet<std::time_put<Char>>(loc);
|
| 401 |
+
auto end = facet.put(os, os, Char(' '), &time, format, modifier);
|
| 402 |
+
if (end.failed()) FMT_THROW(format_error("failed to format time"));
|
| 403 |
+
}
|
| 404 |
+
|
| 405 |
+
template <typename Char, typename OutputIt,
|
| 406 |
+
FMT_ENABLE_IF(!std::is_same<Char, char>::value)>
|
| 407 |
+
auto write(OutputIt out, const std::tm& time, const std::locale& loc,
|
| 408 |
+
char format, char modifier = 0) -> OutputIt {
|
| 409 |
+
auto&& buf = get_buffer<Char>(out);
|
| 410 |
+
do_write<Char>(buf, time, loc, format, modifier);
|
| 411 |
+
return get_iterator(buf, out);
|
| 412 |
+
}
|
| 413 |
+
|
| 414 |
+
template <typename Char, typename OutputIt,
|
| 415 |
+
FMT_ENABLE_IF(std::is_same<Char, char>::value)>
|
| 416 |
+
auto write(OutputIt out, const std::tm& time, const std::locale& loc,
|
| 417 |
+
char format, char modifier = 0) -> OutputIt {
|
| 418 |
+
auto&& buf = basic_memory_buffer<Char>();
|
| 419 |
+
do_write<char>(buf, time, loc, format, modifier);
|
| 420 |
+
return write_encoded_tm_str(out, string_view(buf.data(), buf.size()), loc);
|
| 421 |
+
}
|
| 422 |
+
|
| 423 |
+
template <typename T, typename U>
|
| 424 |
+
using is_similar_arithmetic_type =
|
| 425 |
+
bool_constant<(std::is_integral<T>::value && std::is_integral<U>::value) ||
|
| 426 |
+
(std::is_floating_point<T>::value &&
|
| 427 |
+
std::is_floating_point<U>::value)>;
|
| 428 |
+
|
| 429 |
+
FMT_NORETURN inline void throw_duration_error() {
|
| 430 |
+
FMT_THROW(format_error("cannot format duration"));
|
| 431 |
+
}
|
| 432 |
+
|
| 433 |
+
// Cast one integral duration to another with an overflow check.
|
| 434 |
+
template <typename To, typename FromRep, typename FromPeriod,
|
| 435 |
+
FMT_ENABLE_IF(std::is_integral<FromRep>::value&&
|
| 436 |
+
std::is_integral<typename To::rep>::value)>
|
| 437 |
+
auto duration_cast(std::chrono::duration<FromRep, FromPeriod> from) -> To {
|
| 438 |
+
#if !FMT_SAFE_DURATION_CAST
|
| 439 |
+
return std::chrono::duration_cast<To>(from);
|
| 440 |
+
#else
|
| 441 |
+
// The conversion factor: to.count() == factor * from.count().
|
| 442 |
+
using factor = std::ratio_divide<FromPeriod, typename To::period>;
|
| 443 |
+
|
| 444 |
+
using common_rep = typename std::common_type<FromRep, typename To::rep,
|
| 445 |
+
decltype(factor::num)>::type;
|
| 446 |
+
|
| 447 |
+
int ec = 0;
|
| 448 |
+
auto count = safe_duration_cast::lossless_integral_conversion<common_rep>(
|
| 449 |
+
from.count(), ec);
|
| 450 |
+
if (ec) throw_duration_error();
|
| 451 |
+
|
| 452 |
+
// Multiply from.count() by factor and check for overflow.
|
| 453 |
+
if (const_check(factor::num != 1)) {
|
| 454 |
+
if (count > max_value<common_rep>() / factor::num) throw_duration_error();
|
| 455 |
+
const auto min = (std::numeric_limits<common_rep>::min)() / factor::num;
|
| 456 |
+
if (const_check(!std::is_unsigned<common_rep>::value) && count < min)
|
| 457 |
+
throw_duration_error();
|
| 458 |
+
count *= factor::num;
|
| 459 |
+
}
|
| 460 |
+
if (const_check(factor::den != 1)) count /= factor::den;
|
| 461 |
+
auto to =
|
| 462 |
+
To(safe_duration_cast::lossless_integral_conversion<typename To::rep>(
|
| 463 |
+
count, ec));
|
| 464 |
+
if (ec) throw_duration_error();
|
| 465 |
+
return to;
|
| 466 |
+
#endif
|
| 467 |
+
}
|
| 468 |
+
|
| 469 |
+
template <typename To, typename FromRep, typename FromPeriod,
|
| 470 |
+
FMT_ENABLE_IF(std::is_floating_point<FromRep>::value&&
|
| 471 |
+
std::is_floating_point<typename To::rep>::value)>
|
| 472 |
+
auto duration_cast(std::chrono::duration<FromRep, FromPeriod> from) -> To {
|
| 473 |
+
#if FMT_SAFE_DURATION_CAST
|
| 474 |
+
// Throwing version of safe_duration_cast is only available for
|
| 475 |
+
// integer to integer or float to float casts.
|
| 476 |
+
int ec;
|
| 477 |
+
To to = safe_duration_cast::safe_duration_cast<To>(from, ec);
|
| 478 |
+
if (ec) throw_duration_error();
|
| 479 |
+
return to;
|
| 480 |
+
#else
|
| 481 |
+
// Standard duration cast, may overflow.
|
| 482 |
+
return std::chrono::duration_cast<To>(from);
|
| 483 |
+
#endif
|
| 484 |
+
}
|
| 485 |
+
|
| 486 |
+
template <typename To, typename FromRep, typename FromPeriod,
|
| 487 |
+
FMT_ENABLE_IF(
|
| 488 |
+
!is_similar_arithmetic_type<FromRep, typename To::rep>::value)>
|
| 489 |
+
auto duration_cast(std::chrono::duration<FromRep, FromPeriod> from) -> To {
|
| 490 |
+
// Mixed integer <-> float cast is not supported by safe_duration_cast.
|
| 491 |
+
return std::chrono::duration_cast<To>(from);
|
| 492 |
+
}
|
| 493 |
+
|
| 494 |
+
template <typename Duration>
|
| 495 |
+
auto to_time_t(sys_time<Duration> time_point) -> std::time_t {
|
| 496 |
+
// Cannot use std::chrono::system_clock::to_time_t since this would first
|
| 497 |
+
// require a cast to std::chrono::system_clock::time_point, which could
|
| 498 |
+
// overflow.
|
| 499 |
+
return detail::duration_cast<std::chrono::duration<std::time_t>>(
|
| 500 |
+
time_point.time_since_epoch())
|
| 501 |
+
.count();
|
| 502 |
+
}
|
| 503 |
+
|
| 504 |
+
namespace tz {
|
| 505 |
+
|
| 506 |
+
// DEPRECATED!
|
| 507 |
+
struct time_zone {
|
| 508 |
+
template <typename Duration, typename LocalTime>
|
| 509 |
+
auto to_sys(LocalTime) -> sys_time<Duration> {
|
| 510 |
+
return {};
|
| 511 |
+
}
|
| 512 |
+
};
|
| 513 |
+
template <typename... T> auto current_zone(T...) -> time_zone* {
|
| 514 |
+
return nullptr;
|
| 515 |
+
}
|
| 516 |
+
|
| 517 |
+
template <typename... T> void _tzset(T...) {}
|
| 518 |
+
} // namespace tz
|
| 519 |
+
|
| 520 |
+
// DEPRECATED!
|
| 521 |
+
inline void tzset_once() {
|
| 522 |
+
static bool init = []() {
|
| 523 |
+
using namespace tz;
|
| 524 |
+
_tzset();
|
| 525 |
+
return false;
|
| 526 |
+
}();
|
| 527 |
+
ignore_unused(init);
|
| 528 |
+
}
|
| 529 |
+
} // namespace detail
|
| 530 |
+
|
| 531 |
+
FMT_BEGIN_EXPORT
|
| 532 |
+
|
| 533 |
+
/**
|
| 534 |
+
* Converts given time since epoch as `std::time_t` value into calendar time,
|
| 535 |
+
* expressed in local time. Unlike `std::localtime`, this function is
|
| 536 |
+
* thread-safe on most platforms.
|
| 537 |
+
*/
|
| 538 |
+
FMT_DEPRECATED inline auto localtime(std::time_t time) -> std::tm {
|
| 539 |
+
struct dispatcher {
|
| 540 |
+
std::time_t time_;
|
| 541 |
+
std::tm tm_;
|
| 542 |
+
|
| 543 |
+
inline dispatcher(std::time_t t) : time_(t) {}
|
| 544 |
+
|
| 545 |
+
inline auto run() -> bool {
|
| 546 |
+
using namespace fmt::detail;
|
| 547 |
+
return handle(localtime_r(&time_, &tm_));
|
| 548 |
+
}
|
| 549 |
+
|
| 550 |
+
inline auto handle(std::tm* tm) -> bool { return tm != nullptr; }
|
| 551 |
+
|
| 552 |
+
inline auto handle(detail::null<>) -> bool {
|
| 553 |
+
using namespace fmt::detail;
|
| 554 |
+
return fallback(localtime_s(&tm_, &time_));
|
| 555 |
+
}
|
| 556 |
+
|
| 557 |
+
inline auto fallback(int res) -> bool { return res == 0; }
|
| 558 |
+
|
| 559 |
+
#if !FMT_MSC_VERSION
|
| 560 |
+
inline auto fallback(detail::null<>) -> bool {
|
| 561 |
+
using namespace fmt::detail;
|
| 562 |
+
std::tm* tm = std::localtime(&time_);
|
| 563 |
+
if (tm) tm_ = *tm;
|
| 564 |
+
return tm != nullptr;
|
| 565 |
+
}
|
| 566 |
+
#endif
|
| 567 |
+
};
|
| 568 |
+
dispatcher lt(time);
|
| 569 |
+
// Too big time values may be unsupported.
|
| 570 |
+
if (!lt.run()) FMT_THROW(format_error("time_t value out of range"));
|
| 571 |
+
return lt.tm_;
|
| 572 |
+
}
|
| 573 |
+
|
| 574 |
+
#if FMT_USE_LOCAL_TIME
|
| 575 |
+
template <typename Duration>
|
| 576 |
+
FMT_DEPRECATED auto localtime(std::chrono::local_time<Duration> time)
|
| 577 |
+
-> std::tm {
|
| 578 |
+
using namespace std::chrono;
|
| 579 |
+
using namespace detail::tz;
|
| 580 |
+
return localtime(detail::to_time_t(current_zone()->to_sys<Duration>(time)));
|
| 581 |
+
}
|
| 582 |
+
#endif
|
| 583 |
+
|
| 584 |
+
/**
|
| 585 |
+
* Converts given time since epoch as `std::time_t` value into calendar time,
|
| 586 |
+
* expressed in Coordinated Universal Time (UTC). Unlike `std::gmtime`, this
|
| 587 |
+
* function is thread-safe on most platforms.
|
| 588 |
+
*/
|
| 589 |
+
inline auto gmtime(std::time_t time) -> std::tm {
|
| 590 |
+
struct dispatcher {
|
| 591 |
+
std::time_t time_;
|
| 592 |
+
std::tm tm_;
|
| 593 |
+
|
| 594 |
+
inline dispatcher(std::time_t t) : time_(t) {}
|
| 595 |
+
|
| 596 |
+
inline auto run() -> bool {
|
| 597 |
+
using namespace fmt::detail;
|
| 598 |
+
return handle(gmtime_r(&time_, &tm_));
|
| 599 |
+
}
|
| 600 |
+
|
| 601 |
+
inline auto handle(std::tm* tm) -> bool { return tm != nullptr; }
|
| 602 |
+
|
| 603 |
+
inline auto handle(detail::null<>) -> bool {
|
| 604 |
+
using namespace fmt::detail;
|
| 605 |
+
return fallback(gmtime_s(&tm_, &time_));
|
| 606 |
+
}
|
| 607 |
+
|
| 608 |
+
inline auto fallback(int res) -> bool { return res == 0; }
|
| 609 |
+
|
| 610 |
+
#if !FMT_MSC_VERSION
|
| 611 |
+
inline auto fallback(detail::null<>) -> bool {
|
| 612 |
+
std::tm* tm = std::gmtime(&time_);
|
| 613 |
+
if (tm) tm_ = *tm;
|
| 614 |
+
return tm != nullptr;
|
| 615 |
+
}
|
| 616 |
+
#endif
|
| 617 |
+
};
|
| 618 |
+
auto gt = dispatcher(time);
|
| 619 |
+
// Too big time values may be unsupported.
|
| 620 |
+
if (!gt.run()) FMT_THROW(format_error("time_t value out of range"));
|
| 621 |
+
return gt.tm_;
|
| 622 |
+
}
|
| 623 |
+
|
| 624 |
+
template <typename Duration>
|
| 625 |
+
inline auto gmtime(sys_time<Duration> time_point) -> std::tm {
|
| 626 |
+
return gmtime(detail::to_time_t(time_point));
|
| 627 |
+
}
|
| 628 |
+
|
| 629 |
+
namespace detail {
|
| 630 |
+
|
| 631 |
+
// Writes two-digit numbers a, b and c separated by sep to buf.
|
| 632 |
+
// The method by Pavel Novikov based on
|
| 633 |
+
// https://johnnylee-sde.github.io/Fast-unsigned-integer-to-time-string/.
|
| 634 |
+
inline void write_digit2_separated(char* buf, unsigned a, unsigned b,
|
| 635 |
+
unsigned c, char sep) {
|
| 636 |
+
unsigned long long digits =
|
| 637 |
+
a | (b << 24) | (static_cast<unsigned long long>(c) << 48);
|
| 638 |
+
// Convert each value to BCD.
|
| 639 |
+
// We have x = a * 10 + b and we want to convert it to BCD y = a * 16 + b.
|
| 640 |
+
// The difference is
|
| 641 |
+
// y - x = a * 6
|
| 642 |
+
// a can be found from x:
|
| 643 |
+
// a = floor(x / 10)
|
| 644 |
+
// then
|
| 645 |
+
// y = x + a * 6 = x + floor(x / 10) * 6
|
| 646 |
+
// floor(x / 10) is (x * 205) >> 11 (needs 16 bits).
|
| 647 |
+
digits += (((digits * 205) >> 11) & 0x000f00000f00000f) * 6;
|
| 648 |
+
// Put low nibbles to high bytes and high nibbles to low bytes.
|
| 649 |
+
digits = ((digits & 0x00f00000f00000f0) >> 4) |
|
| 650 |
+
((digits & 0x000f00000f00000f) << 8);
|
| 651 |
+
auto usep = static_cast<unsigned long long>(sep);
|
| 652 |
+
// Add ASCII '0' to each digit byte and insert separators.
|
| 653 |
+
digits |= 0x3030003030003030 | (usep << 16) | (usep << 40);
|
| 654 |
+
|
| 655 |
+
constexpr const size_t len = 8;
|
| 656 |
+
if (const_check(is_big_endian())) {
|
| 657 |
+
char tmp[len];
|
| 658 |
+
std::memcpy(tmp, &digits, len);
|
| 659 |
+
std::reverse_copy(tmp, tmp + len, buf);
|
| 660 |
+
} else {
|
| 661 |
+
std::memcpy(buf, &digits, len);
|
| 662 |
+
}
|
| 663 |
+
}
|
| 664 |
+
|
| 665 |
+
template <typename Period>
|
| 666 |
+
FMT_CONSTEXPR inline auto get_units() -> const char* {
|
| 667 |
+
if (std::is_same<Period, std::atto>::value) return "as";
|
| 668 |
+
if (std::is_same<Period, std::femto>::value) return "fs";
|
| 669 |
+
if (std::is_same<Period, std::pico>::value) return "ps";
|
| 670 |
+
if (std::is_same<Period, std::nano>::value) return "ns";
|
| 671 |
+
if (std::is_same<Period, std::micro>::value)
|
| 672 |
+
return detail::use_utf8 ? "µs" : "us";
|
| 673 |
+
if (std::is_same<Period, std::milli>::value) return "ms";
|
| 674 |
+
if (std::is_same<Period, std::centi>::value) return "cs";
|
| 675 |
+
if (std::is_same<Period, std::deci>::value) return "ds";
|
| 676 |
+
if (std::is_same<Period, std::ratio<1>>::value) return "s";
|
| 677 |
+
if (std::is_same<Period, std::deca>::value) return "das";
|
| 678 |
+
if (std::is_same<Period, std::hecto>::value) return "hs";
|
| 679 |
+
if (std::is_same<Period, std::kilo>::value) return "ks";
|
| 680 |
+
if (std::is_same<Period, std::mega>::value) return "Ms";
|
| 681 |
+
if (std::is_same<Period, std::giga>::value) return "Gs";
|
| 682 |
+
if (std::is_same<Period, std::tera>::value) return "Ts";
|
| 683 |
+
if (std::is_same<Period, std::peta>::value) return "Ps";
|
| 684 |
+
if (std::is_same<Period, std::exa>::value) return "Es";
|
| 685 |
+
if (std::is_same<Period, std::ratio<60>>::value) return "min";
|
| 686 |
+
if (std::is_same<Period, std::ratio<3600>>::value) return "h";
|
| 687 |
+
if (std::is_same<Period, std::ratio<86400>>::value) return "d";
|
| 688 |
+
return nullptr;
|
| 689 |
+
}
|
| 690 |
+
|
| 691 |
+
enum class numeric_system {
|
| 692 |
+
standard,
|
| 693 |
+
// Alternative numeric system, e.g. 十二 instead of 12 in ja_JP locale.
|
| 694 |
+
alternative
|
| 695 |
+
};
|
| 696 |
+
|
| 697 |
+
// Glibc extensions for formatting numeric values.
|
| 698 |
+
enum class pad_type {
|
| 699 |
+
// Pad a numeric result string with zeros (the default).
|
| 700 |
+
zero,
|
| 701 |
+
// Do not pad a numeric result string.
|
| 702 |
+
none,
|
| 703 |
+
// Pad a numeric result string with spaces.
|
| 704 |
+
space,
|
| 705 |
+
};
|
| 706 |
+
|
| 707 |
+
template <typename OutputIt>
|
| 708 |
+
auto write_padding(OutputIt out, pad_type pad, int width) -> OutputIt {
|
| 709 |
+
if (pad == pad_type::none) return out;
|
| 710 |
+
return detail::fill_n(out, width, pad == pad_type::space ? ' ' : '0');
|
| 711 |
+
}
|
| 712 |
+
|
| 713 |
+
template <typename OutputIt>
|
| 714 |
+
auto write_padding(OutputIt out, pad_type pad) -> OutputIt {
|
| 715 |
+
if (pad != pad_type::none) *out++ = pad == pad_type::space ? ' ' : '0';
|
| 716 |
+
return out;
|
| 717 |
+
}
|
| 718 |
+
|
| 719 |
+
// Parses a put_time-like format string and invokes handler actions.
|
| 720 |
+
template <typename Char, typename Handler>
|
| 721 |
+
FMT_CONSTEXPR auto parse_chrono_format(const Char* begin, const Char* end,
|
| 722 |
+
Handler&& handler) -> const Char* {
|
| 723 |
+
if (begin == end || *begin == '}') return begin;
|
| 724 |
+
if (*begin != '%') FMT_THROW(format_error("invalid format"));
|
| 725 |
+
auto ptr = begin;
|
| 726 |
+
while (ptr != end) {
|
| 727 |
+
pad_type pad = pad_type::zero;
|
| 728 |
+
auto c = *ptr;
|
| 729 |
+
if (c == '}') break;
|
| 730 |
+
if (c != '%') {
|
| 731 |
+
++ptr;
|
| 732 |
+
continue;
|
| 733 |
+
}
|
| 734 |
+
if (begin != ptr) handler.on_text(begin, ptr);
|
| 735 |
+
++ptr; // consume '%'
|
| 736 |
+
if (ptr == end) FMT_THROW(format_error("invalid format"));
|
| 737 |
+
c = *ptr;
|
| 738 |
+
switch (c) {
|
| 739 |
+
case '_':
|
| 740 |
+
pad = pad_type::space;
|
| 741 |
+
++ptr;
|
| 742 |
+
break;
|
| 743 |
+
case '-':
|
| 744 |
+
pad = pad_type::none;
|
| 745 |
+
++ptr;
|
| 746 |
+
break;
|
| 747 |
+
}
|
| 748 |
+
if (ptr == end) FMT_THROW(format_error("invalid format"));
|
| 749 |
+
c = *ptr++;
|
| 750 |
+
switch (c) {
|
| 751 |
+
case '%': handler.on_text(ptr - 1, ptr); break;
|
| 752 |
+
case 'n': {
|
| 753 |
+
const Char newline[] = {'\n'};
|
| 754 |
+
handler.on_text(newline, newline + 1);
|
| 755 |
+
break;
|
| 756 |
+
}
|
| 757 |
+
case 't': {
|
| 758 |
+
const Char tab[] = {'\t'};
|
| 759 |
+
handler.on_text(tab, tab + 1);
|
| 760 |
+
break;
|
| 761 |
+
}
|
| 762 |
+
// Year:
|
| 763 |
+
case 'Y': handler.on_year(numeric_system::standard, pad); break;
|
| 764 |
+
case 'y': handler.on_short_year(numeric_system::standard); break;
|
| 765 |
+
case 'C': handler.on_century(numeric_system::standard); break;
|
| 766 |
+
case 'G': handler.on_iso_week_based_year(); break;
|
| 767 |
+
case 'g': handler.on_iso_week_based_short_year(); break;
|
| 768 |
+
// Day of the week:
|
| 769 |
+
case 'a': handler.on_abbr_weekday(); break;
|
| 770 |
+
case 'A': handler.on_full_weekday(); break;
|
| 771 |
+
case 'w': handler.on_dec0_weekday(numeric_system::standard); break;
|
| 772 |
+
case 'u': handler.on_dec1_weekday(numeric_system::standard); break;
|
| 773 |
+
// Month:
|
| 774 |
+
case 'b':
|
| 775 |
+
case 'h': handler.on_abbr_month(); break;
|
| 776 |
+
case 'B': handler.on_full_month(); break;
|
| 777 |
+
case 'm': handler.on_dec_month(numeric_system::standard, pad); break;
|
| 778 |
+
// Day of the year/month:
|
| 779 |
+
case 'U':
|
| 780 |
+
handler.on_dec0_week_of_year(numeric_system::standard, pad);
|
| 781 |
+
break;
|
| 782 |
+
case 'W':
|
| 783 |
+
handler.on_dec1_week_of_year(numeric_system::standard, pad);
|
| 784 |
+
break;
|
| 785 |
+
case 'V': handler.on_iso_week_of_year(numeric_system::standard, pad); break;
|
| 786 |
+
case 'j': handler.on_day_of_year(pad); break;
|
| 787 |
+
case 'd': handler.on_day_of_month(numeric_system::standard, pad); break;
|
| 788 |
+
case 'e':
|
| 789 |
+
handler.on_day_of_month(numeric_system::standard, pad_type::space);
|
| 790 |
+
break;
|
| 791 |
+
// Hour, minute, second:
|
| 792 |
+
case 'H': handler.on_24_hour(numeric_system::standard, pad); break;
|
| 793 |
+
case 'I': handler.on_12_hour(numeric_system::standard, pad); break;
|
| 794 |
+
case 'M': handler.on_minute(numeric_system::standard, pad); break;
|
| 795 |
+
case 'S': handler.on_second(numeric_system::standard, pad); break;
|
| 796 |
+
// Other:
|
| 797 |
+
case 'c': handler.on_datetime(numeric_system::standard); break;
|
| 798 |
+
case 'x': handler.on_loc_date(numeric_system::standard); break;
|
| 799 |
+
case 'X': handler.on_loc_time(numeric_system::standard); break;
|
| 800 |
+
case 'D': handler.on_us_date(); break;
|
| 801 |
+
case 'F': handler.on_iso_date(); break;
|
| 802 |
+
case 'r': handler.on_12_hour_time(); break;
|
| 803 |
+
case 'R': handler.on_24_hour_time(); break;
|
| 804 |
+
case 'T': handler.on_iso_time(); break;
|
| 805 |
+
case 'p': handler.on_am_pm(); break;
|
| 806 |
+
case 'Q': handler.on_duration_value(); break;
|
| 807 |
+
case 'q': handler.on_duration_unit(); break;
|
| 808 |
+
case 'z': handler.on_utc_offset(numeric_system::standard); break;
|
| 809 |
+
case 'Z': handler.on_tz_name(); break;
|
| 810 |
+
// Alternative representation:
|
| 811 |
+
case 'E': {
|
| 812 |
+
if (ptr == end) FMT_THROW(format_error("invalid format"));
|
| 813 |
+
c = *ptr++;
|
| 814 |
+
switch (c) {
|
| 815 |
+
case 'Y': handler.on_year(numeric_system::alternative, pad); break;
|
| 816 |
+
case 'y': handler.on_offset_year(); break;
|
| 817 |
+
case 'C': handler.on_century(numeric_system::alternative); break;
|
| 818 |
+
case 'c': handler.on_datetime(numeric_system::alternative); break;
|
| 819 |
+
case 'x': handler.on_loc_date(numeric_system::alternative); break;
|
| 820 |
+
case 'X': handler.on_loc_time(numeric_system::alternative); break;
|
| 821 |
+
case 'z': handler.on_utc_offset(numeric_system::alternative); break;
|
| 822 |
+
default: FMT_THROW(format_error("invalid format"));
|
| 823 |
+
}
|
| 824 |
+
break;
|
| 825 |
+
}
|
| 826 |
+
case 'O':
|
| 827 |
+
if (ptr == end) FMT_THROW(format_error("invalid format"));
|
| 828 |
+
c = *ptr++;
|
| 829 |
+
switch (c) {
|
| 830 |
+
case 'y': handler.on_short_year(numeric_system::alternative); break;
|
| 831 |
+
case 'm': handler.on_dec_month(numeric_system::alternative, pad); break;
|
| 832 |
+
case 'U':
|
| 833 |
+
handler.on_dec0_week_of_year(numeric_system::alternative, pad);
|
| 834 |
+
break;
|
| 835 |
+
case 'W':
|
| 836 |
+
handler.on_dec1_week_of_year(numeric_system::alternative, pad);
|
| 837 |
+
break;
|
| 838 |
+
case 'V':
|
| 839 |
+
handler.on_iso_week_of_year(numeric_system::alternative, pad);
|
| 840 |
+
break;
|
| 841 |
+
case 'd':
|
| 842 |
+
handler.on_day_of_month(numeric_system::alternative, pad);
|
| 843 |
+
break;
|
| 844 |
+
case 'e':
|
| 845 |
+
handler.on_day_of_month(numeric_system::alternative, pad_type::space);
|
| 846 |
+
break;
|
| 847 |
+
case 'w': handler.on_dec0_weekday(numeric_system::alternative); break;
|
| 848 |
+
case 'u': handler.on_dec1_weekday(numeric_system::alternative); break;
|
| 849 |
+
case 'H': handler.on_24_hour(numeric_system::alternative, pad); break;
|
| 850 |
+
case 'I': handler.on_12_hour(numeric_system::alternative, pad); break;
|
| 851 |
+
case 'M': handler.on_minute(numeric_system::alternative, pad); break;
|
| 852 |
+
case 'S': handler.on_second(numeric_system::alternative, pad); break;
|
| 853 |
+
case 'z': handler.on_utc_offset(numeric_system::alternative); break;
|
| 854 |
+
default: FMT_THROW(format_error("invalid format"));
|
| 855 |
+
}
|
| 856 |
+
break;
|
| 857 |
+
default: FMT_THROW(format_error("invalid format"));
|
| 858 |
+
}
|
| 859 |
+
begin = ptr;
|
| 860 |
+
}
|
| 861 |
+
if (begin != ptr) handler.on_text(begin, ptr);
|
| 862 |
+
return ptr;
|
| 863 |
+
}
|
| 864 |
+
|
| 865 |
+
template <typename Derived> struct null_chrono_spec_handler {
|
| 866 |
+
FMT_CONSTEXPR void unsupported() {
|
| 867 |
+
static_cast<Derived*>(this)->unsupported();
|
| 868 |
+
}
|
| 869 |
+
FMT_CONSTEXPR void on_year(numeric_system, pad_type) { unsupported(); }
|
| 870 |
+
FMT_CONSTEXPR void on_short_year(numeric_system) { unsupported(); }
|
| 871 |
+
FMT_CONSTEXPR void on_offset_year() { unsupported(); }
|
| 872 |
+
FMT_CONSTEXPR void on_century(numeric_system) { unsupported(); }
|
| 873 |
+
FMT_CONSTEXPR void on_iso_week_based_year() { unsupported(); }
|
| 874 |
+
FMT_CONSTEXPR void on_iso_week_based_short_year() { unsupported(); }
|
| 875 |
+
FMT_CONSTEXPR void on_abbr_weekday() { unsupported(); }
|
| 876 |
+
FMT_CONSTEXPR void on_full_weekday() { unsupported(); }
|
| 877 |
+
FMT_CONSTEXPR void on_dec0_weekday(numeric_system) { unsupported(); }
|
| 878 |
+
FMT_CONSTEXPR void on_dec1_weekday(numeric_system) { unsupported(); }
|
| 879 |
+
FMT_CONSTEXPR void on_abbr_month() { unsupported(); }
|
| 880 |
+
FMT_CONSTEXPR void on_full_month() { unsupported(); }
|
| 881 |
+
FMT_CONSTEXPR void on_dec_month(numeric_system, pad_type) { unsupported(); }
|
| 882 |
+
FMT_CONSTEXPR void on_dec0_week_of_year(numeric_system, pad_type) {
|
| 883 |
+
unsupported();
|
| 884 |
+
}
|
| 885 |
+
FMT_CONSTEXPR void on_dec1_week_of_year(numeric_system, pad_type) {
|
| 886 |
+
unsupported();
|
| 887 |
+
}
|
| 888 |
+
FMT_CONSTEXPR void on_iso_week_of_year(numeric_system, pad_type) {
|
| 889 |
+
unsupported();
|
| 890 |
+
}
|
| 891 |
+
FMT_CONSTEXPR void on_day_of_year(pad_type) { unsupported(); }
|
| 892 |
+
FMT_CONSTEXPR void on_day_of_month(numeric_system, pad_type) {
|
| 893 |
+
unsupported();
|
| 894 |
+
}
|
| 895 |
+
FMT_CONSTEXPR void on_24_hour(numeric_system) { unsupported(); }
|
| 896 |
+
FMT_CONSTEXPR void on_12_hour(numeric_system) { unsupported(); }
|
| 897 |
+
FMT_CONSTEXPR void on_minute(numeric_system) { unsupported(); }
|
| 898 |
+
FMT_CONSTEXPR void on_second(numeric_system) { unsupported(); }
|
| 899 |
+
FMT_CONSTEXPR void on_datetime(numeric_system) { unsupported(); }
|
| 900 |
+
FMT_CONSTEXPR void on_loc_date(numeric_system) { unsupported(); }
|
| 901 |
+
FMT_CONSTEXPR void on_loc_time(numeric_system) { unsupported(); }
|
| 902 |
+
FMT_CONSTEXPR void on_us_date() { unsupported(); }
|
| 903 |
+
FMT_CONSTEXPR void on_iso_date() { unsupported(); }
|
| 904 |
+
FMT_CONSTEXPR void on_12_hour_time() { unsupported(); }
|
| 905 |
+
FMT_CONSTEXPR void on_24_hour_time() { unsupported(); }
|
| 906 |
+
FMT_CONSTEXPR void on_iso_time() { unsupported(); }
|
| 907 |
+
FMT_CONSTEXPR void on_am_pm() { unsupported(); }
|
| 908 |
+
FMT_CONSTEXPR void on_duration_value() { unsupported(); }
|
| 909 |
+
FMT_CONSTEXPR void on_duration_unit() { unsupported(); }
|
| 910 |
+
FMT_CONSTEXPR void on_utc_offset(numeric_system) { unsupported(); }
|
| 911 |
+
FMT_CONSTEXPR void on_tz_name() { unsupported(); }
|
| 912 |
+
};
|
| 913 |
+
|
| 914 |
+
class tm_format_checker : public null_chrono_spec_handler<tm_format_checker> {
|
| 915 |
+
private:
|
| 916 |
+
bool has_timezone_ = false;
|
| 917 |
+
|
| 918 |
+
public:
|
| 919 |
+
constexpr explicit tm_format_checker(bool has_timezone)
|
| 920 |
+
: has_timezone_(has_timezone) {}
|
| 921 |
+
|
| 922 |
+
FMT_NORETURN inline void unsupported() {
|
| 923 |
+
FMT_THROW(format_error("no format"));
|
| 924 |
+
}
|
| 925 |
+
|
| 926 |
+
template <typename Char>
|
| 927 |
+
FMT_CONSTEXPR void on_text(const Char*, const Char*) {}
|
| 928 |
+
FMT_CONSTEXPR void on_year(numeric_system, pad_type) {}
|
| 929 |
+
FMT_CONSTEXPR void on_short_year(numeric_system) {}
|
| 930 |
+
FMT_CONSTEXPR void on_offset_year() {}
|
| 931 |
+
FMT_CONSTEXPR void on_century(numeric_system) {}
|
| 932 |
+
FMT_CONSTEXPR void on_iso_week_based_year() {}
|
| 933 |
+
FMT_CONSTEXPR void on_iso_week_based_short_year() {}
|
| 934 |
+
FMT_CONSTEXPR void on_abbr_weekday() {}
|
| 935 |
+
FMT_CONSTEXPR void on_full_weekday() {}
|
| 936 |
+
FMT_CONSTEXPR void on_dec0_weekday(numeric_system) {}
|
| 937 |
+
FMT_CONSTEXPR void on_dec1_weekday(numeric_system) {}
|
| 938 |
+
FMT_CONSTEXPR void on_abbr_month() {}
|
| 939 |
+
FMT_CONSTEXPR void on_full_month() {}
|
| 940 |
+
FMT_CONSTEXPR void on_dec_month(numeric_system, pad_type) {}
|
| 941 |
+
FMT_CONSTEXPR void on_dec0_week_of_year(numeric_system, pad_type) {}
|
| 942 |
+
FMT_CONSTEXPR void on_dec1_week_of_year(numeric_system, pad_type) {}
|
| 943 |
+
FMT_CONSTEXPR void on_iso_week_of_year(numeric_system, pad_type) {}
|
| 944 |
+
FMT_CONSTEXPR void on_day_of_year(pad_type) {}
|
| 945 |
+
FMT_CONSTEXPR void on_day_of_month(numeric_system, pad_type) {}
|
| 946 |
+
FMT_CONSTEXPR void on_24_hour(numeric_system, pad_type) {}
|
| 947 |
+
FMT_CONSTEXPR void on_12_hour(numeric_system, pad_type) {}
|
| 948 |
+
FMT_CONSTEXPR void on_minute(numeric_system, pad_type) {}
|
| 949 |
+
FMT_CONSTEXPR void on_second(numeric_system, pad_type) {}
|
| 950 |
+
FMT_CONSTEXPR void on_datetime(numeric_system) {}
|
| 951 |
+
FMT_CONSTEXPR void on_loc_date(numeric_system) {}
|
| 952 |
+
FMT_CONSTEXPR void on_loc_time(numeric_system) {}
|
| 953 |
+
FMT_CONSTEXPR void on_us_date() {}
|
| 954 |
+
FMT_CONSTEXPR void on_iso_date() {}
|
| 955 |
+
FMT_CONSTEXPR void on_12_hour_time() {}
|
| 956 |
+
FMT_CONSTEXPR void on_24_hour_time() {}
|
| 957 |
+
FMT_CONSTEXPR void on_iso_time() {}
|
| 958 |
+
FMT_CONSTEXPR void on_am_pm() {}
|
| 959 |
+
FMT_CONSTEXPR void on_utc_offset(numeric_system) {
|
| 960 |
+
if (!has_timezone_) FMT_THROW(format_error("no timezone"));
|
| 961 |
+
}
|
| 962 |
+
FMT_CONSTEXPR void on_tz_name() {
|
| 963 |
+
if (!has_timezone_) FMT_THROW(format_error("no timezone"));
|
| 964 |
+
}
|
| 965 |
+
};
|
| 966 |
+
|
| 967 |
+
inline auto tm_wday_full_name(int wday) -> const char* {
|
| 968 |
+
static constexpr const char* full_name_list[] = {
|
| 969 |
+
"Sunday", "Monday", "Tuesday", "Wednesday",
|
| 970 |
+
"Thursday", "Friday", "Saturday"};
|
| 971 |
+
return wday >= 0 && wday <= 6 ? full_name_list[wday] : "?";
|
| 972 |
+
}
|
| 973 |
+
inline auto tm_wday_short_name(int wday) -> const char* {
|
| 974 |
+
static constexpr const char* short_name_list[] = {"Sun", "Mon", "Tue", "Wed",
|
| 975 |
+
"Thu", "Fri", "Sat"};
|
| 976 |
+
return wday >= 0 && wday <= 6 ? short_name_list[wday] : "???";
|
| 977 |
+
}
|
| 978 |
+
|
| 979 |
+
inline auto tm_mon_full_name(int mon) -> const char* {
|
| 980 |
+
static constexpr const char* full_name_list[] = {
|
| 981 |
+
"January", "February", "March", "April", "May", "June",
|
| 982 |
+
"July", "August", "September", "October", "November", "December"};
|
| 983 |
+
return mon >= 0 && mon <= 11 ? full_name_list[mon] : "?";
|
| 984 |
+
}
|
| 985 |
+
inline auto tm_mon_short_name(int mon) -> const char* {
|
| 986 |
+
static constexpr const char* short_name_list[] = {
|
| 987 |
+
"Jan", "Feb", "Mar", "Apr", "May", "Jun",
|
| 988 |
+
"Jul", "Aug", "Sep", "Oct", "Nov", "Dec",
|
| 989 |
+
};
|
| 990 |
+
return mon >= 0 && mon <= 11 ? short_name_list[mon] : "???";
|
| 991 |
+
}
|
| 992 |
+
|
| 993 |
+
template <typename T, typename = void>
|
| 994 |
+
struct has_tm_gmtoff : std::false_type {};
|
| 995 |
+
template <typename T>
|
| 996 |
+
struct has_tm_gmtoff<T, void_t<decltype(T::tm_gmtoff)>> : std::true_type {};
|
| 997 |
+
|
| 998 |
+
template <typename T, typename = void> struct has_tm_zone : std::false_type {};
|
| 999 |
+
template <typename T>
|
| 1000 |
+
struct has_tm_zone<T, void_t<decltype(T::tm_zone)>> : std::true_type {};
|
| 1001 |
+
|
| 1002 |
+
template <typename T, FMT_ENABLE_IF(has_tm_zone<T>::value)>
|
| 1003 |
+
bool set_tm_zone(T& time, char* tz) {
|
| 1004 |
+
time.tm_zone = tz;
|
| 1005 |
+
return true;
|
| 1006 |
+
}
|
| 1007 |
+
template <typename T, FMT_ENABLE_IF(!has_tm_zone<T>::value)>
|
| 1008 |
+
bool set_tm_zone(T&, char*) {
|
| 1009 |
+
return false;
|
| 1010 |
+
}
|
| 1011 |
+
|
| 1012 |
+
inline char* utc() {
|
| 1013 |
+
static char tz[] = "UTC";
|
| 1014 |
+
return tz;
|
| 1015 |
+
}
|
| 1016 |
+
|
| 1017 |
+
// Converts value to Int and checks that it's in the range [0, upper).
|
| 1018 |
+
template <typename T, typename Int, FMT_ENABLE_IF(std::is_integral<T>::value)>
|
| 1019 |
+
inline auto to_nonnegative_int(T value, Int upper) -> Int {
|
| 1020 |
+
if (!std::is_unsigned<Int>::value &&
|
| 1021 |
+
(value < 0 || to_unsigned(value) > to_unsigned(upper))) {
|
| 1022 |
+
FMT_THROW(format_error("chrono value is out of range"));
|
| 1023 |
+
}
|
| 1024 |
+
return static_cast<Int>(value);
|
| 1025 |
+
}
|
| 1026 |
+
template <typename T, typename Int, FMT_ENABLE_IF(!std::is_integral<T>::value)>
|
| 1027 |
+
inline auto to_nonnegative_int(T value, Int upper) -> Int {
|
| 1028 |
+
auto int_value = static_cast<Int>(value);
|
| 1029 |
+
if (int_value < 0 || value > static_cast<T>(upper))
|
| 1030 |
+
FMT_THROW(format_error("invalid value"));
|
| 1031 |
+
return int_value;
|
| 1032 |
+
}
|
| 1033 |
+
|
| 1034 |
+
constexpr auto pow10(std::uint32_t n) -> long long {
|
| 1035 |
+
return n == 0 ? 1 : 10 * pow10(n - 1);
|
| 1036 |
+
}
|
| 1037 |
+
|
| 1038 |
+
// Counts the number of fractional digits in the range [0, 18] according to the
|
| 1039 |
+
// C++20 spec. If more than 18 fractional digits are required then returns 6 for
|
| 1040 |
+
// microseconds precision.
|
| 1041 |
+
template <long long Num, long long Den, int N = 0,
|
| 1042 |
+
bool Enabled = (N < 19) && (Num <= max_value<long long>() / 10)>
|
| 1043 |
+
struct count_fractional_digits {
|
| 1044 |
+
static constexpr int value =
|
| 1045 |
+
Num % Den == 0 ? N : count_fractional_digits<Num * 10, Den, N + 1>::value;
|
| 1046 |
+
};
|
| 1047 |
+
|
| 1048 |
+
// Base case that doesn't instantiate any more templates
|
| 1049 |
+
// in order to avoid overflow.
|
| 1050 |
+
template <long long Num, long long Den, int N>
|
| 1051 |
+
struct count_fractional_digits<Num, Den, N, false> {
|
| 1052 |
+
static constexpr int value = (Num % Den == 0) ? N : 6;
|
| 1053 |
+
};
|
| 1054 |
+
|
| 1055 |
+
// Format subseconds which are given as an integer type with an appropriate
|
| 1056 |
+
// number of digits.
|
| 1057 |
+
template <typename Char, typename OutputIt, typename Duration>
|
| 1058 |
+
void write_fractional_seconds(OutputIt& out, Duration d, int precision = -1) {
|
| 1059 |
+
constexpr auto num_fractional_digits =
|
| 1060 |
+
count_fractional_digits<Duration::period::num,
|
| 1061 |
+
Duration::period::den>::value;
|
| 1062 |
+
|
| 1063 |
+
using subsecond_precision = std::chrono::duration<
|
| 1064 |
+
typename std::common_type<typename Duration::rep,
|
| 1065 |
+
std::chrono::seconds::rep>::type,
|
| 1066 |
+
std::ratio<1, pow10(num_fractional_digits)>>;
|
| 1067 |
+
|
| 1068 |
+
const auto fractional = d - detail::duration_cast<std::chrono::seconds>(d);
|
| 1069 |
+
const auto subseconds =
|
| 1070 |
+
std::chrono::treat_as_floating_point<
|
| 1071 |
+
typename subsecond_precision::rep>::value
|
| 1072 |
+
? fractional.count()
|
| 1073 |
+
: detail::duration_cast<subsecond_precision>(fractional).count();
|
| 1074 |
+
auto n = static_cast<uint32_or_64_or_128_t<long long>>(subseconds);
|
| 1075 |
+
const int num_digits = count_digits(n);
|
| 1076 |
+
|
| 1077 |
+
int leading_zeroes = (std::max)(0, num_fractional_digits - num_digits);
|
| 1078 |
+
if (precision < 0) {
|
| 1079 |
+
FMT_ASSERT(!std::is_floating_point<typename Duration::rep>::value, "");
|
| 1080 |
+
if (std::ratio_less<typename subsecond_precision::period,
|
| 1081 |
+
std::chrono::seconds::period>::value) {
|
| 1082 |
+
*out++ = '.';
|
| 1083 |
+
out = detail::fill_n(out, leading_zeroes, '0');
|
| 1084 |
+
out = format_decimal<Char>(out, n, num_digits);
|
| 1085 |
+
}
|
| 1086 |
+
} else if (precision > 0) {
|
| 1087 |
+
*out++ = '.';
|
| 1088 |
+
leading_zeroes = min_of(leading_zeroes, precision);
|
| 1089 |
+
int remaining = precision - leading_zeroes;
|
| 1090 |
+
out = detail::fill_n(out, leading_zeroes, '0');
|
| 1091 |
+
if (remaining < num_digits) {
|
| 1092 |
+
int num_truncated_digits = num_digits - remaining;
|
| 1093 |
+
n /= to_unsigned(pow10(to_unsigned(num_truncated_digits)));
|
| 1094 |
+
if (n != 0) out = format_decimal<Char>(out, n, remaining);
|
| 1095 |
+
return;
|
| 1096 |
+
}
|
| 1097 |
+
if (n != 0) {
|
| 1098 |
+
out = format_decimal<Char>(out, n, num_digits);
|
| 1099 |
+
remaining -= num_digits;
|
| 1100 |
+
}
|
| 1101 |
+
out = detail::fill_n(out, remaining, '0');
|
| 1102 |
+
}
|
| 1103 |
+
}
|
| 1104 |
+
|
| 1105 |
+
// Format subseconds which are given as a floating point type with an
|
| 1106 |
+
// appropriate number of digits. We cannot pass the Duration here, as we
|
| 1107 |
+
// explicitly need to pass the Rep value in the duration_formatter.
|
| 1108 |
+
template <typename Duration>
|
| 1109 |
+
void write_floating_seconds(memory_buffer& buf, Duration duration,
|
| 1110 |
+
int num_fractional_digits = -1) {
|
| 1111 |
+
using rep = typename Duration::rep;
|
| 1112 |
+
FMT_ASSERT(std::is_floating_point<rep>::value, "");
|
| 1113 |
+
|
| 1114 |
+
auto val = duration.count();
|
| 1115 |
+
|
| 1116 |
+
if (num_fractional_digits < 0) {
|
| 1117 |
+
// For `std::round` with fallback to `round`:
|
| 1118 |
+
// On some toolchains `std::round` is not available (e.g. GCC 6).
|
| 1119 |
+
using namespace std;
|
| 1120 |
+
num_fractional_digits =
|
| 1121 |
+
count_fractional_digits<Duration::period::num,
|
| 1122 |
+
Duration::period::den>::value;
|
| 1123 |
+
if (num_fractional_digits < 6 && static_cast<rep>(round(val)) != val)
|
| 1124 |
+
num_fractional_digits = 6;
|
| 1125 |
+
}
|
| 1126 |
+
|
| 1127 |
+
fmt::format_to(std::back_inserter(buf), FMT_STRING("{:.{}f}"),
|
| 1128 |
+
std::fmod(val * static_cast<rep>(Duration::period::num) /
|
| 1129 |
+
static_cast<rep>(Duration::period::den),
|
| 1130 |
+
static_cast<rep>(60)),
|
| 1131 |
+
num_fractional_digits);
|
| 1132 |
+
}
|
| 1133 |
+
|
| 1134 |
+
template <typename OutputIt, typename Char,
|
| 1135 |
+
typename Duration = std::chrono::seconds>
|
| 1136 |
+
class tm_writer {
|
| 1137 |
+
private:
|
| 1138 |
+
static constexpr int days_per_week = 7;
|
| 1139 |
+
|
| 1140 |
+
const std::locale& loc_;
|
| 1141 |
+
bool is_classic_;
|
| 1142 |
+
OutputIt out_;
|
| 1143 |
+
const Duration* subsecs_;
|
| 1144 |
+
const std::tm& tm_;
|
| 1145 |
+
|
| 1146 |
+
auto tm_sec() const noexcept -> int {
|
| 1147 |
+
FMT_ASSERT(tm_.tm_sec >= 0 && tm_.tm_sec <= 61, "");
|
| 1148 |
+
return tm_.tm_sec;
|
| 1149 |
+
}
|
| 1150 |
+
auto tm_min() const noexcept -> int {
|
| 1151 |
+
FMT_ASSERT(tm_.tm_min >= 0 && tm_.tm_min <= 59, "");
|
| 1152 |
+
return tm_.tm_min;
|
| 1153 |
+
}
|
| 1154 |
+
auto tm_hour() const noexcept -> int {
|
| 1155 |
+
FMT_ASSERT(tm_.tm_hour >= 0 && tm_.tm_hour <= 23, "");
|
| 1156 |
+
return tm_.tm_hour;
|
| 1157 |
+
}
|
| 1158 |
+
auto tm_mday() const noexcept -> int {
|
| 1159 |
+
FMT_ASSERT(tm_.tm_mday >= 1 && tm_.tm_mday <= 31, "");
|
| 1160 |
+
return tm_.tm_mday;
|
| 1161 |
+
}
|
| 1162 |
+
auto tm_mon() const noexcept -> int {
|
| 1163 |
+
FMT_ASSERT(tm_.tm_mon >= 0 && tm_.tm_mon <= 11, "");
|
| 1164 |
+
return tm_.tm_mon;
|
| 1165 |
+
}
|
| 1166 |
+
auto tm_year() const noexcept -> long long { return 1900ll + tm_.tm_year; }
|
| 1167 |
+
auto tm_wday() const noexcept -> int {
|
| 1168 |
+
FMT_ASSERT(tm_.tm_wday >= 0 && tm_.tm_wday <= 6, "");
|
| 1169 |
+
return tm_.tm_wday;
|
| 1170 |
+
}
|
| 1171 |
+
auto tm_yday() const noexcept -> int {
|
| 1172 |
+
FMT_ASSERT(tm_.tm_yday >= 0 && tm_.tm_yday <= 365, "");
|
| 1173 |
+
return tm_.tm_yday;
|
| 1174 |
+
}
|
| 1175 |
+
|
| 1176 |
+
auto tm_hour12() const noexcept -> int {
|
| 1177 |
+
auto h = tm_hour();
|
| 1178 |
+
auto z = h < 12 ? h : h - 12;
|
| 1179 |
+
return z == 0 ? 12 : z;
|
| 1180 |
+
}
|
| 1181 |
+
|
| 1182 |
+
// POSIX and the C Standard are unclear or inconsistent about what %C and %y
|
| 1183 |
+
// do if the year is negative or exceeds 9999. Use the convention that %C
|
| 1184 |
+
// concatenated with %y yields the same output as %Y, and that %Y contains at
|
| 1185 |
+
// least 4 characters, with more only if necessary.
|
| 1186 |
+
auto split_year_lower(long long year) const noexcept -> int {
|
| 1187 |
+
auto l = year % 100;
|
| 1188 |
+
if (l < 0) l = -l; // l in [0, 99]
|
| 1189 |
+
return static_cast<int>(l);
|
| 1190 |
+
}
|
| 1191 |
+
|
| 1192 |
+
// Algorithm: https://en.wikipedia.org/wiki/ISO_week_date.
|
| 1193 |
+
auto iso_year_weeks(long long curr_year) const noexcept -> int {
|
| 1194 |
+
auto prev_year = curr_year - 1;
|
| 1195 |
+
auto curr_p =
|
| 1196 |
+
(curr_year + curr_year / 4 - curr_year / 100 + curr_year / 400) %
|
| 1197 |
+
days_per_week;
|
| 1198 |
+
auto prev_p =
|
| 1199 |
+
(prev_year + prev_year / 4 - prev_year / 100 + prev_year / 400) %
|
| 1200 |
+
days_per_week;
|
| 1201 |
+
return 52 + ((curr_p == 4 || prev_p == 3) ? 1 : 0);
|
| 1202 |
+
}
|
| 1203 |
+
auto iso_week_num(int tm_yday, int tm_wday) const noexcept -> int {
|
| 1204 |
+
return (tm_yday + 11 - (tm_wday == 0 ? days_per_week : tm_wday)) /
|
| 1205 |
+
days_per_week;
|
| 1206 |
+
}
|
| 1207 |
+
auto tm_iso_week_year() const noexcept -> long long {
|
| 1208 |
+
auto year = tm_year();
|
| 1209 |
+
auto w = iso_week_num(tm_yday(), tm_wday());
|
| 1210 |
+
if (w < 1) return year - 1;
|
| 1211 |
+
if (w > iso_year_weeks(year)) return year + 1;
|
| 1212 |
+
return year;
|
| 1213 |
+
}
|
| 1214 |
+
auto tm_iso_week_of_year() const noexcept -> int {
|
| 1215 |
+
auto year = tm_year();
|
| 1216 |
+
auto w = iso_week_num(tm_yday(), tm_wday());
|
| 1217 |
+
if (w < 1) return iso_year_weeks(year - 1);
|
| 1218 |
+
if (w > iso_year_weeks(year)) return 1;
|
| 1219 |
+
return w;
|
| 1220 |
+
}
|
| 1221 |
+
|
| 1222 |
+
void write1(int value) {
|
| 1223 |
+
*out_++ = static_cast<char>('0' + to_unsigned(value) % 10);
|
| 1224 |
+
}
|
| 1225 |
+
void write2(int value) {
|
| 1226 |
+
const char* d = digits2(to_unsigned(value) % 100);
|
| 1227 |
+
*out_++ = *d++;
|
| 1228 |
+
*out_++ = *d;
|
| 1229 |
+
}
|
| 1230 |
+
void write2(int value, pad_type pad) {
|
| 1231 |
+
unsigned int v = to_unsigned(value) % 100;
|
| 1232 |
+
if (v >= 10) {
|
| 1233 |
+
const char* d = digits2(v);
|
| 1234 |
+
*out_++ = *d++;
|
| 1235 |
+
*out_++ = *d;
|
| 1236 |
+
} else {
|
| 1237 |
+
out_ = detail::write_padding(out_, pad);
|
| 1238 |
+
*out_++ = static_cast<char>('0' + v);
|
| 1239 |
+
}
|
| 1240 |
+
}
|
| 1241 |
+
|
| 1242 |
+
void write_year_extended(long long year, pad_type pad) {
|
| 1243 |
+
// At least 4 characters.
|
| 1244 |
+
int width = 4;
|
| 1245 |
+
bool negative = year < 0;
|
| 1246 |
+
if (negative) {
|
| 1247 |
+
year = 0 - year;
|
| 1248 |
+
--width;
|
| 1249 |
+
}
|
| 1250 |
+
uint32_or_64_or_128_t<long long> n = to_unsigned(year);
|
| 1251 |
+
const int num_digits = count_digits(n);
|
| 1252 |
+
if (negative && pad == pad_type::zero) *out_++ = '-';
|
| 1253 |
+
if (width > num_digits)
|
| 1254 |
+
out_ = detail::write_padding(out_, pad, width - num_digits);
|
| 1255 |
+
if (negative && pad != pad_type::zero) *out_++ = '-';
|
| 1256 |
+
out_ = format_decimal<Char>(out_, n, num_digits);
|
| 1257 |
+
}
|
| 1258 |
+
void write_year(long long year, pad_type pad) {
|
| 1259 |
+
write_year_extended(year, pad);
|
| 1260 |
+
}
|
| 1261 |
+
|
| 1262 |
+
void write_utc_offset(long long offset, numeric_system ns) {
|
| 1263 |
+
if (offset < 0) {
|
| 1264 |
+
*out_++ = '-';
|
| 1265 |
+
offset = -offset;
|
| 1266 |
+
} else {
|
| 1267 |
+
*out_++ = '+';
|
| 1268 |
+
}
|
| 1269 |
+
offset /= 60;
|
| 1270 |
+
write2(static_cast<int>(offset / 60));
|
| 1271 |
+
if (ns != numeric_system::standard) *out_++ = ':';
|
| 1272 |
+
write2(static_cast<int>(offset % 60));
|
| 1273 |
+
}
|
| 1274 |
+
|
| 1275 |
+
template <typename T, FMT_ENABLE_IF(has_tm_gmtoff<T>::value)>
|
| 1276 |
+
void format_utc_offset(const T& tm, numeric_system ns) {
|
| 1277 |
+
write_utc_offset(tm.tm_gmtoff, ns);
|
| 1278 |
+
}
|
| 1279 |
+
template <typename T, FMT_ENABLE_IF(!has_tm_gmtoff<T>::value)>
|
| 1280 |
+
void format_utc_offset(const T&, numeric_system ns) {
|
| 1281 |
+
write_utc_offset(0, ns);
|
| 1282 |
+
}
|
| 1283 |
+
|
| 1284 |
+
template <typename T, FMT_ENABLE_IF(has_tm_zone<T>::value)>
|
| 1285 |
+
void format_tz_name(const T& tm) {
|
| 1286 |
+
out_ = write_tm_str<Char>(out_, tm.tm_zone, loc_);
|
| 1287 |
+
}
|
| 1288 |
+
template <typename T, FMT_ENABLE_IF(!has_tm_zone<T>::value)>
|
| 1289 |
+
void format_tz_name(const T&) {
|
| 1290 |
+
out_ = std::copy_n(utc(), 3, out_);
|
| 1291 |
+
}
|
| 1292 |
+
|
| 1293 |
+
void format_localized(char format, char modifier = 0) {
|
| 1294 |
+
out_ = write<Char>(out_, tm_, loc_, format, modifier);
|
| 1295 |
+
}
|
| 1296 |
+
|
| 1297 |
+
public:
|
| 1298 |
+
tm_writer(const std::locale& loc, OutputIt out, const std::tm& tm,
|
| 1299 |
+
const Duration* subsecs = nullptr)
|
| 1300 |
+
: loc_(loc),
|
| 1301 |
+
is_classic_(loc_ == get_classic_locale()),
|
| 1302 |
+
out_(out),
|
| 1303 |
+
subsecs_(subsecs),
|
| 1304 |
+
tm_(tm) {}
|
| 1305 |
+
|
| 1306 |
+
auto out() const -> OutputIt { return out_; }
|
| 1307 |
+
|
| 1308 |
+
FMT_CONSTEXPR void on_text(const Char* begin, const Char* end) {
|
| 1309 |
+
out_ = copy<Char>(begin, end, out_);
|
| 1310 |
+
}
|
| 1311 |
+
|
| 1312 |
+
void on_abbr_weekday() {
|
| 1313 |
+
if (is_classic_)
|
| 1314 |
+
out_ = write(out_, tm_wday_short_name(tm_wday()));
|
| 1315 |
+
else
|
| 1316 |
+
format_localized('a');
|
| 1317 |
+
}
|
| 1318 |
+
void on_full_weekday() {
|
| 1319 |
+
if (is_classic_)
|
| 1320 |
+
out_ = write(out_, tm_wday_full_name(tm_wday()));
|
| 1321 |
+
else
|
| 1322 |
+
format_localized('A');
|
| 1323 |
+
}
|
| 1324 |
+
void on_dec0_weekday(numeric_system ns) {
|
| 1325 |
+
if (is_classic_ || ns == numeric_system::standard) return write1(tm_wday());
|
| 1326 |
+
format_localized('w', 'O');
|
| 1327 |
+
}
|
| 1328 |
+
void on_dec1_weekday(numeric_system ns) {
|
| 1329 |
+
if (is_classic_ || ns == numeric_system::standard) {
|
| 1330 |
+
auto wday = tm_wday();
|
| 1331 |
+
write1(wday == 0 ? days_per_week : wday);
|
| 1332 |
+
} else {
|
| 1333 |
+
format_localized('u', 'O');
|
| 1334 |
+
}
|
| 1335 |
+
}
|
| 1336 |
+
|
| 1337 |
+
void on_abbr_month() {
|
| 1338 |
+
if (is_classic_)
|
| 1339 |
+
out_ = write(out_, tm_mon_short_name(tm_mon()));
|
| 1340 |
+
else
|
| 1341 |
+
format_localized('b');
|
| 1342 |
+
}
|
| 1343 |
+
void on_full_month() {
|
| 1344 |
+
if (is_classic_)
|
| 1345 |
+
out_ = write(out_, tm_mon_full_name(tm_mon()));
|
| 1346 |
+
else
|
| 1347 |
+
format_localized('B');
|
| 1348 |
+
}
|
| 1349 |
+
|
| 1350 |
+
void on_datetime(numeric_system ns) {
|
| 1351 |
+
if (is_classic_) {
|
| 1352 |
+
on_abbr_weekday();
|
| 1353 |
+
*out_++ = ' ';
|
| 1354 |
+
on_abbr_month();
|
| 1355 |
+
*out_++ = ' ';
|
| 1356 |
+
on_day_of_month(numeric_system::standard, pad_type::space);
|
| 1357 |
+
*out_++ = ' ';
|
| 1358 |
+
on_iso_time();
|
| 1359 |
+
*out_++ = ' ';
|
| 1360 |
+
on_year(numeric_system::standard, pad_type::space);
|
| 1361 |
+
} else {
|
| 1362 |
+
format_localized('c', ns == numeric_system::standard ? '\0' : 'E');
|
| 1363 |
+
}
|
| 1364 |
+
}
|
| 1365 |
+
void on_loc_date(numeric_system ns) {
|
| 1366 |
+
if (is_classic_)
|
| 1367 |
+
on_us_date();
|
| 1368 |
+
else
|
| 1369 |
+
format_localized('x', ns == numeric_system::standard ? '\0' : 'E');
|
| 1370 |
+
}
|
| 1371 |
+
void on_loc_time(numeric_system ns) {
|
| 1372 |
+
if (is_classic_)
|
| 1373 |
+
on_iso_time();
|
| 1374 |
+
else
|
| 1375 |
+
format_localized('X', ns == numeric_system::standard ? '\0' : 'E');
|
| 1376 |
+
}
|
| 1377 |
+
void on_us_date() {
|
| 1378 |
+
char buf[8];
|
| 1379 |
+
write_digit2_separated(buf, to_unsigned(tm_mon() + 1),
|
| 1380 |
+
to_unsigned(tm_mday()),
|
| 1381 |
+
to_unsigned(split_year_lower(tm_year())), '/');
|
| 1382 |
+
out_ = copy<Char>(std::begin(buf), std::end(buf), out_);
|
| 1383 |
+
}
|
| 1384 |
+
void on_iso_date() {
|
| 1385 |
+
auto year = tm_year();
|
| 1386 |
+
char buf[10];
|
| 1387 |
+
size_t offset = 0;
|
| 1388 |
+
if (year >= 0 && year < 10000) {
|
| 1389 |
+
write2digits(buf, static_cast<size_t>(year / 100));
|
| 1390 |
+
} else {
|
| 1391 |
+
offset = 4;
|
| 1392 |
+
write_year_extended(year, pad_type::zero);
|
| 1393 |
+
year = 0;
|
| 1394 |
+
}
|
| 1395 |
+
write_digit2_separated(buf + 2, static_cast<unsigned>(year % 100),
|
| 1396 |
+
to_unsigned(tm_mon() + 1), to_unsigned(tm_mday()),
|
| 1397 |
+
'-');
|
| 1398 |
+
out_ = copy<Char>(std::begin(buf) + offset, std::end(buf), out_);
|
| 1399 |
+
}
|
| 1400 |
+
|
| 1401 |
+
void on_utc_offset(numeric_system ns) { format_utc_offset(tm_, ns); }
|
| 1402 |
+
void on_tz_name() { format_tz_name(tm_); }
|
| 1403 |
+
|
| 1404 |
+
void on_year(numeric_system ns, pad_type pad) {
|
| 1405 |
+
if (is_classic_ || ns == numeric_system::standard)
|
| 1406 |
+
return write_year(tm_year(), pad);
|
| 1407 |
+
format_localized('Y', 'E');
|
| 1408 |
+
}
|
| 1409 |
+
void on_short_year(numeric_system ns) {
|
| 1410 |
+
if (is_classic_ || ns == numeric_system::standard)
|
| 1411 |
+
return write2(split_year_lower(tm_year()));
|
| 1412 |
+
format_localized('y', 'O');
|
| 1413 |
+
}
|
| 1414 |
+
void on_offset_year() {
|
| 1415 |
+
if (is_classic_) return write2(split_year_lower(tm_year()));
|
| 1416 |
+
format_localized('y', 'E');
|
| 1417 |
+
}
|
| 1418 |
+
|
| 1419 |
+
void on_century(numeric_system ns) {
|
| 1420 |
+
if (is_classic_ || ns == numeric_system::standard) {
|
| 1421 |
+
auto year = tm_year();
|
| 1422 |
+
auto upper = year / 100;
|
| 1423 |
+
if (year >= -99 && year < 0) {
|
| 1424 |
+
// Zero upper on negative year.
|
| 1425 |
+
*out_++ = '-';
|
| 1426 |
+
*out_++ = '0';
|
| 1427 |
+
} else if (upper >= 0 && upper < 100) {
|
| 1428 |
+
write2(static_cast<int>(upper));
|
| 1429 |
+
} else {
|
| 1430 |
+
out_ = write<Char>(out_, upper);
|
| 1431 |
+
}
|
| 1432 |
+
} else {
|
| 1433 |
+
format_localized('C', 'E');
|
| 1434 |
+
}
|
| 1435 |
+
}
|
| 1436 |
+
|
| 1437 |
+
void on_dec_month(numeric_system ns, pad_type pad) {
|
| 1438 |
+
if (is_classic_ || ns == numeric_system::standard)
|
| 1439 |
+
return write2(tm_mon() + 1, pad);
|
| 1440 |
+
format_localized('m', 'O');
|
| 1441 |
+
}
|
| 1442 |
+
|
| 1443 |
+
void on_dec0_week_of_year(numeric_system ns, pad_type pad) {
|
| 1444 |
+
if (is_classic_ || ns == numeric_system::standard)
|
| 1445 |
+
return write2((tm_yday() + days_per_week - tm_wday()) / days_per_week,
|
| 1446 |
+
pad);
|
| 1447 |
+
format_localized('U', 'O');
|
| 1448 |
+
}
|
| 1449 |
+
void on_dec1_week_of_year(numeric_system ns, pad_type pad) {
|
| 1450 |
+
if (is_classic_ || ns == numeric_system::standard) {
|
| 1451 |
+
auto wday = tm_wday();
|
| 1452 |
+
write2((tm_yday() + days_per_week -
|
| 1453 |
+
(wday == 0 ? (days_per_week - 1) : (wday - 1))) /
|
| 1454 |
+
days_per_week,
|
| 1455 |
+
pad);
|
| 1456 |
+
} else {
|
| 1457 |
+
format_localized('W', 'O');
|
| 1458 |
+
}
|
| 1459 |
+
}
|
| 1460 |
+
void on_iso_week_of_year(numeric_system ns, pad_type pad) {
|
| 1461 |
+
if (is_classic_ || ns == numeric_system::standard)
|
| 1462 |
+
return write2(tm_iso_week_of_year(), pad);
|
| 1463 |
+
format_localized('V', 'O');
|
| 1464 |
+
}
|
| 1465 |
+
|
| 1466 |
+
void on_iso_week_based_year() {
|
| 1467 |
+
write_year(tm_iso_week_year(), pad_type::zero);
|
| 1468 |
+
}
|
| 1469 |
+
void on_iso_week_based_short_year() {
|
| 1470 |
+
write2(split_year_lower(tm_iso_week_year()));
|
| 1471 |
+
}
|
| 1472 |
+
|
| 1473 |
+
void on_day_of_year(pad_type pad) {
|
| 1474 |
+
auto yday = tm_yday() + 1;
|
| 1475 |
+
auto digit1 = yday / 100;
|
| 1476 |
+
if (digit1 != 0)
|
| 1477 |
+
write1(digit1);
|
| 1478 |
+
else
|
| 1479 |
+
out_ = detail::write_padding(out_, pad);
|
| 1480 |
+
write2(yday % 100, pad);
|
| 1481 |
+
}
|
| 1482 |
+
|
| 1483 |
+
void on_day_of_month(numeric_system ns, pad_type pad) {
|
| 1484 |
+
if (is_classic_ || ns == numeric_system::standard)
|
| 1485 |
+
return write2(tm_mday(), pad);
|
| 1486 |
+
format_localized('d', 'O');
|
| 1487 |
+
}
|
| 1488 |
+
|
| 1489 |
+
void on_24_hour(numeric_system ns, pad_type pad) {
|
| 1490 |
+
if (is_classic_ || ns == numeric_system::standard)
|
| 1491 |
+
return write2(tm_hour(), pad);
|
| 1492 |
+
format_localized('H', 'O');
|
| 1493 |
+
}
|
| 1494 |
+
void on_12_hour(numeric_system ns, pad_type pad) {
|
| 1495 |
+
if (is_classic_ || ns == numeric_system::standard)
|
| 1496 |
+
return write2(tm_hour12(), pad);
|
| 1497 |
+
format_localized('I', 'O');
|
| 1498 |
+
}
|
| 1499 |
+
void on_minute(numeric_system ns, pad_type pad) {
|
| 1500 |
+
if (is_classic_ || ns == numeric_system::standard)
|
| 1501 |
+
return write2(tm_min(), pad);
|
| 1502 |
+
format_localized('M', 'O');
|
| 1503 |
+
}
|
| 1504 |
+
|
| 1505 |
+
void on_second(numeric_system ns, pad_type pad) {
|
| 1506 |
+
if (is_classic_ || ns == numeric_system::standard) {
|
| 1507 |
+
write2(tm_sec(), pad);
|
| 1508 |
+
if (subsecs_) {
|
| 1509 |
+
if (std::is_floating_point<typename Duration::rep>::value) {
|
| 1510 |
+
auto buf = memory_buffer();
|
| 1511 |
+
write_floating_seconds(buf, *subsecs_);
|
| 1512 |
+
if (buf.size() > 1) {
|
| 1513 |
+
// Remove the leading "0", write something like ".123".
|
| 1514 |
+
out_ = copy<Char>(buf.begin() + 1, buf.end(), out_);
|
| 1515 |
+
}
|
| 1516 |
+
} else {
|
| 1517 |
+
write_fractional_seconds<Char>(out_, *subsecs_);
|
| 1518 |
+
}
|
| 1519 |
+
}
|
| 1520 |
+
} else {
|
| 1521 |
+
// Currently no formatting of subseconds when a locale is set.
|
| 1522 |
+
format_localized('S', 'O');
|
| 1523 |
+
}
|
| 1524 |
+
}
|
| 1525 |
+
|
| 1526 |
+
void on_12_hour_time() {
|
| 1527 |
+
if (is_classic_) {
|
| 1528 |
+
char buf[8];
|
| 1529 |
+
write_digit2_separated(buf, to_unsigned(tm_hour12()),
|
| 1530 |
+
to_unsigned(tm_min()), to_unsigned(tm_sec()), ':');
|
| 1531 |
+
out_ = copy<Char>(std::begin(buf), std::end(buf), out_);
|
| 1532 |
+
*out_++ = ' ';
|
| 1533 |
+
on_am_pm();
|
| 1534 |
+
} else {
|
| 1535 |
+
format_localized('r');
|
| 1536 |
+
}
|
| 1537 |
+
}
|
| 1538 |
+
void on_24_hour_time() {
|
| 1539 |
+
write2(tm_hour());
|
| 1540 |
+
*out_++ = ':';
|
| 1541 |
+
write2(tm_min());
|
| 1542 |
+
}
|
| 1543 |
+
void on_iso_time() {
|
| 1544 |
+
on_24_hour_time();
|
| 1545 |
+
*out_++ = ':';
|
| 1546 |
+
on_second(numeric_system::standard, pad_type::zero);
|
| 1547 |
+
}
|
| 1548 |
+
|
| 1549 |
+
void on_am_pm() {
|
| 1550 |
+
if (is_classic_) {
|
| 1551 |
+
*out_++ = tm_hour() < 12 ? 'A' : 'P';
|
| 1552 |
+
*out_++ = 'M';
|
| 1553 |
+
} else {
|
| 1554 |
+
format_localized('p');
|
| 1555 |
+
}
|
| 1556 |
+
}
|
| 1557 |
+
|
| 1558 |
+
// These apply to chrono durations but not tm.
|
| 1559 |
+
void on_duration_value() {}
|
| 1560 |
+
void on_duration_unit() {}
|
| 1561 |
+
};
|
| 1562 |
+
|
| 1563 |
+
struct chrono_format_checker : null_chrono_spec_handler<chrono_format_checker> {
|
| 1564 |
+
bool has_precision_integral = false;
|
| 1565 |
+
|
| 1566 |
+
FMT_NORETURN inline void unsupported() { FMT_THROW(format_error("no date")); }
|
| 1567 |
+
|
| 1568 |
+
template <typename Char>
|
| 1569 |
+
FMT_CONSTEXPR void on_text(const Char*, const Char*) {}
|
| 1570 |
+
FMT_CONSTEXPR void on_day_of_year(pad_type) {}
|
| 1571 |
+
FMT_CONSTEXPR void on_24_hour(numeric_system, pad_type) {}
|
| 1572 |
+
FMT_CONSTEXPR void on_12_hour(numeric_system, pad_type) {}
|
| 1573 |
+
FMT_CONSTEXPR void on_minute(numeric_system, pad_type) {}
|
| 1574 |
+
FMT_CONSTEXPR void on_second(numeric_system, pad_type) {}
|
| 1575 |
+
FMT_CONSTEXPR void on_12_hour_time() {}
|
| 1576 |
+
FMT_CONSTEXPR void on_24_hour_time() {}
|
| 1577 |
+
FMT_CONSTEXPR void on_iso_time() {}
|
| 1578 |
+
FMT_CONSTEXPR void on_am_pm() {}
|
| 1579 |
+
FMT_CONSTEXPR void on_duration_value() const {
|
| 1580 |
+
if (has_precision_integral)
|
| 1581 |
+
FMT_THROW(format_error("precision not allowed for this argument type"));
|
| 1582 |
+
}
|
| 1583 |
+
FMT_CONSTEXPR void on_duration_unit() {}
|
| 1584 |
+
};
|
| 1585 |
+
|
| 1586 |
+
template <typename T,
|
| 1587 |
+
FMT_ENABLE_IF(std::is_integral<T>::value&& has_isfinite<T>::value)>
|
| 1588 |
+
inline auto isfinite(T) -> bool {
|
| 1589 |
+
return true;
|
| 1590 |
+
}
|
| 1591 |
+
|
| 1592 |
+
template <typename T, FMT_ENABLE_IF(std::is_integral<T>::value)>
|
| 1593 |
+
inline auto mod(T x, int y) -> T {
|
| 1594 |
+
return x % static_cast<T>(y);
|
| 1595 |
+
}
|
| 1596 |
+
template <typename T, FMT_ENABLE_IF(std::is_floating_point<T>::value)>
|
| 1597 |
+
inline auto mod(T x, int y) -> T {
|
| 1598 |
+
return std::fmod(x, static_cast<T>(y));
|
| 1599 |
+
}
|
| 1600 |
+
|
| 1601 |
+
// If T is an integral type, maps T to its unsigned counterpart, otherwise
|
| 1602 |
+
// leaves it unchanged (unlike std::make_unsigned).
|
| 1603 |
+
template <typename T, bool INTEGRAL = std::is_integral<T>::value>
|
| 1604 |
+
struct make_unsigned_or_unchanged {
|
| 1605 |
+
using type = T;
|
| 1606 |
+
};
|
| 1607 |
+
|
| 1608 |
+
template <typename T> struct make_unsigned_or_unchanged<T, true> {
|
| 1609 |
+
using type = typename std::make_unsigned<T>::type;
|
| 1610 |
+
};
|
| 1611 |
+
|
| 1612 |
+
template <typename Rep, typename Period,
|
| 1613 |
+
FMT_ENABLE_IF(std::is_integral<Rep>::value)>
|
| 1614 |
+
inline auto get_milliseconds(std::chrono::duration<Rep, Period> d)
|
| 1615 |
+
-> std::chrono::duration<Rep, std::milli> {
|
| 1616 |
+
// This may overflow and/or the result may not fit in the target type.
|
| 1617 |
+
#if FMT_SAFE_DURATION_CAST
|
| 1618 |
+
using common_seconds_type =
|
| 1619 |
+
typename std::common_type<decltype(d), std::chrono::seconds>::type;
|
| 1620 |
+
auto d_as_common = detail::duration_cast<common_seconds_type>(d);
|
| 1621 |
+
auto d_as_whole_seconds =
|
| 1622 |
+
detail::duration_cast<std::chrono::seconds>(d_as_common);
|
| 1623 |
+
// This conversion should be nonproblematic.
|
| 1624 |
+
auto diff = d_as_common - d_as_whole_seconds;
|
| 1625 |
+
auto ms = detail::duration_cast<std::chrono::duration<Rep, std::milli>>(diff);
|
| 1626 |
+
return ms;
|
| 1627 |
+
#else
|
| 1628 |
+
auto s = detail::duration_cast<std::chrono::seconds>(d);
|
| 1629 |
+
return detail::duration_cast<std::chrono::milliseconds>(d - s);
|
| 1630 |
+
#endif
|
| 1631 |
+
}
|
| 1632 |
+
|
| 1633 |
+
template <typename Char, typename Rep, typename OutputIt,
|
| 1634 |
+
FMT_ENABLE_IF(std::is_integral<Rep>::value)>
|
| 1635 |
+
auto format_duration_value(OutputIt out, Rep val, int) -> OutputIt {
|
| 1636 |
+
return write<Char>(out, val);
|
| 1637 |
+
}
|
| 1638 |
+
|
| 1639 |
+
template <typename Char, typename Rep, typename OutputIt,
|
| 1640 |
+
FMT_ENABLE_IF(std::is_floating_point<Rep>::value)>
|
| 1641 |
+
auto format_duration_value(OutputIt out, Rep val, int precision) -> OutputIt {
|
| 1642 |
+
auto specs = format_specs();
|
| 1643 |
+
specs.precision = precision;
|
| 1644 |
+
specs.set_type(precision >= 0 ? presentation_type::fixed
|
| 1645 |
+
: presentation_type::general);
|
| 1646 |
+
return write<Char>(out, val, specs);
|
| 1647 |
+
}
|
| 1648 |
+
|
| 1649 |
+
template <typename Char, typename OutputIt>
|
| 1650 |
+
auto copy_unit(string_view unit, OutputIt out, Char) -> OutputIt {
|
| 1651 |
+
return copy<Char>(unit.begin(), unit.end(), out);
|
| 1652 |
+
}
|
| 1653 |
+
|
| 1654 |
+
template <typename OutputIt>
|
| 1655 |
+
auto copy_unit(string_view unit, OutputIt out, wchar_t) -> OutputIt {
|
| 1656 |
+
// This works when wchar_t is UTF-32 because units only contain characters
|
| 1657 |
+
// that have the same representation in UTF-16 and UTF-32.
|
| 1658 |
+
utf8_to_utf16 u(unit);
|
| 1659 |
+
return copy<wchar_t>(u.c_str(), u.c_str() + u.size(), out);
|
| 1660 |
+
}
|
| 1661 |
+
|
| 1662 |
+
template <typename Char, typename Period, typename OutputIt>
|
| 1663 |
+
auto format_duration_unit(OutputIt out) -> OutputIt {
|
| 1664 |
+
if (const char* unit = get_units<Period>())
|
| 1665 |
+
return copy_unit(string_view(unit), out, Char());
|
| 1666 |
+
*out++ = '[';
|
| 1667 |
+
out = write<Char>(out, Period::num);
|
| 1668 |
+
if (const_check(Period::den != 1)) {
|
| 1669 |
+
*out++ = '/';
|
| 1670 |
+
out = write<Char>(out, Period::den);
|
| 1671 |
+
}
|
| 1672 |
+
*out++ = ']';
|
| 1673 |
+
*out++ = 's';
|
| 1674 |
+
return out;
|
| 1675 |
+
}
|
| 1676 |
+
|
| 1677 |
+
class get_locale {
|
| 1678 |
+
private:
|
| 1679 |
+
union {
|
| 1680 |
+
std::locale locale_;
|
| 1681 |
+
};
|
| 1682 |
+
bool has_locale_ = false;
|
| 1683 |
+
|
| 1684 |
+
public:
|
| 1685 |
+
inline get_locale(bool localized, locale_ref loc) : has_locale_(localized) {
|
| 1686 |
+
if (localized)
|
| 1687 |
+
::new (&locale_) std::locale(loc.template get<std::locale>());
|
| 1688 |
+
}
|
| 1689 |
+
inline ~get_locale() {
|
| 1690 |
+
if (has_locale_) locale_.~locale();
|
| 1691 |
+
}
|
| 1692 |
+
inline operator const std::locale&() const {
|
| 1693 |
+
return has_locale_ ? locale_ : get_classic_locale();
|
| 1694 |
+
}
|
| 1695 |
+
};
|
| 1696 |
+
|
| 1697 |
+
template <typename Char, typename Rep, typename Period>
|
| 1698 |
+
struct duration_formatter {
|
| 1699 |
+
using iterator = basic_appender<Char>;
|
| 1700 |
+
iterator out;
|
| 1701 |
+
// rep is unsigned to avoid overflow.
|
| 1702 |
+
using rep =
|
| 1703 |
+
conditional_t<std::is_integral<Rep>::value && sizeof(Rep) < sizeof(int),
|
| 1704 |
+
unsigned, typename make_unsigned_or_unchanged<Rep>::type>;
|
| 1705 |
+
rep val;
|
| 1706 |
+
int precision;
|
| 1707 |
+
locale_ref locale;
|
| 1708 |
+
bool localized = false;
|
| 1709 |
+
using seconds = std::chrono::duration<rep>;
|
| 1710 |
+
seconds s;
|
| 1711 |
+
using milliseconds = std::chrono::duration<rep, std::milli>;
|
| 1712 |
+
bool negative;
|
| 1713 |
+
|
| 1714 |
+
using tm_writer_type = tm_writer<iterator, Char>;
|
| 1715 |
+
|
| 1716 |
+
duration_formatter(iterator o, std::chrono::duration<Rep, Period> d,
|
| 1717 |
+
locale_ref loc)
|
| 1718 |
+
: out(o), val(static_cast<rep>(d.count())), locale(loc), negative(false) {
|
| 1719 |
+
if (d.count() < 0) {
|
| 1720 |
+
val = 0 - val;
|
| 1721 |
+
negative = true;
|
| 1722 |
+
}
|
| 1723 |
+
|
| 1724 |
+
// this may overflow and/or the result may not fit in the
|
| 1725 |
+
// target type.
|
| 1726 |
+
// might need checked conversion (rep!=Rep)
|
| 1727 |
+
s = detail::duration_cast<seconds>(std::chrono::duration<rep, Period>(val));
|
| 1728 |
+
}
|
| 1729 |
+
|
| 1730 |
+
// returns true if nan or inf, writes to out.
|
| 1731 |
+
auto handle_nan_inf() -> bool {
|
| 1732 |
+
if (isfinite(val)) return false;
|
| 1733 |
+
if (isnan(val)) {
|
| 1734 |
+
write_nan();
|
| 1735 |
+
return true;
|
| 1736 |
+
}
|
| 1737 |
+
// must be +-inf
|
| 1738 |
+
if (val > 0)
|
| 1739 |
+
std::copy_n("inf", 3, out);
|
| 1740 |
+
else
|
| 1741 |
+
std::copy_n("-inf", 4, out);
|
| 1742 |
+
return true;
|
| 1743 |
+
}
|
| 1744 |
+
|
| 1745 |
+
auto days() const -> Rep { return static_cast<Rep>(s.count() / 86400); }
|
| 1746 |
+
auto hour() const -> Rep {
|
| 1747 |
+
return static_cast<Rep>(mod((s.count() / 3600), 24));
|
| 1748 |
+
}
|
| 1749 |
+
|
| 1750 |
+
auto hour12() const -> Rep {
|
| 1751 |
+
Rep hour = static_cast<Rep>(mod((s.count() / 3600), 12));
|
| 1752 |
+
return hour <= 0 ? 12 : hour;
|
| 1753 |
+
}
|
| 1754 |
+
|
| 1755 |
+
auto minute() const -> Rep {
|
| 1756 |
+
return static_cast<Rep>(mod((s.count() / 60), 60));
|
| 1757 |
+
}
|
| 1758 |
+
auto second() const -> Rep { return static_cast<Rep>(mod(s.count(), 60)); }
|
| 1759 |
+
|
| 1760 |
+
auto time() const -> std::tm {
|
| 1761 |
+
auto time = std::tm();
|
| 1762 |
+
time.tm_hour = to_nonnegative_int(hour(), 24);
|
| 1763 |
+
time.tm_min = to_nonnegative_int(minute(), 60);
|
| 1764 |
+
time.tm_sec = to_nonnegative_int(second(), 60);
|
| 1765 |
+
return time;
|
| 1766 |
+
}
|
| 1767 |
+
|
| 1768 |
+
void write_sign() {
|
| 1769 |
+
if (!negative) return;
|
| 1770 |
+
*out++ = '-';
|
| 1771 |
+
negative = false;
|
| 1772 |
+
}
|
| 1773 |
+
|
| 1774 |
+
void write(Rep value, int width, pad_type pad = pad_type::zero) {
|
| 1775 |
+
write_sign();
|
| 1776 |
+
if (isnan(value)) return write_nan();
|
| 1777 |
+
uint32_or_64_or_128_t<int> n =
|
| 1778 |
+
to_unsigned(to_nonnegative_int(value, max_value<int>()));
|
| 1779 |
+
int num_digits = detail::count_digits(n);
|
| 1780 |
+
if (width > num_digits) {
|
| 1781 |
+
out = detail::write_padding(out, pad, width - num_digits);
|
| 1782 |
+
}
|
| 1783 |
+
out = format_decimal<Char>(out, n, num_digits);
|
| 1784 |
+
}
|
| 1785 |
+
|
| 1786 |
+
void write_nan() { std::copy_n("nan", 3, out); }
|
| 1787 |
+
|
| 1788 |
+
template <typename Callback, typename... Args>
|
| 1789 |
+
void format_tm(const tm& time, Callback cb, Args... args) {
|
| 1790 |
+
if (isnan(val)) return write_nan();
|
| 1791 |
+
get_locale loc(localized, locale);
|
| 1792 |
+
auto w = tm_writer_type(loc, out, time);
|
| 1793 |
+
(w.*cb)(args...);
|
| 1794 |
+
out = w.out();
|
| 1795 |
+
}
|
| 1796 |
+
|
| 1797 |
+
void on_text(const Char* begin, const Char* end) {
|
| 1798 |
+
copy<Char>(begin, end, out);
|
| 1799 |
+
}
|
| 1800 |
+
|
| 1801 |
+
// These are not implemented because durations don't have date information.
|
| 1802 |
+
void on_abbr_weekday() {}
|
| 1803 |
+
void on_full_weekday() {}
|
| 1804 |
+
void on_dec0_weekday(numeric_system) {}
|
| 1805 |
+
void on_dec1_weekday(numeric_system) {}
|
| 1806 |
+
void on_abbr_month() {}
|
| 1807 |
+
void on_full_month() {}
|
| 1808 |
+
void on_datetime(numeric_system) {}
|
| 1809 |
+
void on_loc_date(numeric_system) {}
|
| 1810 |
+
void on_loc_time(numeric_system) {}
|
| 1811 |
+
void on_us_date() {}
|
| 1812 |
+
void on_iso_date() {}
|
| 1813 |
+
void on_utc_offset(numeric_system) {}
|
| 1814 |
+
void on_tz_name() {}
|
| 1815 |
+
void on_year(numeric_system, pad_type) {}
|
| 1816 |
+
void on_short_year(numeric_system) {}
|
| 1817 |
+
void on_offset_year() {}
|
| 1818 |
+
void on_century(numeric_system) {}
|
| 1819 |
+
void on_iso_week_based_year() {}
|
| 1820 |
+
void on_iso_week_based_short_year() {}
|
| 1821 |
+
void on_dec_month(numeric_system, pad_type) {}
|
| 1822 |
+
void on_dec0_week_of_year(numeric_system, pad_type) {}
|
| 1823 |
+
void on_dec1_week_of_year(numeric_system, pad_type) {}
|
| 1824 |
+
void on_iso_week_of_year(numeric_system, pad_type) {}
|
| 1825 |
+
void on_day_of_month(numeric_system, pad_type) {}
|
| 1826 |
+
|
| 1827 |
+
void on_day_of_year(pad_type) {
|
| 1828 |
+
if (handle_nan_inf()) return;
|
| 1829 |
+
write(days(), 0);
|
| 1830 |
+
}
|
| 1831 |
+
|
| 1832 |
+
void on_24_hour(numeric_system ns, pad_type pad) {
|
| 1833 |
+
if (handle_nan_inf()) return;
|
| 1834 |
+
|
| 1835 |
+
if (ns == numeric_system::standard) return write(hour(), 2, pad);
|
| 1836 |
+
auto time = tm();
|
| 1837 |
+
time.tm_hour = to_nonnegative_int(hour(), 24);
|
| 1838 |
+
format_tm(time, &tm_writer_type::on_24_hour, ns, pad);
|
| 1839 |
+
}
|
| 1840 |
+
|
| 1841 |
+
void on_12_hour(numeric_system ns, pad_type pad) {
|
| 1842 |
+
if (handle_nan_inf()) return;
|
| 1843 |
+
|
| 1844 |
+
if (ns == numeric_system::standard) return write(hour12(), 2, pad);
|
| 1845 |
+
auto time = tm();
|
| 1846 |
+
time.tm_hour = to_nonnegative_int(hour12(), 12);
|
| 1847 |
+
format_tm(time, &tm_writer_type::on_12_hour, ns, pad);
|
| 1848 |
+
}
|
| 1849 |
+
|
| 1850 |
+
void on_minute(numeric_system ns, pad_type pad) {
|
| 1851 |
+
if (handle_nan_inf()) return;
|
| 1852 |
+
|
| 1853 |
+
if (ns == numeric_system::standard) return write(minute(), 2, pad);
|
| 1854 |
+
auto time = tm();
|
| 1855 |
+
time.tm_min = to_nonnegative_int(minute(), 60);
|
| 1856 |
+
format_tm(time, &tm_writer_type::on_minute, ns, pad);
|
| 1857 |
+
}
|
| 1858 |
+
|
| 1859 |
+
void on_second(numeric_system ns, pad_type pad) {
|
| 1860 |
+
if (handle_nan_inf()) return;
|
| 1861 |
+
|
| 1862 |
+
if (ns == numeric_system::standard) {
|
| 1863 |
+
if (std::is_floating_point<rep>::value) {
|
| 1864 |
+
auto buf = memory_buffer();
|
| 1865 |
+
write_floating_seconds(buf, std::chrono::duration<rep, Period>(val),
|
| 1866 |
+
precision);
|
| 1867 |
+
if (negative) *out++ = '-';
|
| 1868 |
+
if (buf.size() < 2 || buf[1] == '.')
|
| 1869 |
+
out = detail::write_padding(out, pad);
|
| 1870 |
+
out = copy<Char>(buf.begin(), buf.end(), out);
|
| 1871 |
+
} else {
|
| 1872 |
+
write(second(), 2, pad);
|
| 1873 |
+
write_fractional_seconds<Char>(
|
| 1874 |
+
out, std::chrono::duration<rep, Period>(val), precision);
|
| 1875 |
+
}
|
| 1876 |
+
return;
|
| 1877 |
+
}
|
| 1878 |
+
auto time = tm();
|
| 1879 |
+
time.tm_sec = to_nonnegative_int(second(), 60);
|
| 1880 |
+
format_tm(time, &tm_writer_type::on_second, ns, pad);
|
| 1881 |
+
}
|
| 1882 |
+
|
| 1883 |
+
void on_12_hour_time() {
|
| 1884 |
+
if (handle_nan_inf()) return;
|
| 1885 |
+
format_tm(time(), &tm_writer_type::on_12_hour_time);
|
| 1886 |
+
}
|
| 1887 |
+
|
| 1888 |
+
void on_24_hour_time() {
|
| 1889 |
+
if (handle_nan_inf()) {
|
| 1890 |
+
*out++ = ':';
|
| 1891 |
+
handle_nan_inf();
|
| 1892 |
+
return;
|
| 1893 |
+
}
|
| 1894 |
+
|
| 1895 |
+
write(hour(), 2);
|
| 1896 |
+
*out++ = ':';
|
| 1897 |
+
write(minute(), 2);
|
| 1898 |
+
}
|
| 1899 |
+
|
| 1900 |
+
void on_iso_time() {
|
| 1901 |
+
on_24_hour_time();
|
| 1902 |
+
*out++ = ':';
|
| 1903 |
+
if (handle_nan_inf()) return;
|
| 1904 |
+
on_second(numeric_system::standard, pad_type::zero);
|
| 1905 |
+
}
|
| 1906 |
+
|
| 1907 |
+
void on_am_pm() {
|
| 1908 |
+
if (handle_nan_inf()) return;
|
| 1909 |
+
format_tm(time(), &tm_writer_type::on_am_pm);
|
| 1910 |
+
}
|
| 1911 |
+
|
| 1912 |
+
void on_duration_value() {
|
| 1913 |
+
if (handle_nan_inf()) return;
|
| 1914 |
+
write_sign();
|
| 1915 |
+
out = format_duration_value<Char>(out, val, precision);
|
| 1916 |
+
}
|
| 1917 |
+
|
| 1918 |
+
void on_duration_unit() { out = format_duration_unit<Char, Period>(out); }
|
| 1919 |
+
};
|
| 1920 |
+
|
| 1921 |
+
} // namespace detail
|
| 1922 |
+
|
| 1923 |
+
#if defined(__cpp_lib_chrono) && __cpp_lib_chrono >= 201907
|
| 1924 |
+
using weekday = std::chrono::weekday;
|
| 1925 |
+
using day = std::chrono::day;
|
| 1926 |
+
using month = std::chrono::month;
|
| 1927 |
+
using year = std::chrono::year;
|
| 1928 |
+
using year_month_day = std::chrono::year_month_day;
|
| 1929 |
+
#else
|
| 1930 |
+
// A fallback version of weekday.
|
| 1931 |
+
class weekday {
|
| 1932 |
+
private:
|
| 1933 |
+
unsigned char value_;
|
| 1934 |
+
|
| 1935 |
+
public:
|
| 1936 |
+
weekday() = default;
|
| 1937 |
+
constexpr explicit weekday(unsigned wd) noexcept
|
| 1938 |
+
: value_(static_cast<unsigned char>(wd != 7 ? wd : 0)) {}
|
| 1939 |
+
constexpr auto c_encoding() const noexcept -> unsigned { return value_; }
|
| 1940 |
+
};
|
| 1941 |
+
|
| 1942 |
+
class day {
|
| 1943 |
+
private:
|
| 1944 |
+
unsigned char value_;
|
| 1945 |
+
|
| 1946 |
+
public:
|
| 1947 |
+
day() = default;
|
| 1948 |
+
constexpr explicit day(unsigned d) noexcept
|
| 1949 |
+
: value_(static_cast<unsigned char>(d)) {}
|
| 1950 |
+
constexpr explicit operator unsigned() const noexcept { return value_; }
|
| 1951 |
+
};
|
| 1952 |
+
|
| 1953 |
+
class month {
|
| 1954 |
+
private:
|
| 1955 |
+
unsigned char value_;
|
| 1956 |
+
|
| 1957 |
+
public:
|
| 1958 |
+
month() = default;
|
| 1959 |
+
constexpr explicit month(unsigned m) noexcept
|
| 1960 |
+
: value_(static_cast<unsigned char>(m)) {}
|
| 1961 |
+
constexpr explicit operator unsigned() const noexcept { return value_; }
|
| 1962 |
+
};
|
| 1963 |
+
|
| 1964 |
+
class year {
|
| 1965 |
+
private:
|
| 1966 |
+
int value_;
|
| 1967 |
+
|
| 1968 |
+
public:
|
| 1969 |
+
year() = default;
|
| 1970 |
+
constexpr explicit year(int y) noexcept : value_(y) {}
|
| 1971 |
+
constexpr explicit operator int() const noexcept { return value_; }
|
| 1972 |
+
};
|
| 1973 |
+
|
| 1974 |
+
class year_month_day {
|
| 1975 |
+
private:
|
| 1976 |
+
fmt::year year_;
|
| 1977 |
+
fmt::month month_;
|
| 1978 |
+
fmt::day day_;
|
| 1979 |
+
|
| 1980 |
+
public:
|
| 1981 |
+
year_month_day() = default;
|
| 1982 |
+
constexpr year_month_day(const year& y, const month& m, const day& d) noexcept
|
| 1983 |
+
: year_(y), month_(m), day_(d) {}
|
| 1984 |
+
constexpr auto year() const noexcept -> fmt::year { return year_; }
|
| 1985 |
+
constexpr auto month() const noexcept -> fmt::month { return month_; }
|
| 1986 |
+
constexpr auto day() const noexcept -> fmt::day { return day_; }
|
| 1987 |
+
};
|
| 1988 |
+
#endif // __cpp_lib_chrono >= 201907
|
| 1989 |
+
|
| 1990 |
+
template <typename Char>
|
| 1991 |
+
struct formatter<weekday, Char> : private formatter<std::tm, Char> {
|
| 1992 |
+
private:
|
| 1993 |
+
bool use_tm_formatter_ = false;
|
| 1994 |
+
|
| 1995 |
+
public:
|
| 1996 |
+
FMT_CONSTEXPR auto parse(parse_context<Char>& ctx) -> const Char* {
|
| 1997 |
+
auto it = ctx.begin(), end = ctx.end();
|
| 1998 |
+
if (it != end && *it == 'L') {
|
| 1999 |
+
++it;
|
| 2000 |
+
this->set_localized();
|
| 2001 |
+
}
|
| 2002 |
+
use_tm_formatter_ = it != end && *it != '}';
|
| 2003 |
+
return use_tm_formatter_ ? formatter<std::tm, Char>::parse(ctx) : it;
|
| 2004 |
+
}
|
| 2005 |
+
|
| 2006 |
+
template <typename FormatContext>
|
| 2007 |
+
auto format(weekday wd, FormatContext& ctx) const -> decltype(ctx.out()) {
|
| 2008 |
+
auto time = std::tm();
|
| 2009 |
+
time.tm_wday = static_cast<int>(wd.c_encoding());
|
| 2010 |
+
if (use_tm_formatter_) return formatter<std::tm, Char>::format(time, ctx);
|
| 2011 |
+
detail::get_locale loc(this->localized(), ctx.locale());
|
| 2012 |
+
auto w = detail::tm_writer<decltype(ctx.out()), Char>(loc, ctx.out(), time);
|
| 2013 |
+
w.on_abbr_weekday();
|
| 2014 |
+
return w.out();
|
| 2015 |
+
}
|
| 2016 |
+
};
|
| 2017 |
+
|
| 2018 |
+
template <typename Char>
|
| 2019 |
+
struct formatter<day, Char> : private formatter<std::tm, Char> {
|
| 2020 |
+
private:
|
| 2021 |
+
bool use_tm_formatter_ = false;
|
| 2022 |
+
|
| 2023 |
+
public:
|
| 2024 |
+
FMT_CONSTEXPR auto parse(parse_context<Char>& ctx) -> const Char* {
|
| 2025 |
+
auto it = ctx.begin(), end = ctx.end();
|
| 2026 |
+
use_tm_formatter_ = it != end && *it != '}';
|
| 2027 |
+
return use_tm_formatter_ ? formatter<std::tm, Char>::parse(ctx) : it;
|
| 2028 |
+
}
|
| 2029 |
+
|
| 2030 |
+
template <typename FormatContext>
|
| 2031 |
+
auto format(day d, FormatContext& ctx) const -> decltype(ctx.out()) {
|
| 2032 |
+
auto time = std::tm();
|
| 2033 |
+
time.tm_mday = static_cast<int>(static_cast<unsigned>(d));
|
| 2034 |
+
if (use_tm_formatter_) return formatter<std::tm, Char>::format(time, ctx);
|
| 2035 |
+
detail::get_locale loc(false, ctx.locale());
|
| 2036 |
+
auto w = detail::tm_writer<decltype(ctx.out()), Char>(loc, ctx.out(), time);
|
| 2037 |
+
w.on_day_of_month(detail::numeric_system::standard, detail::pad_type::zero);
|
| 2038 |
+
return w.out();
|
| 2039 |
+
}
|
| 2040 |
+
};
|
| 2041 |
+
|
| 2042 |
+
template <typename Char>
|
| 2043 |
+
struct formatter<month, Char> : private formatter<std::tm, Char> {
|
| 2044 |
+
private:
|
| 2045 |
+
bool use_tm_formatter_ = false;
|
| 2046 |
+
|
| 2047 |
+
public:
|
| 2048 |
+
FMT_CONSTEXPR auto parse(parse_context<Char>& ctx) -> const Char* {
|
| 2049 |
+
auto it = ctx.begin(), end = ctx.end();
|
| 2050 |
+
if (it != end && *it == 'L') {
|
| 2051 |
+
++it;
|
| 2052 |
+
this->set_localized();
|
| 2053 |
+
}
|
| 2054 |
+
use_tm_formatter_ = it != end && *it != '}';
|
| 2055 |
+
return use_tm_formatter_ ? formatter<std::tm, Char>::parse(ctx) : it;
|
| 2056 |
+
}
|
| 2057 |
+
|
| 2058 |
+
template <typename FormatContext>
|
| 2059 |
+
auto format(month m, FormatContext& ctx) const -> decltype(ctx.out()) {
|
| 2060 |
+
auto time = std::tm();
|
| 2061 |
+
time.tm_mon = static_cast<int>(static_cast<unsigned>(m)) - 1;
|
| 2062 |
+
if (use_tm_formatter_) return formatter<std::tm, Char>::format(time, ctx);
|
| 2063 |
+
detail::get_locale loc(this->localized(), ctx.locale());
|
| 2064 |
+
auto w = detail::tm_writer<decltype(ctx.out()), Char>(loc, ctx.out(), time);
|
| 2065 |
+
w.on_abbr_month();
|
| 2066 |
+
return w.out();
|
| 2067 |
+
}
|
| 2068 |
+
};
|
| 2069 |
+
|
| 2070 |
+
template <typename Char>
|
| 2071 |
+
struct formatter<year, Char> : private formatter<std::tm, Char> {
|
| 2072 |
+
private:
|
| 2073 |
+
bool use_tm_formatter_ = false;
|
| 2074 |
+
|
| 2075 |
+
public:
|
| 2076 |
+
FMT_CONSTEXPR auto parse(parse_context<Char>& ctx) -> const Char* {
|
| 2077 |
+
auto it = ctx.begin(), end = ctx.end();
|
| 2078 |
+
use_tm_formatter_ = it != end && *it != '}';
|
| 2079 |
+
return use_tm_formatter_ ? formatter<std::tm, Char>::parse(ctx) : it;
|
| 2080 |
+
}
|
| 2081 |
+
|
| 2082 |
+
template <typename FormatContext>
|
| 2083 |
+
auto format(year y, FormatContext& ctx) const -> decltype(ctx.out()) {
|
| 2084 |
+
auto time = std::tm();
|
| 2085 |
+
time.tm_year = static_cast<int>(y) - 1900;
|
| 2086 |
+
if (use_tm_formatter_) return formatter<std::tm, Char>::format(time, ctx);
|
| 2087 |
+
detail::get_locale loc(false, ctx.locale());
|
| 2088 |
+
auto w = detail::tm_writer<decltype(ctx.out()), Char>(loc, ctx.out(), time);
|
| 2089 |
+
w.on_year(detail::numeric_system::standard, detail::pad_type::zero);
|
| 2090 |
+
return w.out();
|
| 2091 |
+
}
|
| 2092 |
+
};
|
| 2093 |
+
|
| 2094 |
+
template <typename Char>
|
| 2095 |
+
struct formatter<year_month_day, Char> : private formatter<std::tm, Char> {
|
| 2096 |
+
private:
|
| 2097 |
+
bool use_tm_formatter_ = false;
|
| 2098 |
+
|
| 2099 |
+
public:
|
| 2100 |
+
FMT_CONSTEXPR auto parse(parse_context<Char>& ctx) -> const Char* {
|
| 2101 |
+
auto it = ctx.begin(), end = ctx.end();
|
| 2102 |
+
use_tm_formatter_ = it != end && *it != '}';
|
| 2103 |
+
return use_tm_formatter_ ? formatter<std::tm, Char>::parse(ctx) : it;
|
| 2104 |
+
}
|
| 2105 |
+
|
| 2106 |
+
template <typename FormatContext>
|
| 2107 |
+
auto format(year_month_day val, FormatContext& ctx) const
|
| 2108 |
+
-> decltype(ctx.out()) {
|
| 2109 |
+
auto time = std::tm();
|
| 2110 |
+
time.tm_year = static_cast<int>(val.year()) - 1900;
|
| 2111 |
+
time.tm_mon = static_cast<int>(static_cast<unsigned>(val.month())) - 1;
|
| 2112 |
+
time.tm_mday = static_cast<int>(static_cast<unsigned>(val.day()));
|
| 2113 |
+
if (use_tm_formatter_) return formatter<std::tm, Char>::format(time, ctx);
|
| 2114 |
+
detail::get_locale loc(true, ctx.locale());
|
| 2115 |
+
auto w = detail::tm_writer<decltype(ctx.out()), Char>(loc, ctx.out(), time);
|
| 2116 |
+
w.on_iso_date();
|
| 2117 |
+
return w.out();
|
| 2118 |
+
}
|
| 2119 |
+
};
|
| 2120 |
+
|
| 2121 |
+
template <typename Rep, typename Period, typename Char>
|
| 2122 |
+
struct formatter<std::chrono::duration<Rep, Period>, Char> {
|
| 2123 |
+
private:
|
| 2124 |
+
format_specs specs_;
|
| 2125 |
+
detail::arg_ref<Char> width_ref_;
|
| 2126 |
+
detail::arg_ref<Char> precision_ref_;
|
| 2127 |
+
basic_string_view<Char> fmt_;
|
| 2128 |
+
|
| 2129 |
+
public:
|
| 2130 |
+
FMT_CONSTEXPR auto parse(parse_context<Char>& ctx) -> const Char* {
|
| 2131 |
+
auto it = ctx.begin(), end = ctx.end();
|
| 2132 |
+
if (it == end || *it == '}') return it;
|
| 2133 |
+
|
| 2134 |
+
it = detail::parse_align(it, end, specs_);
|
| 2135 |
+
if (it == end) return it;
|
| 2136 |
+
|
| 2137 |
+
Char c = *it;
|
| 2138 |
+
if ((c >= '0' && c <= '9') || c == '{') {
|
| 2139 |
+
it = detail::parse_width(it, end, specs_, width_ref_, ctx);
|
| 2140 |
+
if (it == end) return it;
|
| 2141 |
+
}
|
| 2142 |
+
|
| 2143 |
+
auto checker = detail::chrono_format_checker();
|
| 2144 |
+
if (*it == '.') {
|
| 2145 |
+
checker.has_precision_integral = !std::is_floating_point<Rep>::value;
|
| 2146 |
+
it = detail::parse_precision(it, end, specs_, precision_ref_, ctx);
|
| 2147 |
+
}
|
| 2148 |
+
if (it != end && *it == 'L') {
|
| 2149 |
+
specs_.set_localized();
|
| 2150 |
+
++it;
|
| 2151 |
+
}
|
| 2152 |
+
end = detail::parse_chrono_format(it, end, checker);
|
| 2153 |
+
fmt_ = {it, detail::to_unsigned(end - it)};
|
| 2154 |
+
return end;
|
| 2155 |
+
}
|
| 2156 |
+
|
| 2157 |
+
template <typename FormatContext>
|
| 2158 |
+
auto format(std::chrono::duration<Rep, Period> d, FormatContext& ctx) const
|
| 2159 |
+
-> decltype(ctx.out()) {
|
| 2160 |
+
auto specs = specs_;
|
| 2161 |
+
auto precision = specs.precision;
|
| 2162 |
+
specs.precision = -1;
|
| 2163 |
+
auto begin = fmt_.begin(), end = fmt_.end();
|
| 2164 |
+
// As a possible future optimization, we could avoid extra copying if width
|
| 2165 |
+
// is not specified.
|
| 2166 |
+
auto buf = basic_memory_buffer<Char>();
|
| 2167 |
+
auto out = basic_appender<Char>(buf);
|
| 2168 |
+
detail::handle_dynamic_spec(specs.dynamic_width(), specs.width, width_ref_,
|
| 2169 |
+
ctx);
|
| 2170 |
+
detail::handle_dynamic_spec(specs.dynamic_precision(), precision,
|
| 2171 |
+
precision_ref_, ctx);
|
| 2172 |
+
if (begin == end || *begin == '}') {
|
| 2173 |
+
out = detail::format_duration_value<Char>(out, d.count(), precision);
|
| 2174 |
+
detail::format_duration_unit<Char, Period>(out);
|
| 2175 |
+
} else {
|
| 2176 |
+
auto f =
|
| 2177 |
+
detail::duration_formatter<Char, Rep, Period>(out, d, ctx.locale());
|
| 2178 |
+
f.precision = precision;
|
| 2179 |
+
f.localized = specs_.localized();
|
| 2180 |
+
detail::parse_chrono_format(begin, end, f);
|
| 2181 |
+
}
|
| 2182 |
+
return detail::write(
|
| 2183 |
+
ctx.out(), basic_string_view<Char>(buf.data(), buf.size()), specs);
|
| 2184 |
+
}
|
| 2185 |
+
};
|
| 2186 |
+
|
| 2187 |
+
template <typename Char> struct formatter<std::tm, Char> {
|
| 2188 |
+
private:
|
| 2189 |
+
format_specs specs_;
|
| 2190 |
+
detail::arg_ref<Char> width_ref_;
|
| 2191 |
+
basic_string_view<Char> fmt_ =
|
| 2192 |
+
detail::string_literal<Char, '%', 'F', ' ', '%', 'T'>();
|
| 2193 |
+
|
| 2194 |
+
protected:
|
| 2195 |
+
auto localized() const -> bool { return specs_.localized(); }
|
| 2196 |
+
FMT_CONSTEXPR void set_localized() { specs_.set_localized(); }
|
| 2197 |
+
|
| 2198 |
+
FMT_CONSTEXPR auto do_parse(parse_context<Char>& ctx, bool has_timezone)
|
| 2199 |
+
-> const Char* {
|
| 2200 |
+
auto it = ctx.begin(), end = ctx.end();
|
| 2201 |
+
if (it == end || *it == '}') return it;
|
| 2202 |
+
|
| 2203 |
+
it = detail::parse_align(it, end, specs_);
|
| 2204 |
+
if (it == end) return it;
|
| 2205 |
+
|
| 2206 |
+
Char c = *it;
|
| 2207 |
+
if ((c >= '0' && c <= '9') || c == '{') {
|
| 2208 |
+
it = detail::parse_width(it, end, specs_, width_ref_, ctx);
|
| 2209 |
+
if (it == end) return it;
|
| 2210 |
+
}
|
| 2211 |
+
|
| 2212 |
+
if (*it == 'L') {
|
| 2213 |
+
specs_.set_localized();
|
| 2214 |
+
++it;
|
| 2215 |
+
}
|
| 2216 |
+
|
| 2217 |
+
end = detail::parse_chrono_format(it, end,
|
| 2218 |
+
detail::tm_format_checker(has_timezone));
|
| 2219 |
+
// Replace the default format string only if the new spec is not empty.
|
| 2220 |
+
if (end != it) fmt_ = {it, detail::to_unsigned(end - it)};
|
| 2221 |
+
return end;
|
| 2222 |
+
}
|
| 2223 |
+
|
| 2224 |
+
template <typename Duration, typename FormatContext>
|
| 2225 |
+
auto do_format(const std::tm& tm, FormatContext& ctx,
|
| 2226 |
+
const Duration* subsecs) const -> decltype(ctx.out()) {
|
| 2227 |
+
auto specs = specs_;
|
| 2228 |
+
auto buf = basic_memory_buffer<Char>();
|
| 2229 |
+
auto out = basic_appender<Char>(buf);
|
| 2230 |
+
detail::handle_dynamic_spec(specs.dynamic_width(), specs.width, width_ref_,
|
| 2231 |
+
ctx);
|
| 2232 |
+
|
| 2233 |
+
auto loc_ref = specs.localized() ? ctx.locale() : detail::locale_ref();
|
| 2234 |
+
detail::get_locale loc(static_cast<bool>(loc_ref), loc_ref);
|
| 2235 |
+
auto w = detail::tm_writer<basic_appender<Char>, Char, Duration>(
|
| 2236 |
+
loc, out, tm, subsecs);
|
| 2237 |
+
detail::parse_chrono_format(fmt_.begin(), fmt_.end(), w);
|
| 2238 |
+
return detail::write(
|
| 2239 |
+
ctx.out(), basic_string_view<Char>(buf.data(), buf.size()), specs);
|
| 2240 |
+
}
|
| 2241 |
+
|
| 2242 |
+
public:
|
| 2243 |
+
FMT_CONSTEXPR auto parse(parse_context<Char>& ctx) -> const Char* {
|
| 2244 |
+
return do_parse(ctx, detail::has_tm_gmtoff<std::tm>::value);
|
| 2245 |
+
}
|
| 2246 |
+
|
| 2247 |
+
template <typename FormatContext>
|
| 2248 |
+
auto format(const std::tm& tm, FormatContext& ctx) const
|
| 2249 |
+
-> decltype(ctx.out()) {
|
| 2250 |
+
return do_format<std::chrono::seconds>(tm, ctx, nullptr);
|
| 2251 |
+
}
|
| 2252 |
+
};
|
| 2253 |
+
|
| 2254 |
+
// DEPRECATED! Reversed order of template parameters.
|
| 2255 |
+
template <typename Char, typename Duration>
|
| 2256 |
+
struct formatter<sys_time<Duration>, Char> : private formatter<std::tm, Char> {
|
| 2257 |
+
FMT_CONSTEXPR auto parse(parse_context<Char>& ctx) -> const Char* {
|
| 2258 |
+
return this->do_parse(ctx, true);
|
| 2259 |
+
}
|
| 2260 |
+
|
| 2261 |
+
template <typename FormatContext>
|
| 2262 |
+
auto format(sys_time<Duration> val, FormatContext& ctx) const
|
| 2263 |
+
-> decltype(ctx.out()) {
|
| 2264 |
+
std::tm tm = gmtime(val);
|
| 2265 |
+
using period = typename Duration::period;
|
| 2266 |
+
if (detail::const_check(
|
| 2267 |
+
period::num == 1 && period::den == 1 &&
|
| 2268 |
+
!std::is_floating_point<typename Duration::rep>::value)) {
|
| 2269 |
+
detail::set_tm_zone(tm, detail::utc());
|
| 2270 |
+
return formatter<std::tm, Char>::format(tm, ctx);
|
| 2271 |
+
}
|
| 2272 |
+
Duration epoch = val.time_since_epoch();
|
| 2273 |
+
Duration subsecs = detail::duration_cast<Duration>(
|
| 2274 |
+
epoch - detail::duration_cast<std::chrono::seconds>(epoch));
|
| 2275 |
+
if (subsecs.count() < 0) {
|
| 2276 |
+
auto second = detail::duration_cast<Duration>(std::chrono::seconds(1));
|
| 2277 |
+
if (tm.tm_sec != 0) {
|
| 2278 |
+
--tm.tm_sec;
|
| 2279 |
+
} else {
|
| 2280 |
+
tm = gmtime(val - second);
|
| 2281 |
+
detail::set_tm_zone(tm, detail::utc());
|
| 2282 |
+
}
|
| 2283 |
+
subsecs += second;
|
| 2284 |
+
}
|
| 2285 |
+
return formatter<std::tm, Char>::do_format(tm, ctx, &subsecs);
|
| 2286 |
+
}
|
| 2287 |
+
};
|
| 2288 |
+
|
| 2289 |
+
template <typename Duration, typename Char>
|
| 2290 |
+
struct formatter<utc_time<Duration>, Char>
|
| 2291 |
+
: formatter<sys_time<Duration>, Char> {
|
| 2292 |
+
template <typename FormatContext>
|
| 2293 |
+
auto format(utc_time<Duration> val, FormatContext& ctx) const
|
| 2294 |
+
-> decltype(ctx.out()) {
|
| 2295 |
+
return formatter<sys_time<Duration>, Char>::format(
|
| 2296 |
+
detail::utc_clock::to_sys(val), ctx);
|
| 2297 |
+
}
|
| 2298 |
+
};
|
| 2299 |
+
|
| 2300 |
+
template <typename Duration, typename Char>
|
| 2301 |
+
struct formatter<local_time<Duration>, Char>
|
| 2302 |
+
: private formatter<std::tm, Char> {
|
| 2303 |
+
FMT_CONSTEXPR auto parse(parse_context<Char>& ctx) -> const Char* {
|
| 2304 |
+
return this->do_parse(ctx, false);
|
| 2305 |
+
}
|
| 2306 |
+
|
| 2307 |
+
template <typename FormatContext>
|
| 2308 |
+
auto format(local_time<Duration> val, FormatContext& ctx) const
|
| 2309 |
+
-> decltype(ctx.out()) {
|
| 2310 |
+
auto time_since_epoch = val.time_since_epoch();
|
| 2311 |
+
auto seconds_since_epoch =
|
| 2312 |
+
detail::duration_cast<std::chrono::seconds>(time_since_epoch);
|
| 2313 |
+
// Use gmtime to prevent time zone conversion since local_time has an
|
| 2314 |
+
// unspecified time zone.
|
| 2315 |
+
std::tm t = gmtime(seconds_since_epoch.count());
|
| 2316 |
+
using period = typename Duration::period;
|
| 2317 |
+
if (period::num == 1 && period::den == 1 &&
|
| 2318 |
+
!std::is_floating_point<typename Duration::rep>::value) {
|
| 2319 |
+
return formatter<std::tm, Char>::format(t, ctx);
|
| 2320 |
+
}
|
| 2321 |
+
auto subsecs =
|
| 2322 |
+
detail::duration_cast<Duration>(time_since_epoch - seconds_since_epoch);
|
| 2323 |
+
return formatter<std::tm, Char>::do_format(t, ctx, &subsecs);
|
| 2324 |
+
}
|
| 2325 |
+
};
|
| 2326 |
+
|
| 2327 |
+
FMT_END_EXPORT
|
| 2328 |
+
FMT_END_NAMESPACE
|
| 2329 |
+
|
| 2330 |
+
#endif // FMT_CHRONO_H_
|
miniconda3/pkgs/fmt-11.2.0-hca5f364_0/include/fmt/color.h
ADDED
|
@@ -0,0 +1,637 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// Formatting library for C++ - color support
|
| 2 |
+
//
|
| 3 |
+
// Copyright (c) 2018 - present, Victor Zverovich and fmt contributors
|
| 4 |
+
// All rights reserved.
|
| 5 |
+
//
|
| 6 |
+
// For the license information refer to format.h.
|
| 7 |
+
|
| 8 |
+
#ifndef FMT_COLOR_H_
|
| 9 |
+
#define FMT_COLOR_H_
|
| 10 |
+
|
| 11 |
+
#include "format.h"
|
| 12 |
+
|
| 13 |
+
FMT_BEGIN_NAMESPACE
|
| 14 |
+
FMT_BEGIN_EXPORT
|
| 15 |
+
|
| 16 |
+
enum class color : uint32_t {
|
| 17 |
+
alice_blue = 0xF0F8FF, // rgb(240,248,255)
|
| 18 |
+
antique_white = 0xFAEBD7, // rgb(250,235,215)
|
| 19 |
+
aqua = 0x00FFFF, // rgb(0,255,255)
|
| 20 |
+
aquamarine = 0x7FFFD4, // rgb(127,255,212)
|
| 21 |
+
azure = 0xF0FFFF, // rgb(240,255,255)
|
| 22 |
+
beige = 0xF5F5DC, // rgb(245,245,220)
|
| 23 |
+
bisque = 0xFFE4C4, // rgb(255,228,196)
|
| 24 |
+
black = 0x000000, // rgb(0,0,0)
|
| 25 |
+
blanched_almond = 0xFFEBCD, // rgb(255,235,205)
|
| 26 |
+
blue = 0x0000FF, // rgb(0,0,255)
|
| 27 |
+
blue_violet = 0x8A2BE2, // rgb(138,43,226)
|
| 28 |
+
brown = 0xA52A2A, // rgb(165,42,42)
|
| 29 |
+
burly_wood = 0xDEB887, // rgb(222,184,135)
|
| 30 |
+
cadet_blue = 0x5F9EA0, // rgb(95,158,160)
|
| 31 |
+
chartreuse = 0x7FFF00, // rgb(127,255,0)
|
| 32 |
+
chocolate = 0xD2691E, // rgb(210,105,30)
|
| 33 |
+
coral = 0xFF7F50, // rgb(255,127,80)
|
| 34 |
+
cornflower_blue = 0x6495ED, // rgb(100,149,237)
|
| 35 |
+
cornsilk = 0xFFF8DC, // rgb(255,248,220)
|
| 36 |
+
crimson = 0xDC143C, // rgb(220,20,60)
|
| 37 |
+
cyan = 0x00FFFF, // rgb(0,255,255)
|
| 38 |
+
dark_blue = 0x00008B, // rgb(0,0,139)
|
| 39 |
+
dark_cyan = 0x008B8B, // rgb(0,139,139)
|
| 40 |
+
dark_golden_rod = 0xB8860B, // rgb(184,134,11)
|
| 41 |
+
dark_gray = 0xA9A9A9, // rgb(169,169,169)
|
| 42 |
+
dark_green = 0x006400, // rgb(0,100,0)
|
| 43 |
+
dark_khaki = 0xBDB76B, // rgb(189,183,107)
|
| 44 |
+
dark_magenta = 0x8B008B, // rgb(139,0,139)
|
| 45 |
+
dark_olive_green = 0x556B2F, // rgb(85,107,47)
|
| 46 |
+
dark_orange = 0xFF8C00, // rgb(255,140,0)
|
| 47 |
+
dark_orchid = 0x9932CC, // rgb(153,50,204)
|
| 48 |
+
dark_red = 0x8B0000, // rgb(139,0,0)
|
| 49 |
+
dark_salmon = 0xE9967A, // rgb(233,150,122)
|
| 50 |
+
dark_sea_green = 0x8FBC8F, // rgb(143,188,143)
|
| 51 |
+
dark_slate_blue = 0x483D8B, // rgb(72,61,139)
|
| 52 |
+
dark_slate_gray = 0x2F4F4F, // rgb(47,79,79)
|
| 53 |
+
dark_turquoise = 0x00CED1, // rgb(0,206,209)
|
| 54 |
+
dark_violet = 0x9400D3, // rgb(148,0,211)
|
| 55 |
+
deep_pink = 0xFF1493, // rgb(255,20,147)
|
| 56 |
+
deep_sky_blue = 0x00BFFF, // rgb(0,191,255)
|
| 57 |
+
dim_gray = 0x696969, // rgb(105,105,105)
|
| 58 |
+
dodger_blue = 0x1E90FF, // rgb(30,144,255)
|
| 59 |
+
fire_brick = 0xB22222, // rgb(178,34,34)
|
| 60 |
+
floral_white = 0xFFFAF0, // rgb(255,250,240)
|
| 61 |
+
forest_green = 0x228B22, // rgb(34,139,34)
|
| 62 |
+
fuchsia = 0xFF00FF, // rgb(255,0,255)
|
| 63 |
+
gainsboro = 0xDCDCDC, // rgb(220,220,220)
|
| 64 |
+
ghost_white = 0xF8F8FF, // rgb(248,248,255)
|
| 65 |
+
gold = 0xFFD700, // rgb(255,215,0)
|
| 66 |
+
golden_rod = 0xDAA520, // rgb(218,165,32)
|
| 67 |
+
gray = 0x808080, // rgb(128,128,128)
|
| 68 |
+
green = 0x008000, // rgb(0,128,0)
|
| 69 |
+
green_yellow = 0xADFF2F, // rgb(173,255,47)
|
| 70 |
+
honey_dew = 0xF0FFF0, // rgb(240,255,240)
|
| 71 |
+
hot_pink = 0xFF69B4, // rgb(255,105,180)
|
| 72 |
+
indian_red = 0xCD5C5C, // rgb(205,92,92)
|
| 73 |
+
indigo = 0x4B0082, // rgb(75,0,130)
|
| 74 |
+
ivory = 0xFFFFF0, // rgb(255,255,240)
|
| 75 |
+
khaki = 0xF0E68C, // rgb(240,230,140)
|
| 76 |
+
lavender = 0xE6E6FA, // rgb(230,230,250)
|
| 77 |
+
lavender_blush = 0xFFF0F5, // rgb(255,240,245)
|
| 78 |
+
lawn_green = 0x7CFC00, // rgb(124,252,0)
|
| 79 |
+
lemon_chiffon = 0xFFFACD, // rgb(255,250,205)
|
| 80 |
+
light_blue = 0xADD8E6, // rgb(173,216,230)
|
| 81 |
+
light_coral = 0xF08080, // rgb(240,128,128)
|
| 82 |
+
light_cyan = 0xE0FFFF, // rgb(224,255,255)
|
| 83 |
+
light_golden_rod_yellow = 0xFAFAD2, // rgb(250,250,210)
|
| 84 |
+
light_gray = 0xD3D3D3, // rgb(211,211,211)
|
| 85 |
+
light_green = 0x90EE90, // rgb(144,238,144)
|
| 86 |
+
light_pink = 0xFFB6C1, // rgb(255,182,193)
|
| 87 |
+
light_salmon = 0xFFA07A, // rgb(255,160,122)
|
| 88 |
+
light_sea_green = 0x20B2AA, // rgb(32,178,170)
|
| 89 |
+
light_sky_blue = 0x87CEFA, // rgb(135,206,250)
|
| 90 |
+
light_slate_gray = 0x778899, // rgb(119,136,153)
|
| 91 |
+
light_steel_blue = 0xB0C4DE, // rgb(176,196,222)
|
| 92 |
+
light_yellow = 0xFFFFE0, // rgb(255,255,224)
|
| 93 |
+
lime = 0x00FF00, // rgb(0,255,0)
|
| 94 |
+
lime_green = 0x32CD32, // rgb(50,205,50)
|
| 95 |
+
linen = 0xFAF0E6, // rgb(250,240,230)
|
| 96 |
+
magenta = 0xFF00FF, // rgb(255,0,255)
|
| 97 |
+
maroon = 0x800000, // rgb(128,0,0)
|
| 98 |
+
medium_aquamarine = 0x66CDAA, // rgb(102,205,170)
|
| 99 |
+
medium_blue = 0x0000CD, // rgb(0,0,205)
|
| 100 |
+
medium_orchid = 0xBA55D3, // rgb(186,85,211)
|
| 101 |
+
medium_purple = 0x9370DB, // rgb(147,112,219)
|
| 102 |
+
medium_sea_green = 0x3CB371, // rgb(60,179,113)
|
| 103 |
+
medium_slate_blue = 0x7B68EE, // rgb(123,104,238)
|
| 104 |
+
medium_spring_green = 0x00FA9A, // rgb(0,250,154)
|
| 105 |
+
medium_turquoise = 0x48D1CC, // rgb(72,209,204)
|
| 106 |
+
medium_violet_red = 0xC71585, // rgb(199,21,133)
|
| 107 |
+
midnight_blue = 0x191970, // rgb(25,25,112)
|
| 108 |
+
mint_cream = 0xF5FFFA, // rgb(245,255,250)
|
| 109 |
+
misty_rose = 0xFFE4E1, // rgb(255,228,225)
|
| 110 |
+
moccasin = 0xFFE4B5, // rgb(255,228,181)
|
| 111 |
+
navajo_white = 0xFFDEAD, // rgb(255,222,173)
|
| 112 |
+
navy = 0x000080, // rgb(0,0,128)
|
| 113 |
+
old_lace = 0xFDF5E6, // rgb(253,245,230)
|
| 114 |
+
olive = 0x808000, // rgb(128,128,0)
|
| 115 |
+
olive_drab = 0x6B8E23, // rgb(107,142,35)
|
| 116 |
+
orange = 0xFFA500, // rgb(255,165,0)
|
| 117 |
+
orange_red = 0xFF4500, // rgb(255,69,0)
|
| 118 |
+
orchid = 0xDA70D6, // rgb(218,112,214)
|
| 119 |
+
pale_golden_rod = 0xEEE8AA, // rgb(238,232,170)
|
| 120 |
+
pale_green = 0x98FB98, // rgb(152,251,152)
|
| 121 |
+
pale_turquoise = 0xAFEEEE, // rgb(175,238,238)
|
| 122 |
+
pale_violet_red = 0xDB7093, // rgb(219,112,147)
|
| 123 |
+
papaya_whip = 0xFFEFD5, // rgb(255,239,213)
|
| 124 |
+
peach_puff = 0xFFDAB9, // rgb(255,218,185)
|
| 125 |
+
peru = 0xCD853F, // rgb(205,133,63)
|
| 126 |
+
pink = 0xFFC0CB, // rgb(255,192,203)
|
| 127 |
+
plum = 0xDDA0DD, // rgb(221,160,221)
|
| 128 |
+
powder_blue = 0xB0E0E6, // rgb(176,224,230)
|
| 129 |
+
purple = 0x800080, // rgb(128,0,128)
|
| 130 |
+
rebecca_purple = 0x663399, // rgb(102,51,153)
|
| 131 |
+
red = 0xFF0000, // rgb(255,0,0)
|
| 132 |
+
rosy_brown = 0xBC8F8F, // rgb(188,143,143)
|
| 133 |
+
royal_blue = 0x4169E1, // rgb(65,105,225)
|
| 134 |
+
saddle_brown = 0x8B4513, // rgb(139,69,19)
|
| 135 |
+
salmon = 0xFA8072, // rgb(250,128,114)
|
| 136 |
+
sandy_brown = 0xF4A460, // rgb(244,164,96)
|
| 137 |
+
sea_green = 0x2E8B57, // rgb(46,139,87)
|
| 138 |
+
sea_shell = 0xFFF5EE, // rgb(255,245,238)
|
| 139 |
+
sienna = 0xA0522D, // rgb(160,82,45)
|
| 140 |
+
silver = 0xC0C0C0, // rgb(192,192,192)
|
| 141 |
+
sky_blue = 0x87CEEB, // rgb(135,206,235)
|
| 142 |
+
slate_blue = 0x6A5ACD, // rgb(106,90,205)
|
| 143 |
+
slate_gray = 0x708090, // rgb(112,128,144)
|
| 144 |
+
snow = 0xFFFAFA, // rgb(255,250,250)
|
| 145 |
+
spring_green = 0x00FF7F, // rgb(0,255,127)
|
| 146 |
+
steel_blue = 0x4682B4, // rgb(70,130,180)
|
| 147 |
+
tan = 0xD2B48C, // rgb(210,180,140)
|
| 148 |
+
teal = 0x008080, // rgb(0,128,128)
|
| 149 |
+
thistle = 0xD8BFD8, // rgb(216,191,216)
|
| 150 |
+
tomato = 0xFF6347, // rgb(255,99,71)
|
| 151 |
+
turquoise = 0x40E0D0, // rgb(64,224,208)
|
| 152 |
+
violet = 0xEE82EE, // rgb(238,130,238)
|
| 153 |
+
wheat = 0xF5DEB3, // rgb(245,222,179)
|
| 154 |
+
white = 0xFFFFFF, // rgb(255,255,255)
|
| 155 |
+
white_smoke = 0xF5F5F5, // rgb(245,245,245)
|
| 156 |
+
yellow = 0xFFFF00, // rgb(255,255,0)
|
| 157 |
+
yellow_green = 0x9ACD32 // rgb(154,205,50)
|
| 158 |
+
}; // enum class color
|
| 159 |
+
|
| 160 |
+
enum class terminal_color : uint8_t {
|
| 161 |
+
black = 30,
|
| 162 |
+
red,
|
| 163 |
+
green,
|
| 164 |
+
yellow,
|
| 165 |
+
blue,
|
| 166 |
+
magenta,
|
| 167 |
+
cyan,
|
| 168 |
+
white,
|
| 169 |
+
bright_black = 90,
|
| 170 |
+
bright_red,
|
| 171 |
+
bright_green,
|
| 172 |
+
bright_yellow,
|
| 173 |
+
bright_blue,
|
| 174 |
+
bright_magenta,
|
| 175 |
+
bright_cyan,
|
| 176 |
+
bright_white
|
| 177 |
+
};
|
| 178 |
+
|
| 179 |
+
enum class emphasis : uint8_t {
|
| 180 |
+
bold = 1,
|
| 181 |
+
faint = 1 << 1,
|
| 182 |
+
italic = 1 << 2,
|
| 183 |
+
underline = 1 << 3,
|
| 184 |
+
blink = 1 << 4,
|
| 185 |
+
reverse = 1 << 5,
|
| 186 |
+
conceal = 1 << 6,
|
| 187 |
+
strikethrough = 1 << 7,
|
| 188 |
+
};
|
| 189 |
+
|
| 190 |
+
// rgb is a struct for red, green and blue colors.
|
| 191 |
+
// Using the name "rgb" makes some editors show the color in a tooltip.
|
| 192 |
+
struct rgb {
|
| 193 |
+
constexpr rgb() : r(0), g(0), b(0) {}
|
| 194 |
+
constexpr rgb(uint8_t r_, uint8_t g_, uint8_t b_) : r(r_), g(g_), b(b_) {}
|
| 195 |
+
constexpr rgb(uint32_t hex)
|
| 196 |
+
: r((hex >> 16) & 0xFF), g((hex >> 8) & 0xFF), b(hex & 0xFF) {}
|
| 197 |
+
constexpr rgb(color hex)
|
| 198 |
+
: r((uint32_t(hex) >> 16) & 0xFF),
|
| 199 |
+
g((uint32_t(hex) >> 8) & 0xFF),
|
| 200 |
+
b(uint32_t(hex) & 0xFF) {}
|
| 201 |
+
uint8_t r;
|
| 202 |
+
uint8_t g;
|
| 203 |
+
uint8_t b;
|
| 204 |
+
};
|
| 205 |
+
|
| 206 |
+
namespace detail {
|
| 207 |
+
|
| 208 |
+
// A bit-packed variant of an RGB color, a terminal color, or unset color.
|
| 209 |
+
// see text_style for the bit-packing scheme.
|
| 210 |
+
struct color_type {
|
| 211 |
+
constexpr color_type() noexcept = default;
|
| 212 |
+
constexpr color_type(color rgb_color) noexcept
|
| 213 |
+
: value_(static_cast<uint32_t>(rgb_color) | (1 << 24)) {}
|
| 214 |
+
constexpr color_type(rgb rgb_color) noexcept
|
| 215 |
+
: color_type(static_cast<color>(
|
| 216 |
+
(static_cast<uint32_t>(rgb_color.r) << 16) |
|
| 217 |
+
(static_cast<uint32_t>(rgb_color.g) << 8) | rgb_color.b)) {}
|
| 218 |
+
constexpr color_type(terminal_color term_color) noexcept
|
| 219 |
+
: value_(static_cast<uint32_t>(term_color) | (3 << 24)) {}
|
| 220 |
+
|
| 221 |
+
constexpr auto is_terminal_color() const noexcept -> bool {
|
| 222 |
+
return (value_ & (1 << 25)) != 0;
|
| 223 |
+
}
|
| 224 |
+
|
| 225 |
+
constexpr auto value() const noexcept -> uint32_t {
|
| 226 |
+
return value_ & 0xFFFFFF;
|
| 227 |
+
}
|
| 228 |
+
|
| 229 |
+
constexpr color_type(uint32_t value) noexcept : value_(value) {}
|
| 230 |
+
|
| 231 |
+
uint32_t value_ = 0;
|
| 232 |
+
};
|
| 233 |
+
} // namespace detail
|
| 234 |
+
|
| 235 |
+
/// A text style consisting of foreground and background colors and emphasis.
|
| 236 |
+
class text_style {
|
| 237 |
+
// The information is packed as follows:
|
| 238 |
+
// ┌──┐
|
| 239 |
+
// │ 0│─┐
|
| 240 |
+
// │..│ ├── foreground color value
|
| 241 |
+
// │23│─┘
|
| 242 |
+
// ├──┤
|
| 243 |
+
// │24│─┬── discriminator for the above value. 00 if unset, 01 if it's
|
| 244 |
+
// │25│─┘ an RGB color, or 11 if it's a terminal color (10 is unused)
|
| 245 |
+
// ├──┤
|
| 246 |
+
// │26│──── overflow bit, always zero (see below)
|
| 247 |
+
// ├──┤
|
| 248 |
+
// │27│─┐
|
| 249 |
+
// │..│ │
|
| 250 |
+
// │50│ │
|
| 251 |
+
// ├──┤ │
|
| 252 |
+
// │51│ ├── background color (same format as the foreground color)
|
| 253 |
+
// │52│ │
|
| 254 |
+
// ├──┤ │
|
| 255 |
+
// │53│─┘
|
| 256 |
+
// ├──┤
|
| 257 |
+
// │54│─┐
|
| 258 |
+
// │..│ ├── emphases
|
| 259 |
+
// │61│─┘
|
| 260 |
+
// ├──┤
|
| 261 |
+
// │62│─┬── unused
|
| 262 |
+
// │63│─┘
|
| 263 |
+
// └──┘
|
| 264 |
+
// The overflow bits are there to make operator|= efficient.
|
| 265 |
+
// When ORing, we must throw if, for either the foreground or background,
|
| 266 |
+
// one style specifies a terminal color and the other specifies any color
|
| 267 |
+
// (terminal or RGB); in other words, if one discriminator is 11 and the
|
| 268 |
+
// other is 11 or 01.
|
| 269 |
+
//
|
| 270 |
+
// We do that check by adding the styles. Consider what adding does to each
|
| 271 |
+
// possible pair of discriminators:
|
| 272 |
+
// 00 + 00 = 000
|
| 273 |
+
// 01 + 00 = 001
|
| 274 |
+
// 11 + 00 = 011
|
| 275 |
+
// 01 + 01 = 010
|
| 276 |
+
// 11 + 01 = 100 (!!)
|
| 277 |
+
// 11 + 11 = 110 (!!)
|
| 278 |
+
// In the last two cases, the ones we want to catch, the third bit——the
|
| 279 |
+
// overflow bit——is set. Bingo.
|
| 280 |
+
//
|
| 281 |
+
// We must take into account the possible carry bit from the bits
|
| 282 |
+
// before the discriminator. The only potentially problematic case is
|
| 283 |
+
// 11 + 00 = 011 (a carry bit would make it 100, not good!), but a carry
|
| 284 |
+
// bit is impossible in that case, because 00 (unset color) means the
|
| 285 |
+
// 24 bits that precede the discriminator are all zero.
|
| 286 |
+
//
|
| 287 |
+
// This test can be applied to both colors simultaneously.
|
| 288 |
+
|
| 289 |
+
public:
|
| 290 |
+
FMT_CONSTEXPR text_style(emphasis em = emphasis()) noexcept
|
| 291 |
+
: style_(static_cast<uint64_t>(em) << 54) {}
|
| 292 |
+
|
| 293 |
+
FMT_CONSTEXPR auto operator|=(text_style rhs) -> text_style& {
|
| 294 |
+
if (((style_ + rhs.style_) & ((1ULL << 26) | (1ULL << 53))) != 0)
|
| 295 |
+
report_error("can't OR a terminal color");
|
| 296 |
+
style_ |= rhs.style_;
|
| 297 |
+
return *this;
|
| 298 |
+
}
|
| 299 |
+
|
| 300 |
+
friend FMT_CONSTEXPR auto operator|(text_style lhs, text_style rhs)
|
| 301 |
+
-> text_style {
|
| 302 |
+
return lhs |= rhs;
|
| 303 |
+
}
|
| 304 |
+
|
| 305 |
+
FMT_CONSTEXPR auto operator==(text_style rhs) const noexcept -> bool {
|
| 306 |
+
return style_ == rhs.style_;
|
| 307 |
+
}
|
| 308 |
+
|
| 309 |
+
FMT_CONSTEXPR auto operator!=(text_style rhs) const noexcept -> bool {
|
| 310 |
+
return !(*this == rhs);
|
| 311 |
+
}
|
| 312 |
+
|
| 313 |
+
FMT_CONSTEXPR auto has_foreground() const noexcept -> bool {
|
| 314 |
+
return (style_ & (1 << 24)) != 0;
|
| 315 |
+
}
|
| 316 |
+
FMT_CONSTEXPR auto has_background() const noexcept -> bool {
|
| 317 |
+
return (style_ & (1ULL << 51)) != 0;
|
| 318 |
+
}
|
| 319 |
+
FMT_CONSTEXPR auto has_emphasis() const noexcept -> bool {
|
| 320 |
+
return (style_ >> 54) != 0;
|
| 321 |
+
}
|
| 322 |
+
FMT_CONSTEXPR auto get_foreground() const noexcept -> detail::color_type {
|
| 323 |
+
FMT_ASSERT(has_foreground(), "no foreground specified for this style");
|
| 324 |
+
return style_ & 0x3FFFFFF;
|
| 325 |
+
}
|
| 326 |
+
FMT_CONSTEXPR auto get_background() const noexcept -> detail::color_type {
|
| 327 |
+
FMT_ASSERT(has_background(), "no background specified for this style");
|
| 328 |
+
return (style_ >> 27) & 0x3FFFFFF;
|
| 329 |
+
}
|
| 330 |
+
FMT_CONSTEXPR auto get_emphasis() const noexcept -> emphasis {
|
| 331 |
+
FMT_ASSERT(has_emphasis(), "no emphasis specified for this style");
|
| 332 |
+
return static_cast<emphasis>(style_ >> 54);
|
| 333 |
+
}
|
| 334 |
+
|
| 335 |
+
private:
|
| 336 |
+
FMT_CONSTEXPR text_style(uint64_t style) noexcept : style_(style) {}
|
| 337 |
+
|
| 338 |
+
friend FMT_CONSTEXPR auto fg(detail::color_type foreground) noexcept
|
| 339 |
+
-> text_style;
|
| 340 |
+
|
| 341 |
+
friend FMT_CONSTEXPR auto bg(detail::color_type background) noexcept
|
| 342 |
+
-> text_style;
|
| 343 |
+
|
| 344 |
+
uint64_t style_ = 0;
|
| 345 |
+
};
|
| 346 |
+
|
| 347 |
+
/// Creates a text style from the foreground (text) color.
|
| 348 |
+
FMT_CONSTEXPR inline auto fg(detail::color_type foreground) noexcept
|
| 349 |
+
-> text_style {
|
| 350 |
+
return foreground.value_;
|
| 351 |
+
}
|
| 352 |
+
|
| 353 |
+
/// Creates a text style from the background color.
|
| 354 |
+
FMT_CONSTEXPR inline auto bg(detail::color_type background) noexcept
|
| 355 |
+
-> text_style {
|
| 356 |
+
return static_cast<uint64_t>(background.value_) << 27;
|
| 357 |
+
}
|
| 358 |
+
|
| 359 |
+
FMT_CONSTEXPR inline auto operator|(emphasis lhs, emphasis rhs) noexcept
|
| 360 |
+
-> text_style {
|
| 361 |
+
return text_style(lhs) | rhs;
|
| 362 |
+
}
|
| 363 |
+
|
| 364 |
+
namespace detail {
|
| 365 |
+
|
| 366 |
+
template <typename Char> struct ansi_color_escape {
|
| 367 |
+
FMT_CONSTEXPR ansi_color_escape(color_type text_color,
|
| 368 |
+
const char* esc) noexcept {
|
| 369 |
+
// If we have a terminal color, we need to output another escape code
|
| 370 |
+
// sequence.
|
| 371 |
+
if (text_color.is_terminal_color()) {
|
| 372 |
+
bool is_background = esc == string_view("\x1b[48;2;");
|
| 373 |
+
uint32_t value = text_color.value();
|
| 374 |
+
// Background ASCII codes are the same as the foreground ones but with
|
| 375 |
+
// 10 more.
|
| 376 |
+
if (is_background) value += 10u;
|
| 377 |
+
|
| 378 |
+
size_t index = 0;
|
| 379 |
+
buffer[index++] = static_cast<Char>('\x1b');
|
| 380 |
+
buffer[index++] = static_cast<Char>('[');
|
| 381 |
+
|
| 382 |
+
if (value >= 100u) {
|
| 383 |
+
buffer[index++] = static_cast<Char>('1');
|
| 384 |
+
value %= 100u;
|
| 385 |
+
}
|
| 386 |
+
buffer[index++] = static_cast<Char>('0' + value / 10u);
|
| 387 |
+
buffer[index++] = static_cast<Char>('0' + value % 10u);
|
| 388 |
+
|
| 389 |
+
buffer[index++] = static_cast<Char>('m');
|
| 390 |
+
buffer[index++] = static_cast<Char>('\0');
|
| 391 |
+
return;
|
| 392 |
+
}
|
| 393 |
+
|
| 394 |
+
for (int i = 0; i < 7; i++) {
|
| 395 |
+
buffer[i] = static_cast<Char>(esc[i]);
|
| 396 |
+
}
|
| 397 |
+
rgb color(text_color.value());
|
| 398 |
+
to_esc(color.r, buffer + 7, ';');
|
| 399 |
+
to_esc(color.g, buffer + 11, ';');
|
| 400 |
+
to_esc(color.b, buffer + 15, 'm');
|
| 401 |
+
buffer[19] = static_cast<Char>(0);
|
| 402 |
+
}
|
| 403 |
+
FMT_CONSTEXPR ansi_color_escape(emphasis em) noexcept {
|
| 404 |
+
uint8_t em_codes[num_emphases] = {};
|
| 405 |
+
if (has_emphasis(em, emphasis::bold)) em_codes[0] = 1;
|
| 406 |
+
if (has_emphasis(em, emphasis::faint)) em_codes[1] = 2;
|
| 407 |
+
if (has_emphasis(em, emphasis::italic)) em_codes[2] = 3;
|
| 408 |
+
if (has_emphasis(em, emphasis::underline)) em_codes[3] = 4;
|
| 409 |
+
if (has_emphasis(em, emphasis::blink)) em_codes[4] = 5;
|
| 410 |
+
if (has_emphasis(em, emphasis::reverse)) em_codes[5] = 7;
|
| 411 |
+
if (has_emphasis(em, emphasis::conceal)) em_codes[6] = 8;
|
| 412 |
+
if (has_emphasis(em, emphasis::strikethrough)) em_codes[7] = 9;
|
| 413 |
+
|
| 414 |
+
size_t index = 0;
|
| 415 |
+
for (size_t i = 0; i < num_emphases; ++i) {
|
| 416 |
+
if (!em_codes[i]) continue;
|
| 417 |
+
buffer[index++] = static_cast<Char>('\x1b');
|
| 418 |
+
buffer[index++] = static_cast<Char>('[');
|
| 419 |
+
buffer[index++] = static_cast<Char>('0' + em_codes[i]);
|
| 420 |
+
buffer[index++] = static_cast<Char>('m');
|
| 421 |
+
}
|
| 422 |
+
buffer[index++] = static_cast<Char>(0);
|
| 423 |
+
}
|
| 424 |
+
FMT_CONSTEXPR operator const Char*() const noexcept { return buffer; }
|
| 425 |
+
|
| 426 |
+
FMT_CONSTEXPR auto begin() const noexcept -> const Char* { return buffer; }
|
| 427 |
+
FMT_CONSTEXPR20 auto end() const noexcept -> const Char* {
|
| 428 |
+
return buffer + basic_string_view<Char>(buffer).size();
|
| 429 |
+
}
|
| 430 |
+
|
| 431 |
+
private:
|
| 432 |
+
static constexpr size_t num_emphases = 8;
|
| 433 |
+
Char buffer[7u + 3u * num_emphases + 1u];
|
| 434 |
+
|
| 435 |
+
static FMT_CONSTEXPR void to_esc(uint8_t c, Char* out,
|
| 436 |
+
char delimiter) noexcept {
|
| 437 |
+
out[0] = static_cast<Char>('0' + c / 100);
|
| 438 |
+
out[1] = static_cast<Char>('0' + c / 10 % 10);
|
| 439 |
+
out[2] = static_cast<Char>('0' + c % 10);
|
| 440 |
+
out[3] = static_cast<Char>(delimiter);
|
| 441 |
+
}
|
| 442 |
+
static FMT_CONSTEXPR auto has_emphasis(emphasis em, emphasis mask) noexcept
|
| 443 |
+
-> bool {
|
| 444 |
+
return static_cast<uint8_t>(em) & static_cast<uint8_t>(mask);
|
| 445 |
+
}
|
| 446 |
+
};
|
| 447 |
+
|
| 448 |
+
template <typename Char>
|
| 449 |
+
FMT_CONSTEXPR auto make_foreground_color(color_type foreground) noexcept
|
| 450 |
+
-> ansi_color_escape<Char> {
|
| 451 |
+
return ansi_color_escape<Char>(foreground, "\x1b[38;2;");
|
| 452 |
+
}
|
| 453 |
+
|
| 454 |
+
template <typename Char>
|
| 455 |
+
FMT_CONSTEXPR auto make_background_color(color_type background) noexcept
|
| 456 |
+
-> ansi_color_escape<Char> {
|
| 457 |
+
return ansi_color_escape<Char>(background, "\x1b[48;2;");
|
| 458 |
+
}
|
| 459 |
+
|
| 460 |
+
template <typename Char>
|
| 461 |
+
FMT_CONSTEXPR auto make_emphasis(emphasis em) noexcept
|
| 462 |
+
-> ansi_color_escape<Char> {
|
| 463 |
+
return ansi_color_escape<Char>(em);
|
| 464 |
+
}
|
| 465 |
+
|
| 466 |
+
template <typename Char> inline void reset_color(buffer<Char>& buffer) {
|
| 467 |
+
auto reset_color = string_view("\x1b[0m");
|
| 468 |
+
buffer.append(reset_color.begin(), reset_color.end());
|
| 469 |
+
}
|
| 470 |
+
|
| 471 |
+
template <typename T> struct styled_arg : view {
|
| 472 |
+
const T& value;
|
| 473 |
+
text_style style;
|
| 474 |
+
styled_arg(const T& v, text_style s) : value(v), style(s) {}
|
| 475 |
+
};
|
| 476 |
+
|
| 477 |
+
template <typename Char>
|
| 478 |
+
void vformat_to(buffer<Char>& buf, text_style ts, basic_string_view<Char> fmt,
|
| 479 |
+
basic_format_args<buffered_context<Char>> args) {
|
| 480 |
+
if (ts.has_emphasis()) {
|
| 481 |
+
auto emphasis = make_emphasis<Char>(ts.get_emphasis());
|
| 482 |
+
buf.append(emphasis.begin(), emphasis.end());
|
| 483 |
+
}
|
| 484 |
+
if (ts.has_foreground()) {
|
| 485 |
+
auto foreground = make_foreground_color<Char>(ts.get_foreground());
|
| 486 |
+
buf.append(foreground.begin(), foreground.end());
|
| 487 |
+
}
|
| 488 |
+
if (ts.has_background()) {
|
| 489 |
+
auto background = make_background_color<Char>(ts.get_background());
|
| 490 |
+
buf.append(background.begin(), background.end());
|
| 491 |
+
}
|
| 492 |
+
vformat_to(buf, fmt, args);
|
| 493 |
+
if (ts != text_style()) reset_color<Char>(buf);
|
| 494 |
+
}
|
| 495 |
+
} // namespace detail
|
| 496 |
+
|
| 497 |
+
inline void vprint(FILE* f, text_style ts, string_view fmt, format_args args) {
|
| 498 |
+
auto buf = memory_buffer();
|
| 499 |
+
detail::vformat_to(buf, ts, fmt, args);
|
| 500 |
+
print(f, FMT_STRING("{}"), string_view(buf.begin(), buf.size()));
|
| 501 |
+
}
|
| 502 |
+
|
| 503 |
+
/**
|
| 504 |
+
* Formats a string and prints it to the specified file stream using ANSI
|
| 505 |
+
* escape sequences to specify text formatting.
|
| 506 |
+
*
|
| 507 |
+
* **Example**:
|
| 508 |
+
*
|
| 509 |
+
* fmt::print(fmt::emphasis::bold | fg(fmt::color::red),
|
| 510 |
+
* "Elapsed time: {0:.2f} seconds", 1.23);
|
| 511 |
+
*/
|
| 512 |
+
template <typename... T>
|
| 513 |
+
void print(FILE* f, text_style ts, format_string<T...> fmt, T&&... args) {
|
| 514 |
+
vprint(f, ts, fmt.str, vargs<T...>{{args...}});
|
| 515 |
+
}
|
| 516 |
+
|
| 517 |
+
/**
|
| 518 |
+
* Formats a string and prints it to stdout using ANSI escape sequences to
|
| 519 |
+
* specify text formatting.
|
| 520 |
+
*
|
| 521 |
+
* **Example**:
|
| 522 |
+
*
|
| 523 |
+
* fmt::print(fmt::emphasis::bold | fg(fmt::color::red),
|
| 524 |
+
* "Elapsed time: {0:.2f} seconds", 1.23);
|
| 525 |
+
*/
|
| 526 |
+
template <typename... T>
|
| 527 |
+
void print(text_style ts, format_string<T...> fmt, T&&... args) {
|
| 528 |
+
return print(stdout, ts, fmt, std::forward<T>(args)...);
|
| 529 |
+
}
|
| 530 |
+
|
| 531 |
+
inline auto vformat(text_style ts, string_view fmt, format_args args)
|
| 532 |
+
-> std::string {
|
| 533 |
+
auto buf = memory_buffer();
|
| 534 |
+
detail::vformat_to(buf, ts, fmt, args);
|
| 535 |
+
return fmt::to_string(buf);
|
| 536 |
+
}
|
| 537 |
+
|
| 538 |
+
/**
|
| 539 |
+
* Formats arguments and returns the result as a string using ANSI escape
|
| 540 |
+
* sequences to specify text formatting.
|
| 541 |
+
*
|
| 542 |
+
* **Example**:
|
| 543 |
+
*
|
| 544 |
+
* ```
|
| 545 |
+
* #include <fmt/color.h>
|
| 546 |
+
* std::string message = fmt::format(fmt::emphasis::bold | fg(fmt::color::red),
|
| 547 |
+
* "The answer is {}", 42);
|
| 548 |
+
* ```
|
| 549 |
+
*/
|
| 550 |
+
template <typename... T>
|
| 551 |
+
inline auto format(text_style ts, format_string<T...> fmt, T&&... args)
|
| 552 |
+
-> std::string {
|
| 553 |
+
return fmt::vformat(ts, fmt.str, vargs<T...>{{args...}});
|
| 554 |
+
}
|
| 555 |
+
|
| 556 |
+
/// Formats a string with the given text_style and writes the output to `out`.
|
| 557 |
+
template <typename OutputIt,
|
| 558 |
+
FMT_ENABLE_IF(detail::is_output_iterator<OutputIt, char>::value)>
|
| 559 |
+
auto vformat_to(OutputIt out, text_style ts, string_view fmt, format_args args)
|
| 560 |
+
-> OutputIt {
|
| 561 |
+
auto&& buf = detail::get_buffer<char>(out);
|
| 562 |
+
detail::vformat_to(buf, ts, fmt, args);
|
| 563 |
+
return detail::get_iterator(buf, out);
|
| 564 |
+
}
|
| 565 |
+
|
| 566 |
+
/**
|
| 567 |
+
* Formats arguments with the given text style, writes the result to the output
|
| 568 |
+
* iterator `out` and returns the iterator past the end of the output range.
|
| 569 |
+
*
|
| 570 |
+
* **Example**:
|
| 571 |
+
*
|
| 572 |
+
* std::vector<char> out;
|
| 573 |
+
* fmt::format_to(std::back_inserter(out),
|
| 574 |
+
* fmt::emphasis::bold | fg(fmt::color::red), "{}", 42);
|
| 575 |
+
*/
|
| 576 |
+
template <typename OutputIt, typename... T,
|
| 577 |
+
FMT_ENABLE_IF(detail::is_output_iterator<OutputIt, char>::value)>
|
| 578 |
+
inline auto format_to(OutputIt out, text_style ts, format_string<T...> fmt,
|
| 579 |
+
T&&... args) -> OutputIt {
|
| 580 |
+
return vformat_to(out, ts, fmt.str, vargs<T...>{{args...}});
|
| 581 |
+
}
|
| 582 |
+
|
| 583 |
+
template <typename T, typename Char>
|
| 584 |
+
struct formatter<detail::styled_arg<T>, Char> : formatter<T, Char> {
|
| 585 |
+
template <typename FormatContext>
|
| 586 |
+
auto format(const detail::styled_arg<T>& arg, FormatContext& ctx) const
|
| 587 |
+
-> decltype(ctx.out()) {
|
| 588 |
+
const auto& ts = arg.style;
|
| 589 |
+
auto out = ctx.out();
|
| 590 |
+
|
| 591 |
+
bool has_style = false;
|
| 592 |
+
if (ts.has_emphasis()) {
|
| 593 |
+
has_style = true;
|
| 594 |
+
auto emphasis = detail::make_emphasis<Char>(ts.get_emphasis());
|
| 595 |
+
out = detail::copy<Char>(emphasis.begin(), emphasis.end(), out);
|
| 596 |
+
}
|
| 597 |
+
if (ts.has_foreground()) {
|
| 598 |
+
has_style = true;
|
| 599 |
+
auto foreground =
|
| 600 |
+
detail::make_foreground_color<Char>(ts.get_foreground());
|
| 601 |
+
out = detail::copy<Char>(foreground.begin(), foreground.end(), out);
|
| 602 |
+
}
|
| 603 |
+
if (ts.has_background()) {
|
| 604 |
+
has_style = true;
|
| 605 |
+
auto background =
|
| 606 |
+
detail::make_background_color<Char>(ts.get_background());
|
| 607 |
+
out = detail::copy<Char>(background.begin(), background.end(), out);
|
| 608 |
+
}
|
| 609 |
+
out = formatter<T, Char>::format(arg.value, ctx);
|
| 610 |
+
if (has_style) {
|
| 611 |
+
auto reset_color = string_view("\x1b[0m");
|
| 612 |
+
out = detail::copy<Char>(reset_color.begin(), reset_color.end(), out);
|
| 613 |
+
}
|
| 614 |
+
return out;
|
| 615 |
+
}
|
| 616 |
+
};
|
| 617 |
+
|
| 618 |
+
/**
|
| 619 |
+
* Returns an argument that will be formatted using ANSI escape sequences,
|
| 620 |
+
* to be used in a formatting function.
|
| 621 |
+
*
|
| 622 |
+
* **Example**:
|
| 623 |
+
*
|
| 624 |
+
* fmt::print("Elapsed time: {0:.2f} seconds",
|
| 625 |
+
* fmt::styled(1.23, fmt::fg(fmt::color::green) |
|
| 626 |
+
* fmt::bg(fmt::color::blue)));
|
| 627 |
+
*/
|
| 628 |
+
template <typename T>
|
| 629 |
+
FMT_CONSTEXPR auto styled(const T& value, text_style ts)
|
| 630 |
+
-> detail::styled_arg<remove_cvref_t<T>> {
|
| 631 |
+
return detail::styled_arg<remove_cvref_t<T>>{value, ts};
|
| 632 |
+
}
|
| 633 |
+
|
| 634 |
+
FMT_END_EXPORT
|
| 635 |
+
FMT_END_NAMESPACE
|
| 636 |
+
|
| 637 |
+
#endif // FMT_COLOR_H_
|
miniconda3/pkgs/fmt-11.2.0-hca5f364_0/include/fmt/compile.h
ADDED
|
@@ -0,0 +1,539 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// Formatting library for C++ - experimental format string compilation
|
| 2 |
+
//
|
| 3 |
+
// Copyright (c) 2012 - present, Victor Zverovich and fmt contributors
|
| 4 |
+
// All rights reserved.
|
| 5 |
+
//
|
| 6 |
+
// For the license information refer to format.h.
|
| 7 |
+
|
| 8 |
+
#ifndef FMT_COMPILE_H_
|
| 9 |
+
#define FMT_COMPILE_H_
|
| 10 |
+
|
| 11 |
+
#ifndef FMT_MODULE
|
| 12 |
+
# include <iterator> // std::back_inserter
|
| 13 |
+
#endif
|
| 14 |
+
|
| 15 |
+
#include "format.h"
|
| 16 |
+
|
| 17 |
+
FMT_BEGIN_NAMESPACE
|
| 18 |
+
|
| 19 |
+
// A compile-time string which is compiled into fast formatting code.
|
| 20 |
+
FMT_EXPORT class compiled_string {};
|
| 21 |
+
|
| 22 |
+
template <typename S>
|
| 23 |
+
struct is_compiled_string : std::is_base_of<compiled_string, S> {};
|
| 24 |
+
|
| 25 |
+
namespace detail {
|
| 26 |
+
|
| 27 |
+
/**
|
| 28 |
+
* Converts a string literal `s` into a format string that will be parsed at
|
| 29 |
+
* compile time and converted into efficient formatting code. Requires C++17
|
| 30 |
+
* `constexpr if` compiler support.
|
| 31 |
+
*
|
| 32 |
+
* **Example**:
|
| 33 |
+
*
|
| 34 |
+
* // Converts 42 into std::string using the most efficient method and no
|
| 35 |
+
* // runtime format string processing.
|
| 36 |
+
* std::string s = fmt::format(FMT_COMPILE("{}"), 42);
|
| 37 |
+
*/
|
| 38 |
+
#if defined(__cpp_if_constexpr) && defined(__cpp_return_type_deduction)
|
| 39 |
+
# define FMT_COMPILE(s) FMT_STRING_IMPL(s, fmt::compiled_string)
|
| 40 |
+
#else
|
| 41 |
+
# define FMT_COMPILE(s) FMT_STRING(s)
|
| 42 |
+
#endif
|
| 43 |
+
|
| 44 |
+
template <typename T, typename... Tail>
|
| 45 |
+
auto first(const T& value, const Tail&...) -> const T& {
|
| 46 |
+
return value;
|
| 47 |
+
}
|
| 48 |
+
|
| 49 |
+
#if defined(__cpp_if_constexpr) && defined(__cpp_return_type_deduction)
|
| 50 |
+
template <typename... Args> struct type_list {};
|
| 51 |
+
|
| 52 |
+
// Returns a reference to the argument at index N from [first, rest...].
|
| 53 |
+
template <int N, typename T, typename... Args>
|
| 54 |
+
constexpr const auto& get([[maybe_unused]] const T& first,
|
| 55 |
+
[[maybe_unused]] const Args&... rest) {
|
| 56 |
+
static_assert(N < 1 + sizeof...(Args), "index is out of bounds");
|
| 57 |
+
if constexpr (N == 0)
|
| 58 |
+
return first;
|
| 59 |
+
else
|
| 60 |
+
return detail::get<N - 1>(rest...);
|
| 61 |
+
}
|
| 62 |
+
|
| 63 |
+
# if FMT_USE_NONTYPE_TEMPLATE_ARGS
|
| 64 |
+
template <int N, typename T, typename... Args, typename Char>
|
| 65 |
+
constexpr auto get_arg_index_by_name(basic_string_view<Char> name) -> int {
|
| 66 |
+
if constexpr (is_static_named_arg<T>()) {
|
| 67 |
+
if (name == T::name) return N;
|
| 68 |
+
}
|
| 69 |
+
if constexpr (sizeof...(Args) > 0)
|
| 70 |
+
return get_arg_index_by_name<N + 1, Args...>(name);
|
| 71 |
+
(void)name; // Workaround an MSVC bug about "unused" parameter.
|
| 72 |
+
return -1;
|
| 73 |
+
}
|
| 74 |
+
# endif
|
| 75 |
+
|
| 76 |
+
template <typename... Args, typename Char>
|
| 77 |
+
FMT_CONSTEXPR auto get_arg_index_by_name(basic_string_view<Char> name) -> int {
|
| 78 |
+
# if FMT_USE_NONTYPE_TEMPLATE_ARGS
|
| 79 |
+
if constexpr (sizeof...(Args) > 0)
|
| 80 |
+
return get_arg_index_by_name<0, Args...>(name);
|
| 81 |
+
# endif
|
| 82 |
+
(void)name;
|
| 83 |
+
return -1;
|
| 84 |
+
}
|
| 85 |
+
|
| 86 |
+
template <typename Char, typename... Args>
|
| 87 |
+
constexpr int get_arg_index_by_name(basic_string_view<Char> name,
|
| 88 |
+
type_list<Args...>) {
|
| 89 |
+
return get_arg_index_by_name<Args...>(name);
|
| 90 |
+
}
|
| 91 |
+
|
| 92 |
+
template <int N, typename> struct get_type_impl;
|
| 93 |
+
|
| 94 |
+
template <int N, typename... Args> struct get_type_impl<N, type_list<Args...>> {
|
| 95 |
+
using type =
|
| 96 |
+
remove_cvref_t<decltype(detail::get<N>(std::declval<Args>()...))>;
|
| 97 |
+
};
|
| 98 |
+
|
| 99 |
+
template <int N, typename T>
|
| 100 |
+
using get_type = typename get_type_impl<N, T>::type;
|
| 101 |
+
|
| 102 |
+
template <typename T> struct is_compiled_format : std::false_type {};
|
| 103 |
+
|
| 104 |
+
template <typename Char> struct text {
|
| 105 |
+
basic_string_view<Char> data;
|
| 106 |
+
using char_type = Char;
|
| 107 |
+
|
| 108 |
+
template <typename OutputIt, typename... Args>
|
| 109 |
+
constexpr OutputIt format(OutputIt out, const Args&...) const {
|
| 110 |
+
return write<Char>(out, data);
|
| 111 |
+
}
|
| 112 |
+
};
|
| 113 |
+
|
| 114 |
+
template <typename Char>
|
| 115 |
+
struct is_compiled_format<text<Char>> : std::true_type {};
|
| 116 |
+
|
| 117 |
+
template <typename Char>
|
| 118 |
+
constexpr text<Char> make_text(basic_string_view<Char> s, size_t pos,
|
| 119 |
+
size_t size) {
|
| 120 |
+
return {{&s[pos], size}};
|
| 121 |
+
}
|
| 122 |
+
|
| 123 |
+
template <typename Char> struct code_unit {
|
| 124 |
+
Char value;
|
| 125 |
+
using char_type = Char;
|
| 126 |
+
|
| 127 |
+
template <typename OutputIt, typename... Args>
|
| 128 |
+
constexpr OutputIt format(OutputIt out, const Args&...) const {
|
| 129 |
+
*out++ = value;
|
| 130 |
+
return out;
|
| 131 |
+
}
|
| 132 |
+
};
|
| 133 |
+
|
| 134 |
+
// This ensures that the argument type is convertible to `const T&`.
|
| 135 |
+
template <typename T, int N, typename... Args>
|
| 136 |
+
constexpr const T& get_arg_checked(const Args&... args) {
|
| 137 |
+
const auto& arg = detail::get<N>(args...);
|
| 138 |
+
if constexpr (detail::is_named_arg<remove_cvref_t<decltype(arg)>>()) {
|
| 139 |
+
return arg.value;
|
| 140 |
+
} else {
|
| 141 |
+
return arg;
|
| 142 |
+
}
|
| 143 |
+
}
|
| 144 |
+
|
| 145 |
+
template <typename Char>
|
| 146 |
+
struct is_compiled_format<code_unit<Char>> : std::true_type {};
|
| 147 |
+
|
| 148 |
+
// A replacement field that refers to argument N.
|
| 149 |
+
template <typename Char, typename T, int N> struct field {
|
| 150 |
+
using char_type = Char;
|
| 151 |
+
|
| 152 |
+
template <typename OutputIt, typename... Args>
|
| 153 |
+
constexpr OutputIt format(OutputIt out, const Args&... args) const {
|
| 154 |
+
const T& arg = get_arg_checked<T, N>(args...);
|
| 155 |
+
if constexpr (std::is_convertible<T, basic_string_view<Char>>::value) {
|
| 156 |
+
auto s = basic_string_view<Char>(arg);
|
| 157 |
+
return copy<Char>(s.begin(), s.end(), out);
|
| 158 |
+
} else {
|
| 159 |
+
return write<Char>(out, arg);
|
| 160 |
+
}
|
| 161 |
+
}
|
| 162 |
+
};
|
| 163 |
+
|
| 164 |
+
template <typename Char, typename T, int N>
|
| 165 |
+
struct is_compiled_format<field<Char, T, N>> : std::true_type {};
|
| 166 |
+
|
| 167 |
+
// A replacement field that refers to argument with name.
|
| 168 |
+
template <typename Char> struct runtime_named_field {
|
| 169 |
+
using char_type = Char;
|
| 170 |
+
basic_string_view<Char> name;
|
| 171 |
+
|
| 172 |
+
template <typename OutputIt, typename T>
|
| 173 |
+
constexpr static bool try_format_argument(
|
| 174 |
+
OutputIt& out,
|
| 175 |
+
// [[maybe_unused]] due to unused-but-set-parameter warning in GCC 7,8,9
|
| 176 |
+
[[maybe_unused]] basic_string_view<Char> arg_name, const T& arg) {
|
| 177 |
+
if constexpr (is_named_arg<typename std::remove_cv<T>::type>::value) {
|
| 178 |
+
if (arg_name == arg.name) {
|
| 179 |
+
out = write<Char>(out, arg.value);
|
| 180 |
+
return true;
|
| 181 |
+
}
|
| 182 |
+
}
|
| 183 |
+
return false;
|
| 184 |
+
}
|
| 185 |
+
|
| 186 |
+
template <typename OutputIt, typename... Args>
|
| 187 |
+
constexpr OutputIt format(OutputIt out, const Args&... args) const {
|
| 188 |
+
bool found = (try_format_argument(out, name, args) || ...);
|
| 189 |
+
if (!found) {
|
| 190 |
+
FMT_THROW(format_error("argument with specified name is not found"));
|
| 191 |
+
}
|
| 192 |
+
return out;
|
| 193 |
+
}
|
| 194 |
+
};
|
| 195 |
+
|
| 196 |
+
template <typename Char>
|
| 197 |
+
struct is_compiled_format<runtime_named_field<Char>> : std::true_type {};
|
| 198 |
+
|
| 199 |
+
// A replacement field that refers to argument N and has format specifiers.
|
| 200 |
+
template <typename Char, typename T, int N> struct spec_field {
|
| 201 |
+
using char_type = Char;
|
| 202 |
+
formatter<T, Char> fmt;
|
| 203 |
+
|
| 204 |
+
template <typename OutputIt, typename... Args>
|
| 205 |
+
constexpr FMT_INLINE OutputIt format(OutputIt out,
|
| 206 |
+
const Args&... args) const {
|
| 207 |
+
const auto& vargs =
|
| 208 |
+
fmt::make_format_args<basic_format_context<OutputIt, Char>>(args...);
|
| 209 |
+
basic_format_context<OutputIt, Char> ctx(out, vargs);
|
| 210 |
+
return fmt.format(get_arg_checked<T, N>(args...), ctx);
|
| 211 |
+
}
|
| 212 |
+
};
|
| 213 |
+
|
| 214 |
+
template <typename Char, typename T, int N>
|
| 215 |
+
struct is_compiled_format<spec_field<Char, T, N>> : std::true_type {};
|
| 216 |
+
|
| 217 |
+
template <typename L, typename R> struct concat {
|
| 218 |
+
L lhs;
|
| 219 |
+
R rhs;
|
| 220 |
+
using char_type = typename L::char_type;
|
| 221 |
+
|
| 222 |
+
template <typename OutputIt, typename... Args>
|
| 223 |
+
constexpr OutputIt format(OutputIt out, const Args&... args) const {
|
| 224 |
+
out = lhs.format(out, args...);
|
| 225 |
+
return rhs.format(out, args...);
|
| 226 |
+
}
|
| 227 |
+
};
|
| 228 |
+
|
| 229 |
+
template <typename L, typename R>
|
| 230 |
+
struct is_compiled_format<concat<L, R>> : std::true_type {};
|
| 231 |
+
|
| 232 |
+
template <typename L, typename R>
|
| 233 |
+
constexpr concat<L, R> make_concat(L lhs, R rhs) {
|
| 234 |
+
return {lhs, rhs};
|
| 235 |
+
}
|
| 236 |
+
|
| 237 |
+
struct unknown_format {};
|
| 238 |
+
|
| 239 |
+
template <typename Char>
|
| 240 |
+
constexpr size_t parse_text(basic_string_view<Char> str, size_t pos) {
|
| 241 |
+
for (size_t size = str.size(); pos != size; ++pos) {
|
| 242 |
+
if (str[pos] == '{' || str[pos] == '}') break;
|
| 243 |
+
}
|
| 244 |
+
return pos;
|
| 245 |
+
}
|
| 246 |
+
|
| 247 |
+
template <typename Args, size_t POS, int ID, typename S>
|
| 248 |
+
constexpr auto compile_format_string(S fmt);
|
| 249 |
+
|
| 250 |
+
template <typename Args, size_t POS, int ID, typename T, typename S>
|
| 251 |
+
constexpr auto parse_tail(T head, S fmt) {
|
| 252 |
+
if constexpr (POS != basic_string_view<typename S::char_type>(fmt).size()) {
|
| 253 |
+
constexpr auto tail = compile_format_string<Args, POS, ID>(fmt);
|
| 254 |
+
if constexpr (std::is_same<remove_cvref_t<decltype(tail)>,
|
| 255 |
+
unknown_format>())
|
| 256 |
+
return tail;
|
| 257 |
+
else
|
| 258 |
+
return make_concat(head, tail);
|
| 259 |
+
} else {
|
| 260 |
+
return head;
|
| 261 |
+
}
|
| 262 |
+
}
|
| 263 |
+
|
| 264 |
+
template <typename T, typename Char> struct parse_specs_result {
|
| 265 |
+
formatter<T, Char> fmt;
|
| 266 |
+
size_t end;
|
| 267 |
+
int next_arg_id;
|
| 268 |
+
};
|
| 269 |
+
|
| 270 |
+
enum { manual_indexing_id = -1 };
|
| 271 |
+
|
| 272 |
+
template <typename T, typename Char>
|
| 273 |
+
constexpr parse_specs_result<T, Char> parse_specs(basic_string_view<Char> str,
|
| 274 |
+
size_t pos, int next_arg_id) {
|
| 275 |
+
str.remove_prefix(pos);
|
| 276 |
+
auto ctx =
|
| 277 |
+
compile_parse_context<Char>(str, max_value<int>(), nullptr, next_arg_id);
|
| 278 |
+
auto f = formatter<T, Char>();
|
| 279 |
+
auto end = f.parse(ctx);
|
| 280 |
+
return {f, pos + fmt::detail::to_unsigned(end - str.data()),
|
| 281 |
+
next_arg_id == 0 ? manual_indexing_id : ctx.next_arg_id()};
|
| 282 |
+
}
|
| 283 |
+
|
| 284 |
+
template <typename Char> struct arg_id_handler {
|
| 285 |
+
arg_id_kind kind;
|
| 286 |
+
arg_ref<Char> arg_id;
|
| 287 |
+
|
| 288 |
+
constexpr int on_auto() {
|
| 289 |
+
FMT_ASSERT(false, "handler cannot be used with automatic indexing");
|
| 290 |
+
return 0;
|
| 291 |
+
}
|
| 292 |
+
constexpr int on_index(int id) {
|
| 293 |
+
kind = arg_id_kind::index;
|
| 294 |
+
arg_id = arg_ref<Char>(id);
|
| 295 |
+
return 0;
|
| 296 |
+
}
|
| 297 |
+
constexpr int on_name(basic_string_view<Char> id) {
|
| 298 |
+
kind = arg_id_kind::name;
|
| 299 |
+
arg_id = arg_ref<Char>(id);
|
| 300 |
+
return 0;
|
| 301 |
+
}
|
| 302 |
+
};
|
| 303 |
+
|
| 304 |
+
template <typename Char> struct parse_arg_id_result {
|
| 305 |
+
arg_id_kind kind;
|
| 306 |
+
arg_ref<Char> arg_id;
|
| 307 |
+
const Char* arg_id_end;
|
| 308 |
+
};
|
| 309 |
+
|
| 310 |
+
template <int ID, typename Char>
|
| 311 |
+
constexpr auto parse_arg_id(const Char* begin, const Char* end) {
|
| 312 |
+
auto handler = arg_id_handler<Char>{arg_id_kind::none, arg_ref<Char>{}};
|
| 313 |
+
auto arg_id_end = parse_arg_id(begin, end, handler);
|
| 314 |
+
return parse_arg_id_result<Char>{handler.kind, handler.arg_id, arg_id_end};
|
| 315 |
+
}
|
| 316 |
+
|
| 317 |
+
template <typename T, typename Enable = void> struct field_type {
|
| 318 |
+
using type = remove_cvref_t<T>;
|
| 319 |
+
};
|
| 320 |
+
|
| 321 |
+
template <typename T>
|
| 322 |
+
struct field_type<T, enable_if_t<detail::is_named_arg<T>::value>> {
|
| 323 |
+
using type = remove_cvref_t<decltype(T::value)>;
|
| 324 |
+
};
|
| 325 |
+
|
| 326 |
+
template <typename T, typename Args, size_t END_POS, int ARG_INDEX, int NEXT_ID,
|
| 327 |
+
typename S>
|
| 328 |
+
constexpr auto parse_replacement_field_then_tail(S fmt) {
|
| 329 |
+
using char_type = typename S::char_type;
|
| 330 |
+
constexpr auto str = basic_string_view<char_type>(fmt);
|
| 331 |
+
constexpr char_type c = END_POS != str.size() ? str[END_POS] : char_type();
|
| 332 |
+
if constexpr (c == '}') {
|
| 333 |
+
return parse_tail<Args, END_POS + 1, NEXT_ID>(
|
| 334 |
+
field<char_type, typename field_type<T>::type, ARG_INDEX>(), fmt);
|
| 335 |
+
} else if constexpr (c != ':') {
|
| 336 |
+
FMT_THROW(format_error("expected ':'"));
|
| 337 |
+
} else {
|
| 338 |
+
constexpr auto result = parse_specs<typename field_type<T>::type>(
|
| 339 |
+
str, END_POS + 1, NEXT_ID == manual_indexing_id ? 0 : NEXT_ID);
|
| 340 |
+
if constexpr (result.end >= str.size() || str[result.end] != '}') {
|
| 341 |
+
FMT_THROW(format_error("expected '}'"));
|
| 342 |
+
return 0;
|
| 343 |
+
} else {
|
| 344 |
+
return parse_tail<Args, result.end + 1, result.next_arg_id>(
|
| 345 |
+
spec_field<char_type, typename field_type<T>::type, ARG_INDEX>{
|
| 346 |
+
result.fmt},
|
| 347 |
+
fmt);
|
| 348 |
+
}
|
| 349 |
+
}
|
| 350 |
+
}
|
| 351 |
+
|
| 352 |
+
// Compiles a non-empty format string and returns the compiled representation
|
| 353 |
+
// or unknown_format() on unrecognized input.
|
| 354 |
+
template <typename Args, size_t POS, int ID, typename S>
|
| 355 |
+
constexpr auto compile_format_string(S fmt) {
|
| 356 |
+
using char_type = typename S::char_type;
|
| 357 |
+
constexpr auto str = basic_string_view<char_type>(fmt);
|
| 358 |
+
if constexpr (str[POS] == '{') {
|
| 359 |
+
if constexpr (POS + 1 == str.size())
|
| 360 |
+
FMT_THROW(format_error("unmatched '{' in format string"));
|
| 361 |
+
if constexpr (str[POS + 1] == '{') {
|
| 362 |
+
return parse_tail<Args, POS + 2, ID>(make_text(str, POS, 1), fmt);
|
| 363 |
+
} else if constexpr (str[POS + 1] == '}' || str[POS + 1] == ':') {
|
| 364 |
+
static_assert(ID != manual_indexing_id,
|
| 365 |
+
"cannot switch from manual to automatic argument indexing");
|
| 366 |
+
constexpr auto next_id =
|
| 367 |
+
ID != manual_indexing_id ? ID + 1 : manual_indexing_id;
|
| 368 |
+
return parse_replacement_field_then_tail<get_type<ID, Args>, Args,
|
| 369 |
+
POS + 1, ID, next_id>(fmt);
|
| 370 |
+
} else {
|
| 371 |
+
constexpr auto arg_id_result =
|
| 372 |
+
parse_arg_id<ID>(str.data() + POS + 1, str.data() + str.size());
|
| 373 |
+
constexpr auto arg_id_end_pos = arg_id_result.arg_id_end - str.data();
|
| 374 |
+
constexpr char_type c =
|
| 375 |
+
arg_id_end_pos != str.size() ? str[arg_id_end_pos] : char_type();
|
| 376 |
+
static_assert(c == '}' || c == ':', "missing '}' in format string");
|
| 377 |
+
if constexpr (arg_id_result.kind == arg_id_kind::index) {
|
| 378 |
+
static_assert(
|
| 379 |
+
ID == manual_indexing_id || ID == 0,
|
| 380 |
+
"cannot switch from automatic to manual argument indexing");
|
| 381 |
+
constexpr auto arg_index = arg_id_result.arg_id.index;
|
| 382 |
+
return parse_replacement_field_then_tail<get_type<arg_index, Args>,
|
| 383 |
+
Args, arg_id_end_pos,
|
| 384 |
+
arg_index, manual_indexing_id>(
|
| 385 |
+
fmt);
|
| 386 |
+
} else if constexpr (arg_id_result.kind == arg_id_kind::name) {
|
| 387 |
+
constexpr auto arg_index =
|
| 388 |
+
get_arg_index_by_name(arg_id_result.arg_id.name, Args{});
|
| 389 |
+
if constexpr (arg_index >= 0) {
|
| 390 |
+
constexpr auto next_id =
|
| 391 |
+
ID != manual_indexing_id ? ID + 1 : manual_indexing_id;
|
| 392 |
+
return parse_replacement_field_then_tail<
|
| 393 |
+
decltype(get_type<arg_index, Args>::value), Args, arg_id_end_pos,
|
| 394 |
+
arg_index, next_id>(fmt);
|
| 395 |
+
} else if constexpr (c == '}') {
|
| 396 |
+
return parse_tail<Args, arg_id_end_pos + 1, ID>(
|
| 397 |
+
runtime_named_field<char_type>{arg_id_result.arg_id.name}, fmt);
|
| 398 |
+
} else if constexpr (c == ':') {
|
| 399 |
+
return unknown_format(); // no type info for specs parsing
|
| 400 |
+
}
|
| 401 |
+
}
|
| 402 |
+
}
|
| 403 |
+
} else if constexpr (str[POS] == '}') {
|
| 404 |
+
if constexpr (POS + 1 == str.size())
|
| 405 |
+
FMT_THROW(format_error("unmatched '}' in format string"));
|
| 406 |
+
return parse_tail<Args, POS + 2, ID>(make_text(str, POS, 1), fmt);
|
| 407 |
+
} else {
|
| 408 |
+
constexpr auto end = parse_text(str, POS + 1);
|
| 409 |
+
if constexpr (end - POS > 1) {
|
| 410 |
+
return parse_tail<Args, end, ID>(make_text(str, POS, end - POS), fmt);
|
| 411 |
+
} else {
|
| 412 |
+
return parse_tail<Args, end, ID>(code_unit<char_type>{str[POS]}, fmt);
|
| 413 |
+
}
|
| 414 |
+
}
|
| 415 |
+
}
|
| 416 |
+
|
| 417 |
+
template <typename... Args, typename S,
|
| 418 |
+
FMT_ENABLE_IF(is_compiled_string<S>::value)>
|
| 419 |
+
constexpr auto compile(S fmt) {
|
| 420 |
+
constexpr auto str = basic_string_view<typename S::char_type>(fmt);
|
| 421 |
+
if constexpr (str.size() == 0) {
|
| 422 |
+
return detail::make_text(str, 0, 0);
|
| 423 |
+
} else {
|
| 424 |
+
constexpr auto result =
|
| 425 |
+
detail::compile_format_string<detail::type_list<Args...>, 0, 0>(fmt);
|
| 426 |
+
return result;
|
| 427 |
+
}
|
| 428 |
+
}
|
| 429 |
+
#endif // defined(__cpp_if_constexpr) && defined(__cpp_return_type_deduction)
|
| 430 |
+
} // namespace detail
|
| 431 |
+
|
| 432 |
+
FMT_BEGIN_EXPORT
|
| 433 |
+
|
| 434 |
+
#if defined(__cpp_if_constexpr) && defined(__cpp_return_type_deduction)
|
| 435 |
+
|
| 436 |
+
template <typename CompiledFormat, typename... Args,
|
| 437 |
+
typename Char = typename CompiledFormat::char_type,
|
| 438 |
+
FMT_ENABLE_IF(detail::is_compiled_format<CompiledFormat>::value)>
|
| 439 |
+
FMT_INLINE std::basic_string<Char> format(const CompiledFormat& cf,
|
| 440 |
+
const Args&... args) {
|
| 441 |
+
auto s = std::basic_string<Char>();
|
| 442 |
+
cf.format(std::back_inserter(s), args...);
|
| 443 |
+
return s;
|
| 444 |
+
}
|
| 445 |
+
|
| 446 |
+
template <typename OutputIt, typename CompiledFormat, typename... Args,
|
| 447 |
+
FMT_ENABLE_IF(detail::is_compiled_format<CompiledFormat>::value)>
|
| 448 |
+
constexpr FMT_INLINE OutputIt format_to(OutputIt out, const CompiledFormat& cf,
|
| 449 |
+
const Args&... args) {
|
| 450 |
+
return cf.format(out, args...);
|
| 451 |
+
}
|
| 452 |
+
|
| 453 |
+
template <typename S, typename... Args,
|
| 454 |
+
FMT_ENABLE_IF(is_compiled_string<S>::value)>
|
| 455 |
+
FMT_INLINE std::basic_string<typename S::char_type> format(const S&,
|
| 456 |
+
Args&&... args) {
|
| 457 |
+
if constexpr (std::is_same<typename S::char_type, char>::value) {
|
| 458 |
+
constexpr auto str = basic_string_view<typename S::char_type>(S());
|
| 459 |
+
if constexpr (str.size() == 2 && str[0] == '{' && str[1] == '}') {
|
| 460 |
+
const auto& first = detail::first(args...);
|
| 461 |
+
if constexpr (detail::is_named_arg<
|
| 462 |
+
remove_cvref_t<decltype(first)>>::value) {
|
| 463 |
+
return fmt::to_string(first.value);
|
| 464 |
+
} else {
|
| 465 |
+
return fmt::to_string(first);
|
| 466 |
+
}
|
| 467 |
+
}
|
| 468 |
+
}
|
| 469 |
+
constexpr auto compiled = detail::compile<Args...>(S());
|
| 470 |
+
if constexpr (std::is_same<remove_cvref_t<decltype(compiled)>,
|
| 471 |
+
detail::unknown_format>()) {
|
| 472 |
+
return fmt::format(
|
| 473 |
+
static_cast<basic_string_view<typename S::char_type>>(S()),
|
| 474 |
+
std::forward<Args>(args)...);
|
| 475 |
+
} else {
|
| 476 |
+
return fmt::format(compiled, std::forward<Args>(args)...);
|
| 477 |
+
}
|
| 478 |
+
}
|
| 479 |
+
|
| 480 |
+
template <typename OutputIt, typename S, typename... Args,
|
| 481 |
+
FMT_ENABLE_IF(is_compiled_string<S>::value)>
|
| 482 |
+
FMT_CONSTEXPR OutputIt format_to(OutputIt out, const S&, Args&&... args) {
|
| 483 |
+
constexpr auto compiled = detail::compile<Args...>(S());
|
| 484 |
+
if constexpr (std::is_same<remove_cvref_t<decltype(compiled)>,
|
| 485 |
+
detail::unknown_format>()) {
|
| 486 |
+
return fmt::format_to(
|
| 487 |
+
out, static_cast<basic_string_view<typename S::char_type>>(S()),
|
| 488 |
+
std::forward<Args>(args)...);
|
| 489 |
+
} else {
|
| 490 |
+
return fmt::format_to(out, compiled, std::forward<Args>(args)...);
|
| 491 |
+
}
|
| 492 |
+
}
|
| 493 |
+
#endif
|
| 494 |
+
|
| 495 |
+
template <typename OutputIt, typename S, typename... Args,
|
| 496 |
+
FMT_ENABLE_IF(is_compiled_string<S>::value)>
|
| 497 |
+
auto format_to_n(OutputIt out, size_t n, const S& fmt, Args&&... args)
|
| 498 |
+
-> format_to_n_result<OutputIt> {
|
| 499 |
+
using traits = detail::fixed_buffer_traits;
|
| 500 |
+
auto buf = detail::iterator_buffer<OutputIt, char, traits>(out, n);
|
| 501 |
+
fmt::format_to(std::back_inserter(buf), fmt, std::forward<Args>(args)...);
|
| 502 |
+
return {buf.out(), buf.count()};
|
| 503 |
+
}
|
| 504 |
+
|
| 505 |
+
template <typename S, typename... Args,
|
| 506 |
+
FMT_ENABLE_IF(is_compiled_string<S>::value)>
|
| 507 |
+
FMT_CONSTEXPR20 auto formatted_size(const S& fmt, const Args&... args)
|
| 508 |
+
-> size_t {
|
| 509 |
+
auto buf = detail::counting_buffer<>();
|
| 510 |
+
fmt::format_to(appender(buf), fmt, args...);
|
| 511 |
+
return buf.count();
|
| 512 |
+
}
|
| 513 |
+
|
| 514 |
+
template <typename S, typename... Args,
|
| 515 |
+
FMT_ENABLE_IF(is_compiled_string<S>::value)>
|
| 516 |
+
void print(std::FILE* f, const S& fmt, const Args&... args) {
|
| 517 |
+
auto buf = memory_buffer();
|
| 518 |
+
fmt::format_to(appender(buf), fmt, args...);
|
| 519 |
+
detail::print(f, {buf.data(), buf.size()});
|
| 520 |
+
}
|
| 521 |
+
|
| 522 |
+
template <typename S, typename... Args,
|
| 523 |
+
FMT_ENABLE_IF(is_compiled_string<S>::value)>
|
| 524 |
+
void print(const S& fmt, const Args&... args) {
|
| 525 |
+
print(stdout, fmt, args...);
|
| 526 |
+
}
|
| 527 |
+
|
| 528 |
+
#if FMT_USE_NONTYPE_TEMPLATE_ARGS
|
| 529 |
+
inline namespace literals {
|
| 530 |
+
template <detail::fixed_string Str> constexpr auto operator""_cf() {
|
| 531 |
+
return FMT_COMPILE(Str.data);
|
| 532 |
+
}
|
| 533 |
+
} // namespace literals
|
| 534 |
+
#endif
|
| 535 |
+
|
| 536 |
+
FMT_END_EXPORT
|
| 537 |
+
FMT_END_NAMESPACE
|
| 538 |
+
|
| 539 |
+
#endif // FMT_COMPILE_H_
|