[issue45929] extend json.tool --json-lines to ignore empty rows

2021-12-08 Thread Vito De Tullio


Vito De Tullio  added the comment:

My final goal is to preserve the empty lines - I think I can do some bash 
magic, but maybe something more complex that a simple sed call.

FWIW on https://jsonlines.org/#line-separator-is-n I see "The last character in 
the file may be a line separator, and it will be treated the same as if there 
was no line separator present.".
And on https://github.com/ndjson/ndjson-spec#32-parsing I see "The parser MAY 
silently ignore empty lines, e.g. \n\n. This behavior MUST be documented and 
SHOULD be configurable by the user of the parser.".

While I get this choice can be "on a grey area", I think this is a known 
"dialect" of the jsonl specs.

--

___
Python tracker 
<https://bugs.python.org/issue45929>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue45929] extend json.tool --json-lines to ignore empty rows

2021-11-29 Thread Vito De Tullio


Change by Vito De Tullio :


--
keywords: +patch
pull_requests: +28086
stage:  -> patch review
pull_request: https://github.com/python/cpython/pull/29858

___
Python tracker 
<https://bugs.python.org/issue45929>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue45929] extend json.tool --json-lines to ignore empty rows

2021-11-29 Thread Vito De Tullio


New submission from Vito De Tullio :

It would be useful to let json.tool support empty rows during handling of json 
lines
generally speaking, this tolerance is already present in parsers like srsly and 
jsonlines

actual behavior:

# happy scenario
$ echo -e '{"foo":1}\n{"bar":2}' | python3.10 -mjson.tool --json-lines
{
"foo": 1
}
{
"bar": 2
}
$

# spurious EOL at EOF
$ echo -e '{"foo":1}\n{"bar":2}\n' | python3.10 -mjson.tool --json-lines
{
"foo": 1
}
{
"bar": 2
}
Expecting value: line 2 column 1 (char 1)
$

# two groups of "rows" in jsonl <- my current usecase
$ echo -e '{"foo":1}\n\n{"bar":2}' | python3.10 -mjson.tool --json-lines
{
"foo": 1
}
Expecting value: line 2 column 1 (char 1)
$


my desired outcome is to preserve the EOLs, so to have something like:

# happy scenario
$ echo -e '{"foo":1}\n{"bar":2}' | python3.10 -mjson.tool --json-lines
{
"foo": 1
}
{
"bar": 2
}
$

# spurious EOL at EOF
$ echo -e '{"foo":1}\n{"bar":2}\n' | python3.10 -mjson.tool --json-lines
{
"foo": 1
}
{
"bar": 2
}

$

# two groups of "rows" in jsonl
$ echo -e '{"foo":1}\n\n{"bar":2}' | python3.10 -mjson.tool --json-lines
{
"foo": 1
}

{
"bar": 2
}
$

--
components: Library (Lib)
messages: 407289
nosy: ZeD
priority: normal
severity: normal
status: open
title: extend json.tool --json-lines to ignore empty rows
type: enhancement
versions: Python 3.10

___
Python tracker 
<https://bugs.python.org/issue45929>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue42424] add constructor that support multiple context managers to contextlib.ExitStack and contextlib.AsyncExitStack

2020-11-21 Thread Vito De Tullio


New submission from Vito De Tullio :

The enhancement is to add a __init__ method to both contextlib.ExitStack and 
contextlib.AsyncExitStack, so that you can pass (async)context managers 
directly in the costructor.

additionally, a new "context_managers" / "async_context_managers" field is 
added to retrieve the values passed


This will ease the usage with lists of context managers

instead of:

with ExitStack() as stack:
files = [stack.enter_context(open(fname)) for fname in filenames]

you can have

with ExitStack(*(open(fname) for fname in filenames)) as stack:
files = stack.context_managers

In my use case I have a fixed + variable number of (async)context managers, and 
I don't even need the "as" part

   ...
   in_send, in_receive = trio.open_memory_channel(0)
   out_sends, out_receives = [], []
   for _ in range(n): # n is dynamic
   out_send, out_receive = trio.open_memory_channel(0)
   out_sends.append(out_send)
   out_receives.append(out_receive)
   
   # syntax error
   async with in_send, in_receive, *out_sends, *out_receives:
   ...

   # with current AsyncExitStack
   async with AsyncExitStack() as stack:
   await stack.async_context_managers(in_send)
   await stack.async_context_managers(in_receive)
   for out_send in out_sends:
   await stack.async_context_managers(out_send)
   for out_receive in out_receives:
   await stack.async_context_managers(out_receives)
   ...

   # with the change
   async with AsyncExitStack(in_send, in_receive, *out_sends, *out_receives):
   ...

--
components: Library (Lib)
messages: 381561
nosy: ZeD
priority: normal
severity: normal
status: open
title: add constructor that support multiple context managers to 
contextlib.ExitStack and contextlib.AsyncExitStack
type: enhancement

___
Python tracker 
<https://bugs.python.org/issue42424>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue5901] missing meta-info in documentation pdf

2009-05-01 Thread Vito De Tullio

New submission from Vito De Tullio :

from http://docs.python.org/download.html and
http://docs.python.org/3.0/download.html you can download the python
documentation in many formats (html, pdf, txt), I think auto-generated
by the .rst source.

While html and txt does not, the pdf format, supports some simple
"meta-data" infos about the document: other than the number of pages,
the page size, the creator, etc... (all auto-filled) there are 4 "keys"
that the current pdf miss to fill and I think it's important: Title,
Subject, Keywords, and Author.

try, for example, to use the simple pdfinfo tool (from
http://poppler.freedesktop.org/) to inspect the current pdf

$ tar xvjf python-3.0.1-docs-pdf-a4.tar.bz2
$ cd docs-pdf
$ ls -1
c-api.pdf
distutils.pdf
documenting.pdf
extending.pdf
howto-advocacy.pdf
howto-cporting.pdf
howto-curses.pdf
howto-doanddont.pdf
howto-functional.pdf
howto-regex.pdf
howto-sockets.pdf
howto-unicode.pdf
howto-urllib2.pdf
howto-webservers.pdf
install.pdf
library.pdf
reference.pdf
tutorial.pdf
using.pdf
whatsnew.pdf
$ pdfinfo library.pdf
Title:
Subject:
Keywords:
Author:
Creator:LaTeX with hyperref package
Producer:   pdfTeX-1.40.9
CreationDate:   Sat Feb 14 11:33:09 2009
ModDate:Sat Feb 14 11:33:09 2009
Tagged: no
Pages:  1077
Encrypted:  no
Page size:  595.276 x 841.89 pts (A4)
File size:  7556857 bytes
Optimized:  no
PDF version:1.4

erh, what is supposed to contain "using.pdf"? and "distutils.pdf"?

(Yes, I know what they contain, but...)

If the pdf were "tagged", not only me, but also my OS will know what's
in these pdf (see nepomuk/strigi/tracker/beagle programs, helping me
find what I'm searching

--
assignee: georg.brandl
components: Documentation
messages: 86931
nosy: ZeD, georg.brandl
severity: normal
status: open
title: missing meta-info in documentation pdf
type: resource usage
versions: Python 3.1

___
Python tracker 
<http://bugs.python.org/issue5901>
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue5807] ConfigParser.RawConfigParser it's an "old-style" class

2009-04-21 Thread Vito De Tullio

New submission from Vito De Tullio :

RawConfigParser does not inherit from object, so using (to make an
example) super() it's impossible.

Python 2.6 (r26:66714, Feb  3 2009, 20:52:03)
[GCC 4.3.2 [gcc-4_3-branch revision 141291]] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from ConfigParser import RawConfigParser
>>> class MyConfigParser(RawConfigParser):
... def __init__(self):
... super(MyConfigParser, self).__init__()
...
>>> mcp = MyConfigParser()
Traceback (most recent call last):
  File "", line 1, in 
  File "", line 3, in __init__
TypeError: super() argument 1 must be type, not classobj
>>>

--
components: Library (Lib)
messages: 86232
nosy: ZeD
severity: normal
status: open
title: ConfigParser.RawConfigParser it's an "old-style" class
versions: Python 2.6

___
Python tracker 
<http://bugs.python.org/issue5807>
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com