-
Notifications
You must be signed in to change notification settings - Fork 40
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: flow for plugin package file mapping and xattr tagging #979
Changes from all commits
eee5184
ea2b752
f1d24d0
2721c9b
5108d15
0bd0232
1b340f8
94448c1
fb711f8
1731916
971289b
f1be473
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
# noqa: A005 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I wonder if this will render the editor modeline below useless. |
||
|
||
# -*- Mode:Python; indent-tabs-mode:nil; tab-width:4 -*- | ||
# | ||
# Copyright 2017-2023 Canonical Ltd. | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,13 +19,14 @@ | |
import logging | ||
import os | ||
import sys | ||
from pathlib import Path | ||
|
||
from craft_parts import errors | ||
|
||
logger = logging.getLogger(__name__) | ||
|
||
|
||
def read_xattr(path: str, key: str) -> str | None: | ||
def read_xattr(path: str | Path, key: str) -> str | None: | ||
"""Get extended attribute metadata from a file. | ||
|
||
:param path: The file to get metadata from. | ||
|
@@ -35,6 +36,7 @@ def read_xattr(path: str, key: str) -> str | None: | |
""" | ||
if sys.platform != "linux": | ||
raise RuntimeError("xattr support only available for Linux") | ||
path = str(path) | ||
|
||
# Extended attributes do not apply to symlinks. | ||
if os.path.islink(path): | ||
|
@@ -58,7 +60,7 @@ def read_xattr(path: str, key: str) -> str | None: | |
return value.decode().strip() | ||
|
||
|
||
def write_xattr(path: str, key: str, value: str) -> None: | ||
def write_xattr(path: str | Path, key: str, value: str) -> None: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For general API consistency it would be better to use only Path here, unless convenience suffers too much. Then it would be simpler to test this only with Path instead of testing with str and Path. |
||
"""Add extended attribute metadata to a file. | ||
|
||
:param path: The file to add metadata to. | ||
|
@@ -67,6 +69,7 @@ def write_xattr(path: str, key: str, value: str) -> None: | |
""" | ||
if sys.platform != "linux": | ||
raise RuntimeError("xattr support only available for Linux") | ||
path = str(path) | ||
|
||
# Extended attributes do not apply to symlinks. | ||
if os.path.islink(path): | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a bit strange in isolate form but I see it's following the xattr pattern already used for stage packages.