Read only the annotation of the FCS file (without reading DATA segment).

        It's advised not to use this method, but instead to access
        the meta data through the FCMeasurement.meta attribute.
774144
def read_meta(self, **kwargs):
        '''
        
        '''
        # TODO Try to rewrite the code to be more logical
        # The reason the equivalent statement is not in the read_data method
        # above is because self.readdata_kwargs are passed
        # as **kwargs to the read_data function.
        if 'channel_naming' in self.readdata_kwargs:
            kwargs['channel_naming'] = self.readdata_kwargs['channel_naming']
        meta = parse_fcs(self.datafile,
                         reformat_meta=True,
                         meta_data_only=True, **kwargs)
        return meta
1289300
def read(self, f):
        
        self.clear_document()

        g = Graph()
        g.parse(f, format='xml')

        for n in g.namespaces():
            ns = n[1].toPython()
            if not ns.endswith(('#', '/', ':')):
                ns = ns + '/'
            self._namespaces[n[0]] = ns
            # Extend the existing namespaces available
            XML_NS[n[0]] = ns

        self._read_sequences(g)
        self._read_component_definitions(g)
        self._extend_component_definitions(g)
        self._read_models(g)
        self._read_module_definitions(g)
        self._extend_module_definitions(g)
        self._read_annotations(g)
        # Last as this needs all other top level objects created
        self._read_collections(g)
1189164
public static Map<String, String> getMetadataFromSequenceFile(FileSystem fs, Path path) {
        try {
            Configuration conf = new Configuration();
            conf.setInt("io.file.buffer.size", 4096);
            SequenceFile.Reader reader = new SequenceFile.Reader(fs, path, new Configuration());
            SequenceFile.Metadata meta = reader.getMetadata();
            reader.close();
            TreeMap<Text, Text> map = meta.getMetadata();
            Map<String, String> values = new HashMap<String, String>();
            for(Map.Entry<Text, Text> entry: map.entrySet())
                values.put(entry.getKey().toString(), entry.getValue().toString());

            return values;
        } catch(IOException e) {
            throw new RuntimeException(e);
        }
    }
71374
@Override
    public MetaData<?, ?> readMetaData(IoBuffer buffer) {
        MetaData<?, ?> retMeta = new MetaData<String, Object>();
        Input input = new Input(buffer);
        String metaType = Deserializer.deserialize(input, String.class);
        log.debug("Metadata type: {}", metaType);
        Map<String, ?> m = Deserializer.deserialize(input, Map.class);
        retMeta.putAll(m);
        return retMeta;
    }
805881
def parse_single_meta(self, fname, selected_meta_data):
        
        # reads a meta data file into a dataframe
        columns = []
        data = []
        with open(fname) as f:
            for line in f:
                splitted = line.split('\t')
                columns.append(splitted[0])
                data.append(splitted[1].split('\n')[0])  # to remove the \n values
        df = pd.DataFrame(data=data, index=columns)
        df = df.T
        sample = self._get_sample_name(fname)
        if selected_meta_data:  # if null then keep all the columns
            try:
                df = df[selected_meta_data]
            except:
                pass
        df['sample'] = sample
        return df
1204965
def parse_meta(filename, data):
    
    if "." not in filename:
        raise MetaParsingException(
            "Can't recognize type of your metadata ('%s')!" % filename
        )

    suffix = filename.rsplit(".", 1)[1].lower()

    if suffix not in SUPPORTED_FILES:
        raise MetaParsingException("Can't parse file of type '%s'!" % suffix)

    fp = validator.FieldParser()
    for key, val in SUPPORTED_FILES[suffix](data).items():
        fp.process(key, val)

    return fp.get_epublication()
