Current File : /home/mmdealscpanel/yummmdeals.com/comparisons.zip
PK��Z�&bsortingtest.pyonu�[����
Afc@s,ddlZddlZd�Ze�dS(i����Ncs{tjd�}|d��xYtjD]N}t�fd�|j�D��}x"|D]\}}d||fGqTWHq%WdS(Ns^(.*)=([-+]?[0-9]+)cSsE|j|�}|r7|j�\}}t|�|fSd|fSdS(Ni(tmatchtgroupstint(titemtprogRtvartnum((s4/usr/lib64/python2.7/Demo/comparisons/sortingtest.pytmakekeys
c3s|]}�|�VqdS(N((t.0R(R(s4/usr/lib64/python2.7/Demo/comparisons/sortingtest.pys	<genexpr>(ss%s=%s(tretcompiletsyststdintsortedtsplit(RtlinetitemsRR((Rs4/usr/lib64/python2.7/Demo/comparisons/sortingtest.pytmains"(R	RR(((s4/usr/lib64/python2.7/Demo/comparisons/sortingtest.pyt<module>s	PK��Z'2ӎ��sortingtest.pynuȯ��#! /usr/bin/python2.7

# 2)  Sorting Test
#
#     Sort an input file that consists of lines like this
#
#         var1=23 other=14 ditto=23 fred=2
#
#     such that each output line is sorted WRT to the number.  Order
#     of output lines does not change.  Resolve collisions using the
#     variable name.   e.g.
#
#         fred=2 other=14 ditto=23 var1=23
#
#     Lines may be up to several kilobytes in length and contain
#     zillions of variables.

# This implementation:
# - Reads stdin, writes stdout
# - Uses any amount of whitespace to separate fields
# - Allows signed numbers
# - Treats illegally formatted fields as field=0
# - Outputs the sorted fields with exactly one space between them
# - Handles blank input lines correctly

import re
import sys

def main():
    prog = re.compile('^(.*)=([-+]?[0-9]+)')
    def makekey(item, prog=prog):
        match = prog.match(item)
        if match:
            var, num = match.groups()
            return int(num), var
        else:
            # Bad input -- pretend it's a var with value 0
            return 0, item
    for line in sys.stdin:
        items = sorted(makekey(item) for item in line.split())
        for num, var in items:
            print "%s=%s" % (var, num),
        print

main()
PK��Zk�4z��regextest.pynuȯ��#! /usr/bin/python2.7

# 1)  Regular Expressions Test
#
#     Read a file of (extended per egrep) regular expressions (one per line),
#     and apply those to all files whose names are listed on the command line.
#     Basically, an 'egrep -f' simulator.  Test it with 20 "vt100" patterns
#     against a five /etc/termcap files.  Tests using more elaborate patters
#     would also be interesting.  Your code should not break if given hundreds
#     of regular expressions or binary files to scan.

# This implementation:
# - combines all patterns into a single one using ( ... | ... | ... )
# - reads patterns from stdin, scans files given as command line arguments
# - produces output in the format <file>:<lineno>:<line>
# - is only about 2.5 times as slow as egrep (though I couldn't run
#   Tom's test -- this system, a vanilla SGI, only has /etc/terminfo)

import string
import sys
import re

def main():
    pats = map(chomp, sys.stdin.readlines())
    bigpat = '(' + '|'.join(pats) + ')'
    prog = re.compile(bigpat)

    for file in sys.argv[1:]:
        try:
            fp = open(file, 'r')
        except IOError, msg:
            print "%s: %s" % (file, msg)
            continue
        lineno = 0
        while 1:
            line = fp.readline()
            if not line:
                break
            lineno = lineno + 1
            if prog.search(line):
                print "%s:%s:%s" % (file, lineno, line),

def chomp(s):
    return s.rstrip('\n')

if __name__ == '__main__':
    main()
PK��Z�&bsortingtest.pycnu�[����
Afc@s,ddlZddlZd�Ze�dS(i����Ncs{tjd�}|d��xYtjD]N}t�fd�|j�D��}x"|D]\}}d||fGqTWHq%WdS(Ns^(.*)=([-+]?[0-9]+)cSsE|j|�}|r7|j�\}}t|�|fSd|fSdS(Ni(tmatchtgroupstint(titemtprogRtvartnum((s4/usr/lib64/python2.7/Demo/comparisons/sortingtest.pytmakekeys
c3s|]}�|�VqdS(N((t.0R(R(s4/usr/lib64/python2.7/Demo/comparisons/sortingtest.pys	<genexpr>(ss%s=%s(tretcompiletsyststdintsortedtsplit(RtlinetitemsRR((Rs4/usr/lib64/python2.7/Demo/comparisons/sortingtest.pytmains"(R	RR(((s4/usr/lib64/python2.7/Demo/comparisons/sortingtest.pyt<module>s	PK��Z]�|I 	 	READMEnu�[���Subject: Re: What language would you use?
From: Tom Christiansen <tchrist@mox.perl.com>
Date: 6 Nov 1994 15:14:51 GMT
Newsgroups: comp.lang.python,comp.lang.tcl,comp.lang.scheme,comp.lang.misc,comp.lang.perl
Message-Id: <39irtb$3t4@csnews.cs.Colorado.EDU>
References: <39b7ha$j9v@zeno.nscf.org> <39hhjp$lgn@csnews.cs.Colorado.EDU> <39hvsu$dus@mathserv.mps.ohio-state.edu>

[...]
If you're really into benchmarks, I'd love it if someone were to code up
the following problems in tcl, python, and scheme (and whatever else you'd
like).  Separate versions (one optimized for speed, one for beauty :-) are
ok.  Post your code so we can time it on our own systems.

0)  Factorial Test  (numerics and function calls)

        (we did this already)

1)  Regular Expressions Test

    Read a file of (extended per egrep) regular expressions (one per line), 
    and apply those to all files whose names are listed on the command line.
    Basically, an 'egrep -f' simulator.  Test it with 20 "vt100" patterns
    against a five /etc/termcap files.  Tests using more elaborate patters
    would also be interesting.  Your code should not break if given hundreds
    of regular expressions or binary files to scan.  

2)  Sorting Test

    Sort an input file that consists of lines like this

        var1=23 other=14 ditto=23 fred=2

    such that each output line is sorted WRT to the number.  Order
    of output lines does not change.  Resolve collisions using the
    variable name.   e.g.

        fred=2 other=14 ditto=23 var1=23 

    Lines may be up to several kilobytes in length and contain
    zillions of variables.

3)  System Test

    Given a list of directories, report any bogus symbolic links contained
    anywhere in those subtrees.  A bogus symbolic link is one that cannot
    be resolved because it points to a nonexistent or otherwise
    unresolvable file.  Do *not* use an external find executable.
    Directories may be very very deep.  Print a warning immediately if the
    system you're running on doesn't support symbolic links.


I'll post perl solutions if people post the others.


--tom
-- 
Tom Christiansen      Perl Consultant, Gamer, Hiker      tchrist@mox.perl.com

 "But Billy! A *small* allowance prepares you for a lifetime of small
 salaries and for your Social Security payments."    --Family Circus
PK��Z7\�AA
regextest.pycnu�[����
Afc@sPddlZddlZddlZd�Zd�ZedkrLe�ndS(i����NcCs�tttjj��}ddj|�d}tj|�}x�tjdD]�}yt	|d�}Wn%t
k
r�}d||fGHqLnXd}xG|j�}|s�Pn|d}|j|�r�d|||fGq�q�WqLWdS(	Nt(t|t)itrs%s: %sis%s:%s:%s(
tmaptchomptsyststdint	readlinestjointretcompiletargvtopentIOErrortreadlinetsearch(tpatstbigpattprogtfiletfptmsgtlinenotline((s2/usr/lib64/python2.7/Demo/comparisons/regextest.pytmains"
cCs
|jd�S(Ns
(trstrip(ts((s2/usr/lib64/python2.7/Demo/comparisons/regextest.pyR+st__main__(tstringRR
RRt__name__(((s2/usr/lib64/python2.7/Demo/comparisons/regextest.pyt<module>s		PK��Z,��
>>systemtest.pycnu�[����
Afc@s?ddlZddlZddlTd�Zd�Ze�dS(i����N(t*cCs�y
tj}Wn#tk
r2dGHtjd�nXtjdrPtjd}nd}|r�tj|�|ddkr�|d}nt|�n
td�dS(Ns'This system doesn't have symbolic linksiiti����t/(tostreadlinktAttributeErrortsystexittargvtchdirtreportboguslinks(tdummytprefix((s3/usr/lib64/python2.7/Demo/comparisons/systemtest.pytmains





cCs�ytjd�}Wn)tjk
r>}d|d|fGHdSX|j�x<|D]4}|tjksP|tjkrzqPnytj|�t}Wn)tjk
r�d|||fGHqPnXt|�rytj	|�Wq�tjk
rd||tj
|�fGHq�XqPt|�rPytj|�Wn+tjk
rY}d|||fGHqPnXzt
||d�Wdtjd�XqPqPWdS(Nt.s%s%s: can't list: %ss%s%s: can't stat: %ss
%s%s -> %ss%s%s: can't chdir: %sRs..(RtlistdirterrortsorttcurdirtpardirtlstattST_MODEtS_ISLNKtstatRtS_ISDIRR	R
(Rtnamestmsgtnametmode((s3/usr/lib64/python2.7/Demo/comparisons/systemtest.pyR
)s<

(RRRR
R
(((s3/usr/lib64/python2.7/Demo/comparisons/systemtest.pyt<module>s

		!PK��Z�%.patternsnu�[���^def 
^class 
^import 
^from 
PK��Z7\�AA
regextest.pyonu�[����
Afc@sPddlZddlZddlZd�Zd�ZedkrLe�ndS(i����NcCs�tttjj��}ddj|�d}tj|�}x�tjdD]�}yt	|d�}Wn%t
k
r�}d||fGHqLnXd}xG|j�}|s�Pn|d}|j|�r�d|||fGq�q�WqLWdS(	Nt(t|t)itrs%s: %sis%s:%s:%s(
tmaptchomptsyststdint	readlinestjointretcompiletargvtopentIOErrortreadlinetsearch(tpatstbigpattprogtfiletfptmsgtlinenotline((s2/usr/lib64/python2.7/Demo/comparisons/regextest.pytmains"
cCs
|jd�S(Ns
(trstrip(ts((s2/usr/lib64/python2.7/Demo/comparisons/regextest.pyR+st__main__(tstringRR
RRt__name__(((s2/usr/lib64/python2.7/Demo/comparisons/regextest.pyt<module>s		PK��Z,��
>>systemtest.pyonu�[����
Afc@s?ddlZddlZddlTd�Zd�Ze�dS(i����N(t*cCs�y
tj}Wn#tk
r2dGHtjd�nXtjdrPtjd}nd}|r�tj|�|ddkr�|d}nt|�n
td�dS(Ns'This system doesn't have symbolic linksiiti����t/(tostreadlinktAttributeErrortsystexittargvtchdirtreportboguslinks(tdummytprefix((s3/usr/lib64/python2.7/Demo/comparisons/systemtest.pytmains





cCs�ytjd�}Wn)tjk
r>}d|d|fGHdSX|j�x<|D]4}|tjksP|tjkrzqPnytj|�t}Wn)tjk
r�d|||fGHqPnXt|�rytj	|�Wq�tjk
rd||tj
|�fGHq�XqPt|�rPytj|�Wn+tjk
rY}d|||fGHqPnXzt
||d�Wdtjd�XqPqPWdS(Nt.s%s%s: can't list: %ss%s%s: can't stat: %ss
%s%s -> %ss%s%s: can't chdir: %sRs..(RtlistdirterrortsorttcurdirtpardirtlstattST_MODEtS_ISLNKtstatRtS_ISDIRR	R
(Rtnamestmsgtnametmode((s3/usr/lib64/python2.7/Demo/comparisons/systemtest.pyR
)s<

(RRRR
R
(((s3/usr/lib64/python2.7/Demo/comparisons/systemtest.pyt<module>s

		!PK��ZD����
systemtest.pynuȯ��#! /usr/bin/python2.7

# 3)  System Test
#
#     Given a list of directories, report any bogus symbolic links contained
#     anywhere in those subtrees.  A bogus symbolic link is one that cannot
#     be resolved because it points to a nonexistent or otherwise
#     unresolvable file.  Do *not* use an external find executable.
#     Directories may be very very deep.  Print a warning immediately if the
#     system you're running on doesn't support symbolic links.

# This implementation:
# - takes one optional argument, using the current directory as default
# - uses chdir to increase performance
# - sorts the names per directory
# - prints output lines of the form "path1 -> path2" as it goes
# - prints error messages about directories it can't list or chdir into

import os
import sys
from stat import *

def main():
    try:
        # Note: can't test for presence of lstat -- it's always there
        dummy = os.readlink
    except AttributeError:
        print "This system doesn't have symbolic links"
        sys.exit(0)
    if sys.argv[1:]:
        prefix = sys.argv[1]
    else:
        prefix = ''
    if prefix:
        os.chdir(prefix)
        if prefix[-1:] != '/': prefix = prefix + '/'
        reportboguslinks(prefix)
    else:
        reportboguslinks('')

def reportboguslinks(prefix):
    try:
        names = os.listdir('.')
    except os.error, msg:
        print "%s%s: can't list: %s" % (prefix, '.', msg)
        return
    names.sort()
    for name in names:
        if name == os.curdir or name == os.pardir:
            continue
        try:
            mode = os.lstat(name)[ST_MODE]
        except os.error:
            print "%s%s: can't stat: %s" % (prefix, name, msg)
            continue
        if S_ISLNK(mode):
            try:
                os.stat(name)
            except os.error:
                print "%s%s -> %s" % \
                      (prefix, name, os.readlink(name))
        elif S_ISDIR(mode):
            try:
                os.chdir(name)
            except os.error, msg:
                print "%s%s: can't chdir: %s" % \
                      (prefix, name, msg)
                continue
            try:
                reportboguslinks(prefix + name + '/')
            finally:
                os.chdir('..')

main()
PK��Z�&bsortingtest.pyonu�[���PK��Z'2ӎ��Wsortingtest.pynuȯ��PK��Zk�4z���	regextest.pynuȯ��PK��Z�&b�sortingtest.pycnu�[���PK��Z]�|I 	 	READMEnu�[���PK��Z7\�AA
Xregextest.pycnu�[���PK��Z,��
>>�!systemtest.pycnu�[���PK��Z�%.R(patternsnu�[���PK��Z7\�AA
�(regextest.pyonu�[���PK��Z,��
>>&-systemtest.pyonu�[���PK��ZD����
�3systemtest.pynuȯ��PKI�<