forked from zaclys/searxng
[docs] add documentation for the scripts in searxng_extra/update
Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>
This commit is contained in:
parent
b630c5d7bc
commit
ffea5d8ef5
|
@ -1,14 +1,15 @@
|
||||||
.. _searxng_extra:
|
.. _searxng_extra:
|
||||||
|
|
||||||
======================================================
|
=============================
|
||||||
Tooling box ``searxng_extra`` for developers and users
|
Tooling box ``searxng_extra``
|
||||||
======================================================
|
=============================
|
||||||
|
|
||||||
In the folder :origin:`searxng_extra/` we maintain some tools useful for
|
In the folder :origin:`searxng_extra/` we maintain some tools useful for CI and
|
||||||
developers.
|
developers.
|
||||||
|
|
||||||
.. toctree::
|
.. toctree::
|
||||||
:maxdepth: 2
|
:maxdepth: 2
|
||||||
:caption: Contents
|
:caption: Contents
|
||||||
|
|
||||||
|
update
|
||||||
standalone_searx.py
|
standalone_searx.py
|
||||||
|
|
|
@ -0,0 +1,88 @@
|
||||||
|
=========================
|
||||||
|
``searxng_extra/update/``
|
||||||
|
=========================
|
||||||
|
|
||||||
|
:origin:`[source] <searxng_extra/update/__init__.py>`
|
||||||
|
|
||||||
|
Scripts to update static data in :origin:`searx/data/`
|
||||||
|
|
||||||
|
.. _update_ahmia_blacklist.py:
|
||||||
|
|
||||||
|
``update_ahmia_blacklist.py``
|
||||||
|
=============================
|
||||||
|
|
||||||
|
:origin:`[source] <searxng_extra/update/update_ahmia_blacklist.py>`
|
||||||
|
|
||||||
|
.. automodule:: searxng_extra.update.update_ahmia_blacklist
|
||||||
|
:members:
|
||||||
|
|
||||||
|
|
||||||
|
``update_currencies.py``
|
||||||
|
========================
|
||||||
|
|
||||||
|
:origin:`[source] <searxng_extra/update/update_currencies.py>`
|
||||||
|
|
||||||
|
.. automodule:: searxng_extra.update.update_currencies
|
||||||
|
:members:
|
||||||
|
|
||||||
|
``update_engine_descriptions.py``
|
||||||
|
=================================
|
||||||
|
|
||||||
|
:origin:`[source] <searxng_extra/update/update_engine_descriptions.py>`
|
||||||
|
|
||||||
|
.. automodule:: searxng_extra.update.update_engine_descriptions
|
||||||
|
:members:
|
||||||
|
|
||||||
|
|
||||||
|
``update_external_bangs.py``
|
||||||
|
============================
|
||||||
|
|
||||||
|
:origin:`[source] <searxng_extra/update/update_external_bangs.py>`
|
||||||
|
|
||||||
|
.. automodule:: searxng_extra.update.update_external_bangs
|
||||||
|
:members:
|
||||||
|
|
||||||
|
|
||||||
|
``update_firefox_version.py``
|
||||||
|
=============================
|
||||||
|
|
||||||
|
:origin:`[source] <searxng_extra/update/update_firefox_version.py>`
|
||||||
|
|
||||||
|
.. automodule:: searxng_extra.update.update_firefox_version
|
||||||
|
:members:
|
||||||
|
|
||||||
|
|
||||||
|
``update_languages.py``
|
||||||
|
=======================
|
||||||
|
|
||||||
|
:origin:`[source] <searxng_extra/update/update_languages.py>`
|
||||||
|
|
||||||
|
.. automodule:: searxng_extra.update.update_languages
|
||||||
|
:members:
|
||||||
|
|
||||||
|
|
||||||
|
``update_osm_keys_tags.py``
|
||||||
|
===========================
|
||||||
|
|
||||||
|
:origin:`[source] <searxng_extra/update/update_osm_keys_tags.py>`
|
||||||
|
|
||||||
|
.. automodule:: searxng_extra.update.update_osm_keys_tags
|
||||||
|
:members:
|
||||||
|
|
||||||
|
|
||||||
|
``update_pygments.py``
|
||||||
|
======================
|
||||||
|
|
||||||
|
:origin:`[source] <searxng_extra/update/update_pygments.py>`
|
||||||
|
|
||||||
|
.. automodule:: searxng_extra.update.update_pygments
|
||||||
|
:members:
|
||||||
|
|
||||||
|
|
||||||
|
``update_wikidata_units.py``
|
||||||
|
============================
|
||||||
|
|
||||||
|
:origin:`[source] <searxng_extra/update/update_wikidata_units.py>`
|
||||||
|
|
||||||
|
.. automodule:: searxng_extra.update.update_wikidata_units
|
||||||
|
:members:
|
|
@ -1,10 +1,14 @@
|
||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
# SPDX-License-Identifier: AGPL-3.0-or-later
|
# SPDX-License-Identifier: AGPL-3.0-or-later
|
||||||
|
"""This script saves `Ahmia's blacklist`_ for onion sites.
|
||||||
|
|
||||||
# This script saves Ahmia's blacklist for onion sites.
|
Output file: :origin:`searx/data/ahmia_blacklist.txt` (:origin:`CI Update data
|
||||||
# More info in https://ahmia.fi/blacklist/
|
... <.github/workflows/data-update.yml>`).
|
||||||
|
|
||||||
|
.. _Ahmia's blacklist: https://ahmia.fi/blacklist/
|
||||||
|
|
||||||
|
"""
|
||||||
|
|
||||||
# set path
|
|
||||||
from os.path import join
|
from os.path import join
|
||||||
|
|
||||||
import requests
|
import requests
|
||||||
|
@ -26,6 +30,7 @@ def get_ahmia_blacklist_filename():
|
||||||
return join(join(searx_dir, "data"), "ahmia_blacklist.txt")
|
return join(join(searx_dir, "data"), "ahmia_blacklist.txt")
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
blacklist = fetch_ahmia_blacklist()
|
blacklist = fetch_ahmia_blacklist()
|
||||||
with open(get_ahmia_blacklist_filename(), "w") as f:
|
with open(get_ahmia_blacklist_filename(), "w") as f:
|
||||||
f.write('\n'.join(blacklist))
|
f.write('\n'.join(blacklist))
|
||||||
|
|
|
@ -1,6 +1,12 @@
|
||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
# SPDX-License-Identifier: AGPL-3.0-or-later
|
# SPDX-License-Identifier: AGPL-3.0-or-later
|
||||||
|
|
||||||
|
"""Fetch currencies from :origin:`searx/engines/wikidata.py` engine.
|
||||||
|
|
||||||
|
Output file: :origin:`searx/data/currencies.json` (:origin:`CI Update data ...
|
||||||
|
<.github/workflows/data-update.yml>`).
|
||||||
|
|
||||||
|
"""
|
||||||
import re
|
import re
|
||||||
import unicodedata
|
import unicodedata
|
||||||
import json
|
import json
|
||||||
|
|
|
@ -1,6 +1,13 @@
|
||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
# SPDX-License-Identifier: AGPL-3.0-or-later
|
# SPDX-License-Identifier: AGPL-3.0-or-later
|
||||||
|
|
||||||
|
"""Fetch website description from websites and from
|
||||||
|
:origin:`searx/engines/wikidata.py` engine.
|
||||||
|
|
||||||
|
Output file: :origin:`searx/data/engine_descriptions.json`.
|
||||||
|
|
||||||
|
"""
|
||||||
|
|
||||||
import json
|
import json
|
||||||
from urllib.parse import urlparse
|
from urllib.parse import urlparse
|
||||||
from os.path import join
|
from os.path import join
|
||||||
|
|
|
@ -1,17 +1,20 @@
|
||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
# lint: pylint
|
# lint: pylint
|
||||||
# SPDX-License-Identifier: AGPL-3.0-or-later
|
# SPDX-License-Identifier: AGPL-3.0-or-later
|
||||||
"""
|
"""Update :origin:`searx/data/external_bangs.json` using the duckduckgo bangs
|
||||||
Update searx/data/external_bangs.json using the duckduckgo bangs.
|
(:origin:`CI Update data ... <.github/workflows/data-update.yml>`).
|
||||||
|
|
||||||
|
https://duckduckgo.com/newbang loads:
|
||||||
|
|
||||||
https://duckduckgo.com/newbang loads
|
|
||||||
* a javascript which provides the bang version ( https://duckduckgo.com/bv1.js )
|
* a javascript which provides the bang version ( https://duckduckgo.com/bv1.js )
|
||||||
* a JSON file which contains the bangs ( https://duckduckgo.com/bang.v260.js for example )
|
* a JSON file which contains the bangs ( https://duckduckgo.com/bang.v260.js for example )
|
||||||
|
|
||||||
This script loads the javascript, then the bangs.
|
This script loads the javascript, then the bangs.
|
||||||
|
|
||||||
The javascript URL may change in the future ( for example https://duckduckgo.com/bv2.js ),
|
The javascript URL may change in the future ( for example
|
||||||
but most probably it will requires to update RE_BANG_VERSION
|
https://duckduckgo.com/bv2.js ), but most probably it will requires to update
|
||||||
|
RE_BANG_VERSION
|
||||||
|
|
||||||
"""
|
"""
|
||||||
# pylint: disable=C0116
|
# pylint: disable=C0116
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,13 @@
|
||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
# SPDX-License-Identifier: AGPL-3.0-or-later
|
# SPDX-License-Identifier: AGPL-3.0-or-later
|
||||||
|
|
||||||
|
"""Fetch firefox useragent signatures
|
||||||
|
|
||||||
|
Output file: :origin:`searx/data/useragents.json` (:origin:`CI Update data ...
|
||||||
|
<.github/workflows/data-update.yml>`).
|
||||||
|
|
||||||
|
"""
|
||||||
|
|
||||||
import json
|
import json
|
||||||
import requests
|
import requests
|
||||||
import re
|
import re
|
||||||
|
@ -66,6 +73,7 @@ def get_useragents_filename():
|
||||||
return join(join(searx_dir, "data"), "useragents.json")
|
return join(join(searx_dir, "data"), "useragents.json")
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
useragents["versions"] = fetch_firefox_last_versions()
|
useragents["versions"] = fetch_firefox_last_versions()
|
||||||
with open(get_useragents_filename(), "w") as f:
|
with open(get_useragents_filename(), "w", encoding='utf-8') as f:
|
||||||
json.dump(useragents, f, indent=4, ensure_ascii=False)
|
json.dump(useragents, f, indent=4, ensure_ascii=False)
|
||||||
|
|
|
@ -1,9 +1,13 @@
|
||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
# SPDX-License-Identifier: AGPL-3.0-or-later
|
# SPDX-License-Identifier: AGPL-3.0-or-later
|
||||||
|
"""This script generates languages.py from intersecting each engine's supported
|
||||||
|
languages.
|
||||||
|
|
||||||
# This script generates languages.py from intersecting each engine's supported languages.
|
Output files: :origin:`searx/data/engines_languages.json` and
|
||||||
#
|
:origin:`searx/languages.py` (:origin:`CI Update data ...
|
||||||
# Output files: searx/data/engines_languages.json and searx/languages.py
|
<.github/workflows/data-update.yml>`).
|
||||||
|
|
||||||
|
"""
|
||||||
|
|
||||||
import json
|
import json
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
|
@ -5,7 +5,10 @@
|
||||||
|
|
||||||
To get the i18n names, the scripts uses `Wikidata Query Service`_ instead of for
|
To get the i18n names, the scripts uses `Wikidata Query Service`_ instead of for
|
||||||
example `OSM tags API`_ (sidenote: the actual change log from
|
example `OSM tags API`_ (sidenote: the actual change log from
|
||||||
map.atownsend.org.uk_ might be useful to normalize OSM tags)
|
map.atownsend.org.uk_ might be useful to normalize OSM tags).
|
||||||
|
|
||||||
|
Output file: :origin:`searx/data/osm_keys_tags` (:origin:`CI Update data ...
|
||||||
|
<.github/workflows/data-update.yml>`).
|
||||||
|
|
||||||
.. _Wikidata Query Service: https://query.wikidata.org/
|
.. _Wikidata Query Service: https://query.wikidata.org/
|
||||||
.. _OSM tags API: https://taginfo.openstreetmap.org/taginfo/apidoc
|
.. _OSM tags API: https://taginfo.openstreetmap.org/taginfo/apidoc
|
||||||
|
|
|
@ -3,6 +3,13 @@
|
||||||
# lint: pylint
|
# lint: pylint
|
||||||
# pylint: disable=missing-module-docstring
|
# pylint: disable=missing-module-docstring
|
||||||
|
|
||||||
|
"""Fetch units from :origin:`searx/engines/wikidata.py` engine.
|
||||||
|
|
||||||
|
Output file: :origin:`searx/data/wikidata_units.json` (:origin:`CI Update data
|
||||||
|
... <.github/workflows/data-update.yml>`).
|
||||||
|
|
||||||
|
"""
|
||||||
|
|
||||||
import json
|
import json
|
||||||
import collections
|
import collections
|
||||||
|
|
||||||
|
@ -54,5 +61,6 @@ def get_wikidata_units_filename():
|
||||||
return join(join(searx_dir, "data"), "wikidata_units.json")
|
return join(join(searx_dir, "data"), "wikidata_units.json")
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
with open(get_wikidata_units_filename(), 'w', encoding="utf8") as f:
|
with open(get_wikidata_units_filename(), 'w', encoding="utf8") as f:
|
||||||
json.dump(get_data(), f, indent=4, ensure_ascii=False)
|
json.dump(get_data(), f, indent=4, ensure_ascii=False)
|
||||||
|
|
Loading…
Reference in New Issue