[Checkins] SVN: lovely.recipe/trunk/ - Re-arranged the fs recipe
code to not check for directory existence during
Christian Theune
ct at gocept.com
Tue Jul 1 04:20:22 EDT 2008
Log message for revision 87870:
- Re-arranged the fs recipe code to not check for directory existence during
initialisation phase.
- Fixed some test issues.
Changed:
U lovely.recipe/trunk/CHANGES.txt
U lovely.recipe/trunk/src/lovely/recipe/fs/README.txt
U lovely.recipe/trunk/src/lovely/recipe/fs/mkdir.py
U lovely.recipe/trunk/src/lovely/recipe/fs/mkfile.py
-=-
Modified: lovely.recipe/trunk/CHANGES.txt
===================================================================
--- lovely.recipe/trunk/CHANGES.txt 2008-07-01 08:00:00 UTC (rev 87869)
+++ lovely.recipe/trunk/CHANGES.txt 2008-07-01 08:20:21 UTC (rev 87870)
@@ -6,12 +6,17 @@
=====
BIG TODO: add tests for lovely.recipe.zeo and lovely.recipe.zope to test and
- to show for what this all is for.
+ to show what this all is for.
+- Re-arranged the fs recipe code to not check for directory existence during
+ initialisation phase.
+
+- Fixed some test issues.
+
2008/04/24 0.3.1b4:
===================
-- fixed os error if a path already esists
+- fixed os error if a path already exists
2008/04/24 0.3.1b3:
===================
Modified: lovely.recipe/trunk/src/lovely/recipe/fs/README.txt
===================================================================
--- lovely.recipe/trunk/src/lovely/recipe/fs/README.txt 2008-07-01 08:00:00 UTC (rev 87869)
+++ lovely.recipe/trunk/src/lovely/recipe/fs/README.txt 2008-07-01 08:20:21 UTC (rev 87870)
@@ -16,6 +16,8 @@
... path = mystuff
... """)
>>> print system(buildout),
+ Getting distribution for 'ZODB3'.
+ Got ZODB3 3...
Installing data-dir.
data-dir: Creating directory mystuff
@@ -68,8 +70,12 @@
... path = with/subdir
... """)
>>> print system(buildout),
+ Uninstalling data-dir.
+ Installing data-dir.
data-dir: Cannot create /sample-buildout/with/subdir. /sample-buildout/with is not a directory.
- ...
+ While:
+ Installing data-dir.
+ Error: Invalid Path
But we need to activate this function explicitely.
@@ -85,8 +91,8 @@
... path = with/subdir
... """)
>>> print system(buildout),
- Uninstalling data-dir.
Installing data-dir.
+ data-dir: Creating parent directory /sample-buildout/with
data-dir: Creating directory with/subdir
>>> ls(sample_buildout)
Modified: lovely.recipe/trunk/src/lovely/recipe/fs/mkdir.py
===================================================================
--- lovely.recipe/trunk/src/lovely/recipe/fs/mkdir.py 2008-07-01 08:00:00 UTC (rev 87869)
+++ lovely.recipe/trunk/src/lovely/recipe/fs/mkdir.py 2008-07-01 08:20:21 UTC (rev 87870)
@@ -1,8 +1,10 @@
import os
import logging
+import zc.buildout
-class Mkdir:
+class Mkdir(object):
+
def __init__(self, buildout, name, options):
self.buildout = buildout
self.name = name
@@ -13,20 +15,25 @@
self.originalPath,
)
self.createPath = options.get('createpath', 'False').lower() in ['true', 'on', '1']
- if ( not self.createPath
- and not os.path.isdir(os.path.dirname(options['path']))
- ):
- logging.getLogger(self.name).error(
- 'Cannot create %s. %s is not a directory.',
- options['path'], os.path.dirname(options['path']))
- raise zc.buildout.UserError('Invalid Path')
def install(self):
path = self.options['path']
- if not os.path.isdir(path):
- logging.getLogger(self.name).info(
- 'Creating directory %s', self.originalPath)
- os.makedirs(path)
+ dirname = os.path.dirname(self.options['path'])
+
+ if not os.path.isdir(dirname):
+ if self.createPath:
+ logging.getLogger(self.name).info(
+ 'Creating parent directory %s', dirname)
+ os.makedirs(dirname)
+ else:
+ logging.getLogger(self.name).error(
+ 'Cannot create %s. %s is not a directory.',
+ path, dirname)
+ raise zc.buildout.UserError('Invalid Path')
+
+ logging.getLogger(self.name).info(
+ 'Creating directory %s', self.originalPath)
+ os.mkdir(path)
return ()
def update(self):
Modified: lovely.recipe/trunk/src/lovely/recipe/fs/mkfile.py
===================================================================
--- lovely.recipe/trunk/src/lovely/recipe/fs/mkfile.py 2008-07-01 08:00:00 UTC (rev 87869)
+++ lovely.recipe/trunk/src/lovely/recipe/fs/mkfile.py 2008-07-01 08:20:21 UTC (rev 87870)
@@ -1,8 +1,9 @@
import os
import logging
-class Mkfile:
+class Mkfile(object):
+
def __init__(self, buildout, name, options):
self.buildout = buildout
self.name = name
@@ -15,28 +16,26 @@
self.originalPath,
)
self.createPath = options.get('createpath', 'False').lower() in ['true', 'on', '1']
- if ( not self.createPath
- and not os.path.isdir(os.path.dirname(options['path']))
- ):
- logging.getLogger(self.name).error(
- 'Cannot create file %s. %s is not a directory.',
- options['path'], os.path.dirname(options['path']))
- raise zc.buildout.UserError('Invalid Path')
def install(self):
- path = self.options['path']
- if self.createPath:
- dirname = os.path.dirname(self.options['path'])
- if not os.path.isdir(dirname):
+ filename = self.options['path']
+ dirname = os.path.dirname(self.options['path'])
+
+ if not os.path.isdir(dirname):
+ if self.createPath:
logging.getLogger(self.name).info(
'Creating directory %s', dirname)
os.makedirs(dirname)
- f = file(path, 'w')
+ else:
+ logging.getLogger(self.name).error(
+ 'Cannot create file %s. %s is not a directory.',
+ filename, dirname)
+ raise zc.buildout.UserError('Invalid path')
+
+ f = file(filename, 'w')
logging.getLogger(self.name).info(
- 'Writing file %s', path)
+ 'Writing file %s', filename)
f.write(self.options['content'])
-
f.close()
- os.chmod(path, self.mode)
- return path
-
+ os.chmod(filename, self.mode)
+ return filename
More information about the Checkins
mailing list