-
Notifications
You must be signed in to change notification settings - Fork 106
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
IndentationError: unindent does not match any outer indentation level in msfrpc_smb.py #1
Comments
I was able to recreate the problem locally on my machine. Seems like inconsistent use of tabs vs. spaces in the code. You can fix that yourself by going through the script and replacing each tab with 4 spaces. Python PEP-8 (https://www.python.org/dev/peps/pep-0008/) states that it is strongly recommended to use 4 spaces for each indentation level. If you don't want to go through manually and change each of the tabs in the file to 4 spaces you could write a python script to do that for you and run it over each file you need to clean up. Example python script to remove indentation inconsistencies: lines = []
with open('msfrpc_smb.py', 'r') as f:
for line in f:
line = line.replace('\t', ' ')
lines.append(line)
with open('msfrpc_smb.py', 'w') as f:
f.writelines(lines) |
very helpful |
python script that can be customized for filename and number of spaces and called from terminal. It also creates a backup of the file before operating on it. Based on @bbishop423: # Fixes python files that contain mixed spaces and tabs.
# Typical error message: "IndentationError: unindent does not match any outer indentation level"
# Example usage:
# python fix_tabs.py -f clustering.py -s 2
import argparse
import shutil
if __name__ == '__main__':
parser = argparse.ArgumentParser()
parser.add_argument('-f', '--file', type = str, help='Specify filename.')
parser.add_argument('-s', '--spaces', type = int, default = 4,
help='Specify number of spaces. Default: %(default)s')
args = parser.parse_args()
shutil.copyfile(args.file, args.file + '.bkp')
lines = []
with open(args.file, 'r') as f:
for line in f:
line = line.replace('\t', ' '*args.spaces)
lines.append(line)
with open(args.file, 'w') as f:
f.writelines(lines) |
All possible working solution [Solved] IndentationError: unindent does not match any outer indentation level |
When I type
python msfrpc_smb.py -p batman -t 192.168.1.135
it return me a error belowFile "msfrpc_smb.py", line 95 with open(ipfile) as f: ^ IndentationError: unindent does not match any outer indentation level
How to fix it?
The text was updated successfully, but these errors were encountered: