def dump_package_data(data, buf, format_=FileFormat.py, skip_attributes=None):
if format_ == FileFormat.txt:<EOL><INDENT>raise ValueError("<STR_LIT>")<EOL><DEDENT>data_ = dict((k, v) for k, v in data.iteritems() if v is not None)<EOL>data_ = package_serialise_schema.validate(data_)<EOL>skip = set(skip_attributes or [])<EOL>items = []<EOL>for key in package_key_order:<EOL><INDENT>if key not in skip:<EOL><INDENT>value = data_.pop(key, None)<EOL>if value is not None:<EOL><INDENT>items.append((key, value))<EOL><DEDENT><DEDENT><DEDENT>for key, value in data_.iteritems():<EOL><INDENT>if key not in skip:<EOL><INDENT>items.append((key, value))<EOL><DEDENT><DEDENT>dump_func = dump_functions[format_]<EOL>dump_func(items, buf)<EOL>
Write package data to `buf`.

    Args:
        data (dict): Data source - must conform to `package_serialise_schema`.
        buf (file-like object): Destination stream.
        format_ (`FileFormat`): Format to dump data in.
        skip_attributes (list of str): List of attributes to not print.