~mterry/duplicity/list-old-chains-0.6

« back to all changes in this revision

Viewing changes to duplicity/selection.py

  • Committer: loafman
  • Date: 2008-12-22 17:22:44 UTC
  • Revision ID: vcs-imports@canonical.com-20081222172244-cjurdc0mt5d41n6d
patch #6700: Make duplicity translatable
https://savannah.nongnu.org/patch/?6700

Show diffs side-by-side

added added

removed removed

Lines of Context:
114
114
            try:
115
115
                mode = os.stat(path.name+"/"+filename)[stat.ST_MODE]
116
116
                if stat.S_ISSOCK(mode):
117
 
                    log.Log("Skipping socket %s/%s" % (path.name, filename), 7)
 
117
                    log.Log(_("Skipping socket %s/%s") % (path.name, filename), 7)
118
118
                else:
119
 
                    log.Log("Error initializing file %s/%s" % (path.name, filename), 2)
 
119
                    log.Log(_("Error initializing file %s/%s") % (path.name, filename), 2)
120
120
            except OSError:
121
 
                log.Log("Error accessing possibly locked file %s/%s" % (path.name, filename), 2);
 
121
                log.Log(_("Error accessing possibly locked file %s/%s") % (path.name, filename), 2);
122
122
            return None
123
123
 
124
124
        def diryield(path):
143
143
 
144
144
        if not path.type:
145
145
            # base doesn't exist
146
 
            log.Log("Warning: base %s doesn't exist, continuing" %
 
146
            log.Log(_("Warning: base %s doesn't exist, continuing") %
147
147
                    path.name, 2)
148
148
            return
149
 
        log.Log("Selecting %s" % path.name, 7)
 
149
        log.Log(_("Selecting %s") % path.name, 7)
150
150
        yield path
151
151
        if not path.isdir():
152
152
            return
164
164
            if val == 0:
165
165
                if delayed_path_stack:
166
166
                    for delayed_path in delayed_path_stack:
167
 
                        log.Log("Selecting %s" % delayed_path.name, 7)
 
167
                        log.Log(_("Selecting %s") % delayed_path.name, 7)
168
168
                        yield delayed_path
169
169
                    del delayed_path_stack[:]
170
 
                log.Log("Selecting %s" % subpath.name, 7)
 
170
                log.Log(_("Selecting %s") % subpath.name, 7)
171
171
                yield subpath
172
172
                if subpath.isdir():
173
173
                    diryield_stack.append(diryield(subpath))
233
233
    def parse_catch_error(self, exc):
234
234
        """Deal with selection error exc"""
235
235
        if isinstance(exc, FilePrefixError):
236
 
            log.FatalError(
 
236
            log.FatalError(_(
237
237
"""Fatal Error: The file specification
238
238
    %s
239
239
cannot match any files in the base directory
240
240
    %s
241
241
Useful file specifications begin with the base directory or some
242
 
pattern (such as '**') which matches the base directory.""" %
 
242
pattern (such as '**') which matches the base directory.""") %
243
243
            (exc, self.prefix), log.ErrorCode.file_prefix_error)
244
244
        elif isinstance(e, GlobbingError):
245
 
            log.FatalError("Fatal Error while processing expression\n"
246
 
                           "%s" % exc, log.ErrorCode.globbing_error)
 
245
            log.FatalError(_("Fatal Error while processing expression\n"
 
246
                             "%s") % exc, log.ErrorCode.globbing_error)
247
247
        else:
248
248
            raise
249
249
 
251
251
        """Exit with error if last selection function isn't an exclude"""
252
252
        if (self.selection_functions and
253
253
            not self.selection_functions[-1].exclude):
254
 
            log.FatalError(
 
254
            log.FatalError(_(
255
255
"""Last selection expression:
256
256
    %s
257
257
only specifies that files be included.  Because the default is to
258
258
include all files, the expression is redundant.  Exiting because this
259
 
probably isn't what you meant.""" %
 
259
probably isn't what you meant.""") %
260
260
            (self.selection_functions[-1].name,),
261
261
            log.ErrorCode.redundant_inclusion)
262
262
 
277
277
        filelist_name is just a string used for logging.
278
278
 
279
279
        """
280
 
        log.Log("Reading filelist %s" % filelist_name, 4)
 
280
        log.Log(_("Reading filelist %s") % filelist_name, 4)
281
281
        tuple_list, something_excluded = \
282
282
                    self.filelist_read(filelist_fp, inc_default, filelist_name)
283
 
        log.Log("Sorting filelist %s" % filelist_name, 4)
 
283
        log.Log(_("Sorting filelist %s") % filelist_name, 4)
284
284
        tuple_list.sort()
285
285
        i = [0] # We have to put index in list because of stupid scoping rules
286
286
 
307
307
            """Warn if prefix is incorrect"""
308
308
            prefix_warnings[0] += 1
309
309
            if prefix_warnings[0] < 6:
310
 
                log.Log("Warning: file specification '%s' in filelist %s\n"
311
 
                        "doesn't start with correct prefix %s.  Ignoring." %
 
310
                log.Log(_("Warning: file specification '%s' in filelist %s\n"
 
311
                          "doesn't start with correct prefix %s.  Ignoring.") %
312
312
                        (exc, filelist_name, self.prefix), 2)
313
313
                if prefix_warnings[0] == 5:
314
 
                    log.Log("Future prefix errors will not be logged.", 2)
 
314
                    log.Log(_("Future prefix errors will not be logged."), 2)
315
315
 
316
316
        something_excluded, tuple_list = None, []
317
317
        separator = globals.null_separator and "\0" or "\n"
327
327
            if not tuple[1]:
328
328
                something_excluded = 1
329
329
        if filelist_fp.close():
330
 
            log.Log("Error closing filelist %s" % filelist_name, 2)
 
330
            log.Log(_("Error closing filelist %s") % filelist_name, 2)
331
331
        return (tuple_list, something_excluded)
332
332
 
333
333
    def filelist_parse_line(self, line, include):
394
394
        See the man page on --[include/exclude]-globbing-filelist
395
395
 
396
396
        """
397
 
        log.Log("Reading globbing filelist %s" % list_name, 4)
 
397
        log.Log(_("Reading globbing filelist %s") % list_name, 4)
398
398
        separator = globals.null_separator and "\0" or "\n"
399
399
        for line in filelist_fp.read().split(separator):
400
400
            if not line:
424
424
        try:
425
425
            regexp = re.compile(regexp_string)
426
426
        except:
427
 
            log.Log("Error compiling regular expression %s" % regexp_string, 1)
 
427
            log.Log(_("Error compiling regular expression %s") % regexp_string, 1)
428
428
            raise
429
429
        
430
430
        def sel_func(path):
440
440
    def devfiles_get_sf(self):
441
441
        """Return a selection function to exclude all dev files"""
442
442
        if self.selection_functions:
443
 
            log.Log("Warning: exclude-device-files is not the first "
444
 
                    "selector.\nThis may not be what you intended", 3)
 
443
            log.Log(_("Warning: exclude-device-files is not the first "
 
444
                      "selector.\nThis may not be what you intended"), 3)
445
445
        def sel_func(path):
446
446
            if path.isdev():
447
447
                return 0