48th Week of 2022
Introduction⚑
- New: Add the donation information.
Coding⚑
Languages⚑
PDM⚑
-
New: Suggest to use pydeps.
If you get lost in understanding your dependencies, you can try using
pydepsto get your head around it.
Libraries⚑
-
New: Introduce python gnupg.
python-gnupg is a Python library to interact with
gpgtaking care of the internal details and allows its users to generate and manage keys, encrypt and decrypt data, and sign and verify messages.pip install python-gnupg```python gpg = gnupg.GPG(gnupghome="/path/to/home/directory")
gpg.decrypt("path/to/file")
public_keys = gpg.list_keys() private_keys = gpg.list_keys(True)
Python Snippets⚑
-
New: Pad a string with spaces.
>>> name = 'John' >>> name.ljust(15) 'John ' -
New: Get hostname of the machine.
Any of the next three options:
import os os.uname()[1] import platform platform.node() import socket socket.gethostname() -
New: Get common elements of two lists.
>>> a = ['a', 'b'] >>> b = ['c', 'd', 'b'] >>> set(a) & set(b) {'b'} -
from pathlib import Path for path in Path("src").rglob("*.c"): print(path.name)
Elasticsearch⚑
-
New: Introduce python elasticsearch library.
Python elasticsearch is the Official low-level client for Elasticsearch. Its goal is to provide common ground for all Elasticsearch-related code in Python; because of this it tries to be opinion-free and very extendable.
pip install elasticsearchUsage:
from elasticsearch import Elasticsearch client = Elasticsearch("http://localhost:9200") +client.indices.get(index="*") resp = client.search(index="test-index", query={"match_all": {}}) documents = resp.body["hits"]["hits"] doc = {"partial_document": "value"} resp = client.update(index=INDEX, id=id_, doc=doc)
pythonping⚑
-
New: Introduce pythonping.
pythonping is simple way to ping in Python. With it, you can send ICMP Probes to remote devices like you would do from the terminal.
Warning: Since using
pythonpingrequires root permissions or grantingcap_net_rawcapability to the python interpreter, try to measure the latency to a server by other means such as usingrequests.
Selenium⚑
-
New: Disable loading of images.
You can pass
optionsto the initialization of the chromedriver to tweak how does the browser behave. To get a list of the actualprefsyou can go tochrome://prefs-internals, there you can get the code you need to tweak.options = ChromeOptions() options.add_experimental_option( "prefs", { "profile.default_content_setting_values.images": 2, }, )
Typer⚑
-
New: Create a
--versioncommand.You could use a callback to implement a
--versionCLI option.It would show the version of your CLI program and then it would terminate it. Even before any other CLI parameter is processed.
from typing import Optional import typer __version__ = "0.1.0" def version_callback(value: bool) -> None: """Print the version of the program.""" if value: print(f"Awesome CLI Version: {__version__}") raise typer.Exit() def main( version: Optional[bool] = typer.Option( None, "--version", callback=version_callback, is_eager=True ), ) -> None: ... if __name__ == "__main__": typer.run(main) -
New: Testing.
Testing is similar to
clicktesting, but you import theCliRunnerdirectly fromtyper:from typer.testing import CliRunner
Sponsor⚑
-
New: Introduce sponsorship analysis.
It may arrive the moment in your life where someone wants to sponsor you. There are many sponsoring platforms you can use, each has their advantages and disadvantages.
- Liberapay.
- Ko-fi.
- Buy me a coffee.
- Github Sponsor.
[Liberapay][3] [Ko-fi][4] [Buy Me a Coffee][6] [Github Sponsor][7] Non-profit [Yes][1] No No No! (Microsoft!) Monthly fee No No No No Donation Commission 0% 0% 5% Not clear Paid plan No [Yes][5] No No Payment Processors Stripe, Paypal Stripe, Paypal Stripe, Standard Payout Stripe One time donations [Possible but not user friendly][2] Yes Yes Yes Membership Yes Yes Yes Yes Shop/Sales No Yes No No Based in France ? United States United States? + Pay delay Instant Instant Instant User friendliness OK Good Good Good Liberapay is the only non-profit recurrent donations platform. It's been the most recommended platform from the people I know from the open-source, activist environment.
Ko-fi would be my next choice, as they don't do commissions on the donations and they support more features (that I don't need