Home Download Buy Blog Forum Support

First plugin attempt: confused on file/library import/includ

First plugin attempt: confused on file/library import/includ

Postby viisual on Wed Feb 22, 2012 1:07 am

I have a library, written in python, that I'd like to include with one of my plugins.

On my OSX machine, which I believe has python installed, I am able to get my plugin to work!
On my PC, I am not able too; I get errors that seem to indicate packages that don't exist (os, re, pkg_resources, sys)

My initial reaction is that; I simply don't have python installed and ST2 doesn't ship with any python libraries with it's interpreter aside from sublime and sublime_package.

If I am not able to get a library loaded into ST2, am I allowed to open files for input, reading.
viisual
 
Posts: 9
Joined: Tue Feb 21, 2012 3:21 pm

Re: First plugin attempt: confused on file/library import/includ

Postby C0D312 on Wed Feb 22, 2012 1:20 am

Sublime Text uses OSX's built-in version of Python.
On Windows (and I think Linux, too), Sublime Text uses a bundled version of Python 2.6.

There should not be an issue with importing os, re, or sys since I've used all of these in some of the plugins I've made. I've never used pkg_resources but I doubt that would cause a problem either.

>>>am I allowed to open files for input, reading.
Yes.

Could you tell me what error you're getting? What is displayed in the console (control + `)?
C0D312
 
Posts: 1063
Joined: Sun Jul 10, 2011 3:23 am

Re: First plugin attempt: confused on file/library import/includ

Postby viisual on Wed Feb 22, 2012 1:29 am

Thanks, I was being purposefully vague.

Code: Select all
Traceback (most recent call last):
  File ".\sublime_plugin.py", line 59, in reload_plugin
  File ".\setup.py", line 3, in <module>
    from setuptools import setup
ImportError: No module named setuptools


I believe this is just me importing wrong, circular or otherwise.
Code: Select all
Traceback (most recent call last):
  File ".\sublime_plugin.py", line 59, in reload_plugin
  File ".\DocDecorator.py", line 172, in <module>
    class FigletFont(object):
  File ".\DocDecorator.py", line 178, in FigletFont
    reMagicNumber = re.compile(r'^[tf]lf2.')
NameError: name 're' is not defined


The code I'm attempting to bundle in a package via: https://github.com/pwaller/pyfiglet
Code: Select all
from pyfiglet import Figlet


--

Edit: Solved the preceding errors. Narrowed it down to pck_resources not being available (I think) so the file input, file reading will need to be modified.

Edit 2: Pretty sure I have it working now. Here's some output:

Code: Select all
Two
            __             _         
      _____/ /_____  _____(_)__  _____
     / ___/ __/ __ \/ ___/ / _ \/ ___/
    (__  ) /_/ /_/ / /  / /  __(__  )
   /____/\__/\____/_/  /_/\___/____/ 
                                      
    tall


Going to finish it up now, thanks for the help.
viisual
 
Posts: 9
Joined: Tue Feb 21, 2012 3:21 pm

Re: First plugin attempt: confused on file/library import/includ

Postby Nachtwind on Wed Feb 22, 2012 5:33 pm

Hi,
I am really looking forward to this plugin to work: Its the only thing i miss at Sublime2. I love the minimap and having big comments would come just handy to find stuff easily with it.


Currently i have that
Code: Select all
Traceback (most recent call last):
  File ".\sublime_plugin.py", line 59, in reload_plugin
  File ".\DocDecorator.py", line 3, in <module>
    from pyfiglet import Figlet
  File ".\pyfiglet\__init__.py", line 65, in <module>
    class FigletFont(object):
  File ".\pyfiglet\__init__.py", line 70, in FigletFont
    reMagicNumber = re.compile(r'^[tf]lf2.')
NameError: name 're' is not defined

Problem.

Is there a quick fix for it available?
Nachtwind
 
Posts: 1
Joined: Wed Feb 22, 2012 5:30 pm

Re: First plugin attempt: confused on file/library import/includ

Postby viisual on Wed Feb 22, 2012 5:50 pm

I'm actively working on it, I promise.

Once it's available I'll be sure to post it.

I am now running into a logic issue... it was working fine at home but now, after converting to file i/o from pkg_resources, it's smushing and looking terrible on OSX.

This should be 'What Heck?':
Code: Select all
     _       ____          __     __  __          __  ___
    | |     / / /_  ____ _/ /_   / / / /__  _____/ /_/__ \
    | | /| / / __ \/ __ `/ __/  / /_/ / _ \/ ___/ //_// _/
    | |/ |/ / / / / /_/ / /_   / __  /  __/ /__/ ,<  /_/ 
    |__/|__/_/ /_/\__,_/\__/  /_/ /_/\___/\___/_/|_|(_)


Edit: It then became clear; I wasn't using fixed width font. /idiot
viisual
 
Posts: 9
Joined: Tue Feb 21, 2012 3:21 pm


Return to Plugin Development

Who is online

Users browsing this forum: No registered users and 9 guests