Commit 4337f20d authored by Dimitri Podborski's avatar Dimitri Podborski
Browse files

pip 8 and improve author name extraction

parent b2043309
...@@ -46,6 +46,11 @@ Temporary Items ...@@ -46,6 +46,11 @@ Temporary Items
# Local History for Visual Studio Code # Local History for Visual Studio Code
.history/ .history/
####################################
# IntelliJ
####################################
.idea/*
#################################### ####################################
# Python # Python
#################################### ####################################
......
...@@ -66,7 +66,8 @@ class MDMSParser: ...@@ -66,7 +66,8 @@ class MDMSParser:
return [] return []
return meetings return meetings
def parse_author_entry(self, author_entry): @staticmethod
def parse_author_entry(author_entry):
""" """
Search entry string for an email, remove it from the name and clean up Search entry string for an email, remove it from the name and clean up
Return a tuple('name', 'email') Return a tuple('name', 'email')
...@@ -75,18 +76,19 @@ class MDMSParser: ...@@ -75,18 +76,19 @@ class MDMSParser:
if len(author_entry) == 0: if len(author_entry) == 0:
return None return None
email = None email = None
match = re.search(r'[\w\.-]+@[\w\.-]+', author_entry) match = re.search(r'[\w.-]+@[\w.-]+', author_entry)
if match: # email found if match: # email found
email = match.group(0) email = match.group(0)
author_entry = author_entry.replace(email, '') # remove email from the name author_entry = author_entry.replace(email, '') # remove email from the name
# remove everything what is inside () or [] # remove everything what is inside () or []
author_entry = re.sub(r'[\(\[].*?[\)\]]', '', author_entry) author_entry = re.sub(r'[(\[].*?[)\]]', '', author_entry)
# remove all non ASCII characters # remove everything which is not a letter and space
author_entry = re.sub(r'[^\x00-\x7F]+', '', author_entry) author_entry = re.sub(r'[^a-zA-Z\s]+', '', author_entry)
author_entry = author_entry.strip() author_entry = author_entry.strip()
return author_entry, email return author_entry, email
def try_parsing_date(self, text): @staticmethod
def try_parsing_date(text):
""" """
Try parsing the timestamp, if not possible return None Try parsing the timestamp, if not possible return None
""" """
...@@ -288,7 +290,8 @@ class MDMSParser: ...@@ -288,7 +290,8 @@ class MDMSParser:
timestamp = self.try_parsing_date(entry[pos2 + 6:pos3]) timestamp = self.try_parsing_date(entry[pos2 + 6:pos3])
return details return details
def check_table_header(self, template, header_row): @staticmethod
def check_table_header(template, header_row):
""" """
Check if header_row contains the same data as the template Check if header_row contains the same data as the template
""" """
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment