semvec/pypi-packages huggingface dataset:
nextcordhealthcheck 0.1.3
A small Python 3 library and command line app to automate Docker health checks for nextcord bots.
Keywords: nextcord docker healthcheck health check bot

# Nextcord Health Check

A small Python 3 library and command line app to automate Docker health checks for [nextcord](https://docs.nextcord.dev/en/stable/index.html) bots.

## Installation

`pip install nextcordhealthcheck`

This will install both the Python library and the command line app, the python library is importable using `import nextcordhealthcheck` and the CLI app by using the command `nextcordhealthcheck`.

## How It Works & Usage Examples

### Python Library (Server)

The library has 1 function, `start`.

`start` takes a `nextcord.Client` object as well as optional parameters, and returns an awaitable that produces a `asyncio.base_events.Server`:

```python
def start(
    client: nextcord.client,
    port: int = 40404,
    bot_max_latency: float = 0.5
) -> Awaitable[asyncio.base_events.Server]
```

`start` calls [`asyncio.start_server`](https://docs.python.org/3/library/asyncio-stream.html#asyncio.start_server), creating an asyncio TCP socket server which listens for connections. Once a client connects, it tests the nextcord client for various things that indicate its health (latency, login status, etc.), and the result of this health check is then sent to the healthcheck client.

The returned `Server` object can be used to stop the server (e.g. `healthcheck_server.close()`)

The default port for the socket server is `40404`, if you change it you will need to use the `--port` flag on the client as well.

```python
import nextcord
import nextcordhealthcheck

class CustomClient(nextcord.Client):
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        self.healthcheck_server = None

    async def on_ready(self):
        if self.healthcheck_server is None:
            self.healthcheck_server = await nextcordhealthcheck.start(self)
            # Later you can close or check on self.healthcheck_server
```

### CLI App (Client)

The CLI app is a simple client that connects to the server and determines its exit code from what the server sends; `0`
for healthy, `1` for unhealthy.

Here's an example of using in a Dockerfile:

```dockerfile
FROM python:3.11-slim-buster

# Copy files, install requirements, setup bot, etc.

RUN pip install nextcordhealthcheck

# The `|| exit 1` isn't required but it's good practice anyway.
HEALTHCHECK CMD nextcordhealthcheck || exit 1

CMD ["python", "/path/to/bot.py"]
```
poisk 1.0.3
Small utilities for searching data structures

Poisk implements a thin veneer of convenience over familiar search functions.
It can be used for:

* regular expression searches;
* jq- or JMESPath-style searches in lists and dicts;
* XPath queries over ElementTrees.


## `one` and `many`

At the core of Poisk is the idea that you'd rather raise an exception than
extract the wrong data. We want to check that our expectations hold. If we
expect our search to return matches, it should not return an empty list. If we
expect a single matching element, there shouldn't be two.

The search functions are grouped into two modules, called `one` and `many`. The
search functions under `one` expect to find a single matching value, which they
return. They raise `NotFound` if no results are found, and `ManyFound` if more
than one match is found.

Here is an example using `one.re`, which performs regular expression searches:

```python
>>> from poisk import one

>>> one.re(r'H\w+', 'Hello world!')
'Hello'

>>> one.re(r'H\w+', 'Greetings, world!')
Traceback (most recent call last):
    ...
poisk.exceptions.NotFound: 'H\\w+' in 'Greetings, world!'

>>> one.re(r'H\w+', 'Ho Ho Ho, world!')
Traceback (most recent call last):
    ...
poisk.exceptions.ManyFound: 'H\\w+' in 'Ho Ho Ho, world!'
```

The corresponding functions under `many` expect one or more results, which they
return as a list. They raise `NotFound` if no matches are found:

```python
>>> from poisk import many

>>> many.re(r'\w+', 'Hello!')
['Hello']

>>> many.re(r'\w+', 'Hello world!')
['Hello', 'world']

>>> many.re(r'\d+', 'Hello world!')
Traceback (most recent call last):
    ...
poisk.exceptions.NotFound: '\\d+' in 'Hello world!'
```


## Supported search functions

The previous two examples use `one.re` and `many.re` to perform regular
expression searches, using the standard
[re](https://docs.python.org/3/library/re.html) module.

Also available are functions for xpath search over ElementTrees using
[lxml.etree](https://lxml.de/api/):

```python
>>> import lxml.etree as ET
>>> from poisk import many, one

>>> document = ET.HTML('''
...     <div>
...         <p id="p1">First paragraph</p>
...         <p id="p2">Second paragraph</p>
...     </div>
... ''')

>>> one.etree('p[@id="p1"]/text()', document)
'First paragraph'

>>> many.etree('p/text()', document)
['First paragraph', 'Second paragraph']
```

The same `one.etree` and `many.etree` functions accept CSS selectors (via
[cssselect](https://github.com/scrapy/cssselect)):

```python
>>> one.etree('p#p1', document).text
'First paragraph'
```

The `one.pods` and `many.pods` functions allow searches using Plain Old Data
Structures (dicts and lists) using a jq- or JMESPath-style query language:

```python
>>> data = {
...     "payload": {
...         "total": 3,
...         "results": [
...             {"id": 1},
...             {"id": 2},
...             {"id": 3},
...         ],
...     },
... }

>>> one.pods('payload.total', data)
3

>>> many.pods('payload.results[].id', data)
[1, 2, 3]
```

The `test/` directory contains many more examples of the sort functionality that Poisk offers.
greps 1.0.4
Simple ipython magic that do grep over ipython outputs
Requires Python: >=3.8,<4.0

# greps
[![Tests](https://github.com/royreznik/greps/actions/workflows/tests.yml/badge.svg)](https://github.com/royreznik/greps/actions/workflows/tests.yml)
![GitHub License](https://img.shields.io/github/license/royreznik/greps)
[![codecov](https://codecov.io/gh/royreznik/greps/graph/graph/badge.svg?token=60063VB6J2)](https://codecov.io/gh/royreznik/greps)
![PyPI - Python Version](https://img.shields.io/pypi/pyversions/greps)
![Code style](https://img.shields.io/badge/code%20style-black-black)

greps is a super simple ipython magic that allow you to use `grep` over IPython output.

## installation
```bash
pip install greps
```
manually loading:
```ipython
# Inside an IPython shell
%load_ext greps
```
Automatic loading:
```bash
echo "c.InteractiveShellApp.extensions = ['greps']" > ~/.ipython/profile_default/ipython_config.py
```


## Usage
On previous output:
```ipython
In [1]: {i:i for i in range(3)}
Out[1]: 
{0: 0,
 1: 1,
 2: 2,
}
 
In [2]: %greps 1
Out[2]: ' 1: 1,\n'
```

On specific output line:
```ipython
In [1]: 1
Out[1]: 1

In [2]: 2
Out[2]: 2

In [3]: 3
Out[3]: 3

In [4]: 4
Out[4]: 4

In [5]: %greps -l 2 2
Out[5]: '2\n'
```