Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
warned = False
if create_readme(readme) != create_readme(modules_readme):
for module in sorted(readme):
if mods and module not in mods:
continue
err = None
if module not in modules_readme:
err = "Module {} in README but not in /modules".format(module)
elif (
"".join(readme[module]).strip()
!= "".join(modules_readme[module]).strip()
):
err = "Module {} docstring does not match README".format(module)
if err:
if not warned:
print_stderr("Documentation does not match!\n")
warned = True
print_stderr(err)
for module in modules_readme:
if mods and module not in mods:
continue
if module not in readme:
print_stderr("Module {} in /modules but not in README".format(module))
if show_diff:
print_stderr(
"\n".join(
difflib.unified_diff(
create_readme(readme).split("\n"),
create_readme(modules_readme).split("\n"),
)
)
elif (
"".join(readme[module]).strip()
!= "".join(modules_readme[module]).strip()
):
err = "Module {} docstring does not match README".format(module)
if err:
if not warned:
print_stderr("Documentation does not match!\n")
warned = True
print_stderr(err)
for module in modules_readme:
if mods and module not in mods:
continue
if module not in readme:
print_stderr("Module {} in /modules but not in README".format(module))
if show_diff:
print_stderr(
"\n".join(
difflib.unified_diff(
create_readme(readme).split("\n"),
create_readme(modules_readme).split("\n"),
)
)
)
else:
if warned:
print_stderr("\nUse `py3-cmd docstring --diff` to view diff.")
if mods and module not in mods:
continue
if module not in readme:
print_stderr("Module {} in /modules but not in README".format(module))
if show_diff:
print_stderr(
"\n".join(
difflib.unified_diff(
create_readme(readme).split("\n"),
create_readme(modules_readme).split("\n"),
)
)
)
else:
if warned:
print_stderr("\nUse `py3-cmd docstring --diff` to view diff.")
!= "".join(modules_readme[module]).strip()
):
err = "Module {} docstring does not match README".format(module)
if err:
if not warned:
print_stderr("Documentation does not match!\n")
warned = True
print_stderr(err)
for module in modules_readme:
if mods and module not in mods:
continue
if module not in readme:
print_stderr("Module {} in /modules but not in README".format(module))
if show_diff:
print_stderr(
"\n".join(
difflib.unified_diff(
create_readme(readme).split("\n"),
create_readme(modules_readme).split("\n"),
)
)
)
else:
if warned:
print_stderr("\nUse `py3-cmd docstring --diff` to view diff.")
for module in sorted(readme):
if mods and module not in mods:
continue
err = None
if module not in modules_readme:
err = "Module {} in README but not in /modules".format(module)
elif (
"".join(readme[module]).strip()
!= "".join(modules_readme[module]).strip()
):
err = "Module {} docstring does not match README".format(module)
if err:
if not warned:
print_stderr("Documentation does not match!\n")
warned = True
print_stderr(err)
for module in modules_readme:
if mods and module not in mods:
continue
if module not in readme:
print_stderr("Module {} in /modules but not in README".format(module))
if show_diff:
print_stderr(
"\n".join(
difflib.unified_diff(
create_readme(readme).split("\n"),
create_readme(modules_readme).split("\n"),
)
)
)
else:
msg, exc_type.__name__, filename, line_no
)
except: # noqa e722
# something went wrong report what we can.
msg = "{}.".format(msg)
finally:
# delete tb!
del tb
# log the exception and notify user
self.py3_wrapper.log(msg, "warning")
if traceback:
# if debug is not in the config then we are at an early stage of
# running py3status and logging is not yet available so output the
# error to STDERR so it can be seen
if "debug" not in self.config:
print_stderr("\n".join(traceback))
elif self.config.get("log_file"):
self.py3_wrapper.log("".join(["Traceback\n"] + traceback))
if notify_user:
self.py3_wrapper.notify_user(msg, level=level)
def update_readme_for_modules(modules):
"""
Update README.md updating the sections for the module names listed.
"""
readme = parse_readme()
module_docstrings = core_module_docstrings()
if modules == ["__all__"]:
modules = core_module_docstrings().keys()
for module in modules:
if module in module_docstrings:
print_stderr("Updating README.md for module {}".format(module))
readme[module] = module_docstrings[module]
else:
print_stderr("Module {} not in core modules".format(module))
# write the file
readme_file = os.path.join(modules_directory(), "README.md")
with open(readme_file, "w") as f:
f.write(create_readme(readme))
if not replaced:
out = out + [
"".join(_to_docstring(modules_dict[mod])).strip() + "\n"
]
replaced = True
if lines:
done = True
if not done and not lines:
lines = True
continue
if not lines or done:
out.append(row)
mod_file = os.path.join(modules_directory(), mod + ".py")
with open(mod_file, "w") as f:
f.writelines(out)
print_stderr("Modules updated from README.md")