Bug#978693: Bookletimposer - variable mismatch in file config.py

2021-02-10 Thread Kjö Hansi Glaz
Hi,

Sorry for the delay and thanks for the bug report.

I belive this is fixed by commit 7e335e6 in bookletimposer.

Thanks again



Bug#978693: Bookletimposer - variable mismatch in file config.py

2020-12-30 Thread Louis Possoz

Package: bookletimposer

Version: 0.3

Symptom: bookletimposer does not open on ubuntu 20.04.

Problem is in file 'config.py'.

# Error in duplicate naming
# using the same name for the function 'debug(msg)' and the boolean 
variable 'debug' results in the boolean variable 'debug' being always True.
# Correction : give function another name (or give boolean variable 
another name)


See attachment, line 42.

#!/usr/bin/env python
# -*- coding: UTF-8 -*-


#
# BookletImposer - Utility to achieve some basic imposition on PDF documents
# Copyright (C) 2008-2019 Kjö Hansi Glaz 
#
# This program is  free software; you can redistribute  it and/or modify
# it under the  terms of the GNU General Public  License as published by
# the Free Software Foundation; either  version 3 of the License, or (at
# your option) any later version.
#
# This program  is distributed in the  hope that it will  be useful, but
# WITHOUT   ANY  WARRANTY;   without  even   the  implied   warranty  of
# MERCHANTABILITY  or FITNESS  FOR A  PARTICULAR PURPOSE.   See  the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see .
#



#
# config.py
#
# This file contains the configuration variables defined at install time
# which will be used somewhere in the program.
#


import os
import os.path

if "DEBUG" in os.environ:
debug = True
else:
debug = False


# Error : duplicate variable name
# using the same name for the function 'debug(msg)' and the boolean variable 'debug' results in the boolean variable 'debug' being always True.
# Correction : give function another name (or give boolean variable another name)
def print_debug_msg(msg):
if debug:
print(msg)


def get_sharedir():
if debug and os.path.exists(os.path.join("/", "usr", "local", "share",
 "bookletimposer")):
return os.path.join("/", "usr", "local", "share")
elif os.path.exists(os.path.join("/", "usr", "share", "bookletimposer")):
return os.path.join("/", "usr", "share")
else:
return ""


def get_datadir():
if debug and os.path.exists("data"):
return "data"
else:
return os.path.join(get_sharedir(), "bookletimposer")


def get_helpdir():
return os.path.join(get_sharedir(), "gnome", "help")


def get_localedir():
return os.path.join(get_sharedir(), "locale")