Python os.path.pardir() Examples

The following are code examples for showing how to use os.path.pardir(). They are extracted from open source Python projects. You can vote up the examples you like or vote down the exmaples you don't like. You can also save this page to your account.

Example 1
Project: calmjs   Author: calmjs   File: test_toolchain.py    (license) View Source Project 6 votes vote down vote up
def test_toolchain_standard_build_dir_remapped(self):
        """
        This can either be caused by relative paths or symlinks.  Will
        result in the manually specified build_dir being remapped to its
        real location
        """

        fake = mkdtemp(self)
        real = mkdtemp(self)
        real_base = basename(real)
        spec = Spec()
        spec['build_dir'] = join(fake, pardir, real_base)

        with pretty_logging(stream=StringIO()) as s:
            with self.assertRaises(NotImplementedError):
                self.toolchain(spec)

        self.assertIn('realpath of build_dir resolved to', s.getvalue())
        self.assertEqual(spec['build_dir'], real) 
Example 2
Project: calmjs   Author: calmjs   File: test_indexer.py    (license) View Source Project 6 votes vote down vote up
def test_module2_recursive_es6(self):
        from calmjs.testing import module2
        calmjs_base_dir = abspath(join(
            indexer.modpath_pkg_resources(indexer)[0], pardir))
        results = {
            k: relpath(v, calmjs_base_dir)
            for k, v in indexer.mapper(module2, globber='recursive').items()
        }
        self.assertEqual(results, {
            'calmjs/testing/module2/index':
                to_os_sep_path('calmjs/testing/module2/index.js'),
            'calmjs/testing/module2/helper':
                to_os_sep_path('calmjs/testing/module2/helper.js'),
            'calmjs/testing/module2/mod/helper':
                to_os_sep_path('calmjs/testing/module2/mod/helper.js'),
        }) 
Example 3
Project: calmjs   Author: calmjs   File: test_indexer.py    (license) View Source Project 6 votes vote down vote up
def test_module2_callables(self):
        from calmjs.testing import module2
        calmjs_base_dir = abspath(join(
            indexer.modpath_pkg_resources(indexer)[0], pardir))
        results = {
            k: relpath(v, calmjs_base_dir)
            for k, v in indexer.mapper(
                module2,
                globber=indexer.globber_recursive,
                modname=indexer.modname_python,
                modpath=indexer.modpath_pkg_resources,
            ).items()
        }
        self.assertEqual(results, {
            'calmjs.testing.module2.index':
                to_os_sep_path('calmjs/testing/module2/index.js'),
            'calmjs.testing.module2.helper':
                to_os_sep_path('calmjs/testing/module2/helper.js'),
            'calmjs.testing.module2.mod.helper':
                to_os_sep_path('calmjs/testing/module2/mod/helper.js'),
        }) 
Example 4
Project: gcforest   Author: w821881341   File: cache_feature.py    (license) View Source Project 6 votes vote down vote up
def save_cache(src_path, des_path, get_feature_func):
    des_path = osp.splitext(des_path)[0] + '.npy'
    try:
        X, sr = librosa.load(src_path)
        src = int(sr)
        feature = get_feature_func(X, sr)
        print('[INFO] Saving Cache in {} ...'.format(des_path))
        des_par = osp.abspath(osp.join(des_path, osp.pardir))
        if not osp.exists(des_par):
            os.makedirs(des_par)
    except Exception, e:
        print("[ERROR] Unkown error happend when dealing with{}".format(src_path))
        #print(e)
        return -1
    np.save(des_path, feature)
    return 0 
Example 5
Project: niceman   Author: ReproNim   File: test_utils.py    (license) View Source Project 6 votes vote down vote up
def test_find_files():
    tests_dir = dirname(__file__)
    proj_dir = normpath(opj(dirname(__file__), pardir))

    ff = find_files('.*', proj_dir)
    ok_generator(ff)
    files = list(ff)
    assert(len(files) > 10)  # we have more than 10 test files here
    assert_in(opj(tests_dir, 'test_utils.py'), files)
    # and no directories should be mentioned
    assert_not_in(tests_dir, files)

    ff2 = find_files('.*', proj_dir, dirs=True)
    files2 = list(ff2)
    assert_in(opj(tests_dir, 'test_utils.py'), files2)
    assert_in(tests_dir, files2)

    # now actually matching the path
    ff3 = find_files('.*/test_.*\.py$', proj_dir, dirs=True)
    files3 = list(ff3)
    assert_in(opj(tests_dir, 'test_utils.py'), files3)
    assert_not_in(tests_dir, files3)
    for f in files3:
        ok_startswith(basename(f), 'test_') 
Example 6
Project: niceman   Author: ReproNim   File: utils.py    (license) View Source Project 6 votes vote down vote up
def skip_if_no_module(module):
    try:
        imp = __import__(module)
    except Exception as exc:
        raise SkipTest("Module %s fails to load: %s" % (module, exc_str(exc)))


# def create_tree_archive(path, name, load, overwrite=False, archives_leading_dir=True):
#     """Given an archive `name`, create under `path` with specified `load` tree
#     """
#     from ..support.archives import compress_files
#     dirname = file_basename(name)
#     full_dirname = opj(path, dirname)
#     os.makedirs(full_dirname)
#     create_tree(full_dirname, load, archives_leading_dir=archives_leading_dir)
#     # create archive
#     if archives_leading_dir:
#         compress_files([dirname], name, path=path, overwrite=overwrite)
#     else:
#         compress_files(list(map(basename, glob.glob(opj(full_dirname, '*')))),
#                        opj(pardir, name),
#                        path=opj(path, dirname),
#                        overwrite=overwrite)
#     # remove original tree
#     shutil.rmtree(full_dirname) 
Example 7
Project: android-project-combine   Author: Jacksgong   File: res_utils.py    (license) View Source Project 6 votes vote down vote up
def find_package_name_dir_up(parent_path):
    for file_name in listdir(parent_path):
        if isdir(file_name):
            continue

        if file_name == 'AndroidManifest.xml':
            for line in open(join(parent_path, file_name), 'r'):
                package_name_re_result = PACKAGE_NAME_RE.search(line)
                if package_name_re_result is not None:
                    return package_name_re_result.groups()[0]

        if file_name == 'build.gradle':
            for line in open(join(parent_path, file_name), 'r'):
                application_id_re_result = APPLICATION_ID_RE.search(line)
                if application_id_re_result is not None:
                    return application_id_re_result.groups()[0]

    return find_package_name_dir_up(abspath(join(parent_path, pardir))) 
Example 8
Project: Flask_Blog   Author: sugarguo   File: loaders.py    (GNU General Public License v3.0) View Source Project 5 votes vote down vote up
def split_template_path(template):
    """Split a path into segments and perform a sanity check.  If it detects
    '..' in the path it will raise a `TemplateNotFound` error.
    """
    pieces = []
    for piece in template.split('/'):
        if path.sep in piece \
           or (path.altsep and path.altsep in piece) or \
           piece == path.pardir:
            raise TemplateNotFound(template)
        elif piece and piece != '.':
            pieces.append(piece)
    return pieces 
Example 9
Project: swjtu-pyscraper   Author: Desgard   File: loaders.py    (MIT License) View Source Project 5 votes vote down vote up
def split_template_path(template):
    """Split a path into segments and perform a sanity check.  If it detects
    '..' in the path it will raise a `TemplateNotFound` error.
    """
    pieces = []
    for piece in template.split('/'):
        if path.sep in piece \
           or (path.altsep and path.altsep in piece) or \
           piece == path.pardir:
            raise TemplateNotFound(template)
        elif piece and piece != '.':
            pieces.append(piece)
    return pieces 
Example 10
Project: sublime-text-3-packages   Author: nickjj   File: loaders.py    (MIT License) View Source Project 5 votes vote down vote up
def split_template_path(template):
    """Split a path into segments and perform a sanity check.  If it detects
    '..' in the path it will raise a `TemplateNotFound` error.
    """
    pieces = []
    for piece in template.split('/'):
        if path.sep in piece \
           or (path.altsep and path.altsep in piece) or \
           piece == path.pardir:
            raise TemplateNotFound(template)
        elif piece and piece != '.':
            pieces.append(piece)
    return pieces 
