Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
N
neoppod
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
1
Issues
1
List
Boards
Labels
Milestones
Merge Requests
2
Merge Requests
2
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
neoppod
Commits
dfe51432
Commit
dfe51432
authored
Apr 19, 2017
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
8f842cba
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
94 additions
and
23 deletions
+94
-23
t/neo/storage/fs1/cmd/fstail/fstail.go
t/neo/storage/fs1/cmd/fstail/fstail.go
+1
-1
t/neo/xcommon/xbufio/xbufio.go
t/neo/xcommon/xbufio/xbufio.go
+1
-0
t/neo/xcommon/xfmt/fmt.go
t/neo/xcommon/xfmt/fmt.go
+30
-4
t/neo/xcommon/xfmt/fmt_test.go
t/neo/xcommon/xfmt/fmt_test.go
+24
-3
t/neo/xcommon/xfmt/python.go
t/neo/xcommon/xfmt/python.go
+21
-15
t/neo/xcommon/xfmt/python_test.go
t/neo/xcommon/xfmt/python_test.go
+17
-0
No files found.
t/neo/storage/fs1/cmd/fstail/fstail.go
View file @
dfe51432
...
...
@@ -122,7 +122,7 @@ func fsTail(w io.Writer, path string, ntxn int) (err error) {
// fstail.py uses repr to print user/description:
// https://github.com/zopefoundation/ZODB/blob/5.2.0-5-g6047e2fae/src/ZODB/scripts/fstail.py#L39
xbuf
.
S
(
"
\n
user="
)
.
Q
bpy
(
txnh
.
User
)
.
S
(
" description="
)
.
Qbpy
(
txnh
.
Description
)
xbuf
.
S
(
"
\n
user="
)
.
Q
pyb
(
txnh
.
User
)
.
S
(
" description="
)
.
Qpyb
(
txnh
.
Description
)
// NOTE in zodb/py .length is len - 8, in zodb/go - whole txn record length
xbuf
.
S
(
" length="
)
.
D64
(
txnh
.
Len
-
8
)
...
...
t/neo/xcommon/xbufio/xbufio.go
View file @
dfe51432
...
...
@@ -42,6 +42,7 @@ func NewReader(r io.Reader) *Reader {
}
// InputOffset returns current position in input stream
// XXX naming + define interface for getting current position
func
(
r
*
Reader
)
InputOffset
()
int64
{
return
r
.
cr
.
Nread
-
int64
(
r
.
Reader
.
Buffered
())
}
t/neo/xcommon/xfmt/fmt.go
View file @
dfe51432
...
...
@@ -2,9 +2,14 @@
// Kirill Smelkov <kirr@nexedi.com>
//
// This program is free software: you can Use, Study, Modify and Redistribute
// it under the terms of the GNU General Public License version
2
, or (at your
// it under the terms of the GNU General Public License version
3
, or (at your
// option) any later version, as published by the Free Software Foundation.
//
// You can also Link and Combine this program with other software covered by
// the terms of any of the Open Source Initiative approved licenses and Convey
// the resulting work. Corresponding source of such a combination shall include
// the source code for all other software used.
//
// This program is distributed WITHOUT ANY WARRANTY; without even the implied
// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
//
...
...
@@ -20,7 +25,7 @@
// xfmt analog would be
//
// xbuf := xfmt.Buffer{}
// xbuf .S("hello ") .Q
s
("world") .C(' ') .D(1) .C(' ') .Xb([]byte("data"))
// xbuf .S("hello ") .Q("world") .C(' ') .D(1) .C(' ') .Xb([]byte("data"))
// s := xbuf.Bytes()
//
// xfmt.Buffer can be reused several times via Buffer.Reset() .
...
...
@@ -91,7 +96,7 @@ func (b *Buffer) Sb(x []byte) *Buffer {
return
b
}
// Cb appends byte formated by %c
// Cb appends byte format
t
ed by %c
func
(
b
*
Buffer
)
Cb
(
c
byte
)
*
Buffer
{
*
b
=
append
(
*
b
,
c
)
return
b
...
...
@@ -171,4 +176,25 @@ func (b *Buffer) X016(x uint64) *Buffer {
return
b
}
// TODO Qs Qb ?
// Q appends string formatted by %q
func
(
b
*
Buffer
)
Q
(
s
string
)
*
Buffer
{
*
b
=
strconv
.
AppendQuote
(
*
b
,
s
)
return
b
}
// Qb appends []byte formatted by %q
func
(
b
*
Buffer
)
Qb
(
s
[]
byte
)
*
Buffer
{
*
b
=
strconv
.
AppendQuote
(
*
b
,
mem
.
String
(
s
))
return
b
}
// Qcb appends byte formatted by %q
func
(
b
*
Buffer
)
Qcb
(
c
byte
)
*
Buffer
{
return
b
.
Qc
(
rune
(
c
))
}
// Qc appends rune formatted by %q
func
(
b
*
Buffer
)
Qc
(
c
rune
)
*
Buffer
{
*
b
=
strconv
.
AppendQuoteRune
(
*
b
,
c
)
return
b
}
t/neo/xcommon/xfmt/fmt_test.go
View file @
dfe51432
// TODO copyright/license
// Copyright (C) 2017 Nexedi SA and Contributors.
// Kirill Smelkov <kirr@nexedi.com>
//
// This program is free software: you can Use, Study, Modify and Redistribute
// it under the terms of the GNU General Public License version 3, or (at your
// option) any later version, as published by the Free Software Foundation.
//
// You can also Link and Combine this program with other software covered by
// the terms of any of the Open Source Initiative approved licenses and Convey
// the resulting work. Corresponding source of such a combination shall include
// the source code for all other software used.
//
// This program is distributed WITHOUT ANY WARRANTY; without even the implied
// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
//
// See COPYING file for full licensing terms.
package
xfmt
...
...
@@ -16,10 +31,16 @@ var testv = []struct {format, xformatMeth string; value interface{}} {
{
"%c"
,
"C"
,
'\u20ac'
},
// 3-bytes encoded
{
"%c"
,
"C"
,
'\U00010001'
},
// 4-bytes encoded
// TODO %q qb qr qs qcb qc
{
"%s"
,
"S"
,
"hello"
},
{
"%s"
,
"Sb"
,
[]
byte
(
"world"
)},
{
"%q"
,
"Q"
,
"alpha"
},
{
"%q"
,
"Qb"
,
[]
byte
(
"beta"
)},
{
"%q"
,
"Qcb"
,
byte
(
'D'
)},
{
"%q"
,
"Qc"
,
'B'
},
// 1-byte encoded
{
"%q"
,
"Qc"
,
'и'
},
// 2-bytes encoded
{
"%q"
,
"Qc"
,
'\u20ac'
},
// 3-bytes encoded
{
"%q"
,
"Qc"
,
'\U00010001'
},
// 4-bytes encoded
{
"%x"
,
"Xb"
,
[]
byte
(
"hexstring"
)},
{
"%x"
,
"Xs"
,
"stringhex"
},
{
"%d"
,
"D"
,
12765
},
...
...
t/neo/xcommon/xfmt/python.go
View file @
dfe51432
// Copyright (C) 2017 Nexedi SA and Contributors.
// Kirill Smelkov <kirr@nexedi.com>
//
// This program is free software: you can Use, Study, Modify and Redistribute
// it under the terms of the GNU General Public License version 3, or (at your
// option) any later version, as published by the Free Software Foundation.
//
// You can also Link and Combine this program with other software covered by
// the terms of any of the Open Source Initiative approved licenses and Convey
// the resulting work. Corresponding source of such a combination shall include
// the source code for all other software used.
//
// This program is distributed WITHOUT ANY WARRANTY; without even the implied
// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
//
// See COPYING file for full licensing terms.
// quoting by Python rules
package
xfmt
import
(
...
...
@@ -8,19 +27,6 @@ import (
"lab.nexedi.com/kirr/go123/mem"
)
// TODO remove - not needed ?
// // pyQuote quotes string the way python repr(str) would do
// func pyQuote(s string) string {
// out := pyQuoteBytes(mem.Bytes(s))
// return mem.String(out)
// }
//
// func pyQuoteBytes(b []byte) []byte {
// buf := make([]byte, 0, (len(b) + 2) /* to reduce allocations when quoting */ * 2)
// return pyAppendQuoteBytes(buf, b)
// }
// bytesContainsByte is like bytes.ContainsRune but a bit faster
func
bytesContainsByte
(
s
[]
byte
,
c
byte
)
bool
{
return
bytes
.
IndexByte
(
s
,
c
)
>=
0
...
...
@@ -112,8 +118,8 @@ func (b *Buffer) Qpy(s string) *Buffer {
return
b
}
// Q
bpy
appends []byte quoted as Python would do
func
(
b
*
Buffer
)
Q
bpy
(
x
[]
byte
)
*
Buffer
{
// Q
pyb
appends []byte quoted as Python would do
func
(
b
*
Buffer
)
Q
pyb
(
x
[]
byte
)
*
Buffer
{
*
b
=
AppendQuotePyBytes
(
*
b
,
x
)
return
b
}
t/neo/xcommon/xfmt/python_test.go
View file @
dfe51432
// Copyright (C) 2017 Nexedi SA and Contributors.
// Kirill Smelkov <kirr@nexedi.com>
//
// This program is free software: you can Use, Study, Modify and Redistribute
// it under the terms of the GNU General Public License version 3, or (at your
// option) any later version, as published by the Free Software Foundation.
//
// You can also Link and Combine this program with other software covered by
// the terms of any of the Open Source Initiative approved licenses and Convey
// the resulting work. Corresponding source of such a combination shall include
// the source code for all other software used.
//
// This program is distributed WITHOUT ANY WARRANTY; without even the implied
// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
//
// See COPYING file for full licensing terms.
package
xfmt
import
(
...
...
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