Skip to content

refactor: use pathlib in util.py #1983

@terriko

Description

@terriko

We're partway through a migration from the older os.path method of handling filesystem paths to the newer Pathlib style, and have a number of files that need updating. I'm filing a separate bug for each so folk doing hacktoberfest can grab one and go really quickly and hopefully so people won't wind up doing too much overlapping work and people can indicate they're working on one by commenting on it.

Basically, the task is to search through the file for the string os.path and replace whatever's there with the equivalent Pathlib construction.

Here's a quick grep on the file to show you what probably needs to be changed:

cve_bin_tool/util.py:                    lambda dirname: os.path.isfile(
cve_bin_tool/util.py:                        os.path.join(dirname, binary + ".exe")
cve_bin_tool/util.py:                lambda dirname: os.path.isfile(os.path.join(dirname, binary)),
cve_bin_tool/util.py:                    if self.pattern_match(os.path.join(dirpath, filename), self.pattern)
cve_bin_tool/util.py:                        os.path.join(dirpath, filename), self.file_exclude_pattern
cve_bin_tool/util.py:                        os.path.join(dirpath, filename), self.folder_exclude_pattern
cve_bin_tool/util.py:                        os.path.join(dirpath, dirname), self.folder_include_pattern
cve_bin_tool/util.py:                        os.path.join(dirpath, dirname), self.folder_exclude_pattern
cve_bin_tool/util.py:                        yield os.path.normpath(os.path.join(dirpath, filename))
cve_bin_tool/util.py:                        yield os.path.normpath(os.path.join(dirpath, dirname))

Don't forget to remove any imports that are no longer needed when you're done! (you can use flake8 to check for those).

Metadata

Metadata

Assignees

No one assigned

    Labels

    good first issueGood for newcomershacktoberfestgood issue for hacktoberfest participation

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions