Skip to content

Commit

Permalink
add a --version flag to otiopluginfo + otioconvert
Browse files Browse the repository at this point in the history
  • Loading branch information
ssteinbach committed Feb 10, 2021
1 parent 2a33b58 commit d919575
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 2 deletions.
41 changes: 39 additions & 2 deletions src/py-opentimelineio/opentimelineio/console/otioconvert.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,12 @@

import opentimelineio as otio

# on some python interpreters, pkg_resources is not available
try:
import pkg_resources
except ImportError:
pkg_resources = None

__doc__ = """ Python wrapper around OTIO to convert timeline files between \
formats.
Expand All @@ -47,14 +53,14 @@ def _parsed_args():
'-i',
'--input',
type=str,
required=True,
required=False,
help='path to input file',
)
parser.add_argument(
'-o',
'--output',
type=str,
required=True,
required=False,
help='path to output file',
)
parser.add_argument(
Expand Down Expand Up @@ -130,6 +136,16 @@ def _parsed_args():
'key=value. Values are strings, numbers or Python literals: True, '
'False, etc. Can be used multiple times: -A burrito="bar" -A taco=12.'
)
parser.add_argument(
'--version',
default=False,
action="store_true",
help=(
"Print the otio and pkg_resource installed plugin version "
"information to the commandline and then exit."
),
)

trim_args = parser.add_argument_group(
title="Trim Arguments",
description="Arguments that allow you to trim the OTIO file."
Expand Down Expand Up @@ -157,6 +173,27 @@ def _parsed_args():

result = parser.parse_args()

# print version information to the shell
if result.version:
print("OpenTimelineIO version: {}".format(otio.__version__))

if pkg_resources:
pkg_resource_plugins = list(
pkg_resources.iter_entry_points("opentimelineio.plugins")
)
if pkg_resource_plugins:
print("Plugins from pkg_resources:")
for plugin in pkg_resource_plugins:
print(" {}".format(plugin.dist))
else:
print("No pkg_resource plugins installed.")
parser.exit()

if not result.input:
parser.error("-i/--input is a required argument")
if not result.output:
parser.error("-o/--output is a required argument")

if result.begin is not None and result.end is None:
parser.error("--begin requires --end.")
if result.end is not None and result.begin is None:
Expand Down
29 changes: 29 additions & 0 deletions src/py-opentimelineio/opentimelineio/console/otiopluginfo.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@
import textwrap
import opentimelineio as otio

# on some python interpreters, pkg_resources is not available
try:
import pkg_resources
except ImportError:
pkg_resources = None

OTIO_PLUGIN_TYPES = ['all'] + otio.plugins.manifest.OTIO_PLUGIN_TYPES

Expand Down Expand Up @@ -78,6 +83,15 @@ def _parsed_args():
nargs='?',
help='Only print information about plugins that match this glob.'
)
parser.add_argument(
'--version',
default=False,
action="store_true",
help=(
"Print the otio and pkg_resource installed plugin version "
"information to the commandline."
),
)

return parser.parse_args()

Expand Down Expand Up @@ -185,6 +199,21 @@ def main():
# load all the otio plugins
active_plugin_manifest = otio.plugins.ActiveManifest()

# print version information to the shell
if args.version:
print("OpenTimelineIO version: {}".format(otio.__version__))

if pkg_resources:
pkg_resource_plugins = list(
pkg_resources.iter_entry_points("opentimelineio.plugins")
)
if pkg_resource_plugins:
print("Plugins from pkg_resources:")
for plugin in pkg_resource_plugins:
print(" {}".format(plugin.dist))
else:
print("No pkg_resource plugins installed.")

# list the loaded manifests
print("Manifests loaded:")
for mf in active_plugin_manifest.source_files:
Expand Down

0 comments on commit d919575

Please sign in to comment.