Encode and write a single document.
514854
def write_document(self, document: BioCDocument):
        """"""
        tree = self.encoder.encode(document)
        self.__writer.send(tree)
425935
def copy_document(destination, identifier, pointer):
    """"""
    record = Record.get_record(identifier)
    click.echo(json.dumps(
        Document(record, pointer).copy(destination)
    ))
120935
def _write(self, content, mode, encoding=None, linesep=False):
        """"""
        makedirs(self.path)
        try:
            encoding = encoding or ENCODING
            if "b" not in mode:
                try:
                    content = str(content)
                except:
                    pass
                if linesep:
                    content += os.linesep
            with codecs.open(self.path, mode, encoding=encoding) as fo:
                fo.write(content)
                return True
        except:
            return False
1049387
def write(self, *text, sep=' '):
        
        self.text += markdown.text(*text, sep)
        return self
588369
def simple_write(filename, group, times, features,
                 properties=None, item='item', mode='a'):
    """"""
    write(filename, group, [item], [times], [features], mode=mode,
          properties=[properties] if properties is not None else None)
411678
def write_single_file(args, base_dir, crawler):
    """"""
    if args['urls'] and args['html']:
        # Create a directory to save PART.html files in
        domain = utils.get_domain(args['urls'][0])
        if not args['quiet']:
            print('Storing html files in {0}/'.format(domain))
        utils.mkdir_and_cd(domain)

    infilenames = []
    for query in args['query']:
        if query in args['files']:
            infilenames.append(query)
        elif query.strip('/') in args['urls']:
            if args['crawl'] or args['crawl_all']:
                # Crawl and save HTML files/image files to disk
                infilenames += crawler.crawl_links(query)
            else:
                raw_resp = utils.get_raw_resp(query)
                if raw_resp is None:
                    return False

                prev_part_num = utils.get_num_part_files()
                utils.write_part_file(args, query, raw_resp)
                curr_part_num = prev_part_num + 1
                infilenames += utils.get_part_filenames(curr_part_num, prev_part_num)

    # Convert output or leave as PART.html files
    if args['html']:
        # HTML files have been written already, so return to base directory
        os.chdir(base_dir)
    else:
        # Write files to text or pdf
        if infilenames:
            if args['out']:
                outfilename = args['out'][0]
            else:
                outfilename = utils.get_single_outfilename(args)
            if outfilename:
                write_files(args, infilenames, outfilename)
        else:
            utils.remove_part_files()
    return True
527553
def encode_document(document):
    """"""
    tree = etree.Element('document')
    etree.SubElement(tree, 'id').text = document.id
    encode_infons(tree, document.infons)
    for passage in document.passages:
        tree.append(encode_passage(passage))
    for ann in document.annotations:
        tree.append(encode_annotation(ann))
    for rel in document.relations:
        tree.append(encode_relation(rel))
    return tree
641276
function encodeArticle(pages, article) {
    var articlePath = article.getPath();

    return {
        path: articlePath,
        title: article.getTitle(),
        level: article.getLevel(),
        exists: (articlePath && pages.has(articlePath)),
        external: article.isExternal()
    };
}
1086583
def create_simple_writer(outputDef, defaultOutput, outputFormat, fieldNames,
                         compress=True, valueClassMappings=None,
                         datasetMetaProps=None, fieldMetaProps=None):
    """"""

    if not outputDef:
        outputBase = defaultOutput
    else:
        outputBase = outputDef

    if outputFormat == 'json':
        write_squonk_datasetmetadata(outputBase, True, valueClassMappings,
                                     datasetMetaProps, fieldMetaProps)
        return BasicObjectWriter(open_output(outputDef, 'data', compress)), outputBase

    elif outputFormat == 'tsv':
        return TsvWriter(open_output(outputDef, 'tsv', compress), fieldNames), outputBase

    else:
        raise ValueError("Unsupported format: " + outputFormat)
1098921
def write(file_name, data):
    """"""
    with open(file_name, 'w') as f:
        f.write(encode(data))
70818
def single_encode(input, errors='strict'):
    
    if not isinstance(input, text_type):
        input = text_type(input, sys.getdefaultencoding(), errors)
    length = len(input)
    input = unicodedata.normalize('NFKC', input)
    return input.translate(single_table), length
