From 72acbeb921f608a204b7e57125ff6c6f6f160bd6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Ga=C5=88o?= Date: Tue, 6 Sep 2022 16:08:18 +0200 Subject: [PATCH] fatfsparse.py: enable automatic detection of lfn --- components/fatfs/fatfsparse.py | 7 +++---- components/fatfs/test_fatfsgen/test_fatfsparse.py | 2 +- docs/en/api-reference/storage/fatfs.rst | 2 +- docs/zh_CN/api-reference/storage/fatfs.rst | 2 +- 4 files changed, 6 insertions(+), 7 deletions(-) diff --git a/components/fatfs/fatfsparse.py b/components/fatfs/fatfsparse.py index ad8195798f..fcc267e94a 100755 --- a/components/fatfs/fatfsparse.py +++ b/components/fatfs/fatfsparse.py @@ -55,9 +55,8 @@ def traverse_folder_tree(directory_bytes_: bytes, try: obj_: dict = Entry.ENTRY_FORMAT_SHORT_NAME.parse( directory_bytes_[obj_address_: obj_address_ + FATDefaults.ENTRY_SIZE]) - except (construct.core.ConstError, UnicodeDecodeError) as e: - if not args.long_name_support: - raise e + except (construct.core.ConstError, UnicodeDecodeError): + args.long_name_support = True continue if obj_['DIR_Attr'] == 0: # empty entry @@ -90,7 +89,7 @@ if __name__ == '__main__': help='Path to the image that will be parsed and extracted.') argument_parser.add_argument('--long-name-support', action='store_true', - help='Set flag to enable long names support.') + help=argparse.SUPPRESS) argument_parser.add_argument('--wear-leveling', action='store_true', diff --git a/components/fatfs/test_fatfsgen/test_fatfsparse.py b/components/fatfs/test_fatfsgen/test_fatfsparse.py index 648926ca44..f2a5b59c89 100755 --- a/components/fatfs/test_fatfsgen/test_fatfsparse.py +++ b/components/fatfs/test_fatfsgen/test_fatfsparse.py @@ -320,7 +320,7 @@ class FatFSGen(unittest.TestCase): f'{os.path.join(os.path.dirname(__file__), "..", "fatfsgen.py")}', 'testf', '--long_name_support' ], stderr=STDOUT) - run(['python', '../fatfsparse.py', 'fatfs_image.img', '--long-name-support'], stderr=STDOUT) + run(['python', '../fatfsparse.py', 'fatfs_image.img'], stderr=STDOUT) assert compare_folders('testf', 'Espressif') diff --git a/docs/en/api-reference/storage/fatfs.rst b/docs/en/api-reference/storage/fatfs.rst index b00691ad76..1b99c61a1b 100644 --- a/docs/en/api-reference/storage/fatfs.rst +++ b/docs/en/api-reference/storage/fatfs.rst @@ -144,4 +144,4 @@ It is a reverse tool of (:component_file:`fatfsgen.py`), i.e. Usage:: - ./fatfsparse.py [-h] [--long-name-support] [--wear-leveling] fatfs_image.img + ./fatfsparse.py [-h] [--wear-leveling] fatfs_image.img diff --git a/docs/zh_CN/api-reference/storage/fatfs.rst b/docs/zh_CN/api-reference/storage/fatfs.rst index 5cddab2e3b..fdc3a7a0f9 100644 --- a/docs/zh_CN/api-reference/storage/fatfs.rst +++ b/docs/zh_CN/api-reference/storage/fatfs.rst @@ -144,4 +144,4 @@ FatFs 分区分析器 您可以使用:: - ./fatfsparse.py [-h] [--long-name-support] [--wear-leveling] fatfs_image.img + ./fatfsparse.py [-h] [--wear-leveling] fatfs_image.img