Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
E
erp5
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Ayush Tiwari
erp5
Commits
56c33d07
Commit
56c33d07
authored
Jun 15, 2011
by
Kazuhiko Shiozaki
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
optimize _getPropertyList and _getCategoryList
* call getters for already stored properties and categories only.
parent
375b9730
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
41 deletions
+22
-41
product/ERP5/MovementCollectionDiff.py
product/ERP5/MovementCollectionDiff.py
+22
-41
No files found.
product/ERP5/MovementCollectionDiff.py
View file @
56c33d07
...
@@ -118,50 +118,31 @@ def _getPropertyAndCategoryList(document):
...
@@ -118,50 +118,31 @@ def _getPropertyAndCategoryList(document):
def
_getPropertyList
(
document
,
acquire
=
True
):
def
_getPropertyList
(
document
,
acquire
=
True
):
property_map
=
document
.
getPropertyMap
()
property_map
=
document
.
getPropertyMap
()
bad_property_list
=
[
'id'
,
'uid'
,
'categories_list'
,
'last_id'
,]
bad_property_list
=
[
'id'
,
'uid'
,
'categories_list'
,
'last_id'
,]
# we don't want acquired properties without acquisition_mask_value
document_dict
=
document
.
__dict__
for
x
in
property_map
:
property_dict
=
{}
if
x
.
has_key
(
'acquisition_base_category'
)
and
not
x
.
get
(
'acquisition_mask_value'
,
0
):
bad_property_list
.
append
(
x
[
'id'
])
default_value_dict
=
dict
([(
x
[
'id'
],
x
.
get
(
'default'
,
None
))
\
for
x
in
property_map
])
getPropertyList
=
document
.
getPropertyList
getPropertyList
=
document
.
getPropertyList
getProperty
=
document
.
getProperty
getProperty
=
document
.
getProperty
getter_list_type_dict
=
{
for
x
in
property_map
:
True
:
getPropertyList
,
property_id
=
x
[
'id'
]
False
:
getProperty
if
property_id
in
bad_property_list
:
}
continue
getter_dict
=
dict
([(
x
[
'id'
],
# we care already stored property only
getter_list_type_dict
[
x
[
'type'
]
in
list_types
and
not
x
[
'id'
].
endswith
(
'_list'
)])
\
elif
(
x
[
'storage_id'
]
or
property_id
)
not
in
document_dict
:
for
x
in
property_map
])
continue
# we don't want acquired properties without acquisition_mask_value
def
filter_property_func
(
x
):
elif
x
.
has_key
(
'acquisition_base_category'
)
and
not
x
.
get
(
'acquisition_mask_value'
,
0
):
key
,
value
=
x
continue
if
key
in
bad_property_list
:
elif
x
[
'type'
]
in
list_types
and
not
property_id
.
endswith
(
'_list'
):
return
False
property_dict
[
property_id
]
=
getPropertyList
(
property_id
)
default
=
default_value_dict
[
key
]
else
:
if
value
==
default
:
property_dict
[
property_id
]
=
getProperty
(
property_id
)
return
False
return
property_dict
if
not
acquire
and
not
document
.
hasProperty
(
key
):
return
False
if
isinstance
(
value
,
(
list
,
tuple
))
and
\
isinstance
(
default
,
(
list
,
tuple
))
and
\
tuple
(
value
)
==
tuple
(
default
):
return
False
return
True
return
dict
(
filter
(
filter_property_func
,
[(
x
,
getter_dict
[
x
](
x
))
for
x
in
\
document
.
getPropertyIdList
()]))
def
_getCategoryList
(
document
,
acquire
=
True
):
def
_getCategoryList
(
document
,
acquire
=
True
):
bad_category_list
=
[
'solver'
,
]
bad_category_list
=
[
'solver'
,
]
# we care already stored category only
document_category_set
=
set
([
x
.
split
(
'/'
,
1
)[
0
]
for
x
in
\
document
.
getCategoryList
()])
getPropertyList
=
document
.
getPropertyList
getPropertyList
=
document
.
getPropertyList
def
filter_category_func
(
x
):
return
dict
([(
x
,
getPropertyList
(
x
))
for
x
in
document_category_set
\
return
len
(
x
[
1
])
!=
0
and
x
[
0
]
not
in
bad_category_list
and
\
if
x
not
in
bad_category_list
])
(
acquire
or
document
.
hasProperty
(
x
[
0
]))
return
dict
(
filter
(
filter_category_func
,
[(
x
,
getPropertyList
(
x
))
for
x
in
\
document
.
getBaseCategoryList
()]))
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a 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