[pitivi] Fix some pylint invalid-name
- From: Thibault Saunier <tsaunier src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pitivi] Fix some pylint invalid-name
- Date: Mon, 11 Nov 2019 22:07:20 +0000 (UTC)
commit d387ec8ed89f3b334409e991023c36a64df37deb
Author: Alexandru Băluț <alexandru balut gmail com>
Date: Fri Nov 1 07:12:51 2019 +0100
Fix some pylint invalid-name
pitivi/autoaligner.py | 4 +-
pitivi/check.py | 18 +--
pitivi/clipproperties.py | 4 +-
pitivi/effects.py | 44 +++---
pitivi/medialibrary.py | 86 +++++-----
pitivi/project.py | 143 +++++++++--------
pitivi/render.py | 91 +++++------
pitivi/timeline/elements.py | 72 ++++-----
pitivi/timeline/timeline.py | 80 +++++-----
pitivi/titleeditor.py | 39 +++--
pitivi/transitions.py | 4 +-
pitivi/utils/loggable.py | 302 ++++++++++++++++++------------------
pitivi/utils/misc.py | 26 ++--
pitivi/utils/pipeline.py | 24 +--
pitivi/utils/proxy.py | 78 +++++-----
pitivi/utils/system.py | 6 +-
pitivi/utils/ui.py | 18 +--
pitivi/utils/validate.py | 86 +++++-----
pitivi/utils/widgets.py | 35 ++---
pitivi/viewer/move_scale_overlay.py | 4 +-
pre-commit.hook | 7 -
tests/common.py | 20 +--
tests/test_editorperspective.py | 6 +-
tests/test_effects.py | 4 +-
tests/test_log.py | 78 +++++-----
tests/test_mediafilespreviewer.py | 4 +-
tests/test_medialibrary.py | 6 +-
tests/test_preset.py | 28 ++--
tests/test_project.py | 28 ++--
tests/test_timeline_timeline.py | 57 ++++---
tests/test_undo.py | 16 +-
tests/test_undo_timeline.py | 20 +--
32 files changed, 716 insertions(+), 722 deletions(-)
---
diff --git a/pitivi/autoaligner.py b/pitivi/autoaligner.py
index 076cc375..e32f89dc 100644
--- a/pitivi/autoaligner.py
+++ b/pitivi/autoaligner.py
@@ -35,7 +35,7 @@ from gettext import gettext as _
import pitivi.configure as configure
-from pitivi.utils.ui import beautify_ETA
+from pitivi.utils.ui import beautify_eta
from pitivi.utils.misc import call_false
from pitivi.utils.extract import Extractee
from pitivi.utils.loggable import Loggable
@@ -378,7 +378,7 @@ class ProgressAggregator(ProgressMeter):
now = time.time()
remaining = (now - self._start) * (1 - frac) / frac
for function in self._watchers:
- function(frac, beautify_ETA(int(remaining * Gst.SECOND)))
+ function(frac, beautify_eta(int(remaining * Gst.SECOND)))
return False
diff --git a/pitivi/check.py b/pitivi/check.py
index bc7a4caa..54d6e2a8 100644
--- a/pitivi/check.py
+++ b/pitivi/check.py
@@ -27,8 +27,8 @@ import os
import sys
from gettext import gettext as _
-missing_soft_deps = {}
-videosink_factory = None
+MISSING_SOFT_DEPS = {}
+VIDEOSINK_FACTORY = None
def _version_to_string(version):
@@ -238,24 +238,24 @@ def _using_broadway_display():
def _check_videosink():
from gi.repository import Gst
- global videosink_factory
+ global VIDEOSINK_FACTORY
# If using GdkBroadwayDisplay make sure not to try to use gtkglsink
# as it would segfault right away.
- if not videosink_factory and \
+ if not VIDEOSINK_FACTORY and \
not _using_broadway_display() and \
"gtkglsink" in os.environ.get("PITIVI_UNSTABLE_FEATURES", ""):
sink = Gst.ElementFactory.make("gtkglsink", None)
if sink:
res = sink.set_state(Gst.State.READY)
if res == Gst.StateChangeReturn.SUCCESS:
- videosink_factory = sink.get_factory()
+ VIDEOSINK_FACTORY = sink.get_factory()
sink.set_state(Gst.State.NULL)
- if not videosink_factory:
- videosink_factory = Gst.ElementFactory.find("gtksink")
+ if not VIDEOSINK_FACTORY:
+ VIDEOSINK_FACTORY = Gst.ElementFactory.find("gtksink")
- return videosink_factory
+ return VIDEOSINK_FACTORY
def _check_hardware_decoders():
@@ -305,7 +305,7 @@ def check_requirements():
for dependency in SOFT_DEPENDENCIES:
dependency.check()
if not dependency.satisfied:
- missing_soft_deps[dependency.modulename] = dependency
+ MISSING_SOFT_DEPS[dependency.modulename] = dependency
print(_("Missing soft dependency:"))
print(dependency)
diff --git a/pitivi/clipproperties.py b/pitivi/clipproperties.py
index 51943f67..57a9a55d 100644
--- a/pitivi/clipproperties.py
+++ b/pitivi/clipproperties.py
@@ -34,7 +34,7 @@ from pitivi.effects import HIDDEN_EFFECTS
from pitivi.undo.timeline import CommitTimelineFinalizingAction
from pitivi.utils.custom_effect_widgets import setup_custom_effect_widgets
from pitivi.utils.loggable import Loggable
-from pitivi.utils.misc import disconnectAllByFunc
+from pitivi.utils.misc import disconnect_all_by_func
from pitivi.utils.pipeline import PipelineError
from pitivi.utils.ui import disable_scroll
from pitivi.utils.ui import EFFECT_TARGET_ENTRY
@@ -851,7 +851,7 @@ class TransformationProperties(Gtk.Expander, Loggable):
if self.source:
try:
self.source.disconnect_by_func(self.__source_property_changed_cb)
- disconnectAllByFunc(self.source, self._control_bindings_changed)
+ disconnect_all_by_func(self.source, self._control_bindings_changed)
except TypeError:
pass
self.source = source
diff --git a/pitivi/effects.py b/pitivi/effects.py
index 3df3d18c..05c1a747 100644
--- a/pitivi/effects.py
+++ b/pitivi/effects.py
@@ -239,7 +239,7 @@ class EffectsManager(Loggable):
useless_words = ["Video", "Audio", "audio", "effect",
_("Video"), _("Audio"), _("Audio").lower(), _("effect")]
- uselessRe = re.compile(" |".join(useless_words))
+ useless_re = re.compile(" |".join(useless_words))
registry = Gst.Registry.get()
factories = registry.get_feature_list(Gst.ElementFactory)
@@ -274,7 +274,7 @@ class EffectsManager(Loggable):
# Workaround https://bugzilla.gnome.org/show_bug.cgi?id=760566
# Add name which identifies the element and is unique.
longname = "%s %s" % (longname, name)
- human_name = uselessRe.sub("", longname).title()
+ human_name = useless_re.sub("", longname).title()
effect = EffectInfo(name,
media_type,
categories=self._getEffectCategories(name),
@@ -369,8 +369,8 @@ class EffectListWidget(Gtk.Box, Loggable):
self.app = instance
- self._draggedItems = None
- self._effectType = VIDEO_EFFECT
+ self._dragged_items = None
+ self._effect_type = VIDEO_EFFECT
self.set_orientation(Gtk.Orientation.VERTICAL)
builder = Gtk.Builder()
@@ -380,8 +380,8 @@ class EffectListWidget(Gtk.Box, Loggable):
toolbar.get_style_context().add_class(Gtk.STYLE_CLASS_INLINE_TOOLBAR)
self.video_togglebutton = builder.get_object("video_togglebutton")
self.audio_togglebutton = builder.get_object("audio_togglebutton")
- self.categoriesWidget = builder.get_object("categories")
- self.searchEntry = builder.get_object("search_entry")
+ self.categories_widget = builder.get_object("categories")
+ self.search_entry = builder.get_object("search_entry")
# Store
self.storemodel = Gtk.ListStore(
@@ -473,7 +473,7 @@ class EffectListWidget(Gtk.Box, Loggable):
self._addFactories(self.app.effects.audio_effects, AUDIO_EFFECT)
return False
- def _addFactories(self, elements, effectType):
+ def _addFactories(self, elements, effect_type):
for element in elements:
name = element.get_name()
if name in HIDDEN_EFFECTS:
@@ -481,25 +481,25 @@ class EffectListWidget(Gtk.Box, Loggable):
effect_info = self.app.effects.getInfo(name)
self.storemodel.append([effect_info.human_name,
effect_info.description,
- effectType,
+ effect_type,
effect_info.categories,
name,
effect_info.icon])
def populate_categories_widget(self):
- self.categoriesWidget.get_model().clear()
+ self.categories_widget.get_model().clear()
icon_column = self.view.get_column(0)
- if self._effectType is VIDEO_EFFECT:
+ if self._effect_type is VIDEO_EFFECT:
for category in self.app.effects.video_categories:
- self.categoriesWidget.append_text(category)
+ self.categories_widget.append_text(category)
icon_column.props.visible = True
else:
for category in self.app.effects.audio_categories:
- self.categoriesWidget.append_text(category)
+ self.categories_widget.append_text(category)
icon_column.props.visible = False
- self.categoriesWidget.set_active(0)
+ self.categories_widget.set_active(0)
def _dndDragDataGetCb(self, unused_view, drag_context, selection_data, unused_info, unused_timestamp):
data = bytes(self.getSelectedEffect(), "UTF-8")
@@ -528,9 +528,9 @@ class EffectListWidget(Gtk.Box, Loggable):
chain_up = not self._rowUnderMouseSelected(view, event)
if chain_up:
- self._draggedItems = None
+ self._dragged_items = None
else:
- self._draggedItems = self.getSelectedEffect()
+ self._dragged_items = self.getSelectedEffect()
Gtk.TreeView.do_button_press_event(view, event)
return True
@@ -553,8 +553,8 @@ class EffectListWidget(Gtk.Box, Loggable):
clip.ui.add_effect(effect_info)
def getSelectedEffect(self):
- if self._draggedItems:
- return self._draggedItems
+ if self._dragged_items:
+ return self._dragged_items
unused_model, rows = self.view.get_selection().get_selected_rows()
path = self.model_filter.convert_path_to_child_path(rows[0])
return self.storemodel[path][COL_ELEMENT_NAME]
@@ -571,9 +571,9 @@ class EffectListWidget(Gtk.Box, Loggable):
self.video_togglebutton.set_active(not widget.get_active())
if self.video_togglebutton.get_active():
- self._effectType = VIDEO_EFFECT
+ self._effect_type = VIDEO_EFFECT
else:
- self._effectType = AUDIO_EFFECT
+ self._effect_type = AUDIO_EFFECT
self.populate_categories_widget()
self.model_filter.refilter()
@@ -587,13 +587,13 @@ class EffectListWidget(Gtk.Box, Loggable):
entry.set_text("")
def _set_row_visible_func(self, model, model_iter, data):
- if not self._effectType == model.get_value(model_iter, COL_EFFECT_TYPE):
+ if not self._effect_type == model.get_value(model_iter, COL_EFFECT_TYPE):
return False
if model.get_value(model_iter, COL_EFFECT_CATEGORIES) is None:
return False
- if self.categoriesWidget.get_active_text() not in model.get_value(model_iter, COL_EFFECT_CATEGORIES):
+ if self.categories_widget.get_active_text() not in model.get_value(model_iter,
COL_EFFECT_CATEGORIES):
return False
- text = self.searchEntry.get_text().lower()
+ text = self.search_entry.get_text().lower()
return text in model.get_value(model_iter, COL_DESC_TEXT).lower() or\
text in model.get_value(model_iter, COL_NAME_TEXT).lower()
diff --git a/pitivi/medialibrary.py b/pitivi/medialibrary.py
index 75001748..aa1e46ca 100644
--- a/pitivi/medialibrary.py
+++ b/pitivi/medialibrary.py
@@ -46,7 +46,7 @@ from pitivi.mediafilespreviewer import PreviewWidget
from pitivi.settings import GlobalSettings
from pitivi.timeline.previewers import AssetPreviewer
from pitivi.utils.loggable import Loggable
-from pitivi.utils.misc import disconnectAllByFunc
+from pitivi.utils.misc import disconnect_all_by_func
from pitivi.utils.misc import path_from_uri
from pitivi.utils.misc import PathWalker
from pitivi.utils.misc import quote_uri
@@ -55,7 +55,7 @@ from pitivi.utils.proxy import get_proxy_target
from pitivi.utils.proxy import ProxyingStrategy
from pitivi.utils.proxy import ProxyManager
from pitivi.utils.ui import beautify_asset
-from pitivi.utils.ui import beautify_ETA
+from pitivi.utils.ui import beautify_eta
from pitivi.utils.ui import FILE_TARGET_ENTRY
from pitivi.utils.ui import fix_infobar
from pitivi.utils.ui import info_name
@@ -79,7 +79,7 @@ GlobalSettings.addConfigOption('closeImportDialog',
section='clip-library',
key='close-import-dialog-after-import',
default=True)
-GlobalSettings.addConfigOption('lastClipView',
+GlobalSettings.addConfigOption('last_clip_view',
section='clip-library',
key='last-clip-view',
type_=int,
@@ -177,11 +177,11 @@ class FileChooserExtraWidget(Gtk.Box, Loggable):
size_group.add_widget(self.__keep_open_check)
size_group.add_widget(hq_proxy_row)
- if self.app.settings.proxyingStrategy == ProxyingStrategy.AUTOMATIC:
+ if self.app.settings.proxying_strategy == ProxyingStrategy.AUTOMATIC:
self.hq_proxy_check.set_active(True)
self.hq_combo.set_sensitive(True)
self.hq_combo.props.active = 0
- elif self.app.settings.proxyingStrategy == ProxyingStrategy.ALL:
+ elif self.app.settings.proxying_strategy == ProxyingStrategy.ALL:
self.hq_proxy_check.set_active(True)
self.hq_combo.set_sensitive(True)
self.hq_combo.props.active = 1
@@ -226,12 +226,12 @@ class FileChooserExtraWidget(Gtk.Box, Loggable):
if self.hq_proxy_check.get_active():
if self.hq_combo.props.active == 0:
- self.app.settings.proxyingStrategy = ProxyingStrategy.AUTOMATIC
+ self.app.settings.proxying_strategy = ProxyingStrategy.AUTOMATIC
else:
- self.app.settings.proxyingStrategy = ProxyingStrategy.ALL
+ self.app.settings.proxying_strategy = ProxyingStrategy.ALL
else:
assert not self.scaled_proxy_check.get_active()
- self.app.settings.proxyingStrategy = ProxyingStrategy.NOTHING
+ self.app.settings.proxying_strategy = ProxyingStrategy.NOTHING
self.app.settings.auto_scaling_enabled = self.scaled_proxy_check.get_active()
@@ -491,9 +491,9 @@ class MediaLibraryWidget(Gtk.Box, Loggable):
self.app = app
self._errors = []
self._project = None
- self._draggedPaths = None
+ self._dragged_paths = None
self.dragged = False
- self.clip_view = self.app.settings.lastClipView
+ self.clip_view = self.app.settings.last_clip_view
if self.clip_view not in (SHOW_TREEVIEW, SHOW_ICONVIEW):
self.clip_view = SHOW_ICONVIEW
self.import_start_time = time.time()
@@ -530,7 +530,7 @@ class MediaLibraryWidget(Gtk.Box, Loggable):
self._import_button = builder.get_object("media_import_button")
self._clipprops_button = builder.get_object("media_props_button")
self._listview_button = builder.get_object("media_listview_button")
- searchEntry = builder.get_object("media_search_entry")
+ search_entry = builder.get_object("media_search_entry")
# Store
self.storemodel = Gtk.ListStore(*STORE_MODEL_STRUCTURE)
@@ -559,13 +559,13 @@ class MediaLibraryWidget(Gtk.Box, Loggable):
# Filtering model for the search box.
# Use this instead of using self.storemodel directly
- self.modelFilter = self.storemodel.filter_new()
- self.modelFilter.set_visible_func(
- self._set_row_visible_func, data=searchEntry)
+ self.model_filter = self.storemodel.filter_new()
+ self.model_filter.set_visible_func(
+ self._set_row_visible_func, data=search_entry)
# TreeView
# Displays icon, name, type, length
- self.treeview = Gtk.TreeView(model=self.modelFilter)
+ self.treeview = Gtk.TreeView(model=self.model_filter)
self.treeview_scrollwin.add(self.treeview)
self.treeview.connect(
"button-press-event", self._treeViewButtonPressEventCb)
@@ -602,7 +602,7 @@ class MediaLibraryWidget(Gtk.Box, Loggable):
namecol.add_attribute(txtcell, "markup", COL_INFOTEXT)
# IconView
- self.iconview = Gtk.IconView(model=self.modelFilter)
+ self.iconview = Gtk.IconView(model=self.model_filter)
self.iconview_scrollwin.add(self.iconview)
self.iconview.connect(
"button-press-event", self._iconview_button_press_event_cb)
@@ -704,8 +704,8 @@ class MediaLibraryWidget(Gtk.Box, Loggable):
return
for asset in self._project.list_assets(GES.Extractable):
- disconnectAllByFunc(asset, self.__assetProxiedCb)
- disconnectAllByFunc(asset, self.__assetProxyingCb)
+ disconnect_all_by_func(asset, self.__assetProxiedCb)
+ disconnect_all_by_func(asset, self.__assetProxyingCb)
self.__disconnectFromProject()
@@ -729,7 +729,7 @@ class MediaLibraryWidget(Gtk.Box, Loggable):
return 1
def getAssetForUri(self, uri):
- for path in self.modelFilter:
+ for path in self.model_filter:
asset = path[COL_ASSET]
info = asset.get_info()
asset_uri = info.get_uri()
@@ -793,7 +793,7 @@ class MediaLibraryWidget(Gtk.Box, Loggable):
# Realistically, nobody expects to search for only one character,
# and skipping that makes a huge difference in responsiveness.
if len(entry.get_text()) != 1:
- self.modelFilter.refilter()
+ self.model_filter.refilter()
def _search_entry_icon_press_cb(self, entry, icon_pos, event):
if icon_pos == Gtk.EntryIconPosition.SECONDARY:
@@ -831,7 +831,7 @@ class MediaLibraryWidget(Gtk.Box, Loggable):
Args:
view_type (int): One of SHOW_TREEVIEW or SHOW_ICONVIEW.
"""
- self.app.settings.lastClipView = view_type
+ self.app.settings.last_clip_view = view_type
# Gather some info before switching views
paths = self.getSelectedPaths()
self._viewUnselectAll()
@@ -983,7 +983,7 @@ class MediaLibraryWidget(Gtk.Box, Loggable):
if project.loaded:
if estimated_time:
- self.__last_proxying_estimate_time = beautify_ETA(int(
+ self.__last_proxying_estimate_time = beautify_eta(int(
estimated_time * Gst.SECOND))
# Translators: this string indicates the estimated time
@@ -1308,7 +1308,7 @@ class MediaLibraryWidget(Gtk.Box, Loggable):
self.iconview.unselect_all()
def __stopUsingProxyCb(self, unused_action, unused_parameter):
- prefer_original = self.app.settings.proxyingStrategy == ProxyingStrategy.NOTHING
+ prefer_original = self.app.settings.proxying_strategy == ProxyingStrategy.NOTHING
self._project.disable_proxies_for_assets(self.getSelectedAssets(),
hq_proxy=not prefer_original)
@@ -1320,7 +1320,7 @@ class MediaLibraryWidget(Gtk.Box, Loggable):
scaled=True)
def __deleteProxiesCb(self, unused_action, unused_parameter):
- prefer_original = self.app.settings.proxyingStrategy == ProxyingStrategy.NOTHING
+ prefer_original = self.app.settings.proxying_strategy == ProxyingStrategy.NOTHING
self._project.disable_proxies_for_assets(self.getSelectedAssets(),
delete_proxy_file=True,
hq_proxy=not prefer_original)
@@ -1512,8 +1512,8 @@ class MediaLibraryWidget(Gtk.Box, Loggable):
Gtk.TreeView.do_button_press_event(treeview, event)
selection = self.treeview.get_selection()
- if self._draggedPaths:
- for path in self._draggedPaths:
+ if self._dragged_paths:
+ for path in self._dragged_paths:
selection.select_path(path)
return True
@@ -1532,12 +1532,12 @@ class MediaLibraryWidget(Gtk.Box, Loggable):
chain_up = True
if not chain_up:
- self._draggedPaths = self.getSelectedPaths()
+ self._dragged_paths = self.getSelectedPaths()
else:
- self._draggedPaths = None
+ self._dragged_paths = None
def _treeViewButtonReleaseEventCb(self, treeview, event):
- self._draggedPaths = None
+ self._dragged_paths = None
selection = self.treeview.get_selection()
state = event.get_state() & (
Gdk.ModifierType.CONTROL_MASK | Gdk.ModifierType.SHIFT_MASK)
@@ -1569,7 +1569,7 @@ class MediaLibraryWidget(Gtk.Box, Loggable):
Space, Shift+Space, Return or Enter is pressed.
This method is the same for both iconview and treeview.
"""
- asset = self.modelFilter[path][COL_ASSET]
+ asset = self.model_filter[path][COL_ASSET]
self.emit('play', asset)
def _iconview_button_press_event_cb(self, iconview, event):
@@ -1577,8 +1577,8 @@ class MediaLibraryWidget(Gtk.Box, Loggable):
Gtk.IconView.do_button_press_event(iconview, event)
- if self._draggedPaths:
- for path in self._draggedPaths:
+ if self._dragged_paths:
+ for path in self._dragged_paths:
self.iconview.select_path(path)
self.iconview_cursor_pos = self.iconview.get_path_at_pos(
@@ -1587,7 +1587,7 @@ class MediaLibraryWidget(Gtk.Box, Loggable):
return True
def _iconview_button_release_event_cb(self, iconview, event):
- self._draggedPaths = None
+ self._dragged_paths = None
control_mask = event.get_state() & Gdk.ModifierType.CONTROL_MASK
shift_mask = event.get_state() & Gdk.ModifierType.SHIFT_MASK
@@ -1668,7 +1668,7 @@ class MediaLibraryWidget(Gtk.Box, Loggable):
# Used with TreeView and IconView
def _dnd_drag_data_get_cb(self, view, context, data, info, timestamp):
paths = self.getSelectedPaths()
- uris = [self.modelFilter[path][COL_URI] for path in paths]
+ uris = [self.model_filter[path][COL_URI] for path in paths]
data.set_uris(uris)
def _dnd_drag_begin_cb(self, view, context):
@@ -1679,7 +1679,7 @@ class MediaLibraryWidget(Gtk.Box, Loggable):
if not paths:
context.drag_abort(int(time.time()))
else:
- row = self.modelFilter[paths[0]]
+ row = self.model_filter[paths[0]]
icon = row[COL_ICON_128]
icon_height = icon.get_height()
@@ -1723,18 +1723,18 @@ class MediaLibraryWidget(Gtk.Box, Loggable):
def getSelectedItems(self):
"""Gets the URIs of the selected items."""
- if self._draggedPaths:
- return [self.modelFilter[path][COL_URI]
- for path in self._draggedPaths]
- return [self.modelFilter[path][COL_URI]
+ if self._dragged_paths:
+ return [self.model_filter[path][COL_URI]
+ for path in self._dragged_paths]
+ return [self.model_filter[path][COL_URI]
for path in self.getSelectedPaths()]
def getSelectedAssets(self):
"""Gets the selected assets."""
- if self._draggedPaths:
- return [self.modelFilter[path][COL_ASSET]
- for path in self._draggedPaths]
- return [self.modelFilter[path][COL_ASSET]
+ if self._dragged_paths:
+ return [self.model_filter[path][COL_ASSET]
+ for path in self._dragged_paths]
+ return [self.model_filter[path][COL_ASSET]
for path in self.getSelectedPaths()]
def activateCompactMode(self):
diff --git a/pitivi/project.py b/pitivi/project.py
index dad55af3..867260d0 100644
--- a/pitivi/project.py
+++ b/pitivi/project.py
@@ -50,19 +50,19 @@ from pitivi.timeline.previewers import ThumbnailCache
from pitivi.undo.project import AssetAddedIntention
from pitivi.undo.project import AssetProxiedIntention
from pitivi.utils.loggable import Loggable
-from pitivi.utils.misc import disconnectAllByFunc
+from pitivi.utils.misc import disconnect_all_by_func
from pitivi.utils.misc import fixate_caps_with_default_values
-from pitivi.utils.misc import isWritable
+from pitivi.utils.misc import is_writable
from pitivi.utils.misc import path_from_uri
from pitivi.utils.misc import quote_uri
from pitivi.utils.misc import scale_pixbuf
from pitivi.utils.misc import unicode_error_dialog
from pitivi.utils.pipeline import Pipeline
from pitivi.utils.ripple_update_group import RippleUpdateGroup
-from pitivi.utils.ui import audio_channels
-from pitivi.utils.ui import audio_rates
+from pitivi.utils.ui import AUDIO_CHANNELS
+from pitivi.utils.ui import AUDIO_RATES
from pitivi.utils.ui import beautify_time_delta
-from pitivi.utils.ui import frame_rates
+from pitivi.utils.ui import FRAME_RATES
from pitivi.utils.ui import get_combo_value
from pitivi.utils.ui import set_combo_value
from pitivi.utils.ui import SPACING
@@ -376,7 +376,7 @@ class ProjectManager(GObject.Object, Loggable):
# provided URI, so ensure it's properly encoded, or GIO will fail:
uri = quote_uri(uri)
- if not isWritable(path_from_uri(uri)):
+ if not is_writable(path_from_uri(uri)):
# TODO: this will not be needed when GTK+ bug #601451 is fixed
self.emit("save-project-failed", uri,
_("You do not have permissions to write to this folder."))
@@ -499,8 +499,8 @@ class ProjectManager(GObject.Object, Loggable):
self.current_project = None
project.create_thumb()
self.emit("project-closed", project)
- disconnectAllByFunc(project, self._projectChangedCb)
- disconnectAllByFunc(project.pipeline, self._projectPipelineDiedCb)
+ disconnect_all_by_func(project, self._projectChangedCb)
+ disconnect_all_by_func(project.pipeline, self._projectPipelineDiedCb)
self._cleanBackup(project.uri)
self.exitcode = project.release()
@@ -2031,32 +2031,31 @@ class ProjectSettingsDialog:
os.path.join(get_ui_dir(), "projectsettings.ui"))
self.builder.connect_signals(self)
- getObj = self.builder.get_object
- self.window = getObj("project-settings-dialog")
- self.frame_rate_combo = getObj("frame_rate_combo")
- self.channels_combo = getObj("channels_combo")
- self.sample_rate_combo = getObj("sample_rate_combo")
- self.year_spinbutton = getObj("year_spinbutton")
- self.author_entry = getObj("author_entry")
- self.width_spinbutton = getObj("width_spinbutton")
- self.height_spinbutton = getObj("height_spinbutton")
- self.audio_presets_combo = getObj("audio_presets_combo")
- self.video_presets_combo = getObj("video_presets_combo")
- self.constrain_sar_button = getObj("constrain_sar_button")
- self.select_dar_radiobutton = getObj("select_dar_radiobutton")
- self.year_spinbutton = getObj("year_spinbutton")
-
- self.video_preset_menubutton = getObj("video_preset_menubutton")
+ self.window = self.builder.get_object("project-settings-dialog")
+ self.frame_rate_combo = self.builder.get_object("frame_rate_combo")
+ self.channels_combo = self.builder.get_object("channels_combo")
+ self.sample_rate_combo = self.builder.get_object("sample_rate_combo")
+ self.year_spinbutton = self.builder.get_object("year_spinbutton")
+ self.author_entry = self.builder.get_object("author_entry")
+ self.width_spinbutton = self.builder.get_object("width_spinbutton")
+ self.height_spinbutton = self.builder.get_object("height_spinbutton")
+ self.audio_presets_combo = self.builder.get_object("audio_presets_combo")
+ self.video_presets_combo = self.builder.get_object("video_presets_combo")
+ self.constrain_sar_button = self.builder.get_object("constrain_sar_button")
+ self.select_dar_radiobutton = self.builder.get_object("select_dar_radiobutton")
+ self.year_spinbutton = self.builder.get_object("year_spinbutton")
+
+ self.video_preset_menubutton = self.builder.get_object("video_preset_menubutton")
self.video_presets.setupUi(self.video_presets_combo,
self.video_preset_menubutton)
self.video_presets.connect("preset-loaded", self.__videoPresetLoadedCb)
- self.audio_preset_menubutton = getObj("audio_preset_menubutton")
+ self.audio_preset_menubutton = self.builder.get_object("audio_preset_menubutton")
self.audio_presets.setupUi(self.audio_presets_combo,
self.audio_preset_menubutton)
- self.scaled_proxy_width_spin = getObj("scaled_proxy_width")
- self.scaled_proxy_height_spin = getObj("scaled_proxy_height")
- self.proxy_res_linked_check = getObj("proxy_res_linked")
+ self.scaled_proxy_width_spin = self.builder.get_object("scaled_proxy_width")
+ self.scaled_proxy_height_spin = self.builder.get_object("scaled_proxy_height")
+ self.proxy_res_linked_check = self.builder.get_object("proxy_res_linked")
def _setupUiConstraints(self):
"""Creates the dynamic widgets and connects other widgets."""
@@ -2067,53 +2066,53 @@ class ProjectSettingsDialog:
self.frame_rate_fraction_widget.show()
# Populate comboboxes.
- self.frame_rate_combo.set_model(frame_rates)
- self.channels_combo.set_model(audio_channels)
- self.sample_rate_combo.set_model(audio_rates)
+ self.frame_rate_combo.set_model(FRAME_RATES)
+ self.channels_combo.set_model(AUDIO_CHANNELS)
+ self.sample_rate_combo.set_model(AUDIO_RATES)
# Behavior.
- self.wg = RippleUpdateGroup()
- self.wg.addVertex(self.frame_rate_combo,
- signal="changed",
- update_func=self._update_combo_func,
- update_func_args=(self.frame_rate_fraction_widget,))
- self.wg.addVertex(self.frame_rate_fraction_widget,
- signal="value-changed",
- update_func=self._update_fraction_func,
- update_func_args=(self.frame_rate_combo,))
- self.wg.addVertex(self.width_spinbutton, signal="value-changed")
- self.wg.addVertex(self.height_spinbutton, signal="value-changed")
- self.wg.addVertex(self.audio_preset_menubutton,
- update_func=self._update_preset_menu_button_func,
- update_func_args=(self.audio_presets,))
- self.wg.addVertex(self.video_preset_menubutton,
- update_func=self._update_preset_menu_button_func,
- update_func_args=(self.video_presets,))
- self.wg.addVertex(self.channels_combo, signal="changed")
- self.wg.addVertex(self.sample_rate_combo, signal="changed")
- self.wg.addVertex(self.scaled_proxy_width_spin, signal="value-changed")
- self.wg.addVertex(self.scaled_proxy_height_spin, signal="value-changed")
+ self.widgets_group = RippleUpdateGroup()
+ self.widgets_group.addVertex(self.frame_rate_combo,
+ signal="changed",
+ update_func=self._update_combo_func,
+ update_func_args=(self.frame_rate_fraction_widget,))
+ self.widgets_group.addVertex(self.frame_rate_fraction_widget,
+ signal="value-changed",
+ update_func=self._update_fraction_func,
+ update_func_args=(self.frame_rate_combo,))
+ self.widgets_group.addVertex(self.width_spinbutton, signal="value-changed")
+ self.widgets_group.addVertex(self.height_spinbutton, signal="value-changed")
+ self.widgets_group.addVertex(self.audio_preset_menubutton,
+ update_func=self._update_preset_menu_button_func,
+ update_func_args=(self.audio_presets,))
+ self.widgets_group.addVertex(self.video_preset_menubutton,
+ update_func=self._update_preset_menu_button_func,
+ update_func_args=(self.video_presets,))
+ self.widgets_group.addVertex(self.channels_combo, signal="changed")
+ self.widgets_group.addVertex(self.sample_rate_combo, signal="changed")
+ self.widgets_group.addVertex(self.scaled_proxy_width_spin, signal="value-changed")
+ self.widgets_group.addVertex(self.scaled_proxy_height_spin, signal="value-changed")
# Constrain width and height IFF the Constrain checkbox is checked.
# Video
- self.wg.addEdge(self.width_spinbutton, self.height_spinbutton,
- predicate=self.widthHeightLinked,
- edge_func=self.updateHeight)
- self.wg.addEdge(self.height_spinbutton, self.width_spinbutton,
- predicate=self.widthHeightLinked,
- edge_func=self.updateWidth)
+ self.widgets_group.addEdge(self.width_spinbutton, self.height_spinbutton,
+ predicate=self.widthHeightLinked,
+ edge_func=self.updateHeight)
+ self.widgets_group.addEdge(self.height_spinbutton, self.width_spinbutton,
+ predicate=self.widthHeightLinked,
+ edge_func=self.updateWidth)
# Proxy
- self.wg.addEdge(self.scaled_proxy_width_spin,
- self.scaled_proxy_height_spin,
- predicate=self.proxy_res_linked,
- edge_func=self.update_scaled_proxy_height)
- self.wg.addEdge(self.scaled_proxy_height_spin,
- self.scaled_proxy_width_spin,
- predicate=self.proxy_res_linked,
- edge_func=self.update_scaled_proxy_width)
+ self.widgets_group.addEdge(self.scaled_proxy_width_spin,
+ self.scaled_proxy_height_spin,
+ predicate=self.proxy_res_linked,
+ edge_func=self.update_scaled_proxy_height)
+ self.widgets_group.addEdge(self.scaled_proxy_height_spin,
+ self.scaled_proxy_width_spin,
+ predicate=self.proxy_res_linked,
+ edge_func=self.update_scaled_proxy_width)
# Keep the framerate combo and fraction widgets in sync.
- self.wg.addBiEdge(
+ self.widgets_group.addBiEdge(
self.frame_rate_combo, self.frame_rate_fraction_widget)
# Presets.
@@ -2132,13 +2131,13 @@ class ProjectSettingsDialog:
self.bindCombo(
self.audio_presets, "sample-rate", self.sample_rate_combo)
- self.wg.addEdge(
+ self.widgets_group.addEdge(
self.frame_rate_fraction_widget, self.video_preset_menubutton)
- self.wg.addEdge(self.width_spinbutton, self.video_preset_menubutton)
- self.wg.addEdge(self.height_spinbutton, self.video_preset_menubutton)
+ self.widgets_group.addEdge(self.width_spinbutton, self.video_preset_menubutton)
+ self.widgets_group.addEdge(self.height_spinbutton, self.video_preset_menubutton)
- self.wg.addEdge(self.channels_combo, self.audio_preset_menubutton)
- self.wg.addEdge(self.sample_rate_combo, self.audio_preset_menubutton)
+ self.widgets_group.addEdge(self.channels_combo, self.audio_preset_menubutton)
+ self.widgets_group.addEdge(self.sample_rate_combo, self.audio_preset_menubutton)
def bindFractionWidget(self, mgr, name, widget):
mgr.bindWidget(name, widget.setWidgetValue, widget.getWidgetValue)
diff --git a/pitivi/render.py b/pitivi/render.py
index c080d6a4..a91cdaf2 100644
--- a/pitivi/render.py
+++ b/pitivi/render.py
@@ -30,16 +30,16 @@ from gi.repository import Gst
from gi.repository import Gtk
from pitivi import configure
-from pitivi.check import missing_soft_deps
+from pitivi.check import MISSING_SOFT_DEPS
from pitivi.preset import EncodingTargetManager
from pitivi.utils.loggable import Loggable
from pitivi.utils.misc import path_from_uri
from pitivi.utils.misc import show_user_manual
from pitivi.utils.ripple_update_group import RippleUpdateGroup
-from pitivi.utils.ui import audio_channels
-from pitivi.utils.ui import audio_rates
-from pitivi.utils.ui import beautify_ETA
-from pitivi.utils.ui import frame_rates
+from pitivi.utils.ui import AUDIO_CHANNELS
+from pitivi.utils.ui import AUDIO_RATES
+from pitivi.utils.ui import beautify_eta
+from pitivi.utils.ui import FRAME_RATES
from pitivi.utils.ui import get_combo_value
from pitivi.utils.ui import set_combo_value
from pitivi.utils.widgets import GstElementSettingsDialog
@@ -409,7 +409,8 @@ class RenderDialog(Loggable):
self.notification = None
# Variables to keep track of progress indication timers:
- self._filesizeEstimateTimer = self._timeEstimateTimer = None
+ self._filesize_estimate_timer = None
+ self._time_estimate_timer = None
self._is_rendering = False
self._rendering_is_paused = False
self._last_timestamp_when_pausing = 0
@@ -420,7 +421,7 @@ class RenderDialog(Loggable):
# Various gstreamer signal connection ID's
# {object: sigId}
- self._gstSigId = {}
+ self._gst_signal_handlers_ids = {}
self.render_presets = EncodingTargetManager(project)
self.render_presets.connect('profile-selected', self._encoding_profile_selected_cb)
@@ -452,9 +453,9 @@ class RenderDialog(Loggable):
self.preferred_aencoder = self.project.aencoder
self.__replaced_assets = {}
- self.frame_rate_combo.set_model(frame_rates)
- self.channels_combo.set_model(audio_channels)
- self.sample_rate_combo.set_model(audio_rates)
+ self.frame_rate_combo.set_model(FRAME_RATES)
+ self.channels_combo.set_model(AUDIO_CHANNELS)
+ self.sample_rate_combo.set_model(AUDIO_RATES)
self.__initialize_muxers_model()
self._displaySettings()
self._displayRenderSettings()
@@ -465,22 +466,22 @@ class RenderDialog(Loggable):
# Monitor changes
- self.wg = RippleUpdateGroup()
- self.wg.addVertex(self.frame_rate_combo, signal="changed")
- self.wg.addVertex(self.channels_combo, signal="changed")
- self.wg.addVertex(self.sample_rate_combo, signal="changed")
- self.wg.addVertex(self.muxer_combo, signal="changed")
- self.wg.addVertex(self.audio_encoder_combo, signal="changed")
- self.wg.addVertex(self.video_encoder_combo, signal="changed")
- self.wg.addVertex(self.preset_menubutton,
- update_func=self._updatePresetMenuButton)
-
- self.wg.addEdge(self.frame_rate_combo, self.preset_menubutton)
- self.wg.addEdge(self.audio_encoder_combo, self.preset_menubutton)
- self.wg.addEdge(self.video_encoder_combo, self.preset_menubutton)
- self.wg.addEdge(self.muxer_combo, self.preset_menubutton)
- self.wg.addEdge(self.channels_combo, self.preset_menubutton)
- self.wg.addEdge(self.sample_rate_combo, self.preset_menubutton)
+ self.widgets_group = RippleUpdateGroup()
+ self.widgets_group.addVertex(self.frame_rate_combo, signal="changed")
+ self.widgets_group.addVertex(self.channels_combo, signal="changed")
+ self.widgets_group.addVertex(self.sample_rate_combo, signal="changed")
+ self.widgets_group.addVertex(self.muxer_combo, signal="changed")
+ self.widgets_group.addVertex(self.audio_encoder_combo, signal="changed")
+ self.widgets_group.addVertex(self.video_encoder_combo, signal="changed")
+ self.widgets_group.addVertex(self.preset_menubutton,
+ update_func=self._updatePresetMenuButton)
+
+ self.widgets_group.addEdge(self.frame_rate_combo, self.preset_menubutton)
+ self.widgets_group.addEdge(self.audio_encoder_combo, self.preset_menubutton)
+ self.widgets_group.addEdge(self.video_encoder_combo, self.preset_menubutton)
+ self.widgets_group.addEdge(self.muxer_combo, self.preset_menubutton)
+ self.widgets_group.addEdge(self.channels_combo, self.preset_menubutton)
+ self.widgets_group.addEdge(self.sample_rate_combo, self.preset_menubutton)
def _encoding_profile_selected_cb(self, unused_target, encoding_profile):
self._set_encoding_profile(encoding_profile)
@@ -586,10 +587,10 @@ class RenderDialog(Loggable):
self.audio_settings_button = builder.get_object(
"audio_settings_button")
self.frame_rate_combo = builder.get_object("frame_rate_combo")
- self.frame_rate_combo.set_model(frame_rates)
+ self.frame_rate_combo.set_model(FRAME_RATES)
self.scale_spinbutton = builder.get_object("scale_spinbutton")
self.channels_combo = builder.get_object("channels_combo")
- self.channels_combo.set_model(audio_channels)
+ self.channels_combo.set_model(AUDIO_CHANNELS)
self.sample_rate_combo = builder.get_object("sample_rate_combo")
self.muxer_combo = builder.get_object("muxercombobox")
self.audio_encoder_combo = builder.get_object("audio_encoder_combo")
@@ -796,8 +797,8 @@ class RenderDialog(Loggable):
if not caps.intersect(ecaps).is_empty():
reduced.append((name, value))
- for v in sorted(reduced, key=lambda v: float(v[1])):
- reduced_model.append(v)
+ for value in sorted(reduced, key=lambda v: float(v[1])):
+ reduced_model.append(value)
combo.set_model(reduced_model)
set_combo_value(combo, combo_value)
@@ -813,12 +814,12 @@ class RenderDialog(Loggable):
caps = template.static_caps.get()
self._update_valid_restriction_values(caps, self.sample_rate_combo,
"audio/x-raw,rate=(int)%d",
- audio_rates,
+ AUDIO_RATES,
self.project.audiorate)
self._update_valid_restriction_values(caps, self.channels_combo,
"audio/x-raw,channels=(int)%d",
- audio_channels,
+ AUDIO_CHANNELS,
self.project.audiochannels)
def _update_valid_video_restrictions(self, factory):
@@ -831,7 +832,7 @@ class RenderDialog(Loggable):
caps = template.static_caps.get()
self._update_valid_restriction_values(
caps, self.frame_rate_combo,
- "video/x-raw,framerate=(GstFraction)%d/%d", frame_rates,
+ "video/x-raw,framerate=(GstFraction)%d/%d", FRAME_RATES,
self.project.videorate,
caps_template_expander=fraction_expander_func)
@@ -923,7 +924,7 @@ class RenderDialog(Loggable):
self._pipeline.set_state(Gst.State.NULL)
self._pipeline.set_mode(GES.PipelineFlags.RENDER)
encodebin = self._pipeline.get_by_name("internal-encodebin")
- self._gstSigId[encodebin] = encodebin.connect(
+ self._gst_signal_handlers_ids[encodebin] = encodebin.connect(
"element-added", self.__element_added_cb)
for element in encodebin.iterate_recurse():
self.__set_properties(element)
@@ -965,9 +966,9 @@ class RenderDialog(Loggable):
self.window.show() # Show the rendering dialog again
def _disconnectFromGst(self):
- for obj, handler_id in self._gstSigId.items():
+ for obj, handler_id in self._gst_signal_handlers_ids.items():
obj.disconnect(handler_id)
- self._gstSigId = {}
+ self._gst_signal_handlers_ids = {}
try:
self.project.pipeline.disconnect_by_func(self._updatePositionCb)
except TypeError:
@@ -979,7 +980,7 @@ class RenderDialog(Loggable):
def _maybe_play_finished_sound(self):
"""Plays a sound to signal the render operation is done."""
- if "GSound" in missing_soft_deps:
+ if "GSound" in MISSING_SOFT_DEPS:
return
from gi.repository import GSound
sound_context = GSound.Context()
@@ -1077,7 +1078,7 @@ class RenderDialog(Loggable):
self.progress.connect("pause", self._pauseRender)
bus = self._pipeline.get_bus()
bus.add_signal_watch()
- self._gstSigId[bus] = bus.connect('message', self._busMessageCb)
+ self._gst_signal_handlers_ids[bus] = bus.connect('message', self._busMessageCb)
self.project.pipeline.connect("position", self._updatePositionCb)
# Force writing the config now, or the path will be reset
# if the user opens the rendering dialog again
@@ -1114,12 +1115,12 @@ class RenderDialog(Loggable):
length = self.project.ges_timeline.props.duration
estimated_time = timediff * length / self.current_position
remaining_time = estimated_time - timediff
- estimate = beautify_ETA(int(remaining_time * Gst.SECOND))
+ estimate = beautify_eta(int(remaining_time * Gst.SECOND))
if estimate:
self.progress.updateProgressbarETA(estimate)
return True
else:
- self._timeEstimateTimer = None
+ self._time_estimate_timer = None
self.debug("Stopping the ETA timer")
return False
@@ -1133,7 +1134,7 @@ class RenderDialog(Loggable):
return True
else:
self.debug("Stopping the filesize estimation timer")
- self._filesizeEstimateTimer = None
+ self._filesize_estimate_timer = None
return False # Stop the timer
# GStreamer callbacks
@@ -1192,16 +1193,16 @@ class RenderDialog(Loggable):
# In order to have enough averaging, only display the ETA after 5s
timediff = time.time() - self._time_started
- if not self._timeEstimateTimer:
+ if not self._time_estimate_timer:
if timediff < 6:
self.progress.progressbar.set_text(_("Estimating..."))
else:
- self._timeEstimateTimer = GLib.timeout_add_seconds(
+ self._time_estimate_timer = GLib.timeout_add_seconds(
3, self._updateTimeEstimateCb)
# Filesize is trickier and needs more time to be meaningful.
- if not self._filesizeEstimateTimer and (fraction > 0.33 or timediff > 180):
- self._filesizeEstimateTimer = GLib.timeout_add_seconds(
+ if not self._filesize_estimate_timer and (fraction > 0.33 or timediff > 180):
+ self._filesize_estimate_timer = GLib.timeout_add_seconds(
5, self._updateFilesizeEstimateCb)
def __element_added_cb(self, unused_bin, gst_element):
diff --git a/pitivi/timeline/elements.py b/pitivi/timeline/elements.py
index 95a2a4d9..90c97e3d 100644
--- a/pitivi/timeline/elements.py
+++ b/pitivi/timeline/elements.py
@@ -39,7 +39,7 @@ from pitivi.timeline.previewers import VideoPreviewer
from pitivi.undo.timeline import CommitTimelineFinalizingAction
from pitivi.utils import pipeline
from pitivi.utils.loggable import Loggable
-from pitivi.utils.misc import disconnectAllByFunc
+from pitivi.utils.misc import disconnect_all_by_func
from pitivi.utils.misc import filename_from_uri
from pitivi.utils.timeline import SELECT
from pitivi.utils.timeline import SELECT_ADD
@@ -99,7 +99,7 @@ class KeyframeCurve(FigureCanvas, Loggable):
self._timeline = timeline
self.__source = binding.props.control_source
self._connect_sources()
- self.__propertyName = binding.props.name
+ self.__property_name = binding.props.name
self.__paramspec = binding.pspec
self.get_style_context().add_class("KeyframeCurve")
@@ -163,9 +163,9 @@ class KeyframeCurve(FigureCanvas, Loggable):
self.mpl_connect('motion_notify_event', self._mpl_motion_event_cb)
def release(self):
- disconnectAllByFunc(self, self.__heightRequestCb)
- disconnectAllByFunc(self, self.__gtkMotionEventCb)
- disconnectAllByFunc(self, self._controlSourceChangedCb)
+ disconnect_all_by_func(self, self.__heightRequestCb)
+ disconnect_all_by_func(self, self.__gtkMotionEventCb)
+ disconnect_all_by_func(self, self._controlSourceChangedCb)
def _connect_sources(self):
self.__source.connect("value-added", self._controlSourceChangedCb)
@@ -416,7 +416,7 @@ class KeyframeCurve(FigureCanvas, Loggable):
# showing what the keyframe curve affects, the timestamp at
# the mouse cursor location, and the value at that timestamp.
markup = _("Property: %s\nTimestamp: %s\nValue: %s") % (
- self.__propertyName,
+ self.__property_name,
Gst.TIME_ARGS(xdata),
"{:.3f}".format(value))
self.set_tooltip_markup(markup)
@@ -632,7 +632,7 @@ class TimelineElement(Gtk.Layout, Zoomable, Loggable):
self.add(self.__background)
self.keyframe_curve = None
- self.__controlledProperty = None
+ self.__controlled_property = None
self.show_all()
# We set up the default mixing property right here, if a binding was
@@ -677,13 +677,13 @@ class TimelineElement(Gtk.Layout, Zoomable, Loggable):
self.__create_keyframe_curve()
def showMultipleKeyframes(self, bindings):
- self.__controlledProperty = None
+ self.__controlled_property = None
self.__create_keyframe_curve(bindings)
def __setKeyframes(self, ges_elem, prop):
self.__removeKeyframes()
- self.__controlledProperty = prop
- if self.__controlledProperty:
+ self.__controlled_property = prop
+ if self.__controlled_property:
self.__createControlBinding(ges_elem)
def __curveEnterCb(self, unused_keyframe_curve):
@@ -712,9 +712,9 @@ class TimelineElement(Gtk.Layout, Zoomable, Loggable):
if len(values) < 2:
source.unset_all()
- val = float(self.__controlledProperty.default_value) / \
- (self.__controlledProperty.maximum -
- self.__controlledProperty.minimum)
+ val = float(self.__controlled_property.default_value) / \
+ (self.__controlled_property.maximum -
+ self.__controlled_property.minimum)
inpoint = self._ges_elem.props.in_point
res = source.set(inpoint, val)
assert res
@@ -725,7 +725,7 @@ class TimelineElement(Gtk.Layout, Zoomable, Loggable):
"""Creates required keyframe curve."""
self.__removeKeyframes()
if not bindings:
- bindings = [self._ges_elem.get_control_binding(self.__controlledProperty.name)]
+ bindings = [self._ges_elem.get_control_binding(self.__controlled_property.name)]
if len(bindings) == 1:
self.keyframe_curve = KeyframeCurve(self.timeline, bindings[0])
@@ -740,11 +740,11 @@ class TimelineElement(Gtk.Layout, Zoomable, Loggable):
def __createControlBinding(self, element):
"""Creates the required ControlBinding and keyframes."""
- if self.__controlledProperty:
+ if self.__controlled_property:
element.connect("control-binding-added",
self.__controlBindingAddedCb)
binding = \
- element.get_control_binding(self.__controlledProperty.name)
+ element.get_control_binding(self.__controlled_property.name)
if binding:
self.__ensure_keyframes(binding)
@@ -754,10 +754,10 @@ class TimelineElement(Gtk.Layout, Zoomable, Loggable):
source = GstController.InterpolationControlSource()
source.props.mode = GstController.InterpolationMode.LINEAR
element.set_control_source(source,
- self.__controlledProperty.name, "direct")
+ self.__controlled_property.name, "direct")
def __controlBindingAddedCb(self, unused_ges_elem, binding):
- if binding.props.name == self.__controlledProperty.name:
+ if binding.props.name == self.__controlled_property.name:
self.__ensure_keyframes(binding)
def do_draw(self, cr):
@@ -773,7 +773,7 @@ class TimelineElement(Gtk.Layout, Zoomable, Loggable):
# Callbacks
def __selectedChangedCb(self, unused_selected, selected):
- if not self.keyframe_curve and self.__controlledProperty and \
+ if not self.keyframe_curve and self.__controlled_property and \
selected and len(self.timeline.selection) == 1:
self.__create_keyframe_curve()
@@ -862,8 +862,8 @@ class VideoSource(TimelineElement):
if child == self.__videoflip:
self.__videoflip = None
self.__apply_new_size_if_needed()
- disconnectAllByFunc(child, self.__track_element_deep_notify_cb)
- disconnectAllByFunc(child, self.__track_element_notify_active_cb)
+ disconnect_all_by_func(child, self.__track_element_deep_notify_cb)
+ disconnect_all_by_func(child, self.__track_element_notify_active_cb)
def __retrieve_project_size(self):
project = self.timeline.app.project_manager.current_project
@@ -1089,8 +1089,8 @@ class Clip(Gtk.EventBox, Zoomable, Loggable):
self.get_accessible().set_name(name)
self._elements_container = None
- self.leftHandle = None
- self.rightHandle = None
+ self.left_handle = None
+ self.right_handle = None
self.handles = []
self.z_order = -1
self.timeline = layer.timeline
@@ -1140,11 +1140,11 @@ class Clip(Gtk.EventBox, Zoomable, Loggable):
return False
if target.name() == EFFECT_TARGET_ENTRY.target:
- self.info("Adding effect %s", self.timeline.dropData)
+ self.info("Adding effect %s", self.timeline.drop_data)
self.timeline.selection.setSelection([self.ges_clip], SELECT)
self.app.gui.editor.switchContextTab(self.ges_clip)
- effect_info = self.app.effects.getInfo(self.timeline.dropData)
+ effect_info = self.app.effects.getInfo(self.timeline.drop_data)
pipeline = self.timeline.ges_timeline.get_parent()
with self.app.action_log.started("add effect",
finalizing_action=CommitTimelineFinalizingAction(pipeline),
@@ -1239,14 +1239,14 @@ class Clip(Gtk.EventBox, Zoomable, Loggable):
self._elements_container = Gtk.Box.new(Gtk.Orientation.VERTICAL, 0)
overlay.add_overlay(self._elements_container)
- self.leftHandle = TrimHandle(self, GES.Edge.EDGE_START)
- overlay.add_overlay(self.leftHandle)
+ self.left_handle = TrimHandle(self, GES.Edge.EDGE_START)
+ overlay.add_overlay(self.left_handle)
- self.rightHandle = TrimHandle(self, GES.Edge.EDGE_END)
- overlay.add_overlay(self.rightHandle)
+ self.right_handle = TrimHandle(self, GES.Edge.EDGE_END)
+ overlay.add_overlay(self.right_handle)
- self.handles.append(self.leftHandle)
- self.handles.append(self.rightHandle)
+ self.handles.append(self.left_handle)
+ self.handles.append(self.right_handle)
def shrinkTrimHandles(self):
for handle in self.handles:
@@ -1293,11 +1293,11 @@ class Clip(Gtk.EventBox, Zoomable, Loggable):
for child in self.ges_clip.get_children(True):
self.__disconnectFromChild(child)
- disconnectAllByFunc(self.ges_clip, self._start_changed_cb)
- disconnectAllByFunc(self.ges_clip, self._duration_changed_cb)
- disconnectAllByFunc(self.ges_clip, self._layer_changed_cb)
- disconnectAllByFunc(self.ges_clip, self._child_added_cb)
- disconnectAllByFunc(self.ges_clip, self._child_removed_cb)
+ disconnect_all_by_func(self.ges_clip, self._start_changed_cb)
+ disconnect_all_by_func(self.ges_clip, self._duration_changed_cb)
+ disconnect_all_by_func(self.ges_clip, self._layer_changed_cb)
+ disconnect_all_by_func(self.ges_clip, self._child_added_cb)
+ disconnect_all_by_func(self.ges_clip, self._child_removed_cb)
def __showHandles(self):
for handle in self.handles:
diff --git a/pitivi/timeline/timeline.py b/pitivi/timeline/timeline.py
index f0adc2dc..33ce4673 100644
--- a/pitivi/timeline/timeline.py
+++ b/pitivi/timeline/timeline.py
@@ -374,15 +374,15 @@ class Timeline(Gtk.EventBox, Zoomable, Loggable):
# Clip editing.
# Which clip widget is being edited.
- self.draggingElement = None
+ self.dragging_element = None
# The GES.Group in case there are one or more clips being dragged.
self.dragging_group = None
- # Which handle of the draggingElement has been clicked, if any.
+ # Which handle of the dragging_element has been clicked, if any.
# If set, it means we are in a trim operation.
- self.__clickedHandle = None
+ self.__clicked_handle = None
# The GES object for controlling the operation.
self.editing_context = None
- # Whether draggingElement really got dragged.
+ # Whether dragging_element really got dragged.
self.__got_dragged = False
# The x of the event which starts the drag operation.
self.__drag_start_x = 0
@@ -398,10 +398,10 @@ class Timeline(Gtk.EventBox, Zoomable, Loggable):
# Set to True when a clip has been dragged because the first
# button-release-event on the clip should be ignored.
self.got_dragged = False
- # Whether the drop data has been received. See self.dropData below.
- self.dropDataReady = False
+ # Whether the drop data has been received. See self.drop_data below.
+ self.drop_data_ready = False
# What's being dropped, for example asset URIs.
- self.dropData = None
+ self.drop_data = None
# Whether clips have been created in the current drag & drop.
self.dropping_clips = False
# The list of (Layer, Clip) tuples dragged into the timeline.
@@ -707,14 +707,14 @@ class Timeline(Gtk.EventBox, Zoomable, Loggable):
res, button = event.get_button()
if res and button == 1:
- self.draggingElement = self._getParentOfType(event_widget, Clip)
+ self.dragging_element = self._getParentOfType(event_widget, Clip)
if isinstance(event_widget, TrimHandle):
- self.__clickedHandle = event_widget
- self.debug("Dragging element is %s", self.draggingElement)
+ self.__clicked_handle = event_widget
+ self.debug("Dragging element is %s", self.dragging_element)
- if self.draggingElement:
+ if self.dragging_element:
self.__drag_start_x = event.x
- self._on_layer = self.draggingElement.layer.ges_layer
+ self._on_layer = self.dragging_element.layer.ges_layer
self.dragging_group = self.selection.group()
else:
layer_controls = self._getParentOfType(event_widget, LayerControls)
@@ -743,7 +743,7 @@ class Timeline(Gtk.EventBox, Zoomable, Loggable):
allow_seek = not self.__got_dragged
res, button = event.get_button()
- if self.draggingElement:
+ if self.dragging_element:
self.dragEnd()
elif self.__moving_layer:
self.__endMovingLayer()
@@ -838,9 +838,9 @@ class Timeline(Gtk.EventBox, Zoomable, Loggable):
yield clip
def _motion_notify_event_cb(self, unused_widget, event):
- if self.draggingElement:
- if isinstance(self.draggingElement, TransitionClip) and \
- not self.__clickedHandle:
+ if self.dragging_element:
+ if isinstance(self.dragging_element, TransitionClip) and \
+ not self.__clicked_handle:
# Don't allow dragging a transition.
return False
@@ -924,11 +924,11 @@ class Timeline(Gtk.EventBox, Zoomable, Loggable):
y (int): The y coordinate relative to the layers box.
"""
placement = 0
- self.draggingElement = None
+ self.dragging_element = None
- assets = self._project.assetsForUris(self.dropData)
+ assets = self._project.assetsForUris(self.drop_data)
if not assets:
- self._project.addUris(self.dropData)
+ self._project.addUris(self.drop_data)
return False
ges_clips = []
@@ -959,7 +959,7 @@ class Timeline(Gtk.EventBox, Zoomable, Loggable):
if ges_clips:
ges_clip = ges_clips[0]
- self.draggingElement = ges_clip.ui
+ self.dragging_element = ges_clip.ui
self._on_layer = ges_layer
self.dropping_clips = True
@@ -975,7 +975,7 @@ class Timeline(Gtk.EventBox, Zoomable, Loggable):
Gdk.drag_status(context, 0, timestamp)
return True
- if not self.dropDataReady:
+ if not self.drop_data_ready:
# We don't know yet the details of what's being dragged.
# Ask for the details.
self.drag_get_data(context, target, timestamp)
@@ -994,17 +994,17 @@ class Timeline(Gtk.EventBox, Zoomable, Loggable):
self._setSeparatorsPrelight(False)
target = self.drag_dest_find_target(context, None)
- if self.draggingElement:
+ if self.dragging_element:
self.__last_clips_on_leave = [(clip.get_layer(), clip)
for clip in self.dragging_group.get_children(False)]
- self.dropDataReady = False
+ self.drop_data_ready = False
if self.dropping_clips:
self.selection.setSelection([], SELECT)
for clip in self.dragging_group.get_children(False):
clip.get_layer().remove_clip(clip)
self._project.pipeline.commit_timeline()
- self.draggingElement = None
+ self.dragging_element = None
self.__got_dragged = False
self.dropping_clips = False
self.dragging_group.ungroup(recursive=False)
@@ -1013,8 +1013,8 @@ class Timeline(Gtk.EventBox, Zoomable, Loggable):
self.cleanDropData()
def cleanDropData(self):
- self.dropDataReady = False
- self.dropData = None
+ self.drop_data_ready = False
+ self.drop_data = None
self.dropping_clips = False
def _drag_drop_cb(self, unused_widget, context, x, y, timestamp):
@@ -1055,16 +1055,16 @@ class Timeline(Gtk.EventBox, Zoomable, Loggable):
def _drag_data_received_cb(self, unused_widget, unused_context, unused_x,
unused_y, selection_data, unused_info, timestamp):
data_type = selection_data.get_data_type().name()
- if not self.dropDataReady:
+ if not self.drop_data_ready:
self.__last_clips_on_leave = None
if data_type == URI_TARGET_ENTRY.target:
- self.dropData = selection_data.get_uris()
- self.dropDataReady = True
+ self.drop_data = selection_data.get_uris()
+ self.drop_data_ready = True
elif data_type == EFFECT_TARGET_ENTRY.target:
# Dragging an effect from the Effect Library.
factory_name = str(selection_data.get_data(), "UTF-8")
- self.dropData = factory_name
- self.dropDataReady = True
+ self.drop_data = factory_name
+ self.drop_data_ready = True
# Handle layers
def _layer_added_cb(self, unused_ges_timeline, ges_layer):
@@ -1307,19 +1307,19 @@ class Timeline(Gtk.EventBox, Zoomable, Loggable):
x (int): The x coordinate relative to the layers box.
y (int): The y coordinate relative to the layers box.
"""
- if not self.draggingElement:
+ if not self.dragging_element:
return
if self.__got_dragged is False:
self.__got_dragged = True
- if self.__clickedHandle:
+ if self.__clicked_handle:
edit_mode = GES.EditMode.EDIT_TRIM
- dragging_edge = self.__clickedHandle.edge
+ dragging_edge = self.__clicked_handle.edge
else:
edit_mode = GES.EditMode.EDIT_NORMAL
dragging_edge = GES.Edge.EDGE_NONE
- self.editing_context = EditingContext(self.draggingElement.ges_clip,
+ self.editing_context = EditingContext(self.dragging_element.ges_clip,
self.ges_timeline,
edit_mode,
dragging_edge,
@@ -1378,7 +1378,7 @@ class Timeline(Gtk.EventBox, Zoomable, Loggable):
if self.editing_context:
self.__end_snap()
- if self._separator_accepting_drop and self.__on_separators and self.__got_dragged and not
self.__clickedHandle:
+ if self._separator_accepting_drop and self.__on_separators and self.__got_dragged and not
self.__clicked_handle:
priority = self.separator_priority(self.__on_separators[1])
ges_layer = self.create_layer(priority)
position = self.editing_context.new_position
@@ -1386,11 +1386,11 @@ class Timeline(Gtk.EventBox, Zoomable, Loggable):
self.editing_context.finish()
- self.draggingElement = None
+ self.dragging_element = None
if self.dragging_group is not None:
self.dragging_group.ungroup(recursive=False)
self.dragging_group = None
- self.__clickedHandle = None
+ self.__clicked_handle = None
self.__got_dragged = False
self.editing_context = None
@@ -1974,12 +1974,12 @@ class TimelineContainer(Gtk.Grid, Zoomable, Loggable):
progress_dialog.window.show()
self.app.action_log.begin("align", toplevel=True)
- def alignedCb(): # Called when alignment is complete
+ def aligned_cb(): # Called when alignment is complete
self.app.action_log.commit()
self._project.pipeline.commit_timeline()
progress_dialog.window.destroy()
- auto_aligner = AutoAligner(self.timeline.selection, alignedCb)
+ auto_aligner = AutoAligner(self.timeline.selection, aligned_cb)
progress_meter = auto_aligner.start()
progress_meter.addWatcher(progress_dialog.updatePosition)
diff --git a/pitivi/titleeditor.py b/pitivi/titleeditor.py
index 7565840a..779fc488 100644
--- a/pitivi/titleeditor.py
+++ b/pitivi/titleeditor.py
@@ -110,22 +110,21 @@ class TitleEditor(Loggable):
self.background_color_picker.add(self.color_picker_background_widget)
self.color_picker_background_widget.connect("value-changed", self._color_picker_value_changed_cb,
self.background_color_button, "foreground-color")
- settings = ["valignment", "halignment", "x-absolute", "y-absolute"]
- for setting in settings:
- self.settings[setting] = builder.get_object(setting)
-
- for n, en in list({_("Absolute"): "absolute",
- _("Top"): "top",
- _("Center"): "center",
- _("Bottom"): "bottom",
- _("Baseline"): "baseline"}.items()):
- self.settings["valignment"].append(en, n)
-
- for n, en in list({_("Absolute"): "absolute",
- _("Left"): "left",
- _("Center"): "center",
- _("Right"): "right"}.items()):
- self.settings["halignment"].append(en, n)
+ for widget_id in ("valignment", "halignment", "x-absolute", "y-absolute"):
+ self.settings[widget_id] = builder.get_object(widget_id)
+
+ for value_id, text in (("absolute", _("Absolute")),
+ ("top", _("Top")),
+ ("center", _("Center")),
+ ("bottom", _("Bottom")),
+ ("baseline", _("Baseline"))):
+ self.settings["valignment"].append(value_id, text)
+
+ for value_id, text in (("absolute", _("Absolute")),
+ ("left", _("Left")),
+ ("center", _("Center")),
+ ("right", _("Right"))):
+ self.settings["halignment"].append(value_id, text)
def _setChildProperty(self, name, value):
with self.app.action_log.started("Title change property",
@@ -137,16 +136,16 @@ class TitleEditor(Loggable):
finally:
self._setting_props = False
- def _color_picker_value_changed_cb(self, widget, colorButton, colorLayer):
+ def _color_picker_value_changed_cb(self, widget, color_button, color_layer):
argb = 0
argb += (1 * 255) * 256 ** 3
argb += float(widget.color_r) * 256 ** 2
argb += float(widget.color_g) * 256 ** 1
argb += float(widget.color_b) * 256 ** 0
- self.debug("Setting text %s to %x", colorLayer, argb)
- self._setChildProperty(colorLayer, argb)
+ self.debug("Setting text %s to %x", color_layer, argb)
+ self._setChildProperty(color_layer, argb)
rgba = argb_to_gdk_rgba(argb)
- colorButton.set_rgba(rgba)
+ color_button.set_rgba(rgba)
def _backgroundColorButtonCb(self, widget):
color = gdk_rgba_to_argb(widget.get_rgba())
diff --git a/pitivi/transitions.py b/pitivi/transitions.py
index a87d45f1..4c15d55d 100644
--- a/pitivi/transitions.py
+++ b/pitivi/transitions.py
@@ -26,7 +26,7 @@ from gi.repository import Gtk
from pitivi.configure import get_pixmap_dir
from pitivi.utils.loggable import Loggable
-from pitivi.utils.misc import disconnectAllByFunc
+from pitivi.utils.misc import disconnect_all_by_func
from pitivi.utils.ui import fix_infobar
from pitivi.utils.ui import PADDING
from pitivi.utils.ui import SPACING
@@ -182,7 +182,7 @@ class TransitionsListWidget(Gtk.Box, Loggable):
self.invert_checkbox.disconnect_by_func(self._invertCheckboxCb)
self.border_mode_normal.disconnect_by_func(self._borderTypeChangedCb)
self.border_mode_loop.disconnect_by_func(self._borderTypeChangedCb)
- disconnectAllByFunc(self.element, self.__updated_cb)
+ disconnect_all_by_func(self.element, self.__updated_cb)
# UI callbacks
diff --git a/pitivi/utils/loggable.py b/pitivi/utils/loggable.py
index 70f0f404..699097a8 100644
--- a/pitivi/utils/loggable.py
+++ b/pitivi/utils/loggable.py
@@ -169,8 +169,8 @@ class TerminalController:
return
# Look up numeric capabilities.
- self.COLS = curses.tigetnum('cols')
- self.LINES = curses.tigetnum('lines')
+ TerminalController.COLS = curses.tigetnum('cols')
+ TerminalController.LINES = curses.tigetnum('lines')
# Look up string capabilities.
for capability in self._STRING_CAPABILITIES:
@@ -215,14 +215,14 @@ class TerminalController:
return re.sub(r'\$\$|\${\w+}', self._render_sub, template)
def _render_sub(self, match):
- s = match.group()
- if s == '$$':
- return s
+ matched_group = match.group()
+ if matched_group == '$$':
+ return matched_group
else:
- return getattr(self, s[2:-1])
+ return getattr(self, matched_group[2:-1])
-def getLevelName(level):
+def get_level_name(level):
"""Returns the name of the specified log level.
Args:
@@ -233,10 +233,10 @@ def getLevelName(level):
"""
assert isinstance(level, int) and level > 0 and level < 7, \
TypeError("Bad debug level")
- return getLevelNames()[level - 1]
+ return get_level_names()[level - 1]
-def getLevelNames():
+def get_level_names():
"""Returns a list with the level names.
Returns:
@@ -245,27 +245,27 @@ def getLevelNames():
return _LEVEL_NAMES
-def getLevelInt(levelName):
+def get_level_int(level_name):
"""Returns the integer value of the levelName.
Args:
- levelName (str): The string value of the level name.
+ level_name (str): The string value of the level name.
Returns:
int: The value of the level name we are interested in.
"""
- assert isinstance(levelName, str) and levelName in getLevelNames(), \
+ assert isinstance(level_name, str) and level_name in get_level_names(), \
"Bad debug level name"
- return getLevelNames().index(levelName) + 1
+ return get_level_names().index(level_name) + 1
-def getFormattedLevelName(level):
+def get_formatted_level_name(level):
assert isinstance(level, int) and level > 0 and level < len(_LEVEL_NAMES) + 1, \
TypeError("Bad debug level")
return _FORMATTED_LEVELS[level - 1]
-def registerCategory(category):
+def register_category(category):
"""Registers the specified category in the debug system.
A level will be assigned to it based on previous calls to setDebug.
@@ -301,7 +301,7 @@ def registerCategory(category):
_categories[category] = level
-def getCategoryLevel(category):
+def get_category_level(category):
"""Gets the debug level at which the specified category is being logged.
Registers the category and thus assigns a log level if it wasn't registered
@@ -312,11 +312,11 @@ def getCategoryLevel(category):
"""
global _categories
if category not in _categories:
- registerCategory(category)
+ register_category(category)
return _categories[category]
-def setLogSettings(state):
+def set_log_settings(state):
"""Updates the current log settings.
This can restore an old saved log settings object returned by
@@ -335,10 +335,10 @@ def setLogSettings(state):
_log_handlers_limited) = state
for category in _categories:
- registerCategory(category)
+ register_category(category)
-def getLogSettings():
+def get_log_settings():
"""Fetches the current log settings.
The returned object can be sent to setLogSettings to restore the
@@ -353,16 +353,16 @@ def getLogSettings():
_log_handlers_limited)
-def _canShortcutLogging(category, level):
+def _can_shortcut_logging(category, level):
if _log_handlers:
# we have some loggers operating without filters, have to do
# everything
return False
else:
- return level > getCategoryLevel(category)
+ return level > get_category_level(category)
-def scrubFilename(filename):
+def scrub_filename(filename):
"""Scrubs the filename to a relative path."""
global _PACKAGE_SCRUB_LIST
for package in _PACKAGE_SCRUB_LIST:
@@ -373,7 +373,7 @@ def scrubFilename(filename):
return filename
-def getFileLine(where=-1):
+def get_file_line(where=-1):
"""Returns the filename and line number for the specified location.
Args:
@@ -398,53 +398,53 @@ def getFileLine(where=-1):
lineno = co.co_firstlineno
name = co.co_name
else:
- stackFrame = sys._getframe() # pylint: disable=protected-access
- while stackFrame:
- co = stackFrame.f_code
+ stack_frame = sys._getframe() # pylint: disable=protected-access
+ while stack_frame:
+ co = stack_frame.f_code
if not co.co_filename.endswith('loggable.py'):
- co = stackFrame.f_code
- lineno = stackFrame.f_lineno
+ co = stack_frame.f_code
+ lineno = stack_frame.f_lineno
name = co.co_name
break
- stackFrame = stackFrame.f_back
+ stack_frame = stack_frame.f_back
if not co:
return "<unknown file>", 0, None
- return scrubFilename(co.co_filename), lineno, name
+ return scrub_filename(co.co_filename), lineno, name
-def ellipsize(o):
+def ellipsize(obj):
"""Ellipsizes the representation of the given object."""
- r = repr(o)
- if len(r) < 800:
- return r
+ obj_repr = repr(obj)
+ if len(obj_repr) < 800:
+ return obj_repr
- r = r[:60] + ' ... ' + r[-15:]
- return r
+ obj_repr = obj_repr[:60] + ' ... ' + obj_repr[-15:]
+ return obj_repr
-def getFormatArgs(startFormat, startArgs, endFormat, endArgs, args, kwargs):
+def get_format_args(start_format, start_args, end_format, end_args, args, kwargs):
"""Creates a format and args to use for logging.
This avoids needlessly interpolating variables.
"""
- debugArgs = startArgs[:]
- for a in args:
- debugArgs.append(ellipsize(a))
+ debug_args = start_args[:]
+ for arg in args:
+ debug_args.append(ellipsize(arg))
for items in list(kwargs.items()):
- debugArgs.extend(items)
- debugArgs.extend(endArgs)
- fmt = startFormat \
- + ', '.join(('%s', ) * len(args)) \
- + (kwargs and ', ' or '') \
- + ', '.join(('%s=%r', ) * len(kwargs)) \
- + endFormat
- return fmt, debugArgs
+ debug_args.extend(items)
+ debug_args.extend(end_args)
+ fmt = start_format \
+ + ', '.join(('%s', ) * len(args)) \
+ + (kwargs and ', ' or '') \
+ + ', '.join(('%s=%r', ) * len(kwargs)) \
+ + end_format
+ return fmt, debug_args
-def doLog(level, obj, category, message, args, where=-1, filePath=None, line=None):
+def do_log(level, obj, category, message, args, where=-1, file_path=None, line=None):
"""Logs something.
Args:
@@ -456,7 +456,7 @@ def doLog(level, obj, category, message, args, where=-1, filePath=None, line=Non
where (int or function): What to log file and line number for;
-1 for one frame above log.py; -2 and down for higher up;
a function for a (future) code object.
- filePath (Optional[str]): The file to show the message as coming from,
+ file_path (Optional[str]): The file to show the message as coming from,
if caller knows best.
line (Optional[int]): The line to show the message as coming from,
if caller knows best.
@@ -473,68 +473,68 @@ def doLog(level, obj, category, message, args, where=-1, filePath=None, line=Non
message = message % args
funcname = None
- if level > getCategoryLevel(category):
+ if level > get_category_level(category):
handlers = _log_handlers
else:
handlers = _log_handlers + _log_handlers_limited
if handlers:
- if filePath is None and line is None:
- (filePath, line, funcname) = getFileLine(where=where)
- ret['filePath'] = filePath
+ if file_path is None and line is None:
+ (file_path, line, funcname) = get_file_line(where=where)
+ ret['filePath'] = file_path
ret['line'] = line
if funcname:
message = "\033[00m\033[32;01m%s:\033[00m %s" % (funcname, message)
for handler in handlers:
try:
- handler(level, obj, category, filePath, line, message)
+ handler(level, obj, category, file_path, line, message)
except TypeError as e:
raise SystemError("handler %r raised a TypeError: %s" % (
- handler, getExceptionMessage(e)))
+ handler, get_exception_message(e)))
return ret
-def errorObject(obj, cat, fmt, *args):
+def error_object(obj, cat, fmt, *args):
"""Logs a fatal error message in the specified category.
This will also raise a `SystemExit`.
"""
- doLog(ERROR, obj, cat, fmt, args)
+ do_log(ERROR, obj, cat, fmt, args)
-def warningObject(obj, cat, fmt, *args):
+def warning_object(obj, cat, fmt, *args):
"""Logs a warning message in the specified category.
This is used for non-fatal problems.
"""
- doLog(WARN, obj, cat, fmt, args)
+ do_log(WARN, obj, cat, fmt, args)
-def fixmeObject(obj, cat, fmt, *args):
+def fixme_object(obj, cat, fmt, *args):
"""Logs a fixme message in the specified category.
This is used for not implemented codepaths or known issues in the code.
"""
- doLog(FIXME, obj, cat, fmt, args)
+ do_log(FIXME, obj, cat, fmt, args)
-def infoObject(obj, cat, fmt, *args):
+def info_object(obj, cat, fmt, *args):
"""Logs an informational message in the specified category."""
- doLog(INFO, obj, cat, fmt, args)
+ do_log(INFO, obj, cat, fmt, args)
-def debugObject(obj, cat, fmt, *args):
+def debug_object(obj, cat, fmt, *args):
"""Logs a debug message in the specified category."""
- doLog(DEBUG, obj, cat, fmt, args)
+ do_log(DEBUG, obj, cat, fmt, args)
-def logObject(obj, cat, fmt, *args):
+def log_object(obj, cat, fmt, *args):
"""Logs a log message.
Used for debugging recurring events.
"""
- doLog(LOG, obj, cat, fmt, args)
+ do_log(LOG, obj, cat, fmt, args)
def safeprintf(file, fmt, *args):
@@ -553,10 +553,10 @@ def safeprintf(file, fmt, *args):
# otherwise ignore it, there's nothing you can do
-def printHandler(level, obj, category, file, line, message):
+def print_handler(level, obj, category, file, line, message):
"""Writes to stderr.
- The output will be different depending the value of "_enableCrackOutput";
+ The output will be different depending the value of "_enable_crack_output";
in Pitivi's case, that is True when the GST_DEBUG env var is defined.
Args:
@@ -575,48 +575,49 @@ def printHandler(level, obj, category, file, line, message):
# If GST_DEBUG is not set, we can assume only PITIVI_DEBUG is set, so don't
# show a bazillion of debug details that are not relevant to Pitivi.
- if not _enableCrackOutput:
+ if not _enable_crack_output:
safeprintf(_outfile, '%s %-8s %-17s %-2s %s %s\n',
- getFormattedLevelName(level), time.strftime("%H:%M:%S"),
+ get_formatted_level_name(level), time.strftime("%H:%M:%S"),
category, obj, message, where)
else:
- o = ""
if obj:
- o = '"' + obj + '"'
+ obj = '"' + obj + '"'
+ else:
+ obj = ""
# level pid object cat time
# 5 + 1 + 7 + 1 + 32 + 1 + 17 + 1 + 15 == 80
safeprintf(
_outfile, '%s [%5d] [0x%12x] %-32s %-17s %-15s %-4s %s %s\n',
- getFormattedLevelName(level), os.getpid(),
+ get_formatted_level_name(level), os.getpid(),
threading.current_thread().ident,
- o[:32], category, time.strftime("%b %d %H:%M:%S"), "",
+ obj[:32], category, time.strftime("%b %d %H:%M:%S"), "",
message, where)
_outfile.flush()
-def logLevelName(level):
+def log_level_name(level):
fmt = '%-5s'
return fmt % (_LEVEL_NAMES[level - 1], )
-def _preformatLevels(enableColorOutput):
+def _preformat_levels(enable_color_output):
terminal_controller = TerminalController()
for level in ERROR, WARN, FIXME, INFO, DEBUG, LOG:
- if enableColorOutput:
+ if enable_color_output:
if isinstance(terminal_controller.BOLD, bytes):
formatter = ''.join(
(terminal_controller.BOLD.decode(),
getattr(terminal_controller, COLORS[level]).decode(),
- logLevelName(level),
+ log_level_name(level),
terminal_controller.NORMAL.decode()))
else:
formatter = ''.join(
(terminal_controller.BOLD,
getattr(terminal_controller, COLORS[level]),
- logLevelName(level),
+ log_level_name(level),
terminal_controller.NORMAL))
else:
- formatter = logLevelName(level)
+ formatter = log_level_name(level)
_FORMATTED_LEVELS.append(formatter)
# "public" useful API
@@ -624,47 +625,47 @@ def _preformatLevels(enableColorOutput):
# setup functions
-def init(envVarName, enableColorOutput=True, enableCrackOutput=True):
+def init(env_var_name, enable_color_output=True, enable_crack_output=True):
"""Initializes the logging system.
Needs to be called before using the log methods.
Args:
- envVarName (str): The name of the environment variable with additional
+ env_var_name (str): The name of the environment variable with additional
settings.
- enableColorOutput (Optional[bool]): Whether to colorize the output.
- enableCrackOutput (Optional[bool]): Whether to print detailed info.
+ enable_color_output (Optional[bool]): Whether to colorize the output.
+ enable_crack_output (Optional[bool]): Whether to print detailed info.
"""
global _initialized
global _outfile
- global _enableCrackOutput
- _enableCrackOutput = enableCrackOutput
+ global _enable_crack_output
+ _enable_crack_output = enable_crack_output
if _initialized:
return
global _ENV_VAR_NAME
- _ENV_VAR_NAME = envVarName
+ _ENV_VAR_NAME = env_var_name
- _preformatLevels(enableColorOutput)
+ _preformat_levels(enable_color_output)
- if envVarName in os.environ:
+ if env_var_name in os.environ:
# install a log handler that uses the value of the environment var
- setDebug(os.environ[envVarName])
- filenameEnvVarName = envVarName + "_FILE"
+ set_debug(os.environ[env_var_name])
+ filename_env_var_name = env_var_name + "_FILE"
- if filenameEnvVarName in os.environ:
+ if filename_env_var_name in os.environ:
# install a log handler that uses the value of the environment var
- _outfile = open(os.environ[filenameEnvVarName], "w+")
+ _outfile = open(os.environ[filename_env_var_name], "w+")
else:
_outfile = sys.stderr
- addLimitedLogHandler(printHandler)
+ add_limited_log_handler(print_handler)
_initialized = True
-def setDebug(string):
+def set_debug(string):
"""Sets the DEBUG string.
This controls the log output.
@@ -678,16 +679,16 @@ def setDebug(string):
# reparse all already registered category levels
for category in _categories:
- registerCategory(category)
+ register_category(category)
-def getDebug():
+def get_debug():
"""Returns the currently active DEBUG string."""
global _DEBUG
return _DEBUG
-def setPackageScrubList(*packages):
+def set_package_scrub_list(*packages):
"""Sets the package names to scrub from filenames.
Filenames from these paths in log messages will be scrubbed to their
@@ -709,7 +710,7 @@ def reset():
_initialized = False
-def addLogHandler(func):
+def add_log_handler(func):
"""Adds a custom log handler.
The log handler receives all the log messages.
@@ -731,7 +732,7 @@ def addLogHandler(func):
_log_handlers.append(func)
-def addLimitedLogHandler(func):
+def add_limited_log_handler(func):
"""Adds a custom limited log handler.
The log handler receives only the messages passing the filter.
@@ -753,7 +754,7 @@ def addLimitedLogHandler(func):
_log_handlers_limited.append(func)
-def removeLogHandler(func):
+def remove_log_handler(func):
"""Removes a registered log handler.
Raises:
@@ -762,7 +763,7 @@ def removeLogHandler(func):
_log_handlers.remove(func)
-def removeLimitedLogHandler(func):
+def remove_limited_log_handler(func):
"""Removes a registered limited log handler.
Raises:
@@ -774,32 +775,32 @@ def removeLimitedLogHandler(func):
def error(cat, fmt, *args):
- errorObject(None, cat, fmt, *args)
+ error_object(None, cat, fmt, *args)
def warning(cat, fmt, *args):
- warningObject(None, cat, fmt, *args)
+ warning_object(None, cat, fmt, *args)
def fixme(cat, fmt, *args):
- fixmeObject(None, cat, fmt, *args)
+ fixme_object(None, cat, fmt, *args)
def info(cat, fmt, *args):
- infoObject(None, cat, fmt, *args)
+ info_object(None, cat, fmt, *args)
def debug(cat, fmt, *args):
- debugObject(None, cat, fmt, *args)
+ debug_object(None, cat, fmt, *args)
def log(cat, fmt, *args):
- logObject(None, cat, fmt, *args)
+ log_object(None, cat, fmt, *args)
# public utility functions
-def getExceptionMessage(exception, frame=-1, filename=None):
+def get_exception_message(exception, frame=-1, filename=None):
"""Returns a short message based on an exception.
Useful for debugging.
@@ -810,7 +811,7 @@ def getExceptionMessage(exception, frame=-1, filename=None):
stack = [f for f in stack if f[0].find(filename) > -1]
# import code; code.interact(local=locals())
(filename, line, func, text) = stack[frame]
- filename = scrubFilename(filename)
+ filename = scrub_filename(filename)
exc = exception.__class__.__name__
msg = ""
# a shortcut to extract a useful message out of most exceptions
@@ -821,8 +822,9 @@ def getExceptionMessage(exception, frame=-1, filename=None):
% locals()
-def reopenOutputFiles():
- """Reopens the stdout and stderr output files, as set by `outputToFiles`."""
+def reopen_output_files():
+ """Reopens the stdout and stderr output files set by `output_to_files`."""
+ global _stdout, _stderr
if not _stdout and not _stderr:
debug('log', 'told to reopen log files, but log files not set')
return
@@ -844,10 +846,10 @@ def reopenOutputFiles():
debug('log', 'opened log %r', _stderr)
-def outputToFiles(stdout=None, stderr=None):
+def output_to_files(stdout=None, stderr=None):
"""Redirects stdout and stderr to the specified files.
- Records the file names so that a future call to reopenOutputFiles()
+ Records the file names so that a future call to reopen_output_files()
can open the same files. Installs a SIGHUP handler that will reopen
the output files.
@@ -857,11 +859,11 @@ def outputToFiles(stdout=None, stderr=None):
"""
global _stdout, _stderr, _old_hup_handler
_stdout, _stderr = stdout, stderr
- reopenOutputFiles()
+ reopen_output_files()
def sighup(signum, frame):
info('log', "Received SIGHUP, reopening logs")
- reopenOutputFiles()
+ reopen_output_files()
if _old_hup_handler:
info('log', "Calling old SIGHUP handler")
_old_hup_handler(signum, frame)
@@ -885,7 +887,7 @@ class BaseLoggable:
to most: log, debug, info, warning, error.
Attributes:
- logCategory (str): The category under which the messages will be filed.
+ log_category (str): The category under which the messages will be filed.
Can be used to set a display filter.
"""
@@ -894,60 +896,60 @@ class BaseLoggable:
By default this will also raise an exception.
"""
- if _canShortcutLogging(self.logCategory, ERROR):
+ if _can_shortcut_logging(self.log_category, ERROR):
return
- errorObject(self.logObjectName(),
- self.logCategory, *self.logFunction(*args))
+ error_object(self.logObjectName(),
+ self.log_category, *self.logFunction(*args))
def warning(self, *args):
"""Logs a warning.
Used for non-fatal problems.
"""
- if _canShortcutLogging(self.logCategory, WARN):
+ if _can_shortcut_logging(self.log_category, WARN):
return
- warningObject(
- self.logObjectName(), self.logCategory, *self.logFunction(*args))
+ warning_object(
+ self.logObjectName(), self.log_category, *self.logFunction(*args))
def fixme(self, *args):
"""Logs a fixme.
Used for FIXMEs.
"""
- if _canShortcutLogging(self.logCategory, FIXME):
+ if _can_shortcut_logging(self.log_category, FIXME):
return
- fixmeObject(self.logObjectName(),
- self.logCategory, *self.logFunction(*args))
+ fixme_object(self.logObjectName(),
+ self.log_category, *self.logFunction(*args))
def info(self, *args):
"""Logs an informational message.
Used for normal operation.
"""
- if _canShortcutLogging(self.logCategory, INFO):
+ if _can_shortcut_logging(self.log_category, INFO):
return
- infoObject(self.logObjectName(),
- self.logCategory, *self.logFunction(*args))
+ info_object(self.logObjectName(),
+ self.log_category, *self.logFunction(*args))
def debug(self, *args):
"""Logs a debug message.
Used for debugging.
"""
- if _canShortcutLogging(self.logCategory, DEBUG):
+ if _can_shortcut_logging(self.log_category, DEBUG):
return
- debugObject(self.logObjectName(),
- self.logCategory, *self.logFunction(*args))
+ debug_object(self.logObjectName(),
+ self.log_category, *self.logFunction(*args))
def log(self, *args):
"""Logs a log message.
Used for debugging recurring events.
"""
- if _canShortcutLogging(self.logCategory, LOG):
+ if _can_shortcut_logging(self.log_category, LOG):
return
- logObject(self.logObjectName(),
- self.logCategory, *self.logFunction(*args))
+ log_object(self.logObjectName(),
+ self.log_category, *self.logFunction(*args))
def doLog(self, level, where, fmt, *args, **kwargs):
"""Logs a message at the specified level.
@@ -966,11 +968,11 @@ class BaseLoggable:
dict: The calculated variables, to be reused in a
call to doLog that should show the same location.
"""
- if _canShortcutLogging(self.logCategory, level):
+ if _can_shortcut_logging(self.log_category, level):
return {}
args = self.logFunction(*args)
- return doLog(level, self.logObjectName(), self.logCategory,
- fmt, args, where=where, **kwargs)
+ return do_log(level, self.logObjectName(), self.log_category,
+ fmt, args, where=where, **kwargs)
def logFunction(self, *args):
"""Processes the arguments applied to the message template.
@@ -988,16 +990,16 @@ class BaseLoggable:
return None
def handleException(self, exc):
- self.warning(getExceptionMessage(exc))
+ self.warning(get_exception_message(exc))
class Loggable(BaseLoggable):
- def __init__(self, logCategory=None):
- if logCategory:
- self.logCategory = logCategory
- elif not hasattr(self, 'logCategory'):
- self.logCategory = self.__class__.__name__.lower()
+ def __init__(self, log_category=None):
+ if log_category:
+ self.log_category = log_category
+ elif not hasattr(self, 'log_category'):
+ self.log_category = self.__class__.__name__.lower()
def logObjectName(self):
res = BaseLoggable.logObjectName(self)
@@ -1006,7 +1008,7 @@ class Loggable(BaseLoggable):
return res
def error(self, fmt, *args):
- if _canShortcutLogging(self.logCategory, ERROR):
+ if _can_shortcut_logging(self.log_category, ERROR):
return
- doLog(ERROR, self.logObjectName(), self.logCategory,
- fmt, self.logFunction(*args), where=-2)
+ do_log(ERROR, self.logObjectName(), self.log_category,
+ fmt, self.logFunction(*args), where=-2)
diff --git a/pitivi/utils/misc.py b/pitivi/utils/misc.py
index 155aec18..dada9306 100644
--- a/pitivi/utils/misc.py
+++ b/pitivi/utils/misc.py
@@ -55,7 +55,7 @@ def scale_pixbuf(pixbuf, width, height):
# Work around https://bugzilla.gnome.org/show_bug.cgi?id=759249
-def disconnectAllByFunc(obj, func):
+def disconnect_all_by_func(obj, func):
i = 0
while True:
i += 1
@@ -113,7 +113,7 @@ def is_valid_file(path):
return False
-def isWritable(path):
+def is_writable(path):
"""Returns whether the file/path is writable."""
try:
if os.path.isdir(path):
@@ -305,9 +305,9 @@ def unicode_error_dialog():
def intersect(v1, v2):
- s = Gst.Structure('t', t=v1).intersect(Gst.Structure('t', t=v2))
- if s:
- return s['t']
+ structure = Gst.Structure('t', t=v1).intersect(Gst.Structure('t', t=v2))
+ if structure:
+ return structure['t']
return None
@@ -372,16 +372,16 @@ def fixate_caps_with_default_values(template, restrictions, default_values,
elif default_val:
struct[field] = default_val
else:
- v = None
+ value = None
struct_val = struct[field]
if prev_val:
- v = intersect(struct_val, prev_val)
- if v is not None:
- struct[field] = v
- if v is None and default_val:
- v = intersect(struct_val, default_val)
- if v is not None:
- struct[field] = v
+ value = intersect(struct_val, prev_val)
+ if value is not None:
+ struct[field] = value
+ if value is None and default_val:
+ value = intersect(struct_val, default_val)
+ if value is not None:
+ struct[field] = value
else:
log.debug("utils", "Field %s from %s is plainly fixated",
field, struct)
diff --git a/pitivi/utils/pipeline.py b/pitivi/utils/pipeline.py
index ce419f61..5c9c6a23 100644
--- a/pitivi/utils/pipeline.py
+++ b/pitivi/utils/pipeline.py
@@ -27,7 +27,7 @@ from gi.repository import GLib
from gi.repository import GObject
from gi.repository import Gst
-from pitivi.check import videosink_factory
+from pitivi.check import VIDEOSINK_FACTORY
from pitivi.utils.loggable import Loggable
from pitivi.utils.misc import format_ns
@@ -89,8 +89,8 @@ class SimplePipeline(GObject.Object, Loggable):
self._bus.add_signal_watch()
self._bus.connect("message", self._busMessageCb)
self._listening = False # for the position handler
- self._listeningInterval = DEFAULT_POSITION_LISTENNING_INTERVAL
- self._listeningSigId = 0
+ self._listening_interval = DEFAULT_POSITION_LISTENNING_INTERVAL
+ self._listening_sig_id = 0
self._duration = Gst.CLOCK_TIME_NONE
# The last known position.
self._last_position = 0 * Gst.SECOND
@@ -108,7 +108,7 @@ class SimplePipeline(GObject.Object, Loggable):
(Gst.Element, Gtk.Widget): An element of type Gst.ElementFlags.SINK
and a widget connected to it.
"""
- factory_name = videosink_factory.get_name()
+ factory_name = VIDEOSINK_FACTORY.get_name()
sink = Gst.ElementFactory.make(factory_name, None)
widget = sink.props.widget
@@ -116,7 +116,7 @@ class SimplePipeline(GObject.Object, Loggable):
self.info("Using gtksink")
video_sink = sink
else:
- self.info("Using glsinkbin around %s", videosink_factory.get_name())
+ self.info("Using glsinkbin around %s", VIDEOSINK_FACTORY.get_name())
video_sink = Gst.ElementFactory.make("glsinkbin", None)
video_sink.props.sink = sink
@@ -266,7 +266,7 @@ class SimplePipeline(GObject.Object, Loggable):
if self._listening:
return True
self._listening = True
- self._listeningInterval = interval
+ self._listening_interval = interval
# if we're in playing, switch it on
self._listenToPosition(self.getState() == Gst.State.PLAYING)
return True
@@ -292,13 +292,13 @@ class SimplePipeline(GObject.Object, Loggable):
# stupid and dumm method, not many checks done
# i.e. it does NOT check for current state
if listen:
- if self._listening and self._listeningSigId == 0:
- self._listeningSigId = GLib.timeout_add(
- self._listeningInterval,
+ if self._listening and self._listening_sig_id == 0:
+ self._listening_sig_id = GLib.timeout_add(
+ self._listening_interval,
self._positionListenerCb)
- elif self._listeningSigId != 0:
- GLib.source_remove(self._listeningSigId)
- self._listeningSigId = 0
+ elif self._listening_sig_id != 0:
+ GLib.source_remove(self._listening_sig_id)
+ self._listening_sig_id = 0
def _async_done_not_received_cb(self):
self.error("we didn't get async done, this is a bug")
diff --git a/pitivi/utils/proxy.py b/pitivi/utils/proxy.py
index 826d676f..1a010e87 100644
--- a/pitivi/utils/proxy.py
+++ b/pitivi/utils/proxy.py
@@ -45,17 +45,17 @@ class ProxyingStrategy:
GlobalSettings.addConfigSection("proxy")
-GlobalSettings.addConfigOption('proxyingStrategy',
+GlobalSettings.addConfigOption('proxying_strategy',
section='proxy',
key='proxying-strategy',
default=ProxyingStrategy.AUTOMATIC)
-GlobalSettings.addConfigOption('numTranscodingJobs',
+GlobalSettings.addConfigOption('num_transcoding_jobs',
section='proxy',
key='num-proxying-jobs',
default=4,
notify=True)
-PreferencesDialog.addNumericPreference('numTranscodingJobs',
+PreferencesDialog.addNumericPreference('num_transcoding_jobs',
description="",
section="_proxies",
label=_("Max number of parallel transcoding jobs"),
@@ -94,19 +94,19 @@ ENCODING_FORMAT_PRORES = "prores-raw-in-matroska.gep"
ENCODING_FORMAT_JPEG = "jpeg-raw-in-matroska.gep"
-def createEncodingProfileSimple(container_caps, audio_caps, video_caps):
- c = GstPbutils.EncodingContainerProfile.new(None, None,
- Gst.Caps(container_caps),
- None)
- a = GstPbutils.EncodingAudioProfile.new(Gst.Caps(audio_caps),
- None, None, 0)
- v = GstPbutils.EncodingVideoProfile.new(Gst.Caps(video_caps),
- None, None, 0)
+def create_encoding_profile_simple(container_caps, audio_caps, video_caps):
+ container_profile = GstPbutils.EncodingContainerProfile.new(None, None,
+ Gst.Caps(container_caps),
+ None)
+ audio_profile = GstPbutils.EncodingAudioProfile.new(Gst.Caps(audio_caps),
+ None, None, 0)
+ video_profile = GstPbutils.EncodingVideoProfile.new(Gst.Caps(video_caps),
+ None, None, 0)
- c.add_profile(a)
- c.add_profile(v)
+ container_profile.add_profile(audio_profile)
+ container_profile.add_profile(video_profile)
- return c
+ return container_profile
class ProxyManager(GObject.Object, Loggable):
@@ -132,7 +132,7 @@ class ProxyManager(GObject.Object, Loggable):
for container in WHITELIST_CONTAINER_CAPS:
for audio in WHITELIST_AUDIO_CAPS:
for video in WHITELIST_VIDEO_CAPS:
- WHITELIST_FORMATS.append(createEncodingProfileSimple(
+ WHITELIST_FORMATS.append(create_encoding_profile_simple(
container, audio, video))
for audio in WHITELIST_AUDIO_CAPS:
@@ -161,7 +161,7 @@ class ProxyManager(GObject.Object, Loggable):
self.__waiting_transcoders = []
self.__encoding_target_file = None
- self.proxyingUnsupported = False
+ self.proxying_unsupported = False
for encoding_format in [ENCODING_FORMAT_JPEG, ENCODING_FORMAT_PRORES]:
self.__encoding_profile = self.__getEncodingProfile(encoding_format)
if self.__encoding_profile:
@@ -170,7 +170,7 @@ class ProxyManager(GObject.Object, Loggable):
break
if not self.__encoding_profile:
- self.proxyingUnsupported = True
+ self.proxying_unsupported = True
self.error("Not supporting any proxy formats!")
return
@@ -198,8 +198,8 @@ class ProxyManager(GObject.Object, Loggable):
return width, height
- def _assetMatchesEncodingFormat(self, asset, encoding_profile):
- def capsMatch(info, profile):
+ def _asset_matches_encoding_format(self, asset, encoding_profile):
+ def caps_match(info, profile):
return not info.get_caps().intersect(profile.get_format()).is_empty()
info = asset.get_info()
@@ -207,7 +207,7 @@ class ProxyManager(GObject.Object, Loggable):
if isinstance(info.get_stream_info(), GstPbutils.DiscovererContainerInfo):
return False
audios = info.get_audio_streams()
- if len(audios) != 1 or not capsMatch(audios[0], encoding_profile):
+ if len(audios) != 1 or not caps_match(audios[0], encoding_profile):
return False
if info.get_video_streams():
return False
@@ -215,19 +215,19 @@ class ProxyManager(GObject.Object, Loggable):
container = info.get_stream_info()
if container:
- if not capsMatch(container, encoding_profile):
+ if not caps_match(container, encoding_profile):
return False
for profile in encoding_profile.get_profiles():
if isinstance(profile, GstPbutils.EncodingAudioProfile):
audios = info.get_audio_streams()
for audio_stream in audios:
- if not capsMatch(audio_stream, profile):
+ if not caps_match(audio_stream, profile):
return False
elif isinstance(profile, GstPbutils.EncodingVideoProfile):
videos = info.get_video_streams()
for video_stream in videos:
- if not capsMatch(video_stream, profile):
+ if not caps_match(video_stream, profile):
return False
return True
@@ -359,7 +359,7 @@ class ProxyManager(GObject.Object, Loggable):
def isAssetFormatWellSupported(self, asset):
for encoding_format in self.WHITELIST_FORMATS:
- if self._assetMatchesEncodingFormat(asset, encoding_format):
+ if self._asset_matches_encoding_format(asset, encoding_format):
self.info("Automatically not proxying")
return True
@@ -377,28 +377,28 @@ class ProxyManager(GObject.Object, Loggable):
return asset_res == target_res
def __assetNeedsTranscoding(self, asset, scaled=False):
- if self.proxyingUnsupported:
+ if self.proxying_unsupported:
self.info("No proxying supported")
return False
if asset.is_image():
return False
- if self.app.settings.proxyingStrategy == ProxyingStrategy.NOTHING:
+ if self.app.settings.proxying_strategy == ProxyingStrategy.NOTHING:
self.debug("Not proxying anything. %s",
- self.app.settings.proxyingStrategy)
+ self.app.settings.proxying_strategy)
return False
- if self.app.settings.proxyingStrategy == ProxyingStrategy.AUTOMATIC \
+ if self.app.settings.proxying_strategy == ProxyingStrategy.AUTOMATIC \
and scaled and not self.asset_matches_target_res(asset):
return True
- if self.app.settings.proxyingStrategy == ProxyingStrategy.AUTOMATIC \
+ if self.app.settings.proxying_strategy == ProxyingStrategy.AUTOMATIC \
and not scaled and not self.is_hq_proxy(asset) and \
self.isAssetFormatWellSupported(asset):
return False
- if not self._assetMatchesEncodingFormat(asset, self.__encoding_profile):
+ if not self._asset_matches_encoding_format(asset, self.__encoding_profile):
return True
self.info("%s does not need proxy", asset.get_id())
@@ -563,10 +563,12 @@ class ProxyManager(GObject.Object, Loggable):
def _get_second_transcoder(self, transcoder):
"""Gets the shadow of a scaled proxy or the other way around."""
all_transcoders = self.__running_transcoders + self.__pending_transcoders
- for t in all_transcoders:
- if t.props.position_update_interval != transcoder.props.position_update_interval \
- and t.props.src_uri == transcoder.props.src_uri:
- return t
+ for transcoder2 in all_transcoders:
+ if transcoder2.props.position_update_interval == transcoder.props.position_update_interval:
+ # Both transcoders are of the same type.
+ continue
+ if transcoder2.props.src_uri == transcoder.props.src_uri:
+ return transcoder2
return None
def _is_shadow_transcoder(self, transcoder):
@@ -648,7 +650,7 @@ class ProxyManager(GObject.Object, Loggable):
transcoder.connect("done", self.__transcoder_done_cb, asset)
transcoder.connect("error", self.__transcoder_error_cb, asset)
- if len(self.__running_transcoders) < self.app.settings.numTranscodingJobs:
+ if len(self.__running_transcoders) < self.app.settings.num_transcoding_jobs:
self.__startTranscoder(transcoder)
else:
self.__pending_transcoders.append(transcoder)
@@ -694,7 +696,7 @@ class ProxyManager(GObject.Object, Loggable):
# Create shadow proxies for unsupported assets
if not self.isAssetFormatWellSupported(asset) and not \
- self.app.settings.proxyingStrategy == ProxyingStrategy.NOTHING \
+ self.app.settings.proxying_strategy == ProxyingStrategy.NOTHING \
and not shadow:
hq_uri = self.app.proxy_manager.getProxyUri(asset)
if not Gio.File.new_for_uri(hq_uri).query_exists(None):
@@ -713,7 +715,7 @@ class ProxyManager(GObject.Object, Loggable):
if not force_proxying:
if not self.__assetNeedsTranscoding(asset, scaled):
self.debug("Not proxying asset (proxying disabled: %s)",
- self.proxyingUnsupported)
+ self.proxying_unsupported)
# Make sure to notify we do not need a proxy for that asset.
self.emit("proxy-ready", asset, None)
return
@@ -728,7 +730,7 @@ class ProxyManager(GObject.Object, Loggable):
return
self.debug("Creating a proxy for %s (strategy: %s, force: %s, scaled: %s)",
- asset.get_id(), self.app.settings.proxyingStrategy,
+ asset.get_id(), self.app.settings.proxying_strategy,
force_proxying, scaled)
if scaled:
project = self.app.project_manager.current_project
diff --git a/pitivi/utils/system.py b/pitivi/utils/system.py
index f21b7227..83591c7a 100644
--- a/pitivi/utils/system.py
+++ b/pitivi/utils/system.py
@@ -23,7 +23,7 @@ import sys
from gi.repository import GObject
-from pitivi.check import missing_soft_deps
+from pitivi.check import MISSING_SOFT_DEPS
from pitivi.configure import APPNAME
from pitivi.utils.loggable import Loggable
@@ -74,7 +74,7 @@ class FreedesktopOrgSystem(System):
def __init__(self):
System.__init__(self)
- if "Notify" not in missing_soft_deps:
+ if "Notify" not in MISSING_SOFT_DEPS:
from gi.repository import Notify
Notify.init(APPNAME)
@@ -82,7 +82,7 @@ class FreedesktopOrgSystem(System):
# call super method for consistent logging
System.desktopMessage(self, title, message, icon)
- if "Notify" not in missing_soft_deps:
+ if "Notify" not in MISSING_SOFT_DEPS:
from gi.repository import Notify
notification = Notify.Notification.new(title, message, icon=icon)
try:
diff --git a/pitivi/utils/ui.py b/pitivi/utils/ui.py
index ac2be35a..d772b6a7 100644
--- a/pitivi/utils/ui.py
+++ b/pitivi/utils/ui.py
@@ -41,7 +41,7 @@ from gi.repository.GstPbutils import DiscovererSubtitleInfo
from gi.repository.GstPbutils import DiscovererVideoInfo
from pitivi.configure import get_pixmap_dir
-from pitivi.utils.loggable import doLog
+from pitivi.utils.loggable import do_log
from pitivi.utils.loggable import ERROR
from pitivi.utils.loggable import INFO
from pitivi.utils.misc import path_from_uri
@@ -456,7 +456,7 @@ def beautify_asset(asset):
try:
beautified_string = beautify_stream(stream)
except NotImplementedError:
- doLog(ERROR, "Beautify", "None", "Cannot beautify %s", stream)
+ do_log(ERROR, "Beautify", "None", "Cannot beautify %s", stream)
continue
if beautified_string:
res.append(beautified_string)
@@ -630,7 +630,7 @@ def beautify_time_delta(seconds):
return ", ".join(parts)
-def beautify_ETA(length_nanos):
+def beautify_eta(length_nanos):
"""Converts the specified duration to a fuzzy estimate.
Intended for progress ETAs, not to indicate a clip's duration.
@@ -716,9 +716,9 @@ def set_combo_value(combo, value):
combo.props.model.foreach(select_specific_row, found)
if len(found) != 1:
- doLog(INFO, None, "utils",
- "Could not set value %s, possible values: %s",
- (value, [v[0] for v in combo.props.model]))
+ do_log(INFO, None, "utils",
+ "Could not set value %s, possible values: %s",
+ (value, [v[0] for v in combo.props.model]))
return False
return True
@@ -774,10 +774,10 @@ def fix_infobar(infobar):
infobar.forall(make_sure_revealer_does_nothing)
-audio_channels = model((str, int),
+AUDIO_CHANNELS = model((str, int),
[(format_audiochannels(ch), ch) for ch in (8, 6, 4, 2, 1)])
-frame_rates = model((str, object),
+FRAME_RATES = model((str, object),
[(format_framerate(Gst.Fraction(*fps)), Gst.Fraction(*fps)) for fps in (
(12, 1),
(15, 1),
@@ -793,7 +793,7 @@ frame_rates = model((str, object),
(120, 1)
)])
-audio_rates = model((str, int),
+AUDIO_RATES = model((str, int),
[(format_audiorate(rate), rate) for rate in (
8000,
11025,
diff --git a/pitivi/utils/validate.py b/pitivi/utils/validate.py
index 508500b7..1673dd22 100644
--- a/pitivi/utils/validate.py
+++ b/pitivi/utils/validate.py
@@ -40,13 +40,14 @@ try:
except ImportError:
GstValidate = None
except ValueError:
+ # pylint: disable=invalid-name
GstValidate = None
monitor = None
has_validate = False
-def Event(event_type, **kwargs):
+def create_event(event_type, **kwargs):
event_types_constructors = {
Gdk.EventType.BUTTON_PRESS: Gdk.EventButton,
Gdk.EventType.BUTTON_RELEASE: Gdk.EventButton,
@@ -138,8 +139,8 @@ def stop_func(scenario, action):
return 1
-def positionChangedCb(pipeline, position, scenario, action,
- wanted_position):
+def position_changed_cb(pipeline, position, scenario, action,
+ wanted_position):
if pipeline._busy_async:
return
@@ -153,7 +154,7 @@ def positionChangedCb(pipeline, position, scenario, action,
"Position after seek (%s) does not match wanted one %s" % (
Gst.TIME_ARGS(position), Gst.TIME_ARGS(wanted_position)))
- pipeline.disconnect_by_func(positionChangedCb)
+ pipeline.disconnect_by_func(position_changed_cb)
action.set_done()
@@ -162,7 +163,7 @@ def seek_func(scenario, action):
"start")
assert res
scenario.get_pipeline().simple_seek(wanted_position)
- scenario.get_pipeline().connect("position", positionChangedCb, scenario,
+ scenario.get_pipeline().connect("position", position_changed_cb, scenario,
action, wanted_position)
return GstValidate.ActionReturn.ASYNC
@@ -219,7 +220,7 @@ def _release_button_if_needed(scenario, timeline, container, layer_prio,
if next_action is None or need_release:
scenario.dragging = False
x = Zoomable.nsToPixelAccurate(position)
- event = Event(Gdk.EventType.BUTTON_RELEASE, button=1, x=x, y=y)
+ event = create_event(Gdk.EventType.BUTTON_RELEASE, button=1, x=x, y=y)
with mock.patch.object(Gtk, "get_event_widget") as get_event_widget:
get_event_widget.return_value = container.ui
container.ui._button_release_event_cb(None, event)
@@ -231,21 +232,21 @@ def _release_button_if_needed(scenario, timeline, container, layer_prio,
% (container.get_layer().get_priority(),
layer_prio))
- cleanEditModes(timeline, scenario)
+ clean_edit_modes(timeline, scenario)
-def cleanEditModes(timeline, scenario):
+def clean_edit_modes(timeline, scenario):
if scenario.last_mode == GES.EditMode.EDIT_RIPPLE:
- event = Event(Gdk.EventType.KEY_RELEASE, keyval=Gdk.KEY_Shift_L)
+ event = create_event(Gdk.EventType.KEY_RELEASE, keyval=Gdk.KEY_Shift_L)
timeline.ui.get_parent().do_key_release_event(event)
elif scenario.last_mode == GES.EditMode.EDIT_ROLL:
- event = Event(Gdk.EventType.KEY_RELEASE, keyval=Gdk.KEY_Control_L)
+ event = create_event(Gdk.EventType.KEY_RELEASE, keyval=Gdk.KEY_Control_L)
timeline.ui.get_parent().do_key_release_event(event)
scenario.last_mode = None
-def setEditingMode(timeline, scenario, action):
+def set_editing_mode(timeline, scenario, action):
if not hasattr(scenario, "last_mode"):
scenario.last_mode = None
@@ -259,18 +260,18 @@ def setEditingMode(timeline, scenario, action):
mode = GES.EditMode.EDIT_NORMAL
if mode == GES.EditMode.EDIT_RIPPLE:
- timeline.ui.get_parent().do_key_press_event(Event(Gdk.EventType.KEY_PRESS, keyval=Gdk.KEY_Shift_L))
+ timeline.ui.get_parent().do_key_press_event(create_event(Gdk.EventType.KEY_PRESS,
keyval=Gdk.KEY_Shift_L))
if scenario.last_mode == GES.EditMode.EDIT_ROLL:
- timeline.ui.get_parent().do_key_release_event(Event(Gdk.EventType.KEY_RELEASE,
keyval=Gdk.KEY_Control_L))
+ timeline.ui.get_parent().do_key_release_event(create_event(Gdk.EventType.KEY_RELEASE,
keyval=Gdk.KEY_Control_L))
elif mode == GES.EditMode.EDIT_ROLL:
- timeline.ui.do_key_press_event(Event(Gdk.EventType.KEY_PRESS, keyval=Gdk.KEY_Control_L))
+ timeline.ui.do_key_press_event(create_event(Gdk.EventType.KEY_PRESS, keyval=Gdk.KEY_Control_L))
if scenario.last_mode == GES.EditMode.EDIT_RIPPLE:
- timeline.ui.do_key_release_event(Event(Gdk.EventType.KEY_RELEASE, keyval=Gdk.KEY_Shift_L))
+ timeline.ui.do_key_release_event(create_event(Gdk.EventType.KEY_RELEASE, keyval=Gdk.KEY_Shift_L))
else:
- cleanEditModes(timeline, scenario)
+ clean_edit_modes(timeline, scenario)
scenario.last_mode = mode
@@ -299,7 +300,7 @@ def edit_container_func(scenario, action):
edge = get_edge(action.structure)
container_ui = container.ui
- setEditingMode(timeline, scenario, action)
+ set_editing_mode(timeline, scenario, action)
y = 21 - container_ui.translate_coordinates(timeline.ui, 0, 0)[1]
@@ -332,20 +333,19 @@ def edit_container_func(scenario, action):
event_widget = container.ui
if isinstance(container, GES.SourceClip):
if edge == GES.Edge.EDGE_START:
- event_widget = container.ui.leftHandle
+ event_widget = container.ui.left_handle
elif edge == GES.Edge.EDGE_END:
- event_widget = container.ui.rightHandle
+ event_widget = container.ui.right_handle
scenario.dragging = True
- event = Event(Gdk.EventType.BUTTON_PRESS, button=1, y=y)
+ event = create_event(Gdk.EventType.BUTTON_PRESS, button=1, y=y)
with mock.patch.object(Gtk, "get_event_widget") as get_event_widget:
get_event_widget.return_value = event_widget
timeline.ui._button_press_event_cb(event_widget, event)
- event = Event(Gdk.EventType.MOTION_NOTIFY, button=1,
- x=Zoomable.nsToPixelAccurate(position) -
- container_ui.translate_coordinates(timeline.ui.layout.layers_vbox, 0, 0)[0],
- y=y, state=Gdk.ModifierType.BUTTON1_MASK)
+ x = Zoomable.nsToPixelAccurate(position) -
container_ui.translate_coordinates(timeline.ui.layout.layers_vbox, 0, 0)[0]
+ event = create_event(Gdk.EventType.MOTION_NOTIFY, button=1,
+ x=x, y=y, state=Gdk.ModifierType.BUTTON1_MASK)
with mock.patch.object(Gtk, "get_event_widget") as get_event_widget:
get_event_widget.return_value = container.ui
timeline.ui._motion_notify_event_cb(None, event)
@@ -440,10 +440,10 @@ def select_clips_func(scenario, action):
if clip.ui.get_state_flags() & Gtk.StateFlags.SELECTED:
should_select = False
- event = Event(Gdk.EventType.KEY_PRESS, keyval=Gdk.KEY_Control_L)
+ event = create_event(Gdk.EventType.KEY_PRESS, keyval=Gdk.KEY_Control_L)
timeline.ui.get_parent().do_key_press_event(event)
- event = Event(Gdk.EventType.BUTTON_RELEASE, button=1)
+ event = create_event(Gdk.EventType.BUTTON_RELEASE, button=1)
with mock.patch.object(Gtk, "get_event_widget") as get_event_widget:
get_event_widget.return_value = clip.ui
clip.ui._button_release_event_cb(None, event)
@@ -460,35 +460,35 @@ def select_clips_func(scenario, action):
"Clip %s should be UNselected but is not"
% clip.get_name())
else:
- for l in timeline.get_layers():
- for c in l.get_clips():
- if c.get_name() in selection:
- if not c.ui.get_state_flags() & Gtk.StateFlags.SELECTED:
+ for layer in timeline.get_layers():
+ for clip in layer.get_clips():
+ if clip.get_name() in selection:
+ if not clip.ui.get_state_flags() & Gtk.StateFlags.SELECTED:
scenario.report_simple(GLib.quark_from_string("scenario::execution-error"),
"Clip %s should be selected (as defined in selection %s)"
" but is not" % (selection, clip.get_name()))
else:
- if c.ui.get_state_flags() & Gtk.StateFlags.SELECTED:
+ if clip.ui.get_state_flags() & Gtk.StateFlags.SELECTED:
scenario.report_simple(GLib.quark_from_string("scenario::execution-error"),
"Clip %s should NOT be selected (as defined in selection %s)"
" but it is" % (selection, clip.get_name()))
if mode == "ctrl":
- event = Event(Gdk.EventType.KEY_RELEASE, keyval=Gdk.KEY_Control_L)
+ event = create_event(Gdk.EventType.KEY_RELEASE, keyval=Gdk.KEY_Control_L)
timeline.ui.get_parent().do_key_release_event(event)
return 1
-def Parameter(name, desc, mandatory=False, possible_variables=None, types=None):
- p = GstValidate.ActionParameter()
- p.description = desc
- p.mandatory = mandatory
- p.name = name
- p.possible_variables = possible_variables
- p.types = types
+def create_action_parameter(name, desc, mandatory=False, possible_variables=None, types=None):
+ parameter = GstValidate.ActionParameter()
+ parameter.description = desc
+ parameter.mandatory = mandatory
+ parameter.name = name
+ parameter.possible_variables = possible_variables
+ parameter.types = types
- return p
+ return parameter
def init():
@@ -543,9 +543,9 @@ def init():
GstValidate.ActionTypeFlags.NONE)
GstValidate.register_action_type("select-clips", "pitivi",
select_clips_func,
- [Parameter("clip-name",
- "The name of the clip to select",
- True, None, "str")],
+ [create_action_parameter("clip-name",
+ "The name of the clip to select",
+ True, None, "str")],
"Select clips",
GstValidate.ActionTypeFlags.NONE)
diff --git a/pitivi/utils/widgets.py b/pitivi/utils/widgets.py
index bf7418c4..18ce05cc 100644
--- a/pitivi/utils/widgets.py
+++ b/pitivi/utils/widgets.py
@@ -353,14 +353,13 @@ class TimeWidget(TextWidget, DynamicWidget):
if self.default is not None:
self.setWidgetValue(self.default)
- def connectActivateEvent(self, activateCb):
- return self.connect("activate", activateCb)
+ def connectActivateEvent(self, activate_cb):
+ return self.connect("activate", activate_cb)
- def connectFocusEvents(self, focusInCb, focusOutCb):
- fIn = self.text.connect("focus-in-event", focusInCb)
- fOut = self.text.connect("focus-out-event", focusOutCb)
-
- return [fIn, fOut]
+ def connectFocusEvents(self, focus_in_cb, focus_out_cb):
+ focus_in_handler_id = self.text.connect("focus-in-event", focus_in_cb)
+ focus_out_handler_id = self.text.connect("focus-out-event", focus_out_cb)
+ return [focus_in_handler_id, focus_out_handler_id]
def setFramerate(self, framerate):
self._framerate = framerate
@@ -507,8 +506,8 @@ class ChoiceWidget(Gtk.Box, DynamicWidget):
def setChoices(self, choices):
self.choices = [choice[0] for choice in choices]
self.values = [choice[1] for choice in choices]
- m = Gtk.ListStore(str)
- self.contents.set_model(m)
+ model = Gtk.ListStore(str)
+ self.contents.set_model(model)
for choice, unused_value in choices:
self.contents.append_text(_(choice))
if len(choices) <= 1:
@@ -1243,14 +1242,14 @@ class ZoomBox(Gtk.Grid, Zoomable):
self.attach(zoom_fit_btn, 0, 0, 1, 1)
# zooming slider
- self._zoomAdjustment = Gtk.Adjustment()
- self._zoomAdjustment.props.lower = 0
- self._zoomAdjustment.props.upper = Zoomable.zoom_steps
+ self._zoom_adjustment = Gtk.Adjustment()
+ self._zoom_adjustment.props.lower = 0
+ self._zoom_adjustment.props.upper = Zoomable.zoom_steps
zoomslider = Gtk.Scale.new(
- Gtk.Orientation.HORIZONTAL, adjustment=self._zoomAdjustment)
- # Setting _zoomAdjustment's value must be done after we create the
+ Gtk.Orientation.HORIZONTAL, adjustment=self._zoom_adjustment)
+ # Setting _zoom_adjustment's value must be done after we create the
# zoom slider, otherwise the slider remains at the leftmost position.
- self._zoomAdjustment.set_value(Zoomable.getCurrentZoomLevel())
+ self._zoom_adjustment.set_value(Zoomable.getCurrentZoomLevel())
zoomslider.props.draw_value = False
zoomslider.connect("scroll-event", self._zoom_slider_scroll_cb)
zoomslider.connect("value-changed", self._zoom_slider_changed_cb)
@@ -1296,11 +1295,11 @@ class ZoomBox(Gtk.Grid, Zoomable):
Zoomable.setZoomLevel(Zoomable.getCurrentZoomLevel() + delta)
def zoomChanged(self):
- zoomLevel = self.getCurrentZoomLevel()
- if int(self._zoomAdjustment.get_value()) != zoomLevel:
+ zoom_level = self.getCurrentZoomLevel()
+ if int(self._zoom_adjustment.get_value()) != zoom_level:
self._manual_set = True
try:
- self._zoomAdjustment.set_value(zoomLevel)
+ self._zoom_adjustment.set_value(zoom_level)
finally:
self._manual_set = False
diff --git a/pitivi/viewer/move_scale_overlay.py b/pitivi/viewer/move_scale_overlay.py
index ba9a19e8..3c94aa01 100644
--- a/pitivi/viewer/move_scale_overlay.py
+++ b/pitivi/viewer/move_scale_overlay.py
@@ -22,7 +22,7 @@ import cairo
import numpy
from pitivi.undo.timeline import CommitTimelineFinalizingAction
-from pitivi.utils.misc import disconnectAllByFunc
+from pitivi.utils.misc import disconnect_all_by_func
from pitivi.utils.pipeline import PipelineError
from pitivi.viewer.overlay import Overlay
@@ -450,7 +450,7 @@ class MoveScaleOverlay(Overlay):
return size[0] / size[1]
def on_button_press(self):
- disconnectAllByFunc(self._source, self.__source_property_changed_cb)
+ disconnect_all_by_func(self._source, self.__source_property_changed_cb)
self.click_source_position = self.__get_source_position()
self.__clicked_handle = None
diff --git a/pre-commit.hook b/pre-commit.hook
index a1942d94..14c95f18 100755
--- a/pre-commit.hook
+++ b/pre-commit.hook
@@ -17,23 +17,16 @@ pitivi/autoaligner.py
pitivi/effects.py
pitivi/medialibrary.py
pitivi/project.py
-pitivi/render.py
pitivi/timeline/elements.py
pitivi/timeline/timeline.py
-pitivi/titleeditor.py
pitivi/utils/extract.py
pitivi/utils/loggable.py
-pitivi/utils/misc.py
pitivi/utils/pipeline.py
-pitivi/utils/proxy.py
pitivi/utils/ui.py
pitivi/utils/validate.py
pitivi/utils/widgets.py
tests/common.py
-tests/test_medialibrary.py
-tests/test_preset.py
tests/test_project.py
-tests/test_timeline_timeline.py
tests/test_undo.py
tests/test_undo_timeline.py
"
diff --git a/tests/common.py b/tests/common.py
index ff9bc0d2..9f39ea15 100644
--- a/tests/common.py
+++ b/tests/common.py
@@ -76,12 +76,12 @@ os.environ["PITIVI_USER_CACHE_DIR"] = tempfile.mkdtemp(suffix="pitiviTestsuite")
locale.setlocale(locale.LC_ALL, "en_US")
-def __create_settings(proxyingStrategy=ProxyingStrategy.NOTHING,
- numTranscodingJobs=4,
+def __create_settings(proxying_strategy=ProxyingStrategy.NOTHING,
+ num_transcoding_jobs=4,
**additional_settings):
settings = GlobalSettings()
- settings.proxyingStrategy = proxyingStrategy
- settings.numTranscodingJobs = numTranscodingJobs
+ settings.proxying_strategy = proxying_strategy
+ settings.num_transcoding_jobs = num_transcoding_jobs
for key, value in additional_settings.items():
setattr(settings, key, value)
return settings
@@ -158,7 +158,7 @@ class OperationTimeout(Exception):
pass
-class checked_operation_duration:
+class CheckedOperationDuration:
def __init__(self, seconds, error_message=None):
if error_message is None:
@@ -196,9 +196,9 @@ class TestCase(unittest.TestCase, Loggable):
def gccollect(self):
ret = 0
while True:
- c = gc.collect()
- ret += c
- if c == 0:
+ count = gc.collect()
+ ret += count
+ if count == 0:
break
return ret
@@ -262,8 +262,8 @@ class TestCase(unittest.TestCase, Loggable):
unused, xges_path = tempfile.mkstemp(suffix=".xges")
proj_uri = Gst.filename_to_uri(os.path.abspath(xges_path))
- with open(xges_path, "w") as f:
- f.write(xges)
+ with open(xges_path, "w") as xges_file:
+ xges_file.write(xges)
return proj_uri
diff --git a/tests/test_editorperspective.py b/tests/test_editorperspective.py
index 658fb9ee..a4562a3c 100644
--- a/tests/test_editorperspective.py
+++ b/tests/test_editorperspective.py
@@ -24,7 +24,7 @@ from gi.repository import GES
from pitivi.dialogs.missingasset import MissingAssetDialog
from pitivi.editorperspective import EditorPerspective
from pitivi.project import ProjectManager
-from pitivi.utils.misc import disconnectAllByFunc
+from pitivi.utils.misc import disconnect_all_by_func
from tests import common
@@ -91,8 +91,8 @@ class TestEditorPerspective(common.TestCase):
editorperspective._projectManagerMissingUriCb)
mainloop.quit()
- disconnectAllByFunc(app.project_manager,
- editorperspective._projectManagerMissingUriCb)
+ disconnect_all_by_func(app.project_manager,
+ editorperspective._projectManagerMissingUriCb)
app.project_manager.connect("missing-uri", __pm_missing_uri_cb)
diff --git a/tests/test_effects.py b/tests/test_effects.py
index 91c5e2eb..1288fa94 100644
--- a/tests/test_effects.py
+++ b/tests/test_effects.py
@@ -146,10 +146,10 @@ class EffectsPropertiesManagerTest(common.TestCase):
# Control the self.prop property on the timeline
prop_keyframe_button.set_active(True)
- self.assertEqual(track_element.ui_element._TimelineElement__controlledProperty, self.prop)
+ self.assertEqual(track_element.ui_element._TimelineElement__controlled_property, self.prop)
# Revert to controlling the default property
prop_keyframe_button.set_active(False)
- self.assertNotEqual(track_element.ui_element._TimelineElement__controlledProperty, self.prop)
+ self.assertNotEqual(track_element.ui_element._TimelineElement__controlled_property, self.prop)
def test_prop_reset(self):
"""Checks the reset button resets the property."""
diff --git a/tests/test_log.py b/tests/test_log.py
index 58233baf..90bde593 100644
--- a/tests/test_log.py
+++ b/tests/test_log.py
@@ -24,7 +24,7 @@ __version__ = "$Rev: 7162 $"
class LogTester(log.Loggable):
- logCategory = 'testlog'
+ log_category = 'testlog'
class LogFunctionTester(log.Loggable):
@@ -64,15 +64,15 @@ class TestLog(TestWithHandler):
# just test for parsing semi- or non-valid FLU_DEBUG variables
def testSetDebug(self):
- log.setDebug(":5")
- log.setDebug("*")
- log.setDebug("5")
+ log.set_debug(":5")
+ log.set_debug("*")
+ log.set_debug("5")
# test for adding a log handler
def testLimitInvisible(self):
- log.setDebug("testlog:%d" % log.INFO)
- log.addLimitedLogHandler(self.handler)
+ log.set_debug("testlog:%d" % log.INFO)
+ log.add_limited_log_handler(self.handler)
# log 2 we shouldn't get
self.tester.log("not visible")
@@ -86,8 +86,8 @@ class TestLog(TestWithHandler):
self.assertFalse(self.message)
def testLimitedVisible(self):
- log.setDebug("testlog:%d" % log.INFO)
- log.addLimitedLogHandler(self.handler)
+ log.set_debug("testlog:%d" % log.INFO)
+ log.add_limited_log_handler(self.handler)
# log 3 we should get
self.tester.info("visible")
@@ -101,8 +101,8 @@ class TestLog(TestWithHandler):
self.assertEqual(self.message, 'also visible')
def testFormatStrings(self):
- log.setDebug("testlog:%d" % log.INFO)
- log.addLimitedLogHandler(self.handler)
+ log.set_debug("testlog:%d" % log.INFO)
+ log.add_limited_log_handler(self.handler)
self.tester.info("%d %s", 42, 'the answer')
self.assertEqual(self.category, 'testlog')
@@ -110,8 +110,8 @@ class TestLog(TestWithHandler):
self.assertEqual(self.message, '42 the answer')
def testLimitedError(self):
- log.setDebug("testlog:%d" % log.ERROR)
- log.addLimitedLogHandler(self.handler)
+ log.set_debug("testlog:%d" % log.ERROR)
+ log.add_limited_log_handler(self.handler)
self.tester.error("error")
self.assertEqual(self.category, 'testlog')
@@ -119,11 +119,11 @@ class TestLog(TestWithHandler):
self.assertEqual(self.message, 'error')
def testLogHandlerLimitedLevels(self):
- log.setDebug("testlog:%d" % log.INFO)
- log.addLimitedLogHandler(self.handler)
+ log.set_debug("testlog:%d" % log.INFO)
+ log.add_limited_log_handler(self.handler)
# now try debug and log again too
- log.setDebug("testlog:%d" % log.LOG)
+ log.set_debug("testlog:%d" % log.LOG)
self.tester.debug("debug")
self.assertEqual(self.category, 'testlog')
@@ -138,8 +138,8 @@ class TestLog(TestWithHandler):
# test that we get all log messages
def testLogHandler(self):
- log.setDebug("testlog:%d" % log.INFO)
- log.addLogHandler(self.handler)
+ log.set_debug("testlog:%d" % log.INFO)
+ log.add_log_handler(self.handler)
self.tester.log("visible")
self.assertEqual(self.message, 'visible')
@@ -157,14 +157,14 @@ class TestOwnLogHandler(TestWithHandler):
# test if our own log handler correctly mangles the message
def testOwnLogHandlerLimited(self):
- log.setDebug("testlog:%d" % log.INFO)
- log.addLogHandler(self.handler)
+ log.set_debug("testlog:%d" % log.INFO)
+ log.add_log_handler(self.handler)
self.tester.log("visible")
self.assertEqual(self.message, 'override visible')
def testLogHandlerAssertion(self):
- self.assertRaises(TypeError, log.addLimitedLogHandler, None)
+ self.assertRaises(TypeError, log.add_limited_log_handler, None)
class TestGetExceptionMessage(unittest.TestCase):
@@ -193,7 +193,7 @@ class TestGetExceptionMessage(unittest.TestCase):
self.verifyException(e)
def verifyException(self, e):
- message = log.getExceptionMessage(e)
+ message = log.get_exception_message(e)
self.assertTrue("func1()" in message, message)
self.assertTrue("test_log.py" in message, message)
self.assertTrue("TypeError" in message, message)
@@ -202,32 +202,32 @@ class TestGetExceptionMessage(unittest.TestCase):
class TestLogSettings(unittest.TestCase):
def testSet(self):
- old = log.getLogSettings()
- log.setDebug('*:5')
- self.assertNotEqual(old, log.getLogSettings())
+ old = log.get_log_settings()
+ log.set_debug('*:5')
+ self.assertNotEqual(old, log.get_log_settings())
- log.setLogSettings(old)
- self.assertEqual(old, log.getLogSettings())
+ log.set_log_settings(old)
+ self.assertEqual(old, log.get_log_settings())
class TestLogNames(unittest.TestCase):
def testGetLevelNames(self):
self.assertEqual(['ERROR', 'WARN', 'FIXME', 'INFO', 'DEBUG', 'LOG'],
- log.getLevelNames())
+ log.get_level_names())
def testGetLevelCode(self):
- self.assertEqual(1, log.getLevelInt('ERROR'))
- self.assertEqual(2, log.getLevelInt('WARN'))
- self.assertEqual(3, log.getLevelInt('FIXME'))
- self.assertEqual(4, log.getLevelInt('INFO'))
- self.assertEqual(5, log.getLevelInt('DEBUG'))
- self.assertEqual(6, log.getLevelInt('LOG'))
+ self.assertEqual(1, log.get_level_int('ERROR'))
+ self.assertEqual(2, log.get_level_int('WARN'))
+ self.assertEqual(3, log.get_level_int('FIXME'))
+ self.assertEqual(4, log.get_level_int('INFO'))
+ self.assertEqual(5, log.get_level_int('DEBUG'))
+ self.assertEqual(6, log.get_level_int('LOG'))
def testGetLevelName(self):
- self.assertEqual('ERROR', log.getLevelName(1))
- self.assertEqual('WARN', log.getLevelName(2))
- self.assertEqual('FIXME', log.getLevelName(3))
- self.assertEqual('INFO', log.getLevelName(4))
- self.assertEqual('DEBUG', log.getLevelName(5))
- self.assertEqual('LOG', log.getLevelName(6))
+ self.assertEqual('ERROR', log.get_level_name(1))
+ self.assertEqual('WARN', log.get_level_name(2))
+ self.assertEqual('FIXME', log.get_level_name(3))
+ self.assertEqual('INFO', log.get_level_name(4))
+ self.assertEqual('DEBUG', log.get_level_name(5))
+ self.assertEqual('LOG', log.get_level_name(6))
diff --git a/tests/test_mediafilespreviewer.py b/tests/test_mediafilespreviewer.py
index b7be02ad..f6a55711 100644
--- a/tests/test_mediafilespreviewer.py
+++ b/tests/test_mediafilespreviewer.py
@@ -33,7 +33,7 @@ class PreviewWidgetTest(common.TestCase):
def test_select_missing_asset(self):
"""Exercise the MissingAssetDialog when loading a project."""
- app = common.create_pitivi(proxyingStrategy=ProxyingStrategy.NOTHING,
+ app = common.create_pitivi(proxying_strategy=ProxyingStrategy.NOTHING,
FCpreviewWidth=640,
FCpreviewHeight=480)
@@ -82,7 +82,7 @@ class PreviewWidgetTest(common.TestCase):
try:
# Our mainloop timeout mechanism cannot be used,
# because the mainloop gets blocked.
- with common.checked_operation_duration(seconds=2):
+ with common.CheckedOperationDuration(seconds=2):
project_manager.load_project(proj_uri)
mainloop.run()
self.assertEqual(preview_loaded_for_uri, asset_uri)
diff --git a/tests/test_medialibrary.py b/tests/test_medialibrary.py
index bfcf8673..e413e74f 100644
--- a/tests/test_medialibrary.py
+++ b/tests/test_medialibrary.py
@@ -94,9 +94,9 @@ class BaseTestMediaLibrary(common.TestCase):
def check_import(self, samples, proxying_strategy=ProxyingStrategy.ALL,
check_no_transcoding=False):
- self._customSetUp(proxyingStrategy=proxying_strategy,
- numTranscodingJobs=4,
- lastClipView=medialibrary.SHOW_TREEVIEW)
+ self._customSetUp(proxying_strategy=proxying_strategy,
+ num_transcoding_jobs=4,
+ last_clip_view=medialibrary.SHOW_TREEVIEW)
self.check_no_transcoding = check_no_transcoding
self.medialibrary._progressbar.connect(
diff --git a/tests/test_preset.py b/tests/test_preset.py
index 40e1b464..32382272 100644
--- a/tests/test_preset.py
+++ b/tests/test_preset.py
@@ -29,25 +29,25 @@ from pitivi.utils.system import System
from tests import common
-def clearPresetManagerPaths(preset_manager):
+def clear_preset_manager_paths(preset_manager):
try:
shutil.rmtree(preset_manager.user_path)
except FileNotFoundError:
pass
-def countJsonFilesIn(dir_path):
+def count_json_files_in(dir_path):
return len([filename
for filename in os.listdir(dir_path)
if filename.endswith(".json")])
-def countDefaultPresets(preset_manager):
- return countJsonFilesIn(preset_manager.default_path)
+def count_default_presets(preset_manager):
+ return count_json_files_in(preset_manager.default_path)
-def countUserPresets(preset_manager):
- return countJsonFilesIn(preset_manager.user_path)
+def count_user_presets(preset_manager):
+ return count_json_files_in(preset_manager.user_path)
class TestPresetBasics(common.TestCase):
@@ -57,7 +57,7 @@ class TestPresetBasics(common.TestCase):
self.manager._serializePreset = lambda preset: dict(preset.items())
def tearDown(self):
- clearPresetManagerPaths(self.manager)
+ clear_preset_manager_paths(self.manager)
def testAddPreset(self):
self.manager.createPreset('preseT onE', {'name1': '1A'})
@@ -116,7 +116,7 @@ class TestAudioPresetsIO(common.TestCase):
self.manager.user_path = tempfile.mkdtemp()
def tearDown(self):
- clearPresetManagerPaths(self.manager)
+ clear_preset_manager_paths(self.manager)
def createOtherManager(self):
other_manager = AudioPresetManager(System())
@@ -128,18 +128,18 @@ class TestAudioPresetsIO(common.TestCase):
{"channels": 6000,
"sample-rate": 44100})
self.manager.saveAll()
- self.assertEqual(1, countUserPresets(self.manager))
+ self.assertEqual(1, count_user_presets(self.manager))
self.manager.createPreset("Nappa",
{"channels": 4000,
"sample-rate": 44100})
self.manager.saveAll()
- self.assertEqual(2, countUserPresets(self.manager))
+ self.assertEqual(2, count_user_presets(self.manager))
other_manager = self.createOtherManager()
other_manager.loadAll()
- total_presets = countDefaultPresets(
- self.manager) + countUserPresets(self.manager)
+ total_presets = count_default_presets(
+ self.manager) + count_user_presets(self.manager)
self.assertEqual(total_presets, len(other_manager.presets))
def testNonAsciiFilenamesSaveAndLoad(self):
@@ -153,7 +153,7 @@ class TestAudioPresetsIO(common.TestCase):
other_manager = self.createOtherManager()
other_manager.loadAll()
- self.assertEqual(1 + countDefaultPresets(
+ self.assertEqual(1 + count_default_presets(
other_manager), len(other_manager.presets))
snaaaake = other_manager.presets[non_ascii_preset_name]
self.assertEqual(snake, snaaaake)
@@ -170,7 +170,7 @@ class TestAudioPresetsIO(common.TestCase):
other_manager = self.createOtherManager()
other_manager.loadAll()
- self.assertEqual(1 + countDefaultPresets(
+ self.assertEqual(1 + count_default_presets(
other_manager), len(other_manager.presets))
other_values = other_manager.presets[preset_name]
self.assertEqual(values, other_values)
diff --git a/tests/test_project.py b/tests/test_project.py
index 202ecb71..2807dde6 100644
--- a/tests/test_project.py
+++ b/tests/test_project.py
@@ -85,8 +85,8 @@ class TestProjectManager(common.TestCase):
# failed
name, args = self.signals[1]
self.assertEqual("new-project-failed", name)
- signalUri, unused_message = args
- self.assertEqual(project_uri, signalUri, self.signals)
+ signal_uri, unused_message = args
+ self.assertEqual(project_uri, signal_uri, self.signals)
def test_new_blank_project_signals(self):
self.manager.new_blank_project()
@@ -104,12 +104,12 @@ class TestProjectManager(common.TestCase):
self.setupApp(app=common.create_pitivi_mock())
mainloop = common.create_main_loop()
- def missingUriCb(self, project, error, clip_asset, result):
+ def missing_uri_cb(self, project, error, clip_asset, result):
result[0] = True
mainloop.quit()
result = [False]
- self.manager.connect("missing-uri", missingUriCb, result)
+ self.manager.connect("missing-uri", missing_uri_cb, result)
with common.cloned_sample():
asset_uri = common.get_sample_uri("missing.png")
@@ -142,12 +142,12 @@ class TestProjectManager(common.TestCase):
self.assertFalse(self.signals)
def testCloseRunningProjectRefuseFromSignal(self):
- def closing(manager, project):
+ def closing_cb(manager, project):
return False
self.manager.current_project = mock.Mock()
self.manager.current_project.uri = "file:///ciao"
- self.manager.connect("closing-project", closing)
+ self.manager.connect("closing-project", closing_cb)
self.assertFalse(self.manager.closeRunningProject())
self.assertEqual(1, len(self.signals))
@@ -324,7 +324,7 @@ class TestProjectLoading(common.TestCase):
"""Loads a project with missing proxies."""
uris = [common.get_sample_uri("1sec_simpsons_trailer.mp4")]
proxy_uri = uris[0] + ".232417.proxy.mkv"
- PROJECT_STR = r"""<ges version='0.3'>
+ xges = r"""<ges version='0.3'>
<project properties='properties;' metadatas='metadatas, name=(string)"New\ Project",
author=(string)Unknown, render-scale=(double)100;'>
<encoding-profiles>
</encoding-profiles>
@@ -350,7 +350,7 @@ class TestProjectLoading(common.TestCase):
</timeline>
</project>
</ges>""" % {"uri": uris[0], "proxy_uri": proxy_uri}
- app = common.create_pitivi(proxyingStrategy=ProxyingStrategy.ALL)
+ app = common.create_pitivi(proxying_strategy=ProxyingStrategy.ALL)
app.recent_manager.remove_item = mock.Mock(return_value=True)
proxy_manager = app.proxy_manager
project_manager = app.project_manager
@@ -358,7 +358,7 @@ class TestProjectLoading(common.TestCase):
mainloop = common.create_main_loop()
- proj_uri = self.create_project_file_from_xges(PROJECT_STR)
+ proj_uri = self.create_project_file_from_xges(xges)
def closing_project_cb(*args, **kwargs):
# Do not ask whether to save project on closing.
@@ -447,7 +447,7 @@ class TestProjectLoading(common.TestCase):
def test_loading_project_with_moved_asset(self):
"""Loads a project with moved asset."""
- app = common.create_pitivi(proxyingStrategy=ProxyingStrategy.NOTHING)
+ app = common.create_pitivi(proxying_strategy=ProxyingStrategy.NOTHING)
proj_uri = self.create_project_file_from_xges("""<ges version='0.3'>
<project properties='properties;' metadatas='metadatas;'>
@@ -487,7 +487,7 @@ class TestProjectLoading(common.TestCase):
if len(created_proxies) == 2:
mainloop.quit()
- app = common.create_pitivi(proxyingStrategy=ProxyingStrategy.ALL)
+ app = common.create_pitivi(proxying_strategy=ProxyingStrategy.ALL)
app.proxy_manager.connect("proxy-ready", proxy_ready_cb)
proj_uri = self.create_project_file_from_xges(r"""<ges version='0.3'>
@@ -639,8 +639,8 @@ class TestProjectSettings(common.TestCase):
self.assertEqual(project.scaled_proxy_width, 123)
self.assertEqual(project.scaled_proxy_height, 456)
- with tempfile.NamedTemporaryFile() as f:
- uri = Gst.filename_to_uri(f.name)
+ with tempfile.NamedTemporaryFile() as temp_file:
+ uri = Gst.filename_to_uri(temp_file.name)
manager.saveProject(uri=uri, backup=False)
app2 = common.create_pitivi_mock(default_scaled_proxy_width=12,
default_scaled_proxy_height=45)
@@ -655,7 +655,7 @@ class TestProjectSettings(common.TestCase):
self.assertEqual(project.scaled_proxy_width, 123)
self.assertEqual(project.scaled_proxy_height, 456)
- with tempfile.NamedTemporaryFile() as f:
+ with tempfile.NamedTemporaryFile() as temp_file:
manager.saveProject(uri=uri, backup=False)
app2 = common.create_pitivi_mock(default_scaled_proxy_width=1,
default_scaled_proxy_height=4)
diff --git a/tests/test_timeline_timeline.py b/tests/test_timeline_timeline.py
index 01329483..74a117b6 100644
--- a/tests/test_timeline_timeline.py
+++ b/tests/test_timeline_timeline.py
@@ -108,9 +108,8 @@ class TestLayers(BaseTestTimeline):
preferred_ges_layer = ges_layers[preferred]
# The heights of the layers.
h = [ges_layer.ui.get_allocation().height for ges_layer in ges_layers]
- s = SEPARATOR_HEIGHT
- def assertLayerAt(ges_layer, y):
+ def assert_layer_at(ges_layer, y):
result = timeline.get_layer_at(
int(y),
prefer_ges_layer=preferred_ges_layer,
@@ -121,30 +120,30 @@ class TestLayers(BaseTestTimeline):
"Expected %d, got %d at %d" % (ges_layers.index(ges_layer), ges_layers.index(result[0]), y))
# y on the top layer.
- assertLayerAt(ges_layers[expectations[0]], 0)
- assertLayerAt(ges_layers[expectations[1]], h[0] / 2 - 1)
- assertLayerAt(ges_layers[expectations[2]], h[0] / 2)
- assertLayerAt(ges_layers[expectations[3]], h[0] - 1)
+ assert_layer_at(ges_layers[expectations[0]], 0)
+ assert_layer_at(ges_layers[expectations[1]], h[0] / 2 - 1)
+ assert_layer_at(ges_layers[expectations[2]], h[0] / 2)
+ assert_layer_at(ges_layers[expectations[3]], h[0] - 1)
# y on the separator.
- assertLayerAt(ges_layers[expectations[4]], h[0])
- assertLayerAt(ges_layers[expectations[5]], h[0] + s - 1)
+ assert_layer_at(ges_layers[expectations[4]], h[0])
+ assert_layer_at(ges_layers[expectations[5]], h[0] + SEPARATOR_HEIGHT - 1)
# y on the middle layer.
- assertLayerAt(ges_layers[expectations[6]], h[0] + s)
- assertLayerAt(ges_layers[expectations[7]], h[0] + s + h[1] / 2 - 1)
- assertLayerAt(ges_layers[expectations[8]], h[0] + s + h[1] / 2)
- assertLayerAt(ges_layers[expectations[9]], h[0] + s + h[1] - 1)
+ assert_layer_at(ges_layers[expectations[6]], h[0] + SEPARATOR_HEIGHT)
+ assert_layer_at(ges_layers[expectations[7]], h[0] + SEPARATOR_HEIGHT + h[1] / 2 - 1)
+ assert_layer_at(ges_layers[expectations[8]], h[0] + SEPARATOR_HEIGHT + h[1] / 2)
+ assert_layer_at(ges_layers[expectations[9]], h[0] + SEPARATOR_HEIGHT + h[1] - 1)
# y on the separator.
- assertLayerAt(ges_layers[expectations[10]], h[0] + s + h[1])
- assertLayerAt(ges_layers[expectations[11]], h[0] + s + h[1] + s - 1)
+ assert_layer_at(ges_layers[expectations[10]], h[0] + SEPARATOR_HEIGHT + h[1])
+ assert_layer_at(ges_layers[expectations[11]], h[0] + SEPARATOR_HEIGHT + h[1] + SEPARATOR_HEIGHT - 1)
# y on the bottom layer.
- assertLayerAt(ges_layers[expectations[12]], h[0] + s + h[1] + s)
- assertLayerAt(ges_layers[expectations[13]], h[0] + s + h[1] + s + h[2] / 2 - 1)
- assertLayerAt(ges_layers[expectations[14]], h[0] + s + h[1] + s + h[2] / 2)
- assertLayerAt(ges_layers[expectations[15]], h[0] + s + h[1] + s + h[2] - 1)
+ assert_layer_at(ges_layers[expectations[12]], h[0] + SEPARATOR_HEIGHT + h[1] + SEPARATOR_HEIGHT)
+ assert_layer_at(ges_layers[expectations[13]], h[0] + SEPARATOR_HEIGHT + h[1] + SEPARATOR_HEIGHT +
h[2] / 2 - 1)
+ assert_layer_at(ges_layers[expectations[14]], h[0] + SEPARATOR_HEIGHT + h[1] + SEPARATOR_HEIGHT +
h[2] / 2)
+ assert_layer_at(ges_layers[expectations[15]], h[0] + SEPARATOR_HEIGHT + h[1] + SEPARATOR_HEIGHT +
h[2] - 1)
def testSetSeparatorsPrelight(self):
timeline_container = common.create_timeline_container()
@@ -446,20 +445,20 @@ class TestGrouping(BaseTestTimeline):
self.assertEqual(ges_clip0.props.start, ges_clip1.props.start)
self.assertEqual(ges_clip0.props.duration, ges_clip1.props.duration)
- bTrackElem0, = ges_clip0.get_children(recursive=False)
- bTrackElem1, = ges_clip1.get_children(recursive=False)
+ track_elem_0, = ges_clip0.get_children(recursive=False)
+ track_elem_1, = ges_clip1.get_children(recursive=False)
- if bTrackElem0.get_track_type() == GES.TrackType.AUDIO:
+ if track_elem_0.get_track_type() == GES.TrackType.AUDIO:
aclip = ges_clip0.ui
- atrackelem = bTrackElem0.ui
+ atrackelem = track_elem_0.ui
vclip = ges_clip1.ui
- vtrackelem = bTrackElem1.ui
+ vtrackelem = track_elem_1.ui
else:
aclip = ges_clip1.ui
- atrackelem = bTrackElem1.ui
+ atrackelem = track_elem_1.ui
vclip = ges_clip0.ui
- vtrackelem = bTrackElem0.ui
+ vtrackelem = track_elem_0.ui
self.assertEqual(aclip.audio_widget, atrackelem)
self.assertEqual(vclip.video_widget, vtrackelem)
@@ -484,7 +483,7 @@ class TestGrouping(BaseTestTimeline):
event.get_button.return_value = True, 1
get_event_widget.return_value = clip1.ui
timeline._button_press_event_cb(None, event)
- self.assertIsNotNone(timeline.draggingElement)
+ self.assertIsNotNone(timeline.dragging_element)
# Move it to the right, on the separator below.
event = mock.Mock()
@@ -593,15 +592,15 @@ class TestEditing(BaseTestTimeline):
event = mock.Mock()
event.x = 100
event.get_button.return_value = True, 1
- get_event_widget.return_value = clip.ui.rightHandle
+ get_event_widget.return_value = clip.ui.right_handle
timeline._button_press_event_cb(None, event)
- self.assertIsNotNone(timeline.draggingElement)
+ self.assertIsNotNone(timeline.dragging_element)
# Drag it to the left, on the separator below.
event = mock.Mock()
event.x = 99
event.get_state.return_value = Gdk.ModifierType.BUTTON1_MASK
- with mock.patch.object(clip.ui.rightHandle, "translate_coordinates") as translate_coordinates:
+ with mock.patch.object(clip.ui.right_handle, "translate_coordinates") as translate_coordinates:
translate_coordinates.return_value = (0, 0)
with mock.patch.object(timeline, "get_layer_at") as get_layer_at:
get_layer_at.return_value = layer, timeline._separators[1]
diff --git a/tests/test_undo.py b/tests/test_undo.py
index 5e4311b2..1b879dc2 100644
--- a/tests/test_undo.py
+++ b/tests/test_undo.py
@@ -91,12 +91,12 @@ class TestUndoableActionLog(common.TestCase):
def _undoActionLogSignalCb(self, log, *args):
args = list(args)
- signalName = args.pop(-1)
- self.signals.append((signalName, args))
+ signal_name = args.pop(-1)
+ self.signals.append((signal_name, args))
def _connectToUndoableActionLog(self, log):
- for signalName in ("begin", "push", "rollback", "commit", "move"):
- log.connect(signalName, self._undoActionLogSignalCb, signalName)
+ for signal_name in ("begin", "push", "rollback", "commit", "move"):
+ log.connect(signal_name, self._undoActionLogSignalCb, signal_name)
def _disconnectFromUndoableActionLog(self, log):
self.log.disconnect_by_func(self._undoActionLogSignalCb)
@@ -280,16 +280,16 @@ class TestUndoableActionLog(common.TestCase):
action1.expand.return_value = False
self.log.push(action1)
self.assertEqual(len(self.signals), 2)
- name, (stack, signalAction) = self.signals[1]
+ name, (stack, signal_action) = self.signals[1]
self.assertEqual(name, "push")
- self.assertTrue(action1 is signalAction)
+ self.assertTrue(action1 is signal_action)
action2 = mock.Mock(spec=UndoableAction)
self.log.push(action2)
self.assertEqual(len(self.signals), 3)
- name, (stack, signalAction) = self.signals[2]
+ name, (stack, signal_action) = self.signals[2]
self.assertEqual(name, "push")
- self.assertTrue(action2 is signalAction)
+ self.assertTrue(action2 is signal_action)
# commit
self.assertEqual(len(self.log.undo_stacks), 0)
diff --git a/tests/test_undo_timeline.py b/tests/test_undo_timeline.py
index 5bb704e5..3a2e9b0e 100644
--- a/tests/test_undo_timeline.py
+++ b/tests/test_undo_timeline.py
@@ -74,9 +74,9 @@ class BaseTestUndoTimeline(common.TestCase):
# the timeline creates transitions automatically.
mainloop = common.create_main_loop()
- def projectLoadedCb(unused_project, unused_timeline):
+ def loaded_cb(project, timeline):
mainloop.quit()
- self.app.project_manager.current_project.connect("loaded", projectLoadedCb)
+ self.app.project_manager.current_project.connect("loaded", loaded_cb)
mainloop.run()
self.assertTrue(self.timeline.props.auto_transition)
@@ -1166,18 +1166,18 @@ class TestDragDropUndo(BaseTestUndoTimeline):
timeline_ui._drag_motion_cb(None, None, 0, 0, 0)
self.assertTrue(timeline_ui.drag_get_data.called)
- self.assertFalse(timeline_ui.dropDataReady)
+ self.assertFalse(timeline_ui.drop_data_ready)
selection_data = mock.Mock()
selection_data.get_data_type = mock.Mock(return_value=target)
selection_data.get_uris.return_value = [asset.props.id]
- self.assertIsNone(timeline_ui.dropData)
- self.assertFalse(timeline_ui.dropDataReady)
+ self.assertIsNone(timeline_ui.drop_data)
+ self.assertFalse(timeline_ui.drop_data_ready)
timeline_ui._drag_data_received_cb(None, None, 0, 0, selection_data, None, 0)
- self.assertEqual(timeline_ui.dropData, [asset.props.id])
- self.assertTrue(timeline_ui.dropDataReady)
+ self.assertEqual(timeline_ui.drop_data, [asset.props.id])
+ self.assertTrue(timeline_ui.drop_data_ready)
timeline_ui.drag_get_data.reset_mock()
- self.assertIsNone(timeline_ui.draggingElement)
+ self.assertIsNone(timeline_ui.dragging_element)
self.assertFalse(timeline_ui.dropping_clips)
def translate_coordinates(widget, x, y):
@@ -1185,11 +1185,11 @@ class TestDragDropUndo(BaseTestUndoTimeline):
timeline_ui.translate_coordinates = translate_coordinates
timeline_ui._drag_motion_cb(timeline_ui, None, 0, LAYER_HEIGHT * 2, 0)
self.assertFalse(timeline_ui.drag_get_data.called)
- self.assertIsNotNone(timeline_ui.draggingElement)
+ self.assertIsNotNone(timeline_ui.dragging_element)
self.assertTrue(timeline_ui.dropping_clips)
timeline_ui._drag_leave_cb(None, None, None)
- self.assertIsNone(timeline_ui.draggingElement)
+ self.assertIsNone(timeline_ui.dragging_element)
self.assertFalse(timeline_ui.dropping_clips)
timeline_ui._drag_drop_cb(None, None, 0, 0, 0)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]