mirror of
https://github.com/ynput/ayon-core.git
synced 2025-12-24 21:04:40 +01:00
Open main file of representation
For image sequences this is the same first file as uses before
This commit is contained in:
parent
c7baf27fa2
commit
767f20ef1b
1 changed files with 7 additions and 29 deletions
|
|
@ -15,8 +15,8 @@ def open(filepath):
|
|||
subprocess.call(('xdg-open', filepath))
|
||||
|
||||
|
||||
class Openfile(load.LoaderPlugin):
|
||||
"""Open Image Sequence with system default"""
|
||||
class OpenFile(load.LoaderPlugin):
|
||||
"""Open Image Sequence or Video with system default"""
|
||||
|
||||
families = ["render2d"]
|
||||
representations = ["*"]
|
||||
|
|
@ -27,32 +27,10 @@ class Openfile(load.LoaderPlugin):
|
|||
color = "orange"
|
||||
|
||||
def load(self, context, name, namespace, data):
|
||||
import clique
|
||||
|
||||
directory = os.path.dirname(self.fname)
|
||||
pattern = clique.PATTERNS["frames"]
|
||||
path = self.fname
|
||||
if not os.path.exists(path):
|
||||
raise RuntimeError("File not found: {}".format(path))
|
||||
|
||||
files = os.listdir(directory)
|
||||
representation = context["representation"]
|
||||
|
||||
ext = representation["name"]
|
||||
path = representation["data"]["path"]
|
||||
|
||||
if ext in ["#"]:
|
||||
collections, remainder = clique.assemble(files,
|
||||
patterns=[pattern],
|
||||
minimum_items=1)
|
||||
|
||||
seqeunce = collections[0]
|
||||
|
||||
first_image = list(seqeunce)[0]
|
||||
filepath = os.path.normpath(os.path.join(directory, first_image))
|
||||
else:
|
||||
file = [f for f in files
|
||||
if ext in f
|
||||
if "#" not in f][0]
|
||||
filepath = os.path.normpath(os.path.join(directory, file))
|
||||
|
||||
self.log.info("Opening : {}".format(filepath))
|
||||
|
||||
open(filepath)
|
||||
self.log.info("Opening : {}".format(path))
|
||||
open(path)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue