Skip to content

Commit

Permalink
Merge pull request #5 from ZhengnanZhao/exclude-dir
Browse files Browse the repository at this point in the history
Fix logic to exclude directory
  • Loading branch information
zzhengnan authored Jun 17, 2020
2 parents 60784c8 + 4cc2cbb commit 86ac94e
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 5 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ optional arguments:
```

## Example output with `pandas`
Running the utility on a local clone of [pandas](https://github.com/pandas-dev/pandas) produces the following. These are all the packages `pandas` imports that are not part of the standard library.
Running the utility on a local clone of `pandas` as of [this commit](https://github.com/pandas-dev/pandas/tree/6eb34f1ba) produces the following. These are all the packages `pandas` imports that are not part of the standard library.
```
$ iscan ~/Desktop/pandas/pandas/
Third-party packages imported across all python files in /Users/zhengnan/Desktop/pandas/pandas/
Expand All @@ -48,5 +48,5 @@ If you are not interested in, say, packages imported during testing, you can spe
```
$ iscan ~/Desktop/pandas/pandas/ -x ~/Desktop/pandas/pandas/tests/
Third-party packages imported across all python files in /Users/zhengnan/Desktop/pandas/pandas/, EXCLUDING those in /Users/zhengnan/Desktop/pandas/pandas/tests/
['AppKit', 'Foundation', 'IPython', 'PyQt4', 'PyQt5', '_csv', 'botocore', 'bs4', 'cycler', 'dateutil', 'fastparquet', 'hypothesis', 'jedi', 'lxml', 'matplotlib', 'mpl_toolkits', 'numba', 'numexpr', 'numpy', 'odf', 'openpyxl', 'pandas', 'pg8000', 'pkg_resources', 'psycopg2', 'py', 'pyarrow', 'pylab', 'pymysql', 'pytest', 'pytz', 'pyxlsb', 'qtpy', 's3fs', 'scipy', 'sqlalchemy', 'tables', 'xarray', 'xlrd', 'xlsxwriter', 'xlwt']
['AppKit', 'Foundation', 'IPython', 'PyQt4', 'PyQt5', 'botocore', 'bs4', 'dateutil', 'hypothesis', 'lxml', 'matplotlib', 'numexpr', 'numpy', 'odf', 'openpyxl', 'pandas', 'pkg_resources', 'pyarrow', 'pytest', 'pytz', 'pyxlsb', 'qtpy', 's3fs', 'scipy', 'sqlalchemy', 'tables', 'xlrd', 'xlsxwriter', 'xlwt']
```
2 changes: 1 addition & 1 deletion iscan/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '0.3.1'
__version__ = '0.3.2'
2 changes: 1 addition & 1 deletion iscan/scan.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ def scan_directory(dir_to_scan: str, dir_to_exclude: str) -> list:
for root_dir, _, fnames in walk(top=dir_to_scan):
# Skip excluded directory
if dir_to_exclude is not None:
if abspath(root_dir) == abspath(dir_to_exclude):
if abspath(dir_to_exclude) in abspath(root_dir):
continue

for fname in fnames:
Expand Down
1 change: 1 addition & 0 deletions iscan/tests/test_package/city/borough/tricky.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
import ctypes
2 changes: 1 addition & 1 deletion iscan/tests/test_scan.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def test_convert_source_to_tree():


@pytest.mark.parametrize('dir_to_exclude, expected', [
(None, ['datetime', 'matplotlib', 'numpy', 'os', 'pandas', 'shutil', 'time']),
(None, ['ctypes', 'datetime', 'matplotlib', 'numpy', 'os', 'pandas', 'shutil', 'time']),
(join(CURRENT_DIR, 'test_package', 'city'), ['matplotlib', 'numpy', 'os', 'pandas', 'shutil', 'time'])
])
def test_scan_directory(dir_to_exclude, expected):
Expand Down

0 comments on commit 86ac94e

Please sign in to comment.