Home Download Buy Blog Forum Support

ST3: ExportHtml

Re: ST3: ExportHtml

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

I meant more this guy:

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)


That helper doesn't handle nested paths too well.

Your get_package_asset function should have worked with nested files before, if I'm not mistaken :)
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 10:11 am

Ah I see. I will...get back on that. Ha. No I don't think it would. I was just looking at the top level package directory, so anything nested would have been missed. I was...umm..testing you to make sure you saw the problem too? Yea let's go with that :D
skuroda
 
Posts: 676
Joined: Fri Oct 05, 2012 8:11 am

Re: ST3: ExportHtml

Postby skuroda on Sat Feb 16, 2013 10:20 am

Unless you meant specifying the entire asset path, then yes it would have. In fact, maybe I should go back to that.

Edit:
So get_package_and_asset_name handles recursive files. I've added a parameter to get_package_asset to do the recursive search (defaults to false). I was thinking this may be useful if nested folders are allowed for settings. I think I've seen a post on this forum related to something like that.
skuroda
 
Posts: 676
Joined: Fri Oct 05, 2012 8:11 am

Re: ST3: ExportHtml

Postby sublimator on Sat Feb 16, 2013 11:54 am

Sorry, was out getting dinner. So it will search for a given base file name anywhere in a zip/folder?

Can't imagine when I'd want that really.

Mostly I just want ability to get things like `dict(pkg='Murky', relative_path='waters/salty/green.color')`

Will look over latest incarnation
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 11:57 am

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 12:07 pm

https://gist.github.com/skuroda/4965913 ... et-py-L125

os.walk should in essence recurse by itself I think

I know the __doc__ for `get_package_and_asset_name` says "This method will return
the package name and asset name from an absolute path" but it would be nice if
it was able to handle paths as returned by things like:

Code: Select all
>>> view.settings().get('syntax')
'Packages/Python/Python.tmLanguage'
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 12:12 pm

It should do what you want (though test it to make sure). I did some and it appears to extract the package and path properly. The recursive thing was more of a me thinking of something else when you said nested files. Though if sublime text allows for nested directories, someone may define a keymap file not at the top level. Of course, this doesn't affect your stuff. I may go back and just take it out. If Sublime Text allows the nested structure at some point, I can re add it. With that being said, I'm done for tonight. I'll check back tomorrow for feedback.

Ha yup. Do you know of any reason not to do that? I've never had a reason to open files as binary in python, so I'm not sure it's 100% safe.

Hmm, I didn't think it did when I test it, or maybe I just wasn't paying attention. And yes I wasn't paying attention. Sad...maybe that's fatigue setting in.

Side notes:
Hmm, great how export html was only discussed on say....the first 20 posts in this thread, but it's all related. And as a random note...apparently the Sublime Text team is at least 2 people (the latest blog post isn't from Jon).
skuroda
 
Posts: 676
Joined: Fri Oct 05, 2012 8:11 am

Re: ST3: ExportHtml

Postby sublimator on Sat Feb 16, 2013 12:24 pm

>>> someone may define a keymap file not at the top level

Ah, I see why you wanted it now
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 12:26 pm

skuroda wrote:apparently the Sublime Text team is at least 2 people (the latest blog post isn't from Jon).


Yes, this is a very recent thing. Jon will be mentioning more on that pretty soon I'd imagine.
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 12:31 pm

skuroda wrote: I've never had a reason to open files as binary in python, so I'm not sure it's 100% safe.


Well, for this, I think you'd probably want it to default to return unicode text, with an option to get it binary.

In any case, the main thing is that it should be consistent.

A user of `get_package_asset` probably just wants something consistent, whether it be ST2/ST3, some partial contents from a zip, or complete contents from a file.

In sublime 2, the open() returns str() which is essentially the bytes() from python 3.

Sublime 3, with python 3, on the other hand, returns str() which is essentially unicode() from python 2.

zipfile seems to return raw bytes in python 2/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

PreviousNext

Return to Plugin Announcements

Who is online

Users browsing this forum: No registered users and 4 guests