<commit_before>"""
Post
----
"""

# Author:	<NAME>
#        	http://les-ejk.cz
# Lince:
#
# Web Processing Service implementation
# Copyright (C) 2006 <NAME>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA

import types,sys
import xml
from xml.dom.minidom import parseString
import pywps
from pywps.Parser import Parser
from pywps.Process.Lang import Lang
from pywps import Soap 

class Post(Parser):
    """Main class for parsing of HTTP POST request types
    
    .. attribute:: document
    
        DOM of input document
    
    .. attribute:: requestParser

        :class:`pywps.Parser.GetCapabilities`, :class:`pywps.Parser.DescribeProcess` 
        or :class:`pywps.Parser.Execute`

    """

    document = None # Document Object Model
    requestParser = None

    GET_CAPABILITIES = "GetCapabilities"
    DESCRIBE_PROCESS = "DescribeProcess"
    EXECUTE = "Execute"

    def __init__(self,wps):
        Parser.__init__(self,wps)

    def parse(self,file):
        """Parse parameters stored as XML file

        :param file: input file object
        :return: parsed input object
        """

        maxFileSize = None
        inputXml = None

        # get the maximal input file size from configuration
        maxFileSize = self.getMaxFileSize(
                pywps.config.getConfigValue("server","maxFileSize").lower())

        # read the document
        if maxFileSize > 0:
            inputXml = file.read(maxFileSize)
            if file.read() != "":
                raise pywps.FileSizeExceeded()
        else:
            inputXml = file.read()

        # make DOM from XML
        try:<commit_msg>java support for HTTP POST parsing<commit_after>"""
Post
----
"""

# Author:	<NAME>
#        	http://les-ejk.cz
# Lince:
#
# Web Processing Service implementation
# Copyright (C) 2006 <NAME>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA

import types,sys
import xml
from xml.dom.minidom import parseString
import pywps
from pywps.Parser import Parser
from pywps.Process.Lang import Lang
from pywps import Soap 
from os import name as OSNAME

class Post(Parser):
    """Main class for parsing of HTTP POST request types
    
    .. attribute:: document
    
        DOM of input document
    
    .. attribute:: requestParser

        :class:`pywps.Parser.GetCapabilities`, :class:`pywps.Parser.DescribeProcess` 
        or :class:`pywps.Parser.Execute`

    """

    document = None # Document Object Model
    requestParser = None

    GET_CAPABILITIES = "GetCapabilities"
    DESCRIBE_PROCESS = "DescribeProcess"
    EXECUTE = "Execute"

    def __init__(self,wps):
        Parser.__init__(self,wps)

    def parse(self,file):
        """Parse parameters stored as XML file

        :param file: input file object or class:`java.io.BufferedReader`
        :return: parsed input object
        """

        maxFileSize = None
        inputXml = None

        # get the maximal input file size from configuration
        maxFileSize = self.getMaxFileSize(
                pywps.config.getConfigValue("server","maxFileSize").lower())

        # read the document
        if OSNAME == "java":
            inputXml = ""
            while 1:
                line = file.readLine()
                if line is Null:
                    break
                inputXml += line
                if maxFileSize > 0 and\
                    inputXml.__sizeof__() > maxFileSize:
                    raise pywps.FileSizeExceeded()
        else:
            if maxFileSize > 0:
                inputXml = file.read(maxFileSize)
                if file.read() != "":
                    raise pywps.FileSizeExceeded()
            else:
                inputXml = file.read()

        # make DOM from XML
        try:
{'fraction_non_alphanumeric': 0.07980652962515115, 'fraction_numerical': 0.007255139056831923, 'mean_word_length': 2.4393624393624393, 'pattern_counts': {'":': 3, '<': 7, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 4}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6774095', 'n_tokens_mistral': 1392, 'n_tokens_neox': 1311, 'n_words': 502}