From: Tony Mack Date: Sat, 7 May 2011 22:59:45 +0000 (-0400) Subject: Initial checkin X-Git-Tag: sfa-1.0-22~73 X-Git-Url: http://git.onelab.eu/?p=sfa.git;a=commitdiff_plain;h=23710aad82de2da85807326fb471965531fd59cc Initial checkin --- diff --git a/sfa/rspecs/rspec_converter.py b/sfa/rspecs/rspec_converter.py new file mode 100755 index 00000000..7a0890e8 --- /dev/null +++ b/sfa/rspecs/rspec_converter.py @@ -0,0 +1,39 @@ +#!/usr/bin/python + +from sfa.rspecs.pg_rspec_converter import PGRSpecConverter +from sfa.rspecs.sfa_rspec_converter import SFARSpecConverter +from sfa.rspecs.rspec_parser import parse_rspec + + +class RSpecConverter: + + @staticmethod + def to_sfa_rspec(in_rspec): + rspec = parse_rspec(in_rspec) + if rspec.format == 'sfa': + return in_rspec + elif rspec.format == 'pg': + return PGRSpecConverter.to_sfa_rspec(in_rspec) + else: + return in_rspec + + @staticmethod + def to_pg_rspec(in_rspec): + rspec = parse_rspec(in_rspec) + if rspec.format == 'pg': + return in_rspec + elif rspec.format == 'sfa': + return SFARSpecConverter.to_pg_rspec(in_rspec) + else: + return in_rspec + + +if __name__ == '__main__': + pg_rspec = 'test/protogeni.rspec' + sfa_rspec = 'test/nodes.rspec' + + print "converting pg rspec to sfa rspec" + print RSpecConverter.to_sfa_rspec(pg_rspec) + + print "converting sfa rspec to pg rspec" + print RSpecConverter.to_pg_rspec(sfa_rspec)