Example 11
Project: zanph   Author: zanph   File: loaders.py    (license) View Source Project 5 votes vote down vote up
def split_template_path(template):
    """Split a path into segments and perform a sanity check.  If it detects
    '..' in the path it will raise a `TemplateNotFound` error.
    """
    pieces = []
    for piece in template.split('/'):
        if path.sep in piece \
           or (path.altsep and path.altsep in piece) or \
           piece == path.pardir:
            raise TemplateNotFound(template)
        elif piece and piece != '.':
            pieces.append(piece)
    return pieces 
Example 12
Project: zanph   Author: zanph   File: __init__.py    (license) View Source Project 5 votes vote down vote up
def get_includes():
    """Return a list of directories to include for linking against pyzmq with cython."""
    from os.path import join, dirname, abspath, pardir
    base = dirname(__file__)
    parent = abspath(join(base, pardir))
    return [ parent ] + [ join(parent, base, subdir) for subdir in ('utils',) ] 
Example 13
Project: Sci-Finder   Author: snverse   File: loaders.py    (license) View Source Project 5 votes vote down vote up
def split_template_path(template):
    """Split a path into segments and perform a sanity check.  If it detects
    '..' in the path it will raise a `TemplateNotFound` error.
    """
    pieces = []
    for piece in template.split('/'):
        if path.sep in piece \
           or (path.altsep and path.altsep in piece) or \
           piece == path.pardir:
            raise TemplateNotFound(template)
        elif piece and piece != '.':
            pieces.append(piece)
    return pieces 
Example 14
Project: Sci-Finder   Author: snverse   File: loaders.py    (license) View Source Project 5 votes vote down vote up
def split_template_path(template):
    """Split a path into segments and perform a sanity check.  If it detects
    '..' in the path it will raise a `TemplateNotFound` error.
    """
    pieces = []
    for piece in template.split('/'):
        if path.sep in piece \
           or (path.altsep and path.altsep in piece) or \
           piece == path.pardir:
            raise TemplateNotFound(template)
        elif piece and piece != '.':
            pieces.append(piece)
    return pieces 
Example 15
Project: Texty   Author: sarthfrey   File: loaders.py    (license) View Source Project 5 votes vote down vote up
def split_template_path(template):
    """Split a path into segments and perform a sanity check.  If it detects
    '..' in the path it will raise a `TemplateNotFound` error.
    """
    pieces = []
    for piece in template.split('/'):
        if path.sep in piece \
           or (path.altsep and path.altsep in piece) or \
           piece == path.pardir:
            raise TemplateNotFound(template)
        elif piece and piece != '.':
            pieces.append(piece)
    return pieces 
Example 16
Project: RPoint   Author: george17-meet   File: loaders.py    (license) View Source Project 5 votes vote down vote up
def split_template_path(template):
    """Split a path into segments and perform a sanity check.  If it detects
    '..' in the path it will raise a `TemplateNotFound` error.
    """
    pieces = []
    for piece in template.split('/'):
        if path.sep in piece \
           or (path.altsep and path.altsep in piece) or \
           piece == path.pardir:
            raise TemplateNotFound(template)
        elif piece and piece != '.':
            pieces.append(piece)
    return pieces 
Example 17
Project: isni-reconcile   Author: cmh2166   File: loaders.py    (license) View Source Project 5 votes vote down vote up
def split_template_path(template):
    """Split a path into segments and perform a sanity check.  If it detects
    '..' in the path it will raise a `TemplateNotFound` error.
    """
    pieces = []
    for piece in template.split('/'):
        if path.sep in piece \
           or (path.altsep and path.altsep in piece) or \
           piece == path.pardir:
            raise TemplateNotFound(template)
        elif piece and piece != '.':
            pieces.append(piece)
    return pieces 
Example 18
Project: flasky   Author: RoseOu   File: loaders.py    (license) View Source Project 5 votes vote down vote up
def split_template_path(template):
    """Split a path into segments and perform a sanity check.  If it detects
    '..' in the path it will raise a `TemplateNotFound` error.
    """
    pieces = []
    for piece in template.split('/'):
        if path.sep in piece \
           or (path.altsep and path.altsep in piece) or \
           piece == path.pardir:
            raise TemplateNotFound(template)
        elif piece and piece != '.':
            pieces.append(piece)
    return pieces 
Example 19
Project: macos-st-packages   Author: zce   File: loaders.py    (license) View Source Project 5 votes vote down vote up
def split_template_path(template):
    """Split a path into segments and perform a sanity check.  If it detects
    '..' in the path it will raise a `TemplateNotFound` error.
    """
    pieces = []
    for piece in template.split('/'):
        if path.sep in piece \
           or (path.altsep and path.altsep in piece) or \
           piece == path.pardir:
            raise TemplateNotFound(template)
        elif piece and piece != '.':
            pieces.append(piece)
    return pieces 
Example 20
Project: CPU-Manager-for-Kubernetes   Author: Intel-Corp   File: util.py    (license) View Source Project 5 votes vote down vote up
def cmk_root():
    return normpath(realpath(join(__file__, pardir, pardir))) 
Example 21
Project: calmjs   Author: calmjs   File: test_indexer.py    (license) View Source Project 5 votes vote down vote up
def test_module1_loader_es6(self):
        from calmjs.testing import module1
        calmjs_base_dir = abspath(join(
            indexer.modpath_pkg_resources(indexer)[0], pardir))
        results = {
            k: relpath(v, calmjs_base_dir)
            for k, v in indexer.mapper_es6(module1).items()
        }
        self.assertEqual(results, {
            'calmjs/testing/module1/hello':
                to_os_sep_path('calmjs/testing/module1/hello.js'),
        }) 
Example 22
Project: calmjs   Author: calmjs   File: test_indexer.py    (license) View Source Project 5 votes vote down vote up
def test_module1_loader_python(self):
        from calmjs.testing import module1
        calmjs_base_dir = abspath(join(
            indexer.modpath_pkg_resources(indexer)[0], pardir))
        results = {
            k: relpath(v, calmjs_base_dir)
            for k, v in indexer.mapper_python(module1).items()
        }
        self.assertEqual(results, {
            'calmjs.testing.module1.hello':
                to_os_sep_path('calmjs/testing/module1/hello.js'),
        }) 
Example 23
Project: calmjs   Author: calmjs   File: test_indexer.py    (license) View Source Project 5 votes vote down vote up
def test_module2_recursive_es6_legacy(self):
        # ensure legacy behavior is maintained, where a single argument
        # is accepted by the modpath function.

        def modpath_last(module):
            return indexer.modpath_last(module)

        from calmjs.testing import module2
        calmjs_base_dir = abspath(join(
            indexer.modpath_pkg_resources(indexer)[0], pardir))

        with pretty_logging(stream=StringIO()) as fd:
            with warnings.catch_warnings(record=True) as w:
                warnings.simplefilter('always')
                results = {
                    k: relpath(v, calmjs_base_dir)
                    for k, v in indexer.mapper(
                        module2, modpath=modpath_last,
                        globber='recursive',
                    ).items()
                }

            self.assertIn(
                "method will need to accept entry_point argument by calmjs-",
                str(w[-1].message)
            )

        self.assertIn(
            "method will need to accept entry_point argument by calmjs-",
            fd.getvalue()
        )

        self.assertEqual(results, {
            'calmjs/testing/module2/index':
                to_os_sep_path('calmjs/testing/module2/index.js'),
            'calmjs/testing/module2/helper':
                to_os_sep_path('calmjs/testing/module2/helper.js'),
            'calmjs/testing/module2/mod/helper':
                to_os_sep_path('calmjs/testing/module2/mod/helper.js'),
        }) 
Example 24
Project: oa_qian   Author: sunqb   File: loaders.py    (license) View Source Project 5 votes vote down vote up
def split_template_path(template):
    """Split a path into segments and perform a sanity check.  If it detects
    '..' in the path it will raise a `TemplateNotFound` error.
    """
    pieces = []
    for piece in template.split('/'):
        if path.sep in piece \
           or (path.altsep and path.altsep in piece) or \
           piece == path.pardir:
            raise TemplateNotFound(template)
        elif piece and piece != '.':
            pieces.append(piece)
    return pieces 
Example 25
Project: RealtimePythonChat   Author: quangtqag   File: loaders.py    (license) View Source Project 5 votes vote down vote up
def split_template_path(template):
    """Split a path into segments and perform a sanity check.  If it detects
    '..' in the path it will raise a `TemplateNotFound` error.
    """
    pieces = []
    for piece in template.split('/'):
        if path.sep in piece \
           or (path.altsep and path.altsep in piece) or \
           piece == path.pardir:
            raise TemplateNotFound(template)
        elif piece and piece != '.':
            pieces.append(piece)
    return pieces 
Example 26
Project: Indushell   Author: SecarmaLabs   File: loaders.py    (license) View Source Project 5 votes vote down vote up
def split_template_path(template):
    """Split a path into segments and perform a sanity check.  If it detects
    '..' in the path it will raise a `TemplateNotFound` error.
    """
    pieces = []
    for piece in template.split('/'):
        if path.sep in piece \
           or (path.altsep and path.altsep in piece) or \
           piece == path.pardir:
            raise TemplateNotFound(template)
        elif piece and piece != '.':
            pieces.append(piece)
    return pieces 
Example 27
Project: django-kaio   Author: APSL   File: options.py    (license) View Source Project 5 votes vote down vote up
def _conf_paths(self):
        paths = []
        current = abspath(".")
        while current != "/":
            paths.append(join(current, DEFAULT_CONF_NAME))
            current = abspath(join(current, pardir))
        return list(reversed(paths)) 
Example 28
Project: Liljimbo-Chatbot   Author: chrisjim316   File: loaders.py    (license) View Source Project 5 votes vote down vote up
def split_template_path(template):
    """Split a path into segments and perform a sanity check.  If it detects
    '..' in the path it will raise a `TemplateNotFound` error.
    """
    pieces = []
    for piece in template.split('/'):
        if path.sep in piece \
           or (path.altsep and path.altsep in piece) or \
           piece == path.pardir:
            raise TemplateNotFound(template)
        elif piece and piece != '.':
            pieces.append(piece)
    return pieces 
Example 29
Project: flask_system   Author: prashasy   File: loaders.py    (license) View Source Project 5 votes vote down vote up
def split_template_path(template):
    """Split a path into segments and perform a sanity check.  If it detects
    '..' in the path it will raise a `TemplateNotFound` error.
    """
    pieces = []
    for piece in template.split('/'):
        if path.sep in piece \
           or (path.altsep and path.altsep in piece) or \
           piece == path.pardir:
            raise TemplateNotFound(template)
        elif piece and piece != '.':
            pieces.append(piece)
    return pieces 
Example 30
Project: chihu   Author: yelongyu   File: loaders.py    (license) View Source Project 5 votes vote down vote up
def split_template_path(template):
    """Split a path into segments and perform a sanity check.  If it detects
    '..' in the path it will raise a `TemplateNotFound` error.
    """
    pieces = []
    for piece in template.split('/'):
        if path.sep in piece \
           or (path.altsep and path.altsep in piece) or \
           piece == path.pardir:
            raise TemplateNotFound(template)
        elif piece and piece != '.':
            pieces.append(piece)
    return pieces 
Example 31
Project: ShelbySearch   Author: Agentscreech   File: loaders.py    (license) View Source Project 5 votes vote down vote up
def split_template_path(template):
    """Split a path into segments and perform a sanity check.  If it detects
    '..' in the path it will raise a `TemplateNotFound` error.
    """
    pieces = []
    for piece in template.split('/'):
        if path.sep in piece \
           or (path.altsep and path.altsep in piece) or \
           piece == path.pardir:
            raise TemplateNotFound(template)
        elif piece and piece != '.':
            pieces.append(piece)
    return pieces 
Example 32
Project: trex-http-proxy   Author: alwye   File: __init__.py    (license) View Source Project 5 votes vote down vote up
def get_includes():
    """Return a list of directories to include for linking against pyzmq with cython."""
    from os.path import join, dirname, abspath, pardir
    base = dirname(__file__)
    parent = abspath(join(base, pardir))
    return [ parent ] + [ join(parent, base, subdir) for subdir in ('utils',) ] 
Example 33
Project: trex-http-proxy   Author: alwye   File: __init__.py    (license) View Source Project 5 votes vote down vote up
def get_includes():
    """Return a list of directories to include for linking against pyzmq with cython."""
    from os.path import join, dirname, abspath, pardir
    base = dirname(__file__)
    parent = abspath(join(base, pardir))
    return [ parent ] + [ join(parent, base, subdir) for subdir in ('utils',) ] 
Example 34
Project: trex-http-proxy   Author: alwye   File: __init__.py    (license) View Source Project 5 votes vote down vote up
def get_includes():
    """Return a list of directories to include for linking against pyzmq with cython."""
    from os.path import join, dirname, abspath, pardir
    base = dirname(__file__)
    parent = abspath(join(base, pardir))
    return [ parent ] + [ join(parent, base, subdir) for subdir in ('utils',) ] 
Example 35
Project: trex-http-proxy   Author: alwye   File: __init__.py    (license) View Source Project 5 votes vote down vote up
def get_includes():
    """Return a list of directories to include for linking against pyzmq with cython."""
    from os.path import join, dirname, abspath, pardir
    base = dirname(__file__)
    parent = abspath(join(base, pardir))
    return [ parent ] + [ join(parent, base, subdir) for subdir in ('utils',) ] 
Example 36
Project: trex-http-proxy   Author: alwye   File: __init__.py    (license) View Source Project 5 votes vote down vote up
def get_includes():
    """Return a list of directories to include for linking against pyzmq with cython."""
    from os.path import join, dirname, abspath, pardir
    base = dirname(__file__)
    parent = abspath(join(base, pardir))
    return [ parent ] + [ join(parent, base, subdir) for subdir in ('utils',) ] 
Example 37
Project: gcForest   Author: kingfengji   File: data_cache.py    (license) View Source Project 5 votes vote down vote up
def check_dir(path):
    """ make sure the dir specified by path got created """
    d = osp.abspath(osp.join(path, osp.pardir))
    if not osp.exists(d):
        os.makedirs(d) 
Example 38
Project: gcForest   Author: kingfengji   File: base_estimator.py    (license) View Source Project 5 votes vote down vote up
def check_dir(path):
    d = osp.abspath(osp.join(path, osp.pardir))
    if not osp.exists(d):
        os.makedirs(d) 
Example 39
Project: gcForest   Author: kingfengji   File: ds_pickle.py    (license) View Source Project 5 votes vote down vote up
def save_dataset(data_path, X, y):
    print('Data Saving in {} (X.shape={},y.shape={})'.format(
            data_path, X.shape, y.shape))
    data_dir = osp.abspath(osp.join(data_path, osp.pardir))
    if not osp.exists(data_dir):
        os.makedirs(data_dir)
    data = {'X': X, 'y': y}
    with open(data_path, 'wb') as f:
        pickle.dump(data, f, pickle.HIGHEST_PROTOCOL) 
Example 40
Project: gcForest   Author: kingfengji   File: ds_base.py    (license) View Source Project 5 votes vote down vote up
def get_dataset_base():
    return osp.abspath(osp.join(__file__, osp.pardir, osp.pardir, osp.pardir, osp.pardir, "datasets")) 
Example 41
Project: gcForest   Author: kingfengji   File: ds_base.py    (license) View Source Project 5 votes vote down vote up
def get_dataset_cache_base():
    return osp.abspath(osp.join(__file__, osp.pardir, osp.pardir, osp.pardir, osp.pardir, "datasets-cache")) 
Example 42
Project: gcForest   Author: kingfengji   File: cascade_classifier.py    (license) View Source Project 5 votes vote down vote up
def check_dir(path):
    d = osp.abspath(osp.join(path, osp.pardir))
    if not osp.exists(d):
        os.makedirs(d) 
Example 43
Project: calmjs.parse   Author: calmjs   File: test_utils.py    (license) View Source Project 5 votes vote down vote up
def test_find_common_same_base_parents_common(self):
        base = tempfile.mktemp()
        source = join(base, 'src', 'file.js')
        source_min = join(base, 'build', 'file.min.js')
        source_map = join(base, 'build', 'file.min.js.map')

        # mapping from source_map to source
        self.assertEqual([pardir, 'src', 'file.js'], utils.normrelpath(
            source_map, source).split(sep))
        # for pointing from source_map.source to the source_min
        self.assertEqual('file.min.js', utils.normrelpath(
            source_map, source_min)) 
Example 44
Project: calmjs.parse   Author: calmjs   File: test_utils.py    (license) View Source Project 5 votes vote down vote up
def test_find_double_parent(self):
        base = tempfile.mktemp()
        root = join(base, 'file.js')
        nested = join(base, 'src', 'dir', 'blahfile.js')

        self.assertEqual([pardir, pardir, 'file.js'], utils.normrelpath(
            nested, root).split(sep))
        self.assertEqual(['src', 'dir', 'blahfile.js'], utils.normrelpath(
            root, nested).split(sep)) 
Example 45
Project: calmjs.parse   Author: calmjs   File: test_utils.py    (license) View Source Project 5 votes vote down vote up
def test_find_same_prefix(self):
        base = tempfile.mktemp()
        src = join(base, 'basesrc', 'source.js')
        tgt = join(base, 'basetgt', 'target.js')
        self.assertEqual([pardir, 'basetgt', 'target.js'], utils.normrelpath(
            src, tgt).split(sep)) 
Example 46
Project: pyetje   Author: rorlika   File: loaders.py    (license) View Source Project 5 votes vote down vote up
def split_template_path(template):
    """Split a path into segments and perform a sanity check.  If it detects
    '..' in the path it will raise a `TemplateNotFound` error.
    """
    pieces = []
    for piece in template.split('/'):
        if path.sep in piece \
           or (path.altsep and path.altsep in piece) or \
           piece == path.pardir:
            raise TemplateNotFound(template)
        elif piece and piece != '.':
            pieces.append(piece)
    return pieces 
Example 47
Project: crc-diagram   Author: IuryAlves   File: testcase.py    (license) View Source Project 5 votes vote down vote up
def setUp(self):
        super(CrcTestCase, self).setUp()
        self.test_files = abspath(
            join(__file__, pardir, 'files')
        ) 
Example 48
Project: tellmeabout.coffee   Author: billyfung   File: loaders.py    (license) View Source Project 5 votes vote down vote up
def split_template_path(template):
    """Split a path into segments and perform a sanity check.  If it detects
    '..' in the path it will raise a `TemplateNotFound` error.
    """
    pieces = []
    for piece in template.split('/'):
        if path.sep in piece \
           or (path.altsep and path.altsep in piece) or \
           piece == path.pardir:
            raise TemplateNotFound(template)
        elif piece and piece != '.':
            pieces.append(piece)
    return pieces 
Example 49
Project: FileStoreGAE   Author: liantian-cn   File: loaders.py    (license) View Source Project 5 votes vote down vote up
def split_template_path(template):
    """Split a path into segments and perform a sanity check.  If it detects
    '..' in the path it will raise a `TemplateNotFound` error.
    """
    pieces = []
    for piece in template.split('/'):
        if path.sep in piece \
           or (path.altsep and path.altsep in piece) or \
           piece == path.pardir:
            raise TemplateNotFound(template)
        elif piece and piece != '.':
            pieces.append(piece)
    return pieces 
Example 50
Project: bawk   Author: jttwnsnd   File: loaders.py    (license) View Source Project 5 votes vote down vote up
def split_template_path(template):
    """Split a path into segments and perform a sanity check.  If it detects
    '..' in the path it will raise a `TemplateNotFound` error.
    """
    pieces = []
    for piece in template.split('/'):
        if path.sep in piece \
           or (path.altsep and path.altsep in piece) or \
           piece == path.pardir:
            raise TemplateNotFound(template)
        elif piece and piece != '.':
            pieces.append(piece)
    return pieces