hash()

Steven D'Aprano steve at REMOVETHIScyber.com.au
Wed Dec 7 05:07:34 EST 2005


On Tue, 06 Dec 2005 15:44:07 +0000, John Marshall wrote:

> The goal is to be able to keep some meta-data
> for each file/directory of a directory hierarchy
> in a separate directory: one meta-data file per
> file/directory. 

So you are planning on shadowing the entire file system with a single
massive directory? Ouch.

Off the top of my head, you could try shadowing the directory tree:

root
+---directory1
+   +---file1
+   +---file2
+---directory2
+   +---file1
+---+SHADOW-METADATA
+   +---directory1-METADATA
+   +   +---file1-METADATA
+   +   +---file2-METADATA
+   +---directory2-METADATA
+   +   +---file1-METADATA
    
Then given a pathname, something like this should point to the metadata:

# not tested
def path_realtometa(path):
    """Given a pathname, return the pathname of the metadata."""
    if "SHADOW-METADATA" in path:
        raise ValueError("Can't shadow a metadata pathname.")
    return "SHADOW-METADATA/"+path

I dare say there are complications I haven't thought of, but there are
three major advantages:

- the metadata system is human friendly and not opaque. Your users can
easily clear out dead links, which is difficult to do with the Gnome and
KDE metadata systems.

- your users won't curse the day you were born if they open your metadata
directory with a GUI file manager like Nautilus, as I have done to the
Gnome developers. (Sorry guys, but didn't you ever test Nautilus with a
directory containing 20,000+ thumbnail files?)

- no collisions. 


-- 
Steven.




More information about the Python-list mailing list