Skip to content

Commit

Permalink
Merge pull request #68 from trisdoan/fix-odoo-module-migrator
Browse files Browse the repository at this point in the history
[FIX] replace pkg_resources with importlib.metadata
  • Loading branch information
sebalix authored Jan 9, 2025
2 parents 539417e + 1decd37 commit 9e90e61
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions oca_port/migrate_addon.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import os
import tempfile
import urllib.parse
import pkg_resources
from importlib import metadata

import click

Expand Down Expand Up @@ -154,10 +154,12 @@ def run(self):
with tempfile.TemporaryDirectory() as patches_dir:
self._generate_patches(patches_dir)
self._apply_patches(patches_dir)
if pkg_resources.get_distribution("odoo-module-migrator") is None:
g.run_pre_commit(self.app.repo, self.app.addon)
else:

try:
metadata.metadata("odoo-module-migrator")
adapted = self._apply_code_pattern()
except metadata.PackageNotFoundError:
g.run_pre_commit(self.app.repo, self.app.addon)
# Check if the addon has commits that update neighboring addons to
# make it work properly
PortAddonPullRequest(self.app, push_branch=False).run()
Expand Down Expand Up @@ -296,3 +298,4 @@ def _apply_code_pattern(self):
return True
except KeyboardInterrupt:
pass
return False

0 comments on commit 9e90e61

Please sign in to comment.