Build dictionary of content
16980
def render_to_response(self, context, *args, **kwargs):
        
        preview_outputs = []
        file_outputs = []
        bast_ctx = context
        added = set()

        for output_group, output_files in context['job_info']['file_groups'].items():
            for output_file_content in output_files:
                if output_group:
                    bast_ctx.update({
                        'job_info': context['job_info'],
                        'output_group': output_group,
                        'output_file_content': output_file_content,
                    })
                    preview = render_to_string('wooey/preview/%s.html' % output_group, bast_ctx)
                    preview_outputs.append(preview)

        for file_info in context['job_info']['all_files']:
            if file_info and file_info.get('name') not in added:
                row_ctx = dict(
                    file=file_info,
                    **context
                )
                table_row = render_to_string('wooey/jobs/results/table_row.html', row_ctx)
                file_outputs.append(table_row)
                added.add(file_info.get('name'))

        return JsonResponse({
            'status': context['job_info']['status'].lower(),
            'command': context['job_info']['job'].command,
            'stdout': context['job_info']['job'].get_stdout(),
            'stderr': context['job_info']['job'].get_stderr(),
            'preview_outputs_html': preview_outputs,
            'file_outputs_html': file_outputs,
        })
707923
def contents(self):
        """"""
        rslt = []
        for (dpos, dlen, ulen, flag, typcd, nm) in self.toc:
            rslt.append(nm)
        return rslt
216465
def build_dictionary(self):
        
        d = {}
        for t in self.all_tags_of_type(DefinitionTag, recurse_into_sprites = False):
            if t.characterId in d:
                #print 'redefinition of characterId %d:' % (t.characterId)
                #print '  was:', d[t.characterId]
                #print 'redef:', t
                raise ValueError('illegal redefinition of character')
            d[t.characterId] = t
        return d
167979
def content(self):
        """"""
        content_list = wrap_list(self._content_preprocessed)
        content_list.extend(self._content_stash)
        content_to_render = '\n'.join(content_list)
        return typogrify(self.content_renderer.render(content_to_render, self.format))
1150547
def _to_dict(self):
        """"""
        _dict = {}
        if hasattr(self, 'exclude_tags_completely'
                  ) and self.exclude_tags_completely is not None:
            _dict['exclude_tags_completely'] = self.exclude_tags_completely
        if hasattr(self, 'exclude_tags_keep_content'
                  ) and self.exclude_tags_keep_content is not None:
            _dict['exclude_tags_keep_content'] = self.exclude_tags_keep_content
        if hasattr(self, 'keep_content') and self.keep_content is not None:
            _dict['keep_content'] = self.keep_content._to_dict()
        if hasattr(self,
                   'exclude_content') and self.exclude_content is not None:
            _dict['exclude_content'] = self.exclude_content._to_dict()
        if hasattr(
                self,
                'keep_tag_attributes') and self.keep_tag_attributes is not None:
            _dict['keep_tag_attributes'] = self.keep_tag_attributes
        if hasattr(self, 'exclude_tag_attributes'
                  ) and self.exclude_tag_attributes is not None:
            _dict['exclude_tag_attributes'] = self.exclude_tag_attributes
        return _dict
228636
def apdu_contents(self, use_dict=None, as_class=dict):
        """"""
        if _debug: APCISequence._debug("apdu_contents use_dict=%r as_class=%r", use_dict, as_class)

        # make/extend the dictionary of content
        if use_dict is None:
            use_dict = as_class()

        # set the function based on the class name
        use_dict.__setitem__('function', self.__class__.__name__)

        # fill in from the sequence contents
        Sequence.dict_contents(self, use_dict=use_dict, as_class=as_class)

        # return what we built/updated
        return use_dict
1337162
def _createDataStructure(self, content):
        
        aux = {}
        aux["headers"] = {}
        aux["content"] = ""
        for i, line in enumerate(content.splitlines()):
            if i == 0:
                aux["procotol"] = line.split()[0]
                aux["code"] = line.split()[1]
            elif line != "":
                header =  line.split(": ")[0]
                aux["headers"][header] = line[line.find(": ")+2:]
            else:
                aux["content"] += self._rebuildHTMLContent(content.splitlines()[i+1:])
                
                # TO-DO: Perform additional processing of the HTML
                
                break  
        return aux
243613
def dict_contents(self, use_dict=None, as_class=dict):
        """"""
        if _debug: Any._debug("dict_contents use_dict=%r as_class=%r", use_dict, as_class)

        # result will be a list
        rslt_list = []

        # loop through the tags
        for tag in self.tagList:
            # build a tag thing
            use_dict = as_class()

            # save the pieces
            use_dict.__setitem__('class', tag.tagClass)
            use_dict.__setitem__('number', tag.tagNumber)
            use_dict.__setitem__('lvt', tag.tagLVT)

            ### use_dict.__setitem__('data', '.'.join('%02X' % ord(c) for c in tag.tagData))

            # add it to the list
            rslt_list = use_dict

        # return what we built
        return rslt_list
