module pycode.code_helper

Short summary

module pyquickhelper.pycode.code_helper

Various function to clean the code.

source on GitHub

Functions

function

truncated documentation

remove_extra_spaces_and_pep8

Removes extra spaces in a filename, replaces the file in place.

remove_extra_spaces_folder

Removes extra files in a folder for specific file extensions.

Documentation

Various function to clean the code.

source on GitHub

pyquickhelper.pycode.code_helper.remove_extra_spaces_and_pep8(filename, apply_pep8=True, aggressive=False, is_string=None)[source]

Removes extra spaces in a filename, replaces the file in place.

Parameters:
  • filename – file name or string (but it assumes it is python).

  • apply_pep8 – if True, calls autopep8 on the file

  • aggressive – more aggressive

  • is_string – force filename to be a string

Returns:

number of removed extra spaces

source on GitHub

pyquickhelper.pycode.code_helper.remove_extra_spaces_folder(folder, extensions=('.py', '.rst', '.md', '.pyx', '.pxd'), apply_pep8=True, file_filter=None)[source]

Removes extra files in a folder for specific file extensions.

Parameters:
  • folder – folder to explore

  • extensions – list of file extensions to process

  • apply_pep8 – if True, calls autopep8 on the file

  • file_filter – None of function which filters based on the filename

Returns:

the list of modified files

The function does not check files having /build/ or /dist/ or temp_ or /build2/ or /build3/ in their name.

The signature of file_filter is the following:

def file_filter(filename):
    return True or False

source on GitHub