def __call__(self): show_status_message('Launching a Mask Script...') if os.path.isfile(as_human_readable(self.pane.get_path()) + os.path.sep + 'package.json'): npmPackagePath = as_human_readable(self.pane.get_path()) + os.path.sep + 'maskfile.md' npmPackagePtr = open(npmPackagePath,"r") npmPackage = json.loads(npmPackagePtr.read()) npmPackagePtr.close() result = show_quicksearch(self._suggest_script) if result: # # Launch the script given. Show the output. # query, script = result # # Get the variables for this plugin # scriptVars = _GetScriptVars() # # Run the script. # saveDir = os.getcwd() os.chdir(as_human_readable(self.pane.get_path()) + os.path.sep) Output = run("source " + scriptVars['local_shell'] + "; mask " + script,stdout=PIPE,shell=True) os.chdir(saveDir) if Output.returncode == 0: if scriptVars['show_output']: show_alert(Output.stdout.decode("utf-8")) else: show_alert("Command line error.") else: show_alert("Not a Mask project directory.") clear_status_message()
def __call__(self, use_regex=False): result = show_quicksearch(self._get_items) if result: query, value = result if value: value = as_url(value) self.pane.set_path(dirname(value))
def __call__(self): show_status_message('Regular Expressions Selection') result = show_quicksearch(self._suggest_projects) if result: query, regexp = result try: pattern = re.compile(regexp) except Exception as e: show_alert('Your Regular Expression statement is not valid.' + str(e)) self.__call__() return used = False lines = [""] if os.path.isfile(REGULAREXPRESSIONHIST): with open(REGULAREXPRESSIONHIST, "r") as f: lines = f.readlines() for line in lines: if line.strip() == regexp: used = True if not used: with open(REGULAREXPRESSIONHIST, "a") as f: f.write(regexp + "\n") scheme, currentDir = splitscheme(self.pane.get_path()) for filep in iterdir(self.pane.get_path()): if pattern.search(filep): self.pane.toggle_selection( as_url(currentDir + os.sep + filep, scheme)) clear_status_message()
def __call__(self): show_status_message('Launching a Script...') result = show_quicksearch(self._suggest_script) if result: # # Launch the script given. Show the output. # query, script = result # # Get the variables for this plugin # scriptVars = _GetScriptVars() # # Get a list of selected files. # selected_files = self.pane.get_selected_files() if len(selected_files) >= 1 or (len(selected_files) == 0 and self.get_chosen_files()): if len(selected_files) == 0 and self.get_chosen_files(): selected_files.append(self.get_chosen_files()[0]) fileList = '' first = True for file in selected_files: if first: fileList += as_human_readable(file) else: fileList += ',' + as_human_readable(file) # # Set the environment variables for the scripts to use. # os.putenv('CURRENT_DIRECTORY', as_human_readable(self.pane.get_path())) panes = self.pane.window.get_panes() os.putenv('LEFT_PANE', as_human_readable(panes[0].get_path())) path = panes[0].get_file_under_cursor() if path is not None: os.putenv('LEFT_PANE_SELECTED_FILE',as_human_readable(path)) else: os.putenv('LEFT_PANE_SELECTED_FILE',"") os.putenv('RIGHT_PANE', as_human_readable(panes[1].get_path())) path = panes[1].get_file_under_cursor() if path is not None: os.putenv('RIGHT_PANE_SELECTED_FILE',as_human_readable(path)) else: os.putenv('RIGHT_PANE_SELECTED_FILE',"") os.putenv('FILES_SELECTED',fileList) # # Run the script. # Output = run("source " + scriptVars['local_shell'] + "; '" + scriptVars['directory'] + "/" + script + "'",stdout=PIPE,shell=True) if Output.returncode == 0: if scriptVars['show_output']: show_alert(Output.stdout.decode("utf-8")) else: show_alert("Command line error.") clear_status_message()
def __call__(self): result = show_quicksearch(self._get_items) if result and result[1]: # Fetch bookmarks to connect to the default path bookmarks = \ load_json('FTP Bookmarks.json', default={}) bookmark = bookmarks[result[1]] url = urlparse(result[1])._replace(path=bookmark[1]).geturl() self.pane.set_path(url)
def __call__(self): self.current_dir = self.pane.get_path() result = show_quicksearch(self._suggest_my_subfolders_and_files) if result: query, file_path = result new_path = dirname(file_path) thePane = self.pane self.pane.set_path( as_url(new_path), lambda: thePane.place_cursor_at(as_url(file_path)))
def __call__(self): """ handle quick search call """ result = show_quicksearch(self._suggest_my_files_and_folders) if result: query, file_path = result # show_alert('file://' + file_path) # current_path = self.normalize_path_name(self.pane.get_path()) # relative_path = file_path[len(current_path) + 1:] # show_alert(current_path) # show_alert(relative_path) self.pane.place_cursor_at(self.file_prefix + file_path)
def __call__(self): result = show_quicksearch(self._get_items) if result and result[1]: choice = show_alert('Are you sure you want to delete "%s"' % (result[1], ), buttons=YES | NO, default_button=NO) if choice == YES: bookmarks = \ load_json('FTP Bookmarks.json', default={}, save_on_quit=True) bookmarks.pop(result[1], None)
def __call__(self): show_status_message('Project Selection') result = show_quicksearch(self._suggest_projects) if result: query, projectName = result if os.path.isfile(PROJECTSLIST): with open(PROJECTSLIST, "r") as f: projects = f.readlines() for projectTuple in projects: parts = projectTuple.split('|') if parts[0].strip() == projectName: self.pane.set_path(as_url(parts[1].strip())) clear_status_message()
def __call__(self): self.current_dir = self.pane.get_path() result = show_quicksearch(self._suggest_my_subfolders_and_files) if result: query, file_path = result new_path = dirname(file_path) # show_alert(new_path) # show_alert('path: ' + new_path + ' file_path: ' + file_path) def cursor_at(): self.pane.place_cursor_at(as_url(file_path)) self.pane.set_path(self.file_prefix + new_path, callback=cursor_at)
def __call__(self): show_status_message('Remove Favorite Directory') result = show_quicksearch(self._suggest_favorite) if result: query, dirName = result if os.path.isfile(FAVORITELIST): with open(FAVORITELIST, "r") as f: directories = f.readlines() with open(FAVORITELIST, "w") as f: for dirTuple in directories: favName = dirTuple.split('|')[0] if favName != dirName: f.write(dirTuple) clear_status_message()
def __call__(self): result = show_quicksearch(self._get_items) if result: query, value = result if value == 'log_file': file = self.pane.get_file_under_cursor() if file is None: self._execute('log') else: self._execute('log', as_human_readable(file)) else: self._execute(value) else: pass
def __call__(self): show_status_message('Remove Project Selection') result = show_quicksearch(self._suggest_projects) if result: query, projectName = result if os.path.isfile(PROJECTSLIST): with open(PROJECTSLIST, "r") as f: projects = f.readlines() with open(PROJECTSLIST, "w") as f: for projectTuple in projects: parts = projectTuple.split('|') if parts[0].strip() != projectName: f.write(projectTuple) clear_status_message()
def __call__(self): show_status_message('Remove Regular Expressions Selection') result = show_quicksearch(self._suggest_projects) if result: query, regexp = result lines = [""] if os.path.isfile(REGULAREXPRESSIONHIST): with open(REGULAREXPRESSIONHIST, "r") as f: lines = f.readlines() with open(REGULAREXPRESSIONHIST, "w") as f: for line in lines: if line.strip() != regexp: f.write(line + "\n") clear_status_message()
def __call__(self): show_status_message('Launching a Command Line...') result = show_quicksearch(self._suggest_script) if result: # # Launch the script given. Show the output. # query, script = result if query != '': script = query # # Get the variables for this plugin # scriptVars = _GetScriptVars() # # Save the command line. # scriptVars['command_line_history'].append(script) # # Set the environment variables for the scripts to use. # os.putenv('cd', as_human_readable(self.pane.get_path())) panes = self.pane.window.get_panes() os.putenv('lp', as_human_readable(panes[0].get_path())) os.putenv('lpf',as_human_readable(panes[0].get_file_under_cursor())) os.putenv('rp', as_human_readable(panes[1].get_path())) os.putenv('rpf',as_human_readable(panes[1].get_file_under_cursor())) os.putenv('cf', os.path.basename(as_human_readable(self.pane.get_file_under_cursor()))) # # Run the script. # saveDir = os.getcwd() os.chdir(as_human_readable(self.pane.get_path()) + os.path.sep) scriptLine = "source " + scriptVars['local_shell'] + "; " + script Output = run(scriptLine,stdout=PIPE,shell=True) os.chdir(saveDir) if Output.returncode == 0: if scriptVars['show_output']: show_alert(Output.stdout.decode("utf-8")) scriptVars['command_line_history'] = CleanCommandLineHistory(scriptVars['command_line_history']) _SaveScriptVars(scriptVars) else: show_alert("Command line error.") clear_status_message()
def __call__(self): show_status_message('Favorite Selection') result = show_quicksearch(self._suggest_directory) if result: query, dirName = result directories = ["Home|~"] if os.path.isfile(FAVORITELIST): with open(FAVORITELIST, "r") as f: directories = f.readlines() for dirTuple in directories: if '|' in dirTuple: favName, favPath = dirTuple.strip().split('|')[0:2] if favName == dirName: if '://' in favPath: self.pane.set_path(expandDirPath(favPath + os.sep)) else: self.pane.set_path(as_url(expandDirPath(favPath + os.sep))) clear_status_message()
def __call__(self): show_status_message('Getting Services...') result = show_quicksearch(self._suggest_script) if result: # # Launch the script given. Show the output. # query, script = result # # Run the script. # Output = run('', stdout=PIPE, shell=True) if Output.returncode == 0: show_alert(Output.stdout.decode("utf-8")) else: show_alert("Command line error.") clear_status_message()
def __call__(self): show_status_message('Editing a Script...') result = show_quicksearch(self._suggest_script) if result: # # Launch the script given. Show the output. # query, script = result # # Get the variables for this plugin # scriptVars = _GetScriptVars() # # Edit the script file. # if self.pane.is_command_visible('open_with_editor'): self.pane.run_command('open_with_editor',{'url': as_url(scriptVars['directory'] + os.sep + script)}) else: show_alert("OpenWithEditor command not found.") clear_status_message()
def __call__(self): show_status_message('Remove Shortener Directory') result = show_quicksearch(self._suggest_shortener) if result: # # Remove the shortener from the list of # shorteners. # query, shortName = result shortenDir = '' if os.path.isfile(SHORTENERLIST): with open(SHORTENERLIST, "r") as f: directories = f.readlines() with open(SHORTENERLIST, "w") as f: for dirTuple in directories: if '|' in dirTuple: shortenerName, shortDir = dirTuple.strip().split('|')[0:2] if shortenerName != shortName: f.write(dirTuple + '\n') else: shortenDir = shortDir # # Remove the shortener from all favorites. # if os.path.isfile(FAVORITELIST): favorties = ["Home|~"] with open(FAVORITELIST, "r") as f: favorties = f.readlines() pattern = re.compile("\{\{" + shortName + "\}\}(.*)$") with open(FAVORITELIST, "w") as f: for fav in favorties: if '|' in fav: favName, favPath = fav.strip().split('|')[0:2] match = pattern.search(favPath) if match: favPath = shortenDir + match.group(1) f.write(favName + "|" + favPath + "\n") clear_status_message()
def __call__(self): result = show_quicksearch(self._get_items) if result and result[1]: self.pane.set_path(result[1])
def __call__(self): """ handle quick search call """ result = show_quicksearch(self._suggest_my_files_and_folders) if result: query, file_path = result self.pane.place_cursor_at(as_url(file_path))