Clean up read_file().

This commit is contained in:
Florian Bruhin 2014-02-14 16:32:56 +01:00
parent 2780793bf4
commit 302736925b
2 changed files with 9 additions and 5 deletions

View File

@ -31,5 +31,9 @@ Subpackages:
# You should have received a copy of the GNU General Public License
# along with qutebrowser. If not, see <http://www.gnu.org/licenses/>.
import os.path
__version_info__ = (0, 0, 0)
__version__ = '.'.join(map(str, __version_info__))
basedir = os.path.dirname(os.path.realpath(__file__))

View File

@ -27,6 +27,8 @@ try:
except ImportError:
from pdb import set_trace as pdb_set_trace
import qutebrowser
def set_trace():
"""
@ -45,8 +47,6 @@ def set_trace():
def read_file(filename):
"""Return the contents of a file contained with qutebrowser."""
fn = os.path.join(os.path.dirname(os.path.realpath(__file__)),
os.path.pardir, filename)
with open(fn, 'r') as f:
# FIXME is there a nicer way?
return '\n'.join(f.readlines())
fn = os.path.join(qutebrowser.basedir, filename)
with open(fn, 'r', encoding='UTF-8') as f:
return f.read()