%global _empty_manifest_terminate_build 0
Name: python-probed
Version: 0.0.11
Release: 1
Summary: Probed collections
License: MIT
URL: https://github.com/pyrustic/probed
Source0: https://mirrors.nju.edu.cn/pypi/web/packages/93/d7/44f901075cfbf3c2b637d8a6d3931281716f39f38b603e1455231a02d348/probed-0.0.11.tar.gz
BuildArch: noarch
%description
# Probed collections
This project is part of the [Pyrustic Open Ecosystem](https://pyrustic.github.io).
> [Installation](#installation) . [Latest](https://github.com/pyrustic/probed/tags) . [Documentation](https://github.com/pyrustic/probed/tree/master/docs/modules#readme)
# Overview
Sometimes you need to know when the content of a data collection has changed.
`Probed` is a library that exposes three classes: `ProbedDict`, `ProbedList` and `ProbedSet`.
These classes are containers like the built-in Python containers (dict, list, set) which they subclass but with not a twist but two twists:
- be notified when the content of your data collection changes (if you wish to be notified);
- being able to put a probe into data collection to do more than just be notified.
Let's write a script to see `Probed` in action:
```python
# script.py
from probed import ProbedList
def on_change(context):
msg = "\nThe {} operation changed the {} collection\n{}"
print(msg.format(context.operation, context.container, context.collection))
plist = ProbedList(on_change=on_change)
plist.append("hi")
plist.insert(1, "friend")
```
Let's run the script:
```bash
$ python3 script.py
The append operation changed the list collection
['hi']
The insert operation changed the list collection
['hi', 'friend']
```
Now, let's discover what the `probe` feature does and how to use it:
```python
# script.py
from probed import ProbedSet
def probe(context):
# this probe will lower strings added to the collection
# also, the object None isn't allowed in the collection
if context.operation == "add":
if context.item is None:
context = None
else:
context.item = context.item.lower()
return context
pset = ProbedSet(probe=probe)
# add items
pset.add("RED")
pset.add(None)
pset.add("Green")
# print
print(pset) # {'red', 'green'}
```
In the last script, the `probe` was used to control the items added to the data collection.
All operations that change the contents of the built-in containers are covered by `probed`.
> **Read the [modules documentation](https://github.com/pyrustic/probed/tree/master/docs/modules#readme) !**
# Related project
The **Shared** data exchange and persistence library uses `Probed` to implement the `autosave` feature !
> **Discover [Shared](https://github.com/pyrustic/shared) !**
# Installation
**Probed** is **cross platform** and versions under **1.0.0** will be considered **Beta** at best. It is built on [Ubuntu](https://ubuntu.com/download/desktop) with [Python 3.8](https://www.python.org/downloads/) and should work on **Python 3.5** or **newer**.
## For the first time
```bash
$ pip install probed
```
## Upgrade
```bash
$ pip install probed --upgrade --upgrade-strategy eager
```
[Back to top](#readme)
%package -n python3-probed
Summary: Probed collections
Provides: python-probed
BuildRequires: python3-devel
BuildRequires: python3-setuptools
BuildRequires: python3-pip
%description -n python3-probed
# Probed collections
This project is part of the [Pyrustic Open Ecosystem](https://pyrustic.github.io).
> [Installation](#installation) . [Latest](https://github.com/pyrustic/probed/tags) . [Documentation](https://github.com/pyrustic/probed/tree/master/docs/modules#readme)
# Overview
Sometimes you need to know when the content of a data collection has changed.
`Probed` is a library that exposes three classes: `ProbedDict`, `ProbedList` and `ProbedSet`.
These classes are containers like the built-in Python containers (dict, list, set) which they subclass but with not a twist but two twists:
- be notified when the content of your data collection changes (if you wish to be notified);
- being able to put a probe into data collection to do more than just be notified.
Let's write a script to see `Probed` in action:
```python
# script.py
from probed import ProbedList
def on_change(context):
msg = "\nThe {} operation changed the {} collection\n{}"
print(msg.format(context.operation, context.container, context.collection))
plist = ProbedList(on_change=on_change)
plist.append("hi")
plist.insert(1, "friend")
```
Let's run the script:
```bash
$ python3 script.py
The append operation changed the list collection
['hi']
The insert operation changed the list collection
['hi', 'friend']
```
Now, let's discover what the `probe` feature does and how to use it:
```python
# script.py
from probed import ProbedSet
def probe(context):
# this probe will lower strings added to the collection
# also, the object None isn't allowed in the collection
if context.operation == "add":
if context.item is None:
context = None
else:
context.item = context.item.lower()
return context
pset = ProbedSet(probe=probe)
# add items
pset.add("RED")
pset.add(None)
pset.add("Green")
# print
print(pset) # {'red', 'green'}
```
In the last script, the `probe` was used to control the items added to the data collection.
All operations that change the contents of the built-in containers are covered by `probed`.
> **Read the [modules documentation](https://github.com/pyrustic/probed/tree/master/docs/modules#readme) !**
# Related project
The **Shared** data exchange and persistence library uses `Probed` to implement the `autosave` feature !
> **Discover [Shared](https://github.com/pyrustic/shared) !**
# Installation
**Probed** is **cross platform** and versions under **1.0.0** will be considered **Beta** at best. It is built on [Ubuntu](https://ubuntu.com/download/desktop) with [Python 3.8](https://www.python.org/downloads/) and should work on **Python 3.5** or **newer**.
## For the first time
```bash
$ pip install probed
```
## Upgrade
```bash
$ pip install probed --upgrade --upgrade-strategy eager
```
[Back to top](#readme)
%package help
Summary: Development documents and examples for probed
Provides: python3-probed-doc
%description help
# Probed collections
This project is part of the [Pyrustic Open Ecosystem](https://pyrustic.github.io).
> [Installation](#installation) . [Latest](https://github.com/pyrustic/probed/tags) . [Documentation](https://github.com/pyrustic/probed/tree/master/docs/modules#readme)
# Overview
Sometimes you need to know when the content of a data collection has changed.
`Probed` is a library that exposes three classes: `ProbedDict`, `ProbedList` and `ProbedSet`.
These classes are containers like the built-in Python containers (dict, list, set) which they subclass but with not a twist but two twists:
- be notified when the content of your data collection changes (if you wish to be notified);
- being able to put a probe into data collection to do more than just be notified.
Let's write a script to see `Probed` in action:
```python
# script.py
from probed import ProbedList
def on_change(context):
msg = "\nThe {} operation changed the {} collection\n{}"
print(msg.format(context.operation, context.container, context.collection))
plist = ProbedList(on_change=on_change)
plist.append("hi")
plist.insert(1, "friend")
```
Let's run the script:
```bash
$ python3 script.py
The append operation changed the list collection
['hi']
The insert operation changed the list collection
['hi', 'friend']
```
Now, let's discover what the `probe` feature does and how to use it:
```python
# script.py
from probed import ProbedSet
def probe(context):
# this probe will lower strings added to the collection
# also, the object None isn't allowed in the collection
if context.operation == "add":
if context.item is None:
context = None
else:
context.item = context.item.lower()
return context
pset = ProbedSet(probe=probe)
# add items
pset.add("RED")
pset.add(None)
pset.add("Green")
# print
print(pset) # {'red', 'green'}
```
In the last script, the `probe` was used to control the items added to the data collection.
All operations that change the contents of the built-in containers are covered by `probed`.
> **Read the [modules documentation](https://github.com/pyrustic/probed/tree/master/docs/modules#readme) !**
# Related project
The **Shared** data exchange and persistence library uses `Probed` to implement the `autosave` feature !
> **Discover [Shared](https://github.com/pyrustic/shared) !**
# Installation
**Probed** is **cross platform** and versions under **1.0.0** will be considered **Beta** at best. It is built on [Ubuntu](https://ubuntu.com/download/desktop) with [Python 3.8](https://www.python.org/downloads/) and should work on **Python 3.5** or **newer**.
## For the first time
```bash
$ pip install probed
```
## Upgrade
```bash
$ pip install probed --upgrade --upgrade-strategy eager
```
[Back to top](#readme)
%prep
%autosetup -n probed-0.0.11
%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-probed -f filelist.lst
%dir %{python3_sitelib}/*
%files help -f doclist.lst
%{_docdir}/*
%changelog
* Wed May 10 2023 Python_Bot - 0.0.11-1
- Package Spec generated