예제 #1
0
 def test(self):
     self.assertEqual(quote('George Saint Pierre'),
                      "I am not impressed by your performance.")
     self.assertEqual(
         quote('Conor McGregor'),
         "I'd like to take this chance to apologize.. To absolutely NOBODY!"
     )
     self.assertEqual(quote('george saint pierre'),
                      "I am not impressed by your performance.")
     self.assertEqual(
         quote('conor mcgregor'),
         "I'd like to take this chance to apologize.. To absolutely NOBODY!"
     )
예제 #2
0
def index():
    quotes = []
    for i in range(10):
        quote_length = random.randrange(10, 30)
        walker = make_prefix_walker(source)
        quotes.append(quote(quote_length, walker))
    return render_template('index.html', quotes=quotes)
예제 #3
0
def VerboseQuote(in_string, specials, *args, **kwargs):
  if verbose:
    sys.stdout.write('Invoking quote(%s, %s, %s)\n' %
                     (repr(in_string), repr(specials),
                      ', '.join([repr(a) for a in args] +
                                [repr(k) + ':' + repr(v)
                                 for k, v in kwargs])))
  return quote.quote(in_string, specials, *args, **kwargs)
예제 #4
0
 def random(self, search):
     results = quote(search or self.default_search)
     if not results:
         return ""
     random_quote = random.choice(results)["quote"]
     wrapped_quote = "\n".join(
         wrap(shorten(random_quote, 280 - 4, placeholder="..."), 70))
     return wrapped_quote
예제 #5
0
def _set_eq_(key, value):
    if value is None:
        return '%s = NULL' % key
    elif type(value) in [int, long]:
        return '%s = %d' % (key, value)
    elif type(value) is float:
        return '%s = %f' % (key, value)
    else:
        return "%s = %s" %(key, quote(str(value)))
예제 #6
0
def main(argv):
    global verbose
    parser = optparse.OptionParser(usage='Usage: %prog [options] word...')
    parser.add_option('-s',
                      '--special-chars',
                      dest='special_chars',
                      default=':',
                      help='Special characters to quote (default is ":")')
    parser.add_option('-q',
                      '--quote',
                      dest='quote',
                      default='\\',
                      help='Quote or escape character (default is "\")')
    parser.add_option('-t',
                      '--run-tests',
                      dest='tests',
                      action='store_true',
                      help='Run built-in tests\n')
    parser.add_option('-u',
                      '--unquote-input',
                      dest='unquote_input',
                      action='store_true',
                      help='Unquote command line argument')
    parser.add_option('-v',
                      '--verbose',
                      dest='verbose',
                      action='store_true',
                      help='Verbose test output')
    options, args = parser.parse_args(argv)

    if options.verbose:
        verbose = True

    num_errors = 0
    if options.tests:
        sys.argv = [sys.argv[0]] + args
        unittest.main()
    else:
        for word in args:
            # NB: there are inputs x for which quote(unquote(x) != x, but
            # there should be no input x for which unquote(quote(x)) != x.
            if options.unquote_input:
                qq = quote.unquote(word, options.special_chars, options.quote)
                sys.stdout.write('unquote(%s) = %s\n' % (word, ''.join(qq)))
                # There is no expected output for unquote -- this is just for
                # manual testing, so it is okay that we do not (and cannot)
                # update num_errors here.
            else:
                q = quote.quote(word, options.special_chars, options.quote)
                qq = quote.unquote(q, options.special_chars, options.quote)
                sys.stdout.write('quote(%s) = %s, unquote(%s) = %s\n' %
                                 (word, q, q, ''.join(qq)))
                if word != ''.join(qq):
                    num_errors += 1
        if num_errors > 0:
            sys.stderr.write('[  FAILED  ] %d test failures\n' % num_errors)
    return num_errors
