Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
wikstraktor
Manage
Activity
Members
Labels
Plan
Issues
3
Issue boards
Milestones
Wiki
External wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Lex gaMe
wikstraktor
Commits
8767d00e
Commit
8767d00e
authored
2 years ago
by
Mathieu Loiseau
Browse files
Options
Downloads
Patches
Plain Diff
With log sqlite db
parent
6081dccb
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
wikstraklog.py
+48
-0
48 additions, 0 deletions
wikstraklog.py
wikstraktor.py
+5
-2
5 additions, 2 deletions
wikstraktor.py
with
53 additions
and
2 deletions
wikstraklog.py
0 → 100755
+
48
−
0
View file @
8767d00e
#!/usr/bin/env python3
import
sqlite3
class
Wikstraklog
:
table_name
=
"
Wikstraklog
"
def
__init__
(
self
,
wikstraktor_version
,
word_language
,
wiki_language
,
file
=
"
wikstraktor.sqlite
"
):
self
.
__connector__
=
sqlite3
.
connect
(
file
)
self
.
__cursor__
=
self
.
__connector__
.
cursor
()
if
self
.
__execute__
(
f
"
SELECT name FROM sqlite_master WHERE type=
'
table
'
AND name=
'
{
Wikstraklog
.
table_name
}
'
;
"
).
fetchone
()
is
None
:
self
.
__execute__
(
f
"""
CREATE TABLE
"
{
Wikstraklog
.
table_name
}
"
(
"
Date
"
DATETIME DEFAULT CURRENT_TIMESTAMP,
"
Wikstraktor_version
"
TEXT NOT NULL,
"
Word_language
"
TEXT NOT NULL,
"
Wiki_language
"
TEXT NOT NULL,
"
Word_form
"
TEXT NOT NULL,
"
Wiki_permanent_id
"
INTEGER NOT NULL,
"
Caller_method
"
TEXT,
"
Content
"
TEXT
);
"""
)
self
.
wx_v
=
wikstraktor_version
self
.
w_l
=
word_language
self
.
wk_l
=
wiki_language
def
set_context
(
self
,
word
,
permanentId
):
self
.
cur_w
=
word
self
.
cur_pid
=
permanentId
def
__execute__
(
self
,
query
,
params
=
None
):
if
params
==
None
:
res
=
self
.
__cursor__
.
execute
(
query
)
else
:
res
=
self
.
__cursor__
.
execute
(
query
,
params
)
self
.
__connector__
.
commit
()
return
res
def
add_log
(
self
,
caller
,
content
,
word
=
None
,
permanentId
=
None
):
if
word
==
None
:
word
=
self
.
cur_w
if
permanentId
==
None
:
permanentId
=
self
.
cur_pid
res
=
self
.
__execute__
(
f
"
INSERT INTO `
{
Wikstraklog
.
table_name
}
` (`Wikstraktor_version`, `Word_language`, `Wiki_language`, `Word_form`, `Wiki_permanent_id`, `Caller_method`, `Content`) VALUES (?, ?, ?, ?, ?, ?, ?)
"
,
(
self
.
wx_v
,
self
.
w_l
,
self
.
wk_l
,
word
,
permanentId
,
caller
,
str
(
content
)))
return
res
if
__name__
==
"
__main__
"
:
from
wikstraktor_version
import
version
as
the_version
log
=
Wikstraklog
(
the_version
,
"
en
"
,
"
fr
"
)
log
.
set_context
(
"
blue
"
,
123456789
)
log
.
add_log
(
"
exampleMethod
"
,
"
no relevant content
"
)
This diff is collapsed.
Click to expand it.
wikstraktor.py
+
5
−
2
View file @
8767d00e
...
...
@@ -3,6 +3,8 @@ import pywikibot
import
wikitextparser
import
importlib
import
json
from
wikstraktor_version
import
version
as
the_version
from
wikstraklog
import
Wikstraklog
#ICITE : fr marche pas, en prend des trucs vides à virer (cf. yellow… def & example)
...
...
@@ -447,8 +449,8 @@ class Wikstraktor:
try
:
m_name
=
f
"
{
wiki_language
}
_
{
entry_language
}
"
.
capitalize
()
instance
=
getattr
(
importlib
.
import_module
(
f
"
parsers.
{
m_name
.
lower
()
}
"
),
f
"
{
m_name
}
_straktor
"
)()
from
wikstraktor_
version
import
version
as
v
instance
.
version
=
v
instance
.
version
=
the_
version
instance
.
log
=
Wikstraklog
(
the_version
,
entry_language
,
wiki_language
)
except
ModuleNotFoundError
:
print
(
f
"
parsers.
{
m_name
.
lower
()
}
module not found or
{
m_name
}
_straktor not found in module
"
)
instance
=
None
...
...
@@ -490,6 +492,7 @@ class Wikstraktor:
def
parse
(
self
,
entry
,
v_id
,
sections
):
self
.
parserContext
=
ParserContext
(
entry
,
self
.
entry_language
,
self
.
wiki_language
,
v_id
,
self
.
version
)
self
.
log
.
set_context
(
entry
,
v_id
)
for
s
in
sections
:
if
s
.
title
!=
None
:
#handle wiki context
...
...
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