1 # (Be in -*- python -*- mode.)
3 # ====================================================================
4 # Copyright (c) 2000-2008 CollabNet. All rights reserved.
6 # This software is licensed as described in the file COPYING, which
7 # you should have received as part of this distribution. The terms
8 # are also available at http://subversion.tigris.org/license-1.html.
9 # If newer versions of this license are posted there, you may use a
10 # newer version instead, at your option.
12 # This software consists of voluntary contributions made by many
13 # individuals. For exact contribution history, see the revision
14 # history and logs, available at http://cvs2svn.tigris.org/.
15 # ====================================================================
17 """This module defines Artifact types to be used with an ArtifactManager."""
22 from cvs2svn_lib
.context
import Ctx
23 from cvs2svn_lib
.log
import logger
26 class Artifact(object):
27 """An object that is created, used across passes, then cleaned up."""
30 # The set of passes that need this artifact. This field is
31 # maintained by ArtifactManager.
32 self
._passes
_needed
= set()
35 """This artifact is no longer needed; clean it up."""
40 class TempFile(Artifact
):
41 """A temporary file that can be used across cvs2svn passes."""
43 def __init__(self
, basename
):
44 Artifact
.__init
__(self
)
45 self
.basename
= basename
47 def _get_filename(self
):
48 return Ctx().get_temp_filename(self
.basename
)
50 filename
= property(_get_filename
)
53 logger
.verbose("Deleting", self
.filename
)
54 os
.unlink(self
.filename
)
57 return 'Temporary file %r' % (self
.filename
,)