Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
Dimitri Podborski
AutomationTools
Commits
4337f20d
Commit
4337f20d
authored
Apr 13, 2021
by
Dimitri Podborski
😂
Browse files
pip 8 and improve author name extraction
parent
b2043309
Changes
2
Hide whitespace changes
Inline
Side-by-side
.gitignore
View file @
4337f20d
...
...
@@ -46,6 +46,11 @@ Temporary Items
# Local History for Visual Studio Code
.history/
####################################
# IntelliJ
####################################
.idea/*
####################################
# Python
####################################
...
...
automation/mdms.py
View file @
4337f20d
...
...
@@ -66,7 +66,8 @@ class MDMSParser:
return
[]
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
Return a tuple('name', 'email')
...
...
@@ -75,18 +76,19 @@ class MDMSParser:
if
len
(
author_entry
)
==
0
:
return
None
email
=
None
match
=
re
.
search
(
r
'[\w
\
.-]+@[\w
\
.-]+'
,
author_entry
)
match
=
re
.
search
(
r
'[\w.-]+@[\w.-]+'
,
author_entry
)
if
match
:
# email found
email
=
match
.
group
(
0
)
author_entry
=
author_entry
.
replace
(
email
,
''
)
# remove email from the name
# remove everything what is inside () or []
author_entry
=
re
.
sub
(
r
'[
\
(\[].*?[
\
)\]]'
,
''
,
author_entry
)
# remove
all non ASCII characters
author_entry
=
re
.
sub
(
r
'[^
\x00-\x7F
]+'
,
''
,
author_entry
)
author_entry
=
re
.
sub
(
r
'[(\[].*?[)\]]'
,
''
,
author_entry
)
# remove
everything which is not a letter and space
author_entry
=
re
.
sub
(
r
'[^
a-zA-Z\s
]+'
,
''
,
author_entry
)
author_entry
=
author_entry
.
strip
()
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
"""
...
...
@@ -288,7 +290,8 @@ class MDMSParser:
timestamp
=
self
.
try_parsing_date
(
entry
[
pos2
+
6
:
pos3
])
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
"""
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment