FAQ
| This is a
LIVE
service |
Changelog
Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
Directory Synchronisation Tool
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Admin message
GitLab has been upgraded. See what's new in the
Changelog
.
Show more breadcrumbs
Information Services
DevOps
Google WorkSpace (aka G-Suite)
Directory Synchronisation Tool
Commits
010da28f
Commit
010da28f
authored
2 years ago
by
Robin Goodall
Browse files
Options
Downloads
Patches
Plain Diff
add check for lookup jd import default displayname
parent
ad5fd3b8
No related branches found
No related tags found
1 merge request
!29
Add check for lookup jd import default displayname
Pipeline
#237197
passed with warnings
2 years ago
Stage: build
Stage: test
Stage: dast
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
.flake8
+1
-1
1 addition, 1 deletion
.flake8
gsuitesync/naming.py
+42
-3
42 additions, 3 deletions
gsuitesync/naming.py
with
43 additions
and
4 deletions
.flake8
+
1
−
1
View file @
010da28f
[flake8]
max-line-length=99
exclude = venv,.tox
exclude = venv,
env,.venv,.env,
.tox
This diff is collapsed.
Click to expand it.
gsuitesync/naming.py
+
42
−
3
View file @
010da28f
...
...
@@ -39,8 +39,9 @@ def get_names(*, uid, display_name=None, cn=None, sn=None, given_name=None):
Names
(
given_name
=
'
Stephen
'
,
family_name
=
'
Quill-RomanXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
'
)
If display name has been changed from cn (or we are missing cn) then use that in
preference to a given name and surname pairing
If display name has been changed from cn (or we are missing cn) but isn
'
t the default
we
'
d get from using preferred first name initial then use that in preference to a given
name and surname pairing, i.e. assume that
'
s what is really wanted
>>>
get_names
(
uid
=
'
spqr1
'
,
cn
=
'
Stephen Quill Roman
'
,
display_name
=
'
Steve Quill-Roman
'
,
...
sn
=
'
Quill Roman
'
,
given_name
=
'
Stephen
'
)
...
...
@@ -48,6 +49,9 @@ def get_names(*, uid, display_name=None, cn=None, sn=None, given_name=None):
>>>
get_names
(
uid
=
'
spqr1
'
,
display_name
=
'
Steve Quill-Roman
'
,
sn
=
'
Quill Roman
'
,
...
given_name
=
'
Stephen
'
)
Names
(
given_name
=
'
Steve
'
,
family_name
=
'
Quill-Roman
'
)
>>>
get_names
(
uid
=
'
spqr1
'
,
cn
=
'
S.P. Quill-Roman
'
,
display_name
=
'
S. Quill-Roman
'
,
...
sn
=
'
Quill-Roman
'
,
given_name
=
'
Steve
'
)
Names
(
given_name
=
'
Steve
'
,
family_name
=
'
Quill-Roman
'
)
If we have given name and surname then pass these through (after stripping unsupported
characters and truncating as above)
...
...
@@ -145,7 +149,9 @@ def get_names(*, uid, display_name=None, cn=None, sn=None, given_name=None):
# If we have a display name and it doesn't match cn (or we have no cn) then use this as
# an indication that this is what the user wants displayed
if
display_name
is
not
None
and
(
cn
is
None
or
cn
!=
display_name
):
if
(
display_name
is
not
None
and
(
cn
is
None
or
cn
!=
display_name
)
and
display_name
!=
jd_import_default
(
given_name
,
sn
)):
gn
,
fn
=
_split_fullname
(
display_name
,
sn
=
sn
,
given_name
=
given_name
)
if
gn
:
return
_make_ret
(
family_name
=
fn
,
given_name
=
gn
)
...
...
@@ -265,6 +271,39 @@ def _split_fullname(fullname, sn=None, given_name=None):
return
(
None
,
None
)
def
jd_import_default
(
gn
,
sn
):
"""
Works out the default display name that Lookup
'
s Jackdaw import would give from given and
surname.
We need both value to work this out
>>>
jd_import_default
(
None
,
None
)
''
>>>
jd_import_default
(
'
foo
'
,
None
)
''
>>>
jd_import_default
(
None
,
'
bar
'
)
''
Use only first initial
>>>
jd_import_default
(
'
Anne Marie
'
,
'
Smith
'
)
'
A. Smith
'
Cope with hyphenated first names
>>>
jd_import_default
(
'
Mary-Anne
'
,
'
Jones
'
)
'
M-A. Jones
'
"""
if
gn
is
None
or
sn
is
None
:
return
''
initial
=
'
-
'
.
join
([
name
[
0
].
upper
()
for
name
in
gn
.
split
(
'
-
'
)])
+
"
.
"
return
f
'
{
initial
}
{
sn
}
'
def
_clean
(
s
):
"""
Clean any
"
bad characters
"
in names. This pattern is based on the one used by the
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment