X-Git-Url: https://git.decadent.org.uk/gitweb/?a=blobdiff_plain;f=daklib%2Ffstransactions.py;h=eb4874a1083ef083781270480165a77dfb1e975a;hb=391f5ec09a119131dc846b796ca791f4cecc69e4;hp=468e2859b2d5ee804714b002734c981ab1a0ff23;hpb=c5501640d444217e7cdbb5e42e31166cd1fe2db6;p=dak.git diff --git a/daklib/fstransactions.py b/daklib/fstransactions.py index 468e2859..eb4874a1 100644 --- a/daklib/fstransactions.py +++ b/daklib/fstransactions.py @@ -122,53 +122,66 @@ class FilesystemTransaction(object): def __init__(self): self.actions = [] - def copy(self, source, destination, link=True, symlink=False, mode=None): - """copy `source` to `destination` + def copy(self, source, destination, link=False, symlink=False, mode=None): + """copy C{source} to C{destination} - Args: - source (str): source file - destination (str): destination file + @type source: str + @param source: source file - Kwargs: - link (bool): Try hardlinking, falling back to copying. - symlink (bool): Create a symlink instead - mode (int): Permissions to change `destination` to. + @type destination: str + @param destination: destination file + + @type link: bool + @param link: try hardlinking, falling back to copying + + @type symlink: bool + @param symlink: create a symlink instead of copying + + @type mode: int + @param mode: permissions to change C{destination} to """ + if isinstance(mode, str) or isinstance(mode, unicode): + mode = int(mode, 8) + self.actions.append(_FilesystemCopyAction(source, destination, link=link, symlink=symlink, mode=mode)) def move(self, source, destination, mode=None): - """move `source` to `destination` + """move C{source} to C{destination} + + @type source: str + @param source: source file - Args: - source (str): source file - destination (str): destination file + @type destination: str + @param destination: destination file - Kwargs: - mode (int): Permissions to change `destination` to. + @type mode: int + @param mode: permissions to change C{destination} to """ self.copy(source, destination, link=True, mode=mode) self.unlink(source) def unlink(self, path): - """unlink `path` + """unlink C{path} - Args: - path (str): file to unlink + @type path: str + @param path: file to unlink """ self.actions.append(_FilesystemUnlinkAction(path)) def create(self, path, mode=None): - """create `filename` and return file handle + """create C{filename} and return file handle - Args: - filename (str): file to create + @type filename: str + @param filename: file to create - Kwargs: - mode (int): Permissions for the new file + @type mode: int + @param mode: permissions for the new file - Returns: - file handle of the new file + @return: file handle of the new file """ + if isinstance(mode, str) or isinstance(mode, unicode): + mode = int(mode, 8) + destdir = os.path.dirname(path) if not os.path.exists(destdir): os.makedirs(destdir, 0o2775)