def load_files_for_dir(self, query, parse_dir, base_path):
        lst_search_items = []
        for file_name in listdir(parse_dir):
            self.limit_file_count -= 1
            self.files_found += 1
            file_path = join(parse_dir, file_name)
            # show_status_message("_suggest_my_subfolders_and_files: " + file_path)
            file_name_clean = file_name
            file_name = join(base_path, file_name)

            if isdir(file_path):
                self.folders_found += 1
                file_name = '[' + file_name + ']'
            match = contains_chars(file_name.lower(), query.lower())

            if match or not query:
                lst_search_items.append(
                    QuicksearchItem(file_path, file_name, highlight=match))

            if isdir(file_path):
                new_base_path = join(base_path, file_name_clean)
                if self.limit_file_count > 0:
                    lst_search_items += self.load_files_for_dir(
                        query, file_path, new_base_path)

        return lst_search_items
Ejemplo n.º 2
0
 def _suggest_favorite(self, query):
     favorites = [""]
     if os.path.isfile(FAVORITELIST):
         with open(FAVORITELIST, "r") as f:
             favorites = f.readlines()
     for favTuple in favorites:
         if '|' in favTuple:
             favName = favTuple.split('|')[0]
             match = contains_chars(favName.lower(), query.lower())
             if match or not query:
                 yield QuicksearchItem(favName, highlight=match)
Ejemplo n.º 3
0
 def _suggest_directory(self, query):
     directories = ["Home|~"]
     if os.path.isfile(FAVORITELIST):
         with open(FAVORITELIST, "r") as f:
             directories = f.readlines()
     for dirTuple in directories:
         if '|' in dirTuple:
             dirName = dirTuple.split('|')[0]
             match = contains_chars(dirName.lower(), query.lower())
             if match or not query:
                 yield QuicksearchItem(dirName, highlight=match)
Ejemplo n.º 4
0
 def _suggest_shortener(self, query):
     shorteners = ["No shorteners are setup."]
     if os.path.isfile(SHORTENERLIST):
         with open(SHORTENERLIST, "r") as f:
             shorteners = f.readlines()
     for shortTuple in shorteners:
         if shortTuple.strip() != "":
             shortName = shortTuple.split('|')[0]
             match = contains_chars(shortName.lower(), query.lower())
             if match or not query:
                 yield QuicksearchItem(shortName, highlight=match)
Ejemplo n.º 5
0
 def _suggest_projects(self, query):
     projects = ["No Projects are setup."]
     if os.path.isfile(PROJECTSLIST):
         with open(PROJECTSLIST, "r") as f:
             projects = f.readlines()
     for projectTuple in projects:
         if projectTuple.strip() != "":
             project = projectTuple.split('|')[0].strip()
             match = contains_chars(project.lower(), query.lower())
             if match or not query:
                 yield QuicksearchItem(project, highlight=match)
Ejemplo n.º 6
0
 def _suggest_projects(self, query):
     regexs = ["No Regular Expression History."]
     if os.path.isfile(REGULAREXPRESSIONHIST):
         with open(REGULAREXPRESSIONHIST, "r") as f:
             regexs = f.readlines()
     for regex in regexs:
         if not regex.strip() == "":
             match = contains_chars(regex.lower().strip(),
                                    query.lower().strip())
             if match or not query:
                 yield QuicksearchItem(regex.strip(), highlight=match)
 def _suggest_my_files_and_folders(self, query):
     dir_path = as_human_readable(self.pane.get_path())
     list_directory_content = listdir(dir_path)
     list_directory_content = sorted(list_directory_content,
                                     key=lambda s: s.lower())
     for file_name in list_directory_content:
         file_path = join(dir_path, file_name)
         if isdir(file_path):
             file_name = '[' + file_name + ']'
         match = contains_chars(file_name.lower(), query.lower())
         if match or not query:
             yield QuicksearchItem(file_path, file_name, highlight=match)
Ejemplo n.º 8
0
    def _suggest_script(self, query):
        scriptVars = _GetScriptVars()
        scripts = scriptVars['command_line_history']

        #
        # Suggested one to the user and let them pick.
        #
        for script in scripts:
            if script.strip() != "":
                scriptName = script
                match = contains_chars(scriptName.lower(), query.lower())
                if match or not query:
                    yield QuicksearchItem(scriptName, highlight=match)
Ejemplo n.º 9
0
    def _suggest_script(self, query):
        scripts = []
        maskPackagePath = as_human_readable(self.pane.get_path()) + os.path.sep + 'maskfile.md'
        maskPackagePtr = open(npmPackagePath,"r")
        maskScript = npmPackagePtr.read()
        maskPackagePtr.close()
        for scriptName, command in scriptNames:
            scripts.append(scriptName)

        #
        # Suggested one to the user and let them pick.
        #
        for script in scripts:
            if script.strip() != "":
                scriptName = script
                match = contains_chars(scriptName.lower(), query.lower())
                if match or not query:
                    yield QuicksearchItem(scriptName, highlight=match)
Ejemplo n.º 10
0
    def _suggest_script(self, query):
        show_alert('/usr/bin/osascript "' +
                   path.dirname(path.realpath(__file__)) +
                   '/serviceMenu.scpt"')
        output = run('/usr/bin/osascript "' +
                     path.dirname(path.realpath(__file__)) +
                     '/serviceMenu.scpt"',
                     stdout=PIPE,
                     shell=True)
        show_alert(output.stdout.decode("utf-8"))
        services = json.loads(output.stdout.decode("utf-8"))

        #
        # Suggested one to the user and let them pick.
        #
        for service in services:
            if service.name.strip() != "":
                serviceName = service.name
                match = contains_chars(serviceName.lower(), query.lower())
                if match or not query:
                    yield QuicksearchItem(serviceName, highlight=match)
Ejemplo n.º 11
0
    def _suggest_script(self, query):
        scripts = ["No scripts are setup."]
        #
        # Get a list of scripts.
        #
        scriptDir = _GetScriptVars()
        scripts = os.listdir(scriptDir['directory'])

        #
        # Suggested one to the user and let them pick.
        #
        for script in scripts:
            scriptName = script.strip()
            if scriptName != "":
                match = False
                if query:
                    match = contains_chars(script.lower(), query.lower())
                else:
                    match = True
                if scriptName[0] == '.' or scriptName[0] == 'L' or scriptName[0] == 'R':
                    match = False
                if match:
                    yield QuicksearchItem(scriptName)