4 Modify external overrides.
6 @contact: Debian FTP Master <ftpmaster@debian.org>
7 @copyright: 2011 Ansgar Burchardt <ansgar@debian.org>
8 @license: GNU General Public License version 2 or later
11 # This program is free software; you can redistribute it and/or modify
12 # it under the terms of the GNU General Public License as published by
13 # the Free Software Foundation; either version 2 of the License, or
14 # (at your option) any later version.
16 # This program is distributed in the hope that it will be useful,
17 # but WITHOUT ANY WARRANTY; without even the implied warranty of
18 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 # GNU General Public License for more details.
21 # You should have received a copy of the GNU General Public License
22 # along with this program; if not, write to the Free Software
23 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25 from daklib.dbconn import *
26 from daklib.config import Config
27 from daklib import utils, daklog
33 print """Usage: dak external-overrides COMMAND
34 Modify external overrides.
36 -h, --help show this help and exit.
38 Commands can use a long or abbreviated form:
40 remove KEY remove external overrides for KEY
43 import KEY import external overrides for KEY
44 i KEY NOTE: This will replace existing overrides.
46 show-key KEY show external overrides for KEY
49 show-package PACKAGE show external overrides for PACKAGE
52 For the 'import' command, external overrides are read from standard input and
53 should be given as lines of the form 'PACKAGE KEY VALUE'.
57 #############################################################################
59 def external_overrides_import(key, file):
60 session = DBConn().session()
62 session.query(ExternalOverride).filter_by(key=key).delete()
65 (package, key, value) = line.strip().split(None, 2)
66 eo = ExternalOverride()
74 #############################################################################
79 Arguments = [('h',"help","External-Overrides::Options::Help")]
81 (command, arg) = apt_pkg.ParseCommandLine(cnf.Cnf, Arguments, sys.argv)
83 Options = cnf.SubTree("External-Overrides::Options")
87 if Options.has_key("Help"):
90 logger = daklog.Logger(cnf, 'external-overrides')
92 if command in ('import', 'i'):
93 external_overrides_import(arg, sys.stdin)
95 print "E: Unknown commands."
97 if __name__ == '__main__':