Giter Club home page Giter Club logo

jsonfs's Introduction

jsonfs

Build Status

Convert a filesystem to a dictionary you can edit in python.

Currently, this is just meant to be a quick and easy way to create nested directories easily in python.

Usage

from jsonfs import Directory

# Creates a directory in the current dir.
# This oject can be treated as a dictionary.
directory = Directory("somedir")

# Create a file (values don't really matter)

directory["somefile.txt"] = None

# Create a directory
directory["anotherdir"] = {"anotherfile.csv": None}

# Commit the changes to impliment the changes above.
directory.commit()  # Now the files and dir are created under "somedir/"

# You can commit with a callback function to call every time a file
# is found in the tree when iterating over files.
def callback(fullpath):
    print fullpath
directory.commit(filehandler=callback)  # prints "somefile.txt" and "anotherfile.csv"


## Other stuff
# All keys are converted to strings when committing.
directory[(1, 2)] = None  # somedir/(1,\ 2)

# If a filename that is specified like a directory is used as a key,
# the file will not be created.
directory["potentialdir/"] = None  # No new file created

Test

$ python testjsonfs.py

TODO

  • Add a way for deleting files.
  • Figure out a way the value for each dictionary can be used.

Suggestions/Bug/I messed something up horribly

Feel free to submit an issue.

jsonfs's People

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.