Never see escaped bytes in output.

Related tags

Miscellaneous uniout
Overview

Uniout

It makes Python print the object representation in readable chars instead of the escaped string.

Example

>>> from pprint import pprint
>>> langs = [
...     'Hello, world!',
...     '你好,世界!',
...     'こんにちは世界',
...     u'Hello, world!',
...     u'你好,世界!',
...     u'こんにちは世界'
... ]
...

Before:

>>> pprint(langs)
['Hello, world!',
 '\xe4\xbd\xa0\xe5\xa5\xbd\xef\xbc\x8c\xe4\xb8\x96\xe7\x95\x8c\xef\xbc\x81',
 '\xe3\x81\x93\xe3\x82\x93\xe3\x81\xab\xe3\x81\xa1\xe3\x81\xaf\xe4\xb8\x96\xe7\x95\x8c',
 u'Hello, world!',
 u'\u4f60\u597d\uff0c\u4e16\u754c\uff01',
 u'\u3053\u3093\u306b\u3061\u306f\u4e16\u754c']

After:

>>> import uniout
>>> pprint(langs)
['Hello, world!',
 '你好,世界!',
 'こんにちは世界',
 u'Hello, world!',
 u'你好,世界!',
 u'こんにちは世界']

Installation

You can install it via PyPI,

sudo pip install uniout

or download it manually.

Changelog

v0.3.7

  1. Switch to long-string syntax (''' or """) automatically.

v0.3.6

  1. Fixed the issue with empty string.

v0.3.5

  1. Make it still works for files.

v0.3.4

  1. A better fix for the previous bug.

v0.3.3

  1. Fixed the problem that Uniout can't be installed by PIP.

v0.3.2

  1. Show the original string if the escaped string can't be decoded properly.
  2. Use better way to find string literals.
  3. Print more correct unescaped string representation.

v0.3.1

  1. Fixed a bug when Uniout works with IPython.

v0.3

Thanks for the pull requests #3 and #4 from @timtan, it now

  1. works well with IPython,
  2. and also supports stderr.
Comments
  • Can not install the package by pip install uniout under windows system

    Can not install the package by pip install uniout under windows system

    I had tried many times to install this package by the command: pip install uniout Its error is :Not found the module named 'builtin' , it seems suitlable for python2, but not for python3。 And I had also downloaded the lateset code from github, and tried to install it by hand. It seems no error found. But I still can not import uniout correctly.... Could you pls tell me how to solve this problem, TIA。

    opened by lmw0320 4
  • python3

    python3

    i have learn python3 for one month,it seems pip3 cant install this, $: sudo pip3 install uniout it say: Collecting uniout Using cached uniout-0.3.7.tar.gz Complete output from command python setup.py egg_info: Traceback (most recent call last): File "", line 1, in File "/tmp/pip-build-wia2didx/uniout/setup.py", line 6, in import uniout File "/tmp/pip-build-wia2didx/uniout/uniout.py", line 9, in if runs_in_ipython(): File "/tmp/pip-build-wia2didx/uniout/_uniout.py", line 93, in runs_in_ipython import builtin ImportError: No module named 'builtin'

    opened by Vivisky 3
  • Really fix PIP installation

    Really fix PIP installation

    A redirected stream may not have encoding information, causing unescape_string_literal to fail with a TypeError (because encoding is None).

    I also put the __version__ variable back to uniout. Hope it makes sense.

    opened by uranusjr 3
  • Conflict with IPython's auto complete

    Conflict with IPython's auto complete

    After import uniout

    IPython's autocomplete is now working. and the backspace cannot position the cursor to correct position.

    but It doesn't affect the normal python shell if I turn on the feature of auto complete

    enhancement 
    opened by timtan 3
  • Can not handle a mixture of str/unicode and float in IPython

    Can not handle a mixture of str/unicode and float in IPython

    python: 2.7.8 ipython: 2.3.1

    Here is the traceback:

    In [6]: (u'哈', 1.1)
    Out[6]: ---------------------------------------------------------------------------
    UnicodeEncodeError                        Traceback (most recent call last)
    /home/tomsheep/.pyenv/versions/2.7.8/lib/python2.7/site-packages/IPython/core/interactiveshell.pyc in run_code(self, code_obj)
       2892             self.CustomTB(etype,value,tb)
       2893         except:
    -> 2894             self.showtraceback()
       2895         else:
       2896             outflag = 0
    
    /home/tomsheep/.pyenv/versions/2.7.8/lib/python2.7/site-packages/IPython/core/interactiveshell.pyc in showtraceback(self, exc_tuple, filename, tb_offset, exception_only)
       1756                                             value, tb, tb_offset=tb_offset)
       1757 
    -> 1758                     self._showtraceback(etype, value, stb)
       1759                     if self.call_pdb:
       1760                         # drop into debugger
    
    /home/tomsheep/.pyenv/versions/2.7.8/lib/python2.7/site-packages/IPython/core/interactiveshell.pyc in _showtraceback(self, etype, evalue, stb)
       1774         place, like a side channel.
       1775         ''"
    -> 1776         print(self.InteractiveTB.stb2text(stb), file=io.stdout)
       1777 
       1778     def showsyntaxerror(self, filename=None):
    
    /home/tomsheep/.pyenv/versions/2.7.8/lib/python2.7/site-packages/_uniout.pyc in <lambda>(b)
         85 
         86     # modify the write method to unescape the output
    ---> 87     unistream.write = lambda b: stream.write(unescape(b, unistream.encoding))
         88 
         89     return unistream
    
    /home/tomsheep/.pyenv/versions/2.7.8/lib/python2.7/site-packages/_uniout.pyc in unescape(b, encoding)
         72 def unescape(b, encoding):
         73     '''Unescape all string and unicode literals in bytes.'''
    ---> 74     return string_literal_re.sub(lambda m: unescape_string_literal(m.group(), encoding), b)
         75 
         76 def make_unistream(stream):
    
    /home/tomsheep/.pyenv/versions/2.7.8/lib/python2.7/site-packages/_uniout.pyc in <lambda>(m)
         72 def unescape(b, encoding):
         73     '''Unescape all string and unicode literals in bytes.'''
    ---> 74     return string_literal_re.sub(lambda m: unescape_string_literal(m.group(), encoding), b)
         75 
         76 def make_unistream(stream):
    
    /home/tomsheep/.pyenv/versions/2.7.8/lib/python2.7/site-packages/_uniout.pyc in unescape_string_literal(literal, encoding)
         54 
         55         return literalize_string(
    ---> 56             literal[2:-1].decode('unicode-escape').encode(encoding),
         57             is_unicode=True
         58         )
    
    UnicodeEncodeError: 'ascii' codec can't encode character u'\u54c8' in position 0: ordinal not in range(128)
    
    opened by tomsheep 2
  • Switched broken pypip.in badges to shields.io

    Switched broken pypip.in badges to shields.io

    Hello, this is an auto-generated Pull Request. (Feedback?)

    Some time ago, pypip.in shut down. This broke the badges for a bunch of repositories, including uniout. Thankfully, an equivalent service is run by shields.io. This pull request changes the badges to use shields.io instead.

    Unfortunately, PyPI has removed download statistics from their API, which means that even the shields.io "download count" badges are broken (they display "no longer available". See this). So those badges should really be removed entirely. Since this is an automated process (and trying to automatically remove the badges from READMEs can be tricky), this pull request just replaces the URL with the shields.io syntax.

    opened by movermeyer 0
Owner
Mosky Liu
❤ Python, Web, statistics, and open source!
Mosky Liu
Never get kicked for inactivity ever again!

FFXIV AFK Bot Tired of getting kicked from games due to inactivity? This Bot will make random movements in random intervals to prevent you from gettin

null 5 Jan 12, 2022
👀 nothing to see here

Woofy Woofy is blue dog companion token of YFI (Wifey) It utilizes a special Woof bonding curve which allows two-way conversion between the tokens. Th

Yearn Finance 36 Mar 14, 2022
Anki Addon idea by gbrl.sc to see previous ratings of a card in the reviewer

Card History At A Glance Stop having to press card browser and ctrl+i for every card and then WINCING to see it's history of reviews FEATURES Visualiz

Jerry Zhou 11 Dec 19, 2022
An application to see if your Ethereum staking validator(s) are members of the current or next post-Altair sync committees.

eth_sync_committee.py Since the Altair upgrade, 512 validators are randomly chosen every 256 epochs (~27 hours) to form a sync committee. Validators i

null 4 Oct 27, 2022
ArinjoyTheDev 1 Jul 17, 2022
This is a modified variation of abhiTronix's vidgear. In this variation, it is possible to write the output file anywhere regardless the permissions.

Info In order to download this package: Windows 10: Press Windows+S, Type PowerShell (cmd in older versions) and hit enter, Type pip install vidgear_n

Ege Akman 3 Jan 30, 2022
Modify version of impacket wmiexec.py, get output(data,response) from registry, don't need SMB connection, also bypassing antivirus-software in lateral movement like WMIHACKER.

wmiexec-RegOut Modify version of impacket wmiexec.py,wmipersist.py. Got output(data,response) from registry, don't need SMB connection, but I'm in the

小离 228 Jan 4, 2023
Time tracking program that will format output to be easily put into Gitlab

time_tracker Time tracking program that will format output to be easily put into Gitlab. Feel free to branch and use it yourself! Getting Started Clon

Jake Strasler 2 Oct 13, 2022
A python script to run any executable and pass test cases to it's stdin and compare stdout with correct output.

quera_testcase_checker A python script to run any executable and pass test cases to it's stdin and compare stdout with correct output. proper way to u

k3y1 1 Nov 15, 2021
Multifunctional Analysis of Regions through Input-Output

MARIO Multifunctional Analysis of Regions through Input-Output. (Documents) What is it MARIO is a python package for handling input-output tables and

null 14 Dec 25, 2022
Automates the fixing of problems reported by yamllint by parsing its output

yamlfixer yamlfixer automates the fixing of problems reported by yamllint by parsing its output. Usage This software automatically fixes some errors a

OPT Nouvelle Caledonie 26 Dec 26, 2022
Process RunGap output file of a workout and load data into Apple Numbers Spreadsheet and my website with API calls

BSD 3-Clause License Copyright (c) 2020, Mike Bromberek All rights reserved. ProcessWorkout Exercise data is exported in JSON format to iCloud using

Mike Bromberek 1 Jan 3, 2022
Meera 2 May 12, 2022
Med to csv - A simple way to parse MedAssociate output file in tidy data

MedAssociates to CSV file A simple way to parse MedAssociate output file in tidy

Jean-Emmanuel Longueville 5 Sep 9, 2022
Arcpy Tool developed for ArcMap 10.x that checks DVOF points against TDS data and creates an output feature class as well as a check database.

DVOF_check_tool Arcpy Tool developed for ArcMap 10.x that checks DVOF points against TDS data and creates an output feature class as well as a check d

null 3 Apr 18, 2022
Python function to extract all the rows from a SQLite database file while iterating over its bytes, such as while downloading it

Python function to extract all the rows from a SQLite database file while iterating over its bytes, such as while downloading it

Department for International Trade 16 Nov 9, 2022
IDA plugin for quickly copying disassembly as encoded hex bytes

HexCopy IDA plugin for quickly copying disassembly as encoded hex bytes. This whole plugin just saves you two extra clicks... but if you are frequentl

OALabs 46 Oct 30, 2022
gcrypter: an encryption algorithm based on bytes and their correspondent numbers to encode strings

gcrypter: an encryption algorithm based on bytes and their correspondent numbers to encode strings

Nuninha-GC 1 Jan 10, 2022
Make files with as many random bytes as you want

Lots o' Bytes ?? Make files with as many random bytes as you want! Use case Can be used to package malware that is normally small by making the downlo

Addi 1 Jan 13, 2022