Skip to main content

Access directories like objects

Project description

Pyerarchy is a Python package for easy file system surfing and manipulation. It enables to interact with the file system directly as Python objects without making implicit calls to os package. Finally it makes the code much more readable and nice.

Basic Usage

The central point of Pyerarchy is the Node. The basic usage starts by initializing an entry point Node and manipulating it further:

node = Node('entry/point/path')  # Initialize a new node

children =  # List all child entities of the node
node.mkdir('newdir').mkdir('anotherdir')  # Create a new directory under node, and another one under the new one :)

# Now access the newly created directories
anotherdir = node/'newdir'/'anotherdir'  # This is the most common way to access nodes
children =  # This method can be used to invoke an operation on the result node

# What about files?
myfile = node.myfile

# And even...
myfile ='w')

# Or...
contents =  # ...which handles everything

# What if the filename contains a dot, dash, etc?
# Well...
myfile_node = node/'filename.with.dots-and-dashes'

# And then do your stuff on myfile_node
with'r') as f:

# Or again...
contents =

Another useful feature of Pyerarchy is very handy in Python modules to interact with static files included in the module:

static_data_node = ThisModuleNode()/'path/to/the/static/data/relative/to/module'

some_file_node = static_data_node/'some/static/text/file'

contents =

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

pyerarchy-0.1.tar.gz (5.2 kB view hashes)

Uploaded source

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