Skip to content

Commit

Permalink
Fixup: format code with Black
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions committed Sep 5, 2022
1 parent af091c2 commit 4b6da94
Show file tree
Hide file tree
Showing 17 changed files with 77 additions and 92 deletions.
5 changes: 1 addition & 4 deletions pod/completion/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,10 +209,7 @@ class Track(models.Model):
_("Kind"), max_length=10, choices=KIND_CHOICES, default="subtitles"
)
lang = models.CharField(
_("Language"),
max_length=2,
choices=LANG_CHOICES,
default=DEFAULT_LANG_TRACK
_("Language"), max_length=2, choices=LANG_CHOICES, default=DEFAULT_LANG_TRACK
)
src = models.ForeignKey(
CustomFileModel,
Expand Down
12 changes: 6 additions & 6 deletions pod/completion/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ def video_caption_maker(request, slug):
"track_language": track_language,
"track_kind": track_kind,
"active_model_enrich": ACTIVE_MODEL_ENRICH,
"page_title": _("Video Caption Maker")
"page_title": _("Video Caption Maker"),
},
)

Expand Down Expand Up @@ -153,7 +153,7 @@ def video_caption_maker_save(request, video):
"current_folder": video_folder,
"form_make_caption": form_caption,
"video": video,
"page_title": _("Video Caption Maker")
"page_title": _("Video Caption Maker"),
},
)

Expand Down Expand Up @@ -198,7 +198,7 @@ def video_completion(request, slug):
"list_track": list_track,
"list_document": list_document,
"list_overlay": list_overlay,
"page_title": _("Video additions")
"page_title": _("Video additions"),
},
)
else:
Expand All @@ -208,7 +208,7 @@ def video_completion(request, slug):
{
"video": video,
"list_contributor": list_contributor,
"page_title": _("Video additions")
"page_title": _("Video additions"),
},
)

Expand Down Expand Up @@ -253,7 +253,7 @@ def video_completion_contributor(request, slug):
"list_track": list_track,
"list_document": list_document,
"list_overlay": list_overlay,
"page_title": _("Video additions")
"page_title": _("Video additions"),
},
)
else:
Expand All @@ -263,7 +263,7 @@ def video_completion_contributor(request, slug):
{
"video": video,
"list_contributor": list_contributor,
"page_title": _("Video additions")
"page_title": _("Video additions"),
},
)

Expand Down
3 changes: 1 addition & 2 deletions pod/live/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,7 @@ def get_form(self, request, obj=None, **kwargs):
kwargs["widgets"] = {
"piloting_conf": Textarea(
attrs={
"placeholder":
"{\n 'server_url':'...',\n \
"placeholder": "{\n 'server_url':'...',\n \
'application':'...',\n 'livestream':'...',\n}"
}
)
Expand Down
51 changes: 27 additions & 24 deletions pod/live/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,36 +159,39 @@ def __init__(self, *args, **kwargs):

class EventForm(forms.ModelForm):
fieldsets = (
(None, {
"fields": [
"title",
"start_date",
"start_time",
"end_time",
"building",
"broadcaster",
"password",
"is_restricted",
"restrict_access_to_groups"
]
}),
(
None,
{
"fields": [
"title",
"start_date",
"start_time",
"end_time",
"building",
"broadcaster",
"password",
"is_restricted",
"restrict_access_to_groups",
]
},
),
(
"advanced_options",
{
"legend": _("Display advanced options"),
"classes": "collapse",
"fields": [
'description',
'owner',
'additional_owners',
'type',
'is_draft',
'is_auto_start',
'iframe_url',
'iframe_height',
'aside_iframe_url',
'thumbnail'
]
"description",
"owner",
"additional_owners",
"type",
"is_draft",
"is_auto_start",
"iframe_url",
"iframe_height",
"aside_iframe_url",
"thumbnail",
],
},
),
)
Expand Down
4 changes: 1 addition & 3 deletions pod/live/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,9 +194,7 @@ def heartbeat(request):
def can_manage_event(user):
return user.is_authenticated and (
user.is_superuser
or user.owner.accessgroup_set.filter(
code_name__in=AFFILIATION_EVENT
).exists()
or user.owner.accessgroup_set.filter(code_name__in=AFFILIATION_EVENT).exists()
)


Expand Down
5 changes: 1 addition & 4 deletions pod/main/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,7 @@
# https://docs.djangoproject.com/en/3.2/topics/i18n/
# https://github.com/django/django/blob/master/django/conf/global_settings.py
LANGUAGE_CODE = "fr"
LANGUAGES = (
("fr", "Français"),
("en", "English")
)
LANGUAGES = (("fr", "Français"), ("en", "English"))

##
# A string representing the time zone for this installation.
Expand Down
4 changes: 2 additions & 2 deletions pod/main/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def test_contact_us(self):
"captcha_0": captcha.hashkey,
"captcha_1": captcha.response,
"url_referrer": "http://localhost:8000/",
"firstname": ""
"firstname": "",
},
)
messages = list(response.wsgi_request._messages)
Expand All @@ -92,7 +92,7 @@ def test_contact_us(self):
"subject": "info",
"description": "",
"captcha": "",
"firstname": ""
"firstname": "",
},
)
self.assertTemplateUsed(response, "contact_us.html")
Expand Down
2 changes: 1 addition & 1 deletion pod/main/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ def get_dest_email(owner, video, form_subject, request):


@csrf_protect
@check_honeypot(field_name='firstname')
@check_honeypot(field_name="firstname")
def contact_us(request):
"""Handle "Contact us" form."""
owner = (
Expand Down
12 changes: 2 additions & 10 deletions pod/meeting/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,20 +33,12 @@
"restrict_access_to_groups",
),
)
MEETING_DISABLE_RECORD = getattr(
settings,
"MEETING_DISABLE_RECORD",
True
)
MEETING_DISABLE_RECORD = getattr(settings, "MEETING_DISABLE_RECORD", True)

MEETING_RECORD_FIELDS = getattr(
settings,
"MEETING_RECORD_FIELDS",
(
"record",
"auto_start_recording",
"allow_start_stop_recording"
)
("record", "auto_start_recording", "allow_start_stop_recording"),
)

MEETING_EXCLUDE_FIELDS = MEETING_MAIN_FIELDS + ("id",)
Expand Down
3 changes: 1 addition & 2 deletions pod/meeting/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -614,8 +614,7 @@ def test_meeting_invite_post_request(self):
response = self.client.post(
url,
{
"emails":
"[email protected]\n\r[email protected], [email protected] [email protected]"
"emails": "[email protected]\n\r[email protected], [email protected] [email protected]"
},
)
self.assertRedirects(
Expand Down
2 changes: 1 addition & 1 deletion pod/playlist/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class Playlist(models.Model):
max_length=100,
help_text=_(
'Used to access this instance, the "slug" is a short'
+ ' label containing only letters, numbers, underscore or dash top.'
+ " label containing only letters, numbers, underscore or dash top."
),
)
owner = models.ForeignKey(User, verbose_name=_("Owner"), on_delete=models.CASCADE)
Expand Down
2 changes: 1 addition & 1 deletion pod/podfile/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -734,7 +734,7 @@ def user_folders(request):
)

page = request.GET.get("page", 1)
user_folder = user_folder.order_by('owner', 'name')
user_folder = user_folder.order_by("owner", "name")
paginator = Paginator(user_folder, 10)
try:
folders = paginator.page(page)
Expand Down
34 changes: 16 additions & 18 deletions pod/video/Encoding_video.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
EXTRACT_THUMBNAIL,
NB_THUMBNAIL,
CREATE_THUMBNAIL,
EXTRACT_SUBTITLE
EXTRACT_SUBTITLE,
)
else:
from .encoding_utils import (
Expand Down Expand Up @@ -60,7 +60,7 @@
EXTRACT_THUMBNAIL,
NB_THUMBNAIL,
CREATE_THUMBNAIL,
EXTRACT_SUBTITLE
EXTRACT_SUBTITLE,
)


Expand All @@ -78,6 +78,7 @@

try:
from django.conf import settings

FFMPEG_CMD = getattr(settings, "FFMPEG_CMD", FFMPEG_CMD)
FFMPEG_CRF = getattr(settings, "FFMPEG_CRF", FFMPEG_CRF)
FFMPEG_PRESET = getattr(settings, "FFMPEG_PRESET", FFMPEG_PRESET)
Expand All @@ -88,14 +89,10 @@
FFMPEG_LIBX = getattr(settings, "FFMPEG_LIBX", FFMPEG_LIBX)
FFMPEG_MP4_ENCODE = getattr(settings, "FFMPEG_MP4_ENCODE", FFMPEG_MP4_ENCODE)
FFMPEG_HLS_COMMON_PARAMS = getattr(
settings,
"FFMPEG_HLS_COMMON_PARAMS",
FFMPEG_HLS_COMMON_PARAMS
settings, "FFMPEG_HLS_COMMON_PARAMS", FFMPEG_HLS_COMMON_PARAMS
)
FFMPEG_HLS_ENCODE_PARAMS = getattr(
settings,
"FFMPEG_HLS_ENCODE_PARAMS",
FFMPEG_HLS_ENCODE_PARAMS
settings, "FFMPEG_HLS_ENCODE_PARAMS", FFMPEG_HLS_ENCODE_PARAMS
)
FFMPEG_MP3_ENCODE = getattr(settings, "FFMPEG_MP3_ENCODE", FFMPEG_MP3_ENCODE)
FFMPEG_M4A_ENCODE = getattr(settings, "FFMPEG_M4A_ENCODE", FFMPEG_M4A_ENCODE)
Expand Down Expand Up @@ -196,7 +193,9 @@ def fix_duration(self, input_file):
msg = "--> get_info_video" + "\n"
probe_cmd = 'ffprobe -v quiet -show_entries format=duration -hide_banner \
-of default=noprint_wrappers=1:nokey=1 -print_format json -i \
"{}"'.format(input_file)
"{}"'.format(
input_file
)
info = get_info_from_video(probe_cmd)
duration = 0
try:
Expand Down Expand Up @@ -308,7 +307,7 @@ def get_hls_command(self):
"preset": FFMPEG_PRESET,
"profile": FFMPEG_PROFILE,
"level": FFMPEG_LEVEL,
"crf": FFMPEG_CRF
"crf": FFMPEG_CRF,
}
in_height = list(self.list_video_track.items())[0][1]["height"]
for index, rend in enumerate(list_rendition):
Expand All @@ -320,7 +319,7 @@ def get_hls_command(self):
"bufsize": list_rendition[rend]["maxrate"],
"ba": list_rendition[rend]["audio_bitrate"],
"hls_time": FFMPEG_HLS_TIME,
"output": output_file
"output": output_file,
}
self.list_hls_files[rend] = output_file
return hls_command
Expand All @@ -346,22 +345,20 @@ def create_main_livestream(self):
livestream_content = ""
for index, rend in enumerate(list_rendition):
rend_livestream = os.path.join(
self.get_output_dir(),
"livestream%s.m3u8" % rend
self.get_output_dir(), "livestream%s.m3u8" % rend
)
if os.path.exists(rend_livestream):
with open(rend_livestream, 'r') as file:
with open(rend_livestream, "r") as file:
data = file.read()
if index == 0:
livestream_content += data
else:
livestream_content += "\n".join(data.split("\n")[2:])
os.remove(rend_livestream)
livestream_file = open(
os.path.join(self.get_output_dir(), "livestream.m3u8"),
"w"
os.path.join(self.get_output_dir(), "livestream.m3u8"), "w"
)
livestream_file.write(livestream_content.replace('\n\n', '\n'))
livestream_file.write(livestream_content.replace("\n\n", "\n"))
livestream_file.close()

def get_mp3_command(self):
Expand Down Expand Up @@ -434,7 +431,8 @@ def get_create_thumbnail_command(self):
for nb in range(0, NB_THUMBNAIL):
num_thumb = str(nb + 1)
self.list_thumbnail_files[num_thumb] = "%s_000%s.png" % (
output_file, num_thumb
output_file,
num_thumb,
)
return thumbnail_command

Expand Down
11 changes: 6 additions & 5 deletions pod/video/Encoding_video_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,9 +203,7 @@ def store_json_encoding_log(self, info_video, video_to_encode):
log_to_text = log_to_text + self.get_output_dir() + "/info_video.json"
log_to_text = log_to_text + "\nEnd : " + self.stop

encoding_log, created = EncodingLog.objects.get_or_create(
video=video_to_encode
)
encoding_log, created = EncodingLog.objects.get_or_create(video=video_to_encode)
encoding_log.log = log_to_text
encoding_log.logfile = self.get_true_path(
self.get_output_dir() + "/info_video.json"
Expand Down Expand Up @@ -233,8 +231,11 @@ def store_json_list_subtitle_files(self, info_video, video_to_encode):
print("subtitle lang: %s " % list_subtitle_files[sub][0])

sub_lang = list_subtitle_files[sub][0]
track_lang = sub_lang[:2] if (
LANG_CHOICES_DICT.get(sub_lang[:2])) else DEFAULT_LANG_TRACK
track_lang = (
sub_lang[:2]
if (LANG_CHOICES_DICT.get(sub_lang[:2]))
else DEFAULT_LANG_TRACK
)

Track.objects.get_or_create(
video=video_to_encode,
Expand Down
Loading

0 comments on commit 4b6da94

Please sign in to comment.