Coder Social home page Coder Social logo

powrap does not work on Windows about powrap HOT 5 OPEN

afpy avatar afpy commented on August 19, 2024 1
powrap does not work on Windows

from powrap.

Comments (5)

JulienPalard avatar JulienPalard commented on August 19, 2024

Hi! Thanks for reporting!

Can you try this patch:

diff --git a/powrap/powrap.py b/powrap/powrap.py
index 17be2f1..d6f515f 100644
--- a/powrap/powrap.py
+++ b/powrap/powrap.py
@@ -48,7 +48,7 @@ def fix_style(po_files, no_wrap=False, quiet=False):
     for po_path in tqdm(po_files, desc="Fixing wrapping of po files", disable=quiet):
         with open(po_path, encoding="UTF-8") as po_file:
             po_content = po_file.read()
-        args = ["msgcat", "-", "-o", po_path]
+        args = ["msgcat", "-", "-o", str(po_path)]
         if no_wrap:
             args[1:1] = ["--no-wrap"]
         try:

I think it's more a Python 3.6 issue than a Windows issue (but I'm surprised you have msgcat on windows :p)

from powrap.

yeyeto2788 avatar yeyeto2788 commented on August 19, 2024

Thanks for the quick reply @JulienPalard

I actually didn't install msgcat so it is weird. I did try your patch and it actually "worked" not raising any exception except for these messages:

(venv) C:\Users\yeyeto2788\workspace\python-docs-es>powrap .\library\othergui.po
Error running msgcat - -o library\othergui.po: [WinError 2] The system cannot find the file specified
Fixing wrapping of po files:   0%|                                                                                                                                                            | 0/1 [00:00<?, ?it/s]

(venv) C:\Users\yeyeto2788\workspace\python-docs-es>powrap C:\Users\yeyeto2788\workspace\python-docs-es\library\abc.po
Error running msgcat - -o C:\Users\yeyeto2788\workspace\python-docs-es\library\abc.po: [WinError 2] The system cannot find the file specified
Fixing wrapping of po files:   0%|    

IMHO this might be somehow expected since I do not have msgcat installed but it is weird having the progress bar stuck on the bottom and the error above the bar.

Seems like the actual error is because when it tries to execute the command and it does not find msgcat, but the .po file exists and checks are passed on line https://github.com/JulienPalard/powrap/blob/master/powrap/powrap.py#L68

from powrap.

JulienPalard avatar JulienPalard commented on August 19, 2024

Yes, that's because you don't have msgcat.

Some people and I are sometimes trying to get rid of this dependency, as we know it's not trivial to get msgcat on Windows.

(I'm starting to think having a textwrap lib in Python implementing https://www.unicode.org/reports/tr14/tr14-45.html would be great.)

Another way to properly indent a .po file in the meantime would be to use poedit (open the file whithin poedit, save, close), which itself uses the same algorithm as msgcat, so it wraps like powrap. The default configuration is the right one (79 chars per line, something like that), yet you may have to check a box like "rewrap even if I did not modified the file" in the settings to encourage it to actually rewrap the file, IIRC it's not by default.

from powrap.

yeyeto2788 avatar yeyeto2788 commented on August 19, 2024

In the meantime, I used the library on Linux based OS on a VM and it worked flawlessly. Thank you very much for your suggestion on using poedit, I'll keep it in mind for the next time.

Do you think https://docs.python.org/3.5/library/textwrap.html does not implement somehow that? If there is anything I can help with just let me know.

I did a quick review of the code and I notice there are still lines belonging to the old dependency of msgcat command execution https://github.com/JulienPalard/powrap/blob/from_msgcat/powrap/powrap.py#L43

from powrap.

JulienPalard avatar JulienPalard commented on August 19, 2024

Do you think https://docs.python.org/3.5/library/textwrap.html does not implement somehow that? If there is anything I can help with just let me know.

No, that's not the same algorithm. I opened an issue about it: https://bugs.python.org/issue41975

I did a quick review of the code and I notice there are still lines belonging to the old dependency of msgcat command execution https://github.com/JulienPalard/powrap/blob/from_msgcat/powrap/powrap.py#L43

Yes, this is clearly WIP, not working, it's really just the beginning of a proof of concept which does not even really solve the problem: instead of having a dependency on msgcat, we have a dependency on libunistring.

from powrap.

Related Issues (13)

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.