INNER CODE UNIT · Python

__init__

aqzt/kjyw · shell/wget/rename.py:10

    def __init__(self, input, output, path, is_url):
        self.input_encoding = input
        self.output_encoding = output
        self.path = path
        self.is_url = is_url

    def start(self):
        self.rename_dir(self.path)

    def rename(self, root, path):
        try:
            if self.is_url:
                new = urllib.unquote(path).decode(self.input_encoding).encode(self.output_encoding)
            else:
                new = path.decode(self.input_encoding).encode(self.output_encoding)
            os.rename(os.path.join(root, path), os.path.join(root, new))
        except:
            pass

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…