Beispiel #1
0
def concatenate(task_name, out_path, files, comment_fmt="# %s\n"):
    # expand globs
    files = [f for glb in files for f in sorted(glob.iglob(glb))]

    # overwrite check
    signature = comment_fmt % "This file was generated by dotfiler; do not edit"
    try:
        with open(out_path) as f:
            content = f.read().decode("utf8")
        if signature not in content:
            log.warn(
                "%s: '%s' already exists and doesn't contain a banner; not overwriting"
                % (task_name, out_path))
            return
    except:
        pass

    sep = comment_fmt % ("-" * 30)

    # make file
    chunks = [signature]

    for file in files:
        chunks.append(sep)
        chunks.append(comment_fmt % file)
        chunks.append(sep)
        with open(file) as f:
            chunks.append(f.read())

    # write
    with open(out_path, 'w') as f:
        f.write(''.join(chunks))
    log.success(task_name + ": generated: " + out_path)
Beispiel #2
0
def concatenate(task_name, out_path, files, comment_fmt="# %s\n"):
    # expand globs
    files = [f
        for glb in files
        for f in sorted(glob.iglob(glb))]

    # overwrite check
    signature = comment_fmt % "This file was generated by dotfiler; do not edit"
    try:
        with open(out_path) as f:
            content = f.read().decode("utf8")
        if signature not in content:
            log.warn("%s: '%s' already exists and doesn't contain a banner; not overwriting" %
                (task_name, out_path))
            return
    except:
        pass

    sep = comment_fmt % ("-" * 30)

    # make file
    chunks = [signature]

    for file in files:
        chunks.append(sep)
        chunks.append(comment_fmt % file)
        chunks.append(sep)
        with open(file) as f:
            chunks.append(f.read())

    # write
    with open(out_path, 'w') as f:
        f.write(''.join(chunks))
    log.success(task_name + ": generated: " + out_path)
Beispiel #3
0
 def finalize(self):
     if not self.exists:
         log.warn(str(self) + ": The component was not found.")
         msgs = self.messages
         if len(msgs) > 0:
             log.notice("  Log messages:")
             for msg in msgs:
                 log.notice("    " + msg)
Beispiel #4
0
 def finalize(self):
     if not self.exists:
         log.warn(str(self) + ": The component was not found.")
         msgs = self.messages
         if len(msgs) > 0:
             log.notice("  Log messages:")
             for msg in msgs:
                 log.notice("    " + msg)