Ejemplo n.º 1
0
 def __str__(self):
     L = []
     n = len(self)
     if conf.getboolean('block', 'header'):
         L.append('# --- block %s ---' % self.name)
     if conf.getboolean('block', 'bytecode'):
         bcs = ["'%s'" % (i.bytes.encode('hex')) for i in self]
         pad = conf.getint('block', 'padding') or 0
         maxlen = max(map(len, bcs)) + pad
         bcs = [s.ljust(maxlen) for s in bcs]
     else:
         bcs = [''] * n
     ins = [('{:<10}'.format(i.address), i.formatter(i)) for i in self]
     for j in range(n):
         L.append('%s %s %s' % (ins[j][0], bcs[j], ins[j][1]))
     return '\n'.join(L)
Ejemplo n.º 2
0
 def __str__(self):
     L = []
     n = len(self)
     if conf.getboolean('block','header'):
         L.append('# --- block %s ---' % self.name)
     if conf.getboolean('block','bytecode'):
         bcs = [ "'%s'"%(i.bytes.encode('hex')) for i in self ]
         pad = conf.getint('block','padding') or 0
         maxlen = max(map(len,bcs))+pad
         bcs = [ s.ljust(maxlen) for s in bcs ]
     else:
         bcs = ['']*n
     ins = [ ('{:<10}'.format(i.address),i.formatter(i)) for i in self ]
     for j in range(n):
         L.append('%s %s %s'%(ins[j][0],bcs[j],ins[j][1]))
     return '\n'.join(L)
Ejemplo n.º 3
0
 def _vltable(self, **kargs):
     T = vltable(**kargs)
     n = len(self.of.instr)
     for i in self.of.instr:
         ins2 = i.toks()
         if isinstance(ins2, str): ins2 = [(Token.Literal, ins2)]
         ins = [(Token.Address, '{:<10}'.format(i.address)),
                (Token.Column, ''),
                (Token.Literal, "'%s'" % (i.bytes.encode('hex'))),
                (Token.Column, '')]
         T.addrow(ins + ins2)
     if conf.getboolean('block', 'bytecode'):
         pad = conf.getint('block', 'padding') or 0
         T.colsize[1] += pad
     if conf.getboolean('block', 'header'):
         T.header = ('# --- block %s ---' % self.of.name).ljust(
             T.width, '-')
     if conf.getboolean('block', 'footer'):
         T.footer = '-' * T.width
     return T
Ejemplo n.º 4
0
"""

from amoco.config import conf

from amoco.logger import Log, logging
logger = Log(__name__)

try:
    import sqlalchemy as sql
    from sqlalchemy import orm
    from sqlalchemy.ext.declarative import declarative_base
    has_sql = True
    Session = orm.scoped_session(orm.sessionmaker())
    Base = declarative_base()
    logflag = conf.getboolean('db', 'log')
    if logflag:
        for l in ('sqlalchemy.engine', 'sqlalchemy.orm'):
            alog = logging.getLogger(l)
            for h in logger.handlers:
                alog.addHandler(h)
            alog.setLevel(logger.level)
except ImportError:
    logger.warning(u"package sqlalchemy not found.")
    has_sql = False


def create(filename=None):
    """creates the database engine and bind it to the scoped Session class.
    The database URL (see :mod:`config.py`) is opened and the
    schema is created if necessary. The default URL uses *sqlite* dialect and