This repository has been archived by the owner on Apr 29, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 126
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Fixes #41 * Added doc string and code changes * Addressing changes ; q' * Correcting spelling
- Loading branch information
1 parent
946f762
commit 6ba7334
Showing
3 changed files
with
53 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,4 +8,5 @@ | |
license='BSD', | ||
packages=['pydsa'], | ||
zip_safe=False, | ||
install_requires=['autopep8'], | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
# !/usr/bin/env python | ||
''' | ||
This module automatically checks for pep8 format. | ||
It scans the complete folder, searches for python files | ||
(ignoring the virtual environment python files) and automatially | ||
format it according to pep8 format using a python plugin 'autopep8'. | ||
''' | ||
|
||
import os | ||
import autopep8 | ||
import sys | ||
|
||
|
||
BASE_DIR = os.path.abspath(__file__) | ||
|
||
|
||
def format_file(path): | ||
''' | ||
The function, using 'for' loop scans all the directories as well | ||
as sub-directories of the folder for python file and checks | ||
for pep8 format. | ||
''' | ||
p = "" | ||
for dirpath, _, filenames in os.walk(path): | ||
if(os.path.exists(os.path.join(dirpath, 'bin/activate'))): | ||
p = dirpath | ||
for f in filenames: | ||
if f.endswith('.py'): | ||
filename = os.path.abspath(os.path.join(dirpath, f)) | ||
if (not bool(p)): | ||
if os.access(filename, os.W_OK): | ||
try: | ||
file1 = open(filename, 'r') | ||
source_code = file1.read() | ||
file1.seek(0) | ||
file1 = open(filename, 'w') | ||
file1.truncate() | ||
file1.write(autopep8.fix_code(source_code)) | ||
file1.close() | ||
except: | ||
print(filename) | ||
print(sys.exc_info()[0]) | ||
|
||
|
||
if __name__ == "__main__": | ||
path_of_dir = [ | ||
os.path.dirname(BASE_DIR), | ||
] | ||
for x in path_of_dir: | ||
format_file(x) |