Winawer / bibbreviate

A python script to abbreviate journal names in a bib file using publicly available journal lists.
MIT License
4 stars 3 forks source link

Python 3 support #4

Open auxym opened 8 years ago

auxym commented 8 years ago

Attemping install through pip3 yields

[sudo] password for francis: 
Downloading/unpacking bibbreviate
  Downloading bibbreviate-0.1.1.tar.gz (70kB): 70kB downloaded
  Running setup.py (path:/tmp/pip-build-80l8xehi/bibbreviate/setup.py) egg_info for package bibbreviate

    warning: manifest_maker: MANIFEST.in, line 2: 'recursive-include' expects <dir> <pattern1> <pattern2> ...

Requirement already satisfied (use --upgrade to upgrade): setuptools in /usr/lib/python3/dist-packages (from bibbreviate)
Downloading/unpacking bibtexparser (from bibbreviate)
  Downloading bibtexparser-0.6.1.tar.gz
  Running setup.py (path:/tmp/pip-build-80l8xehi/bibtexparser/setup.py) egg_info for package bibtexparser

Installing collected packages: bibbreviate, bibtexparser
  Running setup.py install for bibbreviate
      File "/usr/local/lib/python3.4/dist-packages/src/bibbrev.py", line 20
        print "I'm sorry, but something is wrong."
                                                 ^
    SyntaxError: Missing parentheses in call to 'print'

    warning: manifest_maker: MANIFEST.in, line 2: 'recursive-include' expects <dir> <pattern1> <pattern2> ...

    Installing bibbrev script to /usr/local/bin
  Running setup.py install for bibtexparser

Successfully installed bibbreviate bibtexparser
Cleaning up...

As a short term goal, perhaps incompatibility with python 3 might be made explicit?

auxym commented 8 years ago

For what it's worth, I ran the script through autopep8 and 2to3 and tweaked some stuff, it seems to work fine on both python 2.7 and 3.4. Would you like me to submit a pull request? I'm also working on implementing fuzzy string matching (via fuzzywuzzy) and might be able to get it to run on windows. Let me know.

Winawer commented 8 years ago

Bah, sorry, I've been flooded with notifications and missed this one. If you've still got it, I'd be happy to take a pull request. Fire away!

auxym commented 8 years ago

Sorry, I'm a bit busy right now to prepare a proper PR. However, you can check out my fork, I fixed a few bugs. It runs on python 3.4, but I think it still needs a tiny bit of work to run on python 2 with the same code.

Mostly, using io.open instead of plain open, as to have the same behavior on 2/3 (that is, read returns unicode objects). It could use OS default encoding by default and provide a CLI switch to force a specific encoding.

Also, I think you'd need only replace that path concatenation with os.path.join to provide full windows compatibility.

Last thing, my fork has a branch where I started working on fuzzy-matching journal names, it seems to work ok, probably needs some more testing.