Debian Codegraph @

lib/info.py

raw symbols SCIP
1 # -*- coding: utf-8 -*-
2 #
3 # QBrz - Qt frontend to Breezy commands
4 # Copyright (C) 2008 Lukáš Lalinský <[email protected]om>
5 #
6 # This program is free software; you can redistribute it and/or
7 # modify it under the terms of the GNU General Public License
8 # as published by the Free Software Foundation; either version 2
9 # of the License, or (at your option) any later version.
10 #
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
15 #
16 # You should have received a copy of the GNU General Public License
17 # along with this program; if not, write to the Free Software
18 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19
20 from breezy import controldir, osutils
21
22 from breezy.info import show_bzrdir_info
23
24 from breezy.plugins.qbrz.lib.i18n import gettext
25 from breezy.plugins.qbrz.lib.ui_info import Ui_InfoForm
26 from breezy.plugins.qbrz.lib.util import (
27 BTN_CLOSE,
28 QBzrWindow,
29 url_for_display,
30 )
31
32 import io
33
34
35 class QBzrInfoWindow(QBzrWindow):
36
37 def __init__(self, location, parent=None):
38 QBzrWindow.__init__(self, [gettext("Info")], parent)
39 self.restoreSize("info", (580, 250))
40 self.buttonbox = self.create_button_box(BTN_CLOSE)
41 self.ui = Ui_InfoForm()
42 self.ui.setupUi(self.centralwidget)
43 self.ui.verticalLayout.addWidget(self.buttonbox)
44 self.refresh_view(location)
45 self.ui.tabWidget.setCurrentIndex(0)
46
47 def refresh_view(self, location):
48 self._set_location(location)
49 self.populate_unparsed_info(location)
50
51 def _set_location(self, location):
52 if not location:
53 self.ui.local_location.setText('-')
54 return
55 if location != '.':
56 self.ui.local_location.setText(url_for_display(location))
57 return
58 self.ui.local_location.setText(osutils.abspath(location))
59
60 def populate_unparsed_info(self, location):
61 basic = io.StringIO()
62 detailed = io.StringIO()
63 a_controldir = controldir.ControlDir.open_containing(location)[0]
64 show_bzrdir_info(a_controldir, 0, basic)
65 show_bzrdir_info(a_controldir, 2, detailed)
66 self.ui.basic_info.setText(basic.getvalue())
67 self.ui.detailed_info.setText(detailed.getvalue())
68 basic.close()
69 detailed.close()