More pylint improvements
This commit is contained in:
@@ -35,23 +35,7 @@ import time
|
|||||||
import copy
|
import copy
|
||||||
import subprocess
|
import subprocess
|
||||||
from urllib.parse import urlparse
|
from urllib.parse import urlparse
|
||||||
|
|
||||||
#-------------------------------------------------------------------------
|
|
||||||
#
|
|
||||||
# set up logging
|
|
||||||
#
|
|
||||||
#-------------------------------------------------------------------------
|
|
||||||
import logging
|
import logging
|
||||||
LOG = logging.getLogger(".DbManager")
|
|
||||||
|
|
||||||
from gramps.gen.constfunc import win
|
|
||||||
if win():
|
|
||||||
_RCS_FOUND = os.system("rcs -V >nul 2>nul") == 0
|
|
||||||
if _RCS_FOUND and "TZ" not in os.environ:
|
|
||||||
# RCS requires the "TZ" variable be set.
|
|
||||||
os.environ["TZ"] = str(time.timezone)
|
|
||||||
else:
|
|
||||||
_RCS_FOUND = os.system("rcs -V >/dev/null 2>/dev/null") == 0
|
|
||||||
|
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
#
|
#
|
||||||
@@ -68,8 +52,6 @@ from gi.repository import Pango
|
|||||||
#
|
#
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
from gramps.gen.const import GRAMPS_LOCALE as glocale
|
from gramps.gen.const import GRAMPS_LOCALE as glocale
|
||||||
from gramps.gen.plug import BasePluginManager
|
|
||||||
_ = glocale.translation.gettext
|
|
||||||
from gramps.gui.display import display_help
|
from gramps.gui.display import display_help
|
||||||
from gramps.gen.const import URL_WIKISTRING, URL_MANUAL_PAGE
|
from gramps.gen.const import URL_WIKISTRING, URL_MANUAL_PAGE
|
||||||
from .user import User
|
from .user import User
|
||||||
@@ -83,16 +65,33 @@ from .glade import Glade
|
|||||||
from gramps.gen.db.exceptions import DbException
|
from gramps.gen.db.exceptions import DbException
|
||||||
from gramps.gen.config import config
|
from gramps.gen.config import config
|
||||||
from gramps.gui.listmodel import ListModel
|
from gramps.gui.listmodel import ListModel
|
||||||
|
from gramps.gen.constfunc import win
|
||||||
|
from gramps.gen.plug import BasePluginManager
|
||||||
|
_ = glocale.translation.gettext
|
||||||
|
|
||||||
_RETURN = Gdk.keyval_from_name("Return")
|
#-------------------------------------------------------------------------
|
||||||
_KP_ENTER = Gdk.keyval_from_name("KP_Enter")
|
#
|
||||||
|
# set up logging
|
||||||
|
#
|
||||||
|
#-------------------------------------------------------------------------
|
||||||
|
LOG = logging.getLogger(".DbManager")
|
||||||
|
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
#
|
#
|
||||||
# constants
|
# constants
|
||||||
#
|
#
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
|
if win():
|
||||||
|
_RCS_FOUND = os.system("rcs -V >nul 2>nul") == 0
|
||||||
|
if _RCS_FOUND and "TZ" not in os.environ:
|
||||||
|
# RCS requires the "TZ" variable be set.
|
||||||
|
os.environ["TZ"] = str(time.timezone)
|
||||||
|
else:
|
||||||
|
_RCS_FOUND = os.system("rcs -V >/dev/null 2>/dev/null") == 0
|
||||||
|
|
||||||
|
_RETURN = Gdk.keyval_from_name("Return")
|
||||||
|
_KP_ENTER = Gdk.keyval_from_name("KP_Enter")
|
||||||
|
|
||||||
WIKI_HELP_PAGE = _('%s_-_Manage_Family_Trees') % URL_MANUAL_PAGE
|
WIKI_HELP_PAGE = _('%s_-_Manage_Family_Trees') % URL_MANUAL_PAGE
|
||||||
WIKI_HELP_SEC = _('Family_Trees_manager_window')
|
WIKI_HELP_SEC = _('Family_Trees_manager_window')
|
||||||
|
|
||||||
@@ -227,15 +226,14 @@ class DbManager(CLIDbManager):
|
|||||||
self.top.connect('drag_data_received', self.__drag_data_received)
|
self.top.connect('drag_data_received', self.__drag_data_received)
|
||||||
self.top.connect('drag_motion', drag_motion)
|
self.top.connect('drag_motion', drag_motion)
|
||||||
self.top.connect('drag_drop', drop_cb)
|
self.top.connect('drag_drop', drop_cb)
|
||||||
self.define_help_button(self.glade.get_object('help'),
|
self.define_help_button(
|
||||||
WIKI_HELP_PAGE, WIKI_HELP_SEC)
|
self.glade.get_object('help'), WIKI_HELP_PAGE, WIKI_HELP_SEC)
|
||||||
|
|
||||||
if _RCS_FOUND:
|
if _RCS_FOUND:
|
||||||
self.rcs.connect('clicked', self.__rcs)
|
self.rcs.connect('clicked', self.__rcs)
|
||||||
|
|
||||||
def define_help_button(self, button, webpage='', section=''):
|
def define_help_button(self, button, webpage='', section=''):
|
||||||
button.connect('clicked', lambda x: display_help(webpage,
|
button.connect('clicked', lambda x: display_help(webpage, section))
|
||||||
section))
|
|
||||||
|
|
||||||
def __button_press(self, obj, event):
|
def __button_press(self, obj, event):
|
||||||
"""
|
"""
|
||||||
@@ -433,7 +431,7 @@ class DbManager(CLIDbManager):
|
|||||||
If skippath given, the name of skippath is not considered
|
If skippath given, the name of skippath is not considered
|
||||||
"""
|
"""
|
||||||
iter = self.model.get_iter_first()
|
iter = self.model.get_iter_first()
|
||||||
while (iter):
|
while iter:
|
||||||
path = self.model.get_path(iter)
|
path = self.model.get_path(iter)
|
||||||
if path == skippath:
|
if path == skippath:
|
||||||
pass
|
pass
|
||||||
@@ -598,11 +596,12 @@ class DbManager(CLIDbManager):
|
|||||||
node = self.model.get_iter(path)
|
node = self.model.get_iter(path)
|
||||||
filename = self.model.get_value(node, FILE_COL)
|
filename = self.model.get_value(node, FILE_COL)
|
||||||
if self.existing_name(new_text, skippath=path):
|
if self.existing_name(new_text, skippath=path):
|
||||||
DbManager.ERROR(_("Could not rename the Family Tree."),
|
DbManager.ERROR(
|
||||||
|
_("Could not rename the Family Tree."),
|
||||||
_("Family Tree already exists, choose a unique name."))
|
_("Family Tree already exists, choose a unique name."))
|
||||||
return
|
return
|
||||||
old_text, new_text = self.rename_database(filename, new_text)
|
old_text, new_text = self.rename_database(filename, new_text)
|
||||||
if not (old_text is None):
|
if old_text is not None:
|
||||||
rename_filename(old_text, new_text)
|
rename_filename(old_text, new_text)
|
||||||
self.model.set_value(node, NAME_COL, new_text)
|
self.model.set_value(node, NAME_COL, new_text)
|
||||||
#scroll to new position
|
#scroll to new position
|
||||||
@@ -858,8 +857,7 @@ class DbManager(CLIDbManager):
|
|||||||
#First ask user if he is really sure :-)
|
#First ask user if he is really sure :-)
|
||||||
yes_no = QuestionDialog2(
|
yes_no = QuestionDialog2(
|
||||||
_("Repair Family Tree?"),
|
_("Repair Family Tree?"),
|
||||||
_(
|
_("If you click %(bold_start)sProceed%(bold_end)s, Gramps will "
|
||||||
"If you click %(bold_start)sProceed%(bold_end)s, Gramps will "
|
|
||||||
"attempt to recover your Family Tree from the last good "
|
"attempt to recover your Family Tree from the last good "
|
||||||
"backup. There are several ways this can cause unwanted "
|
"backup. There are several ways this can cause unwanted "
|
||||||
"effects, so %(bold_start)sbackup%(bold_end)s the "
|
"effects, so %(bold_start)sbackup%(bold_end)s the "
|
||||||
@@ -934,7 +932,7 @@ class DbManager(CLIDbManager):
|
|||||||
"""
|
"""
|
||||||
self.msg.set_label(msg)
|
self.msg.set_label(msg)
|
||||||
self.top.get_window().set_cursor(Gdk.Cursor.new(Gdk.CursorType.WATCH))
|
self.top.get_window().set_cursor(Gdk.Cursor.new(Gdk.CursorType.WATCH))
|
||||||
while (Gtk.events_pending()):
|
while Gtk.events_pending():
|
||||||
Gtk.main_iteration()
|
Gtk.main_iteration()
|
||||||
|
|
||||||
def __end_cursor(self):
|
def __end_cursor(self):
|
||||||
@@ -1051,9 +1049,9 @@ def find_revisions(name):
|
|||||||
continue
|
continue
|
||||||
match = date.match(line)
|
match = date.match(line)
|
||||||
if match:
|
if match:
|
||||||
date_str = time.strftime('%x %X',
|
date_str = time.strftime(
|
||||||
time.strptime(match.groups()[0], '%Y-%m-%d %H:%M:%S'))
|
'%x %X', time.strptime(match.groups()[0],
|
||||||
|
'%Y-%m-%d %H:%M:%S'))
|
||||||
get_next = True
|
get_next = True
|
||||||
continue
|
continue
|
||||||
if get_next:
|
if get_next:
|
||||||
@@ -1114,8 +1112,7 @@ def check_in(dbase, filename, user, cursor_func = None):
|
|||||||
|
|
||||||
if not os.path.isfile(archive_name):
|
if not os.path.isfile(archive_name):
|
||||||
cmd = init + [archive_name]
|
cmd = init + [archive_name]
|
||||||
proc = subprocess.Popen(cmd,
|
proc = subprocess.Popen(cmd, stderr=subprocess.PIPE)
|
||||||
stderr = subprocess.PIPE)
|
|
||||||
status = proc.wait()
|
status = proc.wait()
|
||||||
message = "\n".join(proc.stderr.readlines())
|
message = "\n".join(proc.stderr.readlines())
|
||||||
proc.stderr.close()
|
proc.stderr.close()
|
||||||
@@ -1141,8 +1138,7 @@ def check_in(dbase, filename, user, cursor_func = None):
|
|||||||
cursor_func(_("Saving archive..."))
|
cursor_func(_("Saving archive..."))
|
||||||
|
|
||||||
cmd = ci_cmd + ['-m%s' % comment, filename, archive_name]
|
cmd = ci_cmd + ['-m%s' % comment, filename, archive_name]
|
||||||
proc = subprocess.Popen(cmd,
|
proc = subprocess.Popen(cmd, stderr=subprocess.PIPE)
|
||||||
stderr = subprocess.PIPE)
|
|
||||||
|
|
||||||
status = proc.wait()
|
status = proc.wait()
|
||||||
message = "\n".join(proc.stderr.readlines())
|
message = "\n".join(proc.stderr.readlines())
|
||||||
|
Reference in New Issue
Block a user