예제 #7
0
def VerboseQuote(in_string, specials, *args, **kwargs):
    if verbose:
        sys.stdout.write(
            "Invoking quote(%s, %s, %s)\n"
            % (
                repr(in_string),
                repr(specials),
                ", ".join([repr(a) for a in args] + [repr(k) + ":" + repr(v) for k, v in kwargs]),
            )
        )
    return quote.quote(in_string, specials, *args, **kwargs)
예제 #8
0
def tuplize_dict(adict):
    klist, vlist = [], []
    for k,v in adict.items():
        klist.append(k)
        if type(v) in [int, long]:
            vlist.append(str(v))
        elif v is None:
            vlist.append('NULL')
        else:
            vlist.append(quote(str(v)))
    return tuple(map(make_tuple, [klist, vlist]))
예제 #9
0
파일: default.py 프로젝트: maslick/webtupoj
def quotes():
    resp = dict()

    citations = []
    authors = ["pushkin", "chekhov", "lermontov", "azimov", "pasternak", "bulgakov", "lenin", "strugatsky", "gumilyov", "akhmatova", "fet"]
    for q in quote(random.choice(authors), limit=5):
        row = dict()
        row["author"] = q["author"]
        row["quote"] = q["quote"]
        citations.append(row)

    resp["citations"] = citations
    return resp
예제 #10
0
파일: run.py 프로젝트: maslick/citatos
def index(environ, start_response):
    start_response('200 OK', [('Content-type', 'text/html')])
    url = '<h1>Hello, world!</h1><div>BACKEND_URL: {0}</div><hr>'.format(
        backend_url)

    citations = ""
    authors = [
        "pushkin", "chekhov", "lermontov", "azimov", "pasternak", "bulgakov",
        "lenin", "strugatsky", "gumilyov", "akhmatova"
    ]
    for q in quote(random.choice(authors), limit=5):
        citations += "<p>{0}: {1}</p>".format(q["author"], q["quote"])
    return [url.encode('utf-8'), citations.encode('utf-8')]
예제 #11
0
async def _(event):
    if event.fwd_from:
        return
    input_str = event.pattern_match.group(1)
    result = quote(input_str, limit=3)
    sed = ""

    for quotes in result:
        sed += str(quotes["quote"]) + "\n\n"

    await event.edit(
        f"<b><u>Quotes Successfully Gathered for given word </b></u><code>{input_str}</code>\n\n\n<code>{sed}</code>",
        parse_mode="HTML",
    )
예제 #12
0
파일: quote_test.py 프로젝트: 7kbird/chrome
def main(argv):
  global verbose
  parser = optparse.OptionParser(
    usage='Usage: %prog [options] word...')
  parser.add_option('-s', '--special-chars', dest='special_chars', default=':',
                    help='Special characters to quote (default is ":")')
  parser.add_option('-q', '--quote', dest='quote', default='\\',
                    help='Quote or escape character (default is "\")')
  parser.add_option('-t', '--run-tests', dest='tests', action='store_true',
                    help='Run built-in tests\n')
  parser.add_option('-u', '--unquote-input', dest='unquote_input',
                    action='store_true', help='Unquote command line argument')
  parser.add_option('-v', '--verbose', dest='verbose', action='store_true',
                    help='Verbose test output')
  options, args = parser.parse_args(argv)

  if options.verbose:
    verbose = True

  num_errors = 0
  if options.tests:
    sys.argv = [sys.argv[0]] + args
    unittest.main()
  else:
    for word in args:
      # NB: there are inputs x for which quote(unquote(x) != x, but
      # there should be no input x for which unquote(quote(x)) != x.
      if options.unquote_input:
        qq = quote.unquote(word, options.special_chars, options.quote)
        sys.stdout.write('unquote(%s) = %s\n'
                         % (word, ''.join(qq)))
        # There is no expected output for unquote -- this is just for
        # manual testing, so it is okay that we do not (and cannot)
        # update num_errors here.
      else:
        q = quote.quote(word, options.special_chars, options.quote)
        qq = quote.unquote(q, options.special_chars, options.quote)
        sys.stdout.write('quote(%s) = %s, unquote(%s) = %s\n'
                         % (word, q, q, ''.join(qq)))
        if word != ''.join(qq):
          num_errors += 1
    if num_errors > 0:
      sys.stderr.write('[  FAILED  ] %d test failures\n' % num_errors)
  return num_errors
예제 #13
0
def main(args):
  global verbose
  parser = argparse.ArgumentParser()
  parser.add_argument('-s', '--special-chars',
                      dest='special_chars', default=':',
                      help='Special characters to quote (default is ":")')
  parser.add_argument('-q', '--quote', dest='quote', default='\\',
                      help='Quote or escape character (default is "\")')
  parser.add_argument('-u', '--unquote-input', dest='unquote_input',
                      action='store_true', help='Unquote command line argument')
  parser.add_argument('-v', '--verbose', dest='verbose', action='store_true',
                      help='Verbose test output')
  parser.add_argument('words', nargs='*')
  options = parser.parse_args(args)

  if options.verbose:
    verbose = True

  if not options.words:
    unittest.main()

  num_errors = 0
  for word in options.words:
    # NB: there are inputs x for which quote(unquote(x) != x, but
    # there should be no input x for which unquote(quote(x)) != x.
    if options.unquote_input:
      qq = quote.unquote(word, options.special_chars, options.quote)
      sys.stdout.write('unquote(%s) = %s\n'
                       % (word, ''.join(qq)))
      # There is no expected output for unquote -- this is just for
      # manual testing, so it is okay that we do not (and cannot)
      # update num_errors here.
    else:
      q = quote.quote(word, options.special_chars, options.quote)
      qq = quote.unquote(q, options.special_chars, options.quote)
      sys.stdout.write('quote(%s) = %s, unquote(%s) = %s\n'
                       % (word, q, q, ''.join(qq)))
      if word != ''.join(qq):
        num_errors += 1
  if num_errors > 0:
    sys.stderr.write('[  FAILED  ] %d test failures\n' % num_errors)
  return num_errors
예제 #14
0
def main(argv):
    global verbose
    parser = optparse.OptionParser(usage="Usage: %prog [options] word...")
    parser.add_option(
        "-s", "--special-chars", dest="special_chars", default=":", help='Special characters to quote (default is ":")'
    )
    parser.add_option("-q", "--quote", dest="quote", default="\\", help='Quote or escape character (default is "")')
    parser.add_option("-t", "--run-tests", dest="tests", action="store_true", help="Run built-in tests\n")
    parser.add_option(
        "-u", "--unquote-input", dest="unquote_input", action="store_true", help="Unquote command line argument"
    )
    parser.add_option("-v", "--verbose", dest="verbose", action="store_true", help="Verbose test output")
    options, args = parser.parse_args(argv)

    if options.verbose:
        verbose = True

    num_errors = 0
    if options.tests:
        sys.argv = [sys.argv[0]] + args
        unittest.main()
    else:
        for word in args:
            # NB: there are inputs x for which quote(unquote(x) != x, but
            # there should be no input x for which unquote(quote(x)) != x.
            if options.unquote_input:
                qq = quote.unquote(word, options.special_chars, options.quote)
                sys.stdout.write("unquote(%s) = %s\n" % (word, "".join(qq)))
                # There is no expected output for unquote -- this is just for
                # manual testing, so it is okay that we do not (and cannot)
                # update num_errors here.
            else:
                q = quote.quote(word, options.special_chars, options.quote)
                qq = quote.unquote(q, options.special_chars, options.quote)
                sys.stdout.write("quote(%s) = %s, unquote(%s) = %s\n" % (word, q, q, "".join(qq)))
                if word != "".join(qq):
                    num_errors += 1
        if num_errors > 0:
            sys.stderr.write("[  FAILED  ] %d test failures\n" % num_errors)
    return num_errors
