Show More
@@ -106,6 +106,23 b' class filebundlestore(object):' | |||
|
106 | 106 | return None |
|
107 | 107 | |
|
108 | 108 | |
|
109 | def format_placeholders_args(args, filename=None, handle=None): | |
|
110 | """Formats `args` with Infinitepush replacements. | |
|
111 | ||
|
112 | Hack to get `str.format()`-ed strings working in a BC way with | |
|
113 | bytes. | |
|
114 | """ | |
|
115 | formatted_args = [] | |
|
116 | for arg in args: | |
|
117 | if filename and arg == b'{filename}': | |
|
118 | formatted_args.append(filename) | |
|
119 | elif handle and arg == b'{handle}': | |
|
120 | formatted_args.append(handle) | |
|
121 | else: | |
|
122 | formatted_args.append(arg) | |
|
123 | return formatted_args | |
|
124 | ||
|
125 | ||
|
109 | 126 | class externalbundlestore(abstractbundlestore): |
|
110 | 127 | def __init__(self, put_binary, put_args, get_binary, get_args): |
|
111 | 128 | """ |
@@ -144,9 +161,9 b' class externalbundlestore(abstractbundle' | |||
|
144 | 161 | temp.write(data) |
|
145 | 162 | temp.flush() |
|
146 | 163 | temp.seek(0) |
|
147 |
formatted_args = |
|
|
148 |
|
|
|
149 |
|
|
|
164 | formatted_args = format_placeholders_args( | |
|
165 | self.put_args, filename=temp.name | |
|
166 | ) | |
|
150 | 167 | returncode, stdout, stderr = self._call_binary( |
|
151 | 168 | [self.put_binary] + formatted_args |
|
152 | 169 | ) |
@@ -166,12 +183,10 b' class externalbundlestore(abstractbundle' | |||
|
166 | 183 | def read(self, handle): |
|
167 | 184 | # Won't work on windows because you can't open file second time without |
|
168 | 185 | # closing it |
|
169 | # TODO: rewrite without str.format() | |
|
170 | 186 | with pycompat.namedtempfile() as temp: |
|
171 |
formatted_args = |
|
|
172 |
|
|
|
173 | for arg in self.get_args | |
|
174 | ] | |
|
187 | formatted_args = format_placeholders_args( | |
|
188 | self.get_args, filename=temp.name, handle=handle | |
|
189 | ) | |
|
175 | 190 | returncode, stdout, stderr = self._call_binary( |
|
176 | 191 | [self.get_binary] + formatted_args |
|
177 | 192 | ) |
General Comments 0
You need to be logged in to leave comments.
Login now