Skip to content

Instantly share code, notes, and snippets.

Last active August 29, 2015 14:00
What would you like to do?
import os
import editor
save this file in the root directory of your script library, and add
the action work_on
WK_PATH = './_working_on_'
WK_CONTENT = '''import editor
if True: # if len(sys.argv) == 1 and sys.argv[1] == 'add'
file_path = '/private%s' % editor.get_path()
cwd_path = os.getcwd()
relative_path = file_path[len(cwd_path)+1:]
file_segments_3 = ':'.join(relative_path.split('/')[-3:])
if not os.path.exists(WK_PATH):
wk_file = '%s/%s/%s' % (cwd_path, WK_PATH, file_segments_3)
wk_file = wk_file.replace('/./', '/')
if not os.path.exists(wk_file):
#, wk_file) # hardlinks don't work
f = open(wk_file, 'w+')
f.write(WK_CONTENT % file_path)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment