You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
-`pico install city foaf emmo dcat2` (the installation of these specific
27
+
well-known ontologies is available via this shortcut)
20
28
21
29
_Behaviour:_
22
-
- The ontology file is parsed, and the entities mapped to python objects.
23
-
- The python classes can be imported via their namespace
24
-
`from osp.core.namespaces import namespace`
30
+
- The ontology file is parsed, and the entities mapped to Python objects.
31
+
- The Python objects can be imported via their namespace `from osp.core.namespaces import namespace`.
25
32
26
33
_Example:_
27
34
```console
@@ -33,12 +40,13 @@ INFO [osp.core.ontology.parser]: Loaded 367 ontology triples in total
33
40
INFO [osp.core.ontology.installation]: Installation successful
34
41
```
35
42
36
-
###Pico lists
43
+
#### pico lists
37
44
_Usage:_`pico list`
38
45
39
46
_Behaviour:_
40
47
- The installed namespaces and packages are printed out. A package can be
41
-
uninstalled and can contain many namespaces. A namespace can be imported in code.
48
+
uninstalled and can contain many namespaces. A namespace can be imported
49
+
within the Python shell.
42
50
43
51
_Example:_
44
52
```console
@@ -56,34 +64,26 @@ Namespaces:
56
64
- city
57
65
```
58
66
59
-
### Pico uninstalls
60
-
_Usage:_`pico uninstall <package>|all`.
61
-
Note that to select all the packages, `all` must be quoted.
67
+
#### pico uninstalls
68
+
_Usage:_
69
+
-`pico uninstall <package>`
70
+
-`pico uninstall all`
62
71
63
72
_Behaviour:_
64
-
-All installed packages / namespaces are uninstalled.
65
-
- All namespaces except the uninstalled ones are re-installed.
73
+
-The specified packages are uninstalled.
74
+
- All packages except the uninstalled ones are re-installed.
66
75
67
76
_Example:_
68
77
```console
78
+
(venv) user@PC:~$ pico uninstall city
69
79
INFO [osp.core.ontology.installation]: Will install the following namespaces: ['qe']
70
80
INFO [osp.core.ontology.yml.yml_parser]: Parsing YAML ontology file /home/<username>/.osp_ontologies/qe.yml
71
81
INFO [osp.core.ontology.yml.yml_parser]: You can now use `from osp.core.namespaces import qe`.
72
82
INFO [osp.core.ontology.parser]: Loaded 205 ontology triples in total
73
83
INFO [osp.core.ontology.installation]: Uninstallation successful
74
84
```
75
85
76
-
### Ontology installation folder
77
-
78
-
The installed ontologies are stored in the directory `~/.osp-ontologies` by
79
-
default. On Windows, `~` usually refers to the path
80
-
`C:\Users\<my username>`.
81
-
82
-
The installation directory can be changed by setting the
83
-
environment variable `OSP_ONTOLOGIES_DIR`. Such action would move it to
84
-
`$OSP_ONTOLOGIES_DIR/.osp-ontologies`.
85
-
86
-
### Conflicts with other "pico" installations
86
+
#### Conflicts with other "pico" installations
87
87
Some Operating Systems might have a pre-existing tool called _pico_.
88
88
In most cases, the previous commands should work, but if any problem arises,
89
89
you can use the following alternative:
@@ -97,6 +97,54 @@ For example:
97
97
python -m osp.core.pico install city
98
98
```
99
99
100
+
### Using pico as a Python module
101
+
102
+
`pico` can also be used within the Python shell. In particular, four
103
+
functions are available to be imported from the `osp.core.pico` module,
104
+
105
+
```python
106
+
from osp.core.pico import install, namespaces, packages, uninstall
107
+
```
108
+
109
+
that cover the three main operations that pico is meant to perform: installing
110
+
ontologies (`install`), uninstalling ontologies (`uninstall`), and listing the
111
+
installed ontologies (`packages`, `namespaces`).
112
+
113
+
Each function is used in a similar way to its command-line counterpart.
114
+
115
+
-`install`: accepts _one or more_ positional arguments of string
116
+
type, which can be either paths to `yml` ontology installation files or
117
+
names of ontologies that can be installed via this shortcut. It is meant to
118
+
clone the
119
+
[behavior of its command-line counterpart](https://simphony.readthedocs.io/en/latest/utils.html#pico-installs).
120
+
121
+
-`uninstall`: accepts _one or more_ positional arguments of string type,
122
+
which must be names of already installed ontology packages. It also
123
+
clones the [behavior of its command-line counterpart](https://simphony.readthedocs.io/en/latest/utils.html#pico-uninstalls).
124
+
125
+
-`packages`: accepts no arguments and returns an [iterator](https://wiki.python.org/moin/Iterator)
126
+
over the names of the installed packages.
127
+
128
+
-`namespaces`: accepts no arguments and returns an iterator yielding one
129
+
[`OntologyNamespace` object](https://simphony.readthedocs.io/en/latest/api_ref.html#osp.core.ontology.namespace.OntologyNamespace) for each installed namespace.
0 commit comments