!I integrate from //ce/main...
[CRYENGINE.git] / Tools / CryVersionSelector / cryproject.py
blobf9942ce2e2230106c0eb68acf5c36f57b481a43e
1 #!/usr/bin/env python3
3 import cryplugin
4 import json
7 class CryProject:
8 def __init__(self):
9 self.data = {}
10 self.path = ''
12 def load(self, path):
13 file = open(path, 'r')
14 self.data = json.loads(file.read())
15 file.close()
17 self.path = path
19 def save(self, path):
20 file = open(path, 'w')
21 file.write(json.dumps(self.data, indent=4, sort_keys=True))
22 file.close()
24 def asset_dir(self):
25 return self.data.get('content', {}).get('assets', [None])[0]
27 def cmakelists_dir(self):
28 return self.data.get('content', {}).get('code', [None])[0]
30 def engine_id(self):
31 return self.data.get('require', {}).get('engine')
33 def is_managed(self):
34 for plugin in self.plugins_list():
35 if 'managed' in plugin.get('type', '').lower():
36 return True
38 if plugin.get('guid') is not None:
39 plugin_file = cryplugin.find(
40 self.data.get(
41 'require', []).get('engine', '.'), plugin['guid'])
42 _plugin = cryplugin.CryPlugin()
43 try:
44 _plugin.load(plugin_file)
45 except Exception:
46 print("Unable to read plugin file %s" % (plugin_file))
47 raise
49 return not _plugin.isNative()
51 return False
53 def name(self):
54 return self.data.get('info', {}).get('name')
56 def libs_list(self):
57 return self.data.get('content', {}).get('libs')
59 def plugins_list(self):
60 return self.data.get('require', {}).get('plugins')
62 def require_list(self):
63 return self.data.get('require', [])
65 def set_engine_id(self, engine_id):
66 self.data['require']['engine'] = engine_id
68 def set_plugin_list(self, plugins):
69 self.data['require']['plugins'] = plugins