/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to breezy/plugins/grep/cmds.py

  • Committer: Jelmer Vernooij
  • Date: 2018-11-11 04:08:32 UTC
  • mto: (7143.16.20 even-more-cleanups)
  • mto: This revision was merged to the branch mainline in revision 7175.
  • Revision ID: jelmer@jelmer.uk-20181111040832-nsljjynzzwmznf3h
Run autopep8.

Show diffs side-by-side

added added

removed removed

Lines of Context:
33
33
#   incorrectly: Object already cleaned up, did you assign it to another
34
34
#   variable?: _factory
35
35
# with lazy import
 
36
 
 
37
 
36
38
def _parse_levels(s):
37
39
    try:
38
40
        return int(s)
114
116
        Option('diff', short_name='p',
115
117
               help='Grep for pattern in changeset for each revision.'),
116
118
        ListOption('exclude', type=text_type, argname='glob', short_name='X',
117
 
            help="Skip files whose base name matches GLOB."),
 
119
                   help="Skip files whose base name matches GLOB."),
118
120
        ListOption('include', type=text_type, argname='glob', short_name='I',
119
 
            help="Search only files whose base name matches GLOB."),
 
121
                   help="Search only files whose base name matches GLOB."),
120
122
        Option('files-with-matches', short_name='l',
121
123
               help='Print only the name of each input file in '
122
124
               'which PATTERN is found.'),
131
133
        Option('ignore-case', short_name='i',
132
134
               help='ignore case distinctions while matching.'),
133
135
        Option('levels',
134
 
           help='Number of levels to display - 0 for all, 1 for collapsed '
135
 
           '(1 is default).',
136
 
           argname='N',
137
 
           type=_parse_levels),
 
136
               help='Number of levels to display - 0 for all, 1 for collapsed '
 
137
               '(1 is default).',
 
138
               argname='N',
 
139
               type=_parse_levels),
138
140
        Option('line-number', short_name='n',
139
141
               help='show 1-based line number.'),
140
142
        Option('no-recursive',
144
146
               'between output lines rather than a newline.'),
145
147
        ]
146
148
 
147
 
 
148
149
    @display_command
149
150
    def run(self, verbose=False, ignore_case=False, no_recursive=False,
150
151
            from_root=False, null=False, levels=None, line_number=False,
158
159
            path_list = ['.']
159
160
        else:
160
161
            if from_root:
161
 
                raise errors.BzrCommandError('cannot specify both --from-root and PATH.')
 
162
                raise errors.BzrCommandError(
 
163
                    'cannot specify both --from-root and PATH.')
162
164
 
163
165
        if files_with_matches and files_without_match:
164
166
            raise errors.BzrCommandError('cannot specify both '
165
 
                '-l/--files-with-matches and -L/--files-without-matches.')
 
167
                                         '-l/--files-with-matches and -L/--files-without-matches.')
166
168
 
167
169
        global_config = GlobalConfig()
168
170
 
174
176
 
175
177
        if color not in ['always', 'never', 'auto']:
176
178
            raise errors.BzrCommandError('Valid values for --color are '
177
 
                '"always", "never" or "auto".')
 
179
                                         '"always", "never" or "auto".')
178
180
 
179
 
        if levels==None:
180
 
            levels=1
 
181
        if levels == None:
 
182
            levels = 1
181
183
 
182
184
        print_revno = False
183
185
        if revision != None or levels == 0:
203
205
            re_flags |= re.IGNORECASE
204
206
 
205
207
        if not fixed_string:
206
 
            patternc = grep.compile_pattern(pattern.encode(grep._user_encoding), re_flags)
 
208
            patternc = grep.compile_pattern(
 
209
                pattern.encode(grep._user_encoding), re_flags)
207
210
 
208
211
        if color == 'always':
209
212
            show_color = True