Parses a Tv Series
    returns the dataset as a dictionary
433243
def parse(link):
    
    html = get_html(link)

    data = {'rating': get_rating(html),
            'name': get_name_date(html)[0]}

    div = html.find(id="title-episode-widget")
    season_tags = get_a(div, find="season=")
    episodes = {}
    for slink in season_tags:
        for e in episode_list(slink):
            season, d = parse_episode(e)
            if season in episodes:
                episodes[season].append(d)
            else:
                episodes[season] = [d]
    data['episodes'] = episodes
    return data
66173
def parse(resp) -> DataFrameType:
    """"""
    statements = []
    for statement in resp['results']:
        series = {}
        for s in statement.get('series', []):
            series[_get_name(s)] = _drop_zero_index(_serializer(s))
        statements.append(series)

    if len(statements) == 1:
        series: dict = statements[0]
        if len(series) == 1:
            return list(series.values())[0]  # DataFrame
        else:
            return series  # dict
    return statements
920871
def get_dataset(self, key, info):
        """"""
        logger.debug("Reading %s.", key)
        return self.file_content[key.name]
303452
def parse_to_dict(self):
        
        lst = []
        with open(self.fname, 'r') as f:
            hdr = f.readline()
            self.hdrs = hdr.split(',')
            #print("self.hdrs = ", self.hdrs)
            for line in f:
                cols = line.split(',')
                if len(cols) == len(self.hdrs):
                    #print(cols)
                    d = {}
                    for ndx, col_header in enumerate(self.hdrs):
                        #d[self.hdrs[ndx].strip('\n').strip()] = cols[ndx].strip('\n').strip()
                        d[col_header.strip('\n').strip()] = cols[ndx].strip('\n').strip()
                        
                    lst.append(d)
                else:
                    print("Error parsing " + self.fname + " line : " + line)
        return lst
1198313
def load_sampleset(self, f, name):
        ''''''
        self.encoder_x = np.array(f[name + '_encoder_x'])
        self.decoder_x = np.array(f[name + '_decoder_x'])
        self.decoder_y = np.array(f[name + '_decoder_y'])
593990
def to_dict(self, data=True):
        """"""
        item = {'dims': self.dims,
                'attrs': decode_numpy_dict_values(self.attrs)}
        if data:
            item['data'] = ensure_us_time_resolution(self.values).tolist()
        else:
            item.update({'dtype': str(self.dtype), 'shape': self.shape})
        return item
417458
def to_dict(self, trim=True):
        """"""
        if trim:
            return self._to_trimmed_dict()
        else:
            return dict(zip(DATASET_KEYS, self))
159741
def __parseDatasets(self):
        """"""
        datasets = []
        if self.__dataItem.has_key('dataSets'):
            for dataset in self.__dataItem['dataSets']:
                datasets.append(DataSet(Sitools2Abstract.getBaseUrl(self), dataset))
        return datasets
1071910
def __hdr2dict(self):
        
        with open(self.filename, 'r') as infile:
            lines = infile.readlines()
        i = 0
        out = dict()
        while i < len(lines):
            line = lines[i].strip('\r\n')
            if '=' in line:
                if '{' in line and '}' not in line:
                    while '}' not in line:
                        i += 1
                        line += lines[i].strip('\n').lstrip()
                line = list(filter(None, re.split(r'\s+=\s+', line)))
                line[1] = re.split(',[ ]*', line[1].strip('{}'))
                key = line[0].replace(' ', '_')
                val = line[1] if len(line[1]) > 1 else line[1][0]
                out[key] = parse_literal(val)
            i += 1
        if 'band_names' in out.keys() and not isinstance(out['band_names'], list):
            out['band_names'] = [out['band_names']]
        return out
742501
def get_dataset(self, key, info):
        """"""
        logger.debug('Reading dataset {}'.format(key.name))

        # Read data from file and calibrate if necessary
        if 'longitude' in key.name:
            data = self.nc['lon']
        elif 'latitude' in key.name:
            data = self.nc['lat']
        else:
            raise KeyError("Unknown dataset: {}".format(key.name))

        # Set proper dimension names
        data = data.rename({'xc': 'x', 'yc': 'y'})

        # Update metadata
        data.attrs.update(info)
        return data
