Exemplo n.º 1
0
Arquivo: base.py Projeto: vdel/CoMFoRT
                if n==id:
                    return behavior
        else:
            return __behaviorRegistry[name][0][1]
    return None

def newFromBehavior(name, id=None):
    """Given a name, return a behaviored ContentLine or Component."""
    name = name.upper()
    behavior = getBehavior(name, id)
    if behavior is None:
        raise VObjectError("No behavior found named %s" % name)
    if behavior.isComponent:
        obj = Component(name)
    else:
        obj = ContentLine(name, [], '')
    obj.behavior = behavior
    obj.isNative = False
    return obj


#--------------------------- Helper function -----------------------------------
def backslashEscape(s):
    s=s.replace("\\","\\\\").replace(";","\;").replace(",","\,")
    return s.replace("\r\n", "\\n").replace("\n","\\n").replace("\r","\\n")

#------------------- Testing and running functions -----------------------------
if __name__ == '__main__':
    import tests
    tests._test()   
Exemplo n.º 2
0
def test_file(file):
    _test(file)
Exemplo n.º 3
0
                        action='store_true',
                        help='show runnning instruction')
    parser.add_argument('--debug-io',
                        dest='debug_io',
                        action='store_true',
                        help='use a line for one IO')
    parser.add_argument('--tape',
                        dest='tape',
                        action='store',
                        default='square.txt',
                        help='filename of tape to run (default=square.txt)')

    args = parser.parse_args()
    SHOW_RUNNNING_INSTRUCTION = args.show_runnning_instruction
    DEBUG_IO = args.debug_io

    if args.test:
        print "Running tests..."
        from tests import _test
        edsac = Edsac()
        _test(edsac)
    elif globals().get("DEBUG"):
        # make easy debug on ipython
        print "Running tests..."
        import tests
        reload(tests)
        edsac = Edsac()
        tests._test(edsac)
    else:
        main()
Exemplo n.º 4
0

def newFromBehavior(name, id=None):
    """Given a name, return a behaviored ContentLine or Component."""
    name = name.upper()
    behavior = getBehavior(name, id)
    if behavior is None:
        raise VObjectError("No behavior found named %s" % name)
    if behavior.isComponent:
        obj = Component(name)
    else:
        obj = ContentLine(name, [], '')
    obj.behavior = behavior
    obj.isNative = False
    return obj


#--------------------------- Helper function -----------------------------------
def backslashEscape(s):
    if isinstance(s, basestring):
        s = s.replace("\\", "\\\\").replace(";", "\;").replace(",", "\,")
        return s.replace("\r\n", "\\n").replace("\n",
                                                "\\n").replace("\r", "\\n")
    return ''


#------------------- Testing and running functions -----------------------------
if __name__ == '__main__':
    import tests
    tests._test()
Exemplo n.º 5
0
                        action='store_true',
                        help='show runnning instruction')
    parser.add_argument('--debug-io',
                        dest='debug_io',
                        action='store_true',
                        help='use a line for one IO')
    parser.add_argument('--tape',
                        dest='tape',
                        action='store',
                        default='square.txt',
                        help='filename of tape to run (default=square.txt)')

    args = parser.parse_args()
    SHOW_RUNNNING_INSTRUCTION = args.show_runnning_instruction
    DEBUG_IO = args.debug_io

    if args.test:
        print "Running tests..."
        from tests import _test
        edsac = Edsac()
        _test(edsac)
    elif globals().get("DEBUG"):
        # make easy debug on ipython
        print "Running tests..."
        import tests
        reload(tests)
        edsac = Edsac()
        tests._test(edsac)
    else:
        main()