Creates a symlink at target *file* pointing to source.

    :arg isfile: when True, if symlinking is disabled in the global config, the file
      is copied instead with fortpy.utility.copyfile; otherwise fortpy.utility.copy
      is used and the target is considered a directory.

def symlink(source, target, isfile=True):
    """Creates a symlink at target *file* pointing to source.

    :arg isfile: when True, if symlinking is disabled in the global config, the file
      is copied instead with fortpy.utility.copyfile; otherwise fortpy.utility.copy
      is used and the target is considered a directory.
    """
    from fortpy.code import config
    from os import path
    if config.symlink:
        from os import symlink, remove
        if path.isfile(target) or path.islink(target):
            remove(target)
        elif path.isdir(target):
            msg.warn("Cannot auto-delete directory '{}' for symlinking.".format(target))
            return
        symlink(source, target)
    else:
        msg.info("   COPY: {}".format(source))
        if isfile:
            copyfile(source, target)
        else:
            copy(source, target)