Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

An error occurs when trying printing a dict containing strings #29

Open
JustMegaAlex opened this issue Mar 17, 2021 · 2 comments
Open

Comments

@JustMegaAlex
Copy link

JustMegaAlex commented Mar 17, 2021

My code
from beeprint import pp pp({1:'string'})
On running it i get an error:

Traceback (most recent call last):
  File "/home/src/Coelus-LLC/coelus/work_2.py", line 13, in <module>
    pp(nss)
  File "/home/src/Coelus-LLC/coelus/.env/lib/python3.8/site-packages/beeprint/printer.py", line 66, in pp
    res = str(Block(config, Context(obj=o)))
  File "/home/src/Coelus-LLC/coelus/.env/lib/python3.8/site-packages/beeprint/models/block.py", line 42, in __str__
    return self.build_block()
  File "/home/src/Coelus-LLC/coelus/.env/lib/python3.8/site-packages/beeprint/models/block.py", line 142, in build_block
    ret += str(ListBlock(self.config, self.ctx))
  File "/home/src/Coelus-LLC/coelus/.env/lib/python3.8/site-packages/beeprint/models/block.py", line 42, in __str__
    return self.build_block()
  File "/home/src/Coelus-LLC/coelus/.env/lib/python3.8/site-packages/beeprint/models/block.py", line 372, in build_block
    ret += str(Block(self.config, ctx))
  File "/home/src/Coelus-LLC/coelus/.env/lib/python3.8/site-packages/beeprint/models/block.py", line 42, in __str__
    return self.build_block()
  File "/home/src/Coelus-LLC/coelus/.env/lib/python3.8/site-packages/beeprint/models/block.py", line 139, in build_block
    ret += str(DictBlock(self.config, self.ctx))
  File "/home/src/Coelus-LLC/coelus/.env/lib/python3.8/site-packages/beeprint/models/block.py", line 42, in __str__
    return self.build_block()
  File "/home/src/Coelus-LLC/coelus/.env/lib/python3.8/site-packages/beeprint/models/block.py", line 312, in build_block
    ret += str(PairBlock(self.config, ctx))
  File "/home/src/Coelus-LLC/coelus/.env/lib/python3.8/site-packages/beeprint/models/block.py", line 42, in __str__
    return self.build_block()
  File "/home/src/Coelus-LLC/coelus/.env/lib/python3.8/site-packages/beeprint/models/block.py", line 501, in build_block
    ret += str(Block(self.config, ctx))
  File "/home/src/Coelus-LLC/coelus/.env/lib/python3.8/site-packages/beeprint/models/block.py", line 42, in __str__
    return self.build_block()
  File "/home/src/Coelus-LLC/coelus/.env/lib/python3.8/site-packages/beeprint/models/block.py", line 139, in build_block
    ret += str(DictBlock(self.config, self.ctx))
  File "/home/src/Coelus-LLC/coelus/.env/lib/python3.8/site-packages/beeprint/models/block.py", line 42, in __str__
    return self.build_block()
  File "/home/src/Coelus-LLC/coelus/.env/lib/python3.8/site-packages/beeprint/models/block.py", line 312, in build_block
    ret += str(PairBlock(self.config, ctx))
  File "/home/src/Coelus-LLC/coelus/.env/lib/python3.8/site-packages/beeprint/models/block.py", line 42, in __str__
    return self.build_block()
  File "/home/src/Coelus-LLC/coelus/.env/lib/python3.8/site-packages/beeprint/models/block.py", line 501, in build_block
    ret += str(Block(self.config, ctx))
  File "/home/src/Coelus-LLC/coelus/.env/lib/python3.8/site-packages/beeprint/models/block.py", line 42, in __str__
    return self.build_block()
  File "/home/src/Coelus-LLC/coelus/.env/lib/python3.8/site-packages/beeprint/models/block.py", line 139, in build_block
    ret += str(DictBlock(self.config, self.ctx))
  File "/home/src/Coelus-LLC/coelus/.env/lib/python3.8/site-packages/beeprint/models/block.py", line 42, in __str__
    return self.build_block()
  File "/home/src/Coelus-LLC/coelus/.env/lib/python3.8/site-packages/beeprint/models/block.py", line 312, in build_block
    ret += str(PairBlock(self.config, ctx))
  File "/home/src/Coelus-LLC/coelus/.env/lib/python3.8/site-packages/beeprint/models/block.py", line 42, in __str__
    return self.build_block()
  File "/home/src/Coelus-LLC/coelus/.env/lib/python3.8/site-packages/beeprint/models/block.py", line 516, in build_block
    ret += self.ctn.write(ustr(" ") + str(rb) + ustr(tail + block_ending))
  File "/home/src/Coelus-LLC/coelus/.env/lib/python3.8/site-packages/beeprint/models/block.py", line 42, in __str__
    return self.build_block()
  File "/home/src/Coelus-LLC/coelus/.env/lib/python3.8/site-packages/beeprint/models/block.py", line 591, in build_block
    return handler(self.ctx, self.typ)
  File "/home/src/Coelus-LLC/coelus/.env/lib/python3.8/site-packages/beeprint/models/block.py", line 710, in __call__
    return self.rearrenge(ctx, typ, wrapper)
  File "/home/src/Coelus-LLC/coelus/.env/lib/python3.8/site-packages/beeprint/models/block.py", line 720, in rearrenge
    left_margin = calc_left_margin(ctx, wrapper)
  File "/home/src/Coelus-LLC/coelus/.env/lib/python3.8/site-packages/beeprint/helpers/string.py", line 54, in calc_left_margin
    left_margin = calc_width(left_filling)
  File "/home/src/Coelus-LLC/coelus/.env/lib/python3.8/site-packages/beeprint/helpers/string.py", line 17, in calc_width
    return urwid.str_util.calc_width(s, 0, len(s))
AttributeError: module 'urwid' has no attribute 'str_util'

python 3.8.5
linux mint os

installed packages:
beeprint==2.4.10
urwid==2.1.2

P.s. i found a workaround just by by renaming urwid/old_str_utils.py to urwid/str_util

@SmartManoj
Copy link

@JustMegaAlex also propose a PR

@fatemegh98
Copy link

Hi @JustMegaAlex
Can you tell me if you solved your issue? I have the same issue as you.

MohammadRimawi added a commit to MohammadRimawi/beeprint that referenced this issue Feb 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants