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

All Samples(5)  |  Call(2)  |  Derive(0)  |  Import(3)
Get the relative path to to_path from from_path

        def get_relative_path(from_path, to_path):
    """Get the relative path to to_path from from_path"""
    from_list = from_path.split(os.sep)
    to_list = to_path.split(os.sep)
    final_list = list(to_list)
    common = []
    uncommon = []
    if len(to_list) > len(from_list):
        for i, segment in enumerate(from_list):
            if to_list[i] == segment:
                final_list.pop(0)
            else:
                return None
        return final_list
    elif to_list == from_list:
        # the relative path between the same paths is an empty sequence
        return []
    else:
        return None
        


src/p/i/pida-0.6.2/pida/core/projects.py   pida(Download)
from pida.core.log import Log
from pida.core.indexer import Indexer
from pida.utils.path import get_relative_path
from pida.utils.addtypes import Enumeration
 
    def get_relative_path_for(self, filename):
        return get_relative_path(self.source_directory, filename)
 
    @staticmethod
    def create_blank_project_file(name, project_directory):

src/p/i/pida-0.6.2/pida/core/languages.py   pida(Download)
    LANG_VALIDATOR_TYPES, LANG_VALIDATOR_SUBTYPES, LANG_PRIO,
    Suggestion, Definition, ValidationError, Documentation)
from pida.utils.path import get_relative_path
# locale
from pida.core.locale import Locale
        if self.filename is None or not self._project_path:
            return None, None
        return get_relative_path(self._project_path, self.filename)
 
    def _get_project(self):

src/p/i/pida-0.6.2/tests/utils/test_path.py   pida(Download)
import os.path
from unittest import TestCase
from pida.utils.path import get_line_from_file, get_relative_path
 
class TestPath(TestCase):