Quick Start

This is a quick introduction to PyOS, see the restaurants example for a more complete example.

[1]:
from pyos.pyos import *
from mincepy.testing import Car
Welcome to

                  ____  ____
                 / __ \/ __ /
    ____  __  __/ / / / /_
   / __ \/ / / / / / /\__ \
  / /_/ / /_/ / /_/ /___/ /
 / .___/\__, /\____//____/
/_/    /____/                 v0.5.1

Our Car class has two members, make and colour, so let’s save a couple in the current directory:

[2]:
pwd()
[2]:
Path('/martin/')
[3]:
ls()
[3]:
<empty>
[4]:
ferrari = Car('ferrari', 'red')
save(ferrari, 'ferrari')
skoda = Car('skoda', 'green')
save(skoda, 'skoda')
ls -l ()
[4]:
*  mincepy|Car  0  Apr 09 21:32  ferrari
*  mincepy|Car  0  Apr 09 21:32  skoda

Let’s have a look at the cars:

[5]:
ls | cat
[5]:
┌──────────────┬────────────────────────┐
│ATTRS         │┌─┬──────┐              │
│              ││0│colour│              │
│              ││1│make  │              │
│              │└─┴──────┘              │
│IGNORE_MISSING│True                    │
│TYPE_ID       │5e075d6244572f823ed93274│
│colour        │red                     │
│make          │ferrari                 │
│obj_id        │5e8f78308ae3ac1077bfc304│
└──────────────┴────────────────────────┘
┌──────────────┬────────────────────────┐
│ATTRS         │┌─┬──────┐              │
│              ││0│colour│              │
│              ││1│make  │              │
│              │└─┴──────┘              │
│IGNORE_MISSING│True                    │
│TYPE_ID       │5e075d6244572f823ed93274│
│colour        │green                   │
│make          │skoda                   │
│obj_id        │5e8f78308ae3ac1077bfc306│
└──────────────┴────────────────────────┘

We see some additional properties of the objects used to store them in the database but our colours and makes are there. Now, let’s move them to their own folder…

[6]:
mv('ferrari', 'skoda', 'garage/')
ls()
[6]:
garage/

…and set some metadata

[7]:
meta -s ('garage/ferrari', reg='VD394') # '-s' for set
meta -s ('garage/skoda', reg='N317')
meta('garage/ferrari') # This gets our metadata
[7]:
┌──────────┬────────────────────────┐
│reg       │VD394                   │
│_directory│/martin/garage/         │
│name      │ferrari                 │
│obj_id    │5e8f78308ae3ac1077bfc304│
└──────────┴────────────────────────┘

The metadata can be used to search:

[8]:
find(meta=dict(reg='VD394')) | locate
[8]:
Path('/martin/garage/ferrari')

Finally, let’s clean up.

[9]:
  rm -r ('garage/')
  ls()
[9]:
<empty>