How to use the classes.info.PATH function in classes

To help you get started, we’ve selected a few classes examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github OpenShot / openshot-qt / src / windows / timeline_webview.py View on Github external
# Search for matching file in project data (if any)
			file_id = data[0]
			file = File.get(id=file_id)

			# Bail if no file found
			if not file:
				event.ignore()
				return
			
			if (file.data["media_type"] == "video" or file.data["media_type"] == "image"):
				# Determine thumb path
				thumb_path = os.path.join(info.THUMBNAIL_PATH, "%s.png" % file.data["id"])
			else:
				# Audio file
				thumb_path = os.path.join(info.PATH, "images", "AudioThumbnail.png")
				
			# Get file name
			path, filename = os.path.split(file.data["path"])
			
			# Convert path to the correct relative path (based on this folder)
			file_path = file.absolute_path()
			
			# Create clip object for this file
			c = openshot.Clip(file_path)
			
			# Append missing attributes to Clip JSON
			new_clip = json.loads(c.Json())
			new_clip["file_id"] = file.id
			new_clip["title"] = filename
			new_clip["image"] = thumb_path
github OpenShot / openshot-qt / src / classes / project_data.py View on Github external
for clip in track.clips:
                            # Get associated file for this clip
                            if clip.file_object.unique_id in file_lookup.keys():
                                file = file_lookup[clip.file_object.unique_id]
                            else:
                                # Skip missing file
                                log.info("Skipping importing missing file: %s" % clip.file_object.unique_id)
                                continue

                            # Create clip
                            if (file.data["media_type"] == "video" or file.data["media_type"] == "image"):
                                # Determine thumb path
                                thumb_path = os.path.join(info.THUMBNAIL_PATH, "%s.png" % file.data["id"])
                            else:
                                # Audio file
                                thumb_path = os.path.join(info.PATH, "images", "AudioThumbnail.png")

                            # Get file name
                            path, filename = os.path.split(file.data["path"])

                            # Convert path to the correct relative path (based on this folder)
                            file_path = file.absolute_path()

                            # Create clip object for this file
                            c = openshot.Clip(file_path)

                            # Append missing attributes to Clip JSON
                            new_clip = json.loads(c.Json(), strict=False)
                            new_clip["file_id"] = file.id
                            new_clip["title"] = filename
                            new_clip["image"] = thumb_path
github OpenShot / openshot-qt / src / windows / file_properties.py View on Github external
from PyQt5.QtCore import *
from PyQt5.QtWidgets import *
import openshot  # Python module for libopenshot (required video editing module installed separately)

from classes import info, ui_util, settings
from classes.app import get_app
from classes.logger import log
from classes.metrics import *

import json

class FileProperties(QDialog):
    """ File Properties Dialog """

    # Path to ui file
    ui_path = os.path.join(info.PATH, 'windows', 'ui', 'file-properties.ui')

    def __init__(self, file):
        self.file = file

        # Create dialog class
        QDialog.__init__(self)

        # Load UI from designer
        ui_util.load_ui(self, self.ui_path)

        # Init UI
        ui_util.init_ui(self)

        # get translations
        app = get_app()
        _ = app._tr
github OpenShot / openshot-qt / src / windows / preferences.py View on Github external
from PyQt5.QtGui import QKeySequence, QIcon
from PyQt5 import uic

from classes import info, ui_util, settings, qt_types, updates
from classes.app import get_app
from classes.language import get_all_languages
from classes.logger import log
from classes.metrics import *
import openshot


class Preferences(QDialog):
    """ Preferences Dialog """

    # Path to ui file
    ui_path = os.path.join(info.PATH, 'windows', 'ui', 'preferences.ui')

    def __init__(self):

        # Create dialog class
        QDialog.__init__(self)

        # Load UI from designer
        ui_util.load_ui(self, self.ui_path)

        # Init UI
        ui_util.init_ui(self)

        # Get settings
        self.s = settings.get_settings()

        # Dynamically load tabs from settings data
github OpenShot / openshot-qt / src / classes / json_data.py View on Github external
def replace_string_to_absolute(self, match):
        """Replace matched string for converting paths to relative paths"""
        key = match.groups(0)[0]
        path = match.groups(0)[1]

        # Find absolute path of file (if needed)
        if "@transitions" in path:
            new_path = path.replace("@transitions", os.path.join(info.PATH, "transitions"))
            new_path = json.dumps(new_path)  # Escape backslashes
            return '"%s": %s' % (key, new_path)

        elif "@assets" in path:
            new_path = path.replace("@assets", path_context["new_project_assets"])
            new_path = json.dumps(new_path)  # Escape backslashes
            return '"%s": %s' % (key, new_path)

        else:
            # Convert path to the correct relative path
            new_path = os.path.abspath(os.path.join(path_context.get("new_project_folder", ""), path))
            new_path = json.dumps(new_path)  # Escape backslashes
            return '"%s": %s' % (key, new_path)
