Worker method for writing meta info
500715
def write_meta_info(self, byte1, byte2, data):
        ""
        write_varlen(self.data, 0)  # tick
        write_byte(self.data, byte1)
        write_byte(self.data, byte2)
        write_varlen(self.data, len(data))
        write_chars(self.data, data)
992462
def write(chunk)
      body = ''
      chunk.msgpack_each {|(tag,time,record)|

        # define index and sourcetype dynamically
        begin
          index = expand_param(@index, tag, time, record)
          sourcetype = expand_param(@sourcetype, tag, time, record)
          event_host = expand_param(@event_host, tag, time, record)
          token = expand_param(@token, tag, time, record)
        rescue => e
          # handle dynamic parameters misconfigurations
          router.emit_error_event(tag, time, record, e)
          next
        end
        log.debug "routing event from #{event_host} to #{index} index"
        log.debug "expanded token #{token}"

        # Parse record to Splunk event format
        case record
        when Integer
          event = record.to_s
        when Hash
          if @send_event_as_json
            event = record.to_json
          else
            event = record.to_json.gsub("\"", %q(\\\"))
          end
        else
          event = record
        end

        sourcetype = @sourcetype == 'tag' ? tag : @sourcetype

        # Build body for the POST request
        if !@usejson
          event = record["time"]+ " " + record["message"].to_json.gsub(/^"|"$/,"")
          body << '{"time":"'+ DateTime.parse(record["time"]).strftime("%Q") +'", "event":"' + event + '", "sourcetype" :"' + sourcetype + '", "source" :"' + @source + '", "index" :"' + index + '", "host" : "' + event_host + '"}'
        elsif @send_event_as_json
          body << '{"time" :' + time.to_s + ', "event" :' + event + ', "sourcetype" :"' + sourcetype + '", "source" :"' + source + '", "index" :"' + index + '", "host" : "' + event_host + '"}'
        else
          body << '{"time" :' + time.to_s + ', "event" :"' + event + '", "sourcetype" :"' + sourcetype + '", "source" :"' + source + '", "index" :"' + index + '", "host" : "' + event_host + '"}'
        end

        if @send_batched_events
          body << "\n"
        else
          send_to_splunk(body, token)
          body = ''
        end
      }

      if @send_batched_events
        send_to_splunk(body, token)
      end
    end
762114
def daily_metadata(year, month, day, dst_folder, writers=[file_writer], geometry_check=None,
                   num_worker_threads=1):
    

    threaded = False

    counter = {
        'products': 0,
        'saved_tiles': 0,
        'skipped_tiles': 0,
        'skipped_tiles_paths': []
    }

    if num_worker_threads > 1:
        threaded = True
        queue = Queue()

    # create folders
    year_dir = os.path.join(dst_folder, str(year))
    month_dir = os.path.join(year_dir, str(month))
    day_dir = os.path.join(month_dir, str(day))

    product_list = get_products_metadata_path(year, month, day)

    logger.info('There are %s products in %s-%s-%s' % (len(list(iterkeys(product_list))),
                                                       year, month, day))

    for name, product in iteritems(product_list):
        product_dir = os.path.join(day_dir, name)

        if threaded:
            queue.put([product, product_dir, counter, writers, geometry_check])
        else:
            counter = product_metadata(product, product_dir, counter, writers, geometry_check)

    if threaded:
        def worker():
            while not queue.empty():
                args = queue.get()
                try:
                    product_metadata(*args)
                except Exception:
                    exc = sys.exc_info()
                    logger.error('%s tile skipped due to error: %s' % (threading.current_thread().name,
                                                                       exc[1].__str__()))
                    args[2]['skipped_tiles'] += 1
                queue.task_done()

        threads = []
        for i in range(num_worker_threads):
            t = threading.Thread(target=worker)
            t.start()
            threads.append(t)

        queue.join()

    return counter
453100
def write_info (self, url_data):
        """"""
        self.write(self.part("info") + self.spaces("info"))
        self.writeln(self.wrap(url_data.info, 65), color=self.colorinfo)
575777
private void writeMetaContinuation()
  {
    TempBuffer tBuf = TempBuffer.create();
    byte []buffer = tBuf.buffer();
    
    int metaLength = _segmentMeta[0].size();
    
    SegmentExtent extent = new SegmentExtent(0, _addressTail, metaLength);
    
    _metaExtents.add(extent);
    
    _addressTail += metaLength;
    
    int offset = 0;
    buffer[offset++] = CODE_META_SEGMENT;
    
    long address = extent.address();
    int length = extent.length();
    
    long value = (address & ~0xffff) | (length >> 16);
    
    offset += BitsUtil.writeLong(buffer, offset, value);
    
    int crc = _nonce;
    crc = Crc32Caucho.generate(crc, buffer, 0, offset);

    offset += BitsUtil.writeInt(buffer, offset, crc);

    try (OutStore sOut = openWrite(_metaOffset, offset)) {
      sOut.write(_metaOffset, buffer, 0, offset);
    }
    
    tBuf.free();
    
    _metaAddress = address;
    _metaOffset = address;
    _metaTail = address + length;
  }
815269
private void writeDetailPageInfos(List<CmsDetailPageInfo> infos, CmsUUID newId) {

        int i = 0;
        for (CmsDetailPageInfo info : infos) {
            if (info.isInherited()) {
                continue;
            }
            CmsUUID id = info.getId();
            if (id == null) {
                id = newId;
            }
            writeValue(info.getType(), id, i);
            i += 1;
        }
    }
383052
def _write_metadata(self):
        
        string_buffer = StringIO()
        writer = csv.writer(string_buffer, delimiter=',', quotechar='"', quoting=csv.QUOTE_MINIMAL)
        writer.writerow(['Path *', 'Title *', 'Source ID', 'Description', 'Author', 'Language', 'License ID *', 'License Description', 'Copyright Holder', 'Thumbnail'])
        for k in self.map:
            node = self.map[k]
            writer.writerow([k, node['title'], node['source_id'], node['description'], node['author'], node['language'], node['license'], node['license_description'], node['copyright_holder'], node['thumbnail']])

        self.zf.writestr('Content.csv', string_buffer.getvalue())
392796
function writeLog(msgs){
    var data = (msgs.length === 1) ? msgs[0] : msgs;
    
    this.config.callback(data);
}
846130
def create_info(name, info_type, url=None, parent=None, id=None,
                context=ctx_default, store=False):
    """"""
    id = str(uuid4()) if id is None else id
    pubsub = _pubsub_key(id)

    info = {'id': id,
            'type': info_type,
            'pubsub': pubsub,
            'url': url,
            'parent': parent,
            'context': context,
            'name': name,
            'status': 'Queued' if info_type == 'job' else None,
            'date_start': None,
            'date_end': None,
            'date_created': str(datetime.now()),
            'result': None}

    if store:
        r_client.set(id, json_encode(info))

        if parent is not None:
            r_client.sadd(_children_key(parent), id)

    return info
365840
def process_output(meta_file, outfile_name, code_links):
    '''
    '''

    # Markdown title line
    doc_str = '# ' + meta_file['header'] + '\n'
    doc_str += 'Generated by [py2md](https://github.com/gbowerman/py2md) on '
    doc_str += strftime("%Y-%m-%d %H:%M:%S ") + '\n\n'

    # Create a table of contents if more than one module (i.e. more than one
    # source file)
    if len(meta_file['modules']) > 1:
        doc_str += "## Contents\n"
        chapter_num = 1
        for meta_doc in meta_file['modules']:
            chapter_name = meta_doc['summary_comment']
            chapter_link = chapter_name.lstrip().replace('.', '').replace(' ', '-').lower()
            doc_str += str(chapter_num) + \
                '. [' + chapter_name + '](#' + chapter_link + ')\n'
            chapter_num += 1


    # Document each meta-file
    for meta_doc in meta_file['modules']:
        doc_str += '## ' + meta_doc['summary_comment'] + '\n'
        doc_str += '[source file](' + meta_doc['source_file'] + ')' + '\n'
        for function_info in meta_doc['functions']:
            doc_str += '### ' + function_info['name'] + '\n'
            doc_str += function_info['definition'] + '\n\n'
            if 'comments' in function_info:
                doc_str += '```\n' + function_info['comments'] + '\n```\n\n'

    # write the markdown to file
    print('Writing file: ' + outfile_name)
    out_file = open(outfile_name, 'w')
    out_file.write(doc_str)
    out_file.close()
1118674
def write_backup_meta_data(self):
        """"""
        auto_backup_meta_file = os.path.join(self._tmp_storage_path, FILE_NAME_AUTO_BACKUP)
        storage.storage_utils.write_dict_to_json(self.meta, auto_backup_meta_file)
213412
def __write_stored_routine_metadata(self):
        
        with open(self._pystratum_metadata_filename, 'w') as stream:
            json.dump(self._pystratum_metadata, stream, indent=4, sort_keys=True)
223003
def range_metadata(start, end, dst_folder, num_worker_threads=0, writers=[file_writer], geometry_check=None):
    

    assert isinstance(start, date)
    assert isinstance(end, date)

    delta = end - start

    dates = []

    for i in range(delta.days + 1):
        dates.append(start + timedelta(days=i))

    days = len(dates)

    total_counter = {
        'days': days,
        'products': 0,
        'saved_tiles': 0,
        'skipped_tiles': 0,
        'skipped_tiles_paths': []
    }

    def update_counter(counter):
        for key in iterkeys(total_counter):
            if key in counter:
                total_counter[key] += counter[key]

    for d in dates:
        logger.info('Getting metadata of {0}-{1}-{2}'.format(d.year, d.month, d.day))
        update_counter(daily_metadata(d.year, d.month, d.day, dst_folder, writers, geometry_check,
                                      num_worker_threads))

    return total_counter
1265395
def write_metadata(self):
        """"""
        import mutagen
        from mutagen import id3

        id3 = id3.ID3(self.filename)
        for tag in self.metadata.keys():
            value = self.metadata[tag]
            frame = mutagen.id3.Frames[tag](3, value)
            try:
                id3.add(frame)
            except:
                raise IOError('EncoderError: cannot tag "' + tag + '"')
        try:
            id3.save()
        except:
            raise IOError('EncoderError: cannot write tags')
413502
def _GenerateClientInfo(self, client_id, client_fd):
    """"""
    summary_dict = client_fd.ToPrimitiveDict(stringify_leaf_fields=True)
    summary = yaml.Dump(summary_dict).encode("utf-8")

    client_info_path = os.path.join(self.prefix, client_id, "client_info.yaml")
    st = os.stat_result((0o644, 0, 0, 0, 0, 0, len(summary), 0, 0, 0))
    yield self.archive_generator.WriteFileHeader(client_info_path, st=st)
    yield self.archive_generator.WriteFileChunk(summary)
    yield self.archive_generator.WriteFileFooter()
1363306
def findIoByMetainfo(metainfo)
      @ioInfo.each_value do |info|
        if info.metainfo == metainfo
          io = info.readFiberIoFacade
          # Don't allow read calls from timer handlers. This is to prevent a complex situation.
          # See the processTimer call in eventLoopBody for more info
          io = WriteOnlyIoFacade.new(info) if @currentHandlerCallback == :timer
          return io
        end
      end
      nil
    end
138399
def _write_metadata(self, handle):
        '''
        '''
        self.check_metadata()

        # header
        self.header.write(handle)
        self._pad_block(handle)
        assert handle.tell() == 512

        # groups
        handle.write(struct.pack(
            'BBBB', 0, 0, self.parameter_blocks(), PROCESSOR_INTEL))
        id_groups = sorted(
            (i, g) for i, g in self.groups.items() if isinstance(i, int))
        for group_id, group in id_groups:
            group.write(group_id, handle)

        # padding
        self._pad_block(handle)
        while handle.tell() != 512 * (self.header.data_block - 1):
            handle.write(b'\x00' * 512)