Return the python representation of the document
431765
def as_python(self, infile, include_original_shex: bool=False):
        
        self._context.resolve_circular_references()            # add forwards for any circular entries
        body = ''
        for k in self._context.ordered_elements():
            v = self._context.grammarelts[k]
            if isinstance(v, (JSGLexerRuleBlock, JSGObjectExpr)):
                body += v.as_python(k)
                if isinstance(v, JSGObjectExpr) and not self._context.has_typeid:
                    self._context.directives.append(f'_CONTEXT.TYPE_EXCEPTIONS.append("{k}")')
            elif isinstance(v, JSGForwardRef):
                pass
            elif isinstance(v, (JSGValueType, JSGArrayExpr)):
                body += f"\n\n\n{k} = {v.signature_type()}"
            else:
                raise NotImplementedError("Unknown grammar elt for {}".format(k))
            self._context.forward_refs.pop(k, None)

        body = '\n' + '\n'.join(self._context.directives) + body
        return _jsg_python_template.format(infile=infile,
                                           original_shex='# ' + self.text if include_original_shex else "",
                                           version=__version__,
                                           gendate=datetime.datetime.now().strftime("%Y-%m-%d %H:%M"),
                                           body=body)
252865
def to_array(self):
        
        array = super(InlineQueryResultCachedDocument, self).to_array()
        # 'type' and 'id' given by superclass
        array['title'] = u(self.title)  # py2: type unicode, py3: type str
        array['document_file_id'] = u(self.document_file_id)  # py2: type unicode, py3: type str
        if self.description is not None:
            array['description'] = u(self.description)  # py2: type unicode, py3: type str
        if self.caption is not None:
            array['caption'] = u(self.caption)  # py2: type unicode, py3: type str
        if self.parse_mode is not None:
            array['parse_mode'] = u(self.parse_mode)  # py2: type unicode, py3: type str
        if self.reply_markup is not None:
            array['reply_markup'] = self.reply_markup.to_array()  # type InlineKeyboardMarkup
        if self.input_message_content is not None:
            array['input_message_content'] = self.input_message_content.to_array()  # type InputMessageContent
        return array
552613
def get_mime_representation(self):
        """"""
        part = deepcopy(self.part)
        part.set_param('maxlinelen', '78', header='Content-Disposition')
        return part
861622
def document(self):
        """"""
        request = self._py_object.request
        resp = request.environ.get('pylons.original_response')
        content = literal(resp.body) or cgi.escape(request.GET.get('message', ''))

        page = """<!DOCTYPE html>
<html lang="en">
    <head>
        <title>NIPAP error</title>
        <meta charset="utf-8">
        <link rel="stylesheet" href="/nipap.css">
    </head>
    <body>
        <div class="top_menu">
            <div class="menu_entry" style="line-height: 0px">
                <div class="menu_entry" style="font-size: 10pt; color: #CCCCCC; padding-top: 11px; font-weight: bold;">
                NIPAP ERROR
                </div>
            </div>
        </div>
        <div class="content_outer">
            <div class="content_inner">
                <p>%s</p>
                <p>Relevant information has been forwarded to the system administrator.</p>
            </div>
			<div style="height: 500px;"> &nbsp; </div>
        </div>
    </body>
</html>""" % content

        # If the error was raised from the XhrController, return HTML-less response
        if type(request.environ['pylons.original_request'].environ.get('pylons.controller')) == XhrController:
            return content
        else:
            return page
197552
def doc(self):
        """"""
        if hasattr(self, '_doc'):
            return self._doc
        elements = self.etree
        doc = self._doc = PyQuery(elements)
        doc.make_links_absolute(utils.text(self.url))
        return doc
1326454
def to_array(self):
        
        array = super(Document, self).to_array()
        array['file_id'] = u(self.file_id)  # py2: type unicode, py3: type str

        if self.thumb is not None:
            array['thumb'] = self.thumb.to_array()  # type PhotoSize

        if self.file_name is not None:
            array['file_name'] = u(self.file_name)  # py2: type unicode, py3: type str

        if self.mime_type is not None:
            array['mime_type'] = u(self.mime_type)  # py2: type unicode, py3: type str

        if self.file_size is not None:
            array['file_size'] = int(self.file_size)  # type int
        return array
1349301
def get_document_list(self):
        
        try:
            return self.__dict__['document_list']
        except KeyError:
            obj_list = DocumentSet([
                self._connection.documents.get(i) for i in self.document_ids
            ])
            self.__dict__['document_list'] = obj_list
            return obj_list
1044463
def _to_dict(self):
        """"""
        _dict = {}
        if hasattr(self, 'document_id') and self.document_id is not None:
            _dict['document_id'] = self.document_id
        if hasattr(self,
                   'configuration_id') and self.configuration_id is not None:
            _dict['configuration_id'] = self.configuration_id
        if hasattr(self, 'status') and self.status is not None:
            _dict['status'] = self.status
        if hasattr(
                self,
                'status_description') and self.status_description is not None:
            _dict['status_description'] = self.status_description
        if hasattr(self, 'filename') and self.filename is not None:
            _dict['filename'] = self.filename
        if hasattr(self, 'file_type') and self.file_type is not None:
            _dict['file_type'] = self.file_type
        if hasattr(self, 'sha1') and self.sha1 is not None:
            _dict['sha1'] = self.sha1
        if hasattr(self, 'notices') and self.notices is not None:
            _dict['notices'] = [x._to_dict() for x in self.notices]
        return _dict
697818
def description(self):
        """"""
        try:
            return self.__cog_cleaned_doc__
        except AttributeError:
            self.__cog_cleaned_doc__ = cleaned = inspect.getdoc(self)
            return cleaned
1226274
def serialize(self):
        """"""
        data = {'doc': self.doc}
        if isinstance(self.query, Query):
            data['query'] = self.query.serialize()
        return data
1275795
function(doc) {
        var node_list = doc.getElementsByTagName("node");
        var nodes = {};
        for (var i = 0; i < node_list.length; i++) {
            var node = node_list[i];
            var id = node.getAttribute("id");
            nodes[id] = {
                'lat': node.getAttribute("lat"),
                'lon': node.getAttribute("lon"),
                'node': node
            };
        }
        return nodes;
    }
976337
def _to_dict(self):
        """"""
        _dict = {}
        if hasattr(self, 'document_label') and self.document_label is not None:
            _dict['document_label'] = self.document_label
        if hasattr(self, 'location') and self.location is not None:
            _dict['location'] = self.location._to_dict()
        if hasattr(self, 'text') and self.text is not None:
            _dict['text'] = self.text
        if hasattr(self, 'types') and self.types is not None:
            _dict['types'] = [x._to_dict() for x in self.types]
        if hasattr(self, 'categories') and self.categories is not None:
            _dict['categories'] = [x._to_dict() for x in self.categories]
        if hasattr(self, 'attributes') and self.attributes is not None:
            _dict['attributes'] = [x._to_dict() for x in self.attributes]
        return _dict
866818
def _to_dict(self):
        """"""
        _dict = {}
        if hasattr(self, 'document') and self.document is not None:
            _dict['document'] = self.document
        if hasattr(self, 'targets') and self.targets is not None:
            _dict['targets'] = self.targets
        return _dict
702649
def _get_span(self, m):
        
        return (m.figure.document.id, m.figure.position)
779995
def _get_docstring(self):
        """"""
        left = self.position
        while left:
            if self.source_code[left: left + 3] in ['"""', "'''"]:
                left += 3
                break
            left -= 1
        right = self.position
        while right < len(self.source_code):
            if self.source_code[right - 3: right] in ['"""', "'''"]:
                right -= 3
                break
            right += 1
        if left and right < len(self.source_code):
            return self.source_code[left: right]
        return ''
1151242
def __get_name(self):
        
        if self.is_new:
            return _("New document")
        try:
            split = self.__docid.split("_")
            short_docid = "_".join(split[:3])
            datetime_obj = datetime.datetime.strptime(
                short_docid, self.DOCNAME_FORMAT)
            final = datetime_obj.strftime("%x")
            return final
        except Exception as exc:
            logger.error("Unable to parse document id [%s]: %s"
                         % (self.docid, exc))
            return self.docid
314839
def to_query(self):
        
        return {
            self.name: {
                'lang': self.lang,
                'script': self.script,
                'params': self.script_params
            }
        }