returns a :class:`DsetInfo` object containing the meta-data from ``dset``
164811
def dset_info(dset):
    ''''''
    if nl.pkg_available('afni'):
        return _dset_info_afni(dset)
    nl.notify('Error: no packages available to get dset info',level=nl.level.error)
    return None
1063458
def get_meta_fields(self, fields, kwargs={}):
        '''
        
        '''
        fields = to_list(fields)
        meta = self.get_meta()
        return {field: meta.get(field) for field in fields}
1274959
def extract_(dstore, dspath):
    
    obj = dstore[dspath]
    if isinstance(obj, Dataset):
        return ArrayWrapper(obj.value, obj.attrs)
    elif isinstance(obj, Group):
        return ArrayWrapper(numpy.array(list(obj)), obj.attrs)
    else:
        return obj
326310
def _get_coordinates_for_dataset_key(self, dsid):
        """"""
        ds_info = self.ids[dsid]
        cids = []

        for cinfo in ds_info.get('coordinates', []):
            if not isinstance(cinfo, dict):
                cinfo = {'name': cinfo}

            cinfo['resolution'] = ds_info['resolution']
            if 'polarization' in ds_info:
                cinfo['polarization'] = ds_info['polarization']
            cid = DatasetID(**cinfo)
            cids.append(self.get_dataset_key(cid))

        return cids
1329162
def metainfo_to_dict(self) -> dict:
        ''''''

        r = {
            "version": self.version,
            "amount": self.amount,
            "number_of_decimals": self.number_of_decimals
        }

        if self.asset_specific_data:
            r.update({'asset_specific_data': self.asset_specific_data})

        return r
347897
def meta(self):
        """"""
        if not self._pv.meta_data_property or not self._meta_target:
            return {}

        return getattr(self._meta_target, self._pv.meta_data_property)
878618
def _get_meta_data(self):
        """"""
        return {
            "comment": self.request.headers.get("comment", ""),
            "author": self.get_current_user() or self.settings.get('annonymous_user')
        }
840954
def packet_meta_data(self):
        """"""

        # For each packet in the pcap process the contents
        for item in self.input_stream:

            # Output object
            output = {}

            # Grab the fields I need
            timestamp = item['timestamp']
            buf = item['raw_buf']

            # Print out the timestamp in UTC
            output['timestamp'] = datetime.datetime.utcfromtimestamp(timestamp)

            # Unpack the Ethernet frame (mac src/dst, ethertype)
            eth = dpkt.ethernet.Ethernet(buf)
            output['eth'] = {'src': eth.src, 'dst': eth.dst, 'type':eth.type, 'len': len(eth)}

            # Grab packet data
            packet = eth.data

            # Packet Type ('EtherType') (IP, ARP, PPPoE, IP6... see http://en.wikipedia.org/wiki/EtherType)
            if hasattr(packet, 'data'):
                output['packet'] = {'type': packet.__class__.__name__, 'data': packet.data}
            else:
                output['packet'] = {'type': None, 'data': None}

            # It this an IP packet?
            if output['packet']['type'] == 'IP':

                # Pull out fragment information (flags and offset all packed into off field, so use bitmasks)
                df = bool(packet.off & dpkt.ip.IP_DF)
                mf = bool(packet.off & dpkt.ip.IP_MF)
                offset = packet.off & dpkt.ip.IP_OFFMASK

                # Pulling out src, dst, length, fragment info, TTL, checksum and Protocol
                output['packet'].update({'src':packet.src, 'dst':packet.dst, 'p': packet.p, 'len':packet.len, 'ttl':packet.ttl,
                                         'df':df, 'mf': mf, 'offset': offset, 'checksum': packet.sum})

            # Is this an IPv6 packet?
            elif output['packet']['type'] == 'IP6':

                # Pulling out the IP6 fields
                output['packet'].update({'src':packet.src, 'dst':packet.dst, 'p': packet.p, 'len':packet.plen, 'ttl':packet.hlim})

            # If the packet isn't IP or IPV6 just pack it as a dictionary
            else:
                output['packet'].update(data_utils.make_dict(packet))

            # For the transport layer we're going to set the transport to None. and
            # hopefully a 'link' upstream will manage the transport functionality
            output['transport'] = None

            # For the application layer we're going to set the application to None. and
            # hopefully a 'link' upstream will manage the application functionality
            output['application'] = None

            # All done
            yield output
871917
def get_metadata(dist):
    
    if not dist.has_metadata('PKG-INFO'):
        return

    msg = email.message_from_string(dist.get_metadata('PKG-INFO'))
    metadata = {}
    for header in [l for l in msg._headers]:
        metadata[header[0]] = header[1]

    return metadata
