def write_to_file(filename, content):
    """
    Writes content to the given file. The file's directory will be created if needed.
      :param filename: name of the output file, relative to the "destination folder" provided by the user
      :param content: iterable (line-by-line) that should be written to the file. Either a list or a generator. Each
                      line will be appended with a "\n". Lines containing None will be skipped.
    """
    if not config["destdir"]:
        print("{destdir} config variable not present. Did you forget to run init()?")
        sys.exit(8)
    abs_filename = os.path.abspath(config["destdir"] + "/" + filename)
    abs_filepath = os.path.dirname(abs_filename)
    if not os.path.exists(abs_filepath):
        try:
            os.makedirs(abs_filepath)
        except OSError as e:
            print("Cannot create directory " + abs_filepath)
            print("Error %d: %s" % (e.errno, e.strerror))
            sys.exit(6)
    with codecs.open(abs_filename, "w", "utf-8") as out:
        if isinstance(content, str): content = [content]
        for line in content:
            if line is not None:
                out.write(line)
                out.write("\n")
def write_to_file(filename, content):
    """
    Writes content to the given file. The file's directory will be created if needed.
      :param filename: name of the output file, relative to the "destination folder" provided by the user
      :param content: iterable (line-by-line) that should be written to the file. Either a list or a generator. Each
                      line will be appended with a "\n". Lines containing None will be skipped.
    """
    if not config["destdir"]:
        print("{destdir} config variable not present. Did you forget to run init()?")
        sys.exit(8)
    abs_filename = os.path.abspath(config["destdir"] + "/" + filename)
    abs_filepath = os.path.dirname(abs_filename)
    if not os.path.exists(abs_filepath):
        try:
            os.makedirs(abs_filepath)
        except OSError as e:
            print("Cannot create directory " + abs_filepath)
            print("Error %d: %s" % (e.errno, e.strerror))
            sys.exit(6)
    with codecs.open(abs_filename, "w", "utf-8") as out:
        if isinstance(content, str): content = [content]
        for line in content:
            if line is not None:
                out.write(line)
                out.write("\n")
def write_to_file ( filename , content ) : if not config [ "destdir" ] : print ( "{destdir} config variable not present. Did you forget to run init()?" ) sys . exit ( 8 ) abs_filename = os . path . abspath ( config [ "destdir" ] + "/" + filename ) abs_filepath = os . path . dirname ( abs_filename ) if not os . path . exists ( abs_filepath ) : try : os . makedirs ( abs_filepath ) except OSError as e : print ( "Cannot create directory " + abs_filepath ) print ( "Error %d: %s" % ( e . errno , e . strerror ) ) sys . exit ( 6 ) with codecs . open ( abs_filename , "w" , "utf-8" ) as out : if isinstance ( content , str ) : content = [ content ] for line in content : if line is not None : out . write ( line ) out . write ( "\n" )
Writes content to the given file. The file's directory will be created if needed.
      :param filename: name of the output file, relative to the "destination folder" provided by the user
      :param content: iterable (line-by-line) that should be written to the file. Either a list or a generator. Each
                      line will be appended with a "\n". Lines containing None will be skipped.
Writes content to the given file . The file s directory will be created if needed . : param filename : name of the output file relative to the destination folder provided by the user : param content : iterable ( line - by - line ) that should be written to the file . Either a list or a generator . Each line will be appended with a \ n . Lines containing None will be skipped .