Skip to content

Commit

Permalink
Fixed issue plone#552
Browse files Browse the repository at this point in the history
  • Loading branch information
MohammadBinAftab committed Feb 6, 2025
1 parent c9a35d7 commit 20ae548
Show file tree
Hide file tree
Showing 4 changed files with 153 additions and 419 deletions.
30 changes: 19 additions & 11 deletions fix-converted-myst.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
import os
import re


logging.basicConfig()
logging.basicConfig(encoding='utf-8') # Add encoding for proper character handling
logger = logging.getLogger("fix converted MyST documentation")
logger.setLevel(logging.INFO)

Expand Down Expand Up @@ -41,16 +40,25 @@ def remove_github_warning(data):
for name in files:
if name.endswith(".py") or name.endswith(".md"):
filename = os.path.join(root, name)
with open(filename, "r+") as f:
data = f.read()
data = replace_label_underscore(data)
data = remove_github_warning(data)
f.seek(0)
f.write(data)
f.truncate()
count_files["modified"] += 1
logger.info(f"{filename} modified.")
try:
with open(filename, "r+") as f:
original_data = f.read()
modified_data = replace_label_underscore(original_data)
modified_data = remove_github_warning(modified_data)

if modified_data != original_data:
f.seek(0)
f.write(modified_data)
f.truncate()
count_files["modified"] += 1
logger.info(f"{filename} modified.")
else:
count_files["unmodified"] += 1
logger.info(f"{filename} unmodified.")


except IOError as e:
logger.error(f"Error processing {filename}: {e}")

logger.info(f'MyST modified for {count_files["modified"]} files.')
logger.info(f'{count_files["unmodified"]} files unmodified.')
5 changes: 1 addition & 4 deletions src/plone/api/env.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,10 +178,7 @@ def getOwner(self):
return None

def getWrappedOwner(self):
return None


def debug_mode():
return None... def debug_mode():
"""Return True if your zope instance is running in debug mode.
:Example: :ref:`env-debug-mode-example`
Expand Down
4 changes: 2 additions & 2 deletions src/plone/api/tests/test_doctests.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,9 @@ def test_suite():
for filename in os.listdir(docs_path):
try:
doctests.append(DocFileSuite(os.path.join(path, filename)))
except OSError:
except OSError as e: # Capture the OSError instance as 'e'
logger.warning(
f"test_doctest.py skipping {filename}",
f"test_doctest.py skipping {filename}: {e}", # Include the error message
)

return unittest.TestSuite(doctests)
Loading

0 comments on commit 20ae548

Please sign in to comment.