%global _empty_manifest_terminate_build 0
Name:		python-nr-stream
Version:	1.1.5
Release:	1
Summary:	please add a summary manually as the author left a blank one
License:	MIT
URL:		https://pypi.org/project/nr-stream/
Source0:	https://mirrors.nju.edu.cn/pypi/web/packages/b7/37/e4d36d852c441233c306c5fbd98147685dce3ac9b0a8bbf4a587d0ea29ea/nr_stream-1.1.5.tar.gz
BuildArch:	noarch


%description
# nr-stream

This package provides utilities for writing functional-style code in Python. The package originally contained only
the `Stream` class, hence the name, but since we've adopted the terminology for letting us *streamline* large chunks
of our code.

## API

### Optional objects

Represents an optional value, i.e. one that either has a valid value or is `None`. The class is useful to
chain modifications and have them execute based on whether a value is available or not.

__Example__

```py
import os
from nr.stream import Optional

opt = Optional(os.getenv("SOMEVAR"))
value = opt.or_else_get(lambda: do_something_else())
value = opt.or_else_raise(lambda: Exception("SOMEVAR not set"))
opt = opt.map(lambda value: value + " another value")
len(opt.stream().count())  # 0 or 1
```

### Refreshable objects

A Refreshable is a container for a value that can be updated and inform listeners. A chained operations on a
refreshable will be replayed if the parent refreshable is updated. This is eager evaluation, not lazy evaluation
and allows performant calls to `.get()` without going through a lazy chain of operations each time.

Unlike `Optional` or `Stream`, the `Refreshable` knows no "empty" state.

This class is often useful to pass configuration data around in your application. It allows making modifications
to the configuration and have it automatically propagate throughout the application.

__Example__

```py
from nr.stream import Refreshable

root = Refreshable[int | None](None)
child = root.map(lambda v: 42 if v is None else v)

print(root.get())  # None
print(child.get()) # 42
root.update(10)
print(root.get())  # 10
print(child.get()) # 10
```

### Stream objects

The Stream class wraps an iterable and allows you to build a chain of modifiers on top of it. This often
greatly simplifies consecutive operations on an iterable object and its items.

__Example__

```py
from nr.stream import Stream

values = [3, 6, 4, 7, 1, 2, 5]
assert list(Stream(values).chunks(values, 3, fill=0).map(sum)) == [13, 10, 5]
```

> __Important__: Stream objects always immediately convert the object passed to an iterator. This means
> that you cannot branch stream objects, as both forks will share the same initial iterator.

### Supplier objects

The Supplier class allows you to lazily evaluate the retrieval of a value, as well as chain modifications
on top of it and even trace the lineage of these modifications. It provides convenience methods such as
`.map()`, `.once()`, `.get_or_raise()`. Unlike an `Optional`, a supplier will treat `None` as a valid value
and instead separately track the state of "no value".

Trying to read a value from an empty supplier raises a `Supplier.Empty` exception. Note that suppliers _always_
evaluate lazily, unlike `Optional`.

__Example__

```py
from nr.stream import Supplier

sup = Supplier.of(42)
sup = sup.map(lambda value: print(value))
assert sup.get() == None  # prints: 42
assert sup.get() == None  # prints: 42

Supplier.void().get()  # raises Supplier.Empty
```



%package -n python3-nr-stream
Summary:	please add a summary manually as the author left a blank one
Provides:	python-nr-stream
BuildRequires:	python3-devel
BuildRequires:	python3-setuptools
BuildRequires:	python3-pip
%description -n python3-nr-stream
# nr-stream

This package provides utilities for writing functional-style code in Python. The package originally contained only
the `Stream` class, hence the name, but since we've adopted the terminology for letting us *streamline* large chunks
of our code.

## API

### Optional objects

Represents an optional value, i.e. one that either has a valid value or is `None`. The class is useful to
chain modifications and have them execute based on whether a value is available or not.

__Example__

```py
import os
from nr.stream import Optional

opt = Optional(os.getenv("SOMEVAR"))
value = opt.or_else_get(lambda: do_something_else())
value = opt.or_else_raise(lambda: Exception("SOMEVAR not set"))
opt = opt.map(lambda value: value + " another value")
len(opt.stream().count())  # 0 or 1
```

### Refreshable objects

A Refreshable is a container for a value that can be updated and inform listeners. A chained operations on a
refreshable will be replayed if the parent refreshable is updated. This is eager evaluation, not lazy evaluation
and allows performant calls to `.get()` without going through a lazy chain of operations each time.

Unlike `Optional` or `Stream`, the `Refreshable` knows no "empty" state.

This class is often useful to pass configuration data around in your application. It allows making modifications
to the configuration and have it automatically propagate throughout the application.

__Example__

```py
from nr.stream import Refreshable

root = Refreshable[int | None](None)
child = root.map(lambda v: 42 if v is None else v)

print(root.get())  # None
print(child.get()) # 42
root.update(10)
print(root.get())  # 10
print(child.get()) # 10
```

### Stream objects

The Stream class wraps an iterable and allows you to build a chain of modifiers on top of it. This often
greatly simplifies consecutive operations on an iterable object and its items.

__Example__

```py
from nr.stream import Stream

values = [3, 6, 4, 7, 1, 2, 5]
assert list(Stream(values).chunks(values, 3, fill=0).map(sum)) == [13, 10, 5]
```

> __Important__: Stream objects always immediately convert the object passed to an iterator. This means
> that you cannot branch stream objects, as both forks will share the same initial iterator.

### Supplier objects

The Supplier class allows you to lazily evaluate the retrieval of a value, as well as chain modifications
on top of it and even trace the lineage of these modifications. It provides convenience methods such as
`.map()`, `.once()`, `.get_or_raise()`. Unlike an `Optional`, a supplier will treat `None` as a valid value
and instead separately track the state of "no value".

Trying to read a value from an empty supplier raises a `Supplier.Empty` exception. Note that suppliers _always_
evaluate lazily, unlike `Optional`.

__Example__

```py
from nr.stream import Supplier

sup = Supplier.of(42)
sup = sup.map(lambda value: print(value))
assert sup.get() == None  # prints: 42
assert sup.get() == None  # prints: 42

Supplier.void().get()  # raises Supplier.Empty
```



%package help
Summary:	Development documents and examples for nr-stream
Provides:	python3-nr-stream-doc
%description help
# nr-stream

This package provides utilities for writing functional-style code in Python. The package originally contained only
the `Stream` class, hence the name, but since we've adopted the terminology for letting us *streamline* large chunks
of our code.

## API

### Optional objects

Represents an optional value, i.e. one that either has a valid value or is `None`. The class is useful to
chain modifications and have them execute based on whether a value is available or not.

__Example__

```py
import os
from nr.stream import Optional

opt = Optional(os.getenv("SOMEVAR"))
value = opt.or_else_get(lambda: do_something_else())
value = opt.or_else_raise(lambda: Exception("SOMEVAR not set"))
opt = opt.map(lambda value: value + " another value")
len(opt.stream().count())  # 0 or 1
```

### Refreshable objects

A Refreshable is a container for a value that can be updated and inform listeners. A chained operations on a
refreshable will be replayed if the parent refreshable is updated. This is eager evaluation, not lazy evaluation
and allows performant calls to `.get()` without going through a lazy chain of operations each time.

Unlike `Optional` or `Stream`, the `Refreshable` knows no "empty" state.

This class is often useful to pass configuration data around in your application. It allows making modifications
to the configuration and have it automatically propagate throughout the application.

__Example__

```py
from nr.stream import Refreshable

root = Refreshable[int | None](None)
child = root.map(lambda v: 42 if v is None else v)

print(root.get())  # None
print(child.get()) # 42
root.update(10)
print(root.get())  # 10
print(child.get()) # 10
```

### Stream objects

The Stream class wraps an iterable and allows you to build a chain of modifiers on top of it. This often
greatly simplifies consecutive operations on an iterable object and its items.

__Example__

```py
from nr.stream import Stream

values = [3, 6, 4, 7, 1, 2, 5]
assert list(Stream(values).chunks(values, 3, fill=0).map(sum)) == [13, 10, 5]
```

> __Important__: Stream objects always immediately convert the object passed to an iterator. This means
> that you cannot branch stream objects, as both forks will share the same initial iterator.

### Supplier objects

The Supplier class allows you to lazily evaluate the retrieval of a value, as well as chain modifications
on top of it and even trace the lineage of these modifications. It provides convenience methods such as
`.map()`, `.once()`, `.get_or_raise()`. Unlike an `Optional`, a supplier will treat `None` as a valid value
and instead separately track the state of "no value".

Trying to read a value from an empty supplier raises a `Supplier.Empty` exception. Note that suppliers _always_
evaluate lazily, unlike `Optional`.

__Example__

```py
from nr.stream import Supplier

sup = Supplier.of(42)
sup = sup.map(lambda value: print(value))
assert sup.get() == None  # prints: 42
assert sup.get() == None  # prints: 42

Supplier.void().get()  # raises Supplier.Empty
```



%prep
%autosetup -n nr-stream-1.1.5

%build
%py3_build

%install
%py3_install
install -d -m755 %{buildroot}/%{_pkgdocdir}
if [ -d doc ]; then cp -arf doc %{buildroot}/%{_pkgdocdir}; fi
if [ -d docs ]; then cp -arf docs %{buildroot}/%{_pkgdocdir}; fi
if [ -d example ]; then cp -arf example %{buildroot}/%{_pkgdocdir}; fi
if [ -d examples ]; then cp -arf examples %{buildroot}/%{_pkgdocdir}; fi
pushd %{buildroot}
if [ -d usr/lib ]; then
	find usr/lib -type f -printf "/%h/%f\n" >> filelist.lst
fi
if [ -d usr/lib64 ]; then
	find usr/lib64 -type f -printf "/%h/%f\n" >> filelist.lst
fi
if [ -d usr/bin ]; then
	find usr/bin -type f -printf "/%h/%f\n" >> filelist.lst
fi
if [ -d usr/sbin ]; then
	find usr/sbin -type f -printf "/%h/%f\n" >> filelist.lst
fi
touch doclist.lst
if [ -d usr/share/man ]; then
	find usr/share/man -type f -printf "/%h/%f.gz\n" >> doclist.lst
fi
popd
mv %{buildroot}/filelist.lst .
mv %{buildroot}/doclist.lst .

%files -n python3-nr-stream -f filelist.lst
%dir %{python3_sitelib}/*

%files help -f doclist.lst
%{_docdir}/*

%changelog
* Tue Apr 11 2023 Python_Bot <Python_Bot@openeuler.org> - 1.1.5-1
- Package Spec generated