1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21 """
22 Contains base placeable classes with names based on XLIFF placeables. See the
23 XLIFF standard for more information about what the names mean.
24 """
25
26 from translate.storage.placeables.interfaces import *
27 from translate.storage.placeables.strelem import StringElem
28
29
30 __all__ = ['Bpt', 'Ept', 'Ph', 'It', 'G', 'Bx', 'Ex', 'X', 'Sub', 'to_base_placeables']
31
32
33
34 -class Bpt(MaskingPlaceable, PairedDelimiter):
36
37
38 -class Ept(MaskingPlaceable, PairedDelimiter):
40
41
42 -class Ph(MaskingPlaceable):
45
46
47 -class It(MaskingPlaceable, Delimiter):
49
50
51 -class G(ReplacementPlaceable):
53
54
55 -class Bx(ReplacementPlaceable, PairedDelimiter):
62
63
64 -class Ex(ReplacementPlaceable, PairedDelimiter):
71
72
73 -class X(ReplacementPlaceable, Delimiter):
81
82
83 -class Sub(SubflowPlaceable):
85
86
88 if not isinstance(tree, StringElem):
89 return tree
90
91 base_class = [klass for klass in tree.__class__.__bases__ \
92 if klass in [Bpt, Ept, Ph, It, G, Bx, Ex, X, Sub]]
93
94 if not base_class:
95 base_class = tree.__class__
96 else:
97 base_class = base_class[0]
98
99 newtree = base_class()
100 newtree.id = tree.id
101 newtree.rid = tree.rid
102 newtree.xid = tree.xid
103 newtree.sub = []
104
105 for subtree in tree.sub:
106 newtree.sub.append(to_base_placeables(subtree))
107
108 return newtree
109