25 from os
import scandir
27 from scandir
import scandir
30 print(
"Please provide the directory where documented .py files are, and the output folder for the .pyzdoc files.")
34pyz_dir_out = sys.argv[2]
37 subfolders, files = [], []
39 for f
in scandir(dir):
41 subfolders.append(f.path)
43 if path.splitext(f.name)[1].lower()
in ext:
47 for dir
in list(subfolders):
51 return subfolders, files
58for pyz_file_path
in filenames:
60 with open(pyz_file_path)
as fd:
61 file_contents = fd.read()
64 module = ast.parse(file_contents)
65 ds = ast.get_docstring(module)
72 pyz_filename_out = pyz_dir_out +
'/' + pyz_file_path[pyz_file_path.rfind(
"_"):] +
'zdoc'
73 with open(pyz_filename_out,
'w')
as pyz_doc_file:
74 pyz_doc_file.write(ds)