32 from classes
import info
33 from classes.app
import get_app
58 def save(self, OBJECT_TYPE):
61 if not self.
id and self.
type ==
"insert":
64 self.
id = project.generate_id()
67 self.
data[
"id"] = copy.deepcopy(self.
id)
71 self.
key = copy.deepcopy(OBJECT_TYPE.object_key)
72 self.
key.append({
"id": self.
id})
75 app.updates.insert(copy.deepcopy(OBJECT_TYPE.object_key), copy.deepcopy(self.
data))
80 elif self.
id and self.
type ==
"update":
83 app.updates.update(self.
key, self.
data)
90 if self.
id and self.
type ==
"update":
92 app.updates.delete(self.
key)
106 parent = project.get(OBJECT_TYPE.object_key)
107 matching_objects = []
115 for key, value
in kwargs.items():
117 if key
in child
and not child[key] == value:
121 elif key ==
"intersect":
122 if child.get(
"position", 0) > value
or \
123 child.get(
"position", 0) + (child.get(
"end", 0) - child.get(
"start", 0)) < value:
128 object = OBJECT_TYPE()
129 object.id = child[
"id"]
130 object.key = [OBJECT_TYPE.object_name, {
"id": object.id}]
131 object.data = copy.deepcopy(child)
132 object.type =
"update" 133 matching_objects.append(object)
136 return matching_objects
140 def get(OBJECT_TYPE, **kwargs):
143 matching_objects = QueryObject.filter(OBJECT_TYPE, **kwargs)
146 return matching_objects[0]
154 object_name =
"clips" 155 object_key = [object_name]
170 return QueryObject.filter(Clip, **kwargs)
175 return QueryObject.get(Clip, **kwargs)
180 path = self.
data.
get(
"reader", {}).
get(
"path")
181 folder_path, filename = os.path.split(path)
182 return os.path.splitext(filename)[0]
187 object_name =
"effects" 188 object_key = [object_name]
193 super().
save(Transition)
198 super().
delete(Transition)
203 return QueryObject.filter(Transition, **kwargs)
208 return QueryObject.get(Transition, **kwargs)
213 path = self.
data.
get(
"reader", {}).
get(
"path")
214 folder_path, filename = os.path.split(path)
215 fileBaseName, fileExtension = os.path.splitext(filename)
219 name_parts = fileBaseName.split(
"_")
220 if name_parts[-1].isdigit():
221 suffix_number = name_parts[-1]
223 item_name = fileBaseName.replace(
"_",
" ").capitalize()
227 item_name = item_name.replace(suffix_number,
"%s")
228 item_name =
get_app()._tr(item_name) % suffix_number
230 item_name =
get_app()._tr(item_name)
237 object_name =
"files" 238 object_key = [object_name]
253 return QueryObject.filter(File, **kwargs)
258 return QueryObject.get(File, **kwargs)
265 project_folder =
None 266 if project.current_filepath:
267 project_folder = os.path.dirname(project.current_filepath)
270 file_path = self.
data[
"path"]
271 if not os.path.isabs(file_path)
and project_folder:
272 file_path = os.path.abspath(os.path.join(project_folder, self.
data[
"path"]))
285 file_path = os.path.relpath(file_path, info.CWD)
294 object_name =
"markers" 295 object_key = [object_name]
310 return QueryObject.filter(Marker, **kwargs)
315 return QueryObject.get(Marker, **kwargs)
321 object_name =
"layers" 322 object_key = [object_name]
337 return QueryObject.filter(Track, **kwargs)
342 return QueryObject.get(Track, **kwargs)
348 object_name =
"effects" 349 object_key = [object_name]
366 clips = project.get([
"clips"])
367 matching_objects = []
373 if "effects" in clip:
374 for child
in clip[
"effects"]:
378 for key, value
in kwargs.items():
379 if key
in child
and not child[key] == value:
386 object.id = child[
"id"]
387 object.key = [
"clips", {
"id": clip[
"id"]},
"effects", {
"id": object.id}]
389 object.type =
"update" 391 matching_objects.append(object)
394 return matching_objects
405 matching_objects = Effect.filter(**kwargs)
408 return matching_objects[0]
def filter(kwargs)
Take any arguments given as filters, and find a list of matching objects.
def filter(kwargs)
Take any arguments given as filters, and find a list of matching objects.
def filter(kwargs)
Take any arguments given as filters, and find a list of matching objects.
def save(self)
Save the object back to the project data store.
def get_app()
Returns the current QApplication instance of OpenShot.
This class allows Tracks to be queried, updated, and deleted from the project data.
def save(self)
Save the object back to the project data store.
def get(OBJECT_TYPE, kwargs)
Take any arguments given as filters, and find the first matching object.
def get(kwargs)
Take any arguments given as filters, and find the first matching object.
def title(self)
Get the translated display title of this item.
def delete(self)
Delete the object from the project data store.
def filter(kwargs)
Take any arguments given as filters, and find a list of matching objects.
def __init__(self)
Constructor.
def save(self)
Save the object back to the project data store.
def get(kwargs)
Take any arguments given as filters, and find the first matching object.
This class allows Effects to be queried, updated, and deleted from the project data.
def filter(kwargs)
Take any arguments given as filters, and find a list of matching objects.
def save(self, OBJECT_TYPE)
Save the object back to the project data store.
def delete(self)
Delete the object from the project data store.
def save(self)
Save the object back to the project data store.
def filter(kwargs)
Take any arguments given as filters, and find a list of matching objects.
def save(self)
Save the object back to the project data store.
def get(kwargs)
Take any arguments given as filters, and find the first matching object.
This class allows Markers to be queried, updated, and deleted from the project data.
def title(self)
Get the translated display title of this item.
This class allows Clips to be queried, updated, and deleted from the project data.
This class allows Transitions (i.e.
def delete(self)
Delete the object from the project data store.
def save(self)
Save the object back to the project data store.
def title(self)
Get the translated display title of this item.
def delete(self, OBJECT_TYPE)
Delete the object from the project data store.
def delete(self)
Delete the object from the project data store.
def relative_path(self)
Get relative path (based on the current working directory)
def filter(OBJECT_TYPE, kwargs)
Take any arguments given as filters, and find a list of matching objects.
This class allows Files to be queried, updated, and deleted from the project data.
This class allows one or more project data objects to be queried.
def title(self)
Get the translated display title of this item.
def delete(self)
Delete the object from the project data store.
def delete(self)
Delete the object from the project data store.
def get(kwargs)
Take any arguments given as filters, and find the first matching object.
def get(kwargs)
Take any arguments given as filters, and find the first matching object.
def absolute_path(self)
Get absolute file path of file.
def get(kwargs)
Take any arguments given as filters, and find the first matching object.