~pkgme-committers/pkgme/trunk

« back to all changes in this revision

Viewing changes to pkgme/write.py

  • Committer: Jonathan Lange
  • Date: 2011-07-29 16:42:33 UTC
  • mfrom: (70.1.13 debug-logging)
  • Revision ID: jml@canonical.com-20110729164233-sokxhclqz8fjjk3k
Debug log system and many debug statements.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
import os
2
2
 
3
3
 
4
 
def write_file(path, content):
 
4
def ensure_containing_directory_exists(path):
5
5
    dirname, basename = os.path.split(path)
6
6
    if dirname != '' and not os.path.exists(dirname):
7
7
        os.makedirs(dirname)
 
8
 
 
9
 
 
10
def touch(path):
 
11
    ensure_containing_directory_exists(path)
 
12
    with open(path, 'a'):
 
13
        pass
 
14
 
 
15
 
 
16
def write_file(path, content):
 
17
    ensure_containing_directory_exists(path)
8
18
    with open(path, "w") as f:
9
19
        f.write(content)
10
20