Skip to main content

Filesystem-like hierarhy of objects and it's namespace

Project description

Python package

pyNamespace

pyNamespace is an Application Framework supporting creation of the in-application data storage, simulating organization and behavior of the Unix filesystem graph. You can create "directories" and data objects. Refer those directories and data using Unix-like path. Also, you can create internal links between an objects and link one data object to more than one "directory".

Creation of a namespace

from pyNamespace import *
ns = Namespace()

After you import pyNamespace module, you shall create an object of type Namespace. The "filesystem" root - "/" will be created automatically.

Reading and writing into a namespace

from pyNamespace import *
ns = Namespace()
ns.set("home/answer", 42)
print(ns.get("home/answer"))

.set and .get methods will store and read objects from Namespace. Parameters for .set will be the path and a value which will be stored at that path. For .get it'll be a path, from which value will be retrieved.

Removing objects from namespace

from pyNamespace import *
ns = Namespace()
ns.set("home/answer", 42)
ns.rm("home/answer")

.rm with path parameter will remove an object from the namespace. .rm also removes all "orphan" (nodes which do not have an incoming connections) nodes from the graph.

Refer one node to another in the namespace.

There are two types of the references Soft-reference assumes that the object will be created in the graph, which will have a reference to another object. Method .get will recognize the reference and return the value of the original (source) object. Hard-reference will actually link source object with destination object in the graph.

.link method will create a "soft-link" and .ref will create a hard-reference.

from pyNamespace import *

ns = Namespace()
ns.set("home/answer", 42)
print(ns.link("home/answer", "etc/answer"))
print(ns.get("etc/answer"))

This is an example of the soft-reference.

from pyNamespace import *

ns = Namespace()
ns.set("home/answer", 41)
ns.ref("home/answer", "etc")
ns.set("home/answer", 42)

This is an example of the hard-reference

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyNamespace-0.0.7.tar.gz (16.6 kB view details)

Uploaded Source

File details

Details for the file pyNamespace-0.0.7.tar.gz.

File metadata

  • Download URL: pyNamespace-0.0.7.tar.gz
  • Upload date:
  • Size: 16.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/46.4.0 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.7.7

File hashes

Hashes for pyNamespace-0.0.7.tar.gz
Algorithm Hash digest
SHA256 5f4869f40a6a105e342dfdc8dc7e7b7a47bb91a397ee57b1e9454ef9c1a55f12
MD5 7dde4bb5cd6fed50689e5f2aef13df58
BLAKE2b-256 ad62aa2e7591b5adab9a29babc02cfeff0151a2449644311fbb892a819a89357

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page