Skip to content
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

Get multiline values as a list for INI files. #276

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/docformatter/configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,6 @@ def _do_read_parser_configuration(self) -> None:
]:
if _section in config.sections():
self.flargs_dct = {
k: v if isinstance(v, list) else str(v)
k: v if isinstance(v, list) else v.split() if len(v.split()) > 1 else str(v)
for k, v in config[_section].items()
}
51 changes: 9 additions & 42 deletions src/docformatter/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,7 @@
# Standard Library Imports
import os
import re
import sysconfig

unicode = str

_PYTHON_LIBS = set(sysconfig.get_paths().values())
from glob import glob


def find_py_files(sources, recursive, exclude=None):
Expand All @@ -43,45 +39,16 @@ def find_py_files(sources, recursive, exclude=None):

Return: yields paths to found files.
"""

def not_hidden(name):
"""Return True if file 'name' isn't .hidden."""
return not name.startswith(".")

def is_excluded(name, exclude):
"""Return True if file 'name' is excluded."""
return (
any(
re.search(re.escape(str(e)), name, re.IGNORECASE)
for e in exclude
)
if exclude
else False
)

if exclude:
exclude_pattern = "|".join(exclude)
for name in sorted(sources):
if recursive and os.path.isdir(name):
for root, dirs, children in os.walk(unicode(name)):
dirs[:] = [
d
for d in dirs
if not_hidden(d) and not is_excluded(d, _PYTHON_LIBS)
]
dirs[:] = sorted(
[d for d in dirs if not is_excluded(d, exclude)]
)
files = sorted(
[
f
for f in children
if not_hidden(f) and not is_excluded(f, exclude)
]
)
for filename in files:
if filename.endswith(".py") and not is_excluded(
root, exclude
):
yield os.path.join(root, filename)
all_files = glob(f"{name}/**/*[.py]", recursive=True)
for filename in all_files:
if exclude:
if re.search(exclude_pattern, filename):
continue
yield filename
else:
yield name

Expand Down
Loading