Python os.path 模块,pardir() 实例源码

我们从Python开源项目中,提取了以下50个代码示例,用于说明如何使用os.path.pardir()

项目:calmjs    作者:calmjs    | 项目源码 | 文件源码
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)
项目:calmjs    作者:calmjs    | 项目源码 | 文件源码
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'),
        })
项目:calmjs    作者:calmjs    | 项目源码 | 文件源码
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'),
        })
项目:gcforest    作者:w821881341    | 项目源码 | 文件源码
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
项目:niceman    作者:ReproNim    | 项目源码 | 文件源码
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_')
项目:niceman    作者:ReproNim    | 项目源码 | 文件源码
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)
项目:android-project-combine    作者:Jacksgong    | 项目源码 | 文件源码
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)))
项目:Flask_Blog    作者:sugarguo    | 项目源码 | 文件源码
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
项目:swjtu-pyscraper    作者:Desgard    | 项目源码 | 文件源码
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
项目:sublime-text-3-packages    作者:nickjj    | 项目源码 | 文件源码
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
项目:zanph    作者:zanph    | 项目源码 | 文件源码
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
项目:zanph    作者:zanph    | 项目源码 | 文件源码
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',) ]
项目:Sci-Finder    作者:snverse    | 项目源码 | 文件源码
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
项目:Sci-Finder    作者:snverse    | 项目源码 | 文件源码
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
项目:Texty    作者:sarthfrey    | 项目源码 | 文件源码
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
项目:RPoint    作者:george17-meet    | 项目源码 | 文件源码
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
项目:isni-reconcile    作者:cmh2166    | 项目源码 | 文件源码
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
项目:flasky    作者:RoseOu    | 项目源码 | 文件源码
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
项目:macos-st-packages    作者:zce    | 项目源码 | 文件源码
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
项目:CPU-Manager-for-Kubernetes    作者:Intel-Corp    | 项目源码 | 文件源码
def cmk_root():
    return normpath(realpath(join(__file__, pardir, pardir)))
项目:calmjs    作者:calmjs    | 项目源码 | 文件源码
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'),
        })
项目:calmjs    作者:calmjs    | 项目源码 | 文件源码
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'),
        })
项目:calmjs    作者:calmjs    | 项目源码 | 文件源码
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'),
        })
项目:oa_qian    作者:sunqb    | 项目源码 | 文件源码
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
项目:RealtimePythonChat    作者:quangtqag    | 项目源码 | 文件源码
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
项目:Indushell    作者:SecarmaLabs    | 项目源码 | 文件源码
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
项目:django-kaio    作者:APSL    | 项目源码 | 文件源码
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))
项目:Liljimbo-Chatbot    作者:chrisjim316    | 项目源码 | 文件源码
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
项目:flask_system    作者:prashasy    | 项目源码 | 文件源码
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
项目:chihu    作者:yelongyu    | 项目源码 | 文件源码
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
项目:ShelbySearch    作者:Agentscreech    | 项目源码 | 文件源码
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
项目:trex-http-proxy    作者:alwye    | 项目源码 | 文件源码
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',) ]
项目:trex-http-proxy    作者:alwye    | 项目源码 | 文件源码
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',) ]
项目:trex-http-proxy    作者:alwye    | 项目源码 | 文件源码
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',) ]
项目:trex-http-proxy    作者:alwye    | 项目源码 | 文件源码
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',) ]
项目:trex-http-proxy    作者:alwye    | 项目源码 | 文件源码
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',) ]
项目:gcForest    作者:kingfengji    | 项目源码 | 文件源码
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)
项目:gcForest    作者:kingfengji    | 项目源码 | 文件源码
def check_dir(path):
    d = osp.abspath(osp.join(path, osp.pardir))
    if not osp.exists(d):
        os.makedirs(d)
项目:gcForest    作者:kingfengji    | 项目源码 | 文件源码
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)
项目:gcForest    作者:kingfengji    | 项目源码 | 文件源码
def get_dataset_base():
    return osp.abspath(osp.join(__file__, osp.pardir, osp.pardir, osp.pardir, osp.pardir, "datasets"))
项目:gcForest    作者:kingfengji    | 项目源码 | 文件源码
def get_dataset_cache_base():
    return osp.abspath(osp.join(__file__, osp.pardir, osp.pardir, osp.pardir, osp.pardir, "datasets-cache"))
项目:gcForest    作者:kingfengji    | 项目源码 | 文件源码
def check_dir(path):
    d = osp.abspath(osp.join(path, osp.pardir))
    if not osp.exists(d):
        os.makedirs(d)
项目:calmjs.parse    作者:calmjs    | 项目源码 | 文件源码
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))
项目:calmjs.parse    作者:calmjs    | 项目源码 | 文件源码
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))
项目:calmjs.parse    作者:calmjs    | 项目源码 | 文件源码
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))
项目:pyetje    作者:rorlika    | 项目源码 | 文件源码
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
项目:crc-diagram    作者:IuryAlves    | 项目源码 | 文件源码
def setUp(self):
        super(CrcTestCase, self).setUp()
        self.test_files = abspath(
            join(__file__, pardir, 'files')
        )
项目:tellmeabout.coffee    作者:billyfung    | 项目源码 | 文件源码
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
项目:FileStoreGAE    作者:liantian-cn    | 项目源码 | 文件源码
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
项目:bawk    作者:jttwnsnd    | 项目源码 | 文件源码
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