Sublime Forum

ST3: ExportHtml

#20

Yeah, breaking up the bbcode tags so the content doesnā€™t get parsed as markup by the forum ā€¦ and get all fucked up colors and missing content ā€¦

0 Likes

#21

[quote=ā€œcastles_made_of_sandā€]https://github.com/sublimator/EditPreferences/blob/master/helpers.py

I got some crap there for getting files ā€¦ not very coherent as itā€™s first pass code as working through understanding ST3 implications ā€¦

I had my own package globbing function which returns paths with /$Package.sublime-package/ if itā€™s a zip file ā€¦

Didnā€™t really come across a case like today when getting a package normalised path from the api that doesnā€™t imply much ā€¦[/quote]

Cool, I will take a look at your stuff. I would like to leverage the work of dealing with package paths instead of wasting time doing it all myself from scratch. I just dont have the motivation right now :smile:.

0 Likes

#22

hrmm, maybe between the 3 of us we can extract a module that works in all cases and isnā€™t too stupid inefficient

Packages/PackageName/Asset.ext
/Abspath/Packages/PackageName/Asset.ext
/Abspath/Packages/PackageName.sublime-package/Asset.ext

I guess each of these could somehow come from the following:

(sublime.packages_path(), sublime.installed_packages_path(), os.path.dirname(sublime.executable_path()))

I might start with extracting just path helper stuff into a new module/repo

0 Likes

#23

Iā€™m doing some testing of it now. Iā€™ll post here in a little bit. How Iā€™m writing it now, you can return either the content of the file being searched for, or it will be extracted to a temp directory and the path will be returned.

0 Likes

#24

[pre=#0C1021]ST2 = sublime.version():1] == ā€˜2ā€™
ST3 = not ST2
[/pre]

I got as far as declaring some constants, then went FUCK THIS, hahaha

Death to ST2 I say!

0 Likes

#25

Cool, I might take @faceless lead and sit this one out too :smile:

0 Likes

#26

Uploads the .pyc file to github Ha take that! :smiley: Alright Iā€™d feel to mean doing that so that would never happen.

0 Likes

#27

[quote=ā€œcastles_made_of_sandā€]
Cool, I might take @faceless lead and sit this one out too :smile:[/quote]

Sitā€™n is where itā€™s at :smile:.

0 Likes

#28

[quote=ā€œfacelessuserā€]

[quote=ā€œcastles_made_of_sandā€]
Cool, I might take @faceless lead and sit this one out too :smile:[/quote]

Sitā€™n is where itā€™s at :smile:.[/quote]

Here you go you sitā€™nā€¦ers? :smiley: If you come across any issues or can think of any improvements, let me know.

gist.github.com/skuroda/4965913

0 Likes

#29

Sitting down @ linux-st3 land :smile:

0 Likes

#30

Looks good :smile:

Python 3 AFAIK seems to auto magically open(f).read() as unicode, defaulting to utf8

Defaulting to utf8 might not hurt, but having a possibility to consistently get bytes back might be nice ā€¦

0 Likes

#31

I think zipfile.ZipFile.read, on the other hand, will always return bytes, even on python 3?

0 Likes

#32
def get_package_asset(package_name, file_name, get_path=False):

Iā€™d like to make a feature request ( bloody rich right?? :smile:

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]>>> import Default.sort

Default.sort.file
ā€˜/home/nick/sublime_text_3/Packages/Default.sublime-package/sort.pyā€™
[/code]

0 Likes

#33

[quote=ā€œcastles_made_of_sandā€]def get_package_asset(package_name, file_name, get_path=False):

Iā€™d like to make a feature request ( bloody rich right?? :smile:

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]>>> import Default.sort

Default.sort.file
ā€˜/home/nick/sublime_text_3/Packages/Default.sublime-package/sort.pyā€™
[/code][/quote]

Iā€™ll take a look at the things you mentioned. If you insist, I suppose I will be a helpful developer and add that :smile:

0 Likes

#34

I really must insist :smile: I demand satisfaction haha

0 Likes

#35

@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 :smile:. I like his suggestion though.

0 Likes

#36

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.

0 Likes

#37

os.path.exists

0 Likes

#38

Letā€™s pretend that I did that originally :smile: 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. :blush:

0 Likes

#39

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()

0 Likes