github OpenShot / openshot-qt / src / windows / models / effects_model.py View on Github external
app = get_app()

        # Get window to check filters
        win = app.window
        _ = app._tr

        # Clear all items
        if clear:
            self.model_names = {}
            self.model.clear()

        # Add Headers
        self.model.setHorizontalHeaderLabels([_("Thumb"), _("Name"), _("Description")])

        # Get the folder path of effects
        effects_dir = os.path.join(info.PATH, "effects")
        icons_dir = os.path.join(effects_dir, "icons")

        # Get a JSON list of all supported effects in libopenshot
        raw_effects_list = json.loads(openshot.EffectInfo.Json())

        # Loop through each effect
        for effect_info in raw_effects_list:
            # Get basic properties about each effect
            effect_name = effect_info["class_name"]
            title = effect_info["name"]
            description = effect_info["description"]
            icon_name = "%s.png" % effect_name.lower()
            icon_path = os.path.join(icons_dir, icon_name)

            # Determine the category of effect (audio, video, both)
            category = None
github OpenShot / openshot-qt / src / windows / new_project.py View on Github external
You should have received a copy of the GNU General Public License
 along with OpenShot Library.  If not, see .
 """

import os

from PyQt5.QtWidgets import *

from classes import info, ui_util


class NewProject(QDialog):
    """ New Project Dialog """

    # Path to ui file
    ui_path = os.path.join(info.PATH, 'windows', 'ui', 'new-project.ui')

    def __init__(self):
        # Create dialog class
        QDialog.__init__(self)

        # Load ui from designer
        ui_util.load_ui(self, self.ui_path)

        # Init UI
        ui_util.init_ui(self)
github OpenShot / openshot-qt / src / classes / importers / final_cut_pro.py View on Github external
# Save new file to the project data
                            file = File()
                            file.data = file_data

                            # Save file
                            file.save()
                        except:
                            # Ignore errors for now
                            pass

                    if (file.data["media_type"] == "video" or file.data["media_type"] == "image"):
                        # Determine thumb path
                        thumb_path = os.path.join(info.THUMBNAIL_PATH, "%s.png" % file.data["id"])
                    else:
                        # Audio file
                        thumb_path = os.path.join(info.PATH, "images", "AudioThumbnail.png")

                    # Create Clip object
                    clip = Clip()
                    clip.data = json.loads(clip_obj.Json())
                    clip.data["file_id"] = file.id
                    clip.data["title"] = clip_element.getElementsByTagName("name")[0].childNodes[0].nodeValue
                    clip.data["layer"] = track.data.get("number", 1000000)
                    clip.data["position"] = float(clip_element.getElementsByTagName("start")[0].childNodes[0].nodeValue) / fps_float
                    clip.data["start"] = float(clip_element.getElementsByTagName("in")[0].childNodes[0].nodeValue) / fps_float
                    clip.data["end"] = float(clip_element.getElementsByTagName("out")[0].childNodes[0].nodeValue) / fps_float

                    # Loop through clip's effects
                    for effect_element in clip_element.getElementsByTagName("effect"):
                        effectid = effect_element.getElementsByTagName("effectid")[0].childNodes[0].nodeValue
                        keyframes = effect_element.getElementsByTagName("keyframe")
                        if effectid == "opacity":
github OpenShot / openshot-qt / src / windows / current_exporting_projects.py View on Github external
import os

from PyQt5.QtWidgets import *

from classes import info, ui_util
from classes.logger import log
from classes.app import get_app
from windows.new_preset_name import NewPresetName
from windows.presets import Presets


class CurrentExportingProjects(QDialog):
    """ Current Exporting Projects """

    # Path to ui file
    ui_path = os.path.join(info.PATH, 'windows', 'ui', 'current-exporting-projects.ui')

    def __init__(self):
        # Create dialog class
        QDialog.__init__(self)

        # Load UI from designer
        ui_util.load_ui(self, self.ui_path)

        # Init UI
        ui_util.init_ui(self)

        # get translations
        self.app = get_app()
        _ = self.app._tr

        # set events handlers
github OpenShot / openshot-qt / src / windows / export_video.py View on Github external
""" Run the conversion and show a progress bar for this one until it will be finished """
        log.info('Conversion has been started')
        windo = ProgressBarExport()
        windo.exec_()


        # def new_frame_name(self):
        # """ Display the new frame name """
        # log.info('')
        # pass


class AverageBitRate(QDialog):
    """ Average Bitrate Dialog """

    ui_path = os.path.join(info.PATH, 'windows', 'ui', 'compression-method.ui')

    def __init__(self):
        # Create dialog class
        QDialog.__init__(self)

        # Load UI from designer
        ui_util.load_ui(self, self.ui_path)

        # Init Ui
        ui_util.init_ui(self)

        # get translations
        self.app = get_app()
        _ = self.app._tr

        # set events handlers