Skip to content

Commit d4cb213

Browse files
authored
Merge pull request #3536 from OpenShot/codacy-clean-up
Code Clean-up flagged by Codacy
2 parents 0d3da87 + 277b73f commit d4cb213

30 files changed

+2731
-2850
lines changed

installer/build-mac-dmg.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ echo "Verifying App Signing"
5959
spctl -a -vv "build/$OS_APP_NAME"
6060

6161
echo "Building Custom DMG"
62-
appdmg installer/dmg-template.json build/$OS_DMG_NAME
62+
appdmg "installer/dmg-template.json" "build/$OS_DMG_NAME"
6363

6464
echo "Code Sign DMG"
6565
codesign -s "OpenShot Studios, LLC" "build/$OS_DMG_NAME" --force

installer/launch-mac.sh

+3-3
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ export QT_PLUGIN_PATH="$CURR_DIR"
1111
export QT_DEBUG_PLUGINS="1"
1212
export DYLD_PRINT_LIBRARIES="1"
1313

14-
echo $CURR_DIR
15-
echo $DYLD_LIBRARY_PATH
16-
echo $QT_PLUGIN_PATH
14+
echo "$CURR_DIR"
15+
echo "$DYLD_LIBRARY_PATH"
16+
echo "$QT_PLUGIN_PATH"
1717

1818
# Launch application
1919
exec "$CURR_DIR/openshot-qt"

installer/mangle-hw-libs.sh

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
usage()
55
{
6-
progname=$(basename $0)
6+
progname="$(basename "$0")"
77
cat << __EOM__
88
${progname} - Replace system paths encoded into shared libraries
99
@@ -15,7 +15,7 @@ __EOM__
1515
}
1616

1717
# Bail with usage information, if the directory path is unset
18-
[ -z $1 ] && usage && exit -1
18+
[ -z "$1" ] && usage && exit -1
1919

2020
# We take one argument, the path in which to look for target libraries
2121
if [ -d "$1" ]; then

src/classes/app.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ def __init__(self, *args, mode=None):
102102
log.info("qt5 version: %s" % QT_VERSION_STR)
103103
log.info("pyqt5 version: %s" % PYQT_VERSION_STR)
104104
except Exception:
105-
pass
105+
log.warning("Error displaying dependency/system details", exc_info=1)
106106

107107
# Setup application
108108
self.setApplicationName('openshot')
@@ -271,12 +271,12 @@ def run(self):
271271
@atexit.register
272272
def onLogTheEnd():
273273
""" Log when the primary Qt event loop ends """
274-
275274
try:
276275
from classes.logger import log
277276
import time
278277
log.info('OpenShot\'s session ended'.center(48))
279278
log.info(time.asctime().center(48))
280279
log.info("================================================")
281280
except Exception:
282-
pass
281+
from classes.logger import log
282+
log.warning('Failed to write session ended log')

src/classes/importers/edl.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535

3636
from classes import info
3737
from classes.app import get_app
38+
from classes.logger import log
3839
from classes.image_types import is_image
3940
from classes.query import Clip, Track, File
4041
from classes.time_parts import timecodeToSeconds
@@ -95,8 +96,7 @@ def create_clip(context, track):
9596
# Save file
9697
file.save()
9798
except:
98-
# Ignore errors for now
99-
pass
99+
log.warning('Error building File object for %s' % clip_path, exc_info=1)
100100

101101
if (file.data["media_type"] == "video" or file.data["media_type"] == "image"):
102102
# Determine thumb path

src/classes/importers/final_cut_pro.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535

3636
from classes import info
3737
from classes.app import get_app
38+
from classes.logger import log
3839
from classes.image_types import is_image
3940
from classes.query import Clip, Track, File
4041
from windows.views.find_file import find_missing_file
@@ -141,8 +142,7 @@ def import_xml():
141142
# Save file
142143
file.save()
143144
except Exception:
144-
# Ignore errors for now
145-
pass
145+
log.warning('Error building File object for %s' % clip_path, exc_info=1)
146146

147147
if (file.data["media_type"] == "video" or file.data["media_type"] == "image"):
148148
# Determine thumb path

src/classes/language.py

+8-9
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,27 @@
1-
"""
1+
"""
22
@file
33
@brief This file loads the current language based on the computer's locale settings
44
@author Noah Figg <[email protected]>
55
@author Jonathan Thomas <[email protected]>
6-
6+
77
@section LICENSE
8-
8+
99
Copyright (c) 2008-2018 OpenShot Studios, LLC
1010
(http://www.openshotstudios.com). This file is part of
1111
OpenShot Video Editor (http://www.openshot.org), an open-source project
1212
dedicated to delivering high quality video editing and animation solutions
1313
to the world.
14-
14+
1515
OpenShot Video Editor is free software: you can redistribute it and/or modify
1616
it under the terms of the GNU General Public License as published by
1717
the Free Software Foundation, either version 3 of the License, or
1818
(at your option) any later version.
19-
19+
2020
OpenShot Video Editor is distributed in the hope that it will be useful,
2121
but WITHOUT ANY WARRANTY; without even the implied warranty of
2222
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2323
GNU General Public License for more details.
24-
24+
2525
You should have received a copy of the GNU General Public License
2626
along with OpenShot Library. If not, see <http://www.gnu.org/licenses/>.
2727
"""
@@ -123,7 +123,7 @@ def init_language():
123123
# returns True when a match was found.
124124
# pattern - a string expected to have one pipe to be filled by locale strings
125125
# path - base path for file (pattern may contain more path)
126-
#
126+
#
127127
def find_language_match(prefix, path, translator, locale_name):
128128
""" Match all combinations of locale, language, and country """
129129

@@ -145,8 +145,7 @@ def get_all_languages():
145145
country_name = QLocale(locale_name).nativeCountryName().title()
146146
all_languages.append((locale_name, native_lang_name, country_name))
147147
except:
148-
# Ignore failed parsing of language
149-
pass
148+
log.warning('Failed to parse language for %s' % locale_name)
150149

151150
# Return list
152151
return all_languages

src/classes/thumbnail.py

+5-2
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,12 @@ def GenerateThumbnail(file_path, thumb_path, thumbnail_frame, width, height, mas
6060
rotate = 0.0
6161
try:
6262
if reader.info.metadata.count("rotate"):
63-
rotate = float(reader.info.metadata.find("rotate").value()[1])
63+
rotate_data = reader.info.metadata.find("rotate").value()[1]
64+
rotate = float(rotate_data)
65+
except ValueError as ex:
66+
log.warning("Could not parse rotation value {}: {}".format(rotate_data, ex))
6467
except Exception:
65-
pass
68+
log.warning("Error reading rotation metadata from {}".format(file_path), exc_info=1)
6669

6770
# Create thumbnail folder (if needed)
6871
parent_path = os.path.dirname(thumb_path)

src/timeline/app.js

+47-42
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/**
22
* @file
3-
* @brief AngularJS App (initializes angular application)
3+
* @brief AngularJS App (initializes angular application)
44
* @author Jonathan Thomas <[email protected]>
55
* @author Cody Parker <[email protected]>
66
*
@@ -28,50 +28,55 @@
2828

2929

3030
// Initialize Angular application
31-
var App = angular.module('openshot-timeline', ['ui.bootstrap','ngAnimate']);
31+
/*global App, timeline, angular*/
32+
var App = angular.module("openshot-timeline", ["ui.bootstrap", "ngAnimate"]);
3233

3334

3435
// Wait for document ready event
35-
$( document ).ready(function() {
36-
37-
/// Capture window resize event, and resize scrollable divs (i.e. track container)
38-
$( window ).resize(function() {
39-
40-
// Determine Y offset for track container div
41-
var track_offset = $("#track_controls").offset().top;
36+
$(document).ready(function () {
4237

43-
// Set the height of the scrollable divs. This resizes the tracks to fit the remaining
44-
// height of the web page. As the user changes the size of the web page, this will continue
45-
// to fire, and resize the child divs to fit.
46-
var new_track_height = $(this).height() - track_offset;
38+
var body_object = $("body");
4739

48-
$("#track_controls").height(new_track_height);
49-
$("#scrolling_tracks").height(new_track_height);
50-
$('body').scope().playhead_height = $("#track-container").height();
51-
$(".playhead-line").height($('body').scope().playhead_height);
52-
});
53-
54-
// Check for Qt Integration
55-
if(typeof timeline != 'undefined') {
56-
timeline.qt_log("Qt Found!");
57-
$('body').scope().EnableQt();
58-
timeline.page_ready();
59-
$('body').scope().SetThumbAddress(timeline.get_thumb_address());
60-
} else {
61-
console.log("Qt NOT Found!");
62-
}
63-
64-
// Manually trigger the window resize code (to verify it runs at least once)
65-
$(window).trigger('resize');
66-
67-
// Bind to keydown event (to detect SHIFT)
68-
$( "body" ).keydown(function(event) {
69-
if (event.which==16)
70-
$('body').scope().shift_pressed = true;
71-
});
72-
$( "body" ).keyup(function(event) {
73-
if ($('body').scope().shift_pressed)
74-
$('body').scope().shift_pressed = false;
75-
});
76-
});
40+
/// Capture window resize event, and resize scrollable divs (i.e. track container)
41+
$(window).resize(function () {
42+
43+
// Determine Y offset for track container div
44+
var track_controls = $("#track_controls");
45+
var track_offset = track_controls.offset().top;
46+
47+
// Set the height of the scrollable divs. This resizes the tracks to fit the remaining
48+
// height of the web page. As the user changes the size of the web page, this will continue
49+
// to fire, and resize the child divs to fit.
50+
var new_track_height = $(this).height() - track_offset;
51+
52+
track_controls.height(new_track_height);
53+
$("#scrolling_tracks").height(new_track_height);
54+
body_object.scope().playhead_height = $("#track-container").height();
55+
$(".playhead-line").height(body_object.scope().playhead_height);
56+
});
57+
58+
// Check for Qt Integration
59+
if (typeof timeline !== "undefined") {
60+
timeline.qt_log("Qt Found!");
61+
body_object.scope().enableQt();
62+
timeline.page_ready();
63+
body_object.scope().setThumbAddress(timeline.get_thumb_address());
64+
}
7765

66+
// Manually trigger the window resize code (to verify it runs at least once)
67+
$(window).trigger("resize");
68+
69+
// Bind to keydown event (to detect SHIFT)
70+
body_object.keydown(function (event) {
71+
if (event.which === 16) {
72+
body_object.scope().shift_pressed = true;
73+
}
74+
});
75+
76+
body_object.keyup(function () {
77+
if (body_object.scope().shift_pressed) {
78+
body_object.scope().shift_pressed = false;
79+
}
80+
});
81+
82+
});

src/timeline/index.html

+15-15
Original file line numberDiff line numberDiff line change
@@ -44,15 +44,15 @@
4444
<!-- RULER (right of screen) -->
4545
<div id="scrolling_ruler">
4646
<!-- PLAYHEAD TOP -->
47-
<div tl-playhead class="playhead playhead-top" ng-right-click="ShowPlayheadMenu(project.playhead_position)" style="left:{{(project.playhead_position * pixelsPerSecond) + playheadOffset}}px;">
47+
<div tl-playhead class="playhead playhead-top" ng-right-click="showPlayheadMenu(project.playhead_position)" style="left:{{(project.playhead_position * pixelsPerSecond) + playheadOffset}}px;">
4848
<div class="playhead-line-small"></div>
4949
</div>
5050
<!-- Ruler extends beyond tracks area at least for a width of vertical scroll bar (or more, like 50px here) -->
51-
<canvas tl-ruler id="ruler" width="{{GetTimelineWidth(1024)+50}}" height="39"></canvas>
51+
<canvas tl-ruler id="ruler" width="{{getTimelineWidth(1024) + 50}}" height="39"></canvas>
5252

5353
<!-- MARKERS -->
5454
<span class="ruler_marker" id="marker_for_{{marker.id}}">
55-
<img ng-repeat="marker in project.markers" id="marker_{{marker.id}}_{{$index}}" ng-right-click="ShowMarkerMenu(marker.id)" style="position: absolute; bottom: 0px; left: {{(marker.position * pixelsPerSecond) - 6 }}px;" class="marker_icon" ng-src="media/images/markers/{{ marker.icon }}" draggable="false"/>
55+
<img ng-repeat="marker in project.markers" id="marker_{{marker.id}}_{{$index}}" ng-right-click="showMarkerMenu(marker.id)" style="position: absolute; bottom: 0px; left: {{(marker.position * pixelsPerSecond) - 6 }}px;" class="marker_icon" ng-src="media/images/markers/{{ marker.icon }}" draggable="false"/>
5656
</span>
5757
<br class="cleared">
5858

@@ -63,29 +63,29 @@
6363

6464
<!-- TRACKS NAMES (left of screen) -->
6565
<div id="track_controls">
66-
<div ng-repeat="layer in project.layers.slice().reverse()" id="track_static_{{layer.number}}" ng-right-click="ShowTrackMenu(layer.id)" class="track_name">
66+
<div ng-repeat="layer in project.layers.slice().reverse()" id="track_static_{{layer.number}}" ng-right-click="showTrackMenu(layer.id)" class="track_name">
6767
<div class="track_top">
68-
<div tl-clip-menu class="track_menu" ng-mousedown="ShowTrackMenu(layer.id)"></div>
69-
<span class="track_label">{{GetTrackName(layer.label, project.layers.length - $index)}}</span><span ng-show="layer.lock" class="track_lock"></span>
68+
<div tl-clip-menu class="track_menu" ng-mousedown="showTrackMenu(layer.id)"></div>
69+
<span class="track_label">{{getTrackName(layer.label, project.layers.length - $index)}}</span><span ng-show="layer.lock" class="track_lock"></span>
7070
</div>
7171
</div>
7272
<br>
7373
</div>
7474
<!-- TRACKS CONTAINER (right of screen) -->
7575
<div tl-scrollable-tracks id="scrolling_tracks">
76-
<div id="track-container" tl-track tl-multi-selectable style="width: {{GetTimelineWidth(1024)}}px; padding-bottom: 2px;">
76+
<div id="track-container" tl-track tl-multi-selectable style="width: {{getTimelineWidth(1024)}}px; padding-bottom: 2px;">
7777
<!-- TRACKS -->
78-
<div ng-repeat="layer in project.layers.slice().reverse()" id="track_{{layer.number}}" ng-right-click="ShowTimelineMenu($event, layer.number)" class="{{GetTrackStyle(layer.lock)}}" style="width:{{GetTimelineWidth(1024)}}px;">
78+
<div ng-repeat="layer in project.layers.slice().reverse()" id="track_{{layer.number}}" ng-right-click="showTimelineMenu($event, layer.number)" class="{{getTrackStyle(layer.lock)}}" style="width:{{getTimelineWidth(1024)}}px;">
7979
</div>
8080

8181
<!-- CLIPS -->
82-
<div ng-hide tl-clip ng-repeat="clip in project.clips" id="clip_{{clip.id}}" ng-click="SelectClip(clip.id, true, $event)" ng-right-click="ShowClipMenu(clip.id, $event)" class="clip droppable" ng-class="getClipStyle(clip)" style="width:{{(clip.end - clip.start) * pixelsPerSecond}}px; left:{{clip.position * pixelsPerSecond}}px; top:{{getTrackTop(clip.layer)}}px;z-index:{{1000 + $index}};">
82+
<div ng-hide tl-clip ng-repeat="clip in project.clips" id="clip_{{clip.id}}" ng-click="selectClip(clip.id, true, $event)" ng-right-click="showClipMenu(clip.id, $event)" class="clip droppable" ng-class="getClipStyle(clip)" style="width:{{(clip.end - clip.start) * pixelsPerSecond}}px; left:{{clip.position * pixelsPerSecond}}px; top:{{getTrackTop(clip.layer)}}px;z-index:{{1000 + $index}};">
8383
<div class="clip_top">
84-
<div tl-clip-menu class="clip_menu" ng-show="!enable_razor" ng-mousedown="ShowClipMenu(clip.id, $event)" tooltip-enable="!enable_razor" tooltip="{{clip.title}}" tooltip-placement="bottom" tooltip-popup-delay="400"></div>
84+
<div tl-clip-menu class="clip_menu" ng-show="!enable_razor" ng-mousedown="showClipMenu(clip.id, $event)" tooltip-enable="!enable_razor" tooltip="{{clip.title}}" tooltip-placement="bottom" tooltip-popup-delay="400"></div>
8585

8686
<!-- CLIP EFFECTS -->
8787
<div ng-show="!enable_razor" class="effect-container" id="effects_{{clip.id}}">
88-
<div class="clip_effects" ng-repeat="effect in clip.effects" id="effect_{{effect.id}}" style="background-color: {{ GetEffectColor(effect.type); }};" ng-click="SelectEffect(effect.id); $event.stopPropagation();" ng-right-click="ShowEffectMenu(effect.id); $event.stopPropagation();" tooltip="{{effect.type}} ({{$index+1}}/{{clip.effects.length}})" tooltip-placement="bottom" tooltip-popup-delay="400">
88+
<div class="clip_effects" ng-repeat="effect in clip.effects" id="effect_{{effect.id}}" style="background-color: {{ getEffectColor(effect.type) }};" ng-click="selectEffect(effect.id); $event.stopPropagation();" ng-right-click="showEffectMenu(effect.id); $event.stopPropagation();" tooltip="{{effect.type}} ({{$index+1}}/{{clip.effects.length}})" tooltip-placement="bottom" tooltip-popup-delay="400">
8989
{{effect.type[0]}}
9090
</div>
9191
</div>
@@ -99,17 +99,17 @@
9999
</div>
100100
<br class="cleared">
101101
<div ng-show="!clip.show_audio" class="thumb-container">
102-
<img class="thumb thumb-start" ng-show="{{ GetThumbPath(clip) }}" ng-src="{{ GetThumbPath(clip) }}"/>
102+
<img class="thumb thumb-start" ng-show="{{ getThumbPath(clip) }}" ng-src="{{ getThumbPath(clip) }}"/>
103103
</div>
104104
<div ng-show="clip.show_audio" class="audio-container">
105105
<canvas tl-audio height="46px" width="{{ (clip.end - clip.start) * pixelsPerSecond}}px" class="audio"></canvas>
106106
</div>
107107
</div>
108108

109109
<!-- TRANSITIONS -->
110-
<div ng-hide tl-transition ng-repeat="transition in project.effects" id="transition_{{transition.id}}" ng-click="SelectTransition(transition.id, true, $event)" ng-right-click="ShowTransitionMenu(transition.id, $event)" class="transition droppable" ng-class="getClipStyle(transition)" style="width:{{ (transition.end - transition.start) * pixelsPerSecond}}px; left:{{transition.position * pixelsPerSecond}}px; top:{{getTrackTop(transition.layer)}}px;z-index:{{5000 + $index}};">
110+
<div ng-hide tl-transition ng-repeat="transition in project.effects" id="transition_{{transition.id}}" ng-click="selectTransition(transition.id, true, $event)" ng-right-click="showTransitionMenu(transition.id, $event)" class="transition droppable" ng-class="getClipStyle(transition)" style="width:{{ (transition.end - transition.start) * pixelsPerSecond}}px; left:{{transition.position * pixelsPerSecond}}px; top:{{getTrackTop(transition.layer)}}px;z-index:{{5000 + $index}};">
111111
<div class="transition_top">
112-
<div tl-clip-menu class="transition_menu" ng-show="!enable_razor" ng-mousedown="ShowTransitionMenu(transition.id, $event)"></div>
112+
<div tl-clip-menu class="transition_menu" ng-show="!enable_razor" ng-mousedown="showTransitionMenu(transition.id, $event)"></div>
113113
<!-- TRANSITION KEYFRAME POINTS -->
114114
<div ng-repeat="(point, value) in getKeyframes(transition)" id="point_{{transition.id}}_{{point}}_{{$index}}" style="left: {{(((point - 1) / (project.fps.num / project.fps.den) - transition.start) * pixelsPerSecond)}}px;" class="point_region" ng-show="transition.selected "><div class="point_icon"></div></div>
115115

@@ -135,7 +135,7 @@
135135

136136
</script>
137137

138-
<div ng-show="!Qt" class="gear" ng-click="ToggleDebug()">
138+
<div ng-show="!Qt" class="gear" ng-click="toggleDebug()">
139139
<img src="media/images/gear.png" width="40">
140140
</div>
141141

0 commit comments

Comments
 (0)