2 import xml.etree.ElementTree as ET
4 scrpit_dir = os.path.dirname(os.path.abspath(__file__))
5 spec_dir = os.path.join(scrpit_dir, "csapi-tizenfx.spec")
6 nuspec_file = os.path.join(scrpit_dir, "../pkg/Tizen.NET/Tizen.NET.nuspec")
7 tree = ET.parse(nuspec_file)
10 tfm_list1 = [] #tizen90, tizen80, tizen70, tizen60, tizen50, tizen40
11 tfm_list2 = [] #tizen10.0
12 tfm_list3 = [] #net6.0-tizen8.0, net6.0-tizen, net6.0
13 for meta_child in root.iter():
14 if meta_child.tag == "{http://schemas.microsoft.com/packaging/2012/06/nuspec.xsd}metadata":
15 for depen_child in meta_child:
16 if depen_child.tag == "{http://schemas.microsoft.com/packaging/2012/06/nuspec.xsd}dependencies":
17 for group in depen_child:
18 tfm = group.attrib["targetFramework"].lower()
19 if tfm.startswith("tizen"):
21 tfm_list1.append(tfm.replace(".", "").strip())
23 tfm_list2.append(tfm.strip())
24 elif tfm.startswith("net"):
26 tfm_list3.append(tfm.strip() + "-tizen")
27 tfm_list3.append(tfm.strip())
30 tfm_list1 = list(set(tfm_list1))
31 tfm_list1.sort(reverse=True)
32 tfm_list2 = list(set(tfm_list2))
33 tfm_list2.sort(reverse=True)
34 tfm_list3 = list(set(tfm_list3))
35 tfm_list3.sort(key=len)
36 tfm_list3.sort(key=lambda s: float(re.search(r'(\d+)\.', s).group()[0]))
38 tfm_list = tfm_list3 + tfm_list2 + tfm_list1
40 f = open(spec_dir,'r')
41 origin_data = f.read()
44 new_data = origin_data.replace("@tfm_support@", ':'.join(tfm_list))
46 f = open(spec_dir, 'w')