Skip to content
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

Read options from a manifest file in importcontent #9467

Merged
Prev Previous commit
Next Next commit
Support manifest_file without a name attribute
This could be a file-like object extended from IOBase.
  • Loading branch information
dylanmccall committed Sep 1, 2022
commit 456069fb3fc73540f3572465214941dbf46ccbad
6 changes: 3 additions & 3 deletions kolibri/core/content/management/commands/importcontent.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ def add_arguments(self, parser):
"""
parser.add_argument(
"--manifest",
# Split the comma separated string we get, into a list of strings
type=argparse.FileType("r"),
default=None,
required=False,
Expand Down Expand Up @@ -108,7 +107,7 @@ def add_arguments(self, parser):
"""
parser.add_argument(
"--exclude_node_ids",
# Split the comma separated string we get, into a list of string
# Split the comma separated string we get, into a list of strings
type=lambda x: x.split(",") if x else [],
default=None,
required=False,
Expand Down Expand Up @@ -285,7 +284,8 @@ def _transfer( # noqa: max-complexity=16
# If manifest_file is stdin, its name will be "<stdin>" and path
# will become "". This feels clumsy, but the resulting behaviour
# is reasonable.
manifest_dir = os.path.dirname(manifest_file.name)
manifest_file_name = getattr(manifest_file, "name", "")
manifest_dir = os.path.dirname(manifest_file_name)
path = os.path.dirname(manifest_dir)

content_manifest = ContentManifest()
Expand Down