GithubHelp home page GithubHelp logo

pytagfs's Introduction

Prerequisites

To run pytagfs you need

Installation

If you want to give the pytagfs a try clone the git repository first.

~/code $ git clone https://github.com/dizel-by/pytagfs.git

Next cd to the pytagfs directory...

~/code $ cd pytagfs

and create a mountpoint directory inside.

~/code/pytagfs $ mkdir mountpoint

Good, now mount the pytagfs.

~/code/pytagfs $ python tags.py test/ mountpoint/

This should end fine. Now you have pytagfs mounted to mountpoint/, read on.

Usage

First cd to the mountpoint/ directory.

~/code/pytagfs $ cd mountpoint/

Now if you followed the Installation instructions above you should see a list of tag directories in mountpoint/

~/code/pytagfs/mountpoint $ ls -F
tag1/  tag2/  tag3/  tag4/

~/code/pytagfs/mountpoint $ ls -F tag1/
file1@  file2@  tag3/  tag4/

~/code/pytagfs/mountpoint $ readlink tag1/file1
/home/ivan/code/pytagfs/test/file1

As you can see each tag directory contains links to actual files and other tags these files are tagged with. If you remove a link pytagfs adjusts the tags automagically.

~/code/pytagfs/mountpoint $ ls -F tag1/ tag3/
tag1/:
file1@  file2@  tag3/  tag4/

tag3/:
file1@  tag1/  tag4/

~/code/pytagfs/mountpoint $ rm tag1/file1

~/code/pytagfs/mountpoint $ ls -F tag1/ tag3/
tag1/:
file2@  tag4/

tag3/:

You can see what's going on by checking the test/ directory insides (I'll use git status).

~/code/pytagfs/mountpoint $ (cd .. && git status -s)
 D test/tags/tag1/file1
 D test/tags/tag3/file1
 D test/tags/tag4/file1

As you can see the link to file1 was deleted from relevant tag directories. Note, there is currently no way to remove a file from just one tag, it's all or nothing.

Ok then, now I'm going to add a tag and then tag an existing file.

~/code/pytagfs/mountpoint $ mkdir textfiles

~/code/pytagfs/mountpoint $ ls -F
tag1/  tag2/  tag3/  tag4/  textfiles/

~/code/pytagfs/mountpoint $ ln -s $(realpath ../test/file1) textfiles/

~/code/pytagfs/mountpoint $ ls -F textfiles/
file1@

And obviously.

~/code/pytagfs/mountpoint $ readlink textfiles/file1 
/home/ivan/code/pytagfs/test/file1

And under the hood (I'll ignore old, now irrelevant output starting now).

~/code/pytagfs/mountpoint $ (cd .. && git add test/tags/textfiles/ && git status -s)
A  test/tags/textfiles/file1

I had to git-add because git doesn't care about directories it wasn't asked to watch.

And I'm going to add a file now.

~/code/pytagfs/mountpoint $ echo 'Roses are red.' > ../test/poetry

~/code/pytagfs/mountpoint $ ln -s $(realpath ../test/poetry) textfiles/

~/code/pytagfs/mountpoint $ ls -F textfiles/
file1@  poetry@

~/code/pytagfs/mountpoint $ readlink textfiles/poetry 
/home/ivan/code/pytagfs/test/poetry

There are two things I want to say here. Firstly the $(realpath) thingie, we don't support relpath targets. And secondly, note that pytagfs works with symlinks and doesn't store the actual files, that's why I had to create a file in test/poetry first and then symlink it. But I'm going to try it nevertheless.

~/code/pytagfs/mountpoint $ echo text > textfiles/newfile
bash: textfiles/newfile: Function not implemented

~/code/pytagfs/mountpoint $ ls -F textfiles/
file1@  poetry@

Oops.

One last thing, I'll get a list of files tagged with both tag1 and tag4.

~/code/pytagfs/mountpoint $ ls -F tag1/tag4/
file2@

~/code/pytagfs/mountpoint $ ls -F tag4/tag1/
file2@

Ok, now unmount.

~/code/pytagfs/mountpoint $ cd .. && fusermount -u mountpoint/

And we're done. Here is what git status shows me.

~/code/pytagfs $ git status -s
 D test/tags/tag1/file1
 D test/tags/tag3/file1
 D test/tags/tag4/file1
A  test/tags/textfiles/file1
?? test/poetry
?? test/tags/textfiles/poetry

Hacking

For playing with fuse-python you will need this link: http://sourceforge.net/apps/mediawiki/fuse/index.php?title=FUSE_Python_Reference

Then we have TagFS.__log(s) for appending strings to /tmp/tags.log file. ls does readdir() (and bash getattr() for every thing it sees to determine how to display it), rm calls unlink(). symlink(), mkdir() and rmdir() are pretty much self-explanatory.

Have fun.

pytagfs's People

Contributors

dizel-by avatar ivan-dives avatar

Watchers

 avatar  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.