Пример #1
0
 def copy(self, src, dest):
     '''
     copy SRC DEST
       Copy SRC to DEST.
       If DEST is a directory, SRC will be copied inside it.
       If DEST doesn't exist, SRC will be copied to a file with
       that name, if the path leading to it exists.
     '''
     cpfile(self._out(src), self._out(dest))
Пример #2
0
 def copy(self, src, dest):
     '''
     copy SRC DEST
       Copy SRC to DEST.
       If DEST is a directory, SRC will be copied inside it.
       If DEST doesn't exist, SRC will be copied to a file with
       that name, if the path leading to it exists.
     '''
     cpfile(self._out(src), self._out(dest))
Пример #3
0
 def copy(self, src, dest):
     '''
     copy SRC DEST
       Copy SRC to DEST.
       If DEST is a directory, SRC will be copied inside it.
       If DEST doesn't exist, SRC will be copied to a file with
       that name, if the path leading to it exists.
     '''
     try:
         cpfile(self._out(src), self._out(dest))
     except shutil.Error as e:
         logger.error(e)
Пример #4
0
 def copy(self, src, dest):
     '''
     copy SRC DEST
       Copy SRC to DEST.
       If DEST is a directory, SRC will be copied inside it.
       If DEST doesn't exist, SRC will be copied to a file with
       that name, if the path leading to it exists.
     '''
     try:
         cpfile(self._out(src), self._out(dest))
     except shutil.Error as e:
         logger.error(e)
Пример #5
0
def do_grafts(grafts, dest, preserve=True):
    '''Copy each of the items listed in grafts into dest.
    If the key ends with '/' it's assumed to be a directory which should be
    created, otherwise just the leading directories will be created.'''
    for imgpath, filename in grafts.items():
        if imgpath[-1] == '/':
            targetdir = join(dest, imgpath)
            imgpath = imgpath[:-1]
        else:
            targetdir = join(dest, dirname(imgpath))
        if not os.path.isdir(targetdir):
            os.makedirs(targetdir)
        if os.path.isdir(filename):
            copytree(filename, join(dest, imgpath), preserve)
        else:
            cpfile(filename, join(dest, imgpath))
Пример #6
0
 def install(self, srcglob, dest):
     '''
     install SRC DEST
       Copy the given file (or files, if a glob is used) from the input
       tree to the given destination in the output tree.
       The path to DEST must exist in the output tree.
       If DEST is a directory, SRC will be copied into that directory.
       If DEST doesn't exist, SRC will be copied to a file with that name,
       assuming the rest of the path exists.
       This is pretty much like how the 'cp' command works.
       Examples:
         install usr/share/myconfig/grub.conf /boot
         install /usr/share/myconfig/grub.conf.in /boot/grub.conf
     '''
     for src in rglob(self._in(srcglob), fatal=True):
         cpfile(src, self._out(dest))
Пример #7
0
def do_grafts(grafts, dest, preserve=True):
    '''Copy each of the items listed in grafts into dest.
    If the key ends with '/' it's assumed to be a directory which should be
    created, otherwise just the leading directories will be created.'''
    for imgpath, filename in grafts.items():
        if imgpath[-1] == '/':
            targetdir = join(dest, imgpath)
            imgpath = imgpath[:-1]
        else:
            targetdir = join(dest, dirname(imgpath))
        if not os.path.isdir(targetdir):
            os.makedirs(targetdir)
        if os.path.isdir(filename):
            copytree(filename, join(dest, imgpath), preserve)
        else:
            cpfile(filename, join(dest, imgpath))
Пример #8
0
 def install(self, srcglob, dest):
     '''
     install SRC DEST
       Copy the given file (or files, if a glob is used) from the input
       tree to the given destination in the output tree.
       The path to DEST must exist in the output tree.
       If DEST is a directory, SRC will be copied into that directory.
       If DEST doesn't exist, SRC will be copied to a file with that name,
       assuming the rest of the path exists.
       This is pretty much like how the 'cp' command works.
       Examples:
         install usr/share/myconfig/grub.conf /boot
         install /usr/share/myconfig/grub.conf.in /boot/grub.conf
     '''
     for src in rglob(self._in(srcglob), fatal=True):
         cpfile(src, self._out(dest))