917463
def _to_dict(self):
        """"""
        _dict = {}
        if hasattr(self, 'limit') and self.limit is not None:
            _dict['limit'] = self.limit
        if hasattr(self, 'keywords') and self.keywords is not None:
            _dict['keywords'] = self.keywords
        if hasattr(self, 'entities') and self.entities is not None:
            _dict['entities'] = self.entities
        return _dict
307834
def mk_dict(results,description):
    """"""
    
    rows=[]
    for row in results:
        row_dict={}
        for idx in range(len(row)):
            col=description[idx][0]
            row_dict[col]=row[idx]
        rows.append(row_dict)
    return rows
951906
def py2dict(elements):
    """"""
    metadata_dict = {}
    # Loop through all elements in the Python object.
    for element in elements.children:
        # Start an empty element list if an entry for the element
        # list hasn't been made in the dictionary.
        if element.tag not in metadata_dict:
            metadata_dict[element.tag] = []
        element_dict = {}
        if hasattr(element, 'qualifier') and element.qualifier is not None:
            element_dict['qualifier'] = element.qualifier
        # Set the element's content as a dictionary
        # of children elements.
        if len(element.children) > 0:
            child_dict = {}
            for child in element.children:
                if child.content is not None:
                    child_dict[child.tag] = child.content
            element_dict['content'] = child_dict
        # Set element content that is not children.
        elif element.content is not None:
            if element.content.strip() != '':
                element_dict['content'] = element.content
        # Append the dictionary to the element list
        # if the element has content or children.
        if element_dict.get('content', False):
            metadata_dict[element.tag].append(element_dict)

    return metadata_dict
757265
def _to_dict(self):
        """"""
        _dict = {}
        if hasattr(self, 'num_pages') and self.num_pages is not None:
            _dict['num_pages'] = self.num_pages
        if hasattr(self, 'author') and self.author is not None:
            _dict['author'] = self.author
        if hasattr(self,
                   'publication_date') and self.publication_date is not None:
            _dict['publication_date'] = self.publication_date
        if hasattr(self, 'title') and self.title is not None:
            _dict['title'] = self.title
        if hasattr(self, 'html') and self.html is not None:
            _dict['html'] = self.html
        return _dict
681906
def _buildDict(self):
        '''
        
        '''
        lexDict = {}
        with io.open(self.islePath, "r", encoding='utf-8') as fd:
            wordList = [line.rstrip('\n') for line in fd]
        
        for row in wordList:
            word, pronunciation = row.split(" ", 1)
            word, extraInfo = word.split("(", 1)
            
            extraInfo = extraInfo.replace(")", "")
            extraInfoList = [segment for segment in extraInfo.split(",")
                             if ("_" not in segment and "+" not in segment and
                                 ':' not in segment and segment != '')]
            
            lexDict.setdefault(word, [])
            lexDict[word].append((pronunciation, extraInfoList))
        
        return lexDict
361362
def load_dict(self, dct):
        """"""
        for k, v in dct.items():
            setattr(self, k, v)
231219
def buildcontent(self):
        """"""

        self.buildcontainer()
        self.option = json.dumps(self.options, cls = HighchartsEncoder)
        self.setoption = json.dumps(self.setOptions, cls = HighchartsEncoder) 
        self.data = json.dumps(self.data_temp, cls = HighchartsEncoder)

        # DEM 2017/04/25: Make 'data' available as an array
        # ... this permits jinja2 array access to each data definition
        # ... which is useful for looping over multiple data sources
        self.data_list = [json.dumps(x, cls = HighchartsEncoder) for x in self.data_temp]
        
        if self.navi_seri_flag:        
            self.navi_seri = json.dumps(self.navi_seri_temp, cls = HighchartsEncoder)

        self._htmlcontent = self.template_content_highcharts.render(chart=self).encode('utf-8')
572337
def _build_dictionary(self, results):
        
        foreign = self._first_key

        dictionary = {}

        for result in results:
            key = getattr(result, foreign)
            if key not in dictionary:
                dictionary[key] = []

            dictionary[key].append(result)

        return dictionary
531611
def _from_dict(cls, _dict):
        """"""
        args = {}
        if 'type' in _dict:
            args['type'] = _dict.get('type')
        if 'text' in _dict:
            args['text'] = _dict.get('text')
        if 'relevance' in _dict:
            args['relevance'] = _dict.get('relevance')
        if 'mentions' in _dict:
            args['mentions'] = [
                EntityMention._from_dict(x) for x in (_dict.get('mentions'))
            ]
        if 'count' in _dict:
            args['count'] = _dict.get('count')
        if 'emotion' in _dict:
            args['emotion'] = EmotionScores._from_dict(_dict.get('emotion'))
        if 'sentiment' in _dict:
            args['sentiment'] = FeatureSentimentResults._from_dict(
                _dict.get('sentiment'))
        if 'disambiguation' in _dict:
            args['disambiguation'] = DisambiguationResult._from_dict(
                _dict.get('disambiguation'))
        return cls(**args)