| 3232 | self.text = '' |
| 3233 | |
| 3234 | def add_content(self, content, to_, verbose=True): |
| 3235 | if isinstance(content, str): |
| 3236 | content = content.encode('utf8') |
| 3237 | |
| 3238 | # Specification for the line we write is supposed to be in |
| 3239 | # https://packaging.python.org/en/latest/specifications/binary-distribution-format |
| 3240 | # but it's not very clear. |
| 3241 | # |
| 3242 | h = hashlib.sha256(content) |
| 3243 | digest = h.digest() |
| 3244 | digest = base64.urlsafe_b64encode(digest) |
| 3245 | digest = digest.rstrip(b'=') |
| 3246 | digest = digest.decode('utf8') |
| 3247 | |
| 3248 | self.text += f'{to_},sha256={digest},{len(content)}\n' |
| 3249 | if verbose: |
| 3250 | log2(f'Adding {to_}') |
| 3251 | |
| 3252 | def add_file(self, from_, to_): |
| 3253 | log1(f'Adding file: {os.path.relpath(from_)} => {to_}') |