Beispiel #1
0
import logging
from priv_logging import getLogger
from fuse import Fuse
from dropbox_manager import DropboxManager
from time import time

import stat    # for file properties
import os      # for filesystem modes (O_RDONLY, etc)
import errno   # for error number codes (ENOENT, etc)
               # - note: these must be returned as negatives

# TODO: Check if fuse has attribute __version__

fuse.fuse_python_api = (0, 2)

logger = getLogger('rofs_fuse')

manager = DropboxManager()

def dirFromList(list):
    """
    Return a properly formatted list of items suitable to a directory listing.
    [['a', 'b', 'c']] => [[('a', 0), ('b', 0), ('c', 0)]]
    """
    return [[(x, 0) for x in list]]

def getDepth(path):
    """
    Return the depth of a given path, zero-based from root ('/')
    """
    if path == '/':
Beispiel #2
0
#!/usr/bin/python
from time import time
import logging
from priv_logging import getLogger

logger = getLogger('cache')

def y(function):
	"""
Based in the javascript implemention at http://matt.might.net/articles/implementation-of-recursive-fixed-point-y-combinator-in-javascript-for-memoization/

The Y combinator finds the fixed point of the "functional" passed in as an argument.
Thus, the Y combinator satisfies the property:
	Y(F) = F(Y(F))

Usage:
	(Factorial example)
	> factgen = lambda fact: lambda x: ((x == 0 and 1) or (x * fact(x-1)))
	> (y(factgen))(6)
	720
	
	"""
	return (lambda x: function(lambda y: (x(x))(y) )) (lambda x: function(lambda y: (x(x))(y)  ) )



	
def y_mem_body(cache, arg):
	"""
Implementation of the memoization technique using the y-combinator, based in the javascript implementation at http://matt.might.net/articles/implementation-of-recursive-fixed-point-y-combinator-in-javascript-for-memoization/
	"""