447011
def _from_dict(cls, _dict):
        """"""
        args = {}
        if 'examples' in _dict:
            args['examples'] = [
                TrainingExample._from_dict(x) for x in (_dict.get('examples'))
            ]
        return cls(**args)
737170
def to_dict(self):
        

        result = self.to_identifier()

        result.update({
            'title': self.title,

            'watched': 1 if self.is_watched else 0,
            'collected': 1 if self.is_collected else 0,

            'plays': self.plays if self.plays is not None else 0,
            'in_watchlist': self.in_watchlist if self.in_watchlist is not None else 0,
            'progress': self.progress,

            'last_watched_at': to_iso8601_datetime(self.last_watched_at),
            'collected_at': to_iso8601_datetime(self.collected_at),
            'paused_at': to_iso8601_datetime(self.paused_at),

            'ids': dict([
                (key, value) for (key, value) in self.keys[1:]  # NOTE: keys[0] is the (<season>, <episode>) identifier
            ])
        })

        if self.rating:
            result['rating'] = self.rating.value
            result['rated_at'] = to_iso8601_datetime(self.rating.timestamp)

        # Extended Info
        if self.first_aired:
            result['first_aired'] = to_iso8601_datetime(self.first_aired)

        if self.updated_at:
            result['updated_at'] = to_iso8601_datetime(self.updated_at)

        if self.overview:
            result['overview'] = self.overview

        if self.available_translations:
            result['available_translations'] = self.available_translations

        return result
1362709
def datasetItems(self):
        
        out = {}
        for item in self.items():
            if isinstance(item, XChartDatasetItem):
                out[item.dataset()] = item
        return out
543492
def _parse_example(serialized_example):
  """"""
  data_fields = {
      "inputs": tf.VarLenFeature(tf.int64),
      "targets": tf.VarLenFeature(tf.int64)
  }
  parsed = tf.parse_single_example(serialized_example, data_fields)
  inputs = tf.sparse_tensor_to_dense(parsed["inputs"])
  targets = tf.sparse_tensor_to_dense(parsed["targets"])
  return inputs, targets
570458
def data_to_dict(self, sysbase=False):
        
        assert isinstance(sysbase, bool)

        ret = {}

        for key in self.data_keys:
            if (not sysbase) and (key in self._store):
                val = self._store[key]
            else:
                val = self.__dict__[key]

            ret[key] = val

        return ret
917431
def result_to_dict(raw_result):
    

    result = {}

    for channel_index, channel in enumerate(raw_result):
        channel_id, channel_name = channel[0], channel[1]
        channel_result = {
            'id': channel_id,
            'name': channel_name,
            'movies': []
        }
        for movie in channel[2]:
            channel_result['movies'].append({
                'title': movie[1],
                'start_time': datetime.fromtimestamp(movie[2]),
                'end_time': datetime.fromtimestamp(movie[2] + movie[3]),
                'inf': True if movie[3] else False,
            })
        result[channel_id] = channel_result

    return result
984239
def parse_tstv_summary(self):
        

        self.vcftools_tstv_summary = dict()
        for f in self.find_log_files('vcftools/tstv_summary', filehandles=True):
            d = {}
            for line in f['f'].readlines()[1:]: # don't add the header line (first row)
                key = line.split()[0] # taking the first column (MODEL) as key
                val = int(line.split()[1]) # taking the second column (COUNT) as value
                d[key] = val
            self.vcftools_tstv_summary[f['s_name']] = d

        # Filter out ignored sample names
        self.vcftools_tstv_summary = self.ignore_samples(self.vcftools_tstv_summary)

        if len(self.vcftools_tstv_summary) == 0:
            return 0

        # Specifying the categories of the bargraph
        keys = OrderedDict()
        keys = ['AC', 'AG', 'AT', 'CG', 'CT', 'GT', 'Ts', 'Tv']

        pconfig = {
            'id': 'vcftools_tstv_summary',
            'title': 'VCFTools: TsTv Summary',
            'ylab': 'Counts',
        }

        self.add_section(
            name = 'TsTv Summary',
            anchor = 'vcftools-tstv-summary',
            description = "Plot of `TSTV-SUMMARY` - count of different types of transition and transversion SNPs.",
            plot = bargraph.plot(self.vcftools_tstv_summary,keys,pconfig)
        )

        return len(self.vcftools_tstv_summary)