예제 #15
0
   def is_command(self, nick, msg, msgcap):
      try:
         data = storage.data
         self.get_current_game(self.botnick)
         if msg[0] == 'shutdown':
            commands.bot_shutdown(nick, msg)
            
         try:
            if nick in bot.channeldata['banlist']:
               return

            if msg[1] == 'new' and msg[0] not in bot.channeldata['showstats']:
               stats.change(nick, msg[0], msg[1])
               return
         except IndexError:
            pass
         except KeyError:
            pass

         if msg[0] in bot.channeldata['showstats']:
            if len(msg) is not 3:
               msg.extend([None] * 3)
            stats.change(nick, msg[0], msg[1], msg[2])

         elif msg[0] == 'game':
            commands.gamecheck(nick, msg, msgcap.split(':!')[-1].split())
            
         elif msg[0] == 'stats':
            stats.statcheck(nick, bot.channeldata)

         elif msg[0] == 'quote':
            quote(nick, msgcap.split(':!')[-1].split(), bot.channeldata['quotes'])

         elif msg[0] == 'vote':
            commands.comm_vote(nick, msg, msgcap.split(':!')[-1].split())

         elif msg[0] in ['request','gamerequest']:
            commands.game_request(nick,' '.join(msg[1:]))

         elif msg[0] == 'response':
            commands.edit_response(nick, msg, msgcap.split(':!')[-1].split(), bot.channeldata['showresponse'])

         elif msg[0] in ['ban','unban']:
            commands.botban(nick, msg, bot.channeldata)

         elif msg[0] == 'uptime':
            commands.uptime()

         elif msg[0] == 'highlight':
            commands.make_highlight(nick, msgcap.split(':!')[-1].split())
            
         elif msg[0] == 'lockdown':
            commands.lockdown(nick, msg, bot.channeldata)

         #Mods only
         elif msg[0] == 'mute':
            if nick in self.modlist:
               try:
                  if msg[1] == 'off':
                     self.mute = False
                     logging.info('Bot unmuted by %s' %nick)
               except IndexError:
                  self.mute = True
                  logging.info('Bot muted by %s' %nick)
                  
         elif msg[0] in bot.channeldata['showresponse']:
            commands.send_response(nick, msg[0], bot.channeldata['showresponse'][msg[0]])
         
         elif msg[0] in data['responses']:
            commands.send_response(nick, msg[0], data['responses'][msg[0]])

      except IndexError:
         pass
예제 #16
0
def aggregated_quote(week1, week2, header):
    # 投票の集計
    print("week1 : ")
    quote.quote(datas=week1, header=header)
    print("week2 : ")
    quote.quote(datas=week2, header=header)
예제 #17
0
def get_some_quotes(query, ammount):
    text = quote(query, ammount)
    return text
import quote
import pprint
q = quote.quote()
pprint.pprint(q.get_quote(["AAPL","AMZN","GOOG","V","MCD","ALXN","YHOO","MSFT","PWE","GLD"]))
예제 #19
0
from quote import quote
import random

random_author = random.randint(0,6)
random_quote = random.randint(0,6)

authors = ["Ray Bradbury", "Alice Walker", "Stephen Hawking", "Steve Jobs", "Coco Chanel", "Anita Roddick", "Helen Keller", ]
result = quote(authors[random_author], limit=7)

famous_quote = result[random_quote]["quote"] + "-" + result[random_quote]["author"]
예제 #20
0
def test_lower_quote():
    assert quote(
        'george saint pierre') == "I am not impressed by your performance."
    assert quote(
        'conor mcgregor'
    ) == "I'd like to take this chance to apologize.. To absolutely NOBODY!"
    def get(self):
        query = Alert.all()
        offset = 0
        alerts = query.fetch(1000)

        if not alerts:
            self.response.out.write("No Tickers...")
            return

        users = {}
        tickers = set()

        for alert in alerts:
            user = alert.user
            ticker = alert.ticker.upper()

            if user in users:
                users[user].append(alert)
            else:
                users[user] = [alert]

            tickers.add(ticker)

        l = list(tickers)

        q = quote.quote()
        for i in range(0, len(tickers), 5):
            d = q.get_quote(l[i:i + 5])

            prices = self.getData(d)

            for user, alerts in users.items():
                for alert in alerts:
                    hi_price = float(alert.hi_price)
                    low_price = float(alert.low_price)
                    ticker = alert.ticker.upper()

                    if ticker not in l[i:i + 5] or ticker not in prices:
                        continue

                    user_address = user.email()
                    price = prices[ticker]

                    if price > hi_price:
                        self.response.out.write(
                            "Broke above %s's limit of $%.2f for %s, now at %.2f, note was %s"
                            % (user.nickname(), hi_price, ticker, price,
                               alert.note))

                        chat_message_sent = False
                        msg = "%s went up to %.2f (Which is past your limit of %.2f), note was: %s!" % (
                            ticker, price, hi_price, alert.note)
                        status_code = xmpp.send_message(user_address, msg)
                        chat_message_sent = (status_code == xmpp.NO_ERROR)

                        if mail.is_email_valid(user_address):
                            sender_address = "*****@*****.**"
                            subject = "Alert for %s" % (ticker)
                            body = "Broke above %s's limit of $%.2f for %s, now at %.2f, note was: %s" % (
                                user.nickname(), hi_price, ticker, price,
                                alert.note)

                            mail.send_mail(sender_address, user_address,
                                           subject, body)

                        alert.delete()

                    elif price < low_price:
                        self.response.out.write(
                            "Broke below %s's limit of $%.2f for %s, now at %.2f, note was: %s"
                            % (user.nickname(), low_price, ticker, price,
                               alert.note))

                        chat_message_sent = False
                        msg = "%s went down to %.2f (Which is past your limit of %.2f), note was: %s!" % (
                            ticker, price, low_price, alert.note)
                        status_code = xmpp.send_message(user_address, msg)
                        chat_message_sent = (status_code == xmpp.NO_ERROR)

                        if mail.is_email_valid(user_address):
                            sender_address = "*****@*****.**"
                            subject = "Alert for %s" % (ticker)
                            body = "Broke below %s's limit of $%.2f for %s, now at %.2f, note was: %s" % (
                                user.nickname(), low_price, ticker, price,
                                alert.note)

                            mail.send_mail(sender_address, user_address,
                                           subject, body)

                        alert.delete()
                    else:
                        alert.curr_price = prices[ticker]
                        alert.put()
예제 #22
0
 def __repr__(self):
     if self._quote:
         expr = " ".join(map(str, [self.left, self.op, quote(str(self.right))]))
     else:
         expr = " ".join(map(str, [self.left, self.op, self.right]))
     return "%s" % expr
예제 #23
0
def test_quote_2():
    search = "blake crouch"
    result = quote(search, limit=5)
    one = result[0]
    assert (one["author"] == "Blake Crouch" and one["book"]
            and isinstance(one["quote"], str))
 def get(self):
   query = Alert.all()
   offset = 0
   alerts = query.fetch(1000)
   
   if not alerts:
     self.response.out.write("No Tickers...") 
     return
   
   users   = {}
   tickers = set()
   
   for alert in alerts:
     user   = alert.user
     ticker = alert.ticker.upper()
     
     if user in users:
       users[user].append(alert)
     else:
       users[user] = [alert]
     
     tickers.add(ticker)
   
   l = list(tickers)
   
   q = quote.quote()
   for i in range(0,len(tickers),5):
     d = q.get_quote(l[i:i+5])
     
     prices = self.getData(d)
     
     for user, alerts in users.items():
       for alert in alerts:
         hi_price  = float(alert.hi_price)
         low_price = float(alert.low_price)
         ticker    = alert.ticker.upper()
         
         if ticker not in l[i:i+5] or ticker not in prices:
           continue
         
         user_address = user.email()
         price = prices[ticker]
         
         if price > hi_price:
           self.response.out.write("Broke above %s's limit of $%.2f for %s, now at %.2f, note was %s" % (user.nickname(),hi_price,ticker, price, alert.note) )
           
           chat_message_sent = False
           msg = "%s went up to %.2f (Which is past your limit of %.2f), note was: %s!" % (ticker,price,hi_price, alert.note)
           status_code = xmpp.send_message(user_address, msg)
           chat_message_sent = (status_code == xmpp.NO_ERROR)
           
           if mail.is_email_valid(user_address):
             sender_address = "*****@*****.**"
             subject = "Alert for %s" % (ticker)
             body = "Broke above %s's limit of $%.2f for %s, now at %.2f, note was: %s" % (user.nickname(), hi_price, ticker, price, alert.note)
             
             mail.send_mail(sender_address, user_address, subject, body)
             
           alert.delete()
           
         elif price < low_price:
           self.response.out.write("Broke below %s's limit of $%.2f for %s, now at %.2f, note was: %s" % (user.nickname(),low_price,ticker,price, alert.note) )
           
           chat_message_sent = False
           msg = "%s went down to %.2f (Which is past your limit of %.2f), note was: %s!" % (ticker,price,low_price, alert.note)
           status_code = xmpp.send_message(user_address, msg)
           chat_message_sent = (status_code == xmpp.NO_ERROR)
           
           
           if mail.is_email_valid(user_address):
             sender_address = "*****@*****.**"
             subject = "Alert for %s" % (ticker)
             body = "Broke below %s's limit of $%.2f for %s, now at %.2f, note was: %s" % (user.nickname(),low_price,ticker,price, alert.note)
             
             mail.send_mail(sender_address, user_address, subject, body)
             
           alert.delete()
         else:
           alert.curr_price = prices[ticker]
           alert.put()
예제 #25
0
                client = wolframalpha.Client(app_id)
                indx = query.lower().split().index('calculate')
                query = query.split()[indx + 1:]
                res = client.query(' '.join(query))
                answer = next(res.results).text
                print("The answer is " + answer)
                fun_talk("The answer is " + answer)

            except Exception as e:
                print(
                    "Couldn't get what you have said, Can you say it again??")

        elif 'quote' in query or 'quotes' in query:
            fun_talk("Tell me the author or person name.")
            q_author = get_command()
            quotes = quote(q_author)
            quote_no = random.randint(1, len(quotes))
            # print(len(quotes))
            # print(quotes)
            print("Author: ", quotes[quote_no]['author'])
            print("-->", quotes[quote_no]['quote'])
            fun_talk(f"Author: {quotes[quote_no]['author']}")
            fun_talk(f"He said {quotes[quote_no]['quote']}")

        elif 'what' in query or 'who' in query:  # or 'where' in query:

            client = wolframalpha.Client("JUGV8R-RXJ4RP7HAG")
            res = client.query(query)
            try:
                print(next(res.results).text)
                fun_talk(next(res.results).text)
예제 #26
0
def quote_route():
    return quote()
예제 #27
0
def test_quote_1():
    search = "Bitcoin Billionaires"
    result = quote(search, limit=5)
    one = result[0]
    assert (one["author"] == "Ben Mezrich" and one["book"]
            and isinstance(one["quote"], str))
예제 #28
0
def test_title_quote():
    assert quote(
        'George Saint Pierre') == "I am not impressed by your performance."
    assert quote(
        'Conor McGregor'
    ) == "I'd like to take this chance to apologize.. To absolutely NOBODY!"
예제 #29
0
파일: test.py 프로젝트: johnmiked15/scrappy
 def setUp(self):
     super(TestQuote, self).setUp()
     self.quote_obj = quote.quote(self.bot)
예제 #30
0
def _set_eq_(key, value):
    return "%s = %s" %(key, quote(str(value)))