Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
gajim
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
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
eta
gajim
Commits
daefea01
Commit
daefea01
authored
19 years ago
by
Yann Leboulanger
Browse files
Options
Downloads
Patches
Plain Diff
function moved to helpers.py
parent
210d9895
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/common/helpers.py
+26
-1
26 additions, 1 deletion
src/common/helpers.py
src/common/logger.py
+3
-30
3 additions, 30 deletions
src/common/logger.py
with
29 additions
and
31 deletions
src/common/helpers.py
+
26
−
1
View file @
daefea01
...
...
@@ -19,6 +19,7 @@
from
common
import
i18n
_
=
i18n
.
_
import
sre
def
get_uf_show
(
show
):
'''
returns a userfriendly string for dnd/xa/chat
...
...
@@ -49,4 +50,28 @@ def get_sorted_keys(adict):
keys
=
adict
.
keys
()
keys
.
sort
()
return
keys
\ No newline at end of file
def
to_one_line
(
msg
):
msg
=
msg
.
replace
(
'
\\
'
,
'
\\\\
'
)
msg
=
msg
.
replace
(
'
\n
'
,
'
\\
n
'
)
# s1 = 'test\ntest\\ntest'
# s11 = s1.replace('\\', '\\\\')
# s12 = s11.replace('\n', '\\n')
# s12
# 'test\\ntest\\\\ntest'
return
msg
def
from_one_line
(
msg
):
# (?<!\\) is a lookbehind assertion which asks anything but '\'
# to match the regexp that follows it
# So here match '\\n' but not if you have a '\' before that
re
=
sre
.
compile
(
r
'
(?<!\\)\\n
'
)
msg
=
re
.
sub
(
'
\n
'
,
msg
)
msg
=
msg
.
replace
(
'
\\\\
'
,
'
\\
'
)
# s12 = 'test\\ntest\\\\ntest'
# s13 = re.sub('\n', s12)
# s14 s13.replace('\\\\', '\\')
# s14
# 'test\ntest\\ntest'
return
msg
This diff is collapsed.
Click to expand it.
src/common/logger.py
+
3
−
30
View file @
daefea01
...
...
@@ -20,10 +20,10 @@
import
os
import
sys
import
time
import
sre
import
common.gajim
from
common
import
i18n
_
=
i18n
.
_
from
common
import
helpers
LOGPATH
=
os
.
path
.
expanduser
(
'
~/.gajim/logs
'
)
if
os
.
name
==
'
nt
'
:
...
...
@@ -54,12 +54,6 @@ class Logger:
print
'
creating
'
,
LOGPATH
,
'
directory
'
os
.
mkdir
(
LOGPATH
)
# (?<!\\) is a lookbehind assertion which asks anything but '\'
# to match the regexp that follows it
# So here match '\\n' but not if you have a '\' before that
self
.
re
=
sre
.
compile
(
r
'
(?<!\\)\\n
'
)
def
write
(
self
,
kind
,
msg
,
jid
,
show
=
None
,
tim
=
None
):
if
not
tim
:
tim
=
time
.
time
()
...
...
@@ -68,18 +62,7 @@ class Logger:
if
not
msg
:
msg
=
''
msg
=
msg
.
replace
(
'
\\
'
,
'
\\\\
'
)
msg
=
msg
.
replace
(
'
\n
'
,
'
\\
n
'
)
# s1 = 'test\ntest'
# s2 = 'test\\ntest'
# s11 = s1.replace('\\', '\\\\')
# s21 = s2.replace('\\', '\\\\')
# s12 = s11.replace('\n', '\\n')
# s22 = s21.replace('\n', '\\n')
# s12
# 'test\\ntest'
# s22
# test\\\\ntest'
msg
=
helpers
.
to_one_line
(
msg
)
if
len
(
jid
.
split
(
'
/
'
))
>
1
:
ji
,
nick
=
jid
.
split
(
'
/
'
,
1
)
else
:
...
...
@@ -176,17 +159,7 @@ class Logger:
while
nb
<
end_line
:
line
=
fic
.
readline
()
if
line
:
line
=
self
.
re
.
sub
(
'
\n
'
,
line
)
line
=
line
.
replace
(
'
\\\\
'
,
'
\\
'
)
# re = sre.compile(r'(?<!\\)\\n')
# s13 = re.sub('\n', s12)
# s23 = re.sub('\n', s22)
# s14 = s13.replace('\\\\', '\\')
# s24 = s23.replace('\\\\', '\\')
# s14
# 'test\ntest'
# s24
# 'test\\ntest'
line
=
helpers
.
from_one_line
(
line
)
lineSplited
=
line
.
split
(
'
:
'
)
if
len
(
lineSplited
)
>
2
:
lines
.
append
(
lineSplited
)
...
...
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