696110
def encode(self, V, P, X, CC, seqNum, M, PT, SSRC, payload):
        """"""
        timestamp = int(time())
        header = bytearray(HEADER_SIZE)
        # Fill the header bytearray with RTP header fields
        # ...
        header[0] = header[0] | V << 6; 
        header[0] = header[0] | P << 5; 
        header[0] = header[0] | X << 4; 
        header[0] = header[0] | CC; 
        header[1] = header[1] | M << 7; 
        header[1] = header[1] | PT; 
        header[2] = (seqNum >> 8) & 0xFF; 
        header[3] = seqNum & 0xFF; 
        header[4] = (timestamp >> 24) & 0xFF; 
        header[5] = (timestamp >> 16) & 0xFF;
        header[6] = (timestamp >> 8) & 0xFF;
        header[7] = timestamp & 0xFF;
        header[8] = (SSRC >> 24) & 0xFF; 
        header[9] = (SSRC >> 16) & 0xFF;
        header[10] = (SSRC >> 8) & 0xFF;
        header[11] = SSRC & 0xFF

        self.header = header
        
        # Get the payload
        # ...
        self.payload = payload
954127
def write_to(output, txt):
    """"""
    if (isinstance(txt, six.binary_type) or six.PY3 and isinstance(output, StringIO)) or isinstance(output, TextIOWrapper):
        output.write(txt)
    else:
        output.write(txt.encode("utf-8", "replace"))
1266130
void writeDocument(OutputStream outStream, Document doc) {
        DOMImplementationRegistry domRegistry = null;
        try {
            domRegistry = DOMImplementationRegistry.newInstance();
        // Fortify Mod: Broaden try block to capture all potential exceptions
        // } catch (Exception e) {
        //    LOGR.warning(e.getMessage());
        // }
        DOMImplementationLS impl = (DOMImplementationLS) domRegistry
                .getDOMImplementation("LS");
        LSSerializer writer = impl.createLSSerializer();
        writer.getDomConfig().setParameter("xml-declaration", false);
        writer.getDomConfig().setParameter("format-pretty-print", true);
        LSOutput output = impl.createLSOutput();
        output.setEncoding("UTF-8");
        output.setByteStream(outStream);
        writer.write(doc, output);
        } catch (Exception e) {
            LOGR.warning(e.getMessage());
        }
    }
324612
def _write_recordio(f, data):
    """"""
    length = len(data)
    f.write(struct.pack('I', _kmagic))
    f.write(struct.pack('I', length))
    pad = (((length + 3) >> 2) << 2) - length
    f.write(data)
    f.write(padding[pad])
915654
def write(self, data):
        """"""
        cnpj, data = data

        path = os.path.join(self.output, '%s.json' % cnpj)
        with open(path, 'w') as f:
            json.dump(data, f, encoding='utf-8')
480374
public void write( Document document ) {
        assert document != null;
        ++count;
        ++totalCount;
        if (count > maxDocumentsPerFile) {
            // Close the stream (we'll open a new one later in the method) ...
            close();
            count = 1;
        }
        try {
            if (stream == null) {
                // Open the stream to the next file ...
                ++fileCount;
                String suffix = StringUtil.justifyRight(Long.toString(fileCount), BackupService.NUM_CHARS_IN_FILENAME_SUFFIX, '0');
                String filename = filenamePrefix + "_" + suffix + DOCUMENTS_EXTENSION;
                if (compress) filename = filename + GZIP_EXTENSION;
                currentFile = new File(parentDirectory, filename);
                OutputStream fileStream = new FileOutputStream(currentFile);
                if (compress) fileStream = new GZIPOutputStream(fileStream);
                stream = new BufferedOutputStream(fileStream);
            }
            Json.write(document, stream);
            // Need to append a non-consumable character so that we can read multiple JSON documents per file
            stream.write((byte)'\n');
        } catch (IOException e) {
            problems.addError(JcrI18n.problemsWritingDocumentToBackup, currentFile.getAbsolutePath(), e.getMessage());
        }
    }