Add files using upload-large-folder tool
Browse filesThis view is limited to 50 files because it contains too many changes. See raw diff
- SPFsmartGATE/LIVE/TMP/babel/babel.egg-info/PKG-INFO +50 -0
- SPFsmartGATE/LIVE/TMP/babel/babel.egg-info/SOURCES.txt +160 -0
- SPFsmartGATE/LIVE/TMP/babel/babel.egg-info/dependency_links.txt +1 -0
- SPFsmartGATE/LIVE/TMP/babel/babel.egg-info/entry_points.txt +20 -0
- SPFsmartGATE/LIVE/TMP/babel/babel.egg-info/not-zip-safe +1 -0
- SPFsmartGATE/LIVE/TMP/babel/babel.egg-info/requires.txt +8 -0
- SPFsmartGATE/LIVE/TMP/babel/babel.egg-info/top_level.txt +1 -0
- SPFsmartGATE/LIVE/TMP/babel/cldr/.gitignore +1 -0
- SPFsmartGATE/LIVE/TMP/babel/docs/changelog.rst +1 -0
- SPFsmartGATE/LIVE/TMP/babel/docs/index.rst +47 -0
- SPFsmartGATE/LIVE/TMP/babel/docs/installation.rst +99 -0
- SPFsmartGATE/LIVE/TMP/babel/docs/numbers.rst +183 -0
- SPFsmartGATE/LIVE/TMP/babel/docs/requirements.txt +1 -0
- SPFsmartGATE/LIVE/TMP/babel/scripts/download_import_cldr.py +88 -0
- SPFsmartGATE/LIVE/TMP/babel/scripts/dump_data.py +43 -0
- SPFsmartGATE/LIVE/TMP/babel/scripts/dump_global.py +30 -0
- SPFsmartGATE/LIVE/TMP/babel/scripts/generate_authors.py +39 -0
- SPFsmartGATE/LIVE/TMP/babel/scripts/import_cldr.py +1042 -0
- SPFsmartGATE/LIVE/TMP/haystack/.github/ISSUE_TEMPLATE/breaking-change-proposal.md +27 -0
- SPFsmartGATE/LIVE/TMP/haystack/.github/ISSUE_TEMPLATE/bug_report.md +34 -0
- SPFsmartGATE/LIVE/TMP/haystack/.github/ISSUE_TEMPLATE/config.yml +5 -0
- SPFsmartGATE/LIVE/TMP/haystack/.github/ISSUE_TEMPLATE/feature_request.md +20 -0
- SPFsmartGATE/LIVE/TMP/haystack/.github/utils/create_unstable_docs.py +54 -0
- SPFsmartGATE/LIVE/TMP/haystack/.github/utils/delete_outdated_docs.py +72 -0
- SPFsmartGATE/LIVE/TMP/haystack/.github/utils/docstrings_checksum.py +49 -0
- SPFsmartGATE/LIVE/TMP/haystack/.github/utils/generate_openapi_specs.py +37 -0
- SPFsmartGATE/LIVE/TMP/haystack/.github/utils/promote_unstable_docs.py +29 -0
- SPFsmartGATE/LIVE/TMP/haystack/.github/utils/pydoc-markdown.sh +10 -0
- SPFsmartGATE/LIVE/TMP/haystack/.github/utils/pyproject_to_requirements.py +47 -0
- SPFsmartGATE/LIVE/TMP/haystack/.github/utils/readme_api.py +55 -0
- SPFsmartGATE/LIVE/TMP/haystack/.github/workflows/ci_metrics.yml +23 -0
- SPFsmartGATE/LIVE/TMP/haystack/.github/workflows/docker_release.yml +69 -0
- SPFsmartGATE/LIVE/TMP/haystack/.github/workflows/docstring_labeler.yml +59 -0
- SPFsmartGATE/LIVE/TMP/haystack/.github/workflows/docstrings_linting.yml +28 -0
- SPFsmartGATE/LIVE/TMP/haystack/.github/workflows/e2e.yml +58 -0
- SPFsmartGATE/LIVE/TMP/haystack/.github/workflows/github_release.yml +74 -0
- SPFsmartGATE/LIVE/TMP/haystack/.github/workflows/labeler.yml +15 -0
- SPFsmartGATE/LIVE/TMP/haystack/.github/workflows/license_compliance.yml +92 -0
- SPFsmartGATE/LIVE/TMP/haystack/.github/workflows/minor_version_release.yml +79 -0
- SPFsmartGATE/LIVE/TMP/haystack/.github/workflows/project.yml +16 -0
- SPFsmartGATE/LIVE/TMP/haystack/.github/workflows/promote_unstable_docs.yml +38 -0
- SPFsmartGATE/LIVE/TMP/haystack/.github/workflows/pypi_release.yml +31 -0
- SPFsmartGATE/LIVE/TMP/haystack/.github/workflows/readme_sync.yml +65 -0
- SPFsmartGATE/LIVE/TMP/haystack/.github/workflows/release_notes.yml +48 -0
- SPFsmartGATE/LIVE/TMP/haystack/.github/workflows/release_notes_skipper.yml +22 -0
- SPFsmartGATE/LIVE/TMP/haystack/.github/workflows/stale.yml +15 -0
- SPFsmartGATE/LIVE/TMP/haystack/.github/workflows/tests.yml +442 -0
- SPFsmartGATE/LIVE/TMP/haystack/.github/workflows/tests_skipper_trigger.yml +48 -0
- SPFsmartGATE/LIVE/TMP/haystack/.github/workflows/tests_skipper_workflow.yml +24 -0
- SPFsmartGATE/LIVE/TMP/haystack/.github/workflows/workflows_linting.yml +23 -0
SPFsmartGATE/LIVE/TMP/babel/babel.egg-info/PKG-INFO
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
Metadata-Version: 2.4
|
| 2 |
+
Name: babel
|
| 3 |
+
Version: 2.16.0
|
| 4 |
+
Summary: Internationalization utilities
|
| 5 |
+
Home-page: https://babel.pocoo.org/
|
| 6 |
+
Author: Armin Ronacher
|
| 7 |
+
Author-email: armin.ronacher@active-4.com
|
| 8 |
+
Maintainer: Aarni Koskela
|
| 9 |
+
Maintainer-email: akx@iki.fi
|
| 10 |
+
License: BSD-3-Clause
|
| 11 |
+
Project-URL: Source, https://github.com/python-babel/babel
|
| 12 |
+
Classifier: Development Status :: 5 - Production/Stable
|
| 13 |
+
Classifier: Environment :: Web Environment
|
| 14 |
+
Classifier: Intended Audience :: Developers
|
| 15 |
+
Classifier: License :: OSI Approved :: BSD License
|
| 16 |
+
Classifier: Operating System :: OS Independent
|
| 17 |
+
Classifier: Programming Language :: Python
|
| 18 |
+
Classifier: Programming Language :: Python :: 3
|
| 19 |
+
Classifier: Programming Language :: Python :: 3 :: Only
|
| 20 |
+
Classifier: Programming Language :: Python :: 3.8
|
| 21 |
+
Classifier: Programming Language :: Python :: 3.9
|
| 22 |
+
Classifier: Programming Language :: Python :: 3.10
|
| 23 |
+
Classifier: Programming Language :: Python :: 3.11
|
| 24 |
+
Classifier: Programming Language :: Python :: 3.12
|
| 25 |
+
Classifier: Programming Language :: Python :: Implementation :: CPython
|
| 26 |
+
Classifier: Programming Language :: Python :: Implementation :: PyPy
|
| 27 |
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
| 28 |
+
Requires-Python: >=3.8
|
| 29 |
+
License-File: LICENSE
|
| 30 |
+
Requires-Dist: pytz>=2015.7; python_version < "3.9"
|
| 31 |
+
Provides-Extra: dev
|
| 32 |
+
Requires-Dist: pytest>=6.0; extra == "dev"
|
| 33 |
+
Requires-Dist: pytest-cov; extra == "dev"
|
| 34 |
+
Requires-Dist: freezegun~=1.0; extra == "dev"
|
| 35 |
+
Dynamic: author
|
| 36 |
+
Dynamic: author-email
|
| 37 |
+
Dynamic: classifier
|
| 38 |
+
Dynamic: description
|
| 39 |
+
Dynamic: home-page
|
| 40 |
+
Dynamic: license
|
| 41 |
+
Dynamic: license-file
|
| 42 |
+
Dynamic: maintainer
|
| 43 |
+
Dynamic: maintainer-email
|
| 44 |
+
Dynamic: project-url
|
| 45 |
+
Dynamic: provides-extra
|
| 46 |
+
Dynamic: requires-dist
|
| 47 |
+
Dynamic: requires-python
|
| 48 |
+
Dynamic: summary
|
| 49 |
+
|
| 50 |
+
A collection of tools for internationalizing Python applications.
|
SPFsmartGATE/LIVE/TMP/babel/babel.egg-info/SOURCES.txt
ADDED
|
@@ -0,0 +1,160 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
AUTHORS
|
| 2 |
+
CHANGES.rst
|
| 3 |
+
LICENSE
|
| 4 |
+
MANIFEST.in
|
| 5 |
+
Makefile
|
| 6 |
+
README.rst
|
| 7 |
+
conftest.py
|
| 8 |
+
pyproject.toml
|
| 9 |
+
setup.cfg
|
| 10 |
+
setup.py
|
| 11 |
+
tox.ini
|
| 12 |
+
babel/__init__.py
|
| 13 |
+
babel/core.py
|
| 14 |
+
babel/dates.py
|
| 15 |
+
babel/languages.py
|
| 16 |
+
babel/lists.py
|
| 17 |
+
babel/localedata.py
|
| 18 |
+
babel/numbers.py
|
| 19 |
+
babel/plural.py
|
| 20 |
+
babel/py.typed
|
| 21 |
+
babel/support.py
|
| 22 |
+
babel/units.py
|
| 23 |
+
babel/util.py
|
| 24 |
+
babel.egg-info/PKG-INFO
|
| 25 |
+
babel.egg-info/SOURCES.txt
|
| 26 |
+
babel.egg-info/dependency_links.txt
|
| 27 |
+
babel.egg-info/entry_points.txt
|
| 28 |
+
babel.egg-info/not-zip-safe
|
| 29 |
+
babel.egg-info/requires.txt
|
| 30 |
+
babel.egg-info/top_level.txt
|
| 31 |
+
babel/locale-data/LICENSE.unicode
|
| 32 |
+
babel/localtime/__init__.py
|
| 33 |
+
babel/localtime/_fallback.py
|
| 34 |
+
babel/localtime/_helpers.py
|
| 35 |
+
babel/localtime/_unix.py
|
| 36 |
+
babel/localtime/_win32.py
|
| 37 |
+
babel/messages/__init__.py
|
| 38 |
+
babel/messages/_compat.py
|
| 39 |
+
babel/messages/catalog.py
|
| 40 |
+
babel/messages/checkers.py
|
| 41 |
+
babel/messages/extract.py
|
| 42 |
+
babel/messages/frontend.py
|
| 43 |
+
babel/messages/jslexer.py
|
| 44 |
+
babel/messages/mofile.py
|
| 45 |
+
babel/messages/plurals.py
|
| 46 |
+
babel/messages/pofile.py
|
| 47 |
+
babel/messages/setuptools_frontend.py
|
| 48 |
+
docs/Makefile
|
| 49 |
+
docs/changelog.rst
|
| 50 |
+
docs/cmdline.rst
|
| 51 |
+
docs/conf.py
|
| 52 |
+
docs/dates.rst
|
| 53 |
+
docs/dev.rst
|
| 54 |
+
docs/index.rst
|
| 55 |
+
docs/installation.rst
|
| 56 |
+
docs/intro.rst
|
| 57 |
+
docs/license.rst
|
| 58 |
+
docs/locale.rst
|
| 59 |
+
docs/make.bat
|
| 60 |
+
docs/messages.rst
|
| 61 |
+
docs/numbers.rst
|
| 62 |
+
docs/requirements.txt
|
| 63 |
+
docs/setup.rst
|
| 64 |
+
docs/support.rst
|
| 65 |
+
docs/_static/logo.pdf
|
| 66 |
+
docs/_static/logo.png
|
| 67 |
+
docs/_static/logo_small.png
|
| 68 |
+
docs/_templates/sidebar-about.html
|
| 69 |
+
docs/_templates/sidebar-links.html
|
| 70 |
+
docs/_templates/sidebar-logo.html
|
| 71 |
+
docs/_themes/LICENSE
|
| 72 |
+
docs/_themes/README
|
| 73 |
+
docs/_themes/babel/layout.html
|
| 74 |
+
docs/_themes/babel/relations.html
|
| 75 |
+
docs/_themes/babel/theme.conf
|
| 76 |
+
docs/_themes/babel/static/babel.css_t
|
| 77 |
+
docs/_themes/babel/static/small_babel.css
|
| 78 |
+
docs/api/core.rst
|
| 79 |
+
docs/api/dates.rst
|
| 80 |
+
docs/api/index.rst
|
| 81 |
+
docs/api/languages.rst
|
| 82 |
+
docs/api/lists.rst
|
| 83 |
+
docs/api/numbers.rst
|
| 84 |
+
docs/api/plural.rst
|
| 85 |
+
docs/api/support.rst
|
| 86 |
+
docs/api/units.rst
|
| 87 |
+
docs/api/messages/catalog.rst
|
| 88 |
+
docs/api/messages/extract.rst
|
| 89 |
+
docs/api/messages/index.rst
|
| 90 |
+
docs/api/messages/mofile.rst
|
| 91 |
+
docs/api/messages/pofile.rst
|
| 92 |
+
scripts/download_import_cldr.py
|
| 93 |
+
scripts/dump_data.py
|
| 94 |
+
scripts/dump_global.py
|
| 95 |
+
scripts/generate_authors.py
|
| 96 |
+
scripts/import_cldr.py
|
| 97 |
+
tests/__init__.py
|
| 98 |
+
tests/conftest.py
|
| 99 |
+
tests/test_core.py
|
| 100 |
+
tests/test_date_intervals.py
|
| 101 |
+
tests/test_dates.py
|
| 102 |
+
tests/test_day_periods.py
|
| 103 |
+
tests/test_languages.py
|
| 104 |
+
tests/test_lists.py
|
| 105 |
+
tests/test_localedata.py
|
| 106 |
+
tests/test_localtime.py
|
| 107 |
+
tests/test_numbers.py
|
| 108 |
+
tests/test_plural.py
|
| 109 |
+
tests/test_smoke.py
|
| 110 |
+
tests/test_support.py
|
| 111 |
+
tests/test_util.py
|
| 112 |
+
tests/interop/__init__.py
|
| 113 |
+
tests/interop/test_jinja2_interop.py
|
| 114 |
+
tests/interop/jinja2_data/hello.html
|
| 115 |
+
tests/interop/jinja2_data/mapping.cfg
|
| 116 |
+
tests/messages/__init__.py
|
| 117 |
+
tests/messages/consts.py
|
| 118 |
+
tests/messages/test_catalog.py
|
| 119 |
+
tests/messages/test_checkers.py
|
| 120 |
+
tests/messages/test_extract.py
|
| 121 |
+
tests/messages/test_frontend.py
|
| 122 |
+
tests/messages/test_js_extract.py
|
| 123 |
+
tests/messages/test_jslexer.py
|
| 124 |
+
tests/messages/test_mofile.py
|
| 125 |
+
tests/messages/test_normalized_string.py
|
| 126 |
+
tests/messages/test_plurals.py
|
| 127 |
+
tests/messages/test_pofile.py
|
| 128 |
+
tests/messages/test_setuptools_frontend.py
|
| 129 |
+
tests/messages/test_toml_config.py
|
| 130 |
+
tests/messages/data/mapping.cfg
|
| 131 |
+
tests/messages/data/setup.cfg
|
| 132 |
+
tests/messages/data/setup.py
|
| 133 |
+
tests/messages/data/project/__init__.py
|
| 134 |
+
tests/messages/data/project/file1.py
|
| 135 |
+
tests/messages/data/project/file2.py
|
| 136 |
+
tests/messages/data/project/_hidden_by_default/hidden_file.py
|
| 137 |
+
tests/messages/data/project/i18n/messages.pot
|
| 138 |
+
tests/messages/data/project/i18n/messages_non_fuzzy.pot
|
| 139 |
+
tests/messages/data/project/i18n/de/LC_MESSAGES/messages.mo
|
| 140 |
+
tests/messages/data/project/i18n/de/LC_MESSAGES/messages.po
|
| 141 |
+
tests/messages/data/project/i18n/de_DE/LC_MESSAGES/bar.po
|
| 142 |
+
tests/messages/data/project/i18n/de_DE/LC_MESSAGES/foo.po
|
| 143 |
+
tests/messages/data/project/i18n/de_DE/LC_MESSAGES/messages.po
|
| 144 |
+
tests/messages/data/project/i18n/fi_BUGGY/LC_MESSAGES/messages.po
|
| 145 |
+
tests/messages/data/project/i18n/ru_RU/LC_MESSAGES/messages.po
|
| 146 |
+
tests/messages/data/project/ignored/a_test_file.txt
|
| 147 |
+
tests/messages/data/project/ignored/an_example.txt
|
| 148 |
+
tests/messages/data/project/ignored/this_wont_normally_be_here.py
|
| 149 |
+
tests/messages/toml-test-cases/bad.extractor.toml
|
| 150 |
+
tests/messages/toml-test-cases/bad.extractors-not-a-dict.toml
|
| 151 |
+
tests/messages/toml-test-cases/bad.just-a-mapping.toml
|
| 152 |
+
tests/messages/toml-test-cases/bad.mapping-not-a-dict.toml
|
| 153 |
+
tests/messages/toml-test-cases/bad.mappings-not-a-list.toml
|
| 154 |
+
tests/messages/toml-test-cases/bad.missing-extraction-method.toml
|
| 155 |
+
tests/messages/toml-test-cases/bad.multiple-mappings-not-a-list.toml
|
| 156 |
+
tests/messages/toml-test-cases/bad.non-string-extraction-method.toml
|
| 157 |
+
tests/messages/toml-test-cases/bad.pattern-type-2.toml
|
| 158 |
+
tests/messages/toml-test-cases/bad.pattern-type.toml
|
| 159 |
+
tests/messages/toml-test-cases/bad.pyproject-without-tool-babel.toml
|
| 160 |
+
tests/messages/toml-test-cases/bad.standalone-with-babel-prefix.toml
|
SPFsmartGATE/LIVE/TMP/babel/babel.egg-info/dependency_links.txt
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
|
SPFsmartGATE/LIVE/TMP/babel/babel.egg-info/entry_points.txt
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
[babel.checkers]
|
| 2 |
+
num_plurals = babel.messages.checkers:num_plurals
|
| 3 |
+
python_format = babel.messages.checkers:python_format
|
| 4 |
+
|
| 5 |
+
[babel.extractors]
|
| 6 |
+
ignore = babel.messages.extract:extract_nothing
|
| 7 |
+
javascript = babel.messages.extract:extract_javascript
|
| 8 |
+
python = babel.messages.extract:extract_python
|
| 9 |
+
|
| 10 |
+
[console_scripts]
|
| 11 |
+
pybabel = babel.messages.frontend:main
|
| 12 |
+
|
| 13 |
+
[distutils.commands]
|
| 14 |
+
compile_catalog = babel.messages.setuptools_frontend:compile_catalog
|
| 15 |
+
extract_messages = babel.messages.setuptools_frontend:extract_messages
|
| 16 |
+
init_catalog = babel.messages.setuptools_frontend:init_catalog
|
| 17 |
+
update_catalog = babel.messages.setuptools_frontend:update_catalog
|
| 18 |
+
|
| 19 |
+
[distutils.setup_keywords]
|
| 20 |
+
message_extractors = babel.messages.setuptools_frontend:check_message_extractors
|
SPFsmartGATE/LIVE/TMP/babel/babel.egg-info/not-zip-safe
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
|
SPFsmartGATE/LIVE/TMP/babel/babel.egg-info/requires.txt
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
[:python_version < "3.9"]
|
| 3 |
+
pytz>=2015.7
|
| 4 |
+
|
| 5 |
+
[dev]
|
| 6 |
+
pytest>=6.0
|
| 7 |
+
pytest-cov
|
| 8 |
+
freezegun~=1.0
|
SPFsmartGATE/LIVE/TMP/babel/babel.egg-info/top_level.txt
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
babel
|
SPFsmartGATE/LIVE/TMP/babel/cldr/.gitignore
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
*
|
SPFsmartGATE/LIVE/TMP/babel/docs/changelog.rst
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
.. include:: ../CHANGES.rst
|
SPFsmartGATE/LIVE/TMP/babel/docs/index.rst
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
.. -*- mode: rst; encoding: utf-8 -*-
|
| 2 |
+
|
| 3 |
+
Babel
|
| 4 |
+
=====
|
| 5 |
+
|
| 6 |
+
Babel is an integrated collection of utilities that assist in
|
| 7 |
+
internationalizing and localizing Python applications, with an emphasis on
|
| 8 |
+
web-based applications.
|
| 9 |
+
|
| 10 |
+
User Documentation
|
| 11 |
+
------------------
|
| 12 |
+
|
| 13 |
+
The user documentation explains some core concept of the library and gives
|
| 14 |
+
some information about how it can be used.
|
| 15 |
+
|
| 16 |
+
.. toctree::
|
| 17 |
+
:maxdepth: 1
|
| 18 |
+
|
| 19 |
+
intro
|
| 20 |
+
installation
|
| 21 |
+
locale
|
| 22 |
+
dates
|
| 23 |
+
numbers
|
| 24 |
+
messages
|
| 25 |
+
cmdline
|
| 26 |
+
setup
|
| 27 |
+
support
|
| 28 |
+
|
| 29 |
+
API Reference
|
| 30 |
+
-------------
|
| 31 |
+
|
| 32 |
+
The API reference lists the full public API that Babel provides.
|
| 33 |
+
|
| 34 |
+
.. toctree::
|
| 35 |
+
:maxdepth: 2
|
| 36 |
+
|
| 37 |
+
api/index
|
| 38 |
+
|
| 39 |
+
Additional Notes
|
| 40 |
+
----------------
|
| 41 |
+
|
| 42 |
+
.. toctree::
|
| 43 |
+
:maxdepth: 2
|
| 44 |
+
|
| 45 |
+
dev
|
| 46 |
+
changelog
|
| 47 |
+
license
|
SPFsmartGATE/LIVE/TMP/babel/docs/installation.rst
ADDED
|
@@ -0,0 +1,99 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
.. _installation:
|
| 2 |
+
|
| 3 |
+
Installation
|
| 4 |
+
============
|
| 5 |
+
|
| 6 |
+
Babel is distributed as a standard Python package fully set up with all
|
| 7 |
+
the dependencies it needs. On Python versions where the standard library
|
| 8 |
+
`zoneinfo`_ module is not available, `pytz`_ needs to be installed for
|
| 9 |
+
timezone support. If `pytz`_ is installed, it is preferred over the
|
| 10 |
+
standard library `zoneinfo`_ module where possible.
|
| 11 |
+
|
| 12 |
+
.. _pytz: https://pythonhosted.org/pytz/
|
| 13 |
+
|
| 14 |
+
.. _zoneinfo: https://docs.python.org/3/library/zoneinfo.html
|
| 15 |
+
|
| 16 |
+
.. _virtualenv:
|
| 17 |
+
|
| 18 |
+
virtualenv
|
| 19 |
+
----------
|
| 20 |
+
|
| 21 |
+
Virtualenv is probably what you want to use during development, and if you
|
| 22 |
+
have shell access to your production machines, you'll probably want to use
|
| 23 |
+
it there, too. Use ``pip`` to install it::
|
| 24 |
+
|
| 25 |
+
$ sudo pip install virtualenv
|
| 26 |
+
|
| 27 |
+
If you're on Windows, run it in a command-prompt window with administrator
|
| 28 |
+
privileges, and leave out ``sudo``.
|
| 29 |
+
|
| 30 |
+
Once you have virtualenv installed, just fire up a shell and create
|
| 31 |
+
your own environment. I usually create a project folder and a `venv`
|
| 32 |
+
folder within::
|
| 33 |
+
|
| 34 |
+
$ mkdir myproject
|
| 35 |
+
$ cd myproject
|
| 36 |
+
$ virtualenv venv
|
| 37 |
+
New python executable in venv/bin/python
|
| 38 |
+
Installing distribute............done.
|
| 39 |
+
|
| 40 |
+
Now, whenever you want to work on a project, you only have to activate the
|
| 41 |
+
corresponding environment. On OS X and Linux, do the following::
|
| 42 |
+
|
| 43 |
+
$ . venv/bin/activate
|
| 44 |
+
|
| 45 |
+
If you are a Windows user, the following command is for you::
|
| 46 |
+
|
| 47 |
+
$ venv\scripts\activate
|
| 48 |
+
|
| 49 |
+
Either way, you should now be using your virtualenv (notice how the prompt of
|
| 50 |
+
your shell has changed to show the active environment).
|
| 51 |
+
|
| 52 |
+
Now you can just enter the following command to get Babel installed in your
|
| 53 |
+
virtualenv::
|
| 54 |
+
|
| 55 |
+
$ pip install Babel
|
| 56 |
+
|
| 57 |
+
A few seconds later and you are good to go.
|
| 58 |
+
|
| 59 |
+
System-Wide Installation
|
| 60 |
+
------------------------
|
| 61 |
+
|
| 62 |
+
This is possible as well, though I do not recommend it. Just run `pip`
|
| 63 |
+
with root privileges::
|
| 64 |
+
|
| 65 |
+
$ sudo pip install Babel
|
| 66 |
+
|
| 67 |
+
(On Windows systems, run it in a command-prompt window with administrator
|
| 68 |
+
privileges, and leave out `sudo`.)
|
| 69 |
+
|
| 70 |
+
|
| 71 |
+
Living on the Edge
|
| 72 |
+
------------------
|
| 73 |
+
|
| 74 |
+
If you want to work with the latest version of Babel, you will need to
|
| 75 |
+
use a git checkout.
|
| 76 |
+
|
| 77 |
+
Get the git checkout in a new virtualenv and run in development mode::
|
| 78 |
+
|
| 79 |
+
$ git clone https://github.com/python-babel/babel
|
| 80 |
+
Initialized empty Git repository in ~/dev/babel/.git/
|
| 81 |
+
$ cd babel
|
| 82 |
+
$ virtualenv venv
|
| 83 |
+
New python executable in venv/bin/python
|
| 84 |
+
Installing distribute............done.
|
| 85 |
+
$ . venv/bin/activate
|
| 86 |
+
$ python setup.py import_cldr
|
| 87 |
+
$ pip install --editable .
|
| 88 |
+
...
|
| 89 |
+
Finished processing dependencies for Babel
|
| 90 |
+
|
| 91 |
+
Make sure to not forget about the ``import_cldr`` step because otherwise
|
| 92 |
+
you will be missing the locale data.
|
| 93 |
+
The custom setup command will download the most appropriate CLDR release from the
|
| 94 |
+
official website and convert it for Babel.
|
| 95 |
+
|
| 96 |
+
This will pull also in the dependencies and activate the git head as the
|
| 97 |
+
current version inside the virtualenv. Then all you have to do is run
|
| 98 |
+
``git pull origin`` to update to the latest version. If the CLDR data
|
| 99 |
+
changes you will have to re-run ``python setup.py import_cldr``.
|
SPFsmartGATE/LIVE/TMP/babel/docs/numbers.rst
ADDED
|
@@ -0,0 +1,183 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
.. -*- mode: rst; encoding: utf-8 -*-
|
| 2 |
+
|
| 3 |
+
.. _numbers:
|
| 4 |
+
|
| 5 |
+
=================
|
| 6 |
+
Number Formatting
|
| 7 |
+
=================
|
| 8 |
+
|
| 9 |
+
|
| 10 |
+
Support for locale-specific formatting and parsing of numbers is provided by
|
| 11 |
+
the ``babel.numbers`` module:
|
| 12 |
+
|
| 13 |
+
.. code-block:: pycon
|
| 14 |
+
|
| 15 |
+
>>> from babel.numbers import format_number, format_decimal, format_compact_decimal, format_percent
|
| 16 |
+
|
| 17 |
+
Examples:
|
| 18 |
+
|
| 19 |
+
.. code-block:: pycon
|
| 20 |
+
|
| 21 |
+
# Numbers with decimal places
|
| 22 |
+
>>> format_decimal(1.2345, locale='en_US')
|
| 23 |
+
u'1.234'
|
| 24 |
+
>>> format_decimal(1.2345, locale='sv_SE')
|
| 25 |
+
u'1,234'
|
| 26 |
+
# Integers with thousand grouping
|
| 27 |
+
>>> format_decimal(12345, locale='de_DE')
|
| 28 |
+
u'12.345'
|
| 29 |
+
>>> format_decimal(12345678, locale='de_DE')
|
| 30 |
+
u'12.345.678'
|
| 31 |
+
|
| 32 |
+
Pattern Syntax
|
| 33 |
+
==============
|
| 34 |
+
|
| 35 |
+
While Babel makes it simple to use the appropriate number format for a given
|
| 36 |
+
locale, you can also force it to use custom patterns. As with date/time
|
| 37 |
+
formatting patterns, the patterns Babel supports for number formatting are
|
| 38 |
+
based on the `Locale Data Markup Language specification`_ (LDML).
|
| 39 |
+
|
| 40 |
+
Examples:
|
| 41 |
+
|
| 42 |
+
.. code-block:: pycon
|
| 43 |
+
|
| 44 |
+
>>> format_decimal(-1.2345, format='#,##0.##;-#', locale='en')
|
| 45 |
+
u'-1.23'
|
| 46 |
+
>>> format_decimal(-1.2345, format='#,##0.##;(#)', locale='en')
|
| 47 |
+
u'(1.23)'
|
| 48 |
+
|
| 49 |
+
The syntax for custom number format patterns is described in detail in the
|
| 50 |
+
the specification. The following table is just a relatively brief overview.
|
| 51 |
+
|
| 52 |
+
.. _`Locale Data Markup Language specification`:
|
| 53 |
+
https://unicode.org/reports/tr35/#Number_Format_Patterns
|
| 54 |
+
|
| 55 |
+
+----------+-----------------------------------------------------------------+
|
| 56 |
+
| Symbol | Description |
|
| 57 |
+
+==========+=================================================================+
|
| 58 |
+
| ``0`` | Digit |
|
| 59 |
+
+----------+-----------------------------------------------------------------+
|
| 60 |
+
| ``1-9`` | '1' through '9' indicate rounding. |
|
| 61 |
+
+----------+-----------------------------------------------------------------+
|
| 62 |
+
| ``@`` | Significant digit |
|
| 63 |
+
+----------+-----------------------------------------------------------------+
|
| 64 |
+
| ``#`` | Digit, zero shows as absent |
|
| 65 |
+
+----------+-----------------------------------------------------------------+
|
| 66 |
+
| ``.`` | Decimal separator or monetary decimal separator |
|
| 67 |
+
+----------+-----------------------------------------------------------------+
|
| 68 |
+
| ``-`` | Minus sign |
|
| 69 |
+
+----------+-----------------------------------------------------------------+
|
| 70 |
+
| ``,`` | Grouping separator |
|
| 71 |
+
+----------+-----------------------------------------------------------------+
|
| 72 |
+
| ``E`` | Separates mantissa and exponent in scientific notation |
|
| 73 |
+
+----------+-----------------------------------------------------------------+
|
| 74 |
+
| ``+`` | Prefix positive exponents with localized plus sign |
|
| 75 |
+
+----------+-----------------------------------------------------------------+
|
| 76 |
+
| ``;`` | Separates positive and negative subpatterns |
|
| 77 |
+
+----------+-----------------------------------------------------------------+
|
| 78 |
+
| ``%`` | Multiply by 100 and show as percentage |
|
| 79 |
+
+----------+-----------------------------------------------------------------+
|
| 80 |
+
| ``‰`` | Multiply by 1000 and show as per mille |
|
| 81 |
+
+----------+-----------------------------------------------------------------+
|
| 82 |
+
| ``¤`` | Currency sign, replaced by currency symbol. If doubled, |
|
| 83 |
+
| | replaced by international currency symbol. If tripled, uses the |
|
| 84 |
+
| | long form of the decimal symbol. |
|
| 85 |
+
+----------+-----------------------------------------------------------------+
|
| 86 |
+
| ``'`` | Used to quote special characters in a prefix or suffix |
|
| 87 |
+
+----------+-----------------------------------------------------------------+
|
| 88 |
+
| ``*`` | Pad escape, precedes pad character |
|
| 89 |
+
+----------+-----------------------------------------------------------------+
|
| 90 |
+
|
| 91 |
+
|
| 92 |
+
Rounding Modes
|
| 93 |
+
==============
|
| 94 |
+
|
| 95 |
+
Since Babel makes full use of Python's `Decimal`_ type to perform number
|
| 96 |
+
rounding before formatting, users have the chance to control the rounding mode
|
| 97 |
+
and other configurable parameters through the active `Context`_ instance.
|
| 98 |
+
|
| 99 |
+
By default, Python rounding mode is ``ROUND_HALF_EVEN`` which complies with
|
| 100 |
+
`UTS #35 section 3.3`_. Yet, the caller has the opportunity to tweak the
|
| 101 |
+
current context before formatting a number or currency:
|
| 102 |
+
|
| 103 |
+
.. code-block:: pycon
|
| 104 |
+
|
| 105 |
+
>>> from babel.numbers import decimal, format_decimal
|
| 106 |
+
>>> with decimal.localcontext(decimal.Context(rounding=decimal.ROUND_DOWN)):
|
| 107 |
+
>>> txt = format_decimal(123.99, format='#', locale='en_US')
|
| 108 |
+
>>> txt
|
| 109 |
+
u'123'
|
| 110 |
+
|
| 111 |
+
It is also possible to use ``decimal.setcontext`` or directly modifying the
|
| 112 |
+
instance returned by ``decimal.getcontext``. However, using a context manager
|
| 113 |
+
is always more convenient due to the automatic restoration and the ability to
|
| 114 |
+
nest them.
|
| 115 |
+
|
| 116 |
+
Whatever mechanism is chosen, always make use of the ``decimal`` module imported
|
| 117 |
+
from ``babel.numbers``. For efficiency reasons, Babel uses the fastest decimal
|
| 118 |
+
implementation available, such as `cdecimal`_. These various implementation
|
| 119 |
+
offer an identical API, but their types and instances do **not** interoperate
|
| 120 |
+
with each other.
|
| 121 |
+
|
| 122 |
+
For example, the previous example can be slightly modified to generate
|
| 123 |
+
unexpected results on Python 2.7, with the `cdecimal`_ module installed:
|
| 124 |
+
|
| 125 |
+
.. code-block:: pycon
|
| 126 |
+
|
| 127 |
+
>>> from decimal import localcontext, Context, ROUND_DOWN
|
| 128 |
+
>>> from babel.numbers import format_decimal
|
| 129 |
+
>>> with localcontext(Context(rounding=ROUND_DOWN)):
|
| 130 |
+
>>> txt = format_decimal(123.99, format='#', locale='en_US')
|
| 131 |
+
>>> txt
|
| 132 |
+
u'124'
|
| 133 |
+
|
| 134 |
+
Changing other parameters such as the precision may also alter the results of
|
| 135 |
+
the number formatting functions. Remember to test your code to make sure it
|
| 136 |
+
behaves as desired.
|
| 137 |
+
|
| 138 |
+
.. _Decimal: https://docs.python.org/3/library/decimal.html#decimal-objects
|
| 139 |
+
.. _Context: https://docs.python.org/3/library/decimal.html#context-objects
|
| 140 |
+
.. _`UTS #35 section 3.3`: https://www.unicode.org/reports/tr35/tr35-numbers.html#Formatting
|
| 141 |
+
.. _cdecimal: https://pypi.org/project/cdecimal/
|
| 142 |
+
|
| 143 |
+
|
| 144 |
+
Parsing Numbers
|
| 145 |
+
===============
|
| 146 |
+
|
| 147 |
+
Babel can also parse numeric data in a locale-sensitive manner:
|
| 148 |
+
|
| 149 |
+
.. code-block:: pycon
|
| 150 |
+
|
| 151 |
+
>>> from babel.numbers import parse_decimal, parse_number
|
| 152 |
+
|
| 153 |
+
Examples:
|
| 154 |
+
|
| 155 |
+
.. code-block:: pycon
|
| 156 |
+
|
| 157 |
+
>>> parse_decimal('1,099.98', locale='en_US')
|
| 158 |
+
1099.98
|
| 159 |
+
>>> parse_decimal('1.099,98', locale='de')
|
| 160 |
+
1099.98
|
| 161 |
+
>>> parse_decimal('2,109,998', locale='de')
|
| 162 |
+
Traceback (most recent call last):
|
| 163 |
+
...
|
| 164 |
+
NumberFormatError: '2,109,998' is not a valid decimal number
|
| 165 |
+
|
| 166 |
+
Note: as of version 2.8.0, the ``parse_number`` function has limited
|
| 167 |
+
functionality. It can remove group symbols of certain locales from numeric
|
| 168 |
+
strings, but may behave unexpectedly until its logic handles more encoding
|
| 169 |
+
issues and other special cases.
|
| 170 |
+
|
| 171 |
+
Examples:
|
| 172 |
+
|
| 173 |
+
.. code-block:: pycon
|
| 174 |
+
|
| 175 |
+
>>> parse_number('1,099', locale='en_US')
|
| 176 |
+
1099
|
| 177 |
+
>>> parse_number('1.099.024', locale='de')
|
| 178 |
+
1099024
|
| 179 |
+
>>> parse_number('123' + u'\xa0' + '4567', locale='ru')
|
| 180 |
+
1234567
|
| 181 |
+
>>> parse_number('123 4567', locale='ru')
|
| 182 |
+
...
|
| 183 |
+
NumberFormatError: '123 4567' is not a valid number
|
SPFsmartGATE/LIVE/TMP/babel/docs/requirements.txt
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
Sphinx~=5.3.0
|
SPFsmartGATE/LIVE/TMP/babel/scripts/download_import_cldr.py
ADDED
|
@@ -0,0 +1,88 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env python3
|
| 2 |
+
|
| 3 |
+
import contextlib
|
| 4 |
+
import hashlib
|
| 5 |
+
import os
|
| 6 |
+
import shutil
|
| 7 |
+
import subprocess
|
| 8 |
+
import sys
|
| 9 |
+
import zipfile
|
| 10 |
+
from urllib.request import urlretrieve
|
| 11 |
+
|
| 12 |
+
URL = 'https://unicode.org/Public/cldr/45/cldr-common-45.0.zip'
|
| 13 |
+
FILENAME = 'cldr-common-45.0.zip'
|
| 14 |
+
# Via https://unicode.org/Public/cldr/45/hashes/SHASUM512.txt
|
| 15 |
+
FILESUM = '638123882bd29911fc9492ec152926572fec48eb6c1f5dd706aee3e59cad8be4963a334bb7a09a645dbedc3356f60ef7ac2ef7ab4ccf2c8926b547782175603c'
|
| 16 |
+
BLKSIZE = 131072
|
| 17 |
+
|
| 18 |
+
|
| 19 |
+
def reporthook(block_count, block_size, total_size):
|
| 20 |
+
bytes_transmitted = block_count * block_size
|
| 21 |
+
cols = shutil.get_terminal_size().columns
|
| 22 |
+
buffer = 6
|
| 23 |
+
percent = float(bytes_transmitted) / (total_size or 1)
|
| 24 |
+
done = int(percent * (cols - buffer))
|
| 25 |
+
bar = ('=' * done).ljust(cols - buffer)
|
| 26 |
+
sys.stdout.write(f'\r{bar}{int(percent * 100): 4d}%')
|
| 27 |
+
sys.stdout.flush()
|
| 28 |
+
|
| 29 |
+
|
| 30 |
+
def log(message):
|
| 31 |
+
sys.stderr.write(f'{message}\n')
|
| 32 |
+
|
| 33 |
+
|
| 34 |
+
def is_good_file(filename):
|
| 35 |
+
if not os.path.isfile(filename):
|
| 36 |
+
log(f"Local copy '{filename}' not found")
|
| 37 |
+
return False
|
| 38 |
+
h = hashlib.sha512()
|
| 39 |
+
with open(filename, 'rb') as f:
|
| 40 |
+
while True:
|
| 41 |
+
blk = f.read(BLKSIZE)
|
| 42 |
+
if not blk:
|
| 43 |
+
break
|
| 44 |
+
h.update(blk)
|
| 45 |
+
digest = h.hexdigest()
|
| 46 |
+
if digest != FILESUM:
|
| 47 |
+
raise RuntimeError(f'Checksum mismatch: {digest!r} != {FILESUM!r}')
|
| 48 |
+
else:
|
| 49 |
+
return True
|
| 50 |
+
|
| 51 |
+
|
| 52 |
+
def main():
|
| 53 |
+
scripts_path = os.path.dirname(os.path.abspath(__file__))
|
| 54 |
+
repo = os.path.dirname(scripts_path)
|
| 55 |
+
cldr_dl_path = os.path.join(repo, 'cldr')
|
| 56 |
+
cldr_path = os.path.join(repo, 'cldr', os.path.splitext(FILENAME)[0])
|
| 57 |
+
zip_path = os.path.join(cldr_dl_path, FILENAME)
|
| 58 |
+
changed = False
|
| 59 |
+
show_progress = (False if os.environ.get("BABEL_CLDR_NO_DOWNLOAD_PROGRESS") else sys.stdout.isatty())
|
| 60 |
+
|
| 61 |
+
while not is_good_file(zip_path):
|
| 62 |
+
log(f"Downloading '{FILENAME}' from {URL}")
|
| 63 |
+
tmp_path = f"{zip_path}.tmp"
|
| 64 |
+
urlretrieve(URL, tmp_path, (reporthook if show_progress else None))
|
| 65 |
+
os.replace(tmp_path, zip_path)
|
| 66 |
+
changed = True
|
| 67 |
+
print()
|
| 68 |
+
common_path = os.path.join(cldr_path, 'common')
|
| 69 |
+
|
| 70 |
+
if changed or not os.path.isdir(common_path):
|
| 71 |
+
if os.path.isdir(common_path):
|
| 72 |
+
log(f"Deleting old CLDR checkout in '{cldr_path}'")
|
| 73 |
+
shutil.rmtree(common_path)
|
| 74 |
+
|
| 75 |
+
log(f"Extracting CLDR to '{cldr_path}'")
|
| 76 |
+
with contextlib.closing(zipfile.ZipFile(zip_path)) as z:
|
| 77 |
+
z.extractall(cldr_path)
|
| 78 |
+
|
| 79 |
+
subprocess.check_call([
|
| 80 |
+
sys.executable,
|
| 81 |
+
os.path.join(scripts_path, 'import_cldr.py'),
|
| 82 |
+
common_path,
|
| 83 |
+
*sys.argv[1:],
|
| 84 |
+
])
|
| 85 |
+
|
| 86 |
+
|
| 87 |
+
if __name__ == '__main__':
|
| 88 |
+
main()
|
SPFsmartGATE/LIVE/TMP/babel/scripts/dump_data.py
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env python
|
| 2 |
+
#
|
| 3 |
+
# Copyright (C) 2007-2011 Edgewall Software, 2013-2024 the Babel team
|
| 4 |
+
# All rights reserved.
|
| 5 |
+
#
|
| 6 |
+
# This software is licensed as described in the file LICENSE, which
|
| 7 |
+
# you should have received as part of this distribution. The terms
|
| 8 |
+
# are also available at http://babel.edgewall.org/wiki/License.
|
| 9 |
+
#
|
| 10 |
+
# This software consists of voluntary contributions made by many
|
| 11 |
+
# individuals. For the exact contribution history, see the revision
|
| 12 |
+
# history and logs, available at http://babel.edgewall.org/log/.
|
| 13 |
+
|
| 14 |
+
from optparse import OptionParser
|
| 15 |
+
from pprint import pprint
|
| 16 |
+
|
| 17 |
+
from babel.localedata import LocaleDataDict, load
|
| 18 |
+
|
| 19 |
+
|
| 20 |
+
def main():
|
| 21 |
+
parser = OptionParser(usage='%prog [options] locale [path]')
|
| 22 |
+
parser.add_option('--noinherit', action='store_false', dest='inherit',
|
| 23 |
+
help='do not merge inherited data into locale data')
|
| 24 |
+
parser.add_option('--resolve', action='store_true', dest='resolve',
|
| 25 |
+
help='resolve aliases in locale data')
|
| 26 |
+
parser.set_defaults(inherit=True, resolve=False)
|
| 27 |
+
options, args = parser.parse_args()
|
| 28 |
+
if len(args) not in (1, 2):
|
| 29 |
+
parser.error('incorrect number of arguments')
|
| 30 |
+
|
| 31 |
+
data = load(args[0], merge_inherited=options.inherit)
|
| 32 |
+
if options.resolve:
|
| 33 |
+
data = LocaleDataDict(data)
|
| 34 |
+
if len(args) > 1:
|
| 35 |
+
for key in args[1].split('.'):
|
| 36 |
+
data = data[key]
|
| 37 |
+
if isinstance(data, dict):
|
| 38 |
+
data = dict(data.items())
|
| 39 |
+
pprint(data)
|
| 40 |
+
|
| 41 |
+
|
| 42 |
+
if __name__ == '__main__':
|
| 43 |
+
main()
|
SPFsmartGATE/LIVE/TMP/babel/scripts/dump_global.py
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env python
|
| 2 |
+
#
|
| 3 |
+
# Copyright (C) 2007-2011 Edgewall Software, 2013-2024 the Babel team
|
| 4 |
+
# All rights reserved.
|
| 5 |
+
#
|
| 6 |
+
# This software is licensed as described in the file LICENSE, which
|
| 7 |
+
# you should have received as part of this distribution. The terms
|
| 8 |
+
# are also available at http://babel.edgewall.org/wiki/License.
|
| 9 |
+
#
|
| 10 |
+
# This software consists of voluntary contributions made by many
|
| 11 |
+
# individuals. For the exact contribution history, see the revision
|
| 12 |
+
# history and logs, available at http://babel.edgewall.org/log/.
|
| 13 |
+
|
| 14 |
+
import os
|
| 15 |
+
import sys
|
| 16 |
+
from pprint import pprint
|
| 17 |
+
|
| 18 |
+
import cPickle as pickle
|
| 19 |
+
|
| 20 |
+
import babel
|
| 21 |
+
|
| 22 |
+
dirname = os.path.join(os.path.dirname(babel.__file__))
|
| 23 |
+
filename = os.path.join(dirname, 'global.dat')
|
| 24 |
+
with open(filename, 'rb') as fileobj:
|
| 25 |
+
data = pickle.load(fileobj)
|
| 26 |
+
|
| 27 |
+
if len(sys.argv) > 1:
|
| 28 |
+
pprint(data.get(sys.argv[1]))
|
| 29 |
+
else:
|
| 30 |
+
pprint(data)
|
SPFsmartGATE/LIVE/TMP/babel/scripts/generate_authors.py
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import os
|
| 2 |
+
from collections import Counter
|
| 3 |
+
from subprocess import check_output
|
| 4 |
+
|
| 5 |
+
root_path = os.path.realpath(os.path.join(os.path.dirname(__file__), '..'))
|
| 6 |
+
|
| 7 |
+
|
| 8 |
+
def get_sorted_authors_list():
|
| 9 |
+
authors = check_output(['git', 'log', '--format=%aN'], cwd=root_path).decode('UTF-8')
|
| 10 |
+
counts = Counter(authors.splitlines())
|
| 11 |
+
return [author for (author, count) in counts.most_common()]
|
| 12 |
+
|
| 13 |
+
|
| 14 |
+
def get_authors_file_content():
|
| 15 |
+
author_list = "\n".join(f"- {a}" for a in get_sorted_authors_list())
|
| 16 |
+
|
| 17 |
+
return f'''
|
| 18 |
+
Babel is written and maintained by the Babel team and various contributors:
|
| 19 |
+
|
| 20 |
+
{author_list}
|
| 21 |
+
|
| 22 |
+
Babel was previously developed under the Copyright of Edgewall Software. The
|
| 23 |
+
following copyright notice holds true for releases before 2013: "Copyright (c)
|
| 24 |
+
2007 - 2011 by Edgewall Software"
|
| 25 |
+
|
| 26 |
+
In addition to the regular contributions Babel includes a fork of Lennart
|
| 27 |
+
Regebro's tzlocal that originally was licensed under the CC0 license. The
|
| 28 |
+
original copyright of that project is "Copyright 2013 by Lennart Regebro".
|
| 29 |
+
'''
|
| 30 |
+
|
| 31 |
+
|
| 32 |
+
def write_authors_file():
|
| 33 |
+
content = get_authors_file_content()
|
| 34 |
+
with open(os.path.join(root_path, 'AUTHORS'), 'w', encoding='UTF-8') as fp:
|
| 35 |
+
fp.write(content)
|
| 36 |
+
|
| 37 |
+
|
| 38 |
+
if __name__ == '__main__':
|
| 39 |
+
write_authors_file()
|
SPFsmartGATE/LIVE/TMP/babel/scripts/import_cldr.py
ADDED
|
@@ -0,0 +1,1042 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env python
|
| 2 |
+
#
|
| 3 |
+
# Copyright (C) 2007-2011 Edgewall Software, 2013-2024 the Babel team
|
| 4 |
+
# All rights reserved.
|
| 5 |
+
#
|
| 6 |
+
# This software is licensed as described in the file LICENSE, which
|
| 7 |
+
# you should have received as part of this distribution. The terms
|
| 8 |
+
# are also available at http://babel.edgewall.org/wiki/License.
|
| 9 |
+
#
|
| 10 |
+
# This software consists of voluntary contributions made by many
|
| 11 |
+
# individuals. For the exact contribution history, see the revision
|
| 12 |
+
# history and logs, available at http://babel.edgewall.org/log/.
|
| 13 |
+
|
| 14 |
+
import collections
|
| 15 |
+
import logging
|
| 16 |
+
import os
|
| 17 |
+
import pickle
|
| 18 |
+
import re
|
| 19 |
+
import sys
|
| 20 |
+
from optparse import OptionParser
|
| 21 |
+
from xml.etree import ElementTree
|
| 22 |
+
|
| 23 |
+
# Make sure we're using Babel source, and not some previously installed version
|
| 24 |
+
CHECKOUT_ROOT = os.path.abspath(os.path.join(
|
| 25 |
+
os.path.dirname(__file__),
|
| 26 |
+
'..',
|
| 27 |
+
))
|
| 28 |
+
BABEL_PACKAGE_ROOT = os.path.join(CHECKOUT_ROOT, "babel")
|
| 29 |
+
sys.path.insert(0, CHECKOUT_ROOT)
|
| 30 |
+
|
| 31 |
+
from babel import dates, numbers
|
| 32 |
+
from babel.dates import split_interval_pattern
|
| 33 |
+
from babel.localedata import Alias
|
| 34 |
+
from babel.plural import PluralRule
|
| 35 |
+
|
| 36 |
+
parse = ElementTree.parse
|
| 37 |
+
weekdays = {'mon': 0, 'tue': 1, 'wed': 2, 'thu': 3, 'fri': 4, 'sat': 5,
|
| 38 |
+
'sun': 6}
|
| 39 |
+
|
| 40 |
+
|
| 41 |
+
def _text(elem):
|
| 42 |
+
buf = [elem.text or '']
|
| 43 |
+
for child in elem:
|
| 44 |
+
buf.append(_text(child))
|
| 45 |
+
buf.append(elem.tail or '')
|
| 46 |
+
return ''.join(filter(None, buf)).strip()
|
| 47 |
+
|
| 48 |
+
|
| 49 |
+
NAME_RE = re.compile(r"^\w+$")
|
| 50 |
+
TYPE_ATTR_RE = re.compile(r"^\w+\[@type='(.*?)'\]$")
|
| 51 |
+
|
| 52 |
+
NAME_MAP = {
|
| 53 |
+
'dateFormats': 'date_formats',
|
| 54 |
+
'dateTimeFormats': 'datetime_formats',
|
| 55 |
+
'eraAbbr': 'abbreviated',
|
| 56 |
+
'eraNames': 'wide',
|
| 57 |
+
'eraNarrow': 'narrow',
|
| 58 |
+
'timeFormats': 'time_formats',
|
| 59 |
+
}
|
| 60 |
+
|
| 61 |
+
log = logging.getLogger("import_cldr")
|
| 62 |
+
|
| 63 |
+
|
| 64 |
+
def need_conversion(dst_filename, data_dict, source_filename):
|
| 65 |
+
with open(source_filename, 'rb') as f:
|
| 66 |
+
blob = f.read(4096)
|
| 67 |
+
version_match = re.search(b'version number="\\$Revision: (\\d+)', blob)
|
| 68 |
+
if not version_match: # CLDR 36.0 was shipped without proper revision numbers
|
| 69 |
+
return True
|
| 70 |
+
version = int(version_match.group(1))
|
| 71 |
+
|
| 72 |
+
data_dict['_version'] = version
|
| 73 |
+
if not os.path.isfile(dst_filename):
|
| 74 |
+
return True
|
| 75 |
+
|
| 76 |
+
with open(dst_filename, 'rb') as f:
|
| 77 |
+
data = pickle.load(f)
|
| 78 |
+
return data.get('_version') != version
|
| 79 |
+
|
| 80 |
+
|
| 81 |
+
def _translate_alias(ctxt, path):
|
| 82 |
+
parts = path.split('/')
|
| 83 |
+
keys = ctxt[:]
|
| 84 |
+
for part in parts:
|
| 85 |
+
if part == '..':
|
| 86 |
+
keys.pop()
|
| 87 |
+
else:
|
| 88 |
+
match = TYPE_ATTR_RE.match(part)
|
| 89 |
+
if match:
|
| 90 |
+
keys.append(match.group(1))
|
| 91 |
+
else:
|
| 92 |
+
assert NAME_RE.match(part)
|
| 93 |
+
keys.append(NAME_MAP.get(part, part))
|
| 94 |
+
return keys
|
| 95 |
+
|
| 96 |
+
|
| 97 |
+
def _parse_currency_date(s):
|
| 98 |
+
if not s:
|
| 99 |
+
return None
|
| 100 |
+
parts = s.split('-', 2)
|
| 101 |
+
return tuple(map(int, parts + [1] * (3 - len(parts))))
|
| 102 |
+
|
| 103 |
+
|
| 104 |
+
def _currency_sort_key(tup):
|
| 105 |
+
code, start, end, tender = tup
|
| 106 |
+
return int(not tender), start or (1, 1, 1)
|
| 107 |
+
|
| 108 |
+
|
| 109 |
+
def _extract_plural_rules(file_path):
|
| 110 |
+
rule_dict = {}
|
| 111 |
+
prsup = parse(file_path)
|
| 112 |
+
for elem in prsup.findall('.//plurals/pluralRules'):
|
| 113 |
+
rules = []
|
| 114 |
+
for rule in elem.findall('pluralRule'):
|
| 115 |
+
rules.append((rule.attrib['count'], str(rule.text)))
|
| 116 |
+
pr = PluralRule(rules)
|
| 117 |
+
for locale in elem.attrib['locales'].split():
|
| 118 |
+
rule_dict[locale] = pr
|
| 119 |
+
return rule_dict
|
| 120 |
+
|
| 121 |
+
|
| 122 |
+
def _time_to_seconds_past_midnight(time_expr):
|
| 123 |
+
"""
|
| 124 |
+
Parse a time expression to seconds after midnight.
|
| 125 |
+
:param time_expr: Time expression string (H:M or H:M:S)
|
| 126 |
+
:rtype: int
|
| 127 |
+
"""
|
| 128 |
+
if time_expr is None:
|
| 129 |
+
return None
|
| 130 |
+
if time_expr.count(":") == 1:
|
| 131 |
+
time_expr += ":00"
|
| 132 |
+
hour, minute, second = (int(p, 10) for p in time_expr.split(":"))
|
| 133 |
+
return hour * 60 * 60 + minute * 60 + second
|
| 134 |
+
|
| 135 |
+
|
| 136 |
+
def _compact_dict(dict):
|
| 137 |
+
"""
|
| 138 |
+
"Compact" the given dict by removing items whose value is None or False.
|
| 139 |
+
"""
|
| 140 |
+
out_dict = {}
|
| 141 |
+
for key, value in dict.items():
|
| 142 |
+
if value is not None and value is not False:
|
| 143 |
+
out_dict[key] = value
|
| 144 |
+
return out_dict
|
| 145 |
+
|
| 146 |
+
|
| 147 |
+
def debug_repr(obj):
|
| 148 |
+
if isinstance(obj, PluralRule):
|
| 149 |
+
return obj.abstract
|
| 150 |
+
return repr(obj)
|
| 151 |
+
|
| 152 |
+
|
| 153 |
+
def write_datafile(path, data, dump_json=False):
|
| 154 |
+
with open(path, 'wb') as outfile:
|
| 155 |
+
pickle.dump(data, outfile, 2)
|
| 156 |
+
if dump_json:
|
| 157 |
+
import json
|
| 158 |
+
|
| 159 |
+
with open(f"{path}.json", "w") as outfile:
|
| 160 |
+
json.dump(data, outfile, indent=4, default=debug_repr)
|
| 161 |
+
|
| 162 |
+
|
| 163 |
+
def main():
|
| 164 |
+
parser = OptionParser(usage='%prog path/to/cldr')
|
| 165 |
+
parser.add_option(
|
| 166 |
+
'-f', '--force', dest='force', action='store_true', default=False,
|
| 167 |
+
help='force import even if destination file seems up to date',
|
| 168 |
+
)
|
| 169 |
+
parser.add_option(
|
| 170 |
+
'-j', '--json', dest='dump_json', action='store_true', default=False,
|
| 171 |
+
help='also export debugging JSON dumps of locale data',
|
| 172 |
+
)
|
| 173 |
+
parser.add_option(
|
| 174 |
+
'-q', '--quiet', dest='quiet', action='store_true', default=bool(os.environ.get('BABEL_CLDR_QUIET')),
|
| 175 |
+
help='quiesce info/warning messages',
|
| 176 |
+
)
|
| 177 |
+
|
| 178 |
+
options, args = parser.parse_args()
|
| 179 |
+
if len(args) != 1:
|
| 180 |
+
parser.error('incorrect number of arguments')
|
| 181 |
+
|
| 182 |
+
logging.basicConfig(
|
| 183 |
+
level=(logging.ERROR if options.quiet else logging.INFO),
|
| 184 |
+
)
|
| 185 |
+
|
| 186 |
+
return process_data(
|
| 187 |
+
srcdir=args[0],
|
| 188 |
+
destdir=BABEL_PACKAGE_ROOT,
|
| 189 |
+
force=bool(options.force),
|
| 190 |
+
dump_json=bool(options.dump_json),
|
| 191 |
+
)
|
| 192 |
+
|
| 193 |
+
|
| 194 |
+
def process_data(srcdir, destdir, force=False, dump_json=False):
|
| 195 |
+
sup_filename = os.path.join(srcdir, 'supplemental', 'supplementalData.xml')
|
| 196 |
+
sup = parse(sup_filename)
|
| 197 |
+
|
| 198 |
+
# Import global data from the supplemental files
|
| 199 |
+
global_path = os.path.join(destdir, 'global.dat')
|
| 200 |
+
global_data = {}
|
| 201 |
+
if force or need_conversion(global_path, global_data, sup_filename):
|
| 202 |
+
global_data.update(parse_global(srcdir, sup))
|
| 203 |
+
write_datafile(global_path, global_data, dump_json=dump_json)
|
| 204 |
+
_process_local_datas(sup, srcdir, destdir, force=force, dump_json=dump_json)
|
| 205 |
+
|
| 206 |
+
|
| 207 |
+
def parse_global(srcdir, sup):
|
| 208 |
+
global_data = {}
|
| 209 |
+
sup_dir = os.path.join(srcdir, 'supplemental')
|
| 210 |
+
territory_zones = global_data.setdefault('territory_zones', {})
|
| 211 |
+
zone_aliases = global_data.setdefault('zone_aliases', {})
|
| 212 |
+
zone_territories = global_data.setdefault('zone_territories', {})
|
| 213 |
+
win_mapping = global_data.setdefault('windows_zone_mapping', {})
|
| 214 |
+
language_aliases = global_data.setdefault('language_aliases', {})
|
| 215 |
+
territory_aliases = global_data.setdefault('territory_aliases', {})
|
| 216 |
+
script_aliases = global_data.setdefault('script_aliases', {})
|
| 217 |
+
variant_aliases = global_data.setdefault('variant_aliases', {})
|
| 218 |
+
likely_subtags = global_data.setdefault('likely_subtags', {})
|
| 219 |
+
territory_currencies = global_data.setdefault('territory_currencies', {})
|
| 220 |
+
parent_exceptions = global_data.setdefault('parent_exceptions', {})
|
| 221 |
+
all_currencies = collections.defaultdict(set)
|
| 222 |
+
currency_fractions = global_data.setdefault('currency_fractions', {})
|
| 223 |
+
territory_languages = global_data.setdefault('territory_languages', {})
|
| 224 |
+
bcp47_timezone = parse(os.path.join(srcdir, 'bcp47', 'timezone.xml'))
|
| 225 |
+
sup_windows_zones = parse(os.path.join(sup_dir, 'windowsZones.xml'))
|
| 226 |
+
sup_metadata = parse(os.path.join(sup_dir, 'supplementalMetadata.xml'))
|
| 227 |
+
sup_likely = parse(os.path.join(sup_dir, 'likelySubtags.xml'))
|
| 228 |
+
# create auxiliary zone->territory map from the windows zones (we don't set
|
| 229 |
+
# the 'zones_territories' map directly here, because there are some zones
|
| 230 |
+
# aliases listed and we defer the decision of which ones to choose to the
|
| 231 |
+
# 'bcp47' data
|
| 232 |
+
_zone_territory_map = {}
|
| 233 |
+
for map_zone in sup_windows_zones.findall('.//windowsZones/mapTimezones/mapZone'):
|
| 234 |
+
if map_zone.attrib.get('territory') == '001':
|
| 235 |
+
win_mapping[map_zone.attrib['other']] = map_zone.attrib['type'].split()[0]
|
| 236 |
+
for tzid in str(map_zone.attrib['type']).split():
|
| 237 |
+
_zone_territory_map[tzid] = str(map_zone.attrib['territory'])
|
| 238 |
+
for key_elem in bcp47_timezone.findall('.//keyword/key'):
|
| 239 |
+
if key_elem.attrib['name'] == 'tz':
|
| 240 |
+
for elem in key_elem.findall('type'):
|
| 241 |
+
if 'deprecated' not in elem.attrib:
|
| 242 |
+
aliases = str(elem.attrib['alias']).split()
|
| 243 |
+
tzid = aliases.pop(0)
|
| 244 |
+
territory = _zone_territory_map.get(tzid, '001')
|
| 245 |
+
territory_zones.setdefault(territory, []).append(tzid)
|
| 246 |
+
zone_territories[tzid] = territory
|
| 247 |
+
for alias in aliases:
|
| 248 |
+
zone_aliases[alias] = tzid
|
| 249 |
+
break
|
| 250 |
+
|
| 251 |
+
# Import Metazone mapping
|
| 252 |
+
meta_zones = global_data.setdefault('meta_zones', {})
|
| 253 |
+
tzsup = parse(os.path.join(srcdir, 'supplemental', 'metaZones.xml'))
|
| 254 |
+
for elem in tzsup.findall('.//timezone'):
|
| 255 |
+
for child in elem.findall('usesMetazone'):
|
| 256 |
+
if 'to' not in child.attrib: # FIXME: support old mappings
|
| 257 |
+
meta_zones[elem.attrib['type']] = child.attrib['mzone']
|
| 258 |
+
|
| 259 |
+
# Language aliases
|
| 260 |
+
for alias in sup_metadata.findall('.//alias/languageAlias'):
|
| 261 |
+
# We don't have a use for those at the moment. They don't
|
| 262 |
+
# pass our parser anyways.
|
| 263 |
+
if '_' in alias.attrib['type']:
|
| 264 |
+
continue
|
| 265 |
+
language_aliases[alias.attrib['type']] = alias.attrib['replacement']
|
| 266 |
+
|
| 267 |
+
# Territory aliases
|
| 268 |
+
for alias in sup_metadata.findall('.//alias/territoryAlias'):
|
| 269 |
+
territory_aliases[alias.attrib['type']] = alias.attrib['replacement'].split()
|
| 270 |
+
|
| 271 |
+
# Script aliases
|
| 272 |
+
for alias in sup_metadata.findall('.//alias/scriptAlias'):
|
| 273 |
+
script_aliases[alias.attrib['type']] = alias.attrib['replacement']
|
| 274 |
+
|
| 275 |
+
# Variant aliases
|
| 276 |
+
for alias in sup_metadata.findall('.//alias/variantAlias'):
|
| 277 |
+
repl = alias.attrib.get('replacement')
|
| 278 |
+
if repl:
|
| 279 |
+
variant_aliases[alias.attrib['type']] = repl
|
| 280 |
+
|
| 281 |
+
# Likely subtags
|
| 282 |
+
for likely_subtag in sup_likely.findall('.//likelySubtags/likelySubtag'):
|
| 283 |
+
likely_subtags[likely_subtag.attrib['from']] = likely_subtag.attrib['to']
|
| 284 |
+
|
| 285 |
+
# Currencies in territories
|
| 286 |
+
for region in sup.findall('.//currencyData/region'):
|
| 287 |
+
region_code = region.attrib['iso3166']
|
| 288 |
+
region_currencies = []
|
| 289 |
+
for currency in region.findall('./currency'):
|
| 290 |
+
cur_code = currency.attrib['iso4217']
|
| 291 |
+
cur_start = _parse_currency_date(currency.attrib.get('from'))
|
| 292 |
+
cur_end = _parse_currency_date(currency.attrib.get('to'))
|
| 293 |
+
cur_tender = currency.attrib.get('tender', 'true') == 'true'
|
| 294 |
+
# Tie region to currency.
|
| 295 |
+
region_currencies.append((cur_code, cur_start, cur_end, cur_tender))
|
| 296 |
+
# Keep a reverse index of currencies to territorie.
|
| 297 |
+
all_currencies[cur_code].add(region_code)
|
| 298 |
+
region_currencies.sort(key=_currency_sort_key)
|
| 299 |
+
territory_currencies[region_code] = region_currencies
|
| 300 |
+
global_data['all_currencies'] = {
|
| 301 |
+
currency: tuple(sorted(regions)) for currency, regions in all_currencies.items()}
|
| 302 |
+
|
| 303 |
+
# Explicit parent locales
|
| 304 |
+
# Since CLDR-43, there are multiple <parentLocales> statements, some of them with a `component="collations"` or
|
| 305 |
+
# `component="segmentations"` attribute; these indicate that only some language aspects should be inherited.
|
| 306 |
+
# (https://cldr.unicode.org/index/downloads/cldr-43)
|
| 307 |
+
#
|
| 308 |
+
# Ignore these for now, as one of them even points to a locale that doesn't have a corresponding XML file (sr_ME)
|
| 309 |
+
# and we crash trying to load it.
|
| 310 |
+
# There is no XPath support to test for an absent attribute, so use Python to filter
|
| 311 |
+
for parentBlock in sup.findall('.//parentLocales'):
|
| 312 |
+
if parentBlock.attrib.get('component'):
|
| 313 |
+
# Consider only unqualified parent declarations
|
| 314 |
+
continue
|
| 315 |
+
|
| 316 |
+
for paternity in parentBlock.findall('./parentLocale'):
|
| 317 |
+
parent = paternity.attrib['parent']
|
| 318 |
+
if parent == 'root':
|
| 319 |
+
# Since CLDR-45, the 'root' parent locale uses 'localeRules="nonlikelyScript"' instead of
|
| 320 |
+
# 'locales'. This special case is handled in babel when loading locale data
|
| 321 |
+
# (https://cldr.unicode.org/index/downloads/cldr-45#h.5rbkhkncdqi9)
|
| 322 |
+
continue
|
| 323 |
+
for child in paternity.attrib['locales'].split():
|
| 324 |
+
parent_exceptions[child] = parent
|
| 325 |
+
|
| 326 |
+
# Currency decimal and rounding digits
|
| 327 |
+
for fraction in sup.findall('.//currencyData/fractions/info'):
|
| 328 |
+
cur_code = fraction.attrib['iso4217']
|
| 329 |
+
cur_digits = int(fraction.attrib['digits'])
|
| 330 |
+
cur_rounding = int(fraction.attrib['rounding'])
|
| 331 |
+
cur_cdigits = int(fraction.attrib.get('cashDigits', cur_digits))
|
| 332 |
+
cur_crounding = int(fraction.attrib.get('cashRounding', cur_rounding))
|
| 333 |
+
currency_fractions[cur_code] = (cur_digits, cur_rounding, cur_cdigits, cur_crounding)
|
| 334 |
+
|
| 335 |
+
# Languages in territories
|
| 336 |
+
for territory in sup.findall('.//territoryInfo/territory'):
|
| 337 |
+
languages = {}
|
| 338 |
+
for language in territory.findall('./languagePopulation'):
|
| 339 |
+
languages[language.attrib['type']] = {
|
| 340 |
+
'population_percent': float(language.attrib['populationPercent']),
|
| 341 |
+
'official_status': language.attrib.get('officialStatus'),
|
| 342 |
+
}
|
| 343 |
+
territory_languages[territory.attrib['type']] = languages
|
| 344 |
+
return global_data
|
| 345 |
+
|
| 346 |
+
|
| 347 |
+
def _process_local_datas(sup, srcdir, destdir, force=False, dump_json=False):
|
| 348 |
+
day_period_rules = parse_day_period_rules(parse(os.path.join(srcdir, 'supplemental', 'dayPeriods.xml')))
|
| 349 |
+
# build a territory containment mapping for inheritance
|
| 350 |
+
regions = {}
|
| 351 |
+
for elem in sup.findall('.//territoryContainment/group'):
|
| 352 |
+
regions[elem.attrib['type']] = elem.attrib['contains'].split()
|
| 353 |
+
|
| 354 |
+
# Resolve territory containment
|
| 355 |
+
territory_containment = {}
|
| 356 |
+
region_items = sorted(regions.items())
|
| 357 |
+
for group, territory_list in region_items:
|
| 358 |
+
for territory in territory_list:
|
| 359 |
+
containers = territory_containment.setdefault(territory, set())
|
| 360 |
+
if group in territory_containment:
|
| 361 |
+
containers |= territory_containment[group]
|
| 362 |
+
containers.add(group)
|
| 363 |
+
|
| 364 |
+
# prepare the per-locale plural rules definitions
|
| 365 |
+
plural_rules = _extract_plural_rules(os.path.join(srcdir, 'supplemental', 'plurals.xml'))
|
| 366 |
+
ordinal_rules = _extract_plural_rules(os.path.join(srcdir, 'supplemental', 'ordinals.xml'))
|
| 367 |
+
|
| 368 |
+
filenames = os.listdir(os.path.join(srcdir, 'main'))
|
| 369 |
+
filenames.remove('root.xml')
|
| 370 |
+
filenames.sort(key=len)
|
| 371 |
+
filenames.insert(0, 'root.xml')
|
| 372 |
+
|
| 373 |
+
for filename in filenames:
|
| 374 |
+
stem, ext = os.path.splitext(filename)
|
| 375 |
+
if ext != '.xml':
|
| 376 |
+
continue
|
| 377 |
+
|
| 378 |
+
full_filename = os.path.join(srcdir, "main", filename)
|
| 379 |
+
data_filename = os.path.join(destdir, "locale-data", f"{stem}.dat")
|
| 380 |
+
|
| 381 |
+
data = {}
|
| 382 |
+
if not (force or need_conversion(data_filename, data, full_filename)):
|
| 383 |
+
continue
|
| 384 |
+
|
| 385 |
+
tree = parse(full_filename)
|
| 386 |
+
|
| 387 |
+
language = None
|
| 388 |
+
elem = tree.find('.//identity/language')
|
| 389 |
+
if elem is not None:
|
| 390 |
+
language = elem.attrib['type']
|
| 391 |
+
|
| 392 |
+
territory = None
|
| 393 |
+
elem = tree.find('.//identity/territory')
|
| 394 |
+
if elem is not None:
|
| 395 |
+
territory = elem.attrib['type']
|
| 396 |
+
else:
|
| 397 |
+
territory = '001' # world
|
| 398 |
+
regions = territory_containment.get(territory, [])
|
| 399 |
+
|
| 400 |
+
log.info(
|
| 401 |
+
'Processing %s (Language = %s; Territory = %s)',
|
| 402 |
+
filename, language, territory,
|
| 403 |
+
)
|
| 404 |
+
|
| 405 |
+
locale_id = '_'.join(filter(None, [
|
| 406 |
+
language,
|
| 407 |
+
territory != '001' and territory or None,
|
| 408 |
+
]))
|
| 409 |
+
|
| 410 |
+
data['locale_id'] = locale_id
|
| 411 |
+
data['unsupported_number_systems'] = set()
|
| 412 |
+
|
| 413 |
+
if locale_id in plural_rules:
|
| 414 |
+
data['plural_form'] = plural_rules[locale_id]
|
| 415 |
+
if locale_id in ordinal_rules:
|
| 416 |
+
data['ordinal_form'] = ordinal_rules[locale_id]
|
| 417 |
+
if locale_id in day_period_rules:
|
| 418 |
+
data["day_period_rules"] = day_period_rules[locale_id]
|
| 419 |
+
|
| 420 |
+
is_global = ("_" not in locale_id)
|
| 421 |
+
parse_locale_display_names(data, tree, is_global=is_global)
|
| 422 |
+
parse_list_patterns(data, tree)
|
| 423 |
+
parse_dates(data, tree, sup, regions, territory)
|
| 424 |
+
|
| 425 |
+
for calendar in tree.findall('.//calendars/calendar'):
|
| 426 |
+
if calendar.attrib['type'] != 'gregorian':
|
| 427 |
+
# TODO: support other calendar types
|
| 428 |
+
continue
|
| 429 |
+
|
| 430 |
+
parse_calendar_months(data, calendar)
|
| 431 |
+
parse_calendar_days(data, calendar)
|
| 432 |
+
parse_calendar_quarters(data, calendar)
|
| 433 |
+
parse_calendar_eras(data, calendar)
|
| 434 |
+
parse_calendar_periods(data, calendar)
|
| 435 |
+
parse_calendar_date_formats(data, calendar)
|
| 436 |
+
parse_calendar_time_formats(data, calendar)
|
| 437 |
+
parse_calendar_datetime_skeletons(data, calendar)
|
| 438 |
+
parse_interval_formats(data, calendar)
|
| 439 |
+
|
| 440 |
+
parse_number_symbols(data, tree)
|
| 441 |
+
parse_numbering_systems(data, tree)
|
| 442 |
+
parse_decimal_formats(data, tree)
|
| 443 |
+
parse_scientific_formats(data, tree)
|
| 444 |
+
parse_percent_formats(data, tree)
|
| 445 |
+
|
| 446 |
+
parse_currency_formats(data, tree)
|
| 447 |
+
parse_currency_unit_patterns(data, tree)
|
| 448 |
+
parse_currency_names(data, tree)
|
| 449 |
+
parse_unit_patterns(data, tree)
|
| 450 |
+
parse_date_fields(data, tree)
|
| 451 |
+
parse_character_order(data, tree)
|
| 452 |
+
parse_measurement_systems(data, tree)
|
| 453 |
+
|
| 454 |
+
unsupported_number_systems_string = ', '.join(sorted(data.pop('unsupported_number_systems')))
|
| 455 |
+
if unsupported_number_systems_string:
|
| 456 |
+
log.warning(
|
| 457 |
+
f"{locale_id}: unsupported number systems were ignored: "
|
| 458 |
+
f"{unsupported_number_systems_string}",
|
| 459 |
+
)
|
| 460 |
+
|
| 461 |
+
write_datafile(data_filename, data, dump_json=dump_json)
|
| 462 |
+
|
| 463 |
+
|
| 464 |
+
def _should_skip_number_elem(data, elem):
|
| 465 |
+
"""
|
| 466 |
+
Figure out whether the numbering-containing element `elem` is in a currently
|
| 467 |
+
non-supported (i.e. currently non-Latin) numbering system.
|
| 468 |
+
|
| 469 |
+
:param data: The root data element, for stashing the warning.
|
| 470 |
+
:param elem: Element with `numberSystem` key
|
| 471 |
+
:return: Boolean
|
| 472 |
+
"""
|
| 473 |
+
number_system = elem.get('numberSystem', 'latn')
|
| 474 |
+
|
| 475 |
+
if number_system != 'latn':
|
| 476 |
+
data['unsupported_number_systems'].add(number_system)
|
| 477 |
+
return True
|
| 478 |
+
|
| 479 |
+
return False
|
| 480 |
+
|
| 481 |
+
|
| 482 |
+
def _should_skip_elem(elem, type=None, dest=None):
|
| 483 |
+
"""
|
| 484 |
+
Check whether the given element should be skipped.
|
| 485 |
+
|
| 486 |
+
Elements are skipped if they are drafts or alternates of data that already exists in `dest`.
|
| 487 |
+
|
| 488 |
+
:param elem: XML element
|
| 489 |
+
:param type: Type string. May be elided if the dest dict is elided.
|
| 490 |
+
:param dest: Destination dict. May be elided to skip the dict check.
|
| 491 |
+
:return: skip boolean
|
| 492 |
+
"""
|
| 493 |
+
if _is_draft_or_alt(elem):
|
| 494 |
+
if dest is None or type in dest:
|
| 495 |
+
return True
|
| 496 |
+
|
| 497 |
+
|
| 498 |
+
def _is_draft_or_alt(elem) -> bool:
|
| 499 |
+
return 'draft' in elem.attrib or 'alt' in elem.attrib
|
| 500 |
+
|
| 501 |
+
|
| 502 |
+
def _import_type_text(dest, elem, type=None, *, allow_variant_and_draft_fallback=True) -> None:
|
| 503 |
+
"""
|
| 504 |
+
Conditionally import the element's inner text(s) into the `dest` dict.
|
| 505 |
+
|
| 506 |
+
If `allow_variant_and_draft_fallback` is True, then the element may be imported
|
| 507 |
+
if there otherwise isn't a pre-existing element of the same type.
|
| 508 |
+
|
| 509 |
+
:param dest: Destination dict
|
| 510 |
+
:param elem: XML element.
|
| 511 |
+
:param type: Override type. (By default, the `type` attr of the element.)
|
| 512 |
+
:param allow_variant_and_draft_fallback: See above.
|
| 513 |
+
:return: Nothing.
|
| 514 |
+
"""
|
| 515 |
+
if type is None:
|
| 516 |
+
type = elem.attrib['type']
|
| 517 |
+
|
| 518 |
+
# Already have this, nothing to do.
|
| 519 |
+
if type in dest:
|
| 520 |
+
return
|
| 521 |
+
|
| 522 |
+
if not allow_variant_and_draft_fallback and _is_draft_or_alt(elem):
|
| 523 |
+
# Not allowed to use a draft/alternate here.
|
| 524 |
+
return
|
| 525 |
+
dest[type] = _text(elem)
|
| 526 |
+
|
| 527 |
+
|
| 528 |
+
def parse_locale_display_names(data, tree, *, is_global: bool):
|
| 529 |
+
territories = data.setdefault('territories', {})
|
| 530 |
+
for elem in tree.findall('.//territories/territory'):
|
| 531 |
+
_import_type_text(territories, elem, allow_variant_and_draft_fallback=is_global)
|
| 532 |
+
languages = data.setdefault('languages', {})
|
| 533 |
+
for elem in tree.findall('.//languages/language'):
|
| 534 |
+
_import_type_text(languages, elem, allow_variant_and_draft_fallback=is_global)
|
| 535 |
+
variants = data.setdefault('variants', {})
|
| 536 |
+
for elem in tree.findall('.//variants/variant'):
|
| 537 |
+
_import_type_text(variants, elem, allow_variant_and_draft_fallback=is_global)
|
| 538 |
+
scripts = data.setdefault('scripts', {})
|
| 539 |
+
for elem in tree.findall('.//scripts/script'):
|
| 540 |
+
_import_type_text(scripts, elem, allow_variant_and_draft_fallback=is_global)
|
| 541 |
+
|
| 542 |
+
|
| 543 |
+
def parse_list_patterns(data, tree):
|
| 544 |
+
list_patterns = data.setdefault('list_patterns', {})
|
| 545 |
+
for list_pattern_el in tree.findall('.//listPatterns/listPattern'):
|
| 546 |
+
pattern_type = list_pattern_el.attrib.get('type', 'standard')
|
| 547 |
+
for pattern_part_el in list_pattern_el.findall('listPatternPart'):
|
| 548 |
+
pattern_part_type = pattern_part_el.attrib['type']
|
| 549 |
+
list_patterns.setdefault(pattern_type, {})[pattern_part_type] = _text(pattern_part_el)
|
| 550 |
+
|
| 551 |
+
|
| 552 |
+
def parse_dates(data, tree, sup, regions, territory):
|
| 553 |
+
week_data = data.setdefault('week_data', {})
|
| 554 |
+
supelem = sup.find('.//weekData')
|
| 555 |
+
for elem in supelem.findall('minDays'):
|
| 556 |
+
if _should_skip_elem(elem):
|
| 557 |
+
continue
|
| 558 |
+
territories = elem.attrib['territories'].split()
|
| 559 |
+
if territory in territories or any(r in territories for r in regions):
|
| 560 |
+
week_data['min_days'] = int(elem.attrib['count'])
|
| 561 |
+
for elem in supelem.findall('firstDay'):
|
| 562 |
+
if _should_skip_elem(elem):
|
| 563 |
+
continue
|
| 564 |
+
territories = elem.attrib['territories'].split()
|
| 565 |
+
if territory in territories or any(r in territories for r in regions):
|
| 566 |
+
week_data['first_day'] = weekdays[elem.attrib['day']]
|
| 567 |
+
for elem in supelem.findall('weekendStart'):
|
| 568 |
+
if _should_skip_elem(elem):
|
| 569 |
+
continue
|
| 570 |
+
territories = elem.attrib['territories'].split()
|
| 571 |
+
if territory in territories or any(r in territories for r in regions):
|
| 572 |
+
week_data['weekend_start'] = weekdays[elem.attrib['day']]
|
| 573 |
+
for elem in supelem.findall('weekendEnd'):
|
| 574 |
+
if _should_skip_elem(elem):
|
| 575 |
+
continue
|
| 576 |
+
territories = elem.attrib['territories'].split()
|
| 577 |
+
if territory in territories or any(r in territories for r in regions):
|
| 578 |
+
week_data['weekend_end'] = weekdays[elem.attrib['day']]
|
| 579 |
+
zone_formats = data.setdefault('zone_formats', {})
|
| 580 |
+
for elem in tree.findall('.//timeZoneNames/gmtFormat'):
|
| 581 |
+
if not _should_skip_elem(elem):
|
| 582 |
+
zone_formats['gmt'] = str(elem.text).replace('{0}', '%s')
|
| 583 |
+
break
|
| 584 |
+
for elem in tree.findall('.//timeZoneNames/regionFormat'):
|
| 585 |
+
if not _should_skip_elem(elem):
|
| 586 |
+
zone_formats['region'] = str(elem.text).replace('{0}', '%s')
|
| 587 |
+
break
|
| 588 |
+
for elem in tree.findall('.//timeZoneNames/fallbackFormat'):
|
| 589 |
+
if not _should_skip_elem(elem):
|
| 590 |
+
zone_formats['fallback'] = (
|
| 591 |
+
str(elem.text).replace('{0}', '%(0)s').replace('{1}', '%(1)s')
|
| 592 |
+
)
|
| 593 |
+
break
|
| 594 |
+
for elem in tree.findall('.//timeZoneNames/fallbackRegionFormat'):
|
| 595 |
+
if not _should_skip_elem(elem):
|
| 596 |
+
zone_formats['fallback_region'] = (
|
| 597 |
+
str(elem.text).replace('{0}', '%(0)s').replace('{1}', '%(1)s')
|
| 598 |
+
)
|
| 599 |
+
break
|
| 600 |
+
time_zones = data.setdefault('time_zones', {})
|
| 601 |
+
for elem in tree.findall('.//timeZoneNames/zone'):
|
| 602 |
+
info = {}
|
| 603 |
+
city = elem.findtext('exemplarCity')
|
| 604 |
+
if city:
|
| 605 |
+
info['city'] = str(city)
|
| 606 |
+
for child in elem.findall('long/*'):
|
| 607 |
+
info.setdefault('long', {})[child.tag] = str(child.text)
|
| 608 |
+
for child in elem.findall('short/*'):
|
| 609 |
+
info.setdefault('short', {})[child.tag] = str(child.text)
|
| 610 |
+
time_zones[elem.attrib['type']] = info
|
| 611 |
+
meta_zones = data.setdefault('meta_zones', {})
|
| 612 |
+
for elem in tree.findall('.//timeZoneNames/metazone'):
|
| 613 |
+
info = {}
|
| 614 |
+
city = elem.findtext('exemplarCity')
|
| 615 |
+
if city:
|
| 616 |
+
info['city'] = str(city)
|
| 617 |
+
for child in elem.findall('long/*'):
|
| 618 |
+
info.setdefault('long', {})[child.tag] = str(child.text)
|
| 619 |
+
for child in elem.findall('short/*'):
|
| 620 |
+
info.setdefault('short', {})[child.tag] = str(child.text)
|
| 621 |
+
meta_zones[elem.attrib['type']] = info
|
| 622 |
+
|
| 623 |
+
|
| 624 |
+
def parse_calendar_months(data, calendar):
|
| 625 |
+
months = data.setdefault('months', {})
|
| 626 |
+
for ctxt in calendar.findall('months/monthContext'):
|
| 627 |
+
ctxt_type = ctxt.attrib['type']
|
| 628 |
+
ctxts = months.setdefault(ctxt_type, {})
|
| 629 |
+
for width in ctxt.findall('monthWidth'):
|
| 630 |
+
width_type = width.attrib['type']
|
| 631 |
+
widths = ctxts.setdefault(width_type, {})
|
| 632 |
+
for elem in width:
|
| 633 |
+
if elem.tag == 'month':
|
| 634 |
+
_import_type_text(widths, elem, int(elem.attrib['type']))
|
| 635 |
+
elif elem.tag == 'alias':
|
| 636 |
+
ctxts[width_type] = Alias(
|
| 637 |
+
_translate_alias(['months', ctxt_type, width_type],
|
| 638 |
+
elem.attrib['path']),
|
| 639 |
+
)
|
| 640 |
+
|
| 641 |
+
|
| 642 |
+
def parse_calendar_days(data, calendar):
|
| 643 |
+
days = data.setdefault('days', {})
|
| 644 |
+
for ctxt in calendar.findall('days/dayContext'):
|
| 645 |
+
ctxt_type = ctxt.attrib['type']
|
| 646 |
+
ctxts = days.setdefault(ctxt_type, {})
|
| 647 |
+
for width in ctxt.findall('dayWidth'):
|
| 648 |
+
width_type = width.attrib['type']
|
| 649 |
+
widths = ctxts.setdefault(width_type, {})
|
| 650 |
+
for elem in width:
|
| 651 |
+
if elem.tag == 'day':
|
| 652 |
+
_import_type_text(widths, elem, weekdays[elem.attrib['type']])
|
| 653 |
+
elif elem.tag == 'alias':
|
| 654 |
+
ctxts[width_type] = Alias(
|
| 655 |
+
_translate_alias(['days', ctxt_type, width_type],
|
| 656 |
+
elem.attrib['path']),
|
| 657 |
+
)
|
| 658 |
+
|
| 659 |
+
|
| 660 |
+
def parse_calendar_quarters(data, calendar):
|
| 661 |
+
quarters = data.setdefault('quarters', {})
|
| 662 |
+
for ctxt in calendar.findall('quarters/quarterContext'):
|
| 663 |
+
ctxt_type = ctxt.attrib['type']
|
| 664 |
+
ctxts = quarters.setdefault(ctxt.attrib['type'], {})
|
| 665 |
+
for width in ctxt.findall('quarterWidth'):
|
| 666 |
+
width_type = width.attrib['type']
|
| 667 |
+
widths = ctxts.setdefault(width_type, {})
|
| 668 |
+
for elem in width:
|
| 669 |
+
if elem.tag == 'quarter':
|
| 670 |
+
_import_type_text(widths, elem, int(elem.attrib['type']))
|
| 671 |
+
elif elem.tag == 'alias':
|
| 672 |
+
ctxts[width_type] = Alias(
|
| 673 |
+
_translate_alias(['quarters', ctxt_type,
|
| 674 |
+
width_type],
|
| 675 |
+
elem.attrib['path']))
|
| 676 |
+
|
| 677 |
+
|
| 678 |
+
def parse_calendar_eras(data, calendar):
|
| 679 |
+
eras = data.setdefault('eras', {})
|
| 680 |
+
for width in calendar.findall('eras/*'):
|
| 681 |
+
width_type = NAME_MAP[width.tag]
|
| 682 |
+
widths = eras.setdefault(width_type, {})
|
| 683 |
+
for elem in width:
|
| 684 |
+
if elem.tag == 'era':
|
| 685 |
+
_import_type_text(widths, elem, type=int(elem.attrib.get('type')))
|
| 686 |
+
elif elem.tag == 'alias':
|
| 687 |
+
eras[width_type] = Alias(
|
| 688 |
+
_translate_alias(['eras', width_type],
|
| 689 |
+
elem.attrib['path']),
|
| 690 |
+
)
|
| 691 |
+
|
| 692 |
+
|
| 693 |
+
def parse_calendar_periods(data, calendar):
|
| 694 |
+
# Day periods (AM/PM/others)
|
| 695 |
+
periods = data.setdefault('day_periods', {})
|
| 696 |
+
for day_period_ctx in calendar.findall('dayPeriods/dayPeriodContext'):
|
| 697 |
+
ctx_type = day_period_ctx.attrib["type"]
|
| 698 |
+
for day_period_width in day_period_ctx.findall('dayPeriodWidth'):
|
| 699 |
+
width_type = day_period_width.attrib["type"]
|
| 700 |
+
dest_dict = periods.setdefault(ctx_type, {}).setdefault(width_type, {})
|
| 701 |
+
for day_period in day_period_width.findall('dayPeriod'):
|
| 702 |
+
period_type = day_period.attrib['type']
|
| 703 |
+
if 'alt' not in day_period.attrib:
|
| 704 |
+
dest_dict[period_type] = str(day_period.text)
|
| 705 |
+
|
| 706 |
+
|
| 707 |
+
def parse_calendar_date_formats(data, calendar):
|
| 708 |
+
date_formats = data.setdefault('date_formats', {})
|
| 709 |
+
for format in calendar.findall('dateFormats'):
|
| 710 |
+
for elem in format:
|
| 711 |
+
if elem.tag == 'dateFormatLength':
|
| 712 |
+
type = elem.attrib.get('type')
|
| 713 |
+
if _should_skip_elem(elem, type, date_formats):
|
| 714 |
+
continue
|
| 715 |
+
try:
|
| 716 |
+
date_formats[type] = dates.parse_pattern(
|
| 717 |
+
str(elem.findtext('dateFormat/pattern')),
|
| 718 |
+
)
|
| 719 |
+
except ValueError as e:
|
| 720 |
+
log.error(e)
|
| 721 |
+
elif elem.tag == 'alias':
|
| 722 |
+
date_formats = Alias(_translate_alias(
|
| 723 |
+
['date_formats'], elem.attrib['path']),
|
| 724 |
+
)
|
| 725 |
+
|
| 726 |
+
|
| 727 |
+
def parse_calendar_time_formats(data, calendar):
|
| 728 |
+
time_formats = data.setdefault('time_formats', {})
|
| 729 |
+
for format in calendar.findall('timeFormats'):
|
| 730 |
+
for elem in format:
|
| 731 |
+
if elem.tag == 'timeFormatLength':
|
| 732 |
+
type = elem.attrib.get('type')
|
| 733 |
+
if _should_skip_elem(elem, type, time_formats):
|
| 734 |
+
continue
|
| 735 |
+
try:
|
| 736 |
+
time_formats[type] = dates.parse_pattern(
|
| 737 |
+
str(elem.findtext('timeFormat/pattern')),
|
| 738 |
+
)
|
| 739 |
+
except ValueError as e:
|
| 740 |
+
log.error(e)
|
| 741 |
+
elif elem.tag == 'alias':
|
| 742 |
+
time_formats = Alias(_translate_alias(
|
| 743 |
+
['time_formats'], elem.attrib['path']),
|
| 744 |
+
)
|
| 745 |
+
|
| 746 |
+
|
| 747 |
+
def parse_calendar_datetime_skeletons(data, calendar):
|
| 748 |
+
datetime_formats = data.setdefault('datetime_formats', {})
|
| 749 |
+
datetime_skeletons = data.setdefault('datetime_skeletons', {})
|
| 750 |
+
for format in calendar.findall('dateTimeFormats'):
|
| 751 |
+
for elem in format:
|
| 752 |
+
if elem.tag == 'dateTimeFormatLength':
|
| 753 |
+
type = elem.attrib.get('type')
|
| 754 |
+
if _should_skip_elem(elem, type, datetime_formats):
|
| 755 |
+
continue
|
| 756 |
+
try:
|
| 757 |
+
datetime_formats[type] = str(elem.findtext('dateTimeFormat/pattern'))
|
| 758 |
+
except ValueError as e:
|
| 759 |
+
log.error(e)
|
| 760 |
+
elif elem.tag == 'alias':
|
| 761 |
+
datetime_formats = Alias(_translate_alias(
|
| 762 |
+
['datetime_formats'], elem.attrib['path']),
|
| 763 |
+
)
|
| 764 |
+
elif elem.tag == 'availableFormats':
|
| 765 |
+
for datetime_skeleton in elem.findall('dateFormatItem'):
|
| 766 |
+
datetime_skeletons[datetime_skeleton.attrib['id']] = (
|
| 767 |
+
dates.parse_pattern(str(datetime_skeleton.text))
|
| 768 |
+
)
|
| 769 |
+
|
| 770 |
+
|
| 771 |
+
def parse_number_symbols(data, tree):
|
| 772 |
+
number_symbols = data.setdefault('number_symbols', {})
|
| 773 |
+
for symbol_system_elem in tree.findall('.//numbers/symbols'):
|
| 774 |
+
number_system = symbol_system_elem.get('numberSystem')
|
| 775 |
+
if not number_system:
|
| 776 |
+
continue
|
| 777 |
+
|
| 778 |
+
for symbol_element in symbol_system_elem.findall('./*'):
|
| 779 |
+
if _should_skip_elem(symbol_element):
|
| 780 |
+
continue
|
| 781 |
+
|
| 782 |
+
number_symbols.setdefault(number_system, {})[symbol_element.tag] = str(symbol_element.text)
|
| 783 |
+
|
| 784 |
+
|
| 785 |
+
def parse_numbering_systems(data, tree):
|
| 786 |
+
default_number_system_node = tree.find('.//numbers/defaultNumberingSystem')
|
| 787 |
+
if default_number_system_node is not None:
|
| 788 |
+
data['default_numbering_system'] = default_number_system_node.text
|
| 789 |
+
|
| 790 |
+
numbering_systems = data.setdefault('numbering_systems', {})
|
| 791 |
+
other_numbering_systems_node = tree.find('.//numbers/otherNumberingSystems') or []
|
| 792 |
+
for system in other_numbering_systems_node:
|
| 793 |
+
numbering_systems[system.tag] = system.text
|
| 794 |
+
|
| 795 |
+
|
| 796 |
+
def parse_decimal_formats(data, tree):
|
| 797 |
+
decimal_formats = data.setdefault('decimal_formats', {})
|
| 798 |
+
for df_elem in tree.findall('.//decimalFormats'):
|
| 799 |
+
if _should_skip_number_elem(data, df_elem): # TODO: Support other number systems
|
| 800 |
+
continue
|
| 801 |
+
for elem in df_elem.findall('./decimalFormatLength'):
|
| 802 |
+
length_type = elem.attrib.get('type')
|
| 803 |
+
if _should_skip_elem(elem, length_type, decimal_formats):
|
| 804 |
+
continue
|
| 805 |
+
if elem.findall('./alias'):
|
| 806 |
+
# TODO map the alias to its target
|
| 807 |
+
continue
|
| 808 |
+
for pattern_el in elem.findall('./decimalFormat/pattern'):
|
| 809 |
+
pattern_type = pattern_el.attrib.get('type')
|
| 810 |
+
pattern = numbers.parse_pattern(str(pattern_el.text))
|
| 811 |
+
if pattern_type:
|
| 812 |
+
# This is a compact decimal format, see:
|
| 813 |
+
# https://www.unicode.org/reports/tr35/tr35-45/tr35-numbers.html#Compact_Number_Formats
|
| 814 |
+
|
| 815 |
+
# These are mapped into a `compact_decimal_formats` dictionary
|
| 816 |
+
# with the format {length: {count: {multiplier: pattern}}}.
|
| 817 |
+
compact_decimal_formats = data.setdefault('compact_decimal_formats', {})
|
| 818 |
+
length_map = compact_decimal_formats.setdefault(length_type, {})
|
| 819 |
+
length_count_map = length_map.setdefault(pattern_el.attrib['count'], {})
|
| 820 |
+
length_count_map[pattern_type] = pattern
|
| 821 |
+
else:
|
| 822 |
+
# Regular decimal format.
|
| 823 |
+
decimal_formats[length_type] = pattern
|
| 824 |
+
|
| 825 |
+
|
| 826 |
+
def parse_scientific_formats(data, tree):
|
| 827 |
+
scientific_formats = data.setdefault('scientific_formats', {})
|
| 828 |
+
for sf_elem in tree.findall('.//scientificFormats'):
|
| 829 |
+
if _should_skip_number_elem(data, sf_elem): # TODO: Support other number systems
|
| 830 |
+
continue
|
| 831 |
+
for elem in sf_elem.findall('./scientificFormatLength'):
|
| 832 |
+
type = elem.attrib.get('type')
|
| 833 |
+
if _should_skip_elem(elem, type, scientific_formats):
|
| 834 |
+
continue
|
| 835 |
+
pattern = str(elem.findtext('scientificFormat/pattern'))
|
| 836 |
+
scientific_formats[type] = numbers.parse_pattern(pattern)
|
| 837 |
+
|
| 838 |
+
|
| 839 |
+
def parse_percent_formats(data, tree):
|
| 840 |
+
percent_formats = data.setdefault('percent_formats', {})
|
| 841 |
+
|
| 842 |
+
for pf_elem in tree.findall('.//percentFormats'):
|
| 843 |
+
if _should_skip_number_elem(data, pf_elem): # TODO: Support other number systems
|
| 844 |
+
continue
|
| 845 |
+
for elem in pf_elem.findall('.//percentFormatLength'):
|
| 846 |
+
type = elem.attrib.get('type')
|
| 847 |
+
if _should_skip_elem(elem, type, percent_formats):
|
| 848 |
+
continue
|
| 849 |
+
pattern = str(elem.findtext('percentFormat/pattern'))
|
| 850 |
+
percent_formats[type] = numbers.parse_pattern(pattern)
|
| 851 |
+
|
| 852 |
+
|
| 853 |
+
def parse_currency_names(data, tree):
|
| 854 |
+
currency_names = data.setdefault('currency_names', {})
|
| 855 |
+
currency_names_plural = data.setdefault('currency_names_plural', {})
|
| 856 |
+
currency_symbols = data.setdefault('currency_symbols', {})
|
| 857 |
+
for elem in tree.findall('.//currencies/currency'):
|
| 858 |
+
code = elem.attrib['type']
|
| 859 |
+
for name in elem.findall('displayName'):
|
| 860 |
+
if ('draft' in name.attrib) and code in currency_names:
|
| 861 |
+
continue
|
| 862 |
+
if 'count' in name.attrib:
|
| 863 |
+
currency_names_plural.setdefault(code, {})[
|
| 864 |
+
name.attrib['count']] = str(name.text)
|
| 865 |
+
else:
|
| 866 |
+
currency_names[code] = str(name.text)
|
| 867 |
+
for symbol in elem.findall('symbol'):
|
| 868 |
+
if 'draft' in symbol.attrib or 'choice' in symbol.attrib: # Skip drafts and choice-patterns
|
| 869 |
+
continue
|
| 870 |
+
if symbol.attrib.get('alt'): # Skip alternate forms
|
| 871 |
+
continue
|
| 872 |
+
currency_symbols[code] = str(symbol.text)
|
| 873 |
+
|
| 874 |
+
|
| 875 |
+
def parse_unit_patterns(data, tree):
|
| 876 |
+
unit_patterns = data.setdefault('unit_patterns', {})
|
| 877 |
+
compound_patterns = data.setdefault('compound_unit_patterns', {})
|
| 878 |
+
unit_display_names = data.setdefault('unit_display_names', {})
|
| 879 |
+
|
| 880 |
+
for elem in tree.findall('.//units/unitLength'):
|
| 881 |
+
unit_length_type = elem.attrib['type']
|
| 882 |
+
for unit in elem.findall('unit'):
|
| 883 |
+
unit_type = unit.attrib['type']
|
| 884 |
+
unit_and_length_patterns = unit_patterns.setdefault(unit_type, {}).setdefault(unit_length_type, {})
|
| 885 |
+
for pattern in unit.findall('unitPattern'):
|
| 886 |
+
if pattern.attrib.get('case', 'nominative') != 'nominative':
|
| 887 |
+
# Skip non-nominative cases.
|
| 888 |
+
continue
|
| 889 |
+
unit_and_length_patterns[pattern.attrib['count']] = _text(pattern)
|
| 890 |
+
|
| 891 |
+
per_unit_pat = unit.find('perUnitPattern')
|
| 892 |
+
if per_unit_pat is not None:
|
| 893 |
+
unit_and_length_patterns['per'] = _text(per_unit_pat)
|
| 894 |
+
|
| 895 |
+
display_name = unit.find('displayName')
|
| 896 |
+
if display_name is not None:
|
| 897 |
+
unit_display_names.setdefault(unit_type, {})[unit_length_type] = _text(display_name)
|
| 898 |
+
|
| 899 |
+
for unit in elem.findall('compoundUnit'):
|
| 900 |
+
unit_type = unit.attrib['type']
|
| 901 |
+
compound_unit_info = {}
|
| 902 |
+
compound_variations = {}
|
| 903 |
+
for child in unit:
|
| 904 |
+
if child.attrib.get('case', 'nominative') != 'nominative':
|
| 905 |
+
# Skip non-nominative cases.
|
| 906 |
+
continue
|
| 907 |
+
if child.tag == "unitPrefixPattern":
|
| 908 |
+
compound_unit_info['prefix'] = _text(child)
|
| 909 |
+
elif child.tag == "compoundUnitPattern":
|
| 910 |
+
compound_variations[None] = _text(child)
|
| 911 |
+
elif child.tag == "compoundUnitPattern1":
|
| 912 |
+
compound_variations[child.attrib.get('count')] = _text(child)
|
| 913 |
+
if compound_variations:
|
| 914 |
+
compound_variation_values = set(compound_variations.values())
|
| 915 |
+
if len(compound_variation_values) == 1:
|
| 916 |
+
# shortcut: if all compound variations are the same, only store one
|
| 917 |
+
compound_unit_info['compound'] = next(iter(compound_variation_values))
|
| 918 |
+
else:
|
| 919 |
+
compound_unit_info['compound_variations'] = compound_variations
|
| 920 |
+
compound_patterns.setdefault(unit_type, {})[unit_length_type] = compound_unit_info
|
| 921 |
+
|
| 922 |
+
|
| 923 |
+
def parse_date_fields(data, tree):
|
| 924 |
+
date_fields = data.setdefault('date_fields', {})
|
| 925 |
+
for elem in tree.findall('.//dates/fields/field'):
|
| 926 |
+
field_type = elem.attrib['type']
|
| 927 |
+
date_fields.setdefault(field_type, {})
|
| 928 |
+
for rel_time in elem.findall('relativeTime'):
|
| 929 |
+
rel_time_type = rel_time.attrib['type']
|
| 930 |
+
for pattern in rel_time.findall('relativeTimePattern'):
|
| 931 |
+
type_dict = date_fields[field_type].setdefault(rel_time_type, {})
|
| 932 |
+
type_dict[pattern.attrib['count']] = str(pattern.text)
|
| 933 |
+
|
| 934 |
+
|
| 935 |
+
def parse_interval_formats(data, tree):
|
| 936 |
+
# https://www.unicode.org/reports/tr35/tr35-dates.html#intervalFormats
|
| 937 |
+
interval_formats = data.setdefault("interval_formats", {})
|
| 938 |
+
for elem in tree.findall("dateTimeFormats/intervalFormats/*"):
|
| 939 |
+
if 'draft' in elem.attrib:
|
| 940 |
+
continue
|
| 941 |
+
if elem.tag == "intervalFormatFallback":
|
| 942 |
+
interval_formats[None] = elem.text
|
| 943 |
+
elif elem.tag == "intervalFormatItem":
|
| 944 |
+
skel_data = interval_formats.setdefault(elem.attrib["id"], {})
|
| 945 |
+
for item_sub in elem:
|
| 946 |
+
if item_sub.tag == "greatestDifference":
|
| 947 |
+
skel_data[item_sub.attrib["id"]] = split_interval_pattern(item_sub.text)
|
| 948 |
+
else:
|
| 949 |
+
raise NotImplementedError(f"Not implemented: {item_sub.tag}({item_sub.attrib!r})")
|
| 950 |
+
|
| 951 |
+
|
| 952 |
+
def parse_currency_formats(data, tree):
|
| 953 |
+
currency_formats = data.setdefault('currency_formats', {})
|
| 954 |
+
for currency_format in tree.findall('.//currencyFormats'):
|
| 955 |
+
if _should_skip_number_elem(data, currency_format): # TODO: Support other number systems
|
| 956 |
+
continue
|
| 957 |
+
|
| 958 |
+
for length_elem in currency_format.findall('./currencyFormatLength'):
|
| 959 |
+
curr_length_type = length_elem.attrib.get('type')
|
| 960 |
+
for elem in length_elem.findall('currencyFormat'):
|
| 961 |
+
type = elem.attrib.get('type')
|
| 962 |
+
if _should_skip_elem(elem, type, currency_formats):
|
| 963 |
+
continue
|
| 964 |
+
for child in elem.iter():
|
| 965 |
+
if child.tag == 'alias':
|
| 966 |
+
currency_formats[type] = Alias(
|
| 967 |
+
_translate_alias(['currency_formats', elem.attrib['type']],
|
| 968 |
+
child.attrib['path']),
|
| 969 |
+
)
|
| 970 |
+
elif child.tag == 'pattern':
|
| 971 |
+
pattern_type = child.attrib.get('type')
|
| 972 |
+
if child.attrib.get('draft') or child.attrib.get('alt'):
|
| 973 |
+
# Skip drafts and alternates.
|
| 974 |
+
# The `noCurrency` alternate for currencies was added in CLDR 42.
|
| 975 |
+
continue
|
| 976 |
+
pattern = numbers.parse_pattern(str(child.text))
|
| 977 |
+
if pattern_type:
|
| 978 |
+
# This is a compact currency format, see:
|
| 979 |
+
# https://www.unicode.org/reports/tr35/tr35-45/tr35-numbers.html#Compact_Number_Formats
|
| 980 |
+
|
| 981 |
+
# These are mapped into a `compact_currency_formats` dictionary
|
| 982 |
+
# with the format {length: {count: {multiplier: pattern}}}.
|
| 983 |
+
compact_currency_formats = data.setdefault('compact_currency_formats', {})
|
| 984 |
+
length_map = compact_currency_formats.setdefault(curr_length_type, {})
|
| 985 |
+
length_count_map = length_map.setdefault(child.attrib['count'], {})
|
| 986 |
+
length_count_map[pattern_type] = pattern
|
| 987 |
+
else:
|
| 988 |
+
# Regular currency format
|
| 989 |
+
currency_formats[type] = pattern
|
| 990 |
+
|
| 991 |
+
|
| 992 |
+
def parse_currency_unit_patterns(data, tree):
|
| 993 |
+
currency_unit_patterns = data.setdefault('currency_unit_patterns', {})
|
| 994 |
+
for currency_formats_elem in tree.findall('.//currencyFormats'):
|
| 995 |
+
if _should_skip_number_elem(data, currency_formats_elem): # TODO: Support other number systems
|
| 996 |
+
continue
|
| 997 |
+
for unit_pattern_elem in currency_formats_elem.findall('./unitPattern'):
|
| 998 |
+
count = unit_pattern_elem.attrib['count']
|
| 999 |
+
pattern = str(unit_pattern_elem.text)
|
| 1000 |
+
currency_unit_patterns[count] = pattern
|
| 1001 |
+
|
| 1002 |
+
|
| 1003 |
+
def parse_day_period_rules(tree):
|
| 1004 |
+
"""
|
| 1005 |
+
Parse dayPeriodRule data into a dict.
|
| 1006 |
+
|
| 1007 |
+
:param tree: ElementTree
|
| 1008 |
+
"""
|
| 1009 |
+
day_periods = {}
|
| 1010 |
+
for ruleset in tree.findall(".//dayPeriodRuleSet"):
|
| 1011 |
+
ruleset_type = ruleset.attrib.get("type") # None|"selection"
|
| 1012 |
+
for rules in ruleset.findall("dayPeriodRules"):
|
| 1013 |
+
locales = rules.attrib["locales"].split()
|
| 1014 |
+
for rule in rules.findall("dayPeriodRule"):
|
| 1015 |
+
type = rule.attrib["type"]
|
| 1016 |
+
if type in ("am", "pm"): # These fixed periods are handled separately by `get_period_id`
|
| 1017 |
+
continue
|
| 1018 |
+
rule = _compact_dict({
|
| 1019 |
+
key: _time_to_seconds_past_midnight(rule.attrib.get(key))
|
| 1020 |
+
for key in ("after", "at", "before", "from", "to")
|
| 1021 |
+
})
|
| 1022 |
+
for locale in locales:
|
| 1023 |
+
dest_list = day_periods.setdefault(locale, {}).setdefault(ruleset_type, {}).setdefault(type, [])
|
| 1024 |
+
dest_list.append(rule)
|
| 1025 |
+
return day_periods
|
| 1026 |
+
|
| 1027 |
+
|
| 1028 |
+
def parse_character_order(data, tree):
|
| 1029 |
+
for elem in tree.findall('.//layout/orientation/characterOrder'):
|
| 1030 |
+
data['character_order'] = elem.text
|
| 1031 |
+
|
| 1032 |
+
|
| 1033 |
+
def parse_measurement_systems(data, tree):
|
| 1034 |
+
measurement_systems = data.setdefault('measurement_systems', {})
|
| 1035 |
+
for measurement_system in tree.findall('.//measurementSystemNames/measurementSystemName'):
|
| 1036 |
+
type = measurement_system.attrib['type']
|
| 1037 |
+
if not _should_skip_elem(measurement_system, type=type, dest=measurement_systems):
|
| 1038 |
+
_import_type_text(measurement_systems, measurement_system, type=type)
|
| 1039 |
+
|
| 1040 |
+
|
| 1041 |
+
if __name__ == '__main__':
|
| 1042 |
+
main()
|
SPFsmartGATE/LIVE/TMP/haystack/.github/ISSUE_TEMPLATE/breaking-change-proposal.md
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
name: Breaking change proposal
|
| 3 |
+
about: Track a breaking change in Haystack
|
| 4 |
+
title: ''
|
| 5 |
+
labels: breaking change
|
| 6 |
+
assignees: ''
|
| 7 |
+
|
| 8 |
+
---
|
| 9 |
+
|
| 10 |
+
## Summary and motivation
|
| 11 |
+
|
| 12 |
+
Briefly explain how the change is breaking and why it is needed.
|
| 13 |
+
|
| 14 |
+
## Checklist
|
| 15 |
+
|
| 16 |
+
```[tasklist]
|
| 17 |
+
### Tasks
|
| 18 |
+
- [ ] The changes are merged in the `main` branch (Code + Docstrings)
|
| 19 |
+
- [ ] Release notes have documented the breaking change
|
| 20 |
+
- [ ] A new version of `haystack-ai` has been released on PyPI
|
| 21 |
+
- [ ] Docs at https://docs.haystack.deepset.ai/ were updated
|
| 22 |
+
- [ ] Integrations on [haystack-core-integrations](https://github.com/deepset-ai/haystack-core-integrations) were updated (if needed) - This step might require a [Breaking change proposal](https://github.com/deepset-ai/haystack-core-integrations/issues/new?assignees=&labels=breaking+change&projects=&template=breaking-change-proposal.md&title=) on the repo
|
| 23 |
+
- [ ] Notebooks on https://github.com/deepset-ai/haystack-cookbook were updated (if needed)
|
| 24 |
+
- [ ] Tutorials on https://github.com/deepset-ai/haystack-tutorials were updated (if needed)
|
| 25 |
+
- [ ] Articles on https://github.com/deepset-ai/haystack-home/tree/main/content were updated (if needed)
|
| 26 |
+
- [ ] Integration tile on https://github.com/deepset-ai/haystack-integrations was updated (if needed)
|
| 27 |
+
```
|
SPFsmartGATE/LIVE/TMP/haystack/.github/ISSUE_TEMPLATE/bug_report.md
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
name: Bug report
|
| 3 |
+
about: Errors you encountered
|
| 4 |
+
title: ''
|
| 5 |
+
labels: ''
|
| 6 |
+
assignees: ''
|
| 7 |
+
|
| 8 |
+
---
|
| 9 |
+
|
| 10 |
+
**Describe the bug**
|
| 11 |
+
A clear and concise description of what the bug is.
|
| 12 |
+
|
| 13 |
+
**Error message**
|
| 14 |
+
Error that was thrown (if available)
|
| 15 |
+
|
| 16 |
+
**Expected behavior**
|
| 17 |
+
A clear and concise description of what you expected to happen.
|
| 18 |
+
|
| 19 |
+
**Additional context**
|
| 20 |
+
Add any other context about the problem here, like document types / preprocessing steps / settings of reader etc.
|
| 21 |
+
|
| 22 |
+
**To Reproduce**
|
| 23 |
+
Steps to reproduce the behavior
|
| 24 |
+
|
| 25 |
+
**FAQ Check**
|
| 26 |
+
- [ ] Have you had a look at [our new FAQ page](https://docs.haystack.deepset.ai/docs/faq)?
|
| 27 |
+
|
| 28 |
+
**System:**
|
| 29 |
+
- OS:
|
| 30 |
+
- GPU/CPU:
|
| 31 |
+
- Haystack version (commit or version number):
|
| 32 |
+
- DocumentStore:
|
| 33 |
+
- Reader:
|
| 34 |
+
- Retriever:
|
SPFsmartGATE/LIVE/TMP/haystack/.github/ISSUE_TEMPLATE/config.yml
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
blank_issues_enabled: true
|
| 2 |
+
contact_links:
|
| 3 |
+
- name: Something unclear? Just ask :)
|
| 4 |
+
url: https://github.com/deepset-ai/haystack/discussions/new
|
| 5 |
+
about: Start a Github discussion with your question
|
SPFsmartGATE/LIVE/TMP/haystack/.github/ISSUE_TEMPLATE/feature_request.md
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
name: Feature request
|
| 3 |
+
about: Suggest an idea for this project
|
| 4 |
+
title: ''
|
| 5 |
+
labels: ''
|
| 6 |
+
assignees: ''
|
| 7 |
+
|
| 8 |
+
---
|
| 9 |
+
|
| 10 |
+
**Is your feature request related to a problem? Please describe.**
|
| 11 |
+
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
|
| 12 |
+
|
| 13 |
+
**Describe the solution you'd like**
|
| 14 |
+
A clear and concise description of what you want to happen.
|
| 15 |
+
|
| 16 |
+
**Describe alternatives you've considered**
|
| 17 |
+
A clear and concise description of any alternative solutions or features you've considered.
|
| 18 |
+
|
| 19 |
+
**Additional context**
|
| 20 |
+
Add any other context or screenshots about the feature request here.
|
SPFsmartGATE/LIVE/TMP/haystack/.github/utils/create_unstable_docs.py
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import re
|
| 2 |
+
import sys
|
| 3 |
+
import argparse
|
| 4 |
+
|
| 5 |
+
from readme_api import get_versions, create_new_unstable
|
| 6 |
+
|
| 7 |
+
|
| 8 |
+
VERSION_VALIDATOR = re.compile(r"^[0-9]+\.[0-9]+$")
|
| 9 |
+
|
| 10 |
+
|
| 11 |
+
def calculate_new_unstable(version: str):
|
| 12 |
+
# version must be formatted like so <major>.<minor>
|
| 13 |
+
major, minor = version.split(".")
|
| 14 |
+
return f"{major}.{int(minor) + 1}-unstable"
|
| 15 |
+
|
| 16 |
+
|
| 17 |
+
if __name__ == "__main__":
|
| 18 |
+
parser = argparse.ArgumentParser()
|
| 19 |
+
parser.add_argument(
|
| 20 |
+
"-v", "--new-version", help="The new unstable version that is being created (e.g. 1.9).", required=True
|
| 21 |
+
)
|
| 22 |
+
args = parser.parse_args()
|
| 23 |
+
|
| 24 |
+
if VERSION_VALIDATOR.match(args.new_version) is None:
|
| 25 |
+
sys.exit("Version must be formatted like so <major>.<minor>")
|
| 26 |
+
|
| 27 |
+
# This two are the version that we must have published in the end
|
| 28 |
+
new_stable = f"{args.new_version}"
|
| 29 |
+
new_unstable = calculate_new_unstable(args.new_version)
|
| 30 |
+
|
| 31 |
+
versions = get_versions()
|
| 32 |
+
new_stable_is_published = new_stable in versions
|
| 33 |
+
new_unstable_is_published = new_unstable in versions
|
| 34 |
+
|
| 35 |
+
if new_stable_is_published and new_unstable_is_published:
|
| 36 |
+
# If both versions are published there's nothing to do.
|
| 37 |
+
# We fail gracefully.
|
| 38 |
+
print(f"Both new version {new_stable} and {new_unstable} are already published.")
|
| 39 |
+
sys.exit(0)
|
| 40 |
+
elif new_stable_is_published or new_unstable_is_published:
|
| 41 |
+
# Either new stable or unstable is already published, it's to risky to
|
| 42 |
+
# proceed so we abort the publishing process.
|
| 43 |
+
sys.exit(f"Either version {new_stable} or {new_unstable} are already published. Too risky to proceed.")
|
| 44 |
+
|
| 45 |
+
# This version must exist since it's the one we're trying to promote
|
| 46 |
+
# to stable.
|
| 47 |
+
current_unstable = f"{new_stable}-unstable"
|
| 48 |
+
|
| 49 |
+
if current_unstable not in versions:
|
| 50 |
+
sys.exit(f"Can't find version {current_unstable} to promote to {new_stable}")
|
| 51 |
+
|
| 52 |
+
# Create create new unstable from the currently existing one.
|
| 53 |
+
# The new unstable will be made stable at a later time by another workflow
|
| 54 |
+
create_new_unstable(current_unstable, new_unstable)
|
SPFsmartGATE/LIVE/TMP/haystack/.github/utils/delete_outdated_docs.py
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import argparse
|
| 2 |
+
import base64
|
| 3 |
+
import os
|
| 4 |
+
import re
|
| 5 |
+
from pathlib import Path
|
| 6 |
+
from typing import List
|
| 7 |
+
|
| 8 |
+
import requests
|
| 9 |
+
import yaml
|
| 10 |
+
|
| 11 |
+
VERSION_VALIDATOR = re.compile(r"^[0-9]+\.[0-9]+$")
|
| 12 |
+
|
| 13 |
+
|
| 14 |
+
def readme_token():
|
| 15 |
+
api_key = os.getenv("README_API_KEY", None)
|
| 16 |
+
if not api_key:
|
| 17 |
+
raise Exception("README_API_KEY env var is not set")
|
| 18 |
+
|
| 19 |
+
api_key = f"{api_key}:"
|
| 20 |
+
return base64.b64encode(api_key.encode("utf-8")).decode("utf-8")
|
| 21 |
+
|
| 22 |
+
|
| 23 |
+
def create_headers(version: str):
|
| 24 |
+
return {"authorization": f"Basic {readme_token()}", "x-readme-version": version}
|
| 25 |
+
|
| 26 |
+
|
| 27 |
+
def get_docs_in_category(category_slug: str, version: str) -> List[str]:
|
| 28 |
+
"""
|
| 29 |
+
Returns the slugs of all documents in a category for the specific version.
|
| 30 |
+
"""
|
| 31 |
+
url = f"https://dash.readme.com/api/v1/categories/{category_slug}/docs"
|
| 32 |
+
headers = create_headers(version)
|
| 33 |
+
res = requests.get(url, headers=headers, timeout=10)
|
| 34 |
+
return [doc["slug"] for doc in res.json()]
|
| 35 |
+
|
| 36 |
+
|
| 37 |
+
def delete_doc(slug: str, version: str):
|
| 38 |
+
url = f"https://dash.readme.com/api/v1/docs/{slug}"
|
| 39 |
+
headers = create_headers(version)
|
| 40 |
+
res = requests.delete(url, headers=headers, timeout=10)
|
| 41 |
+
res.raise_for_status()
|
| 42 |
+
|
| 43 |
+
|
| 44 |
+
if __name__ == "__main__":
|
| 45 |
+
parser = argparse.ArgumentParser(
|
| 46 |
+
description="Delete outdated documentation from Readme.io. "
|
| 47 |
+
"It will delete all documents that are not present in the current config files."
|
| 48 |
+
)
|
| 49 |
+
parser.add_argument(
|
| 50 |
+
"-c", "--config-path", help="Path to folder containing YAML documentation configs", required=True, type=Path
|
| 51 |
+
)
|
| 52 |
+
parser.add_argument("-v", "--version", help="The version that will have its documents deleted", required=True)
|
| 53 |
+
args = parser.parse_args()
|
| 54 |
+
|
| 55 |
+
configs = [yaml.safe_load(c.read_text()) for c in args.config_path.glob("*.yml")]
|
| 56 |
+
|
| 57 |
+
remote_docs = {}
|
| 58 |
+
for config in configs:
|
| 59 |
+
category_slug = config["renderer"]["category_slug"]
|
| 60 |
+
if category_slug in remote_docs:
|
| 61 |
+
continue
|
| 62 |
+
docs = get_docs_in_category(category_slug, args.version)
|
| 63 |
+
|
| 64 |
+
remote_docs[category_slug] = docs
|
| 65 |
+
|
| 66 |
+
for config in configs:
|
| 67 |
+
doc_slug = config["renderer"]["slug"]
|
| 68 |
+
category_slug = config["renderer"]["category_slug"]
|
| 69 |
+
if doc_slug in remote_docs[category_slug]:
|
| 70 |
+
continue
|
| 71 |
+
|
| 72 |
+
delete_doc(doc_slug, args.version)
|
SPFsmartGATE/LIVE/TMP/haystack/.github/utils/docstrings_checksum.py
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from pathlib import Path
|
| 2 |
+
from typing import Iterator
|
| 3 |
+
|
| 4 |
+
import ast
|
| 5 |
+
import hashlib
|
| 6 |
+
|
| 7 |
+
|
| 8 |
+
def docstrings_checksum(python_files: Iterator[Path]):
|
| 9 |
+
files_content = (f.read_text() for f in python_files)
|
| 10 |
+
trees = (ast.parse(c) for c in files_content)
|
| 11 |
+
|
| 12 |
+
# Get all docstrings from async functions, functions,
|
| 13 |
+
# classes and modules definitions
|
| 14 |
+
docstrings = []
|
| 15 |
+
for tree in trees:
|
| 16 |
+
for node in ast.walk(tree):
|
| 17 |
+
if not isinstance(node, (ast.AsyncFunctionDef, ast.FunctionDef, ast.ClassDef, ast.Module)):
|
| 18 |
+
# Skip all node types that can't have docstrings to prevent failures
|
| 19 |
+
continue
|
| 20 |
+
docstring = ast.get_docstring(node)
|
| 21 |
+
if docstring:
|
| 22 |
+
docstrings.append(docstring)
|
| 23 |
+
|
| 24 |
+
# Sort them to be safe, since ast.walk() returns
|
| 25 |
+
# nodes in no specified order.
|
| 26 |
+
# See https://docs.python.org/3/library/ast.html#ast.walk
|
| 27 |
+
docstrings.sort()
|
| 28 |
+
|
| 29 |
+
return hashlib.md5(str(docstrings).encode("utf-8")).hexdigest()
|
| 30 |
+
|
| 31 |
+
|
| 32 |
+
if __name__ == "__main__":
|
| 33 |
+
import argparse
|
| 34 |
+
|
| 35 |
+
parser = argparse.ArgumentParser()
|
| 36 |
+
parser.add_argument("--root", help="Haystack root folder", required=True, type=Path)
|
| 37 |
+
args = parser.parse_args()
|
| 38 |
+
|
| 39 |
+
# Get all Haystack and rest_api python files
|
| 40 |
+
root: Path = args.root.absolute()
|
| 41 |
+
haystack_files = root.glob("haystack/**/*.py")
|
| 42 |
+
rest_api_files = root.glob("rest_api/**/*.py")
|
| 43 |
+
|
| 44 |
+
import itertools
|
| 45 |
+
|
| 46 |
+
python_files = itertools.chain(haystack_files, rest_api_files)
|
| 47 |
+
|
| 48 |
+
md5 = docstrings_checksum(python_files)
|
| 49 |
+
print(md5)
|
SPFsmartGATE/LIVE/TMP/haystack/.github/utils/generate_openapi_specs.py
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env python3
|
| 2 |
+
|
| 3 |
+
import json
|
| 4 |
+
from pathlib import Path
|
| 5 |
+
import os
|
| 6 |
+
import sys
|
| 7 |
+
|
| 8 |
+
import logging
|
| 9 |
+
|
| 10 |
+
logging.basicConfig(level=logging.INFO)
|
| 11 |
+
|
| 12 |
+
|
| 13 |
+
sys.path.append(".")
|
| 14 |
+
from rest_api.utils import get_openapi_specs, get_app, get_pipelines # pylint: disable=wrong-import-position
|
| 15 |
+
from haystack import __version__ # pylint: disable=wrong-import-position
|
| 16 |
+
|
| 17 |
+
REST_PATH = Path("./rest_api/rest_api").absolute()
|
| 18 |
+
PIPELINE_PATH = str(REST_PATH / "pipeline" / "pipeline_empty.haystack-pipeline.yml")
|
| 19 |
+
APP_PATH = str(REST_PATH / "application.py")
|
| 20 |
+
|
| 21 |
+
os.environ["PIPELINE_YAML_PATH"] = PIPELINE_PATH
|
| 22 |
+
|
| 23 |
+
logging.info("Loading OpenAPI specs from %s with pipeline at %s", APP_PATH, PIPELINE_PATH)
|
| 24 |
+
|
| 25 |
+
# To initialize the app and the pipelines
|
| 26 |
+
get_app()
|
| 27 |
+
get_pipelines()
|
| 28 |
+
|
| 29 |
+
# Generate the openapi specs
|
| 30 |
+
specs = get_openapi_specs()
|
| 31 |
+
# Add `x-readme` to disable proxy and limit sample languages on documentation (see https://docs.readme.com/main/docs/openapi-extensions)
|
| 32 |
+
specs.update({"x-readme": {"proxy-enabled": False, "samples-languages": ["curl", "python"]}})
|
| 33 |
+
|
| 34 |
+
# Dump the specs into a JSON file
|
| 35 |
+
with open("openapi.json", "w") as f:
|
| 36 |
+
json.dump(specs, f, indent=4)
|
| 37 |
+
f.write("\n") # We need to add a newline, otherwise there will be a conflict with end-of-file-fixer pre-commit hook
|
SPFsmartGATE/LIVE/TMP/haystack/.github/utils/promote_unstable_docs.py
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import re
|
| 2 |
+
import sys
|
| 3 |
+
import argparse
|
| 4 |
+
|
| 5 |
+
from readme_api import get_versions, promote_unstable_to_stable
|
| 6 |
+
|
| 7 |
+
VERSION_VALIDATOR = re.compile(r"^[0-9]+\.[0-9]+$")
|
| 8 |
+
|
| 9 |
+
if __name__ == "__main__":
|
| 10 |
+
parser = argparse.ArgumentParser()
|
| 11 |
+
parser.add_argument(
|
| 12 |
+
"-v", "--version", help="The version to promote to stable (e.g. 2.1).", required=True
|
| 13 |
+
)
|
| 14 |
+
args = parser.parse_args()
|
| 15 |
+
|
| 16 |
+
if VERSION_VALIDATOR.match(args.version) is None:
|
| 17 |
+
sys.exit("Version must be formatted like so <major>.<minor>")
|
| 18 |
+
|
| 19 |
+
unstable_version = f"{args.version}-unstable"
|
| 20 |
+
stable_version = args.version
|
| 21 |
+
|
| 22 |
+
versions = get_versions()
|
| 23 |
+
if stable_version in versions:
|
| 24 |
+
sys.exit(f"Version {stable_version} is already published.")
|
| 25 |
+
|
| 26 |
+
if unstable_version not in versions:
|
| 27 |
+
sys.exit(f"Can't find version {unstable_version} to promote to {stable_version}")
|
| 28 |
+
|
| 29 |
+
promote_unstable_to_stable(unstable_version, stable_version)
|
SPFsmartGATE/LIVE/TMP/haystack/.github/utils/pydoc-markdown.sh
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/bash
|
| 2 |
+
|
| 3 |
+
set -e # Fails on any error in the following loop
|
| 4 |
+
cd docs/pydoc
|
| 5 |
+
rm -rf temp && mkdir temp
|
| 6 |
+
cd temp
|
| 7 |
+
for file in ../config/* ; do
|
| 8 |
+
echo "Converting $file..."
|
| 9 |
+
pydoc-markdown "$file"
|
| 10 |
+
done
|
SPFsmartGATE/LIVE/TMP/haystack/.github/utils/pyproject_to_requirements.py
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import argparse
|
| 2 |
+
import re
|
| 3 |
+
import sys
|
| 4 |
+
from pathlib import Path
|
| 5 |
+
|
| 6 |
+
import toml
|
| 7 |
+
|
| 8 |
+
matcher = re.compile(r"farm-haystack\[(.+)\]")
|
| 9 |
+
parser = argparse.ArgumentParser(
|
| 10 |
+
prog="pyproject_to_requirements.py", description="Convert pyproject.toml to requirements.txt"
|
| 11 |
+
)
|
| 12 |
+
parser.add_argument("pyproject_path")
|
| 13 |
+
parser.add_argument("--extra", default="")
|
| 14 |
+
|
| 15 |
+
|
| 16 |
+
def resolve(target: str, extras: dict, results: set):
|
| 17 |
+
if target not in extras:
|
| 18 |
+
results.add(target)
|
| 19 |
+
return
|
| 20 |
+
|
| 21 |
+
for t in extras[target]:
|
| 22 |
+
m = matcher.match(t)
|
| 23 |
+
if m:
|
| 24 |
+
for i in m.group(1).split(","):
|
| 25 |
+
resolve(i, extras, results)
|
| 26 |
+
else:
|
| 27 |
+
resolve(t, extras, results)
|
| 28 |
+
|
| 29 |
+
|
| 30 |
+
def main(pyproject_path: Path, extra: str = ""):
|
| 31 |
+
content = toml.load(pyproject_path)
|
| 32 |
+
# basic set of dependencies
|
| 33 |
+
deps = set(content["project"]["dependencies"])
|
| 34 |
+
|
| 35 |
+
if extra:
|
| 36 |
+
extras = content["project"]["optional-dependencies"]
|
| 37 |
+
resolve(extra, extras, deps)
|
| 38 |
+
|
| 39 |
+
sys.stdout.write("\n".join(sorted(deps)))
|
| 40 |
+
sys.stdout.write("\n")
|
| 41 |
+
|
| 42 |
+
|
| 43 |
+
if __name__ == "__main__":
|
| 44 |
+
args = parser.parse_args()
|
| 45 |
+
pyproject_path = Path(args.pyproject_path).absolute()
|
| 46 |
+
|
| 47 |
+
main(pyproject_path, args.extra)
|
SPFsmartGATE/LIVE/TMP/haystack/.github/utils/readme_api.py
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import os
|
| 2 |
+
import base64
|
| 3 |
+
import requests
|
| 4 |
+
|
| 5 |
+
|
| 6 |
+
|
| 7 |
+
class ReadmeAuth(requests.auth.AuthBase):
|
| 8 |
+
def __call__(self, r):
|
| 9 |
+
r.headers["authorization"] = f"Basic {readme_token()}"
|
| 10 |
+
return r
|
| 11 |
+
|
| 12 |
+
|
| 13 |
+
def readme_token():
|
| 14 |
+
api_key = os.getenv("RDME_API_KEY", None)
|
| 15 |
+
if not api_key:
|
| 16 |
+
raise Exception("RDME_API_KEY env var is not set")
|
| 17 |
+
|
| 18 |
+
api_key = f"{api_key}:"
|
| 19 |
+
return base64.b64encode(api_key.encode("utf-8")).decode("utf-8")
|
| 20 |
+
|
| 21 |
+
|
| 22 |
+
def get_versions():
|
| 23 |
+
"""
|
| 24 |
+
Return all versions currently published in Readme.io.
|
| 25 |
+
"""
|
| 26 |
+
url = "https://dash.readme.com/api/v1/version"
|
| 27 |
+
res = requests.get(url, auth=ReadmeAuth(), timeout=30)
|
| 28 |
+
res.raise_for_status()
|
| 29 |
+
return [v["version"] for v in res.json()]
|
| 30 |
+
|
| 31 |
+
|
| 32 |
+
def create_new_unstable(current: str, new: str):
|
| 33 |
+
"""
|
| 34 |
+
Create new version by copying current.
|
| 35 |
+
|
| 36 |
+
:param current: Existing current unstable version
|
| 37 |
+
:param new: Non existing new unstable version
|
| 38 |
+
"""
|
| 39 |
+
url = "https://dash.readme.com/api/v1/version/"
|
| 40 |
+
payload = {"is_beta": False, "version": new, "from": current, "is_hidden": False, "is_stable": False}
|
| 41 |
+
res = requests.post(url, json=payload, auth=ReadmeAuth(), timeout=30)
|
| 42 |
+
res.raise_for_status()
|
| 43 |
+
|
| 44 |
+
|
| 45 |
+
def promote_unstable_to_stable(unstable: str, stable: str):
|
| 46 |
+
"""
|
| 47 |
+
Rename the current unstable to stable and set it as stable.
|
| 48 |
+
|
| 49 |
+
:param unstable: Existing unstable version
|
| 50 |
+
:param stable: Non existing new stable version
|
| 51 |
+
"""
|
| 52 |
+
url = f"https://dash.readme.com/api/v1/version/{unstable}"
|
| 53 |
+
payload = {"is_beta": False, "version": stable, "from": unstable, "is_hidden": False, "is_stable": True}
|
| 54 |
+
res = requests.put(url, json=payload, auth=ReadmeAuth(), timeout=30)
|
| 55 |
+
res.raise_for_status()
|
SPFsmartGATE/LIVE/TMP/haystack/.github/workflows/ci_metrics.yml
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
name: CI Metrics
|
| 2 |
+
|
| 3 |
+
on:
|
| 4 |
+
workflow_run:
|
| 5 |
+
workflows:
|
| 6 |
+
- "end-to-end"
|
| 7 |
+
- "Linting"
|
| 8 |
+
- "Tests"
|
| 9 |
+
types:
|
| 10 |
+
- completed
|
| 11 |
+
pull_request:
|
| 12 |
+
types:
|
| 13 |
+
- opened
|
| 14 |
+
- closed
|
| 15 |
+
jobs:
|
| 16 |
+
send:
|
| 17 |
+
runs-on: ubuntu-latest
|
| 18 |
+
steps:
|
| 19 |
+
- uses: int128/datadog-actions-metrics@v1
|
| 20 |
+
with:
|
| 21 |
+
datadog-api-key: ${{ secrets.DATADOG_API_KEY }}
|
| 22 |
+
datadog-site: "datadoghq.eu"
|
| 23 |
+
collect-job-metrics: true
|
SPFsmartGATE/LIVE/TMP/haystack/.github/workflows/docker_release.yml
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
name: Docker image release
|
| 2 |
+
|
| 3 |
+
on:
|
| 4 |
+
workflow_dispatch:
|
| 5 |
+
push:
|
| 6 |
+
branches:
|
| 7 |
+
- main
|
| 8 |
+
tags:
|
| 9 |
+
- "v2.[0-9]+.[0-9]+*"
|
| 10 |
+
|
| 11 |
+
env:
|
| 12 |
+
DOCKER_REPO_NAME: deepset/haystack
|
| 13 |
+
|
| 14 |
+
jobs:
|
| 15 |
+
build-and-push:
|
| 16 |
+
name: Build base image
|
| 17 |
+
runs-on: ubuntu-latest
|
| 18 |
+
if: github.repository_owner == 'deepset-ai'
|
| 19 |
+
|
| 20 |
+
steps:
|
| 21 |
+
- name: Checkout
|
| 22 |
+
uses: actions/checkout@v4
|
| 23 |
+
|
| 24 |
+
- name: Set up QEMU
|
| 25 |
+
uses: docker/setup-qemu-action@v3
|
| 26 |
+
|
| 27 |
+
- name: Set up Docker Buildx
|
| 28 |
+
uses: docker/setup-buildx-action@v3
|
| 29 |
+
|
| 30 |
+
- name: Login to DockerHub
|
| 31 |
+
uses: docker/login-action@v3
|
| 32 |
+
with:
|
| 33 |
+
username: ${{ secrets.DOCKER_HUB_USER }}
|
| 34 |
+
password: ${{ secrets.DOCKER_HUB_TOKEN }}
|
| 35 |
+
|
| 36 |
+
- name: Docker meta
|
| 37 |
+
id: meta
|
| 38 |
+
uses: docker/metadata-action@v5
|
| 39 |
+
with:
|
| 40 |
+
images: $DOCKER_REPO_NAME
|
| 41 |
+
|
| 42 |
+
- name: Build base images
|
| 43 |
+
uses: docker/bake-action@v5
|
| 44 |
+
env:
|
| 45 |
+
IMAGE_TAG_SUFFIX: ${{ steps.meta.outputs.version }}
|
| 46 |
+
HAYSTACK_VERSION: ${{ steps.meta.outputs.version }}
|
| 47 |
+
with:
|
| 48 |
+
workdir: docker
|
| 49 |
+
targets: base
|
| 50 |
+
push: true
|
| 51 |
+
|
| 52 |
+
- name: Test base image
|
| 53 |
+
run: |
|
| 54 |
+
EXPECTED_VERSION=$(cat VERSION.txt)
|
| 55 |
+
if [[ $EXPECTED_VERSION == *"-"* ]]; then
|
| 56 |
+
EXPECTED_VERSION=$(cut -d '-' -f 1 < VERSION.txt)$(cut -d '-' -f 2 < VERSION.txt)
|
| 57 |
+
fi
|
| 58 |
+
TAG="base-${{ steps.meta.outputs.version }}"
|
| 59 |
+
|
| 60 |
+
PLATFORM="linux/amd64"
|
| 61 |
+
VERSION=$(docker run --platform "$PLATFORM" --rm "deepset/haystack:$TAG" python -c"from haystack.version import __version__; print(__version__)")
|
| 62 |
+
[[ "$VERSION" = "$EXPECTED_VERSION" ]] || echo "::error 'Haystack version in deepset/haystack:$TAG image for $PLATFORM is different from expected'"
|
| 63 |
+
|
| 64 |
+
PLATFORM="linux/arm64"
|
| 65 |
+
VERSION=$(docker run --platform "$PLATFORM" --rm "deepset/haystack:$TAG" python -c"from haystack.version import __version__; print(__version__)")
|
| 66 |
+
[[ "$VERSION" = "$EXPECTED_VERSION" ]] || echo "::error 'Haystack version in deepset/haystack:$TAG image for $PLATFORM is different from expected'"
|
| 67 |
+
|
| 68 |
+
# Remove image after test to avoid filling the GitHub runner and prevent its failure
|
| 69 |
+
docker rmi "deepset/haystack:$TAG"
|
SPFsmartGATE/LIVE/TMP/haystack/.github/workflows/docstring_labeler.yml
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
name: Add label on docstrings edit
|
| 2 |
+
|
| 3 |
+
on:
|
| 4 |
+
pull_request_target:
|
| 5 |
+
paths:
|
| 6 |
+
- "haystack/**/*.py"
|
| 7 |
+
|
| 8 |
+
env:
|
| 9 |
+
PYTHON_VERSION: "3.11"
|
| 10 |
+
|
| 11 |
+
jobs:
|
| 12 |
+
label:
|
| 13 |
+
runs-on: ubuntu-latest
|
| 14 |
+
|
| 15 |
+
steps:
|
| 16 |
+
- name: Checkout base commit
|
| 17 |
+
uses: actions/checkout@v4
|
| 18 |
+
with:
|
| 19 |
+
ref: ${{ github.base_ref }}
|
| 20 |
+
|
| 21 |
+
- name: Copy file
|
| 22 |
+
# We copy our script after base ref checkout so we keep executing
|
| 23 |
+
# the same version even after checking out the HEAD ref.
|
| 24 |
+
# This is done to prevent executing malicious code in forks' PRs.
|
| 25 |
+
run: cp .github/utils/docstrings_checksum.py "${{ runner.temp }}/docstrings_checksum.py"
|
| 26 |
+
|
| 27 |
+
- name: Setup Python
|
| 28 |
+
uses: actions/setup-python@v5
|
| 29 |
+
with:
|
| 30 |
+
python-version: "${{ env.PYTHON_VERSION }}"
|
| 31 |
+
|
| 32 |
+
- name: Get docstrings
|
| 33 |
+
id: base-docstrings
|
| 34 |
+
run: |
|
| 35 |
+
CHECKSUM=$(python "${{ runner.temp }}/docstrings_checksum.py" --root "${{ github.workspace }}")
|
| 36 |
+
echo "checksum=$CHECKSUM" >> "$GITHUB_OUTPUT"
|
| 37 |
+
|
| 38 |
+
- name: Checkout HEAD commit
|
| 39 |
+
uses: actions/checkout@v4
|
| 40 |
+
with:
|
| 41 |
+
ref: ${{ github.event.pull_request.head.ref }}
|
| 42 |
+
# This must be set to correctly checkout a fork
|
| 43 |
+
repository: ${{ github.event.pull_request.head.repo.full_name }}
|
| 44 |
+
|
| 45 |
+
- name: Get docstrings
|
| 46 |
+
id: head-docstrings
|
| 47 |
+
run: |
|
| 48 |
+
CHECKSUM=$(python "${{ runner.temp }}/docstrings_checksum.py" --root "${{ github.workspace }}")
|
| 49 |
+
echo "checksum=$CHECKSUM" >> "$GITHUB_OUTPUT"
|
| 50 |
+
|
| 51 |
+
- name: Check if we should label
|
| 52 |
+
id: run-check
|
| 53 |
+
run: echo "should_run=${{ steps.base-docstrings.outputs.checksum != steps.head-docstrings.outputs.checksum }}" >> "$GITHUB_OUTPUT"
|
| 54 |
+
|
| 55 |
+
- name: Add label
|
| 56 |
+
if: ${{ steps.run-check.outputs.should_run == 'true' }}
|
| 57 |
+
env:
|
| 58 |
+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
| 59 |
+
run: gh pr edit ${{ github.event.pull_request.html_url }} --add-label "type:documentation"
|
SPFsmartGATE/LIVE/TMP/haystack/.github/workflows/docstrings_linting.yml
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
name: run docstrings linting
|
| 2 |
+
|
| 3 |
+
on:
|
| 4 |
+
pull_request:
|
| 5 |
+
types:
|
| 6 |
+
- opened
|
| 7 |
+
- reopened
|
| 8 |
+
- synchronize
|
| 9 |
+
- ready_for_review
|
| 10 |
+
paths:
|
| 11 |
+
- "**.py"
|
| 12 |
+
|
| 13 |
+
env:
|
| 14 |
+
HATCH_VERSION: "1.13.0"
|
| 15 |
+
|
| 16 |
+
jobs:
|
| 17 |
+
docstrings-linting:
|
| 18 |
+
runs-on: ubuntu-latest
|
| 19 |
+
|
| 20 |
+
steps:
|
| 21 |
+
- name: Checkout
|
| 22 |
+
uses: actions/checkout@v4
|
| 23 |
+
|
| 24 |
+
- name: Install Hatch
|
| 25 |
+
run: pip install hatch==${{ env.HATCH_VERSION }}
|
| 26 |
+
|
| 27 |
+
- name: ruff docstrings linting
|
| 28 |
+
run: hatch run ruff check haystack
|
SPFsmartGATE/LIVE/TMP/haystack/.github/workflows/e2e.yml
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# If you change this name also do it in ci_metrics.yml
|
| 2 |
+
name: end-to-end
|
| 3 |
+
|
| 4 |
+
on:
|
| 5 |
+
workflow_dispatch: # Activate this workflow manually
|
| 6 |
+
schedule:
|
| 7 |
+
- cron: "0 0 * * *"
|
| 8 |
+
pull_request:
|
| 9 |
+
types:
|
| 10 |
+
- opened
|
| 11 |
+
- reopened
|
| 12 |
+
- synchronize
|
| 13 |
+
- ready_for_review
|
| 14 |
+
paths:
|
| 15 |
+
- "e2e/**/*.py"
|
| 16 |
+
- ".github/workflows/e2e.yml"
|
| 17 |
+
|
| 18 |
+
env:
|
| 19 |
+
PYTHON_VERSION: "3.8"
|
| 20 |
+
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
|
| 21 |
+
HATCH_VERSION: "1.13.0"
|
| 22 |
+
|
| 23 |
+
jobs:
|
| 24 |
+
run:
|
| 25 |
+
timeout-minutes: 60
|
| 26 |
+
runs-on: ubuntu-latest
|
| 27 |
+
steps:
|
| 28 |
+
- uses: actions/checkout@v4
|
| 29 |
+
|
| 30 |
+
- uses: actions/setup-python@v5
|
| 31 |
+
with:
|
| 32 |
+
python-version: "${{ env.PYTHON_VERSION }}"
|
| 33 |
+
|
| 34 |
+
- name: Install Hatch
|
| 35 |
+
run: pip install hatch==${{ env.HATCH_VERSION }}
|
| 36 |
+
|
| 37 |
+
- name: Run tests
|
| 38 |
+
run: hatch run test:e2e
|
| 39 |
+
|
| 40 |
+
- name: Send event to Datadog
|
| 41 |
+
if: failure() && github.event_name == 'schedule'
|
| 42 |
+
uses: masci/datadog@v1
|
| 43 |
+
with:
|
| 44 |
+
api-key: ${{ secrets.CORE_DATADOG_API_KEY }}
|
| 45 |
+
api-url: https://api.datadoghq.eu
|
| 46 |
+
events: |
|
| 47 |
+
- title: "${{ github.workflow }} workflow"
|
| 48 |
+
text: "Job ${{ github.job }} in branch ${{ github.ref_name }}"
|
| 49 |
+
alert_type: "error"
|
| 50 |
+
source_type_name: "Github"
|
| 51 |
+
host: ${{ github.repository_owner }}
|
| 52 |
+
tags:
|
| 53 |
+
- "project:${{ github.repository }}"
|
| 54 |
+
- "job:${{ github.job }}"
|
| 55 |
+
- "run_id:${{ github.run_id }}"
|
| 56 |
+
- "workflow:${{ github.workflow }}"
|
| 57 |
+
- "branch:${{ github.ref_name }}"
|
| 58 |
+
- "url:https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}"
|
SPFsmartGATE/LIVE/TMP/haystack/.github/workflows/github_release.yml
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
name: Project release on Github
|
| 2 |
+
|
| 3 |
+
on:
|
| 4 |
+
workflow_dispatch: # this is useful to re-generate the release page without a new tag being pushed
|
| 5 |
+
push:
|
| 6 |
+
tags:
|
| 7 |
+
- "v2.[0-9]+.[0-9]+*"
|
| 8 |
+
# Ignore release versions tagged with -rc0 suffix
|
| 9 |
+
- "!v2.[0-9]+.[0-9]-rc0"
|
| 10 |
+
|
| 11 |
+
jobs:
|
| 12 |
+
generate-notes:
|
| 13 |
+
runs-on: ubuntu-latest
|
| 14 |
+
|
| 15 |
+
steps:
|
| 16 |
+
- name: Checkout
|
| 17 |
+
uses: actions/checkout@v4
|
| 18 |
+
with:
|
| 19 |
+
fetch-tags: true
|
| 20 |
+
fetch-depth: 0 # slow but needed by reno
|
| 21 |
+
|
| 22 |
+
- name: Parse version
|
| 23 |
+
id: version
|
| 24 |
+
run: |
|
| 25 |
+
echo "current_release=$(awk -F \\- '{print $1}' < VERSION.txt)" >> "$GITHUB_OUTPUT"
|
| 26 |
+
echo "current_pre_release=$(awk -F \\- '{print $2}' < VERSION.txt)" >> "$GITHUB_OUTPUT"
|
| 27 |
+
|
| 28 |
+
- name: Install reno
|
| 29 |
+
run: |
|
| 30 |
+
python -m pip install --upgrade pip
|
| 31 |
+
pip install "reno<5"
|
| 32 |
+
|
| 33 |
+
- name: Generate release notes for release candidates - minor releases
|
| 34 |
+
if: steps.version.outputs.current_pre_release != '' && endsWith(steps.version.outputs.current_release, '.0')
|
| 35 |
+
env:
|
| 36 |
+
# When generating notes for release candidates of minor versions, pick every vX.Y.Z-rcN but
|
| 37 |
+
# stop when encounter vX.Y.Z-rc0. The -rc0 tag is added automatically when
|
| 38 |
+
# we create the release branch, so we can assume it's always there.
|
| 39 |
+
EARLIEST_VERSION: v${{ steps.version.outputs.current_release }}-rc0
|
| 40 |
+
run: |
|
| 41 |
+
reno report --no-show-source --ignore-cache --earliest-version "$EARLIEST_VERSION" -o relnotes.rst
|
| 42 |
+
|
| 43 |
+
- name: Generate release notes for release candidates - bugfix releases
|
| 44 |
+
if: steps.version.outputs.current_pre_release != '' && !endsWith(steps.version.outputs.current_release, '.0')
|
| 45 |
+
env:
|
| 46 |
+
# When generating notes for release candidates of bugfix releases, pick every vX.Y.Z-rcN but
|
| 47 |
+
# stop when encounter vX.Y.Z-rc1.
|
| 48 |
+
# In this case, we don't have the -rc0 tag, because we don't need to go through commits on main,
|
| 49 |
+
# as we cherry-pick them into the release branch.
|
| 50 |
+
EARLIEST_VERSION: v${{ steps.version.outputs.current_release }}-rc1
|
| 51 |
+
run: |
|
| 52 |
+
reno report --no-show-source --ignore-cache --earliest-version "$EARLIEST_VERSION" -o relnotes.rst
|
| 53 |
+
|
| 54 |
+
- name: Generate release notes for the final release
|
| 55 |
+
if: steps.version.outputs.current_pre_release == ''
|
| 56 |
+
# When generating notes for the final release vX.Y.Z, we just pass --version and reno
|
| 57 |
+
# will automatically collapse all the vX.Y.Z-rcN.
|
| 58 |
+
run: |
|
| 59 |
+
reno report --no-show-source --ignore-cache --version v${{ steps.version.outputs.current_release }} -o relnotes.rst
|
| 60 |
+
|
| 61 |
+
- name: Convert to Markdown
|
| 62 |
+
uses: docker://pandoc/core:3.1
|
| 63 |
+
with:
|
| 64 |
+
args: "--from rst --to markdown_github --no-highlight relnotes.rst -o relnotes.md --wrap=none"
|
| 65 |
+
|
| 66 |
+
- name: Debug
|
| 67 |
+
run: |
|
| 68 |
+
cat relnotes.md
|
| 69 |
+
|
| 70 |
+
- uses: ncipollo/release-action@v1
|
| 71 |
+
with:
|
| 72 |
+
bodyFile: "relnotes.md"
|
| 73 |
+
prerelease: ${{ steps.version.outputs.current_pre_release }}
|
| 74 |
+
allowUpdates: true
|
SPFsmartGATE/LIVE/TMP/haystack/.github/workflows/labeler.yml
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
name: "Labeler"
|
| 2 |
+
on:
|
| 3 |
+
- pull_request_target
|
| 4 |
+
|
| 5 |
+
permissions:
|
| 6 |
+
contents: read
|
| 7 |
+
pull-requests: write
|
| 8 |
+
|
| 9 |
+
jobs:
|
| 10 |
+
triage:
|
| 11 |
+
runs-on: ubuntu-latest
|
| 12 |
+
steps:
|
| 13 |
+
- uses: actions/labeler@v5
|
| 14 |
+
with:
|
| 15 |
+
repo-token: "${{ secrets.GITHUB_TOKEN }}"
|
SPFsmartGATE/LIVE/TMP/haystack/.github/workflows/license_compliance.yml
ADDED
|
@@ -0,0 +1,92 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
name: License Compliance
|
| 2 |
+
|
| 3 |
+
on:
|
| 4 |
+
pull_request:
|
| 5 |
+
paths:
|
| 6 |
+
- "**/pyproject.toml"
|
| 7 |
+
# Since we test PRs, there is no need to run the workflow at each
|
| 8 |
+
# merge on `main`. Let's use a cron job instead.
|
| 9 |
+
schedule:
|
| 10 |
+
- cron: "0 0 * * *" # every day at midnight
|
| 11 |
+
|
| 12 |
+
env:
|
| 13 |
+
CORE_DATADOG_API_KEY: ${{ secrets.CORE_DATADOG_API_KEY }}
|
| 14 |
+
PYTHON_VERSION: "3.10"
|
| 15 |
+
|
| 16 |
+
jobs:
|
| 17 |
+
license_check_direct:
|
| 18 |
+
name: Direct dependencies only
|
| 19 |
+
env:
|
| 20 |
+
REQUIREMENTS_FILE: requirements_direct.txt
|
| 21 |
+
runs-on: ubuntu-latest
|
| 22 |
+
steps:
|
| 23 |
+
- name: Checkout the code
|
| 24 |
+
uses: actions/checkout@v4
|
| 25 |
+
|
| 26 |
+
- name: Setup Python
|
| 27 |
+
uses: actions/setup-python@v5
|
| 28 |
+
with:
|
| 29 |
+
python-version: "${{ env.PYTHON_VERSION }}"
|
| 30 |
+
|
| 31 |
+
- name: Get direct dependencies
|
| 32 |
+
run: |
|
| 33 |
+
pip install toml
|
| 34 |
+
python .github/utils/pyproject_to_requirements.py pyproject.toml > ${{ env.REQUIREMENTS_FILE }}
|
| 35 |
+
|
| 36 |
+
- name: Check Licenses
|
| 37 |
+
id: license_check_report
|
| 38 |
+
uses: pilosus/action-pip-license-checker@v2
|
| 39 |
+
with:
|
| 40 |
+
github-token: ${{ secrets.GH_ACCESS_TOKEN }}
|
| 41 |
+
requirements: ${{ env.REQUIREMENTS_FILE }}
|
| 42 |
+
fail: "Copyleft,Other,Error"
|
| 43 |
+
# Exclusions in the vanilla distribution must be explicitly motivated
|
| 44 |
+
#
|
| 45 |
+
# - tqdm is MLP but there are no better alternatives
|
| 46 |
+
exclude: "(?i)^(tqdm).*"
|
| 47 |
+
|
| 48 |
+
# We keep the license inventory on FOSSA
|
| 49 |
+
- name: Send license report to Fossa
|
| 50 |
+
uses: fossas/fossa-action@v1.4.0
|
| 51 |
+
continue-on-error: true # not critical
|
| 52 |
+
with:
|
| 53 |
+
api-key: ${{ secrets.FOSSA_LICENSE_SCAN_TOKEN }}
|
| 54 |
+
|
| 55 |
+
- name: Print report
|
| 56 |
+
if: ${{ always() }}
|
| 57 |
+
run: echo "${{ steps.license_check_report.outputs.report }}"
|
| 58 |
+
|
| 59 |
+
- name: Calculate alert data
|
| 60 |
+
id: calculator
|
| 61 |
+
shell: bash
|
| 62 |
+
if: (success() || failure())
|
| 63 |
+
run: |
|
| 64 |
+
if [ "${{ job.status }}" = "success" ]; then
|
| 65 |
+
echo "alert_type=success" >> "$GITHUB_OUTPUT";
|
| 66 |
+
else
|
| 67 |
+
echo "alert_type=error" >> "$GITHUB_OUTPUT";
|
| 68 |
+
fi
|
| 69 |
+
|
| 70 |
+
- name: Send event to Datadog
|
| 71 |
+
# This step would fail when running in PRs opened from forks since
|
| 72 |
+
# secrets are not accessible.
|
| 73 |
+
# To prevent showing bogus failures in those PRs we skip the step.
|
| 74 |
+
# The workflow will fail in any case if the actual check fails in the previous steps.
|
| 75 |
+
if: (success() || failure()) && env.CORE_DATADOG_API_KEY != ''
|
| 76 |
+
uses: masci/datadog@v1
|
| 77 |
+
with:
|
| 78 |
+
api-key: ${{ env.CORE_DATADOG_API_KEY }}
|
| 79 |
+
api-url: https://api.datadoghq.eu
|
| 80 |
+
events: |
|
| 81 |
+
- title: "${{ github.job }} in ${{ github.workflow }} workflow"
|
| 82 |
+
text: "License compliance check: direct dependencies only."
|
| 83 |
+
alert_type: "${{ steps.calculator.outputs.alert_type }}"
|
| 84 |
+
source_type_name: "Github"
|
| 85 |
+
host: ${{ github.repository_owner }}
|
| 86 |
+
tags:
|
| 87 |
+
- "project:${{ github.repository }}"
|
| 88 |
+
- "job:${{ github.job }}"
|
| 89 |
+
- "run_id:${{ github.run_id }}"
|
| 90 |
+
- "workflow:${{ github.workflow }}"
|
| 91 |
+
- "branch:${{ github.ref_name }}"
|
| 92 |
+
- "url:https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}"
|
SPFsmartGATE/LIVE/TMP/haystack/.github/workflows/minor_version_release.yml
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
name: Minor Version Release
|
| 2 |
+
|
| 3 |
+
on:
|
| 4 |
+
workflow_dispatch:
|
| 5 |
+
|
| 6 |
+
env:
|
| 7 |
+
PYTHON_VERSION: "3.8"
|
| 8 |
+
|
| 9 |
+
jobs:
|
| 10 |
+
sync:
|
| 11 |
+
runs-on: ubuntu-latest
|
| 12 |
+
steps:
|
| 13 |
+
- name: Checkout this repo
|
| 14 |
+
uses: actions/checkout@v4
|
| 15 |
+
with:
|
| 16 |
+
ref: main
|
| 17 |
+
|
| 18 |
+
- name: Define all versions
|
| 19 |
+
id: versions
|
| 20 |
+
shell: bash
|
| 21 |
+
# We only need `major.minor` in Readme so we cut the full version string to the first two tokens
|
| 22 |
+
run: |
|
| 23 |
+
echo "current_release_minor=$(cut -d "." -f 1,2 < VERSION.txt)" >> "$GITHUB_OUTPUT"
|
| 24 |
+
|
| 25 |
+
- name: Bump version on main
|
| 26 |
+
shell: bash
|
| 27 |
+
env:
|
| 28 |
+
# We use the HAYSTACK_BOT_TOKEN here so the PR created by the step will
|
| 29 |
+
# trigger required workflows and can be merged by anyone
|
| 30 |
+
GITHUB_TOKEN: ${{ secrets.HAYSTACK_BOT_TOKEN }}
|
| 31 |
+
run: |
|
| 32 |
+
git config --global user.name "github-actions[bot]"
|
| 33 |
+
git config --global user.email "github-actions[bot]@users.noreply.github.com"
|
| 34 |
+
|
| 35 |
+
git checkout main
|
| 36 |
+
|
| 37 |
+
# Create the release branch from the current unstable
|
| 38 |
+
git checkout -b v${{ steps.versions.outputs.current_release_minor }}.x
|
| 39 |
+
git push -u origin v${{ steps.versions.outputs.current_release_minor }}.x
|
| 40 |
+
|
| 41 |
+
# Tag the base with X.Y.Z-rc0.
|
| 42 |
+
# At this point VERSION.txt still contains the previous version and not
|
| 43 |
+
# the one specified by the tag.
|
| 44 |
+
# This is good though as we just need this to make reno work properly.
|
| 45 |
+
NEW_VERSION=$(awk -F. '/[0-9]+\./{$2++;print}' OFS=. < VERSION.txt)
|
| 46 |
+
echo "$NEW_VERSION" > VERSION.txt
|
| 47 |
+
VERSION_TAG="v$NEW_VERSION"
|
| 48 |
+
git tag "$VERSION_TAG" -m"$VERSION_TAG"
|
| 49 |
+
git push --tags
|
| 50 |
+
|
| 51 |
+
# Create the branch that bump version in dev branch
|
| 52 |
+
cat VERSION.txt
|
| 53 |
+
git checkout -b bump-version
|
| 54 |
+
git add .
|
| 55 |
+
git commit -m "Update unstable version to $NEW_VERSION"
|
| 56 |
+
git push -u origin bump-version
|
| 57 |
+
|
| 58 |
+
# Create the PR
|
| 59 |
+
gh pr create -B main \
|
| 60 |
+
-H bump-version \
|
| 61 |
+
--title "Bump unstable version" \
|
| 62 |
+
--body "This PR bumps the unstable version for \`v2.x\`. \
|
| 63 |
+
The release branch \`v${{ steps.versions.outputs.current_release_minor }}.x\` has been correctly created. \
|
| 64 |
+
Verify documentation on Readme has been correctly updated before approving and merging this PR." \
|
| 65 |
+
--label "ignore-for-release-notes"
|
| 66 |
+
|
| 67 |
+
- uses: actions/setup-python@v5
|
| 68 |
+
with:
|
| 69 |
+
python-version: "${{ env.PYTHON_VERSION }}"
|
| 70 |
+
|
| 71 |
+
- name: Install create_unstable_docs.py dependencies
|
| 72 |
+
run: pip install requests
|
| 73 |
+
|
| 74 |
+
- name: Release Readme version
|
| 75 |
+
env:
|
| 76 |
+
RDME_API_KEY: ${{ secrets.README_API_KEY }}
|
| 77 |
+
run: |
|
| 78 |
+
git checkout main
|
| 79 |
+
python ./.github/utils/create_unstable_docs.py --new-version ${{ steps.versions.outputs.current_release_minor }}
|
SPFsmartGATE/LIVE/TMP/haystack/.github/workflows/project.yml
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
name: Track issues with Github project
|
| 2 |
+
|
| 3 |
+
on:
|
| 4 |
+
issues:
|
| 5 |
+
types:
|
| 6 |
+
- opened
|
| 7 |
+
|
| 8 |
+
jobs:
|
| 9 |
+
add-to-project:
|
| 10 |
+
name: Add new issues to project for triage
|
| 11 |
+
runs-on: ubuntu-latest
|
| 12 |
+
steps:
|
| 13 |
+
- uses: actions/add-to-project@v1.0.2
|
| 14 |
+
with:
|
| 15 |
+
project-url: https://github.com/orgs/deepset-ai/projects/5
|
| 16 |
+
github-token: ${{ secrets.GH_PROJECT_PAT }}
|
SPFsmartGATE/LIVE/TMP/haystack/.github/workflows/promote_unstable_docs.yml
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
name: Release new minor version docs
|
| 2 |
+
|
| 3 |
+
on:
|
| 4 |
+
push:
|
| 5 |
+
tags:
|
| 6 |
+
# Trigger this only for the first patch release of the new minor
|
| 7 |
+
- "v[0-9]+.[0-9]+.0"
|
| 8 |
+
# Exclude 1.x tags
|
| 9 |
+
- "!v1.[0-9]+.[0-9]+"
|
| 10 |
+
env:
|
| 11 |
+
PYTHON_VERSION: "3.8"
|
| 12 |
+
|
| 13 |
+
jobs:
|
| 14 |
+
promote:
|
| 15 |
+
runs-on: ubuntu-latest
|
| 16 |
+
steps:
|
| 17 |
+
- name: Checkout this repo
|
| 18 |
+
uses: actions/checkout@v4
|
| 19 |
+
|
| 20 |
+
- name: Get version to release
|
| 21 |
+
id: version
|
| 22 |
+
shell: bash
|
| 23 |
+
# We only need `major.minor` in Readme so we cut the full version string to the first two tokens
|
| 24 |
+
run: |
|
| 25 |
+
echo "version=$(cut -d "." -f 1,2 < VERSION.txt)" >> "$GITHUB_OUTPUT"
|
| 26 |
+
|
| 27 |
+
- uses: actions/setup-python@v5
|
| 28 |
+
with:
|
| 29 |
+
python-version: "${{ env.PYTHON_VERSION }}"
|
| 30 |
+
|
| 31 |
+
- name: Install promote_unstable_docs.py dependencies
|
| 32 |
+
run: pip install requests
|
| 33 |
+
|
| 34 |
+
- name: Release Readme version
|
| 35 |
+
env:
|
| 36 |
+
RDME_API_KEY: ${{ secrets.README_API_KEY }}
|
| 37 |
+
run: |
|
| 38 |
+
python ./.github/utils/promote_unstable_docs.py --version ${{ steps.version.outputs.version }}
|
SPFsmartGATE/LIVE/TMP/haystack/.github/workflows/pypi_release.yml
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
name: Project release on PyPi
|
| 2 |
+
|
| 3 |
+
on:
|
| 4 |
+
push:
|
| 5 |
+
tags:
|
| 6 |
+
- "v[0-9]+.[0-9]+.[0-9]+*"
|
| 7 |
+
# We must not release versions tagged with -rc0 suffix
|
| 8 |
+
- "!v[0-9]+.[0-9]+.[0-9]-rc0"
|
| 9 |
+
|
| 10 |
+
env:
|
| 11 |
+
HATCH_VERSION: "1.13.0"
|
| 12 |
+
|
| 13 |
+
jobs:
|
| 14 |
+
release-on-pypi:
|
| 15 |
+
runs-on: ubuntu-latest
|
| 16 |
+
|
| 17 |
+
steps:
|
| 18 |
+
- name: Checkout
|
| 19 |
+
uses: actions/checkout@v4
|
| 20 |
+
|
| 21 |
+
- name: Install Hatch
|
| 22 |
+
run: pip install hatch==${{ env.HATCH_VERSION }}
|
| 23 |
+
|
| 24 |
+
- name: Build Haystack
|
| 25 |
+
run: hatch build
|
| 26 |
+
|
| 27 |
+
- name: Publish on PyPi
|
| 28 |
+
env:
|
| 29 |
+
HATCH_INDEX_USER: __token__
|
| 30 |
+
HATCH_INDEX_AUTH: ${{ secrets.HAYSTACK_AI_PYPI_TOKEN }}
|
| 31 |
+
run: hatch publish -y
|
SPFsmartGATE/LIVE/TMP/haystack/.github/workflows/readme_sync.yml
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
name: Sync docs with Readme
|
| 2 |
+
|
| 3 |
+
on:
|
| 4 |
+
pull_request:
|
| 5 |
+
paths:
|
| 6 |
+
- "docs/pydoc/**"
|
| 7 |
+
push:
|
| 8 |
+
branches:
|
| 9 |
+
- main
|
| 10 |
+
# release branches have the form v1.9.x
|
| 11 |
+
- "v[0-9]+.[0-9]+.x"
|
| 12 |
+
# Exclude 1.x release branches, there's another workflow handling those
|
| 13 |
+
- "!v1.[0-9]+.x"
|
| 14 |
+
|
| 15 |
+
env:
|
| 16 |
+
HATCH_VERSION: "1.13.0"
|
| 17 |
+
PYTHON_VERSION: "3.10"
|
| 18 |
+
|
| 19 |
+
jobs:
|
| 20 |
+
sync:
|
| 21 |
+
runs-on: ubuntu-latest
|
| 22 |
+
steps:
|
| 23 |
+
- name: Checkout this repo
|
| 24 |
+
uses: actions/checkout@v4
|
| 25 |
+
|
| 26 |
+
- name: Set up Python
|
| 27 |
+
uses: actions/setup-python@v5
|
| 28 |
+
with:
|
| 29 |
+
python-version: "${{ env.PYTHON_VERSION }}"
|
| 30 |
+
|
| 31 |
+
- name: Install Hatch
|
| 32 |
+
run: pip install hatch==${{ env.HATCH_VERSION }}
|
| 33 |
+
|
| 34 |
+
- name: Generate API docs
|
| 35 |
+
env:
|
| 36 |
+
# This is necessary to fetch the documentation categories
|
| 37 |
+
# from Readme.io as we need them to associate the slug
|
| 38 |
+
# in config files with their id.
|
| 39 |
+
README_API_KEY: ${{ secrets.README_API_KEY }}
|
| 40 |
+
# The command is a bit misleading, we're not actually syncing anything here,
|
| 41 |
+
# we're just generating the markdown files from the yaml configs.
|
| 42 |
+
run: hatch run readme:sync
|
| 43 |
+
|
| 44 |
+
- name: Get version
|
| 45 |
+
id: version-getter
|
| 46 |
+
run: |
|
| 47 |
+
VERSION="$(hatch version | cut -d '.' -f 1,2)"
|
| 48 |
+
CURRENT_BRANCH="${{ github.ref_name }}"
|
| 49 |
+
# If we're on `main` branch we should push docs to the unstable version
|
| 50 |
+
if [ "$CURRENT_BRANCH" = "main" ]; then
|
| 51 |
+
VERSION="$VERSION-unstable"
|
| 52 |
+
fi
|
| 53 |
+
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
|
| 54 |
+
|
| 55 |
+
- name: Sync docs
|
| 56 |
+
if: github.event_name == 'push'
|
| 57 |
+
uses: readmeio/rdme@v8
|
| 58 |
+
with:
|
| 59 |
+
rdme: docs ./docs/pydoc/temp --key=${{ secrets.README_API_KEY }} --version=${{ steps.version-getter.outputs.version }}
|
| 60 |
+
|
| 61 |
+
- name: Delete outdated
|
| 62 |
+
if: github.event_name == 'push'
|
| 63 |
+
env:
|
| 64 |
+
README_API_KEY: ${{ secrets.README_API_KEY }}
|
| 65 |
+
run: hatch run readme:delete-outdated --version="${{ steps.version-getter.outputs.version }}" --config-path ./docs/pydoc/config
|
SPFsmartGATE/LIVE/TMP/haystack/.github/workflows/release_notes.yml
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
name: Check Release Notes
|
| 2 |
+
|
| 3 |
+
on:
|
| 4 |
+
pull_request:
|
| 5 |
+
types:
|
| 6 |
+
- opened
|
| 7 |
+
- reopened
|
| 8 |
+
- synchronize
|
| 9 |
+
- ready_for_review
|
| 10 |
+
- labeled
|
| 11 |
+
- unlabeled
|
| 12 |
+
paths:
|
| 13 |
+
- "**.py"
|
| 14 |
+
- "pyproject.toml"
|
| 15 |
+
- "!.github/**/*.py"
|
| 16 |
+
|
| 17 |
+
jobs:
|
| 18 |
+
reno:
|
| 19 |
+
runs-on: ubuntu-latest
|
| 20 |
+
steps:
|
| 21 |
+
- name: Checkout
|
| 22 |
+
uses: actions/checkout@v4
|
| 23 |
+
with:
|
| 24 |
+
# With the default value of 1, there are corner cases where tj-actions/changed-files
|
| 25 |
+
# fails with a `no merge base` error
|
| 26 |
+
fetch-depth: 0
|
| 27 |
+
|
| 28 |
+
- name: Get release note files
|
| 29 |
+
id: changed-files
|
| 30 |
+
uses: tj-actions/changed-files@v45
|
| 31 |
+
with:
|
| 32 |
+
files: releasenotes/notes/*.yaml
|
| 33 |
+
|
| 34 |
+
- name: Check release notes
|
| 35 |
+
if: steps.changed-files.outputs.any_changed == 'false' && !contains( github.event.pull_request.labels.*.name, 'ignore-for-release-notes')
|
| 36 |
+
run: |
|
| 37 |
+
# Check if any of the commit messages contain tags ci/docs/test
|
| 38 |
+
if git log --pretty=%s origin/main..HEAD | grep -E '^(ci:|docs:|test:)' > /dev/null; then
|
| 39 |
+
echo "Skipping release note check for commits with 'ci:', 'docs:', or 'test:' tags."
|
| 40 |
+
else
|
| 41 |
+
echo "::error::The release notes file is missing, please add one or attach the label 'ignore-for-release-notes' to this PR."
|
| 42 |
+
exit 1
|
| 43 |
+
fi
|
| 44 |
+
|
| 45 |
+
- name: Verify release notes formatting
|
| 46 |
+
if: steps.changed-files.outputs.any_changed == 'true' && !contains( github.event.pull_request.labels.*.name, 'ignore-for-release-notes')
|
| 47 |
+
run: |
|
| 48 |
+
yamllint -d "{extends: default, rules: {line-length: {max: 1200}}}" ${{ steps.changed-files.outputs.all_changed_files }}
|
SPFsmartGATE/LIVE/TMP/haystack/.github/workflows/release_notes_skipper.yml
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
name: Check Release Notes
|
| 2 |
+
|
| 3 |
+
on:
|
| 4 |
+
pull_request:
|
| 5 |
+
types:
|
| 6 |
+
- opened
|
| 7 |
+
- reopened
|
| 8 |
+
- synchronize
|
| 9 |
+
- ready_for_review
|
| 10 |
+
- labeled
|
| 11 |
+
- unlabeled
|
| 12 |
+
paths-ignore:
|
| 13 |
+
- "**.py"
|
| 14 |
+
- "pyproject.toml"
|
| 15 |
+
- "!.github/**/*.py"
|
| 16 |
+
|
| 17 |
+
jobs:
|
| 18 |
+
reno:
|
| 19 |
+
runs-on: ubuntu-latest
|
| 20 |
+
steps:
|
| 21 |
+
- name: Skip mandatory job
|
| 22 |
+
run: echo "Skipped!"
|
SPFsmartGATE/LIVE/TMP/haystack/.github/workflows/stale.yml
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
name: 'Stalebot'
|
| 2 |
+
on:
|
| 3 |
+
schedule:
|
| 4 |
+
- cron: '30 1 * * *'
|
| 5 |
+
|
| 6 |
+
jobs:
|
| 7 |
+
makestale:
|
| 8 |
+
runs-on: ubuntu-latest
|
| 9 |
+
steps:
|
| 10 |
+
- uses: actions/stale@v9
|
| 11 |
+
with:
|
| 12 |
+
any-of-labels: 'proposal,community-triage'
|
| 13 |
+
stale-pr-message: 'This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 10 days.'
|
| 14 |
+
days-before-stale: 30
|
| 15 |
+
days-before-close: 10
|
SPFsmartGATE/LIVE/TMP/haystack/.github/workflows/tests.yml
ADDED
|
@@ -0,0 +1,442 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# If you change this name also do it in tests_skipper.yml and ci_metrics.yml
|
| 2 |
+
name: Tests
|
| 3 |
+
|
| 4 |
+
on:
|
| 5 |
+
workflow_dispatch: # Activate this workflow manually
|
| 6 |
+
push:
|
| 7 |
+
branches:
|
| 8 |
+
- main
|
| 9 |
+
# release branches have the form v1.9.x
|
| 10 |
+
- "v[0-9].*[0-9].x"
|
| 11 |
+
pull_request:
|
| 12 |
+
types:
|
| 13 |
+
- opened
|
| 14 |
+
- reopened
|
| 15 |
+
- synchronize
|
| 16 |
+
- ready_for_review
|
| 17 |
+
paths:
|
| 18 |
+
# Keep the list in sync with the paths defined in the `tests_skipper.yml` workflow
|
| 19 |
+
- "haystack/**/*.py"
|
| 20 |
+
- "haystack/core/pipeline/predefined/*"
|
| 21 |
+
- "test/**/*.py"
|
| 22 |
+
- "pyproject.toml"
|
| 23 |
+
|
| 24 |
+
env:
|
| 25 |
+
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
|
| 26 |
+
CORE_AZURE_CS_ENDPOINT: ${{ secrets.CORE_AZURE_CS_ENDPOINT }}
|
| 27 |
+
CORE_AZURE_CS_API_KEY: ${{ secrets.CORE_AZURE_CS_API_KEY }}
|
| 28 |
+
AZURE_OPENAI_API_KEY: ${{ secrets.AZURE_OPENAI_API_KEY }}
|
| 29 |
+
AZURE_OPENAI_ENDPOINT: ${{ secrets.AZURE_OPENAI_ENDPOINT }}
|
| 30 |
+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
| 31 |
+
HF_API_TOKEN: ${{ secrets.HUGGINGFACE_API_KEY }}
|
| 32 |
+
PYTHON_VERSION: "3.8"
|
| 33 |
+
HATCH_VERSION: "1.13.0"
|
| 34 |
+
|
| 35 |
+
jobs:
|
| 36 |
+
format:
|
| 37 |
+
runs-on: ubuntu-latest
|
| 38 |
+
steps:
|
| 39 |
+
- uses: actions/checkout@v4
|
| 40 |
+
|
| 41 |
+
- uses: actions/setup-python@v5
|
| 42 |
+
with:
|
| 43 |
+
python-version: "${{ env.PYTHON_VERSION }}"
|
| 44 |
+
|
| 45 |
+
- name: Install Hatch
|
| 46 |
+
run: pip install hatch==${{ env.HATCH_VERSION }}
|
| 47 |
+
|
| 48 |
+
- name: Check file format
|
| 49 |
+
run: hatch run format-check
|
| 50 |
+
|
| 51 |
+
- name: Check linting
|
| 52 |
+
run: hatch run check
|
| 53 |
+
|
| 54 |
+
- name: Check presence of license header
|
| 55 |
+
run: docker run --rm -v "$(pwd):/github/workspace" ghcr.io/korandoru/hawkeye check
|
| 56 |
+
|
| 57 |
+
- name: Calculate alert data
|
| 58 |
+
id: calculator
|
| 59 |
+
shell: bash
|
| 60 |
+
if: (success() || failure()) && github.ref_name == 'main'
|
| 61 |
+
run: |
|
| 62 |
+
if [ "${{ job.status }}" = "success" ]; then
|
| 63 |
+
echo "alert_type=success" >> "$GITHUB_OUTPUT";
|
| 64 |
+
else
|
| 65 |
+
echo "alert_type=error" >> "$GITHUB_OUTPUT";
|
| 66 |
+
fi
|
| 67 |
+
|
| 68 |
+
- name: Send event to Datadog
|
| 69 |
+
if: (success() || failure()) && github.ref_name == 'main'
|
| 70 |
+
uses: masci/datadog@v1
|
| 71 |
+
with:
|
| 72 |
+
api-key: ${{ secrets.CORE_DATADOG_API_KEY }}
|
| 73 |
+
api-url: https://api.datadoghq.eu
|
| 74 |
+
events: |
|
| 75 |
+
- title: "${{ github.workflow }} workflow"
|
| 76 |
+
text: "Job ${{ github.job }} in branch ${{ github.ref_name }}"
|
| 77 |
+
alert_type: "${{ steps.calculator.outputs.alert_type }}"
|
| 78 |
+
source_type_name: "Github"
|
| 79 |
+
host: ${{ github.repository_owner }}
|
| 80 |
+
tags:
|
| 81 |
+
- "project:${{ github.repository }}"
|
| 82 |
+
- "job:${{ github.job }}"
|
| 83 |
+
- "run_id:${{ github.run_id }}"
|
| 84 |
+
- "workflow:${{ github.workflow }}"
|
| 85 |
+
- "branch:${{ github.ref_name }}"
|
| 86 |
+
- "url:https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}"
|
| 87 |
+
|
| 88 |
+
unit-tests:
|
| 89 |
+
name: Unit / ${{ matrix.os }}
|
| 90 |
+
needs: format
|
| 91 |
+
strategy:
|
| 92 |
+
fail-fast: false
|
| 93 |
+
matrix:
|
| 94 |
+
os:
|
| 95 |
+
- ubuntu-latest
|
| 96 |
+
- windows-latest
|
| 97 |
+
- macos-latest
|
| 98 |
+
runs-on: ${{ matrix.os }}
|
| 99 |
+
steps:
|
| 100 |
+
- uses: actions/checkout@v4
|
| 101 |
+
|
| 102 |
+
- uses: actions/setup-python@v5
|
| 103 |
+
with:
|
| 104 |
+
python-version: "${{ env.PYTHON_VERSION }}"
|
| 105 |
+
|
| 106 |
+
- name: Install Hatch
|
| 107 |
+
id: hatch
|
| 108 |
+
shell: bash
|
| 109 |
+
run: |
|
| 110 |
+
pip install hatch==${{ env.HATCH_VERSION }}
|
| 111 |
+
echo "env=$(hatch env find test)" >> "$GITHUB_OUTPUT"
|
| 112 |
+
|
| 113 |
+
- name: Run
|
| 114 |
+
run: hatch run test:unit
|
| 115 |
+
|
| 116 |
+
- uses: actions/cache/save@v4
|
| 117 |
+
id: cache
|
| 118 |
+
with:
|
| 119 |
+
path: ${{ steps.hatch.outputs.env }}
|
| 120 |
+
key: ${{ runner.os }}-${{ github.sha }}
|
| 121 |
+
|
| 122 |
+
- name: Coveralls
|
| 123 |
+
# We upload only coverage for ubuntu as handling both os
|
| 124 |
+
# complicates the workflow too much for little to no gain
|
| 125 |
+
if: matrix.os == 'ubuntu-latest'
|
| 126 |
+
uses: coverallsapp/github-action@v2
|
| 127 |
+
with:
|
| 128 |
+
path-to-lcov: coverage.xml
|
| 129 |
+
|
| 130 |
+
- name: Calculate alert data
|
| 131 |
+
id: calculator
|
| 132 |
+
shell: bash
|
| 133 |
+
if: (success() || failure()) && github.ref_name == 'main'
|
| 134 |
+
run: |
|
| 135 |
+
if [ "${{ job.status }}" = "success" ]; then
|
| 136 |
+
echo "alert_type=success" >> "$GITHUB_OUTPUT";
|
| 137 |
+
else
|
| 138 |
+
echo "alert_type=error" >> "$GITHUB_OUTPUT";
|
| 139 |
+
fi
|
| 140 |
+
|
| 141 |
+
- name: Send event to Datadog
|
| 142 |
+
if: (success() || failure()) && github.ref_name == 'main'
|
| 143 |
+
uses: masci/datadog@v1
|
| 144 |
+
with:
|
| 145 |
+
api-key: ${{ secrets.CORE_DATADOG_API_KEY }}
|
| 146 |
+
api-url: https://api.datadoghq.eu
|
| 147 |
+
events: |
|
| 148 |
+
- title: "${{ github.workflow }} workflow"
|
| 149 |
+
text: "Job ${{ github.job }} in branch ${{ github.ref_name }}"
|
| 150 |
+
alert_type: "${{ steps.calculator.outputs.alert_type }}"
|
| 151 |
+
source_type_name: "Github"
|
| 152 |
+
host: ${{ github.repository_owner }}
|
| 153 |
+
tags:
|
| 154 |
+
- "project:${{ github.repository }}"
|
| 155 |
+
- "job:${{ github.job }}"
|
| 156 |
+
- "run_id:${{ github.run_id }}"
|
| 157 |
+
- "workflow:${{ github.workflow }}"
|
| 158 |
+
- "branch:${{ github.ref_name }}"
|
| 159 |
+
- "url:https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}"
|
| 160 |
+
|
| 161 |
+
lint:
|
| 162 |
+
needs: unit-tests
|
| 163 |
+
runs-on: ubuntu-latest
|
| 164 |
+
steps:
|
| 165 |
+
- name: Checkout
|
| 166 |
+
uses: actions/checkout@v4
|
| 167 |
+
with:
|
| 168 |
+
# With the default value of 1, there are corner cases where tj-actions/changed-files
|
| 169 |
+
# fails with a `no merge base` error
|
| 170 |
+
fetch-depth: 0
|
| 171 |
+
|
| 172 |
+
- name: Get changed files
|
| 173 |
+
id: files
|
| 174 |
+
uses: tj-actions/changed-files@v45
|
| 175 |
+
with:
|
| 176 |
+
files: |
|
| 177 |
+
**/*.py
|
| 178 |
+
files_ignore: |
|
| 179 |
+
test/**
|
| 180 |
+
|
| 181 |
+
- uses: actions/setup-python@v5
|
| 182 |
+
with:
|
| 183 |
+
python-version: "${{ env.PYTHON_VERSION }}"
|
| 184 |
+
|
| 185 |
+
- name: Install Hatch
|
| 186 |
+
id: hatch
|
| 187 |
+
run: |
|
| 188 |
+
pip install hatch==${{ env.HATCH_VERSION }}
|
| 189 |
+
echo "env=$(hatch env find test)" >> "$GITHUB_OUTPUT"
|
| 190 |
+
|
| 191 |
+
- uses: actions/cache/restore@v4
|
| 192 |
+
id: cache
|
| 193 |
+
with:
|
| 194 |
+
path: ${{ steps.hatch.outputs.env }}
|
| 195 |
+
key: ${{ runner.os }}-${{ github.sha }}
|
| 196 |
+
|
| 197 |
+
- name: Mypy
|
| 198 |
+
if: steps.files.outputs.any_changed == 'true'
|
| 199 |
+
run: |
|
| 200 |
+
mkdir .mypy_cache
|
| 201 |
+
hatch run test:types ${{ steps.files.outputs.all_changed_files }}
|
| 202 |
+
|
| 203 |
+
- name: Pylint
|
| 204 |
+
if: steps.files.outputs.any_changed == 'true'
|
| 205 |
+
run: |
|
| 206 |
+
hatch run test:lint ${{ steps.files.outputs.all_changed_files }}
|
| 207 |
+
|
| 208 |
+
- name: Calculate alert data
|
| 209 |
+
id: calculator
|
| 210 |
+
shell: bash
|
| 211 |
+
if: (success() || failure()) && github.ref_name == 'main'
|
| 212 |
+
run: |
|
| 213 |
+
if [ "${{ job.status }}" = "success" ]; then
|
| 214 |
+
echo "alert_type=success" >> "$GITHUB_OUTPUT";
|
| 215 |
+
else
|
| 216 |
+
echo "alert_type=error" >> "$GITHUB_OUTPUT";
|
| 217 |
+
fi
|
| 218 |
+
|
| 219 |
+
- name: Send event to Datadog
|
| 220 |
+
if: (success() || failure()) && github.ref_name == 'main'
|
| 221 |
+
uses: masci/datadog@v1
|
| 222 |
+
with:
|
| 223 |
+
api-key: ${{ secrets.CORE_DATADOG_API_KEY }}
|
| 224 |
+
api-url: https://api.datadoghq.eu
|
| 225 |
+
events: |
|
| 226 |
+
- title: "${{ github.workflow }} workflow"
|
| 227 |
+
text: "Job ${{ github.job }} in branch ${{ github.ref_name }}"
|
| 228 |
+
alert_type: "${{ steps.calculator.outputs.alert_type }}"
|
| 229 |
+
source_type_name: "Github"
|
| 230 |
+
host: ${{ github.repository_owner }}
|
| 231 |
+
tags:
|
| 232 |
+
- "project:${{ github.repository }}"
|
| 233 |
+
- "job:${{ github.job }}"
|
| 234 |
+
- "run_id:${{ github.run_id }}"
|
| 235 |
+
- "workflow:${{ github.workflow }}"
|
| 236 |
+
- "branch:${{ github.ref_name }}"
|
| 237 |
+
- "url:https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}"
|
| 238 |
+
|
| 239 |
+
integration-tests-linux:
|
| 240 |
+
name: Integration / ubuntu-latest
|
| 241 |
+
needs: unit-tests
|
| 242 |
+
runs-on: ubuntu-latest
|
| 243 |
+
services:
|
| 244 |
+
tika:
|
| 245 |
+
image: apache/tika:2.9.0.0
|
| 246 |
+
ports:
|
| 247 |
+
- 9998:9998
|
| 248 |
+
steps:
|
| 249 |
+
- uses: actions/checkout@v4
|
| 250 |
+
|
| 251 |
+
- uses: actions/setup-python@v5
|
| 252 |
+
with:
|
| 253 |
+
python-version: "${{ env.PYTHON_VERSION }}"
|
| 254 |
+
|
| 255 |
+
- name: Install Hatch
|
| 256 |
+
id: hatch
|
| 257 |
+
shell: bash
|
| 258 |
+
run: |
|
| 259 |
+
pip install hatch==${{ env.HATCH_VERSION }}
|
| 260 |
+
echo "env=$(hatch env find test)" >> "$GITHUB_OUTPUT"
|
| 261 |
+
|
| 262 |
+
- uses: actions/cache/restore@v4
|
| 263 |
+
id: cache
|
| 264 |
+
with:
|
| 265 |
+
path: ${{ steps.hatch.outputs.env }}
|
| 266 |
+
key: ${{ runner.os }}-${{ github.sha }}
|
| 267 |
+
|
| 268 |
+
- name: Install dependencies
|
| 269 |
+
run: |
|
| 270 |
+
sudo apt update
|
| 271 |
+
sudo apt install ffmpeg # for local Whisper tests
|
| 272 |
+
|
| 273 |
+
- name: Run
|
| 274 |
+
run: hatch run test:integration
|
| 275 |
+
|
| 276 |
+
- name: Calculate alert data
|
| 277 |
+
id: calculator
|
| 278 |
+
shell: bash
|
| 279 |
+
if: (success() || failure()) && github.ref_name == 'main'
|
| 280 |
+
run: |
|
| 281 |
+
if [ "${{ job.status }}" = "success" ]; then
|
| 282 |
+
echo "alert_type=success" >> "$GITHUB_OUTPUT";
|
| 283 |
+
else
|
| 284 |
+
echo "alert_type=error" >> "$GITHUB_OUTPUT";
|
| 285 |
+
fi
|
| 286 |
+
|
| 287 |
+
- name: Send event to Datadog
|
| 288 |
+
if: (success() || failure()) && github.ref_name == 'main'
|
| 289 |
+
uses: masci/datadog@v1
|
| 290 |
+
with:
|
| 291 |
+
api-key: ${{ secrets.CORE_DATADOG_API_KEY }}
|
| 292 |
+
api-url: https://api.datadoghq.eu
|
| 293 |
+
events: |
|
| 294 |
+
- title: "${{ github.workflow }} workflow"
|
| 295 |
+
text: "Job ${{ github.job }} in branch ${{ github.ref_name }}"
|
| 296 |
+
alert_type: "${{ steps.calculator.outputs.alert_type }}"
|
| 297 |
+
source_type_name: "Github"
|
| 298 |
+
host: ${{ github.repository_owner }}
|
| 299 |
+
tags:
|
| 300 |
+
- "project:${{ github.repository }}"
|
| 301 |
+
- "job:${{ github.job }}"
|
| 302 |
+
- "run_id:${{ github.run_id }}"
|
| 303 |
+
- "workflow:${{ github.workflow }}"
|
| 304 |
+
- "branch:${{ github.ref_name }}"
|
| 305 |
+
- "url:https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}"
|
| 306 |
+
|
| 307 |
+
integration-tests-macos:
|
| 308 |
+
name: Integration / macos-latest
|
| 309 |
+
needs: unit-tests
|
| 310 |
+
runs-on: macos-latest
|
| 311 |
+
env:
|
| 312 |
+
HAYSTACK_MPS_ENABLED: false
|
| 313 |
+
|
| 314 |
+
steps:
|
| 315 |
+
- uses: actions/checkout@v4
|
| 316 |
+
|
| 317 |
+
- uses: actions/setup-python@v5
|
| 318 |
+
with:
|
| 319 |
+
python-version: "${{ env.PYTHON_VERSION }}"
|
| 320 |
+
|
| 321 |
+
- name: Install Hatch
|
| 322 |
+
id: hatch
|
| 323 |
+
shell: bash
|
| 324 |
+
run: |
|
| 325 |
+
pip install hatch==${{ env.HATCH_VERSION }}
|
| 326 |
+
echo "env=$(hatch env find test)" >> "$GITHUB_OUTPUT"
|
| 327 |
+
|
| 328 |
+
- uses: actions/cache/restore@v4
|
| 329 |
+
id: cache
|
| 330 |
+
with:
|
| 331 |
+
path: ${{ steps.hatch.outputs.env }}
|
| 332 |
+
key: ${{ runner.os }}-${{ github.sha }}
|
| 333 |
+
|
| 334 |
+
- name: Install dependencies
|
| 335 |
+
run: |
|
| 336 |
+
brew install ffmpeg # for local Whisper tests
|
| 337 |
+
|
| 338 |
+
- name: Run
|
| 339 |
+
run: hatch run test:integration-mac
|
| 340 |
+
|
| 341 |
+
- name: Calculate alert data
|
| 342 |
+
id: calculator
|
| 343 |
+
shell: bash
|
| 344 |
+
if: (success() || failure()) && github.ref_name == 'main'
|
| 345 |
+
run: |
|
| 346 |
+
if [ "${{ job.status }}" = "success" ]; then
|
| 347 |
+
echo "alert_type=success" >> "$GITHUB_OUTPUT";
|
| 348 |
+
else
|
| 349 |
+
echo "alert_type=error" >> "$GITHUB_OUTPUT";
|
| 350 |
+
fi
|
| 351 |
+
|
| 352 |
+
- name: Send event to Datadog
|
| 353 |
+
if: (success() || failure()) && github.ref_name == 'main'
|
| 354 |
+
uses: masci/datadog@v1
|
| 355 |
+
with:
|
| 356 |
+
api-key: ${{ secrets.CORE_DATADOG_API_KEY }}
|
| 357 |
+
api-url: https://api.datadoghq.eu
|
| 358 |
+
events: |
|
| 359 |
+
- title: "${{ github.workflow }} workflow"
|
| 360 |
+
text: "Job ${{ github.job }} in branch ${{ github.ref_name }}"
|
| 361 |
+
alert_type: "${{ steps.calculator.outputs.alert_type }}"
|
| 362 |
+
source_type_name: "Github"
|
| 363 |
+
host: ${{ github.repository_owner }}
|
| 364 |
+
tags:
|
| 365 |
+
- "project:${{ github.repository }}"
|
| 366 |
+
- "job:${{ github.job }}"
|
| 367 |
+
- "run_id:${{ github.run_id }}"
|
| 368 |
+
- "workflow:${{ github.workflow }}"
|
| 369 |
+
- "branch:${{ github.ref_name }}"
|
| 370 |
+
- "url:https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}"
|
| 371 |
+
|
| 372 |
+
integration-tests-windows:
|
| 373 |
+
name: Integration / windows-latest
|
| 374 |
+
needs: unit-tests
|
| 375 |
+
runs-on: windows-latest
|
| 376 |
+
steps:
|
| 377 |
+
- uses: actions/checkout@v4
|
| 378 |
+
|
| 379 |
+
- uses: actions/setup-python@v5
|
| 380 |
+
with:
|
| 381 |
+
python-version: "${{ env.PYTHON_VERSION }}"
|
| 382 |
+
|
| 383 |
+
- name: Install Hatch
|
| 384 |
+
id: hatch
|
| 385 |
+
shell: bash
|
| 386 |
+
run: |
|
| 387 |
+
pip install hatch==${{ env.HATCH_VERSION }}
|
| 388 |
+
echo "env=$(hatch env find test)" >> "$GITHUB_OUTPUT"
|
| 389 |
+
|
| 390 |
+
- uses: actions/cache/restore@v4
|
| 391 |
+
id: cache
|
| 392 |
+
with:
|
| 393 |
+
path: ${{ steps.hatch.outputs.env }}
|
| 394 |
+
key: ${{ runner.os }}-${{ github.sha }}
|
| 395 |
+
|
| 396 |
+
- name: Run
|
| 397 |
+
run: hatch run test:integration-windows
|
| 398 |
+
|
| 399 |
+
- name: Calculate alert data
|
| 400 |
+
id: calculator
|
| 401 |
+
shell: bash
|
| 402 |
+
if: (success() || failure()) && github.ref_name == 'main'
|
| 403 |
+
run: |
|
| 404 |
+
if [ "${{ job.status }}" = "success" ]; then
|
| 405 |
+
echo "alert_type=success" >> "$GITHUB_OUTPUT";
|
| 406 |
+
else
|
| 407 |
+
echo "alert_type=error" >> "$GITHUB_OUTPUT";
|
| 408 |
+
fi
|
| 409 |
+
|
| 410 |
+
- name: Send event to Datadog
|
| 411 |
+
if: (success() || failure()) && github.ref_name == 'main'
|
| 412 |
+
uses: masci/datadog@v1
|
| 413 |
+
with:
|
| 414 |
+
api-key: ${{ secrets.CORE_DATADOG_API_KEY }}
|
| 415 |
+
api-url: https://api.datadoghq.eu
|
| 416 |
+
events: |
|
| 417 |
+
- title: "${{ github.workflow }} workflow"
|
| 418 |
+
text: "Job ${{ github.job }} in branch ${{ github.ref_name }}"
|
| 419 |
+
alert_type: "${{ steps.calculator.outputs.alert_type }}"
|
| 420 |
+
source_type_name: "Github"
|
| 421 |
+
host: ${{ github.repository_owner }}
|
| 422 |
+
tags:
|
| 423 |
+
- "project:${{ github.repository }}"
|
| 424 |
+
- "job:${{ github.job }}"
|
| 425 |
+
- "run_id:${{ github.run_id }}"
|
| 426 |
+
- "workflow:${{ github.workflow }}"
|
| 427 |
+
- "branch:${{ github.ref_name }}"
|
| 428 |
+
- "url:https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}"
|
| 429 |
+
|
| 430 |
+
trigger-catch-all:
|
| 431 |
+
name: Tests completed
|
| 432 |
+
# This job will be executed only after all the other tests
|
| 433 |
+
# are successful.
|
| 434 |
+
# This way we'll be able to mark only this test as required
|
| 435 |
+
# and skip it accordingly.
|
| 436 |
+
needs:
|
| 437 |
+
- integration-tests-linux
|
| 438 |
+
- integration-tests-macos
|
| 439 |
+
- integration-tests-windows
|
| 440 |
+
uses: ./.github/workflows/tests_skipper_workflow.yml
|
| 441 |
+
with:
|
| 442 |
+
tests_were_skipped: false
|
SPFsmartGATE/LIVE/TMP/haystack/.github/workflows/tests_skipper_trigger.yml
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# If you change this name also do it in tests.yml and ci_metrics.yml
|
| 2 |
+
name: Tests
|
| 3 |
+
|
| 4 |
+
on:
|
| 5 |
+
pull_request:
|
| 6 |
+
types:
|
| 7 |
+
- opened
|
| 8 |
+
- reopened
|
| 9 |
+
- synchronize
|
| 10 |
+
- ready_for_review
|
| 11 |
+
paths-ignore:
|
| 12 |
+
# we skip the tests unless the code changes. The problem is that GitHub will run the check anyway if any other
|
| 13 |
+
# file outside the code changed (e.g. the release notes). Hence, we need a second filter down below.
|
| 14 |
+
# keep the list in sync with the paths defined in the `tests.yml` workflow
|
| 15 |
+
- "haystack/**/*.py"
|
| 16 |
+
- "haystack/core/pipeline/predefined/*"
|
| 17 |
+
- "test/**/*.py"
|
| 18 |
+
|
| 19 |
+
jobs:
|
| 20 |
+
check_if_changed:
|
| 21 |
+
name: Check if changed
|
| 22 |
+
runs-on: ubuntu-latest
|
| 23 |
+
permissions:
|
| 24 |
+
pull-requests: read
|
| 25 |
+
outputs:
|
| 26 |
+
code_changes: ${{ steps.changes.outputs.code_changes }}
|
| 27 |
+
steps:
|
| 28 |
+
- uses: actions/checkout@v4
|
| 29 |
+
- name: Check for changed code
|
| 30 |
+
id: changes
|
| 31 |
+
uses: dorny/paths-filter@de90cc6fb38fc0963ad72b210f1f284cd68cea36
|
| 32 |
+
with:
|
| 33 |
+
# keep the list in sync with the paths defined in the `tests.yml` workflow
|
| 34 |
+
filters: |
|
| 35 |
+
code_changes:
|
| 36 |
+
- haystack/**/*.py
|
| 37 |
+
- "haystack/templates/predefined/*"
|
| 38 |
+
- test/**/*.py
|
| 39 |
+
- "pyproject.toml"
|
| 40 |
+
|
| 41 |
+
trigger-catch-all:
|
| 42 |
+
name: Tests completed
|
| 43 |
+
# Don't run this check if the PR contains both code and non-code changes (e.g. release notes)
|
| 44 |
+
needs: check_if_changed
|
| 45 |
+
if: needs.check_if_changed.outputs.code_changes == 'false'
|
| 46 |
+
uses: ./.github/workflows/tests_skipper_workflow.yml
|
| 47 |
+
with:
|
| 48 |
+
tests_were_skipped: true
|
SPFsmartGATE/LIVE/TMP/haystack/.github/workflows/tests_skipper_workflow.yml
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# If you change this name also do it in tests.yml and ci_metrics.yml
|
| 2 |
+
# We use a separate workflow to skip the tests if the PR contains both code and non-code changes (e.g. release notes).
|
| 3 |
+
# Skipping the job unfortunately doesn't work because GitHub will treat these jobs as successful even if they are
|
| 4 |
+
# skipped. Hence, we need to revert to a separate workflow.
|
| 5 |
+
name: Tests
|
| 6 |
+
on:
|
| 7 |
+
workflow_call:
|
| 8 |
+
inputs:
|
| 9 |
+
tests_were_skipped:
|
| 10 |
+
type: boolean
|
| 11 |
+
required: true
|
| 12 |
+
|
| 13 |
+
jobs:
|
| 14 |
+
catch-all:
|
| 15 |
+
# Don't run this check if the PR contains both code and non-code changes (e.g. release notes)
|
| 16 |
+
name: Mark tests as completed
|
| 17 |
+
runs-on: ubuntu-latest
|
| 18 |
+
steps:
|
| 19 |
+
- name: Skip tests
|
| 20 |
+
if: ${{ github.event.inputs.tests_were_skipped }}
|
| 21 |
+
run: echo "Skipped!"
|
| 22 |
+
- name: Tests completed successfully
|
| 23 |
+
if: ${{ !github.event.inputs.tests_were_skipped }}
|
| 24 |
+
run: echo "Tests completed!"
|
SPFsmartGATE/LIVE/TMP/haystack/.github/workflows/workflows_linting.yml
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
name: Github workflows linter
|
| 2 |
+
|
| 3 |
+
on:
|
| 4 |
+
pull_request:
|
| 5 |
+
paths:
|
| 6 |
+
- ".github/workflows/**"
|
| 7 |
+
|
| 8 |
+
jobs:
|
| 9 |
+
lint-workflows:
|
| 10 |
+
runs-on: ubuntu-latest
|
| 11 |
+
steps:
|
| 12 |
+
- name: Checkout
|
| 13 |
+
uses: actions/checkout@v4
|
| 14 |
+
|
| 15 |
+
- uses: actions/setup-go@v5
|
| 16 |
+
|
| 17 |
+
- name: Install actionlint
|
| 18 |
+
run: go install github.com/rhysd/actionlint/cmd/actionlint@latest
|
| 19 |
+
|
| 20 |
+
- name: Run actionlint
|
| 21 |
+
env:
|
| 22 |
+
SHELLCHECK_OPTS: --exclude=SC2102
|
| 23 |
+
run: actionlint
|