Class format:
        class wrt n m security object  mag  stdev F H_sur  dist     ..E    nobs   time  av_xres av_yres max_x  max_y
        a ..E        e  ..E      i      ..E      node     ..E   argperi      ..E   time_peri      ..E    rate
778286
def from_class_line(cls, classLine, version=4, existing_object=None):
        '''
        
        '''
        if not classLine:
            raise ValueError('No class file line given.')
        if version == 4:
            params = classLine.split()
            if len(params) != 31:
                print params
                raise TypeError('Expected 31 columns, {0} given'.format(len(params)))
            input_params = [params[5]] + params[10:30]  # the elements that are in common
            if not existing_object:
                # can later add more tests that the values match those in the existing object
                retval = cls(*input_params)
            else:
                assert isinstance(existing_object, tno)
                assert existing_object.name == params[5]
                retval = existing_object
            retval.classification = params[0]
            retval.wrt = params[1]
            retval.n = int(params[2])
            retval.m = int(params[3])
            retval.security = params[4]
            retval.mag_discov = float(params[6])
            retval.mag_discov_e = float(params[7])
            retval.filter = params[8]
            retval.H = float(
                params[9])  # H_r magnitude, using the average m_r and the discovery geometry (same error as m_r)
            retval.rate = float(params[30])
        elif version == 5:
            # Upgrade?
            # input_params =
            retval = cls(*input_params)
        else:
            raise VersionError('Unknown version "{0}"'.format(version))
        assert retval
        return retval
290595
def format(self, object, context, maxlevels, level):
        
        return _safe_repr(object, context, maxlevels, level)
175018
def sanitizeStructTime(struct):
    
    maxValues = (9999, 12, 31, 23, 59, 59)
    minValues = (1, 1, 1, 0, 0, 0)
    newstruct = []
    for value, maxValue, minValue in zip(struct[:6], maxValues, minValues):
        newstruct.append(max(minValue, min(value, maxValue)))
    return tuple(newstruct) + struct[6:]
145536
def _format_info(self):
		
		info = 'GNTP/%s %s' % (
			self.info.get('version'),
			self.info.get('messagetype'),
		)
		if self.info.get('encryptionAlgorithmID', None):
			info += ' %s:%s' % (
				self.info.get('encryptionAlgorithmID'),
				self.info.get('ivValue'),
			)
		else:
			info += ' NONE'

		if self.info.get('keyHashAlgorithmID', None):
			info += ' %s:%s.%s' % (
				self.info.get('keyHashAlgorithmID'),
				self.info.get('keyHash'),
				self.info.get('salt')
			)

		return info
132821
def strptime(cls, data, format, scale=DEFAULT_SCALE):  # pragma: no cover
        
        return cls(datetime.strptime(data, format), scale=scale)
566942
def format_object_attrs(obj):
    
    attrs = []
    if hasattr(obj, 'dtype'):
        attrs.append(('dtype', "'{}'".format(obj.dtype)))
    if getattr(obj, 'name', None) is not None:
        attrs.append(('name', default_pprint(obj.name)))
    max_seq_items = get_option('display.max_seq_items') or len(obj)
    if len(obj) > max_seq_items:
        attrs.append(('length', len(obj)))
    return attrs
95906
def str_def(self):
        
        return "classname={!r}; line={!r}; column={!r}; message={!r};". \
            format(self.__class__.__name__, self.line, self.column,
                   self.args[0])
1248029
def _generate_union_class_repr(self, data_type):
        
        self.emit('def __repr__(self):')
        with self.indent():
            self.emit("return '{}(%r, %r)' % (self._tag, self._value)".format(
                class_name_for_data_type(data_type),
            ))
        self.emit()
760904
def serialize_to_rsb(params: dict) -> bytes:
    
    header = bytearray(np.zeros(2048, np.byte).tostring())

    if "text_header_size" in params:
        header[0:4] = struct.pack('I', params["text_header_size"])

    if "events_num" in params:
        header[8:12] = struct.pack('i', params["events_num"])

    if "start_time" in params:
        start_time = dateutil.parser.parse(params["start_time"]).timestamp()
        header[16:24] = struct.pack('Q', int(start_time))

    if "end_time" in params:
        end_time = dateutil.parser.parse(params["end_time"]).timestamp()
        header[24:32] = struct.pack('Q', int(end_time))

    header[32:32 + len(params["filepath"])
           ] = params['filepath'].encode('cp1251')

    header[288:292] = struct.pack('i', params["num_blocks"])

    header[292:296] = struct.pack('i', int(params["aquisition_time"]))

    header[296:300] = struct.pack('i', params["blocks_in_file"])

    header[300:304] = struct.pack('i', int(params["waitTime"]))

    header[312:320] = struct.pack('d', params["threshold"])

    sync_params = params["synchro_control"]
    sync_params_num = len(sync_params)

    header[336:340] = struct.pack('I', sync_params_num)

    for i in range(sync_params_num):
        if sync_params[i] == 'Default':
            code = 0
        else:
            code = synchro_control[sync_params[i]]

        header[320 + i * 4:320 + (i + 1) * 4] = struct.pack('I', code)

    header[344:352] = struct.pack('d', params["sample_freq"])
    header[352:356] = struct.pack('I', params["pre_history"])

    header[356:360] = struct.pack('i', params["packet_number"])

    header[360:364] = struct.pack('I', params["b_size"])

    header[364:368] = struct.pack('I', params["hysteresis"])

    header[368:372] = struct.pack('I', params["channel_number"])

    for i in range(params["channel_number"]):
        off = 372 + 56 * i

        ch_param = params['channel'][i]

        header[off + 44: off + 52] = struct.pack('d', ch_param["adjustment"])
        header[off + 52: off + 56] = struct.pack('I', ch_param["gain"])
        header[off + 36: off + 40] = struct.pack('I', len(ch_param['params']))

        for j, param in enumerate(ch_param['params']):
            if param == 'Default':
                code = 0
            else:
                code = channel_control[param]
                header[off + 4 + j * 4:
                       off + 4 + (j + 1) * 4] = struct.pack('I', code)

    synchro_channel = params['synchro_channel']
    header[632:636] = struct.pack('I', len(synchro_channel['params']))

    for i, param in enumerate(synchro_channel['params']):
        if param == 'Default':
            code = 0
        else:
            code = synchro_channel_control[param]
            header[600 + i * 4: 600 + (i + 1) * 4] = struct.pack('I', code)

    sync_type = synchro_channel_types[synchro_channel['type']]
    header[304:308] = struct.pack('I', sync_type)

    header[636:640] = struct.pack('I', synchro_channel["gain"])

    if "err_lang" in params:
        header[640:644] = struct.pack('I', params["err_lang"])

    if "board_name" in params:
        header[644:644 + len(params["board_name"])] = \
            params['board_name'].encode('cp1251')

    if "board_id" in params:
        header[900: 904] = struct.pack('I', params["board_id"])

    return bytes(header)
904002
def _dict_to_tuple(d):
    '''
    '''    
    # TODO: Adding a ms field to struct_time tuples is problematic 
    # since they don't have this field.  Should use datetime
    # which has a microseconds field, else no ms..  When mapping struct_time 
    # to gDateTime the last 3 fields are irrelevant, here using dummy values to make
    # everything happy.
    # 

    retval = _niltime[:]
    for k,i in ( ('Y', 0), ('M', 1), ('D', 2), ('h', 3), ('m', 4), ):
        v = d.get(k)
        if v: retval[i] = int(v)
        
    v = d.get('s')
    if v:
        msec,sec = _modf(float(v))
        retval[6],retval[5] = int(round(msec*1000)), int(sec)
            
    v = d.get('tz')
    if v and v != 'Z':
        h,m = map(int, v.split(':'))
        # check for time zone offset, if within the same timezone, 
        # ignore offset specific calculations
        offset=_localtimezone().utcoffset(_datetime.now())
        local_offset_hour = offset.seconds/3600
        local_offset_min = (offset.seconds%3600)%60
        if local_offset_hour > 12: 
            local_offset_hour -= 24
            
        if local_offset_hour != h or local_offset_min != m:                
            if h<0:
                #TODO: why is this set to server
                #foff = _fixedoffset(-((abs(h)*60+m)),"server")
                foff = _fixedoffset(-((abs(h)*60+m)))
            else:
                #TODO: why is this set to server
                #foff = _fixedoffset((abs(h)*60+m),"server")
                foff = _fixedoffset((abs(h)*60+m)) 
                
            dt = _datetime(retval[0],retval[1],retval[2],retval[3],retval[4],
                           retval[5],0,foff)
            
            # update dict with calculated timezone
            localdt=dt.astimezone(_localtimezone())
            retval[0] = localdt.year
            retval[1] = localdt.month
            retval[2] = localdt.day
            retval[3] = localdt.hour
            retval[4] = localdt.minute
            retval[5] = localdt.second
            
    if d.get('neg', 0):
        retval[0:5] = map(operator.__neg__, retval[0:5])
    return tuple(retval)
874005
def format( event )
      obj = format_obj(event.data)
      sprintf("%*s  %s : %s\n", ::Logging::MAX_LEVEL_LENGTH,
              ::Logging::LNAMES[event.level], event.logger, obj)
    end
761326
def default(self, obj):
        
        if isinstance(obj, datetime.datetime):
            # Serialize date-time objects. Make sure they're naive.
            if obj.tzinfo is not None:
                raise TypeError('Cannot encode time zone-aware date-times to MessagePack')
            # Then, work out the timestamp in seconds.
            seconds = (obj - datetime.datetime(1970, 1, 1)).total_seconds()
            microseconds = int(seconds * 1000000.0)
            # Then pack it into a big-endian signed 64-bit integer.
            return msgpack.ExtType(
                self.EXT_DATETIME,
                self.STRUCT_DATETIME.pack(microseconds),
            )
        elif isinstance(obj, datetime.date):
            # Serialize local-date objects by packing to a big-endian unsigned short and two big-endian unsigned chars.
            return msgpack.ExtType(
                self.EXT_DATE,
                self.STRUCT_DATE.pack(obj.year, obj.month, obj.day),
            )
        elif isinstance(obj, datetime.time):
            # Serialize dateless-time objects by packing to three big-endian unsigned chars and a big-endian unsigned
            # 32-bit integer.
            return msgpack.ExtType(
                self.EXT_TIME,
                self.STRUCT_TIME.pack(obj.hour, obj.minute, obj.second, obj.microsecond),
            )
        elif isinstance(obj, decimal.Decimal):
            obj_str = six.text_type(obj)[:65535].encode('utf-8')
            obj_len = len(obj_str)
            obj_encoder = struct.Struct(str('!H{}s'.format(obj_len)))
            return msgpack.ExtType(
                self.EXT_DECIMAL,
                obj_encoder.pack(obj_len, obj_str),
            )
        elif isinstance(obj, currint.Amount):
            # Serialize Amount objects. Start with the lowercased currency code as bytes.
            code = obj.currency.code.upper()
            if isinstance(code, six.text_type):
                code = code.encode('ascii')
            # Then pack it in with the minor value.
            return msgpack.ExtType(
                self.EXT_CURRINT,
                self.STRUCT_CURRINT.pack(code, obj.value),
            )
        else:
            # Wuh-woh
            raise TypeError('Cannot encode value of type {} to MessagePack: {}'.format(type(obj).__name__, obj))
805386
def _generate_struct_class_h(self, struct):
        """"""
        self._generate_init_imports_h(struct)
        self._generate_imports_h(self._get_imports_h(struct))

        self.emit()
        self.emit('NS_ASSUME_NONNULL_BEGIN')
        self.emit()

        self.emit('#pragma mark - API Object')
        self.emit()

        self._generate_class_comment(struct)

        struct_name = fmt_class_prefix(struct)

        with self.block_h_from_data_type(struct, protocol=['DBSerializable', 'NSCopying']):
            self.emit('#pragma mark - Instance fields')
            self.emit()
            self._generate_struct_properties(struct.fields)
            self.emit('#pragma mark - Constructors')
            self.emit()
            self._generate_struct_cstor_signature(struct)
            self._generate_struct_cstor_signature_default(struct)
            self._generate_init_unavailable_signature(struct)

        self.emit()
        self.emit()

        self.emit('#pragma mark - Serializer Object')
        self.emit()
        self.emit(comment_prefix)
        self.emit_wrapped_text(
            'The serialization class for the `{}` struct.'.format(
                fmt_class(struct.name)),
            prefix=comment_prefix)
        self.emit(comment_prefix)
        with self.block_h(fmt_serial_class(struct_name)):
            self._generate_serializer_signatures(struct_name)

        self.emit()
        self.emit('NS_ASSUME_NONNULL_END')
        self.emit()
275565
def serialize_rfc(attr, **kwargs):
        
        try:
            if not attr.tzinfo:
                _LOGGER.warning(
                    "Datetime with no tzinfo will be considered UTC.")
            utc = attr.utctimetuple()
        except AttributeError:
            raise TypeError("RFC1123 object must be valid Datetime object.")

        return "{}, {:02} {} {:04} {:02}:{:02}:{:02} GMT".format(
            Serializer.days[utc.tm_wday], utc.tm_mday,
            Serializer.months[utc.tm_mon], utc.tm_year,
            utc.tm_hour, utc.tm_min, utc.tm_sec)
426779
def to_json(cls, obj):
        
        return "{0}d {1}s {2}us".format(
                obj.days, obj.seconds, obj.microseconds)
1135438
def stats(self):
        
        printDebug("Classes.....: %d" % len(self.classes))
        printDebug("Properties..: %d" % len(self.properties))
399367
function format(param, data, cb) {
    const time = util.formatTime(new Date());
    const outArray = data.toString().replace(/^\s+|\s+$/g, '').split(/\s+/);
    let outValueArray = [];
    for (let i = 0; i < outArray.length; i++) {
        if ((!isNaN(outArray[i]))) {
            outValueArray.push(outArray[i]);
        }
    }
    const ps = {};
    ps.time = time;
    ps.serverId = param.serverId;
    ps.serverType = ps.serverId.split('-')[0];
    ps.pid = param.pid;
    const pid = ps.pid;
    ps.cpuAvg = outValueArray[1];
    ps.memAvg = outValueArray[2];
    ps.vsz = outValueArray[3];
    ps.rss = outValueArray[4];
    outValueArray = [];
    if (process.platform === 'darwin') {
        ps.usr = 0;
        ps.sys = 0;
        ps.gue = 0;
        cb(null, ps);
        return;
    }
    exec(`pidstat -p ${pid}`, (err, output) => {
        if (err) {
            console.error('the command pidstat failed! ', err.stack);
            return;
        }
        const _outArray = output.toString().replace(/^\s+|\s+$/g, '').split(/\s+/);
        for (let i = 0; i < _outArray.length; i++) {
            if ((!isNaN(_outArray[i]))) {
                outValueArray.push(_outArray[i]);
            }
        }
        ps.usr = outValueArray[1];
        ps.sys = outValueArray[2];
        ps.gue = outValueArray[3];

        cb(null, ps);
    });
}