Exemple #1
0
    def get(self):
        start_time = time.time()
        guess = None

        if self.request.arguments() == []:
            self.render("help.html")
            return

        mnemonic = self.request.get('mnemonic') or ''
        method = self.request.get('method') or 'simple'
        # Keep backward compatible for now and look for guesses parameter
        limit = self.request.get('guesses') or self.request.get('limit') or 1
        maxdist = self.request.get('maxdist') or 1

        guess = fuzzylas.guess(
            curves,
            mnemonic.upper(),
            method.lower(),
            limit=limit,
            maxdist=maxdist,
        )

        response = {
            "mnemonic": mnemonic,
            "method": method,
            "limit": limit,
            "maxdist": maxdist,
            "time": time.time() - start_time,
            "result": guess
        }

        self.response.headers['Content-Type'] = 'application/vnd.api+json'
        self.response.out.write(json.dumps(response))
        return
Exemple #2
0
 def post(self):
     mnemonic = self.request.get('mnemonic').upper()
     guess = fuzzylas.guess(curves, mnemonic, 'simple', limit=3, maxdist=1)
     if guess is not None:
         self.render("index.html", mnemonic=mnemonic, result=guess)
     else:
         self.reponse.out.write("Oops, something went wrong.")
Exemple #3
0
 def post(self):
     input = self.request.get('mnemonic').upper()
     guess = fuzzylas.guess(curves, input, 'simple', 3)
     self.render("index.html",
                 input=input,
                 result=guess[0],
                 order=sorted(guess[1], key=guess[1].get))
Exemple #4
0
    def get(self):
        start_time = time.time()
        guess = None

        if self.request.arguments() == []:
            self.render("help.html")
            return

        mnemonic = self.request.get('mnemonic') or ''
        method = self.request.get('method') or 'simple'
        # Keep backward compatible for now and look for guesses parameter
        limit = self.request.get('guesses') or self.request.get('limit') or 1
        maxdist = self.request.get('maxdist') or 1

        guess = fuzzylas.guess(curves,
                               mnemonic.upper(),
                               method.lower(),
                               limit=limit,
                               maxdist=maxdist,
                               )

        response = {
            "mnemonic": mnemonic,
            "method": method,
            "limit": limit,
            "maxdist": maxdist,
            "time": time.time() - start_time,
            "result": guess
        }

        self.response.headers['Content-Type'] = 'application/vnd.api+json'
        self.response.out.write(json.dumps(response))
        return
Exemple #5
0
 def post(self):
     mnemonic = self.request.get('mnemonic').upper()
     guess = fuzzylas.guess(curves, mnemonic, 'simple', limit=3, maxdist=1)
     if guess is not None:
         self.render("index.html", mnemonic=mnemonic, result=guess)
     else:
         self.reponse.out.write("Oops, something went wrong.")
Exemple #6
0
    def get(self):

        guess = None

        if self.request.arguments() == []:
            self.render("help.html")

        else:
            mnemonic = self.request.get('mnemonic')
            method = self.request.get('method')
            format = self.request.get('format')
            guesses = self.request.get('guesses')

            if mnemonic:
                mnemonic = mnemonic.upper()
            else:
                mnemonic = ""

            if method:
                method = method.lower()
            else:
                method = "simple"

            if format:
                format = format.lower()

            if guesses:
                guesses = int(guesses)
            else:
                guesses = 1

            guess = fuzzylas.guess(curves, mnemonic, method, guesses)

            if format == "json":
                self.response.headers['Content-Type'] = 'application/json'
                self.response.out.write(json.dumps(guess))

            elif format == "csv":
                dump = 'mnemonic,company,method,description,units\n'
                for g in sorted(guess[1], key=guess[1].get):
                    for i in guess[0][g]:
                        dump = dump + str(g) + ',' + str(
                            i['company']) + ',' + str(i['method']) + ',' + str(
                                i['description']) + ',' + str(
                                    i['units']) + '\n'
                self.response.headers['Content-Type'] = 'text/plain'
                self.response.out.write(dump)

            else:
                self.response.out.write(guess)
Exemple #7
0
 def get(self):
     
     guess = None
     
     if self.request.arguments() == []:
         self.render("help.html")
         
     else:
         mnemonic = self.request.get('mnemonic')
         method  = self.request.get('method')
         format  = self.request.get('format')
         guesses = self.request.get('guesses')
             
         if mnemonic:
             mnemonic = mnemonic.upper()
         else:
             mnemonic=""
             
         if method:
             method = method.lower()
         else:
             method = "simple"
 
         if format:
             format = format.lower()
 
         if guesses:
             guesses = int(guesses)
         else:
             guesses = 1        
             
         guess = fuzzylas.guess(curves,mnemonic,method,guesses)
             
         if format == "json":
             self.response.headers['Content-Type'] = 'application/json'
             self.response.out.write(json.dumps(guess))
             
         elif format == "csv":
             dump = 'mnemonic,company,method,description,units\n'
             for g in sorted(guess[1],key=guess[1].get):
                 for i in guess[0][g]:
                     dump = dump + str(g) + ',' + str(i['company']) + ',' + str(i['method']) + ',' + str(i['description'])+ ',' + str(i['units']) + '\n'
             self.response.headers['Content-Type'] = 'text/plain'
             self.response.out.write(dump)
             
         else:
             self.response.out.write(guess)
Exemple #8
0
 def post(self):
     input = self.request.get('mnemonic').upper()
     guess = fuzzylas.guess(curves,input,'simple',3)
     self.render("index.html", input=input, result=guess[0], order=sorted(guess[1],key=guess[1].get))