Skip to content

Commit

Permalink
[REF] add parse_manifest function
Browse files Browse the repository at this point in the history
  • Loading branch information
legalsylvain committed May 20, 2022
1 parent 99b7c2a commit 8d6f595
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/oca_github_bot/manifest.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,15 @@ def get_manifest_path(addon_dir):
return None


def parse_manifest(manifest: bytes)-> dict:
return ast.literal_eval(manifest)

This comment has been minimized.

Copy link
@sbidoul

sbidoul May 20, 2022

Member

@legalsylvain I'd rather do the utf8 decoding here


def get_manifest(addon_dir):
manifest_path = get_manifest_path(addon_dir)
if not manifest_path:
raise NoManifestFound(f"no manifest found in {addon_dir}")
with open(manifest_path, "r") as f:
return ast.literal_eval(f.read())
return parse_manifest(f.read())

This comment has been minimized.

Copy link
@sbidoul

sbidoul May 20, 2022

Member

And open the file in binary (rb) mode here.



def set_manifest_version(addon_dir, version):
Expand Down Expand Up @@ -277,7 +280,7 @@ def is_maintainer_other_branches(org, repo, username, modified_addons, other_bra
url, allow_redirects=True, headers={"Cache-Control": "no-cache"}
)
if r.ok:
manifest = ast.literal_eval(r.content.decode("utf-8"))
manifest = parse_manifest(r.content.decode("utf-8"))

This comment has been minimized.

Copy link
@sbidoul

sbidoul May 20, 2022

Member

and not decoding here

if username in manifest.get("maintainers", []):
is_maintainer = True
break
Expand Down

0 comments on commit 8d6f595

Please sign in to comment.