Detect byts/string, and load config by default.

This commit is contained in:
2023-10-22 18:41:09 +02:00
parent 9ac9ae210d
commit 8a04be49e7
2 changed files with 20 additions and 9 deletions

View File

@@ -5,14 +5,15 @@ plugins for Midnight Commander.
Tested against python 3.11 and mc 4.8.29 Tested against python 3.11 and mc 4.8.29
Changelog: Changelog:
1.4 Detect byts/string, and load config by default
1.3 Added ability to read config from mc/ini file. 1.3 Added ability to read config from mc/ini file.
1.2 Switch to python3 1.2 Switch to python3
1.1 Added item pattern, and common git/uid attrs 1.1 Added item pattern, and common git/uid attrs
1.0 Initial release 1.0 Initial release
Author: Roman 'gryf' Dobosz <gryf73@gmail.com> Author: Roman 'gryf' Dobosz <gryf73@gmail.com>
Date: 2023-10-18 Date: 2023-10-22
Version: 1.3 Version: 1.4
Licence: BSD Licence: BSD
""" """
import argparse import argparse
@@ -93,23 +94,33 @@ class Archive(object):
self._arch = fname self._arch = fname
self.name_map = {} self.name_map = {}
self._contents = self._get_dir() self._contents = self._get_dir()
self.config = Config(self)
def _map_name(self, name): def _map_name(self, name):
"""MC still have a bug in extfs subsystem, in case of filepaths with """MC still have a bug in extfs subsystem, in case of filepaths with
leading space. This is workaround to this bug, which replaces leading leading space. This is workaround to this bug, which replaces leading
space with tilda.""" space with tilda."""
if name.startswith(b" "): if isinstance(name, bytes):
new_name = b"".join([b"~", name[1:]]) if name.startswith(b" "):
return new_name new_name = b"".join([b"~", name[1:]])
return new_name
else:
if name.startswith(" "):
new_name = "".join(["~", name[1:]])
return new_name
return name return name
def _get_real_name(self, name): def _get_real_name(self, name):
"""Get real filepath of the file. See _map_name docstring for """Get real filepath of the file. See _map_name docstring for
details.""" details."""
for item in self._contents: for item in self._contents:
if item[b'display_name'] == name.encode('utf-8', if isinstance(name, bytes):
'surrogateescape'): if item[b'display_name'] == name.encode('utf-8',
return item[b'fpath'] 'surrogateescape'):
return item[b'fpath']
else:
if item['display_name'] == name:
return item['fpath']
return None return None
def _get_dir(self): def _get_dir(self):

View File

@@ -20,7 +20,7 @@ license_files = LICENSE
long_description = file: README.rst long_description = file: README.rst
name = extfslib name = extfslib
url = https://github.com/gryf/mc_extfslib url = https://github.com/gryf/mc_extfslib
version = 1.3 version = 1.4
[options] [options]
py_modules = extfslib py_modules = extfslib