mirror of
https://github.com/soimort/you-get.git
synced 2025-02-11 12:42:29 +03:00
![henryptung](/assets/img/avatar_default.png)
1. Introduce string.safe_chars, safe_print as ways to ensure that a string is encodable using the specified encoding. Unsafe characters are replaced with '?'. safe_print delegates to print and satisfies the same interface, so it can be used as a drop-in override for print in any file. 2. Move get_filename to fs, since that's where it belongs (fs-related filename handling). Move appending of ID, part number, and extension (when applicable) to get_filename, to avoid accidental truncation. 3. Remove common.tr, since the print override supercedes it. 4. Refactor of log module to work with changes (use print with different files instead of direct writes to stdout, stderr). 5. Modify other files to accommodate the changes (remove calls to tr) 6. Random cleanup I found: a. Some changes to impl of download_urls, download_urls_chunked (is this one even used?)). b. sina_download_by_id? c. ffmpeg_convert_ts_to_mkv tries to convert multiple input files onto the same output file, overwriting its own output each time? d. @staticmethod annotations (IDE sads otherwise). 7. Tests for the new encoding handling.
13 lines
397 B
Python
13 lines
397 B
Python
#!/usr/bin/env python
|
|
|
|
import unittest
|
|
|
|
from you_get.util.strings import *
|
|
|
|
class TestStrings(unittest.TestCase):
|
|
def test_safe_chars_simple(self):
|
|
self.assertEqual('', safe_chars('', encoding='utf-8'))
|
|
self.assertEqual('abc', safe_chars('abc', encoding='utf-8'))
|
|
|
|
def test_safe_chars_replace(self):
|
|
self.assertEqual('a?c', safe_chars('a\u20ACc', encoding='ascii')) |