Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
tev
plugin_event
Commits
a96ea15c
Commit
a96ea15c
authored
Feb 24, 2017
by
LE GAC Renaud
Browse files
Polish migrate-list-070.py
parent
d340b23c
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
30 additions
and
0 deletions
+30
-0
scripts/migrate-list-070.py
scripts/migrate-list-070.py
+30
-0
No files found.
scripts/migrate-list-070.py
View file @
a96ea15c
...
...
@@ -23,8 +23,13 @@
R. Le Gac -- Feb 2017
"""
import
re
import
sys
from
gluon.storage
import
Storage
from
gluon.tools
import
PluginManager
def
fix_dbname
(
s
):
...
...
@@ -52,15 +57,22 @@ if __name__ == "__main__":
event
.
Core
.
define_tables
(
db
,
T
)
event
.
Report
.
define_tables
(
db
,
T
)
rex_id_events
=
re
.
compile
(
"\.id_events *={1,2} *(\d+)"
)
sources
=
PluginManager
(
"event"
).
event
.
sources
.
keys
()
sources
.
sort
()
for
row
in
db
(
db
.
lists
.
id
>
0
).
select
():
rep
=
raw_input
(
"Migrate '%s' [y/N]: "
%
row
.
name
)
if
rep
.
lower
()
!=
"y"
:
continue
# copy and fix
list2
=
Storage
(
name
=
row
.
name
,
title
=
row
.
title
,
definition
=
row
.
definition
,
id_events
=
1
,
group_field
=
row
.
group_field
,
sorters
=
row
.
sorters
,
columns
=
row
.
columns
,
...
...
@@ -72,7 +84,25 @@ if __name__ == "__main__":
list2
.
group_field
=
fix_dbname
(
list2
.
group_field
)
list2
.
sorters
=
[
fix_dbname
(
el
)
for
el
in
list2
.
sorters
]
# find the event identifier
m
=
rex_id_events
.
search
(
row
.
conditions
)
if
m
:
list2
.
id_events
=
int
(
m
.
group
(
1
))
# setup the source
print
"
\t
Select the source: "
for
i
in
xrange
(
len
(
sources
)):
print
"
\t
%5i %s"
%
(
i
,
sources
[
i
])
rep
=
raw_input
(
"
\t
Enter a value [i/N]: "
)
if
not
rep
.
isdigit
():
continue
list2
.
source
=
sources
[
int
(
rep
)]
# create
db
.
lists2
[
0
]
=
list2
db
.
commit
()
print
"
\t
New %s list created"
%
row
.
name
sys
.
exit
(
0
)
\ No newline at end of file
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