Giter Site home page Giter Site logo

reprint's People

Contributors

pickledish avatar yinzo avatar zeruniverse avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

reprint's Issues

Reprint treat unicode emoji pairs a two characters rather than one

Hello, I have encountered a strange problem with reprint. I use it to build a command line utility and needed to have functionality to select a region. I used emoji flags e.g: 🇫🇷 after the region name but this resulted in the formatting of the interface screwing up. What I think is going on is the unicode system for various emojis like flags or options is comprised of 2+ symbols. In the case above, the French flag is made by combining the symbol for F with the symbol for R. See the proposal document here: https://www.unicode.org/L2/L2009/09379-n3727-regionalindicators.pdf. Reprint views this as two separate characters though and prepares it self for a line of length x. When this is rendered out to a user however, the F+R characters are combined into a single character, so a line of length x - 1. This then screws up the following lines as the initial line length calculation is wrong. This problem is apparent across all the various combination emojis that cover cases like gender and race.

Happy to assist with fixing this issue, might need some direction on where I should be looking within the project.

append() not working in 'dict' mode

It raises AttributeError: 'SignalDict' object has no attribute 'append'

Example:

with output(output_type="dict", interval=0) as output:
   output.append('text at the bottom')

如何接受input输入?

我想正常输出一张二维表格,同时最底下可以接受用户输入,然后用用户输入的内容更新表格,这个当前的功能似乎不能做到(显示混乱)

Allow for custom sort order with dict output_type

I would like to pass my own custom function for sorting the dict when using the output_type='dict' option. Currently it sorts by the first character of each key which is fine for some cases, but not all. It would be nice if there was a parameter, say sort_function that I could pass in and replace the lambda x : x[0] function.

Doesn't work properly on Ubuntu

Tried this on Ubuntu 16.04 x64 with Python 3.5.2 in both the default terminal and Terminator and the output doesn't always print over the top of itself, instead printing on new lines as with regular print().

When I run the example from the README, none of the lines seem to reprint. I've also tried this other example and only the Total Progress line stays in the same spot (the Moving File line always prints on a new line).

Not sure if it matters, but I'm using zsh. I tried both of the above on OSX using Terminal.app (also using zsh) and it worked fine.

Format dict key to print

I am using it to print this list:

1: Valtteri Bottas 1:53.581
2: Kimi Räikkönen 1:53.596
3: Max Verstappen 1:54.807
4: Felipe Massa 1:55.591
5: Daniel Ricciardo 1:55.626
6: Sergio Perez 1:55.676
7: Nico Hulkenberg 1:55.623
8: Daniil Kvyat 1:56.183
9: Carlos Sainz Jr. 1:56.151
10: Lance Stroll 1:56.397
11: Kevin Magnussen 1:56.808
12: Esteban Ocon 1:57.530
13: Romain Grosjean 1:57.588
14: Fernando Alonso 1:57.852
15: Jolyon Palmer 1:58.786
16: Pascal Wehrlein 1:58.776
17: Marcus Ericsson 1:58.702
18: Stoffel Vandoorne 1:58.586
19: Sebastian Vettel 2:02.790
20: Lewis Hamilton 1:53.520

but when the position printed is 10 and beyond, it breaks the align with the timings.
How can this be fixed?

I would like to be able to print

01: Valtteri Bottas 1:53.581
02: Kimi Räikkönen 1:53.596
03: Max Verstappen 1:54.807
04: Felipe Massa 1:55.591
05: Daniel Ricciardo 1:55.626
06: Sergio Perez 1:55.676
07: Nico Hulkenberg 1:55.623
08: Daniil Kvyat 1:56.183
09: Carlos Sainz Jr. 1:56.151
10: Lance Stroll 1:56.397
11: Kevin Magnussen 1:56.808
12: Esteban Ocon 1:57.530
13: Romain Grosjean 1:57.588
14: Fernando Alonso 1:57.852
15: Jolyon Palmer 1:58.786
16: Pascal Wehrlein 1:58.776
17: Marcus Ericsson 1:58.702
18: Stoffel Vandoorne 1:58.586
19: Sebastian Vettel 2:02.790
20: Lewis Hamilton 1:53.520

I added just now by hand a leading space to format the driver standings, while the timings are in correct alignement in my output, but here github is breaking the alignement :)

EDIT 1:
I added a leading 0 because the space isn't shown :)
Great library, very useful

Nice Table Formatting broken when adding colored text

I am inserting in a dict this string

CSI="\x1B["
driverName = "Sebastian Vettel"
driverName = CSI + "31;40m" + driverName + CSI + "0m"

currentStanding[ driverPosition ] = driverName

and then using your method to print this dict
with output(output_type="dict", initial_len=1, interval=200, ) as currentStanding:

when I try to output raw string it is all nice, but when I add the escape sequence to print the colored name it prints two columns..
Thanks

Zero division error

When I run

with output(output_type='dict') as output_lines:
    output_lines['a'] = 'test'

I receive a zero division error with the following traceback:

Traceback (most recent call last):
  File "C:\***\testReprint.py", line 4, in <module>
    output_lines['a'] = 'test'
  File "C:\Python27\lib\site-packages\reprint\reprint.py", line 243, in __exit__
    self.refresh(forced=True)
  File "C:\Python27\lib\site-packages\reprint\reprint.py", line 230, in refresh
    print_multi_line(self.warped_obj, self.force_single_line)
  File "C:\Python27\lib\site-packages\reprint\reprint.py", line 134, in print_multi_line
    lines = lines_of_content(content, columns)
  File "C:\Python27\lib\site-packages\reprint\reprint.py", line 112, in lines_of_content
    result += ceil((line_width(_k) + line_width(_v) + 2) / width)
ZeroDivisionError: division by zero

This only happens when I run it from IDLE by pressing f5. get_terminal_size() seems to return 0s when run in the IDLE shell. Running from the python shell returns an actual value.

I recommend either an assert statement to give at least a sensical error:
assert all(get_terminal_size()), 'Reprint does not work in the IDLE terminal.'

Or a redefinition of the function in cases where length and width are zero to return arbitrary values.

if not all(get_terminal_size()):
    def get_terminal_size():
        return 80, 25 #windows terminal size, can be anything?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.