Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
U
uffd
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Operate
Terraform modules
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Luca (strifel)
uffd
Commits
0bf93a57
Commit
0bf93a57
authored
4 years ago
by
Julian
Browse files
Options
Downloads
Patches
Plain Diff
Fixed linter errors
parent
1306790e
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
.pylintrc
+1
-0
1 addition, 0 deletions
.pylintrc
ldap3_mapper_new/base.py
+15
-9
15 additions, 9 deletions
ldap3_mapper_new/base.py
with
16 additions
and
9 deletions
.pylintrc
+
1
−
0
View file @
0bf93a57
...
@@ -147,6 +147,7 @@ disable=missing-module-docstring,
...
@@ -147,6 +147,7 @@ disable=missing-module-docstring,
method-hidden,
method-hidden,
bad-continuation,
bad-continuation,
too-many-ancestors,
too-many-ancestors,
no-self-use,
# Enable the message, report, category or checker with the given id(s). You can
# Enable the message, report, category or checker with the given id(s). You can
# either give multiple identifier separated by comma (,) or put this option
# either give multiple identifier separated by comma (,) or put this option
...
...
This diff is collapsed.
Click to expand it.
ldap3_mapper_new/base.py
+
15
−
9
View file @
0bf93a57
from
copy
import
deepcopy
from
copy
import
deepcopy
from
ldap3
import
MODIFY_REPLACE
,
MODIFY_DELETE
,
MODIFY_ADD
,
ALL_ATTRIBUTES
,
ALL_OPERATIONAL_ATTRIBUTES
class
LDAPCommitError
(
Exception
):
pass
class
SessionState
:
class
SessionState
:
def
__init__
(
self
,
objects
=
None
,
deleted_objects
=
None
,
references
=
None
):
def
__init__
(
self
,
objects
=
None
,
deleted_objects
=
None
,
references
=
None
):
self
.
objects
=
objects
or
{}
self
.
objects
=
objects
or
{}
...
@@ -11,14 +16,15 @@ class SessionState:
...
@@ -11,14 +16,15 @@ class SessionState:
def
ref
(
self
,
obj
,
attr
,
values
):
def
ref
(
self
,
obj
,
attr
,
values
):
for
value
in
values
:
for
value
in
values
:
key
=
(
attr
,
value
)
if
key
not
in
self
.
references
:
if
key
not
in
self
.
references
:
self
.
references
[
key
]
=
{
self
.
obj
}
self
.
references
[
key
]
=
{
obj
}
else
:
else
:
self
.
references
[
key
].
add
(
self
.
obj
)
self
.
references
[
key
].
add
(
obj
)
def
unref
(
self
,
obj
,
attr
,
values
):
def
unref
(
self
,
obj
,
attr
,
values
):
for
value
in
values
:
for
value
in
values
:
self
.
references
.
get
((
name
,
value
),
set
()).
discard
(
obj
)
self
.
references
.
get
((
attr
,
value
),
set
()).
discard
(
obj
)
class
ObjectState
:
class
ObjectState
:
def
__init__
(
self
,
session
=
None
,
attributes
=
None
,
dn
=
None
):
def
__init__
(
self
,
session
=
None
,
attributes
=
None
,
dn
=
None
):
...
@@ -93,7 +99,7 @@ class ModifyOperation:
...
@@ -93,7 +99,7 @@ class ModifyOperation:
for
attr
,
changes
in
self
.
changes
.
items
():
for
attr
,
changes
in
self
.
changes
.
items
():
for
action
,
values
in
changes
:
for
action
,
values
in
changes
:
if
action
==
MODIFY_REPLACE
:
if
action
==
MODIFY_REPLACE
:
session_state
.
unref
(
self
.
obj
,
attr
,
self
.
attributes
.
get
(
attr
,
[])
session_state
.
unref
(
self
.
obj
,
attr
,
self
.
attributes
.
get
(
attr
,
[])
)
session_state
.
ref
(
self
.
obj
,
attr
,
values
)
session_state
.
ref
(
self
.
obj
,
attr
,
values
)
elif
action
==
MODIFY_ADD
:
elif
action
==
MODIFY_ADD
:
session_state
.
ref
(
self
.
obj
,
attr
,
values
)
session_state
.
ref
(
self
.
obj
,
attr
,
values
)
...
@@ -141,9 +147,9 @@ class Session:
...
@@ -141,9 +147,9 @@ class Session:
oper
=
self
.
changes
.
pop
(
0
)
oper
=
self
.
changes
.
pop
(
0
)
try
:
try
:
oper
.
apply_ldap
(
conn
)
oper
.
apply_ldap
(
conn
)
except
e
:
except
Exception
as
err
:
self
.
changes
.
insert
(
0
,
oper
)
self
.
changes
.
insert
(
0
,
oper
)
raise
e
raise
e
rr
oper
.
apply_object
(
oper
.
obj
.
committed_state
)
oper
.
apply_object
(
oper
.
obj
.
committed_state
)
oper
.
apply_session
(
self
.
committed_state
)
oper
.
apply_session
(
self
.
committed_state
)
self
.
committed_state
=
self
.
state
.
copy
()
self
.
committed_state
=
self
.
state
.
copy
()
...
@@ -207,21 +213,21 @@ class Object:
...
@@ -207,21 +213,21 @@ class Object:
def
setattr
(
self
,
name
,
values
):
def
setattr
(
self
,
name
,
values
):
oper
=
ModifyOperation
(
self
,
{
name
:
[(
MODIFY_REPLACE
,
[
values
])]})
oper
=
ModifyOperation
(
self
,
{
name
:
[(
MODIFY_REPLACE
,
[
values
])]})
oper
.
apply_object
(
obj
.
state
)
oper
.
apply_object
(
self
.
state
)
if
self
.
state
.
session
:
if
self
.
state
.
session
:
oper
.
apply_session
(
self
.
state
.
session
.
state
)
oper
.
apply_session
(
self
.
state
.
session
.
state
)
self
.
state
.
session
.
changes
.
append
(
oper
)
self
.
state
.
session
.
changes
.
append
(
oper
)
def
attr_append
(
self
,
name
,
value
):
def
attr_append
(
self
,
name
,
value
):
oper
=
ModifyOperation
(
self
,
{
name
:
[(
MODIFY_ADD
,
[
value
])]})
oper
=
ModifyOperation
(
self
,
{
name
:
[(
MODIFY_ADD
,
[
value
])]})
oper
.
apply_object
(
obj
.
state
)
oper
.
apply_object
(
self
.
state
)
if
self
.
state
.
session
:
if
self
.
state
.
session
:
oper
.
apply_session
(
self
.
state
.
session
.
state
)
oper
.
apply_session
(
self
.
state
.
session
.
state
)
self
.
state
.
session
.
changes
.
append
(
oper
)
self
.
state
.
session
.
changes
.
append
(
oper
)
def
attr_remove
(
self
,
name
,
value
):
def
attr_remove
(
self
,
name
,
value
):
oper
=
ModifyOperation
(
self
,
{
name
:
[(
MODIFY_DELETE
,
[
value
])]})
oper
=
ModifyOperation
(
self
,
{
name
:
[(
MODIFY_DELETE
,
[
value
])]})
oper
.
apply_object
(
obj
.
state
)
oper
.
apply_object
(
self
.
state
)
if
self
.
state
.
session
:
if
self
.
state
.
session
:
oper
.
apply_session
(
self
.
state
.
session
.
state
)
oper
.
apply_session
(
self
.
state
.
session
.
state
)
self
.
state
.
session
.
changes
.
append
(
oper
)
self
.
state
.
session
.
changes
.
append
(
oper
)
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