Skip to main content

Pistachio aims to simplify reoccurring tasks when working with the file system.

Project description

pistachio

Pistachio aims to simplify reoccurring tasks when working with the file system.

Developing

To install pistachio, along with the tools you need to develop and run tests, run the following in your virtualenv:

$ pip install -e .[dev]

Install

You can install pistachio by running the following command.

$ pip install pistachio

Usage

To use pistachio you can inport the module by running the following commands.

>>> import pistachio

Describe

Method to return a description for the resource.

>>> print(json.dumps(pistachio.describe("README.md"), sort_keys=2, indent=2))
{
  "exists": true,
  "is_directory": false,
  "is_file": true,
  "is_symlink": false,
  "name": "README.md",
  "path": "README.md",
  "stem": "README",
  "suffix": ".md"
}

print(json.dumps(pistachio.tree("src"), sort_keys=2, indent=2))

Exists

You can confirm if a directory, file or symbolic link exists using the following method.

>>> pistachio.exists("README.md")
True

Get MD5 Hash

This method will return the MD5 hash string for a specific file.

>>> pistachio.get_md5_hash("README.md")
"2f853812babf98322618edeb24359591"

Is Directory

Is the resource a directory? True or False.

>>> pistachio.is_directory("README.md")
False

Is File

Is the resource a file? True or False.

>>> pistachio.is_file("README.md")
True

Is Symlink

Is the resource a symbolic link? True or False.

>>> pistachio.is_symlink("README.md")
False

Make Directory

Make a new directory or directory tree.

>>> pistachio.mkdir("src")
>>> pistachio.exists("src")
True

Touch

This method will create an empty file with a given filename and directory path.

>>> pistachio.touch("foo.bar")
True

Tree

This method will return a list of directories, files and symlinks below a specific directory.

>>> print(json.dumps(pistachio.tree("src"), sort_keys=2, indent=2))
{
  "path": "src",
  "results": [
    {
      "exists": true,
      "is_directory": false,
      "is_file": true,
      "is_symlink": false,
      "name": "__init__.py",
      "path": "./__init__.py",
      "stem": "__init__",
      "suffix": ".py"
    },
    {
      "exists": true,
      "is_directory": false,
      "is_file": true,
      "is_symlink": false,
      "name": "pistachio.py",
      "path": "./pistachio.py",
      "stem": "pistachio",
      "suffix": ".py"
    }
  ]
}

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

pistachio-0.4.0.tar.gz (6.3 kB view hashes)

Uploaded Source

Built Distribution

pistachio-0.4.0-py3-none-any.whl (4.2 kB view hashes)

Uploaded Python 3

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