def __write_merged_imports(self, file: TextIOWrapper, imports: list):
"""
Sorts and write the given imports to the file, adding a blank line between
each group
f -- the file object (needs write permission)
imports -- the list of imports
"""
sorted_imports = self.sort_imports(imports)
previous_group = -1
for imp in sorted_imports:
group = self.get_import_group(imp)
if not (group == previous_group):
if not (previous_group == -1):
file.write("\n")
previous_group = group
file.write(imp)
评论列表
文章目录