810822
def load_ds_ids_from_config(self):
        """"""
        ids = []
        for dataset in self.datasets.values():
            # xarray doesn't like concatenating attributes that are lists
            # https://github.com/pydata/xarray/issues/2060
            if 'coordinates' in dataset and \
                    isinstance(dataset['coordinates'], list):
                dataset['coordinates'] = tuple(dataset['coordinates'])
            # Build each permutation/product of the dataset
            id_kwargs = []
            for key in DATASET_KEYS:
                val = dataset.get(key)
                if key in ["wavelength", "modifiers"] and isinstance(val,
                                                                     list):
                    # special case: wavelength can be [min, nominal, max]
                    # but is still considered 1 option
                    # it also needs to be a tuple so it can be used in
                    # a dictionary key (DatasetID)
                    id_kwargs.append((tuple(val), ))
                elif key == "modifiers" and val is None:
                    # empty modifiers means no modifiers applied
                    id_kwargs.append((tuple(), ))
                elif isinstance(val, (list, tuple, set)):
                    # this key has multiple choices
                    # (ex. 250 meter, 500 meter, 1000 meter resolutions)
                    id_kwargs.append(val)
                elif isinstance(val, dict):
                    id_kwargs.append(val.keys())
                else:
                    # this key only has one choice so make it a one
                    # item iterable
                    id_kwargs.append((val, ))
            for id_params in itertools.product(*id_kwargs):
                dsid = DatasetID(*id_params)
                ids.append(dsid)

                # create dataset infos specifically for this permutation
                ds_info = dataset.copy()
                for key in DATASET_KEYS:
                    if isinstance(ds_info.get(key), dict):
                        ds_info.update(ds_info[key][getattr(dsid, key)])
                    # this is important for wavelength which was converted
                    # to a tuple
                    ds_info[key] = getattr(dsid, key)
                self.ids[dsid] = ds_info

        return ids
535338
def metainfo_to_dict(self) -> dict:
        ''''''

        r = {
            "version": self.version,
            "name": self.name,
            "number_of_decimals": self.number_of_decimals,
            "issue_mode": self.issue_mode
        }

        if self.asset_specific_data:
            r.update({'asset_specific_data': self.asset_specific_data})

        return r
876451
def _find_bad_meta(self):
        ''''''
        self._badmeta = dict()

        for datatype in self.meta:
            for item in self.meta[datatype]:
                if not Dap._meta_valid[datatype].match(item):
                    if datatype not in self._badmeta:
                        self._badmeta[datatype] = []
                    self._badmeta[datatype].append(item)
253746
def get_meta_data(self, request_adu):
        "
        try:
            transaction_id, protocol_id, length, unit_id = \
                unpack_mbap(request_adu[:7])
        except struct.error:
            raise ServerDeviceFailureError()

        return {
            'transaction_id': transaction_id,
            'protocol_id': protocol_id,
            'length': length,
            'unit_id': unit_id,
        }
31697
def read_meta(self, f):
        
        if not isinstance(f, BacktrackableFile):
            f = BacktrackableFile(f)

        try:
            (name, value) = self.read_meta_line(f)
            while name:
                name = (name == 'nominal_offset' and 'timestamp_rounding' or
                        name)
                name = (name == 'actual_offset' and 'timestamp_offset' or name)
                method_name = 'get_{}'.format(name)
                method = getattr(self, method_name, None)
                if method:
                    method(name, value)
                name, value = self.read_meta_line(f)
                if not name and not value:
                    break
        except ParsingError as e:
            e.args = e.args + (f.line_number,)
            raise
446345
def _get_dsnames(cls, data, ignore_keys=['attrs', 'plotter', 'ds'],
                     concat_dim=False):
        """"""
        def filter_ignores(item):
            return item[0] not in ignore_keys and isinstance(item[1], dict)
        if 'fname' in data:
            return {tuple(
                [data['fname'], data['store']] +
                ([data.get('concat_dim')] if concat_dim else []))}
        return set(chain(*map(partial(cls._get_dsnames, concat_dim=concat_dim,
                                      ignore_keys=ignore_keys),
                              dict(filter(filter_ignores,
                                          six.iteritems(data))).values())))
1086290
def mapper(self, meta_data, instance):
        
        d = dict(meta_data)
        v = d.pop(self.aggregation_meta_data)
        instance = deepcopy(instance)
        instance.value[self.aggregation_meta_data] = v
        return instance
1109030
def get_dataset(dataset_name):
    
    # mnist
    if dataset == "mnist":
        train_data = gluon.data.DataLoader(
            gluon.data.vision.MNIST('./data', train=True, transform=transformer),
            batch_size, shuffle=True, last_batch='discard')

        val_data = gluon.data.DataLoader(
            gluon.data.vision.MNIST('./data', train=False, transform=transformer),
            batch_size, shuffle=False)
    # cifar10
    elif dataset == "cifar10":
        train_data = gluon.data.DataLoader(
            gluon.data.vision.CIFAR10('./data', train=True, transform=transformer),
            batch_size, shuffle=True, last_batch='discard')

        val_data = gluon.data.DataLoader(
            gluon.data.vision.CIFAR10('./data', train=False, transform=transformer),
            batch_size, shuffle=False)

    return train_data, val_data