added few docstrings

This commit is contained in:
iLLiCiTiT 2021-12-09 12:21:12 +01:00
parent 43c552dbbf
commit ad99d2a841
4 changed files with 24 additions and 2 deletions

View file

@ -12,6 +12,9 @@ from .bootstrap_repos import (
)
from .version import __version__ as version
# Store OpenPypeVersion to 'sys.modules'
# - this makes it available in OpenPype processes without modifying
# 'sys.path' or 'PYTHONPATH'
if "OpenPypeVersion" not in sys.modules:
sys.modules["OpenPypeVersion"] = OpenPypeVersion
@ -64,6 +67,7 @@ def open_update_window(openpype_version):
def show_message_dialog(title, message):
"""Show dialog with a message and title to user."""
if os.getenv("OPENPYPE_HEADLESS_MODE"):
print("!!! Can't open dialog in headless mode. Exiting.")
sys.exit(1)

View file

@ -7,6 +7,7 @@ from .tools import (
class MessageDialog(QtWidgets.QDialog):
"""Simple message dialog with title, message and OK button."""
def __init__(self, title, message):
super(MessageDialog, self).__init__()
@ -27,7 +28,6 @@ class MessageDialog(QtWidgets.QDialog):
btns_layout.addWidget(ok_btn, 0)
layout = QtWidgets.QVBoxLayout(self)
# layout.setContentsMargins(0, 0, 0, 0)
layout.addWidget(label_widget, 1)
layout.addLayout(btns_layout, 0)

View file

@ -12,6 +12,16 @@ from .exceptions import BaseInvalidValue
class OpenPypeVersionInput(TextEntity):
"""Entity to store OpenPype version to use.
It is text input as creating of settings on different machines may
affect which versions are available so it must have option to set OpenPype
version which is not available for machine where settings entities are
loaded.
It is possible to enter empty string. In that case is used any latest
version. Any other string must match regex of OpenPype version semantic.
"""
def _item_initialization(self):
super(OpenPypeVersionInput, self)._item_initialization()
self.multiline = False
@ -19,9 +29,13 @@ class OpenPypeVersionInput(TextEntity):
self.value_hints = []
def _get_openpype_versions(self):
return []
"""This is abstract method returning version hints for UI purposes."""
raise NotImplementedError((
"{} does not have implemented '_get_openpype_versions'"
).format(self.__class__.__name__))
def set_override_state(self, state, *args, **kwargs):
"""Update value hints for UI purposes."""
value_hints = []
if state is OverrideState.STUDIO:
versions = self._get_openpype_versions()
@ -36,6 +50,7 @@ class OpenPypeVersionInput(TextEntity):
)
def convert_to_valid_type(self, value):
"""Add validation of version regex."""
if value and value is not NOT_SET:
OpenPypeVersion = get_OpenPypeVersion()
if OpenPypeVersion is not None:
@ -52,6 +67,7 @@ class OpenPypeVersionInput(TextEntity):
class ProductionVersionsInputEntity(OpenPypeVersionInput):
"""Entity meant only for global settings to define production version."""
schema_types = ["production-versions-text"]
def _get_openpype_versions(self):
@ -61,6 +77,7 @@ class ProductionVersionsInputEntity(OpenPypeVersionInput):
class StagingVersionsInputEntity(OpenPypeVersionInput):
"""Entity meant only for global settings to define staging version."""
schema_types = ["staging-versions-text"]
def _get_openpype_versions(self):

View file

@ -28,6 +28,7 @@ class BaseWidget(QtWidgets.QWidget):
@staticmethod
def set_style_property(obj, property_name, property_value):
"""Change QWidget property and polish it's style."""
if obj.property(property_name) == property_value:
return