|
22 | 22 | 'join_dict', |
23 | 23 | 'join_lines', |
24 | 24 | 'join_list', |
25 | | - 'str_spice', |
26 | | - 'str_spice_list', |
27 | 25 | 'prefix_lines', |
28 | 26 | 'remove_multi_space', |
29 | | - 'TextBufer', |
30 | 27 | ] |
31 | 28 |
|
32 | 29 | #################################################################################################### |
33 | 30 |
|
34 | 31 | import os |
35 | 32 |
|
36 | | -#################################################################################################### |
37 | | - |
38 | | -from PySpice.Unit.Unit import UnitValue |
39 | | - |
40 | | -#################################################################################################### |
41 | | - |
42 | | -def str_spice(obj, unit=True): |
43 | | - # Fixme: right place ??? |
44 | | - '''Convert an object to a Spice compatible string.''' |
45 | | - if isinstance(obj, UnitValue): |
46 | | - if unit: |
47 | | - return obj.str_spice() |
48 | | - else: # Fixme: ok ??? |
49 | | - return obj.str(spice=False, space=False, unit=False) |
50 | | - else: |
51 | | - return str(obj) |
52 | | - |
53 | | -#################################################################################################### |
54 | | - |
55 | | -def str_spice_list(*args): |
56 | | - return [str_spice(x) for x in args] |
| 33 | +from .unit import str_spice |
57 | 34 |
|
58 | 35 | #################################################################################################### |
59 | 36 |
|
60 | 37 | def prefix_lines(items, prefix=''): |
61 | 38 | return [prefix + str(item) |
62 | 39 | for item in items |
63 | | - if item is not None] # Fixme: and item |
| 40 | + if item is not None] # Fixme: and item |
64 | 41 |
|
65 | 42 | #################################################################################################### |
66 | 43 |
|
@@ -110,35 +87,3 @@ def remove_multi_space(txt: str) -> str: |
110 | 87 | new_txt += c |
111 | 88 | last_c = c |
112 | 89 | return new_txt |
113 | | - |
114 | | -#################################################################################################### |
115 | | - |
116 | | -class TextBuffer: |
117 | | - |
118 | | - ############################################## |
119 | | - |
120 | | - def __init__(self): |
121 | | - self._lines = [] |
122 | | - |
123 | | - ############################################## |
124 | | - |
125 | | - def _append_line(self, line): |
126 | | - if line is not None: |
127 | | - _ = str(line) |
128 | | - if _: |
129 | | - self._lines.append(_) |
130 | | - |
131 | | - ############################################## |
132 | | - |
133 | | - def __iadd__(self, obj): |
134 | | - if isinstance(obj, (list, tuple)): |
135 | | - for _ in obj: |
136 | | - self._append_line(_) |
137 | | - else: |
138 | | - self._append_line(obj) |
139 | | - return self |
140 | | - |
141 | | - ############################################## |
142 | | - |
143 | | - def __str__(self): |
144 | | - return os.linesep.join(self._lines) |
0 commit comments