3 from sfa.rspecs.pg_rspec_converter import PGRSpecConverter
4 from sfa.rspecs.sfa_rspec_converter import SfaRSpecConverter
5 from sfa.rspecs.rspec import RSpec
6 from sfa.rspecs.version_manager import VersionManager
11 def to_sfa_rspec(in_rspec, content_type=None):
12 rspec = RSpec(in_rspec)
13 version_manager = VersionManager()
14 sfa_version = version_manager._get_version('sfa', '1')
15 pg_version = version_manager._get_version('protogeni', '2')
16 if rspec.version.type.lower() == sfa_version.type.lower():
18 elif rspec.version.type.lower() == pg_version.type.lower():
19 return PGRSpecConverter.to_sfa_rspec(in_rspec, content_type)
24 def to_pg_rspec(in_rspec, content_type=None):
25 rspec = RSpec(in_rspec)
26 version_manager = VersionManager()
27 sfa_version = version_manager._get_version('sfa', '1')
28 pg_version = version_manager._get_version('protogeni', '2')
30 if rspec.version.type.lower() == pg_version.type.lower():
32 elif rspec.version.type.lower() == sfa_version.type.lower():
33 return SfaRSpecConverter.to_pg_rspec(in_rspec, content_type)
38 if __name__ == '__main__':
39 pg_rspec = 'test/protogeni.rspec'
40 sfa_rspec = 'test/nodes.rspec'
42 print "converting pg rspec to sfa rspec"
43 print RSpecConverter.to_sfa_rspec(pg_rspec)
45 print "converting sfa rspec to pg rspec"
46 print RSpecConverter.to_pg_rspec(sfa_rspec)