Sublime Forum

ST3: ExportHtml

#63

[quote=“castles_made_of_sand”]
I think you can boil down the code to pretty much that, which will return None implicitly if nothing is found.[/quote]

Nothing wrong with simplifying…but I can’t stand implicit Nones. It makes it so clear that that is actually the intent to actually return a None for clarity sake. I know this is stylistic and all…just saying…

0 Likes

#64

Fair enough :smile: Excuse the tasteless bike-shedding :blush:

I find it clearer in that particular case but to each their own

0 Likes

#65

This bike-shedding proven pretty constructive for me anyway, noticed some bugs in the gist code, and the edit preferences code.

I’m going to merge ideas/insights from both of them and slap some unit tests on em at some point.

0 Likes

#66

There seems to be a bug with path return. If path was not recursive, you would return the path as a boolean. I have fixed it below.

[pre=#2D2D2D]def get_package_asset(package_name, file_name, get_path=False, recursive_search=False):
packages_path = sublime.packages_path()
sublime_package = package_name + “.sublime-package”
path = None

if os.path.exists(os.path.join(packages_path, package_name)):
    if recursive_search:
        path = _find_file(os.path.join(packages_path, package_name), file_name)
    elif os.path.exists(os.path.join(packages_path, package_name, file_name)):
        path = os.path.join(packages_path, package_name, file_name)[/pre]
0 Likes

#67

bike-shedding, that was a new one for me; had to consult google :smile:. Yeah, I try not to get too invested in my stylistic opinions. Usually, I throw it out there and if people ignore it, I shrug it off. I realize my opinion doesn’t govern the world :smile:.

0 Likes

#68

github.com/sublimator/PackageRe … sources.py

My shed got purple :smile:

0 Likes

#69

[quote=“castles_made_of_sand”]https://github.com/sublimator/PackageResources/blob/master/package_resources.py

My shed got purple :smile:[/quote]

Cool. I will give it a try.

0 Likes

#70

Send us a pull request when you find bugs or add features eh …

The globber aint finished btw …

0 Likes

#71

[quote=“facelessuser”]I do do a number of score selectors, but not as many as you would think.

I grab the scope name from the selection and then compare all of the theme scopes with score_selector. Once I determine the best matches, I add the scope name with the best theme scope matches for foreground, background, etc. to the dictionary and never have to run score_selector on the same scope again.

I don’t notice much of a difference with the ST2 version and the ST3 version for this plugin.[/quote]

That’s a clever use of memoization :smiley:

0 Likes

#72

[quote=“facelessuser”]There seems to be a bug with path return. If path was not recursive, you would return the path as a boolean. I have fixed it below.
[/quote]

Woops, that was bad. :blush:

Is it possible to have assets outside of one of the sublime text paths (as specified in the following test)

r2 = (tc("/Abs/Packages/ZipPseudo.sublime-package/nested/sort.py"))

Made a couple updates. Used walk’s recursion rather than my own. get_package_and_asset_name should now

0 Likes

#73

Think I’ve taken everything that has been mentioned. get_package_asset now defaults to returning files UTF-8 encoded. In addition, there are two new parameters, a boolean to return the data in it’s binary form (default false) and a string for encoding type (default utf-8).

0 Likes

#74

[quote=“skuroda”]
Is it possible to have assets outside of one of the sublime text paths (as specified in the following test)

CODE: SELECT ALL
r2 = (tc("/Abs/Packages/ZipPseudo.sublime-package/nested/sort.py"))[/quote]

I don’t think so, not meaningfully anyway. If your routine relies on removing the install path prefixes just kill the test case.

In contrast to a path like Packages/Yes/no.yes

Abs there was just symbolic of an absolute path to the executable folder or installed_packages_path()

0 Likes

#75

**“De”**coded

gist.github.com/skuroda/4965913 … set-py-L62
Not sure if you wanted this to work on ST2 as well as ST3, but afaik, the open builtin on python2 doesn’t take an encoding kwarg.

I think codecs.open, on the other hand, works :smile:

encoding String representing the encoding to use when reading. Only takes affect when return_binary is True (default utf-8).
I think that was meant to be when return binary is False

0 Likes

#76

Okay fine UTF-8 decoded by default. :smile: Yup definitely should be False. Hmm I should fix that, no reason this shouldn’t work for ST2 and 3. I guess if I was thinking beforehand I would have written something like this earlier. I should take a closer look at your PackageResources stuff. It’s probably a lot better than mine. Though if I only wrote code where it was better than everyone else’s, well I wouldn’t be writing very much. And that’s no fun. Thanks for all the feedback.

0 Likes

#77

I stole some of your ideas :smile:

There’s some other functionality in there (that I eventually want to finish … one of these days ) re: globbing

Was doing flat globbing until you made me realize that settings / keymaps could be nested.

re: package assets:

Turn on sublime.log_commands(True) and run the menu item Preferences -> Default keybindings

Take note of the command and args.

You can use that ${packages}/Path/to.file form to open package assets, be they zipped or not. If they zipped they are open in read only mode.

Dunno if that’s interesting to you for anything but I think it’s kinda neat.

0 Likes

#78

Everybody’s stuff seems to work great for what I am doing. I didn’t really have to do anything…I could get used to this :smile:. I will probably roll out a new ExportHtml rev tomorrow. Got too much stuff tonight going on.

0 Likes

#79

[quote=“castles_made_of_sand”]
Turn on sublime.log_commands(True) and run the menu item Preferences -> Default keybindings

Take note of the command and args.

You can use that ${packages}/Path/to.file form to open package assets, be they zipped or not. If they zipped they are open in read only mode.

Dunno if that’s interesting to you for anything but I think it’s kinda neat.[/quote]

That is interesting. I have to say, I’m glad ST3 was updated to make those files read only if they were read from sublime-packages.

Haha. Don’t tell me you want to try to do something like this person did (link)

0 Likes

#80

[quote=“skuroda”]
Haha. Don’t tell me you want to try to do something like this person did (link)[/quote]

That sounds awesome…if only I could get away with it… :smile:.

0 Likes

#81

New version published with the ability to find color schemes in zip files. Thanks everyone for your contributions.

0 Likes

#82

Looks like a couple of my plugins don’t work when they are archived as .sublime-package. This should be fixed for ExportHtml now.

0 Likes