MCPcopy Create free account
hub / github.com/ActiveState/code / makepath

Function makepath

recipes/Python/117243_helpful_5liner/recipe-117243.py:3–23  ·  view source on GitHub ↗

creates missing directories for the given path and returns a normalized absolute version of the path. - if the given path already exists in the filesystem the filesystem is not modified. - otherwise makepath creates directories along the given path using the dirname()

(path)

Source from the content-addressed store, hash-verified

1#!/usr/bin/env python
2
3def makepath(path):
4
5 """ creates missing directories for the given path and
6 returns a normalized absolute version of the path.
7
8 - if the given path already exists in the filesystem
9 the filesystem is not modified.
10
11 - otherwise makepath creates directories along the given path
12 using the dirname() of the path. You may append
13 a '/' to the path if you want it to be a directory path.
14
15 from holger@trillke.net 2002/03/18
16 """
17
18 from os import makedirs
19 from os.path import normpath,dirname,exists,abspath
20
21 dpath = normpath(dirname(path))
22 if not exists(dpath): makedirs(dpath)
23 return normpath(abspath(path))
24
25#
26#

Callers 1

recipe-117243.pyFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected