Did I find the right examples for you? yes no      Crawl my project      Python Jobs

All Samples(7)  |  Call(5)  |  Derive(0)  |  Import(2)
Parses out a path to a file in a format suitable for
inserting into and searching the database

Args:
watch_dirs - list of directories script is watching
p - full path to file (if p is a directory [requires trailing slash], file_name will be "")

Returns: tuple (watch_dir, base_path, file_name)

        def split_path(watch_dirs, p):
    """
    Parses out a path to a file in a format suitable for
    inserting into and searching the database
    
    Args:
    watch_dirs - list of directories script is watching
    p - full path to file (if p is a directory [requires trailing slash], file_name will be "")
    
    Returns: tuple (watch_dir, base_path, file_name)
    """

    watch_dir = ""
    base_path = ""
    file_name = ""

    # find which watch_dir is being used
    for d in watch_dirs:
        split = re.split("^{0}".format(d), p)
        if split[0] == "":
            watch_dir = d.rstrip(os.sep)
            base_path = split[1].lstrip(os.sep)
            break

    base_path, file_name = os.path.split(base_path)

    return(watch_dir, base_path, file_name)
        


src/a/r/archivedb-0.2.3/archivedb/monitor.py   archivedb(Download)
import archivedb.config as config
import archivedb.sql as sql
from archivedb.common import md5sum, split_path
from archivedb.logger import log_traceback
 
    size = os.stat(full_path).st_size
 
    (watch_dir, path, filename) = split_path(args["watch_dirs"], full_path)
 
    data = db.get_fields(watch_dir, path, filename, ["mtime", "size"])
                    dest_full_path += os.sep
 
                src_split_path = split_path(args["watch_dirs"], src_full_path)
                dest_split_path = split_path(args["watch_dirs"], dest_full_path)
                log.debug("src_split_path    = {0}".format(src_split_path))

src/a/r/archivedb-0.2.3/archivedb/sql.py   archivedb(Download)
import logging
import archivedb.config as config
from archivedb.common import enum_to_list, list_to_enum, split_path
 
#### DEPRECATED ################################################################
    def delete_file(self, full_path):
        (watch_dir, path, filename) = split_path(config.args["watch_dirs"], full_path)
 
        # get id
        data = self.get_fields(watch_dir, path, filename, ["id"])
    def delete_directory(self, d):
        self._check_connection()
        d = d.rstrip(os.sep) + os.sep # append os.sep so split_path knows its a dir
        watch_dir, path = split_path(config.args["watch_dirs"], d)[0:2]