benschwarz / sublime-bower

Install Bower packages from within Sublime
MIT License
226 stars 12 forks source link

Changes for ST3 #8

Closed pahlers closed 11 years ago

pahlers commented 11 years ago

Here are changes for ST3. First draft. It kills the version for ST2, so please don't merge.

I didn't test it really well. It would be nice if you included a unit test ;-). 'jQuery' and 'ace' downloaded very well. '666' went wrong. I didn't figure out why. Maybe you can.

benschwarz commented 11 years ago

Thanks Peter, I'll check the changes against st2. I don't have a license for 3 yet, I'd never bothered to upgrade. — Sent from Mailbox for iPhone

On Tue, Apr 2, 2013 at 7:09 PM, Peter Ahlers (eonlepapillon) notifications@github.com wrote:

Here are changes for ST3. First draft. It kills the version for ST2, so please don't merge. I didn't test it really well. It would be nice if you included a unit test ;-). 'jQuery' and 'ace' downloaded very well. '666' went wrong. I didn't figure out why. Maybe you can.

benschwarz commented 11 years ago

As you'll note, I totally restructured the codebase — hopefully its a step to making it more maintainable now that I've hacked out that all important first working version.

I'll come back around to trying to implement your changes, or seeing what we can do to make it work in both ST2 & 3 at once.

… at a high level, can you explain why its not working in ST3?

pahlers commented 11 years ago

Some packages renamed and/or have other structures:

urllib got another structure: First:

urllib2.urlopen()
urllib2.Request()

Now:

urllib.request.urlopen()
urllib.request.Request()

You can solve these with the next pattern:

try:
    # Python 3
    from io import StringIO 
except ImportError:
    # Python 2
    from StringIO import StringIO

Example:

try:
    # Python 3
    import urllib.request as req
except ImportError:
    # Python 2
    import urllib2 as req

try:
    # Python 3
    from io import StringIO 
except ImportError:
    # Python 2
    from StringIO import StringIO

request = req.Request(uri)
respons = req.urlopen(request)
benschwarz commented 11 years ago

Great. I'll consider all of that and have a go at working on ST3. I downloaded a copy and got started, but right now I'm getting

reloading plugin Bower.Bower
Traceback (most recent call last):
  File "/Volumes/Sublime Text/Sublime Text.app/Contents/MacOS/sublime_plugin.py", line 72, in reload_plugin
    m = importlib.import_module(modulename)
  File "X/importlib/__init__.py", line 88, in import_module
  File "<frozen importlib._bootstrap>", line 1577, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1558, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1525, in _find_and_load_unlocked
  File "/Users/benschwarz/Library/Application Support/Sublime Text 3/Installed Packages/Bower.sublime-package/Bower.py", line 5, in <module>
ImportError: No module named 'bower'

So I'll have to start from there and figure it out.

Thanks so much for your assistance so far!

On Wednesday, 3 April 2013 at 12:44 AM, Peter Ahlers (eonlepapillon) wrote:

Some packages renamed and/or have other structures: package urllib2 become urllib package StringIO become io

urllib got another structure: First:
urllib2.urlopen() urllib2.Request()

Now: urllib.request.urlopen() urllib.request.Request()

You can solve these with the next pattern: try: # Python 3 from io import StringIO except ImportError: # Python 2 from StringIO import StringIO

Example: try: # Python 3 import urllib.request as req except ImportError: # Python 2 import urllib2 as req try: # Python 3 from io import StringIO except ImportError: # Python 2 from StringIO import StringIO request = req.Request(uri) respons = req.urlopen(request)

— Reply to this email directly or view it on GitHub (https://github.com/benschwarz/sublime-bower/pull/8#issuecomment-15775658).

pahlers commented 11 years ago

I added a st2/3 example.

benschwarz commented 11 years ago

Legendary! That'll really help a lot - hopefully there won't be too much more to do.

On Wednesday, 3 April 2013 at 12:49 AM, Peter Ahlers (eonlepapillon) wrote:

I added a st2/3 example.

— Reply to this email directly or view it on GitHub (https://github.com/benschwarz/sublime-bower/pull/8#issuecomment-15775916).

benschwarz commented 11 years ago

ST3 continues to throw either throw module errors that make little sense, or doesn't throw any errors at all (and the plugin isn't seemingly available).

Any help here would be awesome folks

pahlers commented 11 years ago

Do you have a branch with the 'error' version?