Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def finalize_options(self):
"Get options from config files."
self.arguments = {}
computed_settings = from_path(os.getcwd())
for (key, value) in itemsview(computed_settings):
self.arguments[key] = value
if file_names == ['-']:
try:
# python 3
file_ = sys.stdin.buffer
except AttributeError:
# python 2
file_ = sys.stdin
SortImports(file_=file_, write_to_stdout=True, **arguments)
else:
if not file_names:
file_names = ['.']
arguments['recursive'] = True
if not arguments.get('apply', False):
arguments['ask_to_apply'] = True
config = from_path(arguments.get('settings_path', '') or os.path.abspath(file_names[0]) or os.getcwd()).copy()
config.update(arguments)
wrong_sorted_files = False
skipped = []
if config.get('filter_files'):
filtered_files = []
for file_name in file_names:
if should_skip(file_name, config):
skipped.append(file_name)
else:
filtered_files.append(file_name)
file_names = filtered_files
if arguments.get('recursive', False):
file_names = iter_source_code(file_names, config, skipped)
num_skipped = 0