Skip to content

Commit a781788

Browse files
committed
Fixing bugs with changelog parsing, and removing the 2 separate git log formats - we only generate a single format git log. Simplifying the regex also to be more flexible.
1 parent be8cefd commit a781788

File tree

2 files changed

+13
-42
lines changed

2 files changed

+13
-42
lines changed

src/windows/about.py

+12-41
Original file line numberDiff line numberDiff line change
@@ -49,48 +49,24 @@
4949

5050

5151
def parse_changelog(changelog_path):
52-
"""Read changelog entries from provided file path."""
53-
changelog_list = []
54-
if not os.path.exists(changelog_path):
55-
return None
56-
# Attempt to open changelog with utf-8, and then utf-16 (for unix / windows support)
57-
for encoding_name in ('utf_8', 'utf_16'):
58-
try:
59-
with codecs.open(
60-
changelog_path, 'r', encoding=encoding_name
61-
) as changelog_file:
62-
for line in changelog_file:
63-
changelog_list.append({
64-
'hash': line[:9].strip(),
65-
'date': line[9:20].strip(),
66-
'author': line[20:45].strip(),
67-
'subject': line[45:].strip(),
68-
})
69-
break
70-
except Exception:
71-
log.warning('Failed to parse log file %s with encoding %s' % (changelog_path, encoding_name))
72-
return changelog_list
73-
74-
75-
def parse_new_changelog(changelog_path):
76-
"""Parse changelog data from specified new-format file."""
52+
"""Parse changelog data from specified gitlab-ci generated file."""
7753
if not os.path.exists(changelog_path):
7854
return None
7955
changelog_list = None
8056
for encoding_name in ('utf_8', 'utf_16'):
8157
try:
8258
with codecs.open(changelog_path, 'r', encoding=encoding_name) as changelog_file:
8359
# Generate match object with fields from all matching lines
84-
matches = re.findall(
85-
r"^-\s?([0-9a-f]{40})\s(\d{4,4}-\d{2,2}-\d{2,2})\s(.*)\s\[(.*)\]\s*$",
86-
changelog_file.read(), re.MULTILINE)
60+
matches = re.findall(r"(\w{6,10})\s+(\d{4}-\d{2}-\d{2})\s+(.*)\s{2,99}?(.*)",
61+
changelog_file.read(), re.MULTILINE)
8762
log.debug("Parsed {} changelog lines from {}".format(len(matches), changelog_path))
8863
changelog_list = [{
89-
"hash": entry[0],
90-
"date": entry[1],
91-
"subject": entry[2],
92-
"author": entry[3],
64+
"hash": entry[0].strip(),
65+
"date": entry[1].strip(),
66+
"author": entry[2].strip(),
67+
"subject": entry[3].strip(),
9368
} for entry in matches]
69+
break
9470
except UnicodeError:
9571
log.debug('Failed to parse log file %s with encoding %s' % (changelog_path, encoding_name))
9672
continue
@@ -409,17 +385,12 @@ def __init__(self):
409385

410386
# Read changelog file for each project
411387
for project in ['openshot-qt', 'libopenshot', 'libopenshot-audio']:
412-
new_changelog_path = os.path.join(info.PATH, 'resources', '{}.log'.format(project))
413-
old_changelog_path = os.path.join(info.PATH, 'settings', '{}.log'.format(project))
414-
if os.path.exists(new_changelog_path):
415-
log.debug("Reading changelog file: {}".format(new_changelog_path))
416-
changelog_list = parse_new_changelog(new_changelog_path)
417-
elif os.path.isfile(old_changelog_path):
418-
log.debug("Reading legacy changelog file: {}".format(old_changelog_path))
419-
changelog_list = parse_changelog(old_changelog_path)
388+
changelog_path = os.path.join(info.PATH, 'settings', '{}.log'.format(project))
389+
if os.path.exists(changelog_path):
390+
log.debug("Reading changelog file: {}".format(changelog_path))
391+
changelog_list = parse_changelog(changelog_path)
420392
else:
421393
changelog_list = None
422-
# Hopefully we found ONE of the two
423394
if changelog_list is None:
424395
log.warn("Could not load changelog for {}".format(project))
425396
# Hide the tab for this changelog

src/windows/views/zoom_slider.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ def paintEvent(self, event, *args):
150150

151151
# Get FPS info
152152
fps_num = get_app().project.get("fps").get("num", 24)
153-
fps_den = get_app().project.get("fps").get("den", 1)
153+
fps_den = get_app().project.get("fps").get("den", 1) or 1
154154
fps_float = float(fps_num / fps_den)
155155

156156
# Determine scale factor

0 commit comments

Comments
 (0)