semvec/pypi-packages huggingface dataset:
constrained_types 0.4.0
Extensions for primitives to add validation constraints
Requires Python: ~=3.6

# Constrained Types

Statement: Nothing should ever really be modelled as any String or any integer.


## Example
A user wants to order a number of books. Can it be zero? Can it be negative?
```python
@add_constraint(lambda x: x > 0, "Order must be at least 1")
class OrderQuantity(ConstrainedInt):
    pass
```

now:
```python
quantity = OrderQuantity(5)

# works exactly like an int
total_price = quantity * 5

# but you can't create sneaky discount books
quantity = OrderQuantity(-1)
# !! raises ValueError
```

## Multiple constraints
```python
@add_constraint(lambda x: x > 0, "Order must be at least 1")
@add_constraint(lambda x: x < 200, "Our shipping system can't send more then 200")
class OrderQuantity(ConstrainedInt):
    pass
```

In addition the constraints are guaranteed to execute in order so any
expensive checks to run can be listed further down.

## Cache results
If you expect the same value multiple times you can add caching for
the validation. The actual caching is passed to `functools.lru_cache`.

```python
@add_constraint(lambda x: len(x) > 0, "The order id must be set")
@add_constraint(lambda x: len(x) < 10, "Order ids are under 10 chars")
@add_constraint(some_really_complicated_checksum, "The order number was invalid")
@cache_constraint_results(maxsize=100)
class OrderId(ConstrainedString):
    pass
```

## Works well with mypy (or other static type checkers)
```python
# The following will type check fine. OrderId is a real type
def retrieve_order(order_id: OrderId):
    ...
```
maybe something further down only accepts strings:

```python
def _fetch_item_from_db(table_name: str, item_id: str):
    ...

def retrieve_order(order_id: OrderId):
    # The following will type check fine. OrderId extends str
    return _fetch_item_from_db("orders", order_id)
```



## Integrates with pydantic
```python
@add_constraint(lambda x: x > 0, "Order must be at least 1")
class OrderQuantity(ConstrainedInt):
    pass


@add_constraint(lambda x: len(x) == 4, "Invalid order id")
class BookId(ConstrainedString):
    pass


class Order(BaseModel):
    book_quantity: OrderQuantity
    book_id: BookId
```

### Why not use the pydantic version of these constrained types?
The pydantic types only really work with pydantic. Invalid instances
can be created by constructing directly. Since constraint checking
is triggered by the constructor the constraints will *always* be
true for any instance of the class.
pub-downloader 0.3
Download 'periodic' Jehovah's Witnesses publications from the command line
Requires Python: >=3.6


## PD (Publication Downloader)
```
usage: pd [-h] [-m MONTH] [-y YEAR] [-l LANG] [-f FORMAT] [-c] [-v] {w,wp,g,mwb}

    Short for "Publication Downloader", pd.py is a script written using Python 3.8 that downloads
    the publication specified. You can download any "periodic" JW publication - Awake, Watchtower,
    Watchtower - Public or Meeting Workbook in any format from the command line.

positional arguments:
  {w,wp,g,mwb}          The type of the publication to download

optional arguments:
  -h, --help            show this help message and exit
  -m MONTH, --month MONTH
                        The month of the issue (defaults to the current month)
  -y YEAR, --year YEAR  The year of the issue (defaults to the current year)
  -l LANG, --lang LANG  The short language code of the target language
                        (ex: AM for Amharic, E for English, etc. Defaults to AM)
  -f FORMAT, --format FORMAT
                        The file format of the download. PDF, JWPUB, EPUB, BRL or RTF
                        (defaults to JWPUB)
  -c, --cont            Decides weather the script should continue downloading releases of the
                        specified publication until the end of the year (See the last example below)
  -v, --version         show program's version number and exit

examples:
    Executing the command below will not download any publication as the publication is not supplied.
    % python3.8 pd.py --year 2010 --month 2 --format pdf --lang e

    This will download the Awake of September 2010 in the PDF format and the English language.
    % python3.8 pd.py g --year 2010 --month 9 --format pdf --lang e

    This will download the Public Watchtower of the current year and month in the EPUB
    format and the Arabic language.
    % python3.8 pd.py wp --format epub --lang a

    This will download all Meeting Workbook issues from January 2018 up to December 2018
    in the JWPUB format and the Amharic language (note that `--cont` is passed).
    % python3.8 pd.py mwb --year 2018 --month 1 --format jwpub --lang am --cont
```

It was written using Python 3.8 and the minimum version of Python 3 its compatible with is uncertain.

#### Installation
PD is available on [PyPi](https://pypi.org/project/pub_downloader/). You can install it with: `pip3 install pub_downloader`.