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

All Samples(29)  |  Call(26)  |  Derive(0)  |  Import(3)
Return a relative version of a path

        def relpath(path, start=curdir):
    """Return a relative version of a path"""

    if not path:
        raise ValueError("no path specified")

    start_list = [x for x in abspath(start).split(sep) if x]
    path_list = [x for x in abspath(path).split(sep) if x]

    # Work out how much of the filepath is shared by start and path.
    i = len(commonprefix([start_list, path_list]))

    rel_list = [pardir] * (len(start_list)-i) + path_list[i:]
    if not rel_list:
        return curdir
    return join(*rel_list)
        


src/a/r/Archiver-0.2.2/archiver/api.py   Archiver(Download)
import uuid
 
from bn import relpath, uniform_path, AttributeDict
from sqlalchemy import Table, Column, Integer, String, MetaData, ForeignKey,\
    DateTime, Enum, select, and_, create_engine, not_
                num_dirs += 1
                path = os.path.join(root, directory)
                log.debug('Inspecting directory %r to add to source %r', relpath(path, base_path), source)
                metadata = self.source.metadata(path)
                del metadata['size']
                add_directory_metadata = True
                replace_directory_metadata = False
                if update:
                    directory_records = self.metadata._directory_metadata_exists(
                        relpath(path, base_path),
                        metadata_format = [
                            source__uid,
                            relpath(path, base_path),
                            metadata['modified'],
                            metadata['owner'],
                            log.info(
                                'Updating the existing directory metadata for %r',
                                relpath(path, base_path)
                            )
                            replace_directory_metadata=True

src/d/r/DreamweaverTemplate-0.2.2/dreamweavertemplate/__init__.py   DreamweaverTemplate(Download)
import re
 
from bn import relpath, uniform_path
 
log = logging.getLogger(__name__)
                    pos = end_of_start_html_tag(template_region)
                    rel = relpath(
                        template_path, 
                        posixpath.dirname(new_path)
                    )
                        )
                    rel = relpath(
                        template_path, 
                        posixpath.dirname(new_path)
                    )
        # Calculate the new relative path from the new_path to the absolute 
        # path of the link
        new_link = relpath(link_path, posixpath.dirname(new_path))
        # If the link is a directory ensure there is a trailing slash
        if (old_link == '.' or old_link.endswith('/')) and \

src/g/a/Gallery-0.1.0/gallery/__init__.py   Gallery(Download)
 
from bn import uniform_path
from bn import relpath
from commandtool import parse_html_config
from commandtool import strip_docstring
                picpath = dirpath.replace(meta, source_1024)
                if not os.path.isdir(os.path.join(dirpath, filename)):
                    path = relpath(os.path.join(picpath, filename), source_1024)
                    photos.append(path)
            else:
                vidpath = dirpath.replace(meta, source_h264)
                if not os.path.isdir(os.path.join(vidpath, filename)):
                    path = relpath(os.path.join(vidpath, filename), source_h264)

src/a/s/asm.cms-0.1.8/src/asm/cms/htmlpage.py   asm.cms(Download)
    def fix_relative(url):
        if not url.startswith('/'):
            return
        return bn.relpath(url, current_path)