From eefe6b24fd3a4df34593abe8f79b3a9f84ed4be1 Mon Sep 17 00:00:00 2001 From: CoprDistGit Date: Wed, 12 Apr 2023 04:44:59 +0000 Subject: automatic import of python-networkx-query --- .gitignore | 1 + python-networkx-query.spec | 787 +++++++++++++++++++++++++++++++++++++++++++++ sources | 1 + 3 files changed, 789 insertions(+) create mode 100644 python-networkx-query.spec create mode 100644 sources diff --git a/.gitignore b/.gitignore index e69de29..d171caa 100644 --- a/.gitignore +++ b/.gitignore @@ -0,0 +1 @@ +/networkx_query-1.0.1.tar.gz diff --git a/python-networkx-query.spec b/python-networkx-query.spec new file mode 100644 index 0000000..8a81b1d --- /dev/null +++ b/python-networkx-query.spec @@ -0,0 +1,787 @@ +%global _empty_manifest_terminate_build 0 +Name: python-networkx-query +Version: 1.0.1 +Release: 1 +Summary: NetworkX Query Tool +License: MIT +URL: https://pypi.org/project/networkx_query +Source0: https://mirrors.nju.edu.cn/pypi/web/packages/38/37/1869daa4e0c5ff21e7305441f316e58962de3cc1cb015b2b29e49facd09f/networkx_query-1.0.1.tar.gz +BuildArch: noarch + +Requires: python3-networkx + +%description +# networkx-query + + +[![Unix Build Status](https://img.shields.io/travis/geronimo-iia/networkx-query/master.svg?label=unix)](https://travis-ci.com/geronimo-iia/networkx-query)[![Coverage Status](https://img.shields.io/coveralls/geronimo-iia/networkx-query/master.svg)](https://coveralls.io/r/geronimo-iia/networkx-query) +[![Codacy Badge](https://api.codacy.com/project/badge/Grade/fe669a02b4aa46b5b1faf619ba2bf382)](https://www.codacy.com/app/geronimo-iia/networkx-query?utm_source=github.com&utm_medium=referral&utm_content=geronimo-iia/networkx-query&utm_campaign=Badge_Grade)[![Scrutinizer Code Quality](https://img.shields.io/scrutinizer/g/geronimo-iia/networkx-query.svg)](https://scrutinizer-ci.com/g/geronimo-iia/networkx-query/?branch=master) +[![PyPI Version](https://img.shields.io/pypi/v/networkx-query.svg)](https://pypi.org/project/networkx-query) +[![PyPI License](https://img.shields.io/pypi/l/networkx-query.svg)](https://pypi.org/project/networkx-query) + +Versions following [Semantic Versioning](https://semver.org/) + +## Overview + +NetworkX Query Tool (preview) + +See [documentation](https://geronimo-iia.github.io/networkx-query). + + +## Installation + +Install this library directly into an activated virtual environment: + +```text +$ pip install networkx-query +``` + +or add it to your [Poetry](https://poetry.eustace.io/) project: + +```text +$ poetry add networkx-query +``` + +## Usage + +### Searching nodes + +```python +import networkx as nx +from networkx_query import search_nodes, search_edges + +g = nx.DiGraph() +g.add_node(1, product="chocolate") +g.add_node(2, product="milk") +g.add_node(3, product="coat") +g.add_edge(1, 2, action="shake") +g.add_edge(3, 2, action="produce") + + +for node_id in search_nodes(g, {"==": [("product",), "chocolate"]}): + print(node_id) + +>> 1 +``` + +### Searching edges + +```python +for edge_id in search_edges(g, {"eq": [("action",), "produce"]}): + print(edge_id) + +>> (3, 2) +``` + +### Searching relation ship + +With ```search_direct_relationships``` you can made a query which filter edges on their : + - source node attributes + - edge attributes + - target node attributes + +With this graph: + +```python +import networkx as nx +from networkx_query import search_direct_relationships + +g = nx.DiGraph() +for i in range(30): + g.add_node(i, data=i) + +for i in range(10, 30): + g.add_edge(i - 10, i, data=i) +``` + +We can filtering all edges with source node with data < 3: + +```python +list(search_direct_relationships(graph=g, source={"lt": ["data", 3]})) + +[(0, 10), (1, 11), (2, 12)] +``` + + +We can filtering all edges with: + - source node with data < 8 + - edge with data > 15 + +```python +list(search_direct_relationships(graph=g, source={"lt": ["data", 8]}, edge={"gt": ["data", 15]})) + +>> [(6, 16), (7, 17)] +``` + +We can filtering all edges with: + - source node with data > 9 + - edge with data > 15 + - target node with data < 22 + +```python +search_direct_relationships( + graph=g, source={"gt": ["data", 9]}, edge={"gt": ["data", 15]}, target={'lt': ["data", 22]} + ) + ) + +>> [(10, 20), (11, 21)] +``` + +## API + +Actually, we have: + +- [search_edges](https://geronimo-iia.github.io/networkx-query/api.html#networkx_query.search_edges) +- [search_nodes](https://geronimo-iia.github.io/networkx-query/api.html#networkx_query.search_nodes) +- [search_direct_relationships](https://geronimo-iia.github.io/networkx-query/api.html#networkx_query.search_direct_relationships) + + +All this function are based on [prepare_query](https://geronimo-iia.github.io/networkx-query/api.html#networkx_query.prepare_query) which return an Evaluator. + +Quickly, ```Evaluator``` are function with this signature: (context) -> bool, and ```Context``` is a dictionary like structure (with in and [] methods, and support __contains__ or (__iter__ and __getitem__)) +With networkX, node and edge attributes are dictionary like, so implementation of this three methods are very simple. + + + +## Query language + +We define a little json query language like [json-query-language](https://github.com/clue/json-query-language/blob/master/SYNTAX.md) +against nodes or edges attributes. + + +### Expressions + +Main expression syntax turn around this: + +``` +{ + operator_name : parameters +} +``` + +### Basic matching expression + +Test if a node/edge has an attribute named "my_property": +``` +{ + "has" : "my_property" +} +``` + + +Test if a node/edge has an attribute product : { "definition": { "name": xxx }} with xxx equals to "chocolate". +``` +{ + "eq" : [ ("product", "definition", "name"), "chocolate"] +} +``` + +The tuple ```("product", "definition", "name")``` is a path in attribut dictionnary. +A Path is a single string or a tuple of string which represente a path in a tree (here a dictionary). + +We support this operators: + +| Name | Alias | Parameters | Description | +| -------- | :---: | --------------- | ----------------------------------------------------------------------------- | +| has | | Path | Check if path exists in context. | +| contains | | Path, str | Check if an attribut path exists and contains specified value. | +| eq | `==` | Path, Any | Check if an attribut path exists and equals specified value. | +| neq | `!=` | Path, Any | Check if an attribut path did not exists or not equals specified value. | +| gt | `>` | Path, Any | Check if an attribut path exists and greather that specified value. | +| lt | `<` | Path, Any | Check if an attribut path exists and lower that specified value. | +| gte | `>=` | Path, Any | Check if an attribut path exists and greather or equals that specified value. | +| lte | `<=` | Path, Any | Check if an attribut path exists and lower or equals that specified value. | +| in | `:=` | Path, List[Any] | Check if an attribut path exists and attribut value in specified values. | + + +### Boolean composition of matching expression + +We support this operators: + +| Name | Alias | Parameters | Description | +| ---- | :---: | ------------- | -------------- | +| and | `&&` | list of query | And operator. | +| or | \|\| | list of query | Or operator. | +| xor | | list of query | xor operator. | +| nxor | | list of query | nxor operator. | +| not | `!` | query | Not operator. | + + +By default, a list of expressions is equivalent of an "AND" of this expressions. + +Example: +``` +{ + 'not': { + 'has': ['group'] + }, + 'has': 'application', + 'eq': [('_link', 'other', 'weight'), 2] +} +``` +is equivalent to: + +``` +{ + 'and': [ + { + 'not': [ + { + 'has': ['group'] + } + ] + }, + { + 'has': ['application'] + }, + { + 'eq': [('_link', 'other', 'weight'), 2] + } + ] +} +``` + + +## Wished Features + +- add projection expression (a return like statement) +- add join relation ship +- add path condition between node + + + + +%package -n python3-networkx-query +Summary: NetworkX Query Tool +Provides: python-networkx-query +BuildRequires: python3-devel +BuildRequires: python3-setuptools +BuildRequires: python3-pip +%description -n python3-networkx-query +# networkx-query + + +[![Unix Build Status](https://img.shields.io/travis/geronimo-iia/networkx-query/master.svg?label=unix)](https://travis-ci.com/geronimo-iia/networkx-query)[![Coverage Status](https://img.shields.io/coveralls/geronimo-iia/networkx-query/master.svg)](https://coveralls.io/r/geronimo-iia/networkx-query) +[![Codacy Badge](https://api.codacy.com/project/badge/Grade/fe669a02b4aa46b5b1faf619ba2bf382)](https://www.codacy.com/app/geronimo-iia/networkx-query?utm_source=github.com&utm_medium=referral&utm_content=geronimo-iia/networkx-query&utm_campaign=Badge_Grade)[![Scrutinizer Code Quality](https://img.shields.io/scrutinizer/g/geronimo-iia/networkx-query.svg)](https://scrutinizer-ci.com/g/geronimo-iia/networkx-query/?branch=master) +[![PyPI Version](https://img.shields.io/pypi/v/networkx-query.svg)](https://pypi.org/project/networkx-query) +[![PyPI License](https://img.shields.io/pypi/l/networkx-query.svg)](https://pypi.org/project/networkx-query) + +Versions following [Semantic Versioning](https://semver.org/) + +## Overview + +NetworkX Query Tool (preview) + +See [documentation](https://geronimo-iia.github.io/networkx-query). + + +## Installation + +Install this library directly into an activated virtual environment: + +```text +$ pip install networkx-query +``` + +or add it to your [Poetry](https://poetry.eustace.io/) project: + +```text +$ poetry add networkx-query +``` + +## Usage + +### Searching nodes + +```python +import networkx as nx +from networkx_query import search_nodes, search_edges + +g = nx.DiGraph() +g.add_node(1, product="chocolate") +g.add_node(2, product="milk") +g.add_node(3, product="coat") +g.add_edge(1, 2, action="shake") +g.add_edge(3, 2, action="produce") + + +for node_id in search_nodes(g, {"==": [("product",), "chocolate"]}): + print(node_id) + +>> 1 +``` + +### Searching edges + +```python +for edge_id in search_edges(g, {"eq": [("action",), "produce"]}): + print(edge_id) + +>> (3, 2) +``` + +### Searching relation ship + +With ```search_direct_relationships``` you can made a query which filter edges on their : + - source node attributes + - edge attributes + - target node attributes + +With this graph: + +```python +import networkx as nx +from networkx_query import search_direct_relationships + +g = nx.DiGraph() +for i in range(30): + g.add_node(i, data=i) + +for i in range(10, 30): + g.add_edge(i - 10, i, data=i) +``` + +We can filtering all edges with source node with data < 3: + +```python +list(search_direct_relationships(graph=g, source={"lt": ["data", 3]})) + +[(0, 10), (1, 11), (2, 12)] +``` + + +We can filtering all edges with: + - source node with data < 8 + - edge with data > 15 + +```python +list(search_direct_relationships(graph=g, source={"lt": ["data", 8]}, edge={"gt": ["data", 15]})) + +>> [(6, 16), (7, 17)] +``` + +We can filtering all edges with: + - source node with data > 9 + - edge with data > 15 + - target node with data < 22 + +```python +search_direct_relationships( + graph=g, source={"gt": ["data", 9]}, edge={"gt": ["data", 15]}, target={'lt': ["data", 22]} + ) + ) + +>> [(10, 20), (11, 21)] +``` + +## API + +Actually, we have: + +- [search_edges](https://geronimo-iia.github.io/networkx-query/api.html#networkx_query.search_edges) +- [search_nodes](https://geronimo-iia.github.io/networkx-query/api.html#networkx_query.search_nodes) +- [search_direct_relationships](https://geronimo-iia.github.io/networkx-query/api.html#networkx_query.search_direct_relationships) + + +All this function are based on [prepare_query](https://geronimo-iia.github.io/networkx-query/api.html#networkx_query.prepare_query) which return an Evaluator. + +Quickly, ```Evaluator``` are function with this signature: (context) -> bool, and ```Context``` is a dictionary like structure (with in and [] methods, and support __contains__ or (__iter__ and __getitem__)) +With networkX, node and edge attributes are dictionary like, so implementation of this three methods are very simple. + + + +## Query language + +We define a little json query language like [json-query-language](https://github.com/clue/json-query-language/blob/master/SYNTAX.md) +against nodes or edges attributes. + + +### Expressions + +Main expression syntax turn around this: + +``` +{ + operator_name : parameters +} +``` + +### Basic matching expression + +Test if a node/edge has an attribute named "my_property": +``` +{ + "has" : "my_property" +} +``` + + +Test if a node/edge has an attribute product : { "definition": { "name": xxx }} with xxx equals to "chocolate". +``` +{ + "eq" : [ ("product", "definition", "name"), "chocolate"] +} +``` + +The tuple ```("product", "definition", "name")``` is a path in attribut dictionnary. +A Path is a single string or a tuple of string which represente a path in a tree (here a dictionary). + +We support this operators: + +| Name | Alias | Parameters | Description | +| -------- | :---: | --------------- | ----------------------------------------------------------------------------- | +| has | | Path | Check if path exists in context. | +| contains | | Path, str | Check if an attribut path exists and contains specified value. | +| eq | `==` | Path, Any | Check if an attribut path exists and equals specified value. | +| neq | `!=` | Path, Any | Check if an attribut path did not exists or not equals specified value. | +| gt | `>` | Path, Any | Check if an attribut path exists and greather that specified value. | +| lt | `<` | Path, Any | Check if an attribut path exists and lower that specified value. | +| gte | `>=` | Path, Any | Check if an attribut path exists and greather or equals that specified value. | +| lte | `<=` | Path, Any | Check if an attribut path exists and lower or equals that specified value. | +| in | `:=` | Path, List[Any] | Check if an attribut path exists and attribut value in specified values. | + + +### Boolean composition of matching expression + +We support this operators: + +| Name | Alias | Parameters | Description | +| ---- | :---: | ------------- | -------------- | +| and | `&&` | list of query | And operator. | +| or | \|\| | list of query | Or operator. | +| xor | | list of query | xor operator. | +| nxor | | list of query | nxor operator. | +| not | `!` | query | Not operator. | + + +By default, a list of expressions is equivalent of an "AND" of this expressions. + +Example: +``` +{ + 'not': { + 'has': ['group'] + }, + 'has': 'application', + 'eq': [('_link', 'other', 'weight'), 2] +} +``` +is equivalent to: + +``` +{ + 'and': [ + { + 'not': [ + { + 'has': ['group'] + } + ] + }, + { + 'has': ['application'] + }, + { + 'eq': [('_link', 'other', 'weight'), 2] + } + ] +} +``` + + +## Wished Features + +- add projection expression (a return like statement) +- add join relation ship +- add path condition between node + + + + +%package help +Summary: Development documents and examples for networkx-query +Provides: python3-networkx-query-doc +%description help +# networkx-query + + +[![Unix Build Status](https://img.shields.io/travis/geronimo-iia/networkx-query/master.svg?label=unix)](https://travis-ci.com/geronimo-iia/networkx-query)[![Coverage Status](https://img.shields.io/coveralls/geronimo-iia/networkx-query/master.svg)](https://coveralls.io/r/geronimo-iia/networkx-query) +[![Codacy Badge](https://api.codacy.com/project/badge/Grade/fe669a02b4aa46b5b1faf619ba2bf382)](https://www.codacy.com/app/geronimo-iia/networkx-query?utm_source=github.com&utm_medium=referral&utm_content=geronimo-iia/networkx-query&utm_campaign=Badge_Grade)[![Scrutinizer Code Quality](https://img.shields.io/scrutinizer/g/geronimo-iia/networkx-query.svg)](https://scrutinizer-ci.com/g/geronimo-iia/networkx-query/?branch=master) +[![PyPI Version](https://img.shields.io/pypi/v/networkx-query.svg)](https://pypi.org/project/networkx-query) +[![PyPI License](https://img.shields.io/pypi/l/networkx-query.svg)](https://pypi.org/project/networkx-query) + +Versions following [Semantic Versioning](https://semver.org/) + +## Overview + +NetworkX Query Tool (preview) + +See [documentation](https://geronimo-iia.github.io/networkx-query). + + +## Installation + +Install this library directly into an activated virtual environment: + +```text +$ pip install networkx-query +``` + +or add it to your [Poetry](https://poetry.eustace.io/) project: + +```text +$ poetry add networkx-query +``` + +## Usage + +### Searching nodes + +```python +import networkx as nx +from networkx_query import search_nodes, search_edges + +g = nx.DiGraph() +g.add_node(1, product="chocolate") +g.add_node(2, product="milk") +g.add_node(3, product="coat") +g.add_edge(1, 2, action="shake") +g.add_edge(3, 2, action="produce") + + +for node_id in search_nodes(g, {"==": [("product",), "chocolate"]}): + print(node_id) + +>> 1 +``` + +### Searching edges + +```python +for edge_id in search_edges(g, {"eq": [("action",), "produce"]}): + print(edge_id) + +>> (3, 2) +``` + +### Searching relation ship + +With ```search_direct_relationships``` you can made a query which filter edges on their : + - source node attributes + - edge attributes + - target node attributes + +With this graph: + +```python +import networkx as nx +from networkx_query import search_direct_relationships + +g = nx.DiGraph() +for i in range(30): + g.add_node(i, data=i) + +for i in range(10, 30): + g.add_edge(i - 10, i, data=i) +``` + +We can filtering all edges with source node with data < 3: + +```python +list(search_direct_relationships(graph=g, source={"lt": ["data", 3]})) + +[(0, 10), (1, 11), (2, 12)] +``` + + +We can filtering all edges with: + - source node with data < 8 + - edge with data > 15 + +```python +list(search_direct_relationships(graph=g, source={"lt": ["data", 8]}, edge={"gt": ["data", 15]})) + +>> [(6, 16), (7, 17)] +``` + +We can filtering all edges with: + - source node with data > 9 + - edge with data > 15 + - target node with data < 22 + +```python +search_direct_relationships( + graph=g, source={"gt": ["data", 9]}, edge={"gt": ["data", 15]}, target={'lt': ["data", 22]} + ) + ) + +>> [(10, 20), (11, 21)] +``` + +## API + +Actually, we have: + +- [search_edges](https://geronimo-iia.github.io/networkx-query/api.html#networkx_query.search_edges) +- [search_nodes](https://geronimo-iia.github.io/networkx-query/api.html#networkx_query.search_nodes) +- [search_direct_relationships](https://geronimo-iia.github.io/networkx-query/api.html#networkx_query.search_direct_relationships) + + +All this function are based on [prepare_query](https://geronimo-iia.github.io/networkx-query/api.html#networkx_query.prepare_query) which return an Evaluator. + +Quickly, ```Evaluator``` are function with this signature: (context) -> bool, and ```Context``` is a dictionary like structure (with in and [] methods, and support __contains__ or (__iter__ and __getitem__)) +With networkX, node and edge attributes are dictionary like, so implementation of this three methods are very simple. + + + +## Query language + +We define a little json query language like [json-query-language](https://github.com/clue/json-query-language/blob/master/SYNTAX.md) +against nodes or edges attributes. + + +### Expressions + +Main expression syntax turn around this: + +``` +{ + operator_name : parameters +} +``` + +### Basic matching expression + +Test if a node/edge has an attribute named "my_property": +``` +{ + "has" : "my_property" +} +``` + + +Test if a node/edge has an attribute product : { "definition": { "name": xxx }} with xxx equals to "chocolate". +``` +{ + "eq" : [ ("product", "definition", "name"), "chocolate"] +} +``` + +The tuple ```("product", "definition", "name")``` is a path in attribut dictionnary. +A Path is a single string or a tuple of string which represente a path in a tree (here a dictionary). + +We support this operators: + +| Name | Alias | Parameters | Description | +| -------- | :---: | --------------- | ----------------------------------------------------------------------------- | +| has | | Path | Check if path exists in context. | +| contains | | Path, str | Check if an attribut path exists and contains specified value. | +| eq | `==` | Path, Any | Check if an attribut path exists and equals specified value. | +| neq | `!=` | Path, Any | Check if an attribut path did not exists or not equals specified value. | +| gt | `>` | Path, Any | Check if an attribut path exists and greather that specified value. | +| lt | `<` | Path, Any | Check if an attribut path exists and lower that specified value. | +| gte | `>=` | Path, Any | Check if an attribut path exists and greather or equals that specified value. | +| lte | `<=` | Path, Any | Check if an attribut path exists and lower or equals that specified value. | +| in | `:=` | Path, List[Any] | Check if an attribut path exists and attribut value in specified values. | + + +### Boolean composition of matching expression + +We support this operators: + +| Name | Alias | Parameters | Description | +| ---- | :---: | ------------- | -------------- | +| and | `&&` | list of query | And operator. | +| or | \|\| | list of query | Or operator. | +| xor | | list of query | xor operator. | +| nxor | | list of query | nxor operator. | +| not | `!` | query | Not operator. | + + +By default, a list of expressions is equivalent of an "AND" of this expressions. + +Example: +``` +{ + 'not': { + 'has': ['group'] + }, + 'has': 'application', + 'eq': [('_link', 'other', 'weight'), 2] +} +``` +is equivalent to: + +``` +{ + 'and': [ + { + 'not': [ + { + 'has': ['group'] + } + ] + }, + { + 'has': ['application'] + }, + { + 'eq': [('_link', 'other', 'weight'), 2] + } + ] +} +``` + + +## Wished Features + +- add projection expression (a return like statement) +- add join relation ship +- add path condition between node + + + + +%prep +%autosetup -n networkx-query-1.0.1 + +%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-networkx-query -f filelist.lst +%dir %{python3_sitelib}/* + +%files help -f doclist.lst +%{_docdir}/* + +%changelog +* Wed Apr 12 2023 Python_Bot - 1.0.1-1 +- Package Spec generated diff --git a/sources b/sources new file mode 100644 index 0000000..0fefb3e --- /dev/null +++ b/sources @@ -0,0 +1 @@ +9dd9411eb61c36bdf7dc92e014441c8a networkx_query-1.0.1.tar.gz -- cgit v1.2.3