Permalink
Browse files

Update v0.9:

  • Loading branch information...
1 parent 12d23e1 commit 450f5383475933a2caa325578c6bea5e54994806 @titoBouzout committed Jan 5, 2012
View
@@ -0,0 +1,39 @@
+[
+ {
+ "caption": "Preferences",
+ "mnemonic": "n",
+ "id": "preferences",
+ "children":
+ [
+ {
+ "caption": "Package Settings",
+ "mnemonic": "P",
+ "id": "package-settings",
+ "children":
+ [
+ {
+ "caption": "Side Bar",
+ "children":
+ [
+ {
+ "command": "open_file", "args":
+ {
+ "file": "${packages}/SideBarEnhancements/Side Bar.sublime-settings"
+ },
+ "caption": "Settings – Default"
+ },
+ {
+ "command": "open_file", "args":
+ {
+ "file": "${packages}/User/Side Bar.sublime-settings"
+ },
+ "caption": "Settings – User"
+ },
+ { "caption": "-" }
+ ]
+ }
+ ]
+ }
+ ]
+ }
+]
View
@@ -90,13 +90,11 @@
"children":
[
{ "caption": "Edit Project", "id": "side-bar-project-open-file", "command": "side_bar_project_open_file", "args": {"paths": []} },
- /*
- I successfully added the following functions but I'm unable to reload the project file
- */
{ "caption": "-", "id": "side-bar-project-open-file-separator" },
{ "caption": "Promote as Project Folder", "id": "side-bar-project-item-add", "command": "side_bar_project_item_add", "args": {"paths": []} },
{ "caption": "Exclude From Project", "id": "side-bar-project-item-exclude", "command": "side_bar_project_item_exclude", "args": {"paths": []} },
{ "caption": "-", "id": "side-bar-project-item-separator" },
+ { "caption": "Remove Folder from Project", "command": "remove_folder", "args": { "dirs": []} },
{ "command": "prompt_add_folder", "caption": "Add Folder to Project…", "mnemonic": "d" }
]
@@ -0,0 +1,6 @@
+{
+ "statusbar_modified_time" : true,
+ "statusbar_modified_time_format" : "%A %b %d %H:%M:%S %Y",
+
+ "statusbar_file_size" : true
+}
View
@@ -7,6 +7,22 @@
from SideBarProject import SideBarProject
from Utils import uniqueList
+def disable_default():
+ default = sublime.packages_path()+'/Default/Side Bar.sublime-menu'
+ desired = sublime.packages_path()+'/SideBarEnhancements/disable_default/Side Bar.sublime-menu.txt'
+ if file(default, 'r').read() == file(desired, 'r').read():
+ file(default, 'w+').write('[/*'+file(desired, 'r').read()+'*/]')
+
+ default = sublime.packages_path()+'/Default/Side Bar Mount Point.sublime-menu'
+ desired = sublime.packages_path()+'/SideBarEnhancements/disable_default/Side Bar Mount Point.sublime-menu.txt'
+ if file(default, 'r').read() == file(desired, 'r').read():
+ file(default, 'w+').write('[/*'+file(desired, 'r').read()+'*/]')
+
+try:
+ disable_default();
+except:
+ pass
+
#NOTES
# A "directory" for this plugin is a "directory"
# A "directory" for a user is a "folder"
@@ -95,7 +111,7 @@ def run(self, paths = []):
"command": "side_bar_files_open_with",
"args": {
"paths": [],
- "application": "C:\\\\Archivos de programa\\\\Adobe\\\\Adobe Photoshop CS4\\\\Photoshop.exe",
+ "application": "Adobe Photoshop CS5.app", // OSX
"extensions":"psd|png|jpg|jpeg" //any file with these extensions
}
},
@@ -111,7 +127,7 @@ def run(self, paths = []):
"command": "side_bar_files_open_with",
"args": {
"paths": [],
- "application": "C:\\\\Archivos de programa\\\\SeaMonkey\\\\seamonkey.exe",
+ "application": "C:\\\\Archivos de programa\\\\SeaMonkey\\\\seamonkey.exe", // WINNT
"extensions":"" //open all even folders
}
},
@@ -781,21 +797,18 @@ def is_enabled(self, paths = []):
class SideBarDeleteCommand(sublime_plugin.WindowCommand):
def run(self, paths = []):
import sys
- if sys.platform == 'darwin':
+ try:
+ path = os.path.join(sublime.packages_path(), 'SideBarEnhancements')
+ if path not in sys.path:
+ sys.path.append(path)
+ import send2trash
+ for item in SideBarSelection(paths).getSelectedItemsWithoutChildItems():
+ send2trash.send2trash(item.path())
+ SideBarProject().refresh();
+ except:
import functools
self.window.run_command('hide_panel');
self.window.show_input_panel("Permanently Delete:", paths[0], functools.partial(self.on_done, paths[0]), None, None)
- else:
- try:
- sys.path.append(os.path.join(sublime.packages_path(), 'SideBarEnhancements'))
- import send2trash
- for item in SideBarSelection(paths).getSelectedItemsWithoutChildItems():
- send2trash.send2trash(item.path())
- SideBarProject().refresh();
- except:
- import functools
- self.window.run_command('hide_panel');
- self.window.show_input_panel("Permanently Delete:", paths[0], functools.partial(self.on_done, paths[0]), None, None)
def on_done(self, old, new):
self.remove(new)
@@ -850,28 +863,19 @@ def run(self, paths = []):
if project.hasOpenedProject():
for item in SideBarSelection(paths).getSelectedDirectories():
project.rootAdd(item.path())
- view = SideBarItem(project.getProjectFile(), False).edit();
- sublime.active_window().focus_view(view)
- sublime.set_timeout(lambda: sublime.active_window().run_command('save'), 250)
- sublime.set_timeout(lambda: sublime.active_window().run_command('close'), 400)
def is_enabled(self, paths = []):
- return False #SideBarSelection(paths).hasDirectories()
+ return SideBarSelection(paths).hasDirectories()
class SideBarProjectItemExcludeCommand(sublime_plugin.WindowCommand):
def run(self, paths = []):
project = SideBarProject()
if project.hasOpenedProject():
- file = project.getProjectFile()
for item in SideBarSelection(paths).getSelectedItems():
if item.isDirectory():
project.excludeDirectory(item.path())
else:
project.excludeFile(item.path())
- view = SideBarItem(file, False).edit();
- sublime.active_window().focus_view(view)
- sublime.set_timeout(lambda: sublime.active_window().run_command('save'), 250)
- sublime.set_timeout(lambda: sublime.active_window().run_command('close'), 400)
def is_enabled(self, paths = []):
- return False #len(paths) > 0
+ return len(paths) > 0
View
@@ -130,7 +130,9 @@ def open(self):
import subprocess
subprocess.Popen([self.nameSystem()], cwd=self.dirnameSystem(), shell=True)
else:
- sys.path.append(os.path.join(sublime.packages_path(), 'SideBarEnhancements'))
+ path = os.path.join(sublime.packages_path(), 'SideBarEnhancements')
+ if path not in sys.path:
+ sys.path.append(path)
import desktop
desktop.open(self.path())
View
@@ -18,11 +18,11 @@ def getDirectoryFromPath(self, path):
def getProjectFile(self):
import json
- data = json.loads(file(os.path.normpath(os.path.join(sublime.packages_path(), '..', 'Settings', 'Session.sublime_session')), 'rb').read())
+ data = json.loads(file(os.path.normpath(os.path.join(sublime.packages_path(), '..', 'Settings', 'Session.sublime_session')), 'r').read())
projects = data['workspaces']['recent_workspaces']
for project_file in projects:
project_file = re.sub(r'^/([^/])/', '\\1:/', project_file);
- folders = json.loads(file(project_file, 'rb').read())['folders']
+ folders = json.loads(file(project_file, 'r').read())['folders']
found_all = True
for directory in self.getDirectories():
found = False
@@ -41,23 +41,23 @@ def getProjectFile(self):
def excludeDirectory(self, path):
import json
project_file = self.getProjectFile();
- project = json.loads(file(project_file, 'rb').read())
+ project = json.loads(file(project_file, 'r').read())
path = re.sub(r'^([^/])\:/', '/\\1/', path.replace('\\', '/'))
for folder in project['folders']:
if path.find(folder['path']) == 0:
try:
- folder['folder_exclude_patterns'].append(path.replace(folder['path']+'/', '', 1)+'/')
+ folder['folder_exclude_patterns'].append(re.sub(r'/+$', '', path.replace(folder['path']+'/', '', 1)))
except:
- folder['folder_exclude_patterns'] = [path.replace(folder['path']+'/', '', 1)+'/']
- file(project_file, 'wb+').write(json.dumps(project, indent=1))
+ folder['folder_exclude_patterns'] = [re.sub(r'/+$', '', path.replace(folder['path']+'/', '', 1))]
+ file(project_file, 'w+').write(json.dumps(project, indent=1))
return
def excludeFile(self, path):
import json
project_file = self.getProjectFile();
- project = json.loads(file(project_file, 'rb').read())
+ project = json.loads(file(project_file, 'r').read())
path = re.sub(r'^([^/])\:/', '/\\1/', path.replace('\\', '/'))
@@ -67,21 +67,23 @@ def excludeFile(self, path):
folder['file_exclude_patterns'].append(path.replace(folder['path']+'/', '', 1))
except:
folder['file_exclude_patterns'] = [path.replace(folder['path']+'/', '', 1)]
- file(project_file, 'wb+').write(json.dumps(project, indent=1))
+ file(project_file, 'w+').write(json.dumps(project, indent=1))
return
def rootAdd(self, path):
import json
project_file = self.getProjectFile();
- project = json.loads(file(project_file, 'rb').read())
+ project = json.loads(file(project_file, 'r').read())
path = re.sub(r'^([^/])\:/', '/\\1/', path.replace('\\', '/'))
project['folders'].append({'path':path});
- file(project_file, 'wb+').write(json.dumps(project, indent=1))
+ file(project_file, 'w+').write(json.dumps(project, indent=1))
def refresh(self):
try:
+ sublime.set_timeout(lambda:sublime.active_window().run_command('refresh_folder_list'), 200);
sublime.set_timeout(lambda:sublime.active_window().run_command('refresh_folder_list'), 1300);
+ sublime.set_timeout(lambda:sublime.active_window().run_command('refresh_folder_list'), 2300);
except:
pass
View
0 SideBarSelection.py 100644 → 100755
No changes.
View
@@ -0,0 +1,18 @@
+import sublime, sublime_plugin
+from hurry.filesize import size
+from os.path import getsize
+
+s = sublime.load_settings('Side Bar.sublime-settings')
+
+class StatusBarFileSize(sublime_plugin.EventListener):
+
+ def on_load(self, v):
+ if s.get('statusbar_file_size') and v.file_name():
+ self.show(v, size(getsize(v.file_name())))
+
+ def on_post_save(self, v):
+ if s.get('statusbar_file_size') and v.file_name():
+ self.show(v, size(getsize(v.file_name())))
+
+ def show(self, v, size):
+ v.set_status('statusbar_file_size', size);
View
@@ -0,0 +1,19 @@
+import sublime, sublime_plugin, time
+from os.path import getmtime
+
+s = sublime.load_settings('Side Bar.sublime-settings')
+
+class StatusBarModifiedTime(sublime_plugin.EventListener):
+
+ def on_load(self, v):
+ if s.get('statusbar_modified_time') and v.file_name():
+ self.show(v, getmtime(v.file_name()))
+
+ def on_post_save(self, v):
+ if s.get('statusbar_modified_time') and v.file_name():
+ self.show(v, getmtime(v.file_name()))
+
+ def show(self, v, mtime):
+ v.set_status('statusbar_modified_time', time.strftime(s.get('statusbar_modified_time_format'), time.localtime(mtime)));
+
+
View
0 Utils.py 100644 → 100755
No changes.
@@ -0,0 +1,4 @@
+[
+ { "caption": "-", "id": "folder_commands" },
+ { "caption": "Remove Folder from Project", "command": "remove_folder", "args": { "dirs": []} }
+]
@@ -0,0 +1,11 @@
+[
+ { "caption": "New File", "command": "new_file_at", "args": {"dirs": []} },
+ { "caption": "Rename…", "command": "rename_path", "args": {"paths": []} },
+ { "caption": "Delete File", "command": "delete_file", "args": {"files": []} },
+ { "caption": "Open Containing Folder…", "command": "open_containing_folder", "args": {"files": []} },
+ { "caption": "-", "id": "folder_commands" },
+ { "caption": "New Folder…", "command": "new_folder", "args": {"dirs": []} },
+ { "caption": "Delete Folder", "command": "delete_folder", "args": {"dirs": []} },
+ { "caption": "Find in Folder…", "command": "find_in_folder", "args": {"dirs": []} },
+ { "caption": "-", "id": "end" }
+]
View
@@ -0,0 +1,71 @@
+Metadata-Version: 1.0
+Name: hurry.filesize
+Version: 0.9
+Summary: A simple Python library for human readable file sizes (or anything sized in bytes).
+Home-page: UNKNOWN
+Author: Martijn Faassen, Startifact
+Author-email: faassen@startifact.com
+License: ZPL 2.1
+Description: hurry.filesize
+ ==============
+
+ hurry.filesize a simple Python library that can take a number of bytes and
+ returns a human-readable string with the size in it, in kilobytes (K),
+ megabytes (M), etc.
+
+ The default system it uses is "traditional", where multipliers of 1024
+ increase the unit size::
+
+ >>> from hurry.filesize import size
+ >>> size(1024)
+ '1K'
+
+ An alternative, slightly more verbose system::
+
+ >>> from hurry.filesize import alternative
+ >>> size(1, system=alternative)
+ '1 byte'
+ >>> size(10, system=alternative)
+ '10 bytes'
+ >>> size(1024, system=alternative)
+ '1 KB'
+
+ A verbose system::
+
+ >>> from hurry.filesize import verbose
+ >>> size(10, system=verbose)
+ '10 bytes'
+ >>> size(1024, system=verbose)
+ '1 kilobyte'
+ >>> size(2000, system=verbose)
+ '1 kilobyte'
+ >>> size(3000, system=verbose)
+ '2 kilobytes'
+ >>> size(1024 * 1024, system=verbose)
+ '1 megabyte'
+ >>> size(1024 * 1024 * 3, system=verbose)
+ '3 megabytes'
+
+ You can also use the SI system, where multipliers of 1000 increase the unit
+ size::
+
+ >>> from hurry.filesize import si
+ >>> size(1000, system=si)
+ '1K'
+
+
+ Changes
+ =======
+
+ 0.9 (2009-03-11)
+ ----------------
+
+ * Initial public release.
+
+ Download
+ ========
+
+Keywords: file size bytes
+Platform: UNKNOWN
+Classifier: Programming Language :: Python
+Classifier: Topic :: Software Development :: Libraries :: Python Modules
Oops, something went wrong.

0 comments on commit 450f538

Please sign in to comment.