1315229
def _read_metadata(self, f):
        """"""

        raw_data_index = types.Uint32.read(f, self.endianness)

        log.debug("Reading metadata for object %s", self.tdms_object.path)

        # Object has no data in this segment
        if raw_data_index == 0xFFFFFFFF:
            log.debug("Object has no data in this segment")
            self.has_data = False
            # Leave number_values and data_size as set previously,
            # as these may be re-used by later segments.
        # Data has same structure as previously
        elif raw_data_index == 0x00000000:
            log.debug(
                "Object has same data structure as in the previous segment")
            self.has_data = True
        elif raw_data_index == 0x00001269 or raw_data_index == 0x00001369:
            # This is a DAQmx raw data segment.
            #    0x00001269 for segment containing Format Changing scaler.
            #    0x00001369 for segment containing Digital Line scaler.
            if raw_data_index == 0x00001369:
                # special scaling for DAQ's digital input lines?
                log.warning("DAQmx with Digital Line scaler has not tested")

            # DAQmx raw data format metadata has its own class
            self.has_data = True
            self.tdms_object.has_data = True

            info = self._read_metadata_mx(f)
            self.dimension = info.dimension
            self.data_type = info.data_type
            # DAQmx format has special chunking
            self.data_size = info.chunk_size
            self.number_values = info.chunk_size
            # segment reading code relies on a single consistent raw
            # data width so assert that there is only one.
            assert(len(info.raw_data_widths) == 1)
            self.raw_data_width = info.raw_data_widths[0]
            # fall through and read properties
        else:
            # Assume metadata format is legacy TDMS format.
            # raw_data_index gives the length of the index information.
            self.has_data = True
            self.tdms_object.has_data = True

            # Read the data type
            try:
                self.data_type = types.tds_data_types[
                    types.Uint32.read(f, self.endianness)]
            except KeyError:
                raise KeyError("Unrecognised data type")
            if (self.tdms_object.data_type is not None and
                    self.data_type != self.tdms_object.data_type):
                raise ValueError(
                    "Segment object doesn't have the same data "
                    "type as previous segments.")
            else:
                self.tdms_object.data_type = self.data_type
            log.debug("Object data type: %r", self.tdms_object.data_type)

            if (self.tdms_object.data_type.size is None and
                    self.tdms_object.data_type != types.String):
                raise ValueError(
                    "Unsupported data type: %r" % self.tdms_object.data_type)

            # Read data dimension
            self.dimension = types.Uint32.read(f, self.endianness)
            # In TDMS version 2.0, 1 is the only valid value for dimension
            if self.dimension != 1:
                log.warning("Data dimension is not 1")

            # Read number of values
            self.number_values = types.Uint64.read(f, self.endianness)

            # Variable length data types have total size
            if self.data_type in (types.String, ):
                self.data_size = types.Uint64.read(f, self.endianness)
            else:
                self.data_size = (
                    self.number_values *
                    self.data_type.size * self.dimension)

            log.debug(
                "Object number of values in segment: %d", self.number_values)

        # Read data properties
        num_properties = types.Uint32.read(f, self.endianness)
        log.debug("Reading %d properties", num_properties)
        for i in range(num_properties):
            prop_name, value = read_property(f, self.endianness)
            self.tdms_object.properties[prop_name] = value
578924
def _read_metadata(self, f, endianness):
        
        self.data_type = types.tds_data_types[0xFFFFFFFF]
        self.dimension = types.Uint32.read(f, endianness)
        # In TDMS format version 2.0, 1 is the only valid value for dimension
        if self.dimension != 1:
            log.warning("Data dimension is not 1")
        self.chunk_size = types.Uint64.read(f, endianness)
        # size of vector of format changing scalers
        self.scaler_vector_length = types.Uint32.read(f, endianness)
        # Size of the vector
        log.debug("mxDAQ format scaler vector size '%d'" %
                  (self.scaler_vector_length,))
        if self.scaler_vector_length > 1:
            log.error("mxDAQ multiple format changing scalers not implemented")

        for idx in range(self.scaler_vector_length):
            # WARNING: This code overwrites previous values with new
            # values.  At this time NI provides no documentation on
            # how to use these scalers and sample TDMS files do not
            # include more than one of these scalers.
            self.scaler_data_type_code = types.Uint32.read(f, endianness)
            self.scaler_data_type = (
                types.tds_data_types[self.scaler_data_type_code])

            # more info for format changing scaler
            self.scaler_raw_buffer_index = types.Uint32.read(f, endianness)
            self.scaler_raw_byte_offset = types.Uint32.read(f, endianness)
            self.scaler_sample_format_bitmap = types.Uint32.read(f, endianness)
            self.scale_id = types.Uint32.read(f, endianness)

        raw_data_widths_length = types.Uint32.read(f, endianness)
        self.raw_data_widths = np.zeros(raw_data_widths_length, dtype=np.int32)
        for cnt in range(raw_data_widths_length):
            self.raw_data_widths[cnt] = types.Uint32.read(f, endianness)
1308714
private AnnotationInfo readAnnotation() throws IOException {
        // Lcom/xyz/Annotation; -> Lcom.xyz.Annotation;
        final String annotationClassName = getConstantPoolClassDescriptor(
                inputStreamOrByteBuffer.readUnsignedShort());
        final int numElementValuePairs = inputStreamOrByteBuffer.readUnsignedShort();
        AnnotationParameterValueList paramVals = null;
        if (numElementValuePairs > 0) {
            paramVals = new AnnotationParameterValueList(numElementValuePairs);
            for (int i = 0; i < numElementValuePairs; i++) {
                final String paramName = getConstantPoolString(inputStreamOrByteBuffer.readUnsignedShort());
                final Object paramValue = readAnnotationElementValue();
                paramVals.add(new AnnotationParameterValue(paramName, paramValue));
            }
        }
        return new AnnotationInfo(annotationClassName, paramVals);
    }
1193740
def read_metadata(self, f, objects, previous_segment=None):
        """"""

        if not self.toc["kTocMetaData"]:
            try:
                self.ordered_objects = previous_segment.ordered_objects
            except AttributeError:
                raise ValueError(
                    "kTocMetaData is not set for segment but "
                    "there is no previous segment")
            self.calculate_chunks()
            return
        if not self.toc["kTocNewObjList"]:
            # In this case, there can be a list of new objects that
            # are appended, or previous objects can also be repeated
            # if their properties change
            self.ordered_objects = [
                copy(o) for o in previous_segment.ordered_objects]

        log.debug("Reading metadata at %d", f.tell())

        # First four bytes have number of objects in metadata
        num_objects = types.Int32.read(f, self.endianness)

        for obj in range(num_objects):
            # Read the object path
            object_path = types.String.read(f, self.endianness)

            # If this is a new segment for an existing object,
            # reuse the existing object, otherwise,
            # create a new object and add it to the object dictionary
            if object_path in objects:
                obj = objects[object_path]
            else:
                obj = TdmsObject(object_path, self.tdms_file)
                objects[object_path] = obj

            # Add this segment object to the list of segment objects,
            # re-using any properties from previous segments.
            updating_existing = False
            if not self.toc["kTocNewObjList"]:
                # Search for the same object from the previous segment
                # object list.
                obj_index = [
                    i for i, o in enumerate(self.ordered_objects)
                    if o.tdms_object is obj]
                if len(obj_index) > 0:
                    updating_existing = True
                    log.debug("Updating object in segment list")
                    obj_index = obj_index[0]
                    segment_obj = self.ordered_objects[obj_index]
            if not updating_existing:
                if obj._previous_segment_object is not None:
                    log.debug("Copying previous segment object")
                    segment_obj = copy(obj._previous_segment_object)
                else:
                    log.debug("Creating a new segment object")
                    segment_obj = _TdmsSegmentObject(obj, self.endianness)
                self.ordered_objects.append(segment_obj)
            # Read the metadata for this object, updating any
            # data structure information and properties.
            segment_obj._read_metadata(f)
            obj._previous_segment_object = segment_obj

        self.calculate_chunks()
640223
private void readJSR303Annotations(UIComponent component) {
		coreExpression = ELTools.getCoreValueExpression(component);
//		Annotation[] annotations = ELTools.readAnnotations(component);
//		if (null != annotations) {
//			for (Annotation a : annotations) {
//				if (a instanceof Max) {
//					long maximum = ((Max) a).value();
//					max = maximum;
//					hasMax = true;
//				} else if (a instanceof Min) {
//					long minimum = ((Min) a).value();
//					hasMin = true;
//					min = minimum;
//				} else if (a instanceof Size) {
//					maxSize = ((Size) a).max();
//					hasMaxSize = maxSize > 0;
//					minSize = ((Size) a).min();
//					hasMinSize = minSize > 0;
//				} else if (a instanceof NotNull) {
//					isRequired = true;
//				} else if (a.annotationType().getSimpleName().equals("NotEmpty")) {
//					isRequired = true;
//				}
//			}
//		}

		clazz = ELTools.getType(component);
		if ((clazz == Integer.class) || (clazz == int.class)
				|| (clazz == Byte.class) || (clazz == byte.class)
				|| (clazz == Short.class) || (clazz == short.class)
				|| (clazz == Long.class) || (clazz == long.class)) {
			isInteger = true;
			isNumeric = true;
		} else if ((clazz == Double.class) || (clazz == double.class)
				|| (clazz == Float.class) || (clazz == float.class)) {
			isFloat = true;
			isNumeric = true;
		} else if ((clazz==Date.class) || (clazz==java.util.Date.class)) {
			isDate=true;
		}
		else if ((clazz==Boolean.class) || (clazz==boolean.class)) {
			isBoolean=true;
		}
	}
1151411
private void readFederation() {
        if (federation != null) {
            Operation fedOp = new Operation.Builder(READ_RESOURCE_OPERATION,
                    FEDERATION_TEMPLATE.resolve(statementContext, federation)).param(RECURSIVE, true).build();
            Operation sdOp = new Operation.Builder(READ_CHILDREN_NAMES_OPERATION,
                    AddressTemplate.of("{selected.profile}/subsystem=security").resolve(statementContext))
                    .param(CHILD_TYPE, "security-domain")
                    .build();
            dispatcher.execute(new DMRAction(new Composite(fedOp, sdOp)), new SimpleCallback<DMRResponse>() {
                @Override
                public void onSuccess(final DMRResponse dmrResponse) {
                    ModelNode response = dmrResponse.get();

                    if (response.isFailure()) {
                        Log.error("Failed to read federation " + federation, response.getFailureDescription());
                    } else {
                        ModelNode fedNode = response.get(RESULT).get("step-1").get(RESULT);
                        identityProvider = fedNode.get("identity-provider").asProperty().getName();
                        List<ModelNode> sdNodes = response.get(RESULT).get("step-2").get(RESULT).asList();

                        getView().update(fedNode, Ordering.natural().immutableSortedCopy(
                                FluentIterable.from(sdNodes).transform(ModelNode::asString)));
                    }
                }
            });
        }
    }
1095955
def read_json(self):
        
        with reading_ancillary_files(self):
            metadata = super(ImpactLayerMetadata, self).read_json()
            if 'provenance' in metadata:
                for provenance_step in metadata['provenance']:
                    try:
                        title = provenance_step['title']
                        if 'IF Provenance' in title:
                            self.append_if_provenance_step(
                                provenance_step['title'],
                                provenance_step['description'],
                                provenance_step['time'],
                                provenance_step['data']
                            )
                        else:
                            self.append_provenance_step(
                                provenance_step['title'],
                                provenance_step['description'],
                                provenance_step['time'],
                            )
                    except KeyError:
                        # we want to get as much as we can without raising
                        # errors
                        pass
            if 'summary_data' in metadata:
                self.summary_data = metadata['summary_data']

        return metadata
654277
def read_meta_line(self, f):
        """"""
        line = f.readline()
        if isinstance(line, bytes):
            line = line.decode('utf-8-sig')
        name, value = '', ''
        if line.isspace():
            return (name, value)
        if line.find('=') > 0:
            name, value = line.split('=', 1)
            name = name.rstrip().lower()
            value = value.strip()
        name = '' if any([c.isspace() for c in name]) else name
        if not name:
            raise ParsingError("Invalid file header line")
        return (name, value)
141158
def ParseMetadataFile(
      self, parser_mediator, file_entry, data_stream_name):
    
    parent_path_spec = getattr(file_entry.path_spec, 'parent', None)
    filename_upper = file_entry.name.upper()
    if (self._mft_parser and parent_path_spec and
        filename_upper in ('$MFT', '$MFTMIRR') and not data_stream_name):
      self._ParseDataStreamWithParser(
          parser_mediator, self._mft_parser, file_entry, '')

    elif (self._usnjrnl_parser and parent_path_spec and
          filename_upper == '$USNJRNL' and data_stream_name == '$J'):
      # To be able to ignore the sparse data ranges the UsnJrnl parser
      # needs to read directly from the volume.
      volume_file_object = path_spec_resolver.Resolver.OpenFileObject(
          parent_path_spec, resolver_context=parser_mediator.resolver_context)

      try:
        self._ParseFileEntryWithParser(
            parser_mediator, self._usnjrnl_parser, file_entry,
            file_object=volume_file_object)
      finally:
        volume_file_object.close()
879946
void readMeta() {
    final int check = buffer.getInt();
    if(check != MAGIC) {
      throw new AbortException("File does not start with expected magic.");
    }
    final int nummeta = buffer.getInt();
    assert (nummeta > 0) : "Empty bundle?";
    meta = new BundleMeta(nummeta);
    sers = new ByteBufferSerializer<?>[nummeta];
    data = new Object[nummeta];
    for(int i = 0; i < nummeta; i++) {
      try {
        @SuppressWarnings("unchecked")
        SimpleTypeInformation<? extends Object> type = (SimpleTypeInformation<? extends Object>) TypeInformationSerializer.STATIC.fromByteBuffer(buffer);
        sers[i] = type.getSerializer();
        if(i == 0 && DBID.class.isAssignableFrom(type.getRestrictionClass())) {
          hasids = true;
        }
        else {
          meta.add(type);
        }
      }
      catch(UnsupportedOperationException e) {
        throw new AbortException("Deserialization failed: " + e.getMessage(), e);
      }
      catch(IOException e) {
        throw new AbortException("IO error", e);
      }
    }
  }
1371594
def ID_from_data(self, ID_field='$SRC'):
        '''
        
        '''
        try:
            return self.get_meta_fields(ID_field)[ID_field]
        except KeyError:
            msg = "The keyword '{}' does not exist in the following FCS file: {}"
            msg = msg.format(ID_field, self.datafile)
            raise Exception(msg)