~ubuntu-branches/debian/sid/obnam/sid

« back to all changes in this revision

Viewing changes to find-all-obnam-errors

  • Committer: Package Import Robot
  • Author(s): Lars Wirzenius
  • Date: 2015-07-01 18:14:49 UTC
  • Revision ID: package-import@ubuntu.com-20150701181449-taxcvqg9cviw2cxo
Tags: 1.10-1
* New upstream version.
  * Fix "restore to /tmp messes up directory perms" by preventing
    restores to a non-empty directory. (Closes: #760492)
* Add build-dependency on git.
* Drop build-dependency on texlive and building of PDF form of manual.
  Texlive is an insanely large build dependency.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright 2014  Lars Wirzenius
 
1
#!/usr/bin/env python
 
2
# Copyright 2014-2015  Lars Wirzenius
2
3
#
3
4
# This program is free software: you can redistribute it and/or modify
4
5
# it under the terms of the GNU General Public License as published by
16
17
# =*= License: GPL-3+ =*=
17
18
 
18
19
 
19
 
import collections
 
20
import imp
20
21
import inspect
 
22
import os
 
23
 
 
24
import cliapp
21
25
 
22
26
import obnamlib
 
27
import obnamlib.plugins
23
28
 
24
29
 
25
30
def get_modules(module):
49
54
    return [x for x in objs if is_obnam_error(x)]
50
55
 
51
56
 
52
 
def get_obnam_errors_recursively(module):
53
 
    modules = get_modules_recursively(obnamlib)
54
 
    errors = set()
55
 
    for module in modules:
56
 
        for error in get_obnam_errors(module):
57
 
            errors.add(error)
58
 
    return errors
59
 
 
60
 
 
61
 
def dump(msg, things):
62
 
    print msg
63
 
    for x in things:
64
 
        print '  ', repr(x)
65
 
 
66
 
 
67
 
 
68
 
for error_class in get_obnam_errors_recursively(obnamlib):
69
 
    e = error_class()
70
 
    print e.id, e.msg
 
57
all_modules = get_modules_recursively(obnamlib)
 
58
 
 
59
# This is a bit of magic to load all the modules that contain plugins.
 
60
def find_plugin_modules(*args):
 
61
    for module_filename in app.pluginmgr.plugin_files:
 
62
        module_name, ext = os.path.splitext(os.path.basename(module_filename))
 
63
        with open(module_filename) as f:
 
64
            module = imp.load_module(module_name, f, module_filename,
 
65
                                     ('.py', 'r', imp.PY_SOURCE))
 
66
        all_modules.append(module)
 
67
 
 
68
 
 
69
# This is a terrible kludge.
 
70
app = obnamlib.App()
 
71
app.process_args = find_plugin_modules
 
72
app.run()
 
73
 
 
74
template = '''\
 
75
{id} ({class_name}): {msg}
 
76
'''
 
77
 
 
78
for module in set(all_modules):
 
79
    for error_class in get_obnam_errors(module):
 
80
        e = error_class()
 
81
        print template.format(
 
82
            class_name=error_class.__name__,
 
83
            id=e.id,
 
84
            msg=e.msg,
 
85
        ),