~louis/ubuntu/trusty/clamav/lp799623_fix_logrotate

« back to all changes in this revision

Viewing changes to libclamav/c++/llvm/utils/lit/lit/ShCommands.py

  • Committer: Bazaar Package Importer
  • Author(s): Scott Kitterman
  • Date: 2010-03-12 11:30:04 UTC
  • mfrom: (0.41.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20100312113004-b0fop4bkycszdd0z
Tags: 0.96~rc1+dfsg-0ubuntu1
* New upstream RC - FFE (LP: #537636):
  - Add OfficialDatabaseOnly option to clamav-base.postinst.in
  - Add LocalSocketGroup option to clamav-base.postinst.in
  - Add LocalSocketMode option to clamav-base.postinst.in
  - Add CrossFilesystems option to clamav-base.postinst.in
  - Add ClamukoScannerCount option to clamav-base.postinst.in
  - Add BytecodeSecurity opiton to clamav-base.postinst.in
  - Add DetectionStatsHostID option to clamav-freshclam.postinst.in
  - Add Bytecode option to clamav-freshclam.postinst.in
  - Add MilterSocketGroup option to clamav-milter.postinst.in
  - Add MilterSocketMode option to clamav-milter.postinst.in
  - Add ReportHostname option to clamav-milter.postinst.in
  - Bump libclamav SO version to 6.1.0 in libclamav6.install
  - Drop clamdmon from clamav.examples (no longer shipped by upstream)
  - Drop libclamav.a from libclamav-dev.install (not built by upstream)
  - Update SO version for lintian override for libclamav6
  - Add new Bytecode Testing Tool, usr/bin/clambc, to clamav.install
  - Add build-depends on python and python-setuptools for new test suite
  - Update debian/copyright for the embedded copy of llvm (using the system
    llvm is not currently feasible)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
class Command:
 
2
    def __init__(self, args, redirects):
 
3
        self.args = list(args)
 
4
        self.redirects = list(redirects)
 
5
 
 
6
    def __repr__(self):
 
7
        return 'Command(%r, %r)' % (self.args, self.redirects)
 
8
 
 
9
    def __cmp__(self, other):
 
10
        if not isinstance(other, Command):
 
11
            return -1
 
12
 
 
13
        return cmp((self.args, self.redirects),
 
14
                   (other.args, other.redirects))
 
15
 
 
16
    def toShell(self, file):
 
17
        for arg in self.args:
 
18
            if "'" not in arg:
 
19
                quoted = "'%s'" % arg
 
20
            elif '"' not in arg and '$' not in arg:
 
21
                quoted = '"%s"' % arg
 
22
            else:
 
23
                raise NotImplementedError,'Unable to quote %r' % arg
 
24
            print >>file, quoted,
 
25
 
 
26
            # For debugging / validation.
 
27
            import ShUtil
 
28
            dequoted = list(ShUtil.ShLexer(quoted).lex())
 
29
            if dequoted != [arg]:
 
30
                raise NotImplementedError,'Unable to quote %r' % arg
 
31
 
 
32
        for r in self.redirects:
 
33
            if len(r[0]) == 1:
 
34
                print >>file, "%s '%s'" % (r[0][0], r[1]),
 
35
            else:
 
36
                print >>file, "%s%s '%s'" % (r[0][1], r[0][0], r[1]),
 
37
 
 
38
class Pipeline:
 
39
    def __init__(self, commands, negate=False, pipe_err=False):
 
40
        self.commands = commands
 
41
        self.negate = negate
 
42
        self.pipe_err = pipe_err
 
43
 
 
44
    def __repr__(self):
 
45
        return 'Pipeline(%r, %r, %r)' % (self.commands, self.negate,
 
46
                                         self.pipe_err)
 
47
 
 
48
    def __cmp__(self, other):
 
49
        if not isinstance(other, Pipeline):
 
50
            return -1
 
51
 
 
52
        return cmp((self.commands, self.negate, self.pipe_err),
 
53
                   (other.commands, other.negate, self.pipe_err))
 
54
 
 
55
    def toShell(self, file, pipefail=False):
 
56
        if pipefail != self.pipe_err:
 
57
            raise ValueError,'Inconsistent "pipefail" attribute!'
 
58
        if self.negate:
 
59
            print >>file, '!',
 
60
        for cmd in self.commands:
 
61
            cmd.toShell(file)
 
62
            if cmd is not self.commands[-1]:
 
63
                print >>file, '|\n ',
 
64
 
 
65
class Seq:
 
66
    def __init__(self, lhs, op, rhs):
 
67
        assert op in (';', '&', '||', '&&')
 
68
        self.op = op
 
69
        self.lhs = lhs
 
70
        self.rhs = rhs
 
71
 
 
72
    def __repr__(self):
 
73
        return 'Seq(%r, %r, %r)' % (self.lhs, self.op, self.rhs)
 
74
 
 
75
    def __cmp__(self, other):
 
76
        if not isinstance(other, Seq):
 
77
            return -1
 
78
 
 
79
        return cmp((self.lhs, self.op, self.rhs),
 
80
                   (other.lhs, other.op, other.rhs))
 
81
 
 
82
    def toShell(self, file, pipefail=False):
 
83
        self.lhs.toShell(file, pipefail)
 
84
        print >>file, ' %s\n' % self.op
 
85
        self.rhs.toShell(file, pipefail)