A PHP Error was encountered

Severity: 8192

Message: Function create_function() is deprecated

Filename: geshi/geshi.php

Line Number: 4698

Backtrace:

File: /home/httpd/vhosts/scratchbook.ch/geopaste.scratchbook.ch/application/libraries/geshi/geshi.php
Line: 4698
Function: _error_handler

File: /home/httpd/vhosts/scratchbook.ch/geopaste.scratchbook.ch/application/libraries/geshi/geshi.php
Line: 4621
Function: _optimize_regexp_list_tokens_to_string

File: /home/httpd/vhosts/scratchbook.ch/geopaste.scratchbook.ch/application/libraries/geshi/geshi.php
Line: 1655
Function: optimize_regexp_list

File: /home/httpd/vhosts/scratchbook.ch/geopaste.scratchbook.ch/application/libraries/geshi/geshi.php
Line: 2029
Function: optimize_keyword_group

File: /home/httpd/vhosts/scratchbook.ch/geopaste.scratchbook.ch/application/libraries/geshi/geshi.php
Line: 2168
Function: build_parse_cache

File: /home/httpd/vhosts/scratchbook.ch/geopaste.scratchbook.ch/application/libraries/Process.php
Line: 45
Function: parse_code

File: /home/httpd/vhosts/scratchbook.ch/geopaste.scratchbook.ch/application/models/Pastes.php
Line: 517
Function: syntax

File: /home/httpd/vhosts/scratchbook.ch/geopaste.scratchbook.ch/application/controllers/Main.php
Line: 693
Function: getPaste

File: /home/httpd/vhosts/scratchbook.ch/geopaste.scratchbook.ch/index.php
Line: 315
Function: require_once

Untitled - Stikked
From Sloppy Echidna, 13 Years ago, written in Python.
Embed
  1. ###
  2. # Copyright (c) 2004, Jeremiah Fincher
  3. # All rights reserved.
  4. #
  5. # Redistribution and use in source and binary forms, with or without
  6. # modification, are permitted provided that the following conditions are met:
  7. #
  8. #   * Redistributions of source code must retain the above copyright notice,
  9. #     this list of conditions, and the following disclaimer.
  10. #   * Redistributions in binary form must reproduce the above copyright notice,
  11. #     this list of conditions, and the following disclaimer in the
  12. #     documentation and/or other materials provided with the distribution.
  13. #   * Neither the name of the author of this software nor the name of
  14. #     contributors to this software may be used to endorse or promote products
  15. #     derived from this software without specific prior written consent.
  16. #
  17. # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  18. # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  19. # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  20. # ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
  21. # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
  22. # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
  23. # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
  24. # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
  25. # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  26. # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  27. # POSSIBILITY OF SUCH DAMAGE.
  28. ###
  29.  
  30. import time
  31. TIME = time # For later use.
  32. from datetime import datetime
  33.  
  34. import supybot.conf as conf
  35. import supybot.utils as utils
  36. from supybot.commands import *
  37. import supybot.callbacks as callbacks
  38. from supybot.i18n import PluginInternationalization, internationalizeDocstring
  39. _ = PluginInternationalization('Time')
  40.  
  41. parser = utils.python.universalImport('dateutil.parser', 'local.dateutil.parser')
  42.  
  43. def parse(s):
  44.     todo = []
  45.     s = s.replace('noon', '12:00')
  46.     s = s.replace('midnight', '00:00')
  47.     if 'tomorrow' in s:
  48.         todo.append(lambda i: i + 86400)
  49.         s = s.replace('tomorrow', '')
  50.     if 'next week' in s:
  51.         todo.append(lambda i: i + 86400*7)
  52.         s = s.replace('next week', '')
  53.     i = int(time.mktime(parser.parse(s, fuzzy=True).timetuple()))
  54.     for f in todo:
  55.         i = f(i)
  56.     return i
  57.  
  58. class Time(callbacks.Plugin):
  59.     @internationalizeDocstring
  60.     def seconds(self, irc, msg, args):
  61.         """[<years>y] [<weeks>w] [<days>d] [<hours>h] [<minutes>m] [<seconds>s]
  62.  
  63.        Returns the number of seconds in the number of <years>, <weeks>,
  64.        <days>, <hours>, <minutes>, and <seconds> given.  An example usage is
  65.        "seconds 2h 30m", which would return 9000, which is '3600*2 + 30*60'.
  66.        Useful for scheduling events at a given number of seconds in the
  67.        future.
  68.        """
  69.         if not args:
  70.             raise callbacks.ArgumentError
  71.         seconds = 0
  72.         for arg in args:
  73.             if not arg or arg[-1] not in 'ywdhms':
  74.                 raise callbacks.ArgumentError
  75.             (s, kind) = arg[:-1], arg[-1]
  76.             try:
  77.                 i = int(s)
  78.             except ValueError:
  79.                 irc.errorInvalid('argument', arg, Raise=True)
  80.             if kind == 'y':
  81.                 seconds += i*31536000
  82.             elif kind == 'w':
  83.                 seconds += i*604800
  84.             elif kind == 'd':
  85.                 seconds += i*86400
  86.             elif kind == 'h':
  87.                 seconds += i*3600
  88.             elif kind == 'm':
  89.                 seconds += i*60
  90.             elif kind == 's':
  91.                 seconds += i
  92.         irc.reply(str(seconds))
  93.  
  94.     @internationalizeDocstring
  95.     def at(self, irc, msg, args, s):
  96.         """<time string>
  97.  
  98.        Returns the number of seconds since epoch <time string> is.
  99.        <time string> can be any number of natural formats; just try something
  100.        and see if it will work.
  101.        """
  102.         now = int(time.time())
  103.         new = parse(s)
  104.         if new != now:
  105.             irc.reply(str(new))
  106.         else:
  107.             irc.error(_('That\'s right now!'))
  108.     at = wrap(at, ['text'])
  109.  
  110.     @internationalizeDocstring
  111.     def until(self, irc, msg, args, s):
  112.         """<time string>
  113.  
  114.        Returns the number of seconds until <time string>.
  115.        """
  116.         now = int(time.time())
  117.         new = parse(s)
  118.         if new != now:
  119.             if new - now < 0:
  120.                 new += 86400
  121.             irc.reply(str(new-now))
  122.         else:
  123.             irc.error(_('That\'s right now!'))
  124.     until = wrap(until, ['text'])
  125.  
  126.     @internationalizeDocstring
  127.     def ctime(self, irc, msg, args, seconds):
  128.         """[<seconds since epoch>]
  129.  
  130.        Returns the ctime for <seconds since epoch>, or the current ctime if
  131.        no <seconds since epoch> is given.
  132.        """
  133.         irc.reply(time.ctime(seconds))
  134.     ctime = wrap(ctime,[additional(('int', _('number of seconds since epoch')),
  135.                                     TIME.time)])
  136.  
  137.     @internationalizeDocstring
  138.     def time(self, irc, msg, args, channel, format, seconds):
  139.         """[<format>] [<seconds since epoch>]
  140.  
  141.        Returns the current time in <format> format, or, if <format> is not
  142.        given, uses the configurable format for the current channel.  If no
  143.        <seconds since epoch> time is given, the current time is used.
  144.        """
  145.         if not format:
  146.             if channel:
  147.                 format = self.registryValue('format', channel)
  148.             else:
  149.                 format = self.registryValue('format')
  150.         irc.reply(time.strftime(format, time.localtime(seconds)))
  151.     time = wrap(time, [optional('channel'), optional('nonInt'),
  152.                        additional('float', TIME.time)])
  153.  
  154.     def owner(self, irc, msg, args):
  155.         """Returns the time of the owner"""    
  156.         os.environ['TZ'] = 'Europe/Belgrade'
  157.         time.tzset()
  158.         irc.reply(time.strftime('%H:%M:%S'))
  159.     owner = wrap(owner)  
  160.                        
  161.     @internationalizeDocstring
  162.     def elapsed(self, irc, msg, args, seconds):
  163.         """<seconds>
  164.  
  165.        Returns a pretty string that is the amount of time represented by
  166.        <seconds>.
  167.        """
  168.         irc.reply(utils.timeElapsed(seconds))
  169.     elapsed = wrap(elapsed, ['int'])
  170.  
  171.     @internationalizeDocstring
  172.     def tztime(self, irc, msg, args, timezone):
  173.         """<region>/<city>
  174.  
  175.        Takes a city and its region, and returns the locale time."""
  176.         try:
  177.             import pytz
  178.         except ImportError:
  179.             irc.error(_('Python-tz is required by the command, but is not '
  180.                         'installed on this computer.'))
  181.             return
  182.         try:
  183.             timezone = pytz.timezone(timezone)
  184.         except pytz.UnknownTimeZoneError:
  185.             irc.error(_('Unknown timezone'))
  186.             return
  187.         irc.reply(str(datetime.now(timezone)))
  188.     tztime = wrap(tztime, ['text'])
  189.  
  190.  
  191. Class = Time
  192.  
  193. # vim:set shiftwidth=4 softtabstop=4 expandtab textwidth=79:
  194.