Home Download Buy Blog Forum Support

ST3: ExportHtml

Re: ST3: ExportHtml

Postby sublimator on Sat Feb 16, 2013 7:44 am

I think zipfile.ZipFile.read, on the other hand, will always return bytes, even on python 3?
It is better to remain silent and be thought a fool, than to speak out and remove all doubt
sublimator
 
Posts: 649
Joined: Thu Mar 20, 2008 5:41 am

Re: ST3: ExportHtml

Postby sublimator on Sat Feb 16, 2013 7:50 am

Code: Select all
def get_package_asset(package_name, file_name, get_path=False):


I'd like to make a feature request ( bloody rich right?? :)

I want another helper that will get some arbitrary path and determine the pakage_name/file_name from it so I can feed it to the get_package_asset guy

Code: Select all
>>> import Default.sort
>>> Default.sort.__file__
'/home/nick/sublime_text_3/Packages/Default.sublime-package/sort.py'
It is better to remain silent and be thought a fool, than to speak out and remove all doubt
sublimator
 
Posts: 649
Joined: Thu Mar 20, 2008 5:41 am

Re: ST3: ExportHtml

Postby skuroda on Sat Feb 16, 2013 7:52 am

castles_made_of_sand wrote:
Code: Select all
def get_package_asset(package_name, file_name, get_path=False):


I'd like to make a feature request ( bloody rich right?? :)

I want another helper that will get some arbitrary path and determine the pakage_name/file_name from it so I can feed it to the get_package_asset guy

Code: Select all
>>> import Default.sort
>>> Default.sort.__file__
'/home/nick/sublime_text_3/Packages/Default.sublime-package/sort.py'


I'll take a look at the things you mentioned. If you insist, I suppose I will be a helpful developer and add that :)
skuroda
 
Posts: 677
Joined: Fri Oct 05, 2012 8:11 am

Re: ST3: ExportHtml

Postby sublimator on Sat Feb 16, 2013 7:55 am

skuroda wrote:I'll take a look at the things you mentioned. If you insist, I suppose I will be a helpful developer and add that


I really must insist :) I demand satisfaction haha
It is better to remain silent and be thought a fool, than to speak out and remove all doubt
sublimator
 
Posts: 649
Joined: Thu Mar 20, 2008 5:41 am

Re: ST3: ExportHtml

Postby facelessuser on Sat Feb 16, 2013 7:56 am

@skuroda thanks for doing this. When I get off my butt tomorrow I am going to try this. Sounds like @castles is trying to keep you busy :). I like his suggestion though.
facelessuser
 
Posts: 1567
Joined: Tue Apr 05, 2011 7:38 pm

Re: ST3: ExportHtml

Postby sublimator on Sat Feb 16, 2013 7:59 am

https://gist.github.com/skuroda/4965913 ... set-py-L21

Also, you could probably cut to the chase there, just piecing together an absolute path, checking if the file exists, rather than doing two os.listdir() calls.
It is better to remain silent and be thought a fool, than to speak out and remove all doubt
sublimator
 
Posts: 649
Joined: Thu Mar 20, 2008 5:41 am

Re: ST3: ExportHtml

Postby sublimator on Sat Feb 16, 2013 8:01 am

os.path.exists
It is better to remain silent and be thought a fool, than to speak out and remove all doubt
sublimator
 
Posts: 649
Joined: Thu Mar 20, 2008 5:41 am

Re: ST3: ExportHtml

Postby skuroda on Sat Feb 16, 2013 8:09 am

castles_made_of_sand wrote:os.path.exists


Let's pretend that I did that originally :) I did it in the _search_zip method. Also added a method to get package and asset name from absolute path. Updates on the Gist .

Edit: err half way. Woops. :oops:
skuroda
 
Posts: 677
Joined: Fri Oct 05, 2012 8:11 am

Re: ST3: ExportHtml

Postby sublimator on Sat Feb 16, 2013 8:12 am

Another thing, generally you wanna use try/finally when using open() zipfile.ZipFile() etc

Python has `with` for that: `with open(bla) as file_handle: file_handle.read()`
It is better to remain silent and be thought a fool, than to speak out and remove all doubt
sublimator
 
Posts: 649
Joined: Thu Mar 20, 2008 5:41 am

Re: ST3: ExportHtml

Postby sublimator on Sat Feb 16, 2013 8:17 am

Code: Select all
def get_package_and_asset(path):
    package = os.path.basename(os.path.dirname(path))
    package = package.replace(".sublime-package", "")
    asset = os.path.basename(path)
    return (package, asset)


I want my money back! Oh wait, I didn't pay any nor do I really care about windows absolute paths!
It is better to remain silent and be thought a fool, than to speak out and remove all doubt
sublimator
 
Posts: 649
Joined: Thu Mar 20, 2008 5:41 am

PreviousNext

Return to Plugin Announcements

Who is online

Users browsing this forum: No registered users and 6 guests