def make_cmd(self, pattern): cmd = [self.path, '--nocolor', '--nogroup', '--vimgrep', '--noheading'] if self.ignore: cmd.extend(['--ignore', self.ignore]) if self.file_regex: cmd.extend(['-G', self.file_regex]) if self.nocase: cmd.append('-s') if not self.multiline: cmd.append('--nomultiline') else: cmd.append('--multiline') if self.type == 1: cmd.append(build_regex(pattern)) elif self.type == 2: cmd.append(pattern) else: cmd.extend(['-Q', pattern]) if not Sniper.wide: cmd.extend([self.area.project, AreaVi.HOME]) else: cmd.extend(Sniper.dirs) return cmd
def run_cmd(self, data): path = check_output( ['locate', '--limit', '1', '--regexp', build_regex(data, '.*')], encoding='utf8') path = path.strip('\n').rstrip('\n') return path
def search_down(self, wid): """ """ data = wid.get() pattern = build_regex(data) self.area.ipick('(SEARCH_MATCH)', pattern, nocase=self.nocase, stopindex='end', index='insert')
def search_up(self, wid): """ """ data = wid.get() pattern = build_regex(data) self.area.ipick('(SEARCH_MATCH)', pattern, index='insert', nocase=self.nocase, stopindex='1.0', backwards=True)
def run_cmd(self, pattern): cmd = ['locate', '--limit', '200'] regex = build_regex(pattern, '.*') cmd.extend(['--regexp', regex]) child = Popen(cmd, stdout=PIPE, stderr=STDOUT, encoding=self.area.charset) output = child.communicate()[0] return output
def update(self, wid): """ """ data = wid.get() pattern = build_regex(data) root.status.set_msg('Pattern:%s' % pattern) self.area.ipick('(SEARCH_MATCH)', pattern, verbose=True, backwards=self.backwards, index=self.index, nocase=self.nocase, stopindex=self.stopindex)
def make_cmd(self, pattern): # When FSniffer.wide is False it searches in the current # Areavi instance project. cmd = ['locate', '--limit', '200'] regex = build_regex(pattern, '.*') if self.wide or not self.area.project: cmd.extend(['--regexp', regex]) else: cmd.extend(['--regexp', '%s.*%s' % (self.area.project, regex)]) # Used to filter only files because locate doesn't support # searching only for files. cmd = '%s | %s' % (' '.join(cmd), '''while read -r file; do [ -d "$file" ] || printf '%s\n' "$file"; done''') return cmd
def update_pattern(self, wid): pattern = build_regex(wid.get(), '.*') root.status.set_msg('File pattern: %s' % pattern)