python3: enforce use of absolute imports

Where relative imports are currently being relied upon, do this
explicitly.
This commit is contained in:
Eli Schwartz 2019-04-22 12:22:48 -04:00 committed by Jim Miller
parent 517082f4d1
commit 4a3640cc33
3 changed files with 14 additions and 16 deletions

View file

@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
from __future__ import (unicode_literals, division,
from __future__ import (absolute_import, unicode_literals, division,
print_function)
__license__ = 'GPL v3'
@ -23,11 +23,11 @@ class BasicIniHighlighter(QSyntaxHighlighter):
format, so I'm leaving this in the project even though I'm not
using.
'''
def __init__( self, parent, theme ):
QSyntaxHighlighter.__init__( self, parent )
self.parent = parent
self.highlightingRules = []
# keyword
@ -61,4 +61,3 @@ class HighlightingRule():
brush = QBrush(color, style)
charfmt.setForeground(brush)
self.highlight = charfmt

View file

@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
from __future__ import (unicode_literals, division,
from __future__ import (absolute_import, unicode_literals, division,
print_function)
__license__ = 'GPL v3'
@ -74,7 +74,7 @@ from calibre_plugins.fanficfare_plugin.fanficfare.configurable \
import (get_valid_sections, get_valid_entries,
get_valid_keywords, get_valid_entry_keywords)
from inihighlighter import IniHighlighter
from .inihighlighter import IniHighlighter
## moved to prefs.py so they can be included in jobs.py.
from calibre_plugins.fanficfare_plugin.prefs import \
@ -1370,7 +1370,7 @@ class IniTextDialog(SizePersistedDialog):
self.resize_dialog()
def accept(self):
from fff_util import test_config
from .fff_util import test_config
# print("in accept")
errors = test_config(self.get_plain_text())

View file

@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
from __future__ import (unicode_literals, division,
from __future__ import (absolute_import, unicode_literals, division,
print_function)
__license__ = 'GPL v3'
@ -19,11 +19,11 @@ class IniHighlighter(QSyntaxHighlighter):
QSyntaxHighlighter class for use with QTextEdit for highlighting
ini config files.
'''
def __init__( self, parent, sections=[], keywords=[], entries=[], entry_keywords=[] ):
QSyntaxHighlighter.__init__( self, parent )
self.parent = parent
self.highlightingRules = []
if entries:
@ -33,7 +33,7 @@ class IniHighlighter(QSyntaxHighlighter):
# true/false -- just to be nice.
self.highlightingRules.append( HighlightingRule( r"\b(true|false)\b", Qt.darkGreen ) )
# *all* keywords -- change known later.
self.errorRule = HighlightingRule( r"^[^:=\s][^:=]*[:=]", Qt.red )
self.highlightingRules.append( self.errorRule )
@ -70,7 +70,7 @@ class IniHighlighter(QSyntaxHighlighter):
# NOT comments -- but can be custom columns, so don't flag.
#self.highlightingRules.append( HighlightingRule( r"(?<!^)#[^\n]*" , Qt.red ) )
# comments -- comments must start from column 0.
self.commentRule = HighlightingRule( r"^#[^\n]*" , Qt.darkYellow )
self.highlightingRules.append( self.commentRule )
@ -91,15 +91,15 @@ class IniHighlighter(QSyntaxHighlighter):
# unknown section, error all:
if blocknum == 1 and blocknum == self.previousBlockState():
self.setFormat( 0, len(text), self.errorRule.highlight )
# teststory section rules:
if blocknum == 3:
self.setFormat( 0, len(text), self.teststoryRule.highlight )
# storyUrl section rules:
if blocknum == 4:
self.setFormat( 0, len(text), self.storyUrlRule.highlight )
self.setCurrentBlockState( blocknum )
class HighlightingRule():
@ -117,4 +117,3 @@ class HighlightingRule():
charfmt.setFontWeight(weight)
self.highlight = charfmt
self.blocknum=blocknum