Migrate code style to Black
This commit is contained in:
@@ -26,4 +26,5 @@ able to run gramps from the source directory without setting PYTHONPATH
|
||||
From this position, import gramps works great
|
||||
"""
|
||||
import gramps.grampsapp as app
|
||||
|
||||
app.main()
|
||||
|
||||
@@ -5,36 +5,40 @@ from os.path import join
|
||||
import sys
|
||||
import site
|
||||
|
||||
if getattr(sys, 'frozen', False):
|
||||
if getattr(sys, "frozen", False):
|
||||
aio = os.path.dirname(sys.executable)
|
||||
sys.path.insert(1, aio)
|
||||
sys.path.insert(1, os.path.join(aio,'lib'))
|
||||
sys.path.insert(1, os.path.join(aio, "lib"))
|
||||
sys.path.insert(1, site.getusersitepackages())
|
||||
environ['PANGOCAIRO_BACKEND'] = 'fontconfig'
|
||||
environ['SSL_CERT_FILE'] = join(aio, 'ssl/certs/ca-bundle.trust.crt')
|
||||
environ['GI_TYPELIB_PATH'] = join(aio, 'lib/girepository-1.0')
|
||||
environ['G_ENABLE_DIAGNOSTIC'] = '0'
|
||||
environ['G_PARAM_DEPRECATED'] = '0'
|
||||
environ['GRAMPS_RESOURCES'] = join(aio, 'share')
|
||||
environ['PATH'] = aio + ';' + aio +'\lib;' + environ['PATH']
|
||||
environ["PANGOCAIRO_BACKEND"] = "fontconfig"
|
||||
environ["SSL_CERT_FILE"] = join(aio, "ssl/certs/ca-bundle.trust.crt")
|
||||
environ["GI_TYPELIB_PATH"] = join(aio, "lib/girepository-1.0")
|
||||
environ["G_ENABLE_DIAGNOSTIC"] = "0"
|
||||
environ["G_PARAM_DEPRECATED"] = "0"
|
||||
environ["GRAMPS_RESOURCES"] = join(aio, "share")
|
||||
environ["PATH"] = aio + ";" + aio + "\lib;" + environ["PATH"]
|
||||
|
||||
|
||||
def close():
|
||||
sys.exit()
|
||||
|
||||
|
||||
import atexit
|
||||
import ctypes
|
||||
|
||||
HANDLE = ctypes.windll.kernel32.CreateMutexW(None, 1, "org.gramps-project.gramps")
|
||||
ERROR = ctypes.GetLastError()
|
||||
if ERROR == 183: #ERROR_ALREADY_EXISTS:
|
||||
print('Gramps is already running!', file=sys.stderr)
|
||||
if ERROR == 183: # ERROR_ALREADY_EXISTS:
|
||||
print("Gramps is already running!", file=sys.stderr)
|
||||
close()
|
||||
|
||||
atexit.register(ctypes.windll.kernel32.CloseHandle, HANDLE)
|
||||
atexit.register(ctypes.windll.kernel32.ReleaseMutex, HANDLE)
|
||||
|
||||
import warnings
|
||||
|
||||
warnings.simplefilter("ignore")
|
||||
|
||||
import gramps.grampsapp as app
|
||||
|
||||
app.run()
|
||||
|
||||
@@ -5,19 +5,20 @@ from os.path import join
|
||||
import sys
|
||||
import site
|
||||
|
||||
if getattr(sys, 'frozen', False):
|
||||
if getattr(sys, "frozen", False):
|
||||
aio = os.path.dirname(sys.executable)
|
||||
sys.path.insert(1, aio)
|
||||
sys.path.insert(1, os.path.join(aio,'lib'))
|
||||
sys.path.insert(1, os.path.join(aio, "lib"))
|
||||
sys.path.insert(1, site.getusersitepackages())
|
||||
environ['LANG'] = 'en'
|
||||
environ['PANGOCAIRO_BACKEND'] = 'fontconfig'
|
||||
environ['SSL_CERT_FILE'] = join(aio, 'ssl/certs/ca-bundle.trust.crt')
|
||||
environ['GI_TYPELIB_PATH'] = join(aio, 'lib/girepository-1.0')
|
||||
environ['G_ENABLE_DIAGNOSTIC'] = '0'
|
||||
environ['G_PARAM_DEPRECATED'] = '0'
|
||||
environ['GRAMPS_RESOURCES'] = join(aio, 'share')
|
||||
environ['PATH'] = aio + ';' + aio +'\lib;' + environ['PATH']
|
||||
environ["LANG"] = "en"
|
||||
environ["PANGOCAIRO_BACKEND"] = "fontconfig"
|
||||
environ["SSL_CERT_FILE"] = join(aio, "ssl/certs/ca-bundle.trust.crt")
|
||||
environ["GI_TYPELIB_PATH"] = join(aio, "lib/girepository-1.0")
|
||||
environ["G_ENABLE_DIAGNOSTIC"] = "0"
|
||||
environ["G_PARAM_DEPRECATED"] = "0"
|
||||
environ["GRAMPS_RESOURCES"] = join(aio, "share")
|
||||
environ["PATH"] = aio + ";" + aio + "\lib;" + environ["PATH"]
|
||||
|
||||
import gramps.grampsapp as app
|
||||
|
||||
app.run()
|
||||
|
||||
@@ -1,39 +1,42 @@
|
||||
#!/usr/bin/env python3
|
||||
'''
|
||||
"""
|
||||
grampsw.exe
|
||||
'''
|
||||
"""
|
||||
import os
|
||||
from os import environ
|
||||
from os.path import join
|
||||
import sys
|
||||
import site
|
||||
|
||||
if getattr(sys, 'frozen', False):
|
||||
if getattr(sys, "frozen", False):
|
||||
aio = os.path.dirname(sys.executable)
|
||||
sys.path.insert(1, aio)
|
||||
sys.path.insert(1, os.path.join(aio,'lib'))
|
||||
sys.path.insert(1, os.path.join(aio, "lib"))
|
||||
sys.path.insert(1, site.getusersitepackages())
|
||||
environ['SSL_CERT_FILE'] = join(aio, 'ssl/certs/ca-bundle.trust.crt')
|
||||
environ['GI_TYPELIB_PATH'] = join(aio, 'lib/girepository-1.0')
|
||||
environ['G_ENABLE_DIAGNOSTIC'] = '0'
|
||||
environ['G_PARAM_DEPRECATED'] = '0'
|
||||
environ['GRAMPS_RESOURCES'] = join(aio, 'share')
|
||||
environ['PATH'] = aio + ';' + aio +'\lib;' + environ['PATH']
|
||||
environ["SSL_CERT_FILE"] = join(aio, "ssl/certs/ca-bundle.trust.crt")
|
||||
environ["GI_TYPELIB_PATH"] = join(aio, "lib/girepository-1.0")
|
||||
environ["G_ENABLE_DIAGNOSTIC"] = "0"
|
||||
environ["G_PARAM_DEPRECATED"] = "0"
|
||||
environ["GRAMPS_RESOURCES"] = join(aio, "share")
|
||||
environ["PATH"] = aio + ";" + aio + "\lib;" + environ["PATH"]
|
||||
|
||||
import atexit
|
||||
import ctypes
|
||||
|
||||
|
||||
def close():
|
||||
''' Show warning dialog if Gramps is already running'''
|
||||
sys.exit('Gramps is already running!')
|
||||
"""Show warning dialog if Gramps is already running"""
|
||||
sys.exit("Gramps is already running!")
|
||||
|
||||
|
||||
HANDLE = ctypes.windll.kernel32.CreateMutexW(None, 1, "org.gramps-project.gramps")
|
||||
ERROR = ctypes.GetLastError()
|
||||
if ERROR == 183: #ERROR_ALREADY_EXISTS:
|
||||
if ERROR == 183: # ERROR_ALREADY_EXISTS:
|
||||
close()
|
||||
|
||||
atexit.register(ctypes.windll.kernel32.CloseHandle, HANDLE)
|
||||
atexit.register(ctypes.windll.kernel32.ReleaseMutex, HANDLE)
|
||||
|
||||
import gramps.grampsapp as app
|
||||
|
||||
app.main()
|
||||
|
||||
340
aio/setup.py
340
aio/setup.py
@@ -1,7 +1,7 @@
|
||||
'''
|
||||
"""
|
||||
Use with:
|
||||
python3 setup.py build_exe --no-compress -O1
|
||||
'''
|
||||
"""
|
||||
import sys
|
||||
import os
|
||||
import site
|
||||
@@ -11,171 +11,273 @@ import atexit
|
||||
import shutil
|
||||
import zipfile
|
||||
import cx_Freeze
|
||||
sys.path.insert(0,'dist')
|
||||
|
||||
sys.path.insert(0, "dist")
|
||||
import gramps
|
||||
from gramps.version import VERSION_TUPLE
|
||||
|
||||
try:
|
||||
from gramps.version import VERSION_QUALIFIER
|
||||
except:
|
||||
VERSION_QUALIFIER = ''
|
||||
UPX_ALT_PATH = r'UPX'
|
||||
VERSION_QUALIFIER = ""
|
||||
UPX_ALT_PATH = r"UPX"
|
||||
|
||||
#import logging
|
||||
#logging.basicConfig(level=logging.DEBUG)
|
||||
VQ = {'-alpha1': 10, '-alpha2': 11, '-alpha3': 12,
|
||||
'-beta1': 21, '-beta2': 22, '-beta3': 23,
|
||||
'-rc1': 22, '': 0}
|
||||
# import logging
|
||||
# logging.basicConfig(level=logging.DEBUG)
|
||||
VQ = {
|
||||
"-alpha1": 10,
|
||||
"-alpha2": 11,
|
||||
"-alpha3": 12,
|
||||
"-beta1": 21,
|
||||
"-beta2": 22,
|
||||
"-beta3": 23,
|
||||
"-rc1": 22,
|
||||
"": 0,
|
||||
}
|
||||
|
||||
VERSION = ('.'.join(map(str, VERSION_TUPLE)) + '.' +
|
||||
str(VQ.get(VERSION_QUALIFIER, 99)))
|
||||
COPYRIGHT="Copyright 2020, Gramps developers. GNU General Public License"
|
||||
VERSION = ".".join(map(str, VERSION_TUPLE)) + "." + str(VQ.get(VERSION_QUALIFIER, 99))
|
||||
COPYRIGHT = "Copyright 2020, Gramps developers. GNU General Public License"
|
||||
# Prepare a temporay directory
|
||||
TEMP_DIR = tempfile.TemporaryDirectory()
|
||||
atexit.register(TEMP_DIR.cleanup)
|
||||
BASE_DIR = os.path.split(sys.prefix)[1]
|
||||
SETUP_DIR = os.path.dirname(os.path.realpath(__file__))
|
||||
SETUP_FILES = ['setup.py', 'gramps.ico', 'grampsc.ico', 'grampsd.ico',
|
||||
'grampsaioc.py', 'grampsaiocd.py', 'grampsaiow.py']
|
||||
if '32' in BASE_DIR:
|
||||
SETUP_FILES.append(''.join(('grampsaio', '32', '.nsi')))
|
||||
SETUP_FILES = [
|
||||
"setup.py",
|
||||
"gramps.ico",
|
||||
"grampsc.ico",
|
||||
"grampsd.ico",
|
||||
"grampsaioc.py",
|
||||
"grampsaiocd.py",
|
||||
"grampsaiow.py",
|
||||
]
|
||||
if "32" in BASE_DIR:
|
||||
SETUP_FILES.append("".join(("grampsaio", "32", ".nsi")))
|
||||
else:
|
||||
SETUP_FILES.append(''.join(('grampsaio', '64', '.nsi')))
|
||||
SETUP_FILES.append("".join(("grampsaio", "64", ".nsi")))
|
||||
|
||||
INCLUDE_DLL_PATH = os.path.join(sys.exec_prefix, 'bin')
|
||||
INCLUDE_DLL_PATH = os.path.join(sys.exec_prefix, "bin")
|
||||
INCLUDE_FILES = []
|
||||
INCLUDES = ['gi', 'cgi', 'colorsys', 'site']
|
||||
PACKAGES = ['gi', 'cairo', 'xml', 'bsddb3', 'lxml', 'PIL', 'json', 'csv',
|
||||
'sqlite3', 'cProfile', 'networkx', 'psycopg2', 'requests', 'logging'
|
||||
, 'html', 'compileall', 'graphviz', 'pydotplus', 'pygraphviz', 'pydot' ]
|
||||
EXCLUDES = ['tkinter', 'PyQt5', 'PyQt5.QtCore', 'PyQt5.QtGui', 'pyside'
|
||||
'PyQt5.QtWidgets', 'sip', 'lib2to3', 'PIL.ImageQt', 'pip', 'distlib'
|
||||
]
|
||||
INCLUDES = ["gi", "cgi", "colorsys", "site"]
|
||||
PACKAGES = [
|
||||
"gi",
|
||||
"cairo",
|
||||
"xml",
|
||||
"bsddb3",
|
||||
"lxml",
|
||||
"PIL",
|
||||
"json",
|
||||
"csv",
|
||||
"sqlite3",
|
||||
"cProfile",
|
||||
"networkx",
|
||||
"psycopg2",
|
||||
"requests",
|
||||
"logging",
|
||||
"html",
|
||||
"compileall",
|
||||
"graphviz",
|
||||
"pydotplus",
|
||||
"pygraphviz",
|
||||
"pydot",
|
||||
]
|
||||
EXCLUDES = [
|
||||
"tkinter",
|
||||
"PyQt5",
|
||||
"PyQt5.QtCore",
|
||||
"PyQt5.QtGui",
|
||||
"pyside" "PyQt5.QtWidgets",
|
||||
"sip",
|
||||
"lib2to3",
|
||||
"PIL.ImageQt",
|
||||
"pip",
|
||||
"distlib",
|
||||
]
|
||||
|
||||
REPLACE_PATHS = [('*', 'AIO/'),
|
||||
( site.getsitepackages()[0]
|
||||
+'cx_freeze-5.0-py3.6-mingw.egg/cx_Freeze', 'cx_Freeze/')
|
||||
]
|
||||
MISSING_DLL = ['libgtk-3-0.dll', 'libgtkspell3-3-0.dll', 'libgexiv2-2.dll',
|
||||
'libgoocanvas-3.0-9.dll', 'libosmgpsmap-1.0-1.dll',
|
||||
'gswin32c.exe', 'dot.exe', 'libgvplugin_core-6.dll',
|
||||
'libgvplugin_dot_layout-6.dll', 'libgvplugin_gd-6.dll',
|
||||
'libgvplugin_pango-6.dll', 'libgvplugin_rsvg-6.dll',
|
||||
'glib-compile-schemas.exe',
|
||||
'gdk-pixbuf-query-loaders.exe', 'gtk-update-icon-cache-3.0.exe',
|
||||
'fc-cache.exe', 'fc-match.exe', 'gspawn-win64-helper-console.exe',
|
||||
'gspawn-win64-helper.exe', 'libgeocode-glib-0.dll'
|
||||
]
|
||||
BIN_EXCLUDES = ['Qt5Core.dll', 'gdiplus.dll', 'gdiplus']
|
||||
REPLACE_PATHS = [
|
||||
("*", "AIO/"),
|
||||
(
|
||||
site.getsitepackages()[0] + "cx_freeze-5.0-py3.6-mingw.egg/cx_Freeze",
|
||||
"cx_Freeze/",
|
||||
),
|
||||
]
|
||||
MISSING_DLL = [
|
||||
"libgtk-3-0.dll",
|
||||
"libgtkspell3-3-0.dll",
|
||||
"libgexiv2-2.dll",
|
||||
"libgoocanvas-3.0-9.dll",
|
||||
"libosmgpsmap-1.0-1.dll",
|
||||
"gswin32c.exe",
|
||||
"dot.exe",
|
||||
"libgvplugin_core-6.dll",
|
||||
"libgvplugin_dot_layout-6.dll",
|
||||
"libgvplugin_gd-6.dll",
|
||||
"libgvplugin_pango-6.dll",
|
||||
"libgvplugin_rsvg-6.dll",
|
||||
"glib-compile-schemas.exe",
|
||||
"gdk-pixbuf-query-loaders.exe",
|
||||
"gtk-update-icon-cache-3.0.exe",
|
||||
"fc-cache.exe",
|
||||
"fc-match.exe",
|
||||
"gspawn-win64-helper-console.exe",
|
||||
"gspawn-win64-helper.exe",
|
||||
"libgeocode-glib-0.dll",
|
||||
]
|
||||
BIN_EXCLUDES = ["Qt5Core.dll", "gdiplus.dll", "gdiplus"]
|
||||
|
||||
from os.path import dirname, basename
|
||||
import lib2to3
|
||||
lib23_path = dirname(lib2to3.__file__)
|
||||
INCLUDE_FILES.append((lib23_path, 'lib/lib2to3'))
|
||||
import pip
|
||||
libpip_path = dirname(pip.__file__)
|
||||
INCLUDE_FILES.append((libpip_path,'lib/pip'))
|
||||
import distlib
|
||||
libdistlib_path = dirname(distlib.__file__)
|
||||
INCLUDE_FILES.append((libdistlib_path,'lib/distlib'))
|
||||
|
||||
os.makedirs(os.path.join(BASE_DIR, 'var/cache/fontconfig'), exist_ok=True)
|
||||
lib23_path = dirname(lib2to3.__file__)
|
||||
INCLUDE_FILES.append((lib23_path, "lib/lib2to3"))
|
||||
import pip
|
||||
|
||||
libpip_path = dirname(pip.__file__)
|
||||
INCLUDE_FILES.append((libpip_path, "lib/pip"))
|
||||
import distlib
|
||||
|
||||
libdistlib_path = dirname(distlib.__file__)
|
||||
INCLUDE_FILES.append((libdistlib_path, "lib/distlib"))
|
||||
|
||||
os.makedirs(os.path.join(BASE_DIR, "var/cache/fontconfig"), exist_ok=True)
|
||||
for file in SETUP_FILES:
|
||||
INCLUDE_FILES.append((os.path.join(SETUP_DIR, file),
|
||||
os.path.join('src', file)))
|
||||
INCLUDE_FILES.append((os.path.join(SETUP_DIR, file), os.path.join("src", file)))
|
||||
for dll in MISSING_DLL:
|
||||
INCLUDE_FILES.append((os.path.join(INCLUDE_DLL_PATH, dll),
|
||||
os.path.join('lib',dll)))
|
||||
MISSING_LIBS = ['lib/enchant-2', 'lib/gdk-pixbuf-2.0', 'lib/girepository-1.0',
|
||||
'share/enchant', 'share/glib-2.0/schemas',
|
||||
'share/xml/iso-codes', 'etc/gtk-3.0',
|
||||
'etc/ssl/certs', 'etc/ssl/cert.pem', 'etc/fonts', 'lib/gio',
|
||||
'share/icons/gnome',
|
||||
'share/icons/hicolor', 'share/icons/gramps.png',
|
||||
'share/icons/Adwaita/icon-theme.cache',
|
||||
'share/icons/Adwaita/index.theme', 'share/hunspell'
|
||||
]
|
||||
ADWAITA = ['8x8', '16x16', '22x22', '24x24', '32x32', '48x48', '64x64',
|
||||
'96x96', 'cursors'
|
||||
]
|
||||
INCLUDE_FILES.append(
|
||||
(os.path.join(INCLUDE_DLL_PATH, dll), os.path.join("lib", dll))
|
||||
)
|
||||
MISSING_LIBS = [
|
||||
"lib/enchant-2",
|
||||
"lib/gdk-pixbuf-2.0",
|
||||
"lib/girepository-1.0",
|
||||
"share/enchant",
|
||||
"share/glib-2.0/schemas",
|
||||
"share/xml/iso-codes",
|
||||
"etc/gtk-3.0",
|
||||
"etc/ssl/certs",
|
||||
"etc/ssl/cert.pem",
|
||||
"etc/fonts",
|
||||
"lib/gio",
|
||||
"share/icons/gnome",
|
||||
"share/icons/hicolor",
|
||||
"share/icons/gramps.png",
|
||||
"share/icons/Adwaita/icon-theme.cache",
|
||||
"share/icons/Adwaita/index.theme",
|
||||
"share/hunspell",
|
||||
]
|
||||
ADWAITA = [
|
||||
"8x8",
|
||||
"16x16",
|
||||
"22x22",
|
||||
"24x24",
|
||||
"32x32",
|
||||
"48x48",
|
||||
"64x64",
|
||||
"96x96",
|
||||
"cursors",
|
||||
]
|
||||
for adw in ADWAITA:
|
||||
INCLUDE_FILES.append((os.path.join(sys.prefix, 'share/icons/Adwaita', adw),
|
||||
os.path.join('share/icons/Adwaita', adw)))
|
||||
INCLUDE_FILES.append(
|
||||
(
|
||||
os.path.join(sys.prefix, "share/icons/Adwaita", adw),
|
||||
os.path.join("share/icons/Adwaita", adw),
|
||||
)
|
||||
)
|
||||
for lib in MISSING_LIBS:
|
||||
INCLUDE_FILES.append((os.path.join(sys.prefix, lib), lib))
|
||||
|
||||
INCLUDE_FILES.append('dist/gramps')
|
||||
INCLUDE_FILES.append(('dist/gramps-' + '.'.join(map(str, VERSION_TUPLE)) + '.data/data/share','share'))
|
||||
EXECUTABLES = [cx_Freeze.Executable("grampsaioc.py", base="Console",
|
||||
target_name='gramps.exe',
|
||||
icon='gramps.ico', copyright=COPYRIGHT),
|
||||
cx_Freeze.Executable("grampsaiow.py", base="Win32GUI",
|
||||
target_name='grampsw.exe',
|
||||
icon='gramps.ico', copyright=COPYRIGHT),
|
||||
cx_Freeze.Executable("grampsaiocd.py", base="Console",
|
||||
target_name='grampsd.exe',
|
||||
icon='grampsd.ico', copyright=COPYRIGHT)
|
||||
]
|
||||
BUILD_EXE_OPTIONS = {'packages':PACKAGES,
|
||||
'includes':INCLUDES,
|
||||
'excludes':EXCLUDES,
|
||||
'include_files':INCLUDE_FILES,
|
||||
'bin_includes':MISSING_DLL,
|
||||
'zip_include_packages': '*', #ZIP_INCLUDE_PACKAGES,
|
||||
'zip_exclude_packages':EXCLUDES,
|
||||
'bin_excludes':BIN_EXCLUDES,
|
||||
'replace_paths':REPLACE_PATHS,
|
||||
'build_exe':BASE_DIR,
|
||||
}
|
||||
BDIST_MSI_OPTIONS = { #uuid.uuid5(uuid.NAMESPACE_DNS, 'GrampsAIO64-5-trunk')
|
||||
'upgrade_code': '{fbccc04b-7b2e-56d3-8bb7-94d5f68de822}',
|
||||
#uuid.uuid5(uuid.NAMESPACE_DNS, 'v5.0.0-alpha1-476-g473d3aa')
|
||||
'product_code': '{48304362-2945-5a10-ad60-241f233be4d2}',
|
||||
'add_to_path': False,
|
||||
INCLUDE_FILES.append("dist/gramps")
|
||||
INCLUDE_FILES.append(
|
||||
("dist/gramps-" + ".".join(map(str, VERSION_TUPLE)) + ".data/data/share", "share")
|
||||
)
|
||||
EXECUTABLES = [
|
||||
cx_Freeze.Executable(
|
||||
"grampsaioc.py",
|
||||
base="Console",
|
||||
target_name="gramps.exe",
|
||||
icon="gramps.ico",
|
||||
copyright=COPYRIGHT,
|
||||
),
|
||||
cx_Freeze.Executable(
|
||||
"grampsaiow.py",
|
||||
base="Win32GUI",
|
||||
target_name="grampsw.exe",
|
||||
icon="gramps.ico",
|
||||
copyright=COPYRIGHT,
|
||||
),
|
||||
cx_Freeze.Executable(
|
||||
"grampsaiocd.py",
|
||||
base="Console",
|
||||
target_name="grampsd.exe",
|
||||
icon="grampsd.ico",
|
||||
copyright=COPYRIGHT,
|
||||
),
|
||||
]
|
||||
BUILD_EXE_OPTIONS = {
|
||||
"packages": PACKAGES,
|
||||
"includes": INCLUDES,
|
||||
"excludes": EXCLUDES,
|
||||
"include_files": INCLUDE_FILES,
|
||||
"bin_includes": MISSING_DLL,
|
||||
"zip_include_packages": "*", # ZIP_INCLUDE_PACKAGES,
|
||||
"zip_exclude_packages": EXCLUDES,
|
||||
"bin_excludes": BIN_EXCLUDES,
|
||||
"replace_paths": REPLACE_PATHS,
|
||||
"build_exe": BASE_DIR,
|
||||
}
|
||||
BDIST_MSI_OPTIONS = { # uuid.uuid5(uuid.NAMESPACE_DNS, 'GrampsAIO64-5-trunk')
|
||||
"upgrade_code": "{fbccc04b-7b2e-56d3-8bb7-94d5f68de822}",
|
||||
# uuid.uuid5(uuid.NAMESPACE_DNS, 'v5.0.0-alpha1-476-g473d3aa')
|
||||
"product_code": "{48304362-2945-5a10-ad60-241f233be4d2}",
|
||||
"add_to_path": False,
|
||||
#'initial_target_dir': r'[ProgramFilesFolder]\%s\%s' %
|
||||
#(company_name, product_name),
|
||||
}
|
||||
# (company_name, product_name),
|
||||
}
|
||||
cx_Freeze.setup(
|
||||
name="GrampsAIO32" if '32' in BASE_DIR else "GrampsAIO64",
|
||||
options={"build_exe": BUILD_EXE_OPTIONS, 'bdist_msi': BDIST_MSI_OPTIONS},
|
||||
name="GrampsAIO32" if "32" in BASE_DIR else "GrampsAIO64",
|
||||
options={"build_exe": BUILD_EXE_OPTIONS, "bdist_msi": BDIST_MSI_OPTIONS},
|
||||
version=VERSION,
|
||||
description="Gramps Genealogy software",
|
||||
long_description=VERSION_QUALIFIER,
|
||||
executables=EXECUTABLES)
|
||||
executables=EXECUTABLES,
|
||||
)
|
||||
|
||||
ZIN = zipfile.ZipFile(os.path.join(BASE_DIR, 'lib/library.zip'), 'r')
|
||||
ZOUT = zipfile.ZipFile(os.path.join(BASE_DIR, 'lib/pythonx.zip'), 'w')
|
||||
ZIN = zipfile.ZipFile(os.path.join(BASE_DIR, "lib/library.zip"), "r")
|
||||
ZOUT = zipfile.ZipFile(os.path.join(BASE_DIR, "lib/pythonx.zip"), "w")
|
||||
for item in ZIN.infolist():
|
||||
if not os.path.dirname(item.filename).startswith('gramps'):
|
||||
#if '/test' in item.filename or 'test/' in item.filename:
|
||||
if not os.path.dirname(item.filename).startswith("gramps"):
|
||||
# if '/test' in item.filename or 'test/' in item.filename:
|
||||
# print("Zip Excluded:", item.filename)
|
||||
#else:
|
||||
# else:
|
||||
print("Zip Included:", item.filename)
|
||||
buffer = ZIN.read(item.filename)
|
||||
ZOUT.writestr(item, buffer)
|
||||
ZOUT.close()
|
||||
ZIN.close()
|
||||
shutil.move(os.path.join(BASE_DIR, 'lib/pythonx.zip'),
|
||||
os.path.join(BASE_DIR, 'lib/library.zip'))
|
||||
shutil.move(
|
||||
os.path.join(BASE_DIR, "lib/pythonx.zip"), os.path.join(BASE_DIR, "lib/library.zip")
|
||||
)
|
||||
|
||||
if os.path.isfile(UPX_ALT_PATH):
|
||||
UPX = UPX_ALT_PATH
|
||||
else:
|
||||
WHICH = 'where' if os.name == 'nt' else 'which'
|
||||
WHICH = "where" if os.name == "nt" else "which"
|
||||
try:
|
||||
subprocess.check_call([WHICH, 'UPX'])
|
||||
subprocess.check_call([WHICH, "UPX"])
|
||||
except subprocess.CalledProcessError:
|
||||
UPX = None
|
||||
else:
|
||||
UPX = 'upx'
|
||||
UPX = "upx"
|
||||
if UPX is not None:
|
||||
ARGS = [UPX, '-7', '--no-progress']
|
||||
ARGS.extend(os.path.join(BASE_DIR, filename) for filename in
|
||||
os.listdir(BASE_DIR) if filename == 'name' or
|
||||
os.path.splitext(filename)[1].lower() in
|
||||
('.exe', '.dll', '.pyd', '.so') and
|
||||
os.path.splitext(filename)[0].lower() not in
|
||||
('libgcc_s_dw2-1', 'gramps', 'grampsw', 'grampsd',
|
||||
'libwinpthread-1'))
|
||||
ARGS = [UPX, "-7", "--no-progress"]
|
||||
ARGS.extend(
|
||||
os.path.join(BASE_DIR, filename)
|
||||
for filename in os.listdir(BASE_DIR)
|
||||
if filename == "name"
|
||||
or os.path.splitext(filename)[1].lower() in (".exe", ".dll", ".pyd", ".so")
|
||||
and os.path.splitext(filename)[0].lower()
|
||||
not in ("libgcc_s_dw2-1", "gramps", "grampsw", "grampsd", "libwinpthread-1")
|
||||
)
|
||||
subprocess.call(ARGS)
|
||||
else:
|
||||
print("\nUPX not found")
|
||||
|
||||
138
data/man/conf.py
138
data/man/conf.py
@@ -16,210 +16,204 @@ import sys, os
|
||||
# If extensions (or modules to document with autodoc) are in another directory,
|
||||
# add these directories to sys.path here. If the directory is relative to the
|
||||
# documentation root, use os.path.abspath to make it absolute, like shown here.
|
||||
#sys.path.insert(0, os.path.abspath('.'))
|
||||
# sys.path.insert(0, os.path.abspath('.'))
|
||||
|
||||
# -- General configuration -----------------------------------------------------
|
||||
|
||||
# If your documentation needs a minimal Sphinx version, state it here.
|
||||
#needs_sphinx = '1.0'
|
||||
# needs_sphinx = '1.0'
|
||||
|
||||
# Add any Sphinx extension module names here, as strings. They can be extensions
|
||||
# coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
|
||||
extensions = []
|
||||
|
||||
# Add any paths that contain templates here, relative to this directory.
|
||||
templates_path = ['_templates']
|
||||
templates_path = ["_templates"]
|
||||
|
||||
# The suffix of source filenames.
|
||||
source_suffix = '.rst'
|
||||
source_suffix = ".rst"
|
||||
|
||||
# The encoding of source files.
|
||||
#source_encoding = 'utf-8-sig'
|
||||
# source_encoding = 'utf-8-sig'
|
||||
|
||||
# The master toctree document.
|
||||
master_doc = 'index'
|
||||
master_doc = "index"
|
||||
|
||||
# General information about the project.
|
||||
project = u'Gramps'
|
||||
copyright = u'2015, Gramps project'
|
||||
project = "Gramps"
|
||||
copyright = "2015, Gramps project"
|
||||
|
||||
# The version info for the project you're documenting, acts as replacement for
|
||||
# |version| and |release|, also used in various other places throughout the
|
||||
# built documents.
|
||||
#
|
||||
# The short X.Y version.
|
||||
version = '4.2'
|
||||
version = "4.2"
|
||||
# The full version, including alpha/beta/rc tags.
|
||||
release = '4.2.0'
|
||||
release = "4.2.0"
|
||||
|
||||
# The language for content autogenerated by Sphinx. Refer to documentation
|
||||
# for a list of supported languages.
|
||||
#locale_dirs = './locale'
|
||||
#gettext_compact = True
|
||||
# locale_dirs = './locale'
|
||||
# gettext_compact = True
|
||||
|
||||
# There are two options for replacing |today|: either, you set today to some
|
||||
# non-false value, then it is used:
|
||||
#today = ''
|
||||
# today = ''
|
||||
# Else, today_fmt is used as the format for a strftime call.
|
||||
today_fmt = '%B %d, %Y'
|
||||
today_fmt = "%B %d, %Y"
|
||||
|
||||
# List of patterns, relative to source directory, that match files and
|
||||
# directories to ignore when looking for source files.
|
||||
exclude_patterns = ['_build']
|
||||
exclude_patterns = ["_build"]
|
||||
|
||||
# The reST default role (used for this markup: `text`) to use for all documents.
|
||||
#default_role = None
|
||||
# default_role = None
|
||||
|
||||
# If true, '()' will be appended to :func: etc. cross-reference text.
|
||||
#add_function_parentheses = True
|
||||
# add_function_parentheses = True
|
||||
|
||||
# If true, the current module name will be prepended to all description
|
||||
# unit titles (such as .. function::).
|
||||
#add_module_names = True
|
||||
# add_module_names = True
|
||||
|
||||
# If true, sectionauthor and moduleauthor directives will be shown in the
|
||||
# output. They are ignored by default.
|
||||
#show_authors = False
|
||||
# show_authors = False
|
||||
|
||||
# The name of the Pygments (syntax highlighting) style to use.
|
||||
pygments_style = 'sphinx'
|
||||
pygments_style = "sphinx"
|
||||
|
||||
# A list of ignored prefixes for module index sorting.
|
||||
#modindex_common_prefix = []
|
||||
# modindex_common_prefix = []
|
||||
|
||||
|
||||
# -- Options for HTML output ---------------------------------------------------
|
||||
|
||||
# The theme to use for HTML and HTML Help pages. See the documentation for
|
||||
# a list of builtin themes.
|
||||
html_theme = 'default'
|
||||
html_theme = "default"
|
||||
|
||||
# Theme options are theme-specific and customize the look and feel of a theme
|
||||
# further. For a list of options available for each theme, see the
|
||||
# documentation.
|
||||
#html_theme_options = {}
|
||||
# html_theme_options = {}
|
||||
|
||||
# Add any paths that contain custom themes here, relative to this directory.
|
||||
#html_theme_path = []
|
||||
# html_theme_path = []
|
||||
|
||||
# The name for this set of Sphinx documents. If None, it defaults to
|
||||
# "<project> v<release> documentation".
|
||||
#html_title = None
|
||||
# html_title = None
|
||||
|
||||
# A shorter title for the navigation bar. Default is the same as html_title.
|
||||
#html_short_title = None
|
||||
# html_short_title = None
|
||||
|
||||
# The name of an image file (relative to this directory) to place at the top
|
||||
# of the sidebar.
|
||||
#html_logo = None
|
||||
# html_logo = None
|
||||
|
||||
# The name of an image file (within the static path) to use as favicon of the
|
||||
# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32
|
||||
# pixels large.
|
||||
#html_favicon = None
|
||||
# html_favicon = None
|
||||
|
||||
# Add any paths that contain custom static files (such as style sheets) here,
|
||||
# relative to this directory. They are copied after the builtin static files,
|
||||
# so a file named "default.css" will overwrite the builtin "default.css".
|
||||
#html_static_path = ['_static']
|
||||
# html_static_path = ['_static']
|
||||
|
||||
# If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
|
||||
# using the given strftime format.
|
||||
#html_last_updated_fmt = '%b %d, %Y'
|
||||
# html_last_updated_fmt = '%b %d, %Y'
|
||||
|
||||
# If true, SmartyPants will be used to convert quotes and dashes to
|
||||
# typographically correct entities.
|
||||
#html_use_smartypants = True
|
||||
# html_use_smartypants = True
|
||||
|
||||
# Custom sidebar templates, maps document names to template names.
|
||||
#html_sidebars = {}
|
||||
# html_sidebars = {}
|
||||
|
||||
# Additional templates that should be rendered to pages, maps page names to
|
||||
# template names.
|
||||
#html_additional_pages = {}
|
||||
# html_additional_pages = {}
|
||||
|
||||
# If false, no module index is generated.
|
||||
#html_domain_indices = True
|
||||
# html_domain_indices = True
|
||||
|
||||
# If false, no index is generated.
|
||||
#html_use_index = True
|
||||
# html_use_index = True
|
||||
|
||||
# If true, the index is split into individual pages for each letter.
|
||||
#html_split_index = False
|
||||
# html_split_index = False
|
||||
|
||||
# If true, links to the reST sources are added to the pages.
|
||||
#html_show_sourcelink = True
|
||||
# html_show_sourcelink = True
|
||||
|
||||
# If true, "Created using Sphinx" is shown in the HTML footer. Default is True.
|
||||
#html_show_sphinx = True
|
||||
# html_show_sphinx = True
|
||||
|
||||
# If true, "(C) Copyright ..." is shown in the HTML footer. Default is True.
|
||||
#html_show_copyright = True
|
||||
# html_show_copyright = True
|
||||
|
||||
# If true, an OpenSearch description file will be output, and all pages will
|
||||
# contain a <link> tag referring to it. The value of this option must be the
|
||||
# base URL from which the finished HTML is served.
|
||||
#html_use_opensearch = ''
|
||||
# html_use_opensearch = ''
|
||||
|
||||
# This is the file name suffix for HTML files (e.g. ".xhtml").
|
||||
#html_file_suffix = None
|
||||
# html_file_suffix = None
|
||||
|
||||
# Output file base name for HTML help builder.
|
||||
htmlhelp_basename = 'Grampsdoc'
|
||||
htmlhelp_basename = "Grampsdoc"
|
||||
|
||||
|
||||
# -- Options for LaTeX output --------------------------------------------------
|
||||
|
||||
latex_elements = {
|
||||
# The paper size ('letterpaper' or 'a4paper').
|
||||
#'papersize': 'letterpaper',
|
||||
|
||||
# The font size ('10pt', '11pt' or '12pt').
|
||||
#'pointsize': '10pt',
|
||||
|
||||
# Additional stuff for the LaTeX preamble.
|
||||
#'preamble': '',
|
||||
# The paper size ('letterpaper' or 'a4paper').
|
||||
#'papersize': 'letterpaper',
|
||||
# The font size ('10pt', '11pt' or '12pt').
|
||||
#'pointsize': '10pt',
|
||||
# Additional stuff for the LaTeX preamble.
|
||||
#'preamble': '',
|
||||
}
|
||||
|
||||
# Grouping the document tree into LaTeX files. List of tuples
|
||||
# (source start file, target name, title, author, documentclass [howto/manual]).
|
||||
latex_documents = [
|
||||
('index', 'Gramps.tex', u'Gramps Documentation',
|
||||
u'.', 'manual'),
|
||||
("index", "Gramps.tex", "Gramps Documentation", ".", "manual"),
|
||||
]
|
||||
|
||||
# The name of an image file (relative to this directory) to place at the top of
|
||||
# the title page.
|
||||
#latex_logo = None
|
||||
# latex_logo = None
|
||||
|
||||
# For "manual" documents, if this is true, then toplevel headings are parts,
|
||||
# not chapters.
|
||||
#latex_use_parts = False
|
||||
# latex_use_parts = False
|
||||
|
||||
# If true, show page references after internal links.
|
||||
#latex_show_pagerefs = False
|
||||
# latex_show_pagerefs = False
|
||||
|
||||
# If true, show URL addresses after external links.
|
||||
#latex_show_urls = False
|
||||
# latex_show_urls = False
|
||||
|
||||
# Documents to append as an appendix to all manuals.
|
||||
#latex_appendices = []
|
||||
# latex_appendices = []
|
||||
|
||||
# If false, no module index is generated.
|
||||
#latex_domain_indices = True
|
||||
# latex_domain_indices = True
|
||||
|
||||
|
||||
# -- Options for manual page output --------------------------------------------
|
||||
|
||||
# One entry per manual page. List of tuples
|
||||
# (source start file, name, description, authors, manual section).
|
||||
man_pages = [
|
||||
('en', 'gramps', u'Gramps Documentation',
|
||||
['Gramps project'], 1)
|
||||
]
|
||||
man_pages = [("en", "gramps", "Gramps Documentation", ["Gramps project"], 1)]
|
||||
|
||||
# If true, show URL addresses after external links.
|
||||
#man_show_urls = False
|
||||
# man_show_urls = False
|
||||
|
||||
|
||||
# -- Options for Texinfo output ------------------------------------------------
|
||||
@@ -228,16 +222,22 @@ man_pages = [
|
||||
# (source start file, target name, title, author,
|
||||
# dir menu entry, description, category)
|
||||
texinfo_documents = [
|
||||
('index', 'Gramps', u'Gramps Documentation',
|
||||
u'.', 'Gramps', 'One line description of project.',
|
||||
'Miscellaneous'),
|
||||
(
|
||||
"index",
|
||||
"Gramps",
|
||||
"Gramps Documentation",
|
||||
".",
|
||||
"Gramps",
|
||||
"One line description of project.",
|
||||
"Miscellaneous",
|
||||
),
|
||||
]
|
||||
|
||||
# Documents to append as an appendix to all manuals.
|
||||
#texinfo_appendices = []
|
||||
# texinfo_appendices = []
|
||||
|
||||
# If false, no module index is generated.
|
||||
#texinfo_domain_indices = True
|
||||
# texinfo_domain_indices = True
|
||||
|
||||
# How to display URL addresses: 'footnote', 'no', or 'inline'.
|
||||
#texinfo_show_urls = 'footnote'
|
||||
# texinfo_show_urls = 'footnote'
|
||||
|
||||
@@ -16,210 +16,204 @@ import sys, os
|
||||
# If extensions (or modules to document with autodoc) are in another directory,
|
||||
# add these directories to sys.path here. If the directory is relative to the
|
||||
# documentation root, use os.path.abspath to make it absolute, like shown here.
|
||||
#sys.path.insert(0, os.path.abspath('.'))
|
||||
# sys.path.insert(0, os.path.abspath('.'))
|
||||
|
||||
# -- General configuration -----------------------------------------------------
|
||||
|
||||
# If your documentation needs a minimal Sphinx version, state it here.
|
||||
#needs_sphinx = '1.0'
|
||||
# needs_sphinx = '1.0'
|
||||
|
||||
# Add any Sphinx extension module names here, as strings. They can be extensions
|
||||
# coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
|
||||
extensions = []
|
||||
|
||||
# Add any paths that contain templates here, relative to this directory.
|
||||
templates_path = ['_templates']
|
||||
templates_path = ["_templates"]
|
||||
|
||||
# The suffix of source filenames.
|
||||
source_suffix = '.rst'
|
||||
source_suffix = ".rst"
|
||||
|
||||
# The encoding of source files.
|
||||
#source_encoding = 'utf-8-sig'
|
||||
# source_encoding = 'utf-8-sig'
|
||||
|
||||
# The master toctree document.
|
||||
master_doc = 'cs'
|
||||
master_doc = "cs"
|
||||
|
||||
# General information about the project.
|
||||
project = u'Gramps'
|
||||
copyright = u'2015, Gramps project'
|
||||
project = "Gramps"
|
||||
copyright = "2015, Gramps project"
|
||||
|
||||
# The version info for the project you're documenting, acts as replacement for
|
||||
# |version| and |release|, also used in various other places throughout the
|
||||
# built documents.
|
||||
#
|
||||
# The short X.Y version.
|
||||
version = '4.2'
|
||||
version = "4.2"
|
||||
# The full version, including alpha/beta/rc tags.
|
||||
release = '4.2.0'
|
||||
release = "4.2.0"
|
||||
|
||||
# The language for content autogenerated by Sphinx. Refer to documentation
|
||||
# for a list of supported languages.
|
||||
locale_dirs = './locale'
|
||||
locale_dirs = "./locale"
|
||||
gettext_compact = True
|
||||
|
||||
# There are two options for replacing |today|: either, you set today to some
|
||||
# non-false value, then it is used:
|
||||
#today = ''
|
||||
# today = ''
|
||||
# Else, today_fmt is used as the format for a strftime call.
|
||||
today_fmt = '%B %d, %Y'
|
||||
today_fmt = "%B %d, %Y"
|
||||
|
||||
# List of patterns, relative to source directory, that match files and
|
||||
# directories to ignore when looking for source files.
|
||||
exclude_patterns = ['_build']
|
||||
exclude_patterns = ["_build"]
|
||||
|
||||
# The reST default role (used for this markup: `text`) to use for all documents.
|
||||
#default_role = None
|
||||
# default_role = None
|
||||
|
||||
# If true, '()' will be appended to :func: etc. cross-reference text.
|
||||
#add_function_parentheses = True
|
||||
# add_function_parentheses = True
|
||||
|
||||
# If true, the current module name will be prepended to all description
|
||||
# unit titles (such as .. function::).
|
||||
#add_module_names = True
|
||||
# add_module_names = True
|
||||
|
||||
# If true, sectionauthor and moduleauthor directives will be shown in the
|
||||
# output. They are ignored by default.
|
||||
#show_authors = False
|
||||
# show_authors = False
|
||||
|
||||
# The name of the Pygments (syntax highlighting) style to use.
|
||||
pygments_style = 'sphinx'
|
||||
pygments_style = "sphinx"
|
||||
|
||||
# A list of ignored prefixes for module index sorting.
|
||||
#modindex_common_prefix = []
|
||||
# modindex_common_prefix = []
|
||||
|
||||
|
||||
# -- Options for HTML output ---------------------------------------------------
|
||||
|
||||
# The theme to use for HTML and HTML Help pages. See the documentation for
|
||||
# a list of builtin themes.
|
||||
html_theme = 'default'
|
||||
html_theme = "default"
|
||||
|
||||
# Theme options are theme-specific and customize the look and feel of a theme
|
||||
# further. For a list of options available for each theme, see the
|
||||
# documentation.
|
||||
#html_theme_options = {}
|
||||
# html_theme_options = {}
|
||||
|
||||
# Add any paths that contain custom themes here, relative to this directory.
|
||||
#html_theme_path = []
|
||||
# html_theme_path = []
|
||||
|
||||
# The name for this set of Sphinx documents. If None, it defaults to
|
||||
# "<project> v<release> documentation".
|
||||
#html_title = None
|
||||
# html_title = None
|
||||
|
||||
# A shorter title for the navigation bar. Default is the same as html_title.
|
||||
#html_short_title = None
|
||||
# html_short_title = None
|
||||
|
||||
# The name of an image file (relative to this directory) to place at the top
|
||||
# of the sidebar.
|
||||
#html_logo = None
|
||||
# html_logo = None
|
||||
|
||||
# The name of an image file (within the static path) to use as favicon of the
|
||||
# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32
|
||||
# pixels large.
|
||||
#html_favicon = None
|
||||
# html_favicon = None
|
||||
|
||||
# Add any paths that contain custom static files (such as style sheets) here,
|
||||
# relative to this directory. They are copied after the builtin static files,
|
||||
# so a file named "default.css" will overwrite the builtin "default.css".
|
||||
#html_static_path = ['_static']
|
||||
# html_static_path = ['_static']
|
||||
|
||||
# If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
|
||||
# using the given strftime format.
|
||||
#html_last_updated_fmt = '%b %d, %Y'
|
||||
# html_last_updated_fmt = '%b %d, %Y'
|
||||
|
||||
# If true, SmartyPants will be used to convert quotes and dashes to
|
||||
# typographically correct entities.
|
||||
#html_use_smartypants = True
|
||||
# html_use_smartypants = True
|
||||
|
||||
# Custom sidebar templates, maps document names to template names.
|
||||
#html_sidebars = {}
|
||||
# html_sidebars = {}
|
||||
|
||||
# Additional templates that should be rendered to pages, maps page names to
|
||||
# template names.
|
||||
#html_additional_pages = {}
|
||||
# html_additional_pages = {}
|
||||
|
||||
# If false, no module index is generated.
|
||||
#html_domain_indices = True
|
||||
# html_domain_indices = True
|
||||
|
||||
# If false, no index is generated.
|
||||
#html_use_index = True
|
||||
# html_use_index = True
|
||||
|
||||
# If true, the index is split into individual pages for each letter.
|
||||
#html_split_index = False
|
||||
# html_split_index = False
|
||||
|
||||
# If true, links to the reST sources are added to the pages.
|
||||
#html_show_sourcelink = True
|
||||
# html_show_sourcelink = True
|
||||
|
||||
# If true, "Created using Sphinx" is shown in the HTML footer. Default is True.
|
||||
#html_show_sphinx = True
|
||||
# html_show_sphinx = True
|
||||
|
||||
# If true, "(C) Copyright ..." is shown in the HTML footer. Default is True.
|
||||
#html_show_copyright = True
|
||||
# html_show_copyright = True
|
||||
|
||||
# If true, an OpenSearch description file will be output, and all pages will
|
||||
# contain a <link> tag referring to it. The value of this option must be the
|
||||
# base URL from which the finished HTML is served.
|
||||
#html_use_opensearch = ''
|
||||
# html_use_opensearch = ''
|
||||
|
||||
# This is the file name suffix for HTML files (e.g. ".xhtml").
|
||||
#html_file_suffix = None
|
||||
# html_file_suffix = None
|
||||
|
||||
# Output file base name for HTML help builder.
|
||||
htmlhelp_basename = 'Grampsdoc'
|
||||
htmlhelp_basename = "Grampsdoc"
|
||||
|
||||
|
||||
# -- Options for LaTeX output --------------------------------------------------
|
||||
|
||||
latex_elements = {
|
||||
# The paper size ('letterpaper' or 'a4paper').
|
||||
#'papersize': 'letterpaper',
|
||||
|
||||
# The font size ('10pt', '11pt' or '12pt').
|
||||
#'pointsize': '10pt',
|
||||
|
||||
# Additional stuff for the LaTeX preamble.
|
||||
#'preamble': '',
|
||||
# The paper size ('letterpaper' or 'a4paper').
|
||||
#'papersize': 'letterpaper',
|
||||
# The font size ('10pt', '11pt' or '12pt').
|
||||
#'pointsize': '10pt',
|
||||
# Additional stuff for the LaTeX preamble.
|
||||
#'preamble': '',
|
||||
}
|
||||
|
||||
# Grouping the document tree into LaTeX files. List of tuples
|
||||
# (source start file, target name, title, author, documentclass [howto/manual]).
|
||||
latex_documents = [
|
||||
('index', 'Gramps.tex', u'Gramps Documentation',
|
||||
u'.', 'manual'),
|
||||
("index", "Gramps.tex", "Gramps Documentation", ".", "manual"),
|
||||
]
|
||||
|
||||
# The name of an image file (relative to this directory) to place at the top of
|
||||
# the title page.
|
||||
#latex_logo = None
|
||||
# latex_logo = None
|
||||
|
||||
# For "manual" documents, if this is true, then toplevel headings are parts,
|
||||
# not chapters.
|
||||
#latex_use_parts = False
|
||||
# latex_use_parts = False
|
||||
|
||||
# If true, show page references after internal links.
|
||||
#latex_show_pagerefs = False
|
||||
# latex_show_pagerefs = False
|
||||
|
||||
# If true, show URL addresses after external links.
|
||||
#latex_show_urls = False
|
||||
# latex_show_urls = False
|
||||
|
||||
# Documents to append as an appendix to all manuals.
|
||||
#latex_appendices = []
|
||||
# latex_appendices = []
|
||||
|
||||
# If false, no module index is generated.
|
||||
#latex_domain_indices = True
|
||||
# latex_domain_indices = True
|
||||
|
||||
|
||||
# -- Options for manual page output --------------------------------------------
|
||||
|
||||
# One entry per manual page. List of tuples
|
||||
# (source start file, name, description, authors, manual section).
|
||||
man_pages = [
|
||||
('cs', 'gramps', u'Gramps Documentation',
|
||||
[u'.'], 1)
|
||||
]
|
||||
man_pages = [("cs", "gramps", "Gramps Documentation", ["."], 1)]
|
||||
|
||||
# If true, show URL addresses after external links.
|
||||
#man_show_urls = False
|
||||
# man_show_urls = False
|
||||
|
||||
|
||||
# -- Options for Texinfo output ------------------------------------------------
|
||||
@@ -228,16 +222,22 @@ man_pages = [
|
||||
# (source start file, target name, title, author,
|
||||
# dir menu entry, description, category)
|
||||
texinfo_documents = [
|
||||
('index', 'Gramps', u'Gramps Documentation',
|
||||
u'.', 'Gramps', 'One line description of project.',
|
||||
'Miscellaneous'),
|
||||
(
|
||||
"index",
|
||||
"Gramps",
|
||||
"Gramps Documentation",
|
||||
".",
|
||||
"Gramps",
|
||||
"One line description of project.",
|
||||
"Miscellaneous",
|
||||
),
|
||||
]
|
||||
|
||||
# Documents to append as an appendix to all manuals.
|
||||
#texinfo_appendices = []
|
||||
# texinfo_appendices = []
|
||||
|
||||
# If false, no module index is generated.
|
||||
#texinfo_domain_indices = True
|
||||
# texinfo_domain_indices = True
|
||||
|
||||
# How to display URL addresses: 'footnote', 'no', or 'inline'.
|
||||
#texinfo_show_urls = 'footnote'
|
||||
# texinfo_show_urls = 'footnote'
|
||||
|
||||
@@ -16,210 +16,204 @@ import sys, os
|
||||
# If extensions (or modules to document with autodoc) are in another directory,
|
||||
# add these directories to sys.path here. If the directory is relative to the
|
||||
# documentation root, use os.path.abspath to make it absolute, like shown here.
|
||||
#sys.path.insert(0, os.path.abspath('.'))
|
||||
# sys.path.insert(0, os.path.abspath('.'))
|
||||
|
||||
# -- General configuration -----------------------------------------------------
|
||||
|
||||
# If your documentation needs a minimal Sphinx version, state it here.
|
||||
#needs_sphinx = '1.0'
|
||||
# needs_sphinx = '1.0'
|
||||
|
||||
# Add any Sphinx extension module names here, as strings. They can be extensions
|
||||
# coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
|
||||
extensions = []
|
||||
|
||||
# Add any paths that contain templates here, relative to this directory.
|
||||
templates_path = ['_templates']
|
||||
templates_path = ["_templates"]
|
||||
|
||||
# The suffix of source filenames.
|
||||
source_suffix = '.rst'
|
||||
source_suffix = ".rst"
|
||||
|
||||
# The encoding of source files.
|
||||
#source_encoding = 'utf-8-sig'
|
||||
# source_encoding = 'utf-8-sig'
|
||||
|
||||
# The master toctree document.
|
||||
master_doc = 'fr'
|
||||
master_doc = "fr"
|
||||
|
||||
# General information about the project.
|
||||
project = u'Gramps'
|
||||
copyright = u'2015, Gramps project'
|
||||
project = "Gramps"
|
||||
copyright = "2015, Gramps project"
|
||||
|
||||
# The version info for the project you're documenting, acts as replacement for
|
||||
# |version| and |release|, also used in various other places throughout the
|
||||
# built documents.
|
||||
#
|
||||
# The short X.Y version.
|
||||
version = '4.2'
|
||||
version = "4.2"
|
||||
# The full version, including alpha/beta/rc tags.
|
||||
release = '4.2.0'
|
||||
release = "4.2.0"
|
||||
|
||||
# The language for content autogenerated by Sphinx. Refer to documentation
|
||||
# for a list of supported languages.
|
||||
locale_dirs = './locale'
|
||||
locale_dirs = "./locale"
|
||||
gettext_compact = True
|
||||
|
||||
# There are two options for replacing |today|: either, you set today to some
|
||||
# non-false value, then it is used:
|
||||
#today = ''
|
||||
# today = ''
|
||||
# Else, today_fmt is used as the format for a strftime call.
|
||||
today_fmt = '%d %B %Y'
|
||||
today_fmt = "%d %B %Y"
|
||||
|
||||
# List of patterns, relative to source directory, that match files and
|
||||
# directories to ignore when looking for source files.
|
||||
exclude_patterns = ['_build']
|
||||
exclude_patterns = ["_build"]
|
||||
|
||||
# The reST default role (used for this markup: `text`) to use for all documents.
|
||||
#default_role = None
|
||||
# default_role = None
|
||||
|
||||
# If true, '()' will be appended to :func: etc. cross-reference text.
|
||||
#add_function_parentheses = True
|
||||
# add_function_parentheses = True
|
||||
|
||||
# If true, the current module name will be prepended to all description
|
||||
# unit titles (such as .. function::).
|
||||
#add_module_names = True
|
||||
# add_module_names = True
|
||||
|
||||
# If true, sectionauthor and moduleauthor directives will be shown in the
|
||||
# output. They are ignored by default.
|
||||
#show_authors = False
|
||||
# show_authors = False
|
||||
|
||||
# The name of the Pygments (syntax highlighting) style to use.
|
||||
pygments_style = 'sphinx'
|
||||
pygments_style = "sphinx"
|
||||
|
||||
# A list of ignored prefixes for module index sorting.
|
||||
#modindex_common_prefix = []
|
||||
# modindex_common_prefix = []
|
||||
|
||||
|
||||
# -- Options for HTML output ---------------------------------------------------
|
||||
|
||||
# The theme to use for HTML and HTML Help pages. See the documentation for
|
||||
# a list of builtin themes.
|
||||
html_theme = 'default'
|
||||
html_theme = "default"
|
||||
|
||||
# Theme options are theme-specific and customize the look and feel of a theme
|
||||
# further. For a list of options available for each theme, see the
|
||||
# documentation.
|
||||
#html_theme_options = {}
|
||||
# html_theme_options = {}
|
||||
|
||||
# Add any paths that contain custom themes here, relative to this directory.
|
||||
#html_theme_path = []
|
||||
# html_theme_path = []
|
||||
|
||||
# The name for this set of Sphinx documents. If None, it defaults to
|
||||
# "<project> v<release> documentation".
|
||||
#html_title = None
|
||||
# html_title = None
|
||||
|
||||
# A shorter title for the navigation bar. Default is the same as html_title.
|
||||
#html_short_title = None
|
||||
# html_short_title = None
|
||||
|
||||
# The name of an image file (relative to this directory) to place at the top
|
||||
# of the sidebar.
|
||||
#html_logo = None
|
||||
# html_logo = None
|
||||
|
||||
# The name of an image file (within the static path) to use as favicon of the
|
||||
# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32
|
||||
# pixels large.
|
||||
#html_favicon = None
|
||||
# html_favicon = None
|
||||
|
||||
# Add any paths that contain custom static files (such as style sheets) here,
|
||||
# relative to this directory. They are copied after the builtin static files,
|
||||
# so a file named "default.css" will overwrite the builtin "default.css".
|
||||
#html_static_path = ['_static']
|
||||
# html_static_path = ['_static']
|
||||
|
||||
# If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
|
||||
# using the given strftime format.
|
||||
#html_last_updated_fmt = '%b %d, %Y'
|
||||
# html_last_updated_fmt = '%b %d, %Y'
|
||||
|
||||
# If true, SmartyPants will be used to convert quotes and dashes to
|
||||
# typographically correct entities.
|
||||
#html_use_smartypants = True
|
||||
# html_use_smartypants = True
|
||||
|
||||
# Custom sidebar templates, maps document names to template names.
|
||||
#html_sidebars = {}
|
||||
# html_sidebars = {}
|
||||
|
||||
# Additional templates that should be rendered to pages, maps page names to
|
||||
# template names.
|
||||
#html_additional_pages = {}
|
||||
# html_additional_pages = {}
|
||||
|
||||
# If false, no module index is generated.
|
||||
#html_domain_indices = True
|
||||
# html_domain_indices = True
|
||||
|
||||
# If false, no index is generated.
|
||||
#html_use_index = True
|
||||
# html_use_index = True
|
||||
|
||||
# If true, the index is split into individual pages for each letter.
|
||||
#html_split_index = False
|
||||
# html_split_index = False
|
||||
|
||||
# If true, links to the reST sources are added to the pages.
|
||||
#html_show_sourcelink = True
|
||||
# html_show_sourcelink = True
|
||||
|
||||
# If true, "Created using Sphinx" is shown in the HTML footer. Default is True.
|
||||
#html_show_sphinx = True
|
||||
# html_show_sphinx = True
|
||||
|
||||
# If true, "(C) Copyright ..." is shown in the HTML footer. Default is True.
|
||||
#html_show_copyright = True
|
||||
# html_show_copyright = True
|
||||
|
||||
# If true, an OpenSearch description file will be output, and all pages will
|
||||
# contain a <link> tag referring to it. The value of this option must be the
|
||||
# base URL from which the finished HTML is served.
|
||||
#html_use_opensearch = ''
|
||||
# html_use_opensearch = ''
|
||||
|
||||
# This is the file name suffix for HTML files (e.g. ".xhtml").
|
||||
#html_file_suffix = None
|
||||
# html_file_suffix = None
|
||||
|
||||
# Output file base name for HTML help builder.
|
||||
htmlhelp_basename = 'Grampsdoc'
|
||||
htmlhelp_basename = "Grampsdoc"
|
||||
|
||||
|
||||
# -- Options for LaTeX output --------------------------------------------------
|
||||
|
||||
latex_elements = {
|
||||
# The paper size ('letterpaper' or 'a4paper').
|
||||
#'papersize': 'letterpaper',
|
||||
|
||||
# The font size ('10pt', '11pt' or '12pt').
|
||||
#'pointsize': '10pt',
|
||||
|
||||
# Additional stuff for the LaTeX preamble.
|
||||
#'preamble': '',
|
||||
# The paper size ('letterpaper' or 'a4paper').
|
||||
#'papersize': 'letterpaper',
|
||||
# The font size ('10pt', '11pt' or '12pt').
|
||||
#'pointsize': '10pt',
|
||||
# Additional stuff for the LaTeX preamble.
|
||||
#'preamble': '',
|
||||
}
|
||||
|
||||
# Grouping the document tree into LaTeX files. List of tuples
|
||||
# (source start file, target name, title, author, documentclass [howto/manual]).
|
||||
latex_documents = [
|
||||
('index', 'Gramps.tex', u'Gramps Documentation',
|
||||
u'.', 'manual'),
|
||||
("index", "Gramps.tex", "Gramps Documentation", ".", "manual"),
|
||||
]
|
||||
|
||||
# The name of an image file (relative to this directory) to place at the top of
|
||||
# the title page.
|
||||
#latex_logo = None
|
||||
# latex_logo = None
|
||||
|
||||
# For "manual" documents, if this is true, then toplevel headings are parts,
|
||||
# not chapters.
|
||||
#latex_use_parts = False
|
||||
# latex_use_parts = False
|
||||
|
||||
# If true, show page references after internal links.
|
||||
#latex_show_pagerefs = False
|
||||
# latex_show_pagerefs = False
|
||||
|
||||
# If true, show URL addresses after external links.
|
||||
#latex_show_urls = False
|
||||
# latex_show_urls = False
|
||||
|
||||
# Documents to append as an appendix to all manuals.
|
||||
#latex_appendices = []
|
||||
# latex_appendices = []
|
||||
|
||||
# If false, no module index is generated.
|
||||
#latex_domain_indices = True
|
||||
# latex_domain_indices = True
|
||||
|
||||
|
||||
# -- Options for manual page output --------------------------------------------
|
||||
|
||||
# One entry per manual page. List of tuples
|
||||
# (source start file, name, description, authors, manual section).
|
||||
man_pages = [
|
||||
('fr', 'gramps', u'Gramps Documentation',
|
||||
['Jerome Rapinat'], 1)
|
||||
]
|
||||
man_pages = [("fr", "gramps", "Gramps Documentation", ["Jerome Rapinat"], 1)]
|
||||
|
||||
# If true, show URL addresses after external links.
|
||||
#man_show_urls = False
|
||||
# man_show_urls = False
|
||||
|
||||
|
||||
# -- Options for Texinfo output ------------------------------------------------
|
||||
@@ -228,16 +222,22 @@ man_pages = [
|
||||
# (source start file, target name, title, author,
|
||||
# dir menu entry, description, category)
|
||||
texinfo_documents = [
|
||||
('index', 'Gramps', u'Gramps Documentation',
|
||||
u'.', 'Gramps', 'One line description of project.',
|
||||
'Miscellaneous'),
|
||||
(
|
||||
"index",
|
||||
"Gramps",
|
||||
"Gramps Documentation",
|
||||
".",
|
||||
"Gramps",
|
||||
"One line description of project.",
|
||||
"Miscellaneous",
|
||||
),
|
||||
]
|
||||
|
||||
# Documents to append as an appendix to all manuals.
|
||||
#texinfo_appendices = []
|
||||
# texinfo_appendices = []
|
||||
|
||||
# If false, no module index is generated.
|
||||
#texinfo_domain_indices = True
|
||||
# texinfo_domain_indices = True
|
||||
|
||||
# How to display URL addresses: 'footnote', 'no', or 'inline'.
|
||||
#texinfo_show_urls = 'footnote'
|
||||
# texinfo_show_urls = 'footnote'
|
||||
|
||||
@@ -16,210 +16,204 @@ import sys, os
|
||||
# If extensions (or modules to document with autodoc) are in another directory,
|
||||
# add these directories to sys.path here. If the directory is relative to the
|
||||
# documentation root, use os.path.abspath to make it absolute, like shown here.
|
||||
#sys.path.insert(0, os.path.abspath('.'))
|
||||
# sys.path.insert(0, os.path.abspath('.'))
|
||||
|
||||
# -- General configuration -----------------------------------------------------
|
||||
|
||||
# If your documentation needs a minimal Sphinx version, state it here.
|
||||
#needs_sphinx = '1.0'
|
||||
# needs_sphinx = '1.0'
|
||||
|
||||
# Add any Sphinx extension module names here, as strings. They can be extensions
|
||||
# coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
|
||||
extensions = []
|
||||
|
||||
# Add any paths that contain templates here, relative to this directory.
|
||||
templates_path = ['_templates']
|
||||
templates_path = ["_templates"]
|
||||
|
||||
# The suffix of source filenames.
|
||||
source_suffix = '.rst'
|
||||
source_suffix = ".rst"
|
||||
|
||||
# The encoding of source files.
|
||||
#source_encoding = 'utf-8-sig'
|
||||
# source_encoding = 'utf-8-sig'
|
||||
|
||||
# The master toctree document.
|
||||
master_doc = 'nl'
|
||||
master_doc = "nl"
|
||||
|
||||
# General information about the project.
|
||||
project = u'Gramps'
|
||||
copyright = u'2015, Gramps project'
|
||||
project = "Gramps"
|
||||
copyright = "2015, Gramps project"
|
||||
|
||||
# The version info for the project you're documenting, acts as replacement for
|
||||
# |version| and |release|, also used in various other places throughout the
|
||||
# built documents.
|
||||
#
|
||||
# The short X.Y version.
|
||||
version = '4.2'
|
||||
version = "4.2"
|
||||
# The full version, including alpha/beta/rc tags.
|
||||
release = '4.2.0'
|
||||
release = "4.2.0"
|
||||
|
||||
# The language for content autogenerated by Sphinx. Refer to documentation
|
||||
# for a list of supported languages.
|
||||
locale_dirs = './locale'
|
||||
locale_dirs = "./locale"
|
||||
gettext_compact = True
|
||||
|
||||
# There are two options for replacing |today|: either, you set today to some
|
||||
# non-false value, then it is used:
|
||||
#today = ''
|
||||
# today = ''
|
||||
# Else, today_fmt is used as the format for a strftime call.
|
||||
today_fmt = '%B %d, %Y'
|
||||
today_fmt = "%B %d, %Y"
|
||||
|
||||
# List of patterns, relative to source directory, that match files and
|
||||
# directories to ignore when looking for source files.
|
||||
exclude_patterns = ['_build']
|
||||
exclude_patterns = ["_build"]
|
||||
|
||||
# The reST default role (used for this markup: `text`) to use for all documents.
|
||||
#default_role = None
|
||||
# default_role = None
|
||||
|
||||
# If true, '()' will be appended to :func: etc. cross-reference text.
|
||||
#add_function_parentheses = True
|
||||
# add_function_parentheses = True
|
||||
|
||||
# If true, the current module name will be prepended to all description
|
||||
# unit titles (such as .. function::).
|
||||
#add_module_names = True
|
||||
# add_module_names = True
|
||||
|
||||
# If true, sectionauthor and moduleauthor directives will be shown in the
|
||||
# output. They are ignored by default.
|
||||
#show_authors = False
|
||||
# show_authors = False
|
||||
|
||||
# The name of the Pygments (syntax highlighting) style to use.
|
||||
pygments_style = 'sphinx'
|
||||
pygments_style = "sphinx"
|
||||
|
||||
# A list of ignored prefixes for module index sorting.
|
||||
#modindex_common_prefix = []
|
||||
# modindex_common_prefix = []
|
||||
|
||||
|
||||
# -- Options for HTML output ---------------------------------------------------
|
||||
|
||||
# The theme to use for HTML and HTML Help pages. See the documentation for
|
||||
# a list of builtin themes.
|
||||
html_theme = 'default'
|
||||
html_theme = "default"
|
||||
|
||||
# Theme options are theme-specific and customize the look and feel of a theme
|
||||
# further. For a list of options available for each theme, see the
|
||||
# documentation.
|
||||
#html_theme_options = {}
|
||||
# html_theme_options = {}
|
||||
|
||||
# Add any paths that contain custom themes here, relative to this directory.
|
||||
#html_theme_path = []
|
||||
# html_theme_path = []
|
||||
|
||||
# The name for this set of Sphinx documents. If None, it defaults to
|
||||
# "<project> v<release> documentation".
|
||||
#html_title = None
|
||||
# html_title = None
|
||||
|
||||
# A shorter title for the navigation bar. Default is the same as html_title.
|
||||
#html_short_title = None
|
||||
# html_short_title = None
|
||||
|
||||
# The name of an image file (relative to this directory) to place at the top
|
||||
# of the sidebar.
|
||||
#html_logo = None
|
||||
# html_logo = None
|
||||
|
||||
# The name of an image file (within the static path) to use as favicon of the
|
||||
# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32
|
||||
# pixels large.
|
||||
#html_favicon = None
|
||||
# html_favicon = None
|
||||
|
||||
# Add any paths that contain custom static files (such as style sheets) here,
|
||||
# relative to this directory. They are copied after the builtin static files,
|
||||
# so a file named "default.css" will overwrite the builtin "default.css".
|
||||
#html_static_path = ['_static']
|
||||
# html_static_path = ['_static']
|
||||
|
||||
# If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
|
||||
# using the given strftime format.
|
||||
#html_last_updated_fmt = '%b %d, %Y'
|
||||
# html_last_updated_fmt = '%b %d, %Y'
|
||||
|
||||
# If true, SmartyPants will be used to convert quotes and dashes to
|
||||
# typographically correct entities.
|
||||
#html_use_smartypants = True
|
||||
# html_use_smartypants = True
|
||||
|
||||
# Custom sidebar templates, maps document names to template names.
|
||||
#html_sidebars = {}
|
||||
# html_sidebars = {}
|
||||
|
||||
# Additional templates that should be rendered to pages, maps page names to
|
||||
# template names.
|
||||
#html_additional_pages = {}
|
||||
# html_additional_pages = {}
|
||||
|
||||
# If false, no module index is generated.
|
||||
#html_domain_indices = True
|
||||
# html_domain_indices = True
|
||||
|
||||
# If false, no index is generated.
|
||||
#html_use_index = True
|
||||
# html_use_index = True
|
||||
|
||||
# If true, the index is split into individual pages for each letter.
|
||||
#html_split_index = False
|
||||
# html_split_index = False
|
||||
|
||||
# If true, links to the reST sources are added to the pages.
|
||||
#html_show_sourcelink = True
|
||||
# html_show_sourcelink = True
|
||||
|
||||
# If true, "Created using Sphinx" is shown in the HTML footer. Default is True.
|
||||
#html_show_sphinx = True
|
||||
# html_show_sphinx = True
|
||||
|
||||
# If true, "(C) Copyright ..." is shown in the HTML footer. Default is True.
|
||||
#html_show_copyright = True
|
||||
# html_show_copyright = True
|
||||
|
||||
# If true, an OpenSearch description file will be output, and all pages will
|
||||
# contain a <link> tag referring to it. The value of this option must be the
|
||||
# base URL from which the finished HTML is served.
|
||||
#html_use_opensearch = ''
|
||||
# html_use_opensearch = ''
|
||||
|
||||
# This is the file name suffix for HTML files (e.g. ".xhtml").
|
||||
#html_file_suffix = None
|
||||
# html_file_suffix = None
|
||||
|
||||
# Output file base name for HTML help builder.
|
||||
htmlhelp_basename = 'Grampsdoc'
|
||||
htmlhelp_basename = "Grampsdoc"
|
||||
|
||||
|
||||
# -- Options for LaTeX output --------------------------------------------------
|
||||
|
||||
latex_elements = {
|
||||
# The paper size ('letterpaper' or 'a4paper').
|
||||
#'papersize': 'letterpaper',
|
||||
|
||||
# The font size ('10pt', '11pt' or '12pt').
|
||||
#'pointsize': '10pt',
|
||||
|
||||
# Additional stuff for the LaTeX preamble.
|
||||
#'preamble': '',
|
||||
# The paper size ('letterpaper' or 'a4paper').
|
||||
#'papersize': 'letterpaper',
|
||||
# The font size ('10pt', '11pt' or '12pt').
|
||||
#'pointsize': '10pt',
|
||||
# Additional stuff for the LaTeX preamble.
|
||||
#'preamble': '',
|
||||
}
|
||||
|
||||
# Grouping the document tree into LaTeX files. List of tuples
|
||||
# (source start file, target name, title, author, documentclass [howto/manual]).
|
||||
latex_documents = [
|
||||
('index', 'Gramps.tex', u'Gramps Documentation',
|
||||
u'.', 'manual'),
|
||||
("index", "Gramps.tex", "Gramps Documentation", ".", "manual"),
|
||||
]
|
||||
|
||||
# The name of an image file (relative to this directory) to place at the top of
|
||||
# the title page.
|
||||
#latex_logo = None
|
||||
# latex_logo = None
|
||||
|
||||
# For "manual" documents, if this is true, then toplevel headings are parts,
|
||||
# not chapters.
|
||||
#latex_use_parts = False
|
||||
# latex_use_parts = False
|
||||
|
||||
# If true, show page references after internal links.
|
||||
#latex_show_pagerefs = False
|
||||
# latex_show_pagerefs = False
|
||||
|
||||
# If true, show URL addresses after external links.
|
||||
#latex_show_urls = False
|
||||
# latex_show_urls = False
|
||||
|
||||
# Documents to append as an appendix to all manuals.
|
||||
#latex_appendices = []
|
||||
# latex_appendices = []
|
||||
|
||||
# If false, no module index is generated.
|
||||
#latex_domain_indices = True
|
||||
# latex_domain_indices = True
|
||||
|
||||
|
||||
# -- Options for manual page output --------------------------------------------
|
||||
|
||||
# One entry per manual page. List of tuples
|
||||
# (source start file, name, description, authors, manual section).
|
||||
man_pages = [
|
||||
('nl', 'gramps', u'Gramps Documentation',
|
||||
[u'.'], 1)
|
||||
]
|
||||
man_pages = [("nl", "gramps", "Gramps Documentation", ["."], 1)]
|
||||
|
||||
# If true, show URL addresses after external links.
|
||||
#man_show_urls = False
|
||||
# man_show_urls = False
|
||||
|
||||
|
||||
# -- Options for Texinfo output ------------------------------------------------
|
||||
@@ -228,16 +222,22 @@ man_pages = [
|
||||
# (source start file, target name, title, author,
|
||||
# dir menu entry, description, category)
|
||||
texinfo_documents = [
|
||||
('index', 'Gramps', u'Gramps Documentation',
|
||||
u'.', 'Gramps', 'One line description of project.',
|
||||
'Miscellaneous'),
|
||||
(
|
||||
"index",
|
||||
"Gramps",
|
||||
"Gramps Documentation",
|
||||
".",
|
||||
"Gramps",
|
||||
"One line description of project.",
|
||||
"Miscellaneous",
|
||||
),
|
||||
]
|
||||
|
||||
# Documents to append as an appendix to all manuals.
|
||||
#texinfo_appendices = []
|
||||
# texinfo_appendices = []
|
||||
|
||||
# If false, no module index is generated.
|
||||
#texinfo_domain_indices = True
|
||||
# texinfo_domain_indices = True
|
||||
|
||||
# How to display URL addresses: 'footnote', 'no', or 'inline'.
|
||||
#texinfo_show_urls = 'footnote'
|
||||
# texinfo_show_urls = 'footnote'
|
||||
|
||||
@@ -16,210 +16,204 @@ import sys, os
|
||||
# If extensions (or modules to document with autodoc) are in another directory,
|
||||
# add these directories to sys.path here. If the directory is relative to the
|
||||
# documentation root, use os.path.abspath to make it absolute, like shown here.
|
||||
#sys.path.insert(0, os.path.abspath('.'))
|
||||
# sys.path.insert(0, os.path.abspath('.'))
|
||||
|
||||
# -- General configuration -----------------------------------------------------
|
||||
|
||||
# If your documentation needs a minimal Sphinx version, state it here.
|
||||
#needs_sphinx = '1.0'
|
||||
# needs_sphinx = '1.0'
|
||||
|
||||
# Add any Sphinx extension module names here, as strings. They can be extensions
|
||||
# coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
|
||||
extensions = []
|
||||
|
||||
# Add any paths that contain templates here, relative to this directory.
|
||||
templates_path = ['_templates']
|
||||
templates_path = ["_templates"]
|
||||
|
||||
# The suffix of source filenames.
|
||||
source_suffix = '.rst'
|
||||
source_suffix = ".rst"
|
||||
|
||||
# The encoding of source files.
|
||||
#source_encoding = 'utf-8-sig'
|
||||
# source_encoding = 'utf-8-sig'
|
||||
|
||||
# The master toctree document.
|
||||
master_doc = 'pl'
|
||||
master_doc = "pl"
|
||||
|
||||
# General information about the project.
|
||||
project = u'Gramps'
|
||||
copyright = u'2015, Gramps project'
|
||||
project = "Gramps"
|
||||
copyright = "2015, Gramps project"
|
||||
|
||||
# The version info for the project you're documenting, acts as replacement for
|
||||
# |version| and |release|, also used in various other places throughout the
|
||||
# built documents.
|
||||
#
|
||||
# The short X.Y version.
|
||||
version = '4.2'
|
||||
version = "4.2"
|
||||
# The full version, including alpha/beta/rc tags.
|
||||
release = '4.2.0'
|
||||
release = "4.2.0"
|
||||
|
||||
# The language for content autogenerated by Sphinx. Refer to documentation
|
||||
# for a list of supported languages.
|
||||
locale_dirs = './locale'
|
||||
locale_dirs = "./locale"
|
||||
gettext_compact = True
|
||||
|
||||
# There are two options for replacing |today|: either, you set today to some
|
||||
# non-false value, then it is used:
|
||||
#today = ''
|
||||
# today = ''
|
||||
# Else, today_fmt is used as the format for a strftime call.
|
||||
today_fmt = '%B %d, %Y'
|
||||
today_fmt = "%B %d, %Y"
|
||||
|
||||
# List of patterns, relative to source directory, that match files and
|
||||
# directories to ignore when looking for source files.
|
||||
exclude_patterns = ['_build']
|
||||
exclude_patterns = ["_build"]
|
||||
|
||||
# The reST default role (used for this markup: `text`) to use for all documents.
|
||||
#default_role = None
|
||||
# default_role = None
|
||||
|
||||
# If true, '()' will be appended to :func: etc. cross-reference text.
|
||||
#add_function_parentheses = True
|
||||
# add_function_parentheses = True
|
||||
|
||||
# If true, the current module name will be prepended to all description
|
||||
# unit titles (such as .. function::).
|
||||
#add_module_names = True
|
||||
# add_module_names = True
|
||||
|
||||
# If true, sectionauthor and moduleauthor directives will be shown in the
|
||||
# output. They are ignored by default.
|
||||
#show_authors = False
|
||||
# show_authors = False
|
||||
|
||||
# The name of the Pygments (syntax highlighting) style to use.
|
||||
pygments_style = 'sphinx'
|
||||
pygments_style = "sphinx"
|
||||
|
||||
# A list of ignored prefixes for module index sorting.
|
||||
#modindex_common_prefix = []
|
||||
# modindex_common_prefix = []
|
||||
|
||||
|
||||
# -- Options for HTML output ---------------------------------------------------
|
||||
|
||||
# The theme to use for HTML and HTML Help pages. See the documentation for
|
||||
# a list of builtin themes.
|
||||
html_theme = 'default'
|
||||
html_theme = "default"
|
||||
|
||||
# Theme options are theme-specific and customize the look and feel of a theme
|
||||
# further. For a list of options available for each theme, see the
|
||||
# documentation.
|
||||
#html_theme_options = {}
|
||||
# html_theme_options = {}
|
||||
|
||||
# Add any paths that contain custom themes here, relative to this directory.
|
||||
#html_theme_path = []
|
||||
# html_theme_path = []
|
||||
|
||||
# The name for this set of Sphinx documents. If None, it defaults to
|
||||
# "<project> v<release> documentation".
|
||||
#html_title = None
|
||||
# html_title = None
|
||||
|
||||
# A shorter title for the navigation bar. Default is the same as html_title.
|
||||
#html_short_title = None
|
||||
# html_short_title = None
|
||||
|
||||
# The name of an image file (relative to this directory) to place at the top
|
||||
# of the sidebar.
|
||||
#html_logo = None
|
||||
# html_logo = None
|
||||
|
||||
# The name of an image file (within the static path) to use as favicon of the
|
||||
# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32
|
||||
# pixels large.
|
||||
#html_favicon = None
|
||||
# html_favicon = None
|
||||
|
||||
# Add any paths that contain custom static files (such as style sheets) here,
|
||||
# relative to this directory. They are copied after the builtin static files,
|
||||
# so a file named "default.css" will overwrite the builtin "default.css".
|
||||
#html_static_path = ['_static']
|
||||
# html_static_path = ['_static']
|
||||
|
||||
# If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
|
||||
# using the given strftime format.
|
||||
#html_last_updated_fmt = '%b %d, %Y'
|
||||
# html_last_updated_fmt = '%b %d, %Y'
|
||||
|
||||
# If true, SmartyPants will be used to convert quotes and dashes to
|
||||
# typographically correct entities.
|
||||
#html_use_smartypants = True
|
||||
# html_use_smartypants = True
|
||||
|
||||
# Custom sidebar templates, maps document names to template names.
|
||||
#html_sidebars = {}
|
||||
# html_sidebars = {}
|
||||
|
||||
# Additional templates that should be rendered to pages, maps page names to
|
||||
# template names.
|
||||
#html_additional_pages = {}
|
||||
# html_additional_pages = {}
|
||||
|
||||
# If false, no module index is generated.
|
||||
#html_domain_indices = True
|
||||
# html_domain_indices = True
|
||||
|
||||
# If false, no index is generated.
|
||||
#html_use_index = True
|
||||
# html_use_index = True
|
||||
|
||||
# If true, the index is split into individual pages for each letter.
|
||||
#html_split_index = False
|
||||
# html_split_index = False
|
||||
|
||||
# If true, links to the reST sources are added to the pages.
|
||||
#html_show_sourcelink = True
|
||||
# html_show_sourcelink = True
|
||||
|
||||
# If true, "Created using Sphinx" is shown in the HTML footer. Default is True.
|
||||
#html_show_sphinx = True
|
||||
# html_show_sphinx = True
|
||||
|
||||
# If true, "(C) Copyright ..." is shown in the HTML footer. Default is True.
|
||||
#html_show_copyright = True
|
||||
# html_show_copyright = True
|
||||
|
||||
# If true, an OpenSearch description file will be output, and all pages will
|
||||
# contain a <link> tag referring to it. The value of this option must be the
|
||||
# base URL from which the finished HTML is served.
|
||||
#html_use_opensearch = ''
|
||||
# html_use_opensearch = ''
|
||||
|
||||
# This is the file name suffix for HTML files (e.g. ".xhtml").
|
||||
#html_file_suffix = None
|
||||
# html_file_suffix = None
|
||||
|
||||
# Output file base name for HTML help builder.
|
||||
htmlhelp_basename = 'Grampsdoc'
|
||||
htmlhelp_basename = "Grampsdoc"
|
||||
|
||||
|
||||
# -- Options for LaTeX output --------------------------------------------------
|
||||
|
||||
latex_elements = {
|
||||
# The paper size ('letterpaper' or 'a4paper').
|
||||
#'papersize': 'letterpaper',
|
||||
|
||||
# The font size ('10pt', '11pt' or '12pt').
|
||||
#'pointsize': '10pt',
|
||||
|
||||
# Additional stuff for the LaTeX preamble.
|
||||
#'preamble': '',
|
||||
# The paper size ('letterpaper' or 'a4paper').
|
||||
#'papersize': 'letterpaper',
|
||||
# The font size ('10pt', '11pt' or '12pt').
|
||||
#'pointsize': '10pt',
|
||||
# Additional stuff for the LaTeX preamble.
|
||||
#'preamble': '',
|
||||
}
|
||||
|
||||
# Grouping the document tree into LaTeX files. List of tuples
|
||||
# (source start file, target name, title, author, documentclass [howto/manual]).
|
||||
latex_documents = [
|
||||
('index', 'Gramps.tex', u'Gramps Documentation',
|
||||
u'.', 'manual'),
|
||||
("index", "Gramps.tex", "Gramps Documentation", ".", "manual"),
|
||||
]
|
||||
|
||||
# The name of an image file (relative to this directory) to place at the top of
|
||||
# the title page.
|
||||
#latex_logo = None
|
||||
# latex_logo = None
|
||||
|
||||
# For "manual" documents, if this is true, then toplevel headings are parts,
|
||||
# not chapters.
|
||||
#latex_use_parts = False
|
||||
# latex_use_parts = False
|
||||
|
||||
# If true, show page references after internal links.
|
||||
#latex_show_pagerefs = False
|
||||
# latex_show_pagerefs = False
|
||||
|
||||
# If true, show URL addresses after external links.
|
||||
#latex_show_urls = False
|
||||
# latex_show_urls = False
|
||||
|
||||
# Documents to append as an appendix to all manuals.
|
||||
#latex_appendices = []
|
||||
# latex_appendices = []
|
||||
|
||||
# If false, no module index is generated.
|
||||
#latex_domain_indices = True
|
||||
# latex_domain_indices = True
|
||||
|
||||
|
||||
# -- Options for manual page output --------------------------------------------
|
||||
|
||||
# One entry per manual page. List of tuples
|
||||
# (source start file, name, description, authors, manual section).
|
||||
man_pages = [
|
||||
('pl', 'gramps', u'Gramps Documentation',
|
||||
[u'.'], 1)
|
||||
]
|
||||
man_pages = [("pl", "gramps", "Gramps Documentation", ["."], 1)]
|
||||
|
||||
# If true, show URL addresses after external links.
|
||||
#man_show_urls = False
|
||||
# man_show_urls = False
|
||||
|
||||
|
||||
# -- Options for Texinfo output ------------------------------------------------
|
||||
@@ -228,16 +222,22 @@ man_pages = [
|
||||
# (source start file, target name, title, author,
|
||||
# dir menu entry, description, category)
|
||||
texinfo_documents = [
|
||||
('index', 'Gramps', u'Gramps Documentation',
|
||||
u'.', 'Gramps', 'One line description of project.',
|
||||
'Miscellaneous'),
|
||||
(
|
||||
"index",
|
||||
"Gramps",
|
||||
"Gramps Documentation",
|
||||
".",
|
||||
"Gramps",
|
||||
"One line description of project.",
|
||||
"Miscellaneous",
|
||||
),
|
||||
]
|
||||
|
||||
# Documents to append as an appendix to all manuals.
|
||||
#texinfo_appendices = []
|
||||
# texinfo_appendices = []
|
||||
|
||||
# If false, no module index is generated.
|
||||
#texinfo_domain_indices = True
|
||||
# texinfo_domain_indices = True
|
||||
|
||||
# How to display URL addresses: 'footnote', 'no', or 'inline'.
|
||||
#texinfo_show_urls = 'footnote'
|
||||
# texinfo_show_urls = 'footnote'
|
||||
|
||||
@@ -16,210 +16,204 @@ import sys, os
|
||||
# If extensions (or modules to document with autodoc) are in another directory,
|
||||
# add these directories to sys.path here. If the directory is relative to the
|
||||
# documentation root, use os.path.abspath to make it absolute, like shown here.
|
||||
#sys.path.insert(0, os.path.abspath('.'))
|
||||
# sys.path.insert(0, os.path.abspath('.'))
|
||||
|
||||
# -- General configuration -----------------------------------------------------
|
||||
|
||||
# If your documentation needs a minimal Sphinx version, state it here.
|
||||
#needs_sphinx = '1.0'
|
||||
# needs_sphinx = '1.0'
|
||||
|
||||
# Add any Sphinx extension module names here, as strings. They can be extensions
|
||||
# coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
|
||||
extensions = []
|
||||
|
||||
# Add any paths that contain templates here, relative to this directory.
|
||||
templates_path = ['_templates']
|
||||
templates_path = ["_templates"]
|
||||
|
||||
# The suffix of source filenames.
|
||||
source_suffix = '.rst'
|
||||
source_suffix = ".rst"
|
||||
|
||||
# The encoding of source files.
|
||||
#source_encoding = 'utf-8-sig'
|
||||
# source_encoding = 'utf-8-sig'
|
||||
|
||||
# The master toctree document.
|
||||
master_doc = 'pt_BR'
|
||||
master_doc = "pt_BR"
|
||||
|
||||
# General information about the project.
|
||||
project = u'Gramps'
|
||||
copyright = u'2015, Gramps project'
|
||||
project = "Gramps"
|
||||
copyright = "2015, Gramps project"
|
||||
|
||||
# The version info for the project you're documenting, acts as replacement for
|
||||
# |version| and |release|, also used in various other places throughout the
|
||||
# built documents.
|
||||
#
|
||||
# The short X.Y version.
|
||||
version = '4.2'
|
||||
version = "4.2"
|
||||
# The full version, including alpha/beta/rc tags.
|
||||
release = '4.2.0'
|
||||
release = "4.2.0"
|
||||
|
||||
# The language for content autogenerated by Sphinx. Refer to documentation
|
||||
# for a list of supported languages.
|
||||
locale_dirs = './locale'
|
||||
locale_dirs = "./locale"
|
||||
gettext_compact = True
|
||||
|
||||
# There are two options for replacing |today|: either, you set today to some
|
||||
# non-false value, then it is used:
|
||||
#today = ''
|
||||
# today = ''
|
||||
# Else, today_fmt is used as the format for a strftime call.
|
||||
today_fmt = '%B %d, %Y'
|
||||
today_fmt = "%B %d, %Y"
|
||||
|
||||
# List of patterns, relative to source directory, that match files and
|
||||
# directories to ignore when looking for source files.
|
||||
exclude_patterns = ['_build']
|
||||
exclude_patterns = ["_build"]
|
||||
|
||||
# The reST default role (used for this markup: `text`) to use for all documents.
|
||||
#default_role = None
|
||||
# default_role = None
|
||||
|
||||
# If true, '()' will be appended to :func: etc. cross-reference text.
|
||||
#add_function_parentheses = True
|
||||
# add_function_parentheses = True
|
||||
|
||||
# If true, the current module name will be prepended to all description
|
||||
# unit titles (such as .. function::).
|
||||
#add_module_names = True
|
||||
# add_module_names = True
|
||||
|
||||
# If true, sectionauthor and moduleauthor directives will be shown in the
|
||||
# output. They are ignored by default.
|
||||
#show_authors = False
|
||||
# show_authors = False
|
||||
|
||||
# The name of the Pygments (syntax highlighting) style to use.
|
||||
pygments_style = 'sphinx'
|
||||
pygments_style = "sphinx"
|
||||
|
||||
# A list of ignored prefixes for module index sorting.
|
||||
#modindex_common_prefix = []
|
||||
# modindex_common_prefix = []
|
||||
|
||||
|
||||
# -- Options for HTML output ---------------------------------------------------
|
||||
|
||||
# The theme to use for HTML and HTML Help pages. See the documentation for
|
||||
# a list of builtin themes.
|
||||
html_theme = 'default'
|
||||
html_theme = "default"
|
||||
|
||||
# Theme options are theme-specific and customize the look and feel of a theme
|
||||
# further. For a list of options available for each theme, see the
|
||||
# documentation.
|
||||
#html_theme_options = {}
|
||||
# html_theme_options = {}
|
||||
|
||||
# Add any paths that contain custom themes here, relative to this directory.
|
||||
#html_theme_path = []
|
||||
# html_theme_path = []
|
||||
|
||||
# The name for this set of Sphinx documents. If None, it defaults to
|
||||
# "<project> v<release> documentation".
|
||||
#html_title = None
|
||||
# html_title = None
|
||||
|
||||
# A shorter title for the navigation bar. Default is the same as html_title.
|
||||
#html_short_title = None
|
||||
# html_short_title = None
|
||||
|
||||
# The name of an image file (relative to this directory) to place at the top
|
||||
# of the sidebar.
|
||||
#html_logo = None
|
||||
# html_logo = None
|
||||
|
||||
# The name of an image file (within the static path) to use as favicon of the
|
||||
# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32
|
||||
# pixels large.
|
||||
#html_favicon = None
|
||||
# html_favicon = None
|
||||
|
||||
# Add any paths that contain custom static files (such as style sheets) here,
|
||||
# relative to this directory. They are copied after the builtin static files,
|
||||
# so a file named "default.css" will overwrite the builtin "default.css".
|
||||
#html_static_path = ['_static']
|
||||
# html_static_path = ['_static']
|
||||
|
||||
# If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
|
||||
# using the given strftime format.
|
||||
#html_last_updated_fmt = '%b %d, %Y'
|
||||
# html_last_updated_fmt = '%b %d, %Y'
|
||||
|
||||
# If true, SmartyPants will be used to convert quotes and dashes to
|
||||
# typographically correct entities.
|
||||
#html_use_smartypants = True
|
||||
# html_use_smartypants = True
|
||||
|
||||
# Custom sidebar templates, maps document names to template names.
|
||||
#html_sidebars = {}
|
||||
# html_sidebars = {}
|
||||
|
||||
# Additional templates that should be rendered to pages, maps page names to
|
||||
# template names.
|
||||
#html_additional_pages = {}
|
||||
# html_additional_pages = {}
|
||||
|
||||
# If false, no module index is generated.
|
||||
#html_domain_indices = True
|
||||
# html_domain_indices = True
|
||||
|
||||
# If false, no index is generated.
|
||||
#html_use_index = True
|
||||
# html_use_index = True
|
||||
|
||||
# If true, the index is split into individual pages for each letter.
|
||||
#html_split_index = False
|
||||
# html_split_index = False
|
||||
|
||||
# If true, links to the reST sources are added to the pages.
|
||||
#html_show_sourcelink = True
|
||||
# html_show_sourcelink = True
|
||||
|
||||
# If true, "Created using Sphinx" is shown in the HTML footer. Default is True.
|
||||
#html_show_sphinx = True
|
||||
# html_show_sphinx = True
|
||||
|
||||
# If true, "(C) Copyright ..." is shown in the HTML footer. Default is True.
|
||||
#html_show_copyright = True
|
||||
# html_show_copyright = True
|
||||
|
||||
# If true, an OpenSearch description file will be output, and all pages will
|
||||
# contain a <link> tag referring to it. The value of this option must be the
|
||||
# base URL from which the finished HTML is served.
|
||||
#html_use_opensearch = ''
|
||||
# html_use_opensearch = ''
|
||||
|
||||
# This is the file name suffix for HTML files (e.g. ".xhtml").
|
||||
#html_file_suffix = None
|
||||
# html_file_suffix = None
|
||||
|
||||
# Output file base name for HTML help builder.
|
||||
htmlhelp_basename = 'Grampsdoc'
|
||||
htmlhelp_basename = "Grampsdoc"
|
||||
|
||||
|
||||
# -- Options for LaTeX output --------------------------------------------------
|
||||
|
||||
latex_elements = {
|
||||
# The paper size ('letterpaper' or 'a4paper').
|
||||
#'papersize': 'letterpaper',
|
||||
|
||||
# The font size ('10pt', '11pt' or '12pt').
|
||||
#'pointsize': '10pt',
|
||||
|
||||
# Additional stuff for the LaTeX preamble.
|
||||
#'preamble': '',
|
||||
# The paper size ('letterpaper' or 'a4paper').
|
||||
#'papersize': 'letterpaper',
|
||||
# The font size ('10pt', '11pt' or '12pt').
|
||||
#'pointsize': '10pt',
|
||||
# Additional stuff for the LaTeX preamble.
|
||||
#'preamble': '',
|
||||
}
|
||||
|
||||
# Grouping the document tree into LaTeX files. List of tuples
|
||||
# (source start file, target name, title, author, documentclass [howto/manual]).
|
||||
latex_documents = [
|
||||
('index', 'Gramps.tex', u'Gramps Documentation',
|
||||
u'.', 'manual'),
|
||||
("index", "Gramps.tex", "Gramps Documentation", ".", "manual"),
|
||||
]
|
||||
|
||||
# The name of an image file (relative to this directory) to place at the top of
|
||||
# the title page.
|
||||
#latex_logo = None
|
||||
# latex_logo = None
|
||||
|
||||
# For "manual" documents, if this is true, then toplevel headings are parts,
|
||||
# not chapters.
|
||||
#latex_use_parts = False
|
||||
# latex_use_parts = False
|
||||
|
||||
# If true, show page references after internal links.
|
||||
#latex_show_pagerefs = False
|
||||
# latex_show_pagerefs = False
|
||||
|
||||
# If true, show URL addresses after external links.
|
||||
#latex_show_urls = False
|
||||
# latex_show_urls = False
|
||||
|
||||
# Documents to append as an appendix to all manuals.
|
||||
#latex_appendices = []
|
||||
# latex_appendices = []
|
||||
|
||||
# If false, no module index is generated.
|
||||
#latex_domain_indices = True
|
||||
# latex_domain_indices = True
|
||||
|
||||
|
||||
# -- Options for manual page output --------------------------------------------
|
||||
|
||||
# One entry per manual page. List of tuples
|
||||
# (source start file, name, description, authors, manual section).
|
||||
man_pages = [
|
||||
('pt_BR', 'gramps', u'Gramps Documentation',
|
||||
[u'.'], 1)
|
||||
]
|
||||
man_pages = [("pt_BR", "gramps", "Gramps Documentation", ["."], 1)]
|
||||
|
||||
# If true, show URL addresses after external links.
|
||||
#man_show_urls = False
|
||||
# man_show_urls = False
|
||||
|
||||
|
||||
# -- Options for Texinfo output ------------------------------------------------
|
||||
@@ -228,16 +222,22 @@ man_pages = [
|
||||
# (source start file, target name, title, author,
|
||||
# dir menu entry, description, category)
|
||||
texinfo_documents = [
|
||||
('index', 'Gramps', u'Gramps Documentation',
|
||||
u'.', 'Gramps', 'One line description of project.',
|
||||
'Miscellaneous'),
|
||||
(
|
||||
"index",
|
||||
"Gramps",
|
||||
"Gramps Documentation",
|
||||
".",
|
||||
"Gramps",
|
||||
"One line description of project.",
|
||||
"Miscellaneous",
|
||||
),
|
||||
]
|
||||
|
||||
# Documents to append as an appendix to all manuals.
|
||||
#texinfo_appendices = []
|
||||
# texinfo_appendices = []
|
||||
|
||||
# If false, no module index is generated.
|
||||
#texinfo_domain_indices = True
|
||||
# texinfo_domain_indices = True
|
||||
|
||||
# How to display URL addresses: 'footnote', 'no', or 'inline'.
|
||||
#texinfo_show_urls = 'footnote'
|
||||
# texinfo_show_urls = 'footnote'
|
||||
|
||||
@@ -16,210 +16,204 @@ import sys, os
|
||||
# If extensions (or modules to document with autodoc) are in another directory,
|
||||
# add these directories to sys.path here. If the directory is relative to the
|
||||
# documentation root, use os.path.abspath to make it absolute, like shown here.
|
||||
#sys.path.insert(0, os.path.abspath('.'))
|
||||
# sys.path.insert(0, os.path.abspath('.'))
|
||||
|
||||
# -- General configuration -----------------------------------------------------
|
||||
|
||||
# If your documentation needs a minimal Sphinx version, state it here.
|
||||
#needs_sphinx = '1.0'
|
||||
# needs_sphinx = '1.0'
|
||||
|
||||
# Add any Sphinx extension module names here, as strings. They can be extensions
|
||||
# coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
|
||||
extensions = []
|
||||
|
||||
# Add any paths that contain templates here, relative to this directory.
|
||||
templates_path = ['_templates']
|
||||
templates_path = ["_templates"]
|
||||
|
||||
# The suffix of source filenames.
|
||||
source_suffix = '.rst'
|
||||
source_suffix = ".rst"
|
||||
|
||||
# The encoding of source files.
|
||||
#source_encoding = 'utf-8-sig'
|
||||
# source_encoding = 'utf-8-sig'
|
||||
|
||||
# The master toctree document.
|
||||
master_doc = 'sv'
|
||||
master_doc = "sv"
|
||||
|
||||
# General information about the project.
|
||||
project = u'Gramps'
|
||||
copyright = u'2015, Gramps project'
|
||||
project = "Gramps"
|
||||
copyright = "2015, Gramps project"
|
||||
|
||||
# The version info for the project you're documenting, acts as replacement for
|
||||
# |version| and |release|, also used in various other places throughout the
|
||||
# built documents.
|
||||
#
|
||||
# The short X.Y version.
|
||||
version = '4.2'
|
||||
version = "4.2"
|
||||
# The full version, including alpha/beta/rc tags.
|
||||
release = '4.2.0'
|
||||
release = "4.2.0"
|
||||
|
||||
# The language for content autogenerated by Sphinx. Refer to documentation
|
||||
# for a list of supported languages.
|
||||
locale_dirs = './locale'
|
||||
locale_dirs = "./locale"
|
||||
gettext_compact = True
|
||||
|
||||
# There are two options for replacing |today|: either, you set today to some
|
||||
# non-false value, then it is used:
|
||||
#today = ''
|
||||
# today = ''
|
||||
# Else, today_fmt is used as the format for a strftime call.
|
||||
today_fmt = '%B %d, %Y'
|
||||
today_fmt = "%B %d, %Y"
|
||||
|
||||
# List of patterns, relative to source directory, that match files and
|
||||
# directories to ignore when looking for source files.
|
||||
exclude_patterns = ['_build']
|
||||
exclude_patterns = ["_build"]
|
||||
|
||||
# The reST default role (used for this markup: `text`) to use for all documents.
|
||||
#default_role = None
|
||||
# default_role = None
|
||||
|
||||
# If true, '()' will be appended to :func: etc. cross-reference text.
|
||||
#add_function_parentheses = True
|
||||
# add_function_parentheses = True
|
||||
|
||||
# If true, the current module name will be prepended to all description
|
||||
# unit titles (such as .. function::).
|
||||
#add_module_names = True
|
||||
# add_module_names = True
|
||||
|
||||
# If true, sectionauthor and moduleauthor directives will be shown in the
|
||||
# output. They are ignored by default.
|
||||
#show_authors = False
|
||||
# show_authors = False
|
||||
|
||||
# The name of the Pygments (syntax highlighting) style to use.
|
||||
pygments_style = 'sphinx'
|
||||
pygments_style = "sphinx"
|
||||
|
||||
# A list of ignored prefixes for module index sorting.
|
||||
#modindex_common_prefix = []
|
||||
# modindex_common_prefix = []
|
||||
|
||||
|
||||
# -- Options for HTML output ---------------------------------------------------
|
||||
|
||||
# The theme to use for HTML and HTML Help pages. See the documentation for
|
||||
# a list of builtin themes.
|
||||
html_theme = 'default'
|
||||
html_theme = "default"
|
||||
|
||||
# Theme options are theme-specific and customize the look and feel of a theme
|
||||
# further. For a list of options available for each theme, see the
|
||||
# documentation.
|
||||
#html_theme_options = {}
|
||||
# html_theme_options = {}
|
||||
|
||||
# Add any paths that contain custom themes here, relative to this directory.
|
||||
#html_theme_path = []
|
||||
# html_theme_path = []
|
||||
|
||||
# The name for this set of Sphinx documents. If None, it defaults to
|
||||
# "<project> v<release> documentation".
|
||||
#html_title = None
|
||||
# html_title = None
|
||||
|
||||
# A shorter title for the navigation bar. Default is the same as html_title.
|
||||
#html_short_title = None
|
||||
# html_short_title = None
|
||||
|
||||
# The name of an image file (relative to this directory) to place at the top
|
||||
# of the sidebar.
|
||||
#html_logo = None
|
||||
# html_logo = None
|
||||
|
||||
# The name of an image file (within the static path) to use as favicon of the
|
||||
# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32
|
||||
# pixels large.
|
||||
#html_favicon = None
|
||||
# html_favicon = None
|
||||
|
||||
# Add any paths that contain custom static files (such as style sheets) here,
|
||||
# relative to this directory. They are copied after the builtin static files,
|
||||
# so a file named "default.css" will overwrite the builtin "default.css".
|
||||
#html_static_path = ['_static']
|
||||
# html_static_path = ['_static']
|
||||
|
||||
# If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
|
||||
# using the given strftime format.
|
||||
#html_last_updated_fmt = '%b %d, %Y'
|
||||
# html_last_updated_fmt = '%b %d, %Y'
|
||||
|
||||
# If true, SmartyPants will be used to convert quotes and dashes to
|
||||
# typographically correct entities.
|
||||
#html_use_smartypants = True
|
||||
# html_use_smartypants = True
|
||||
|
||||
# Custom sidebar templates, maps document names to template names.
|
||||
#html_sidebars = {}
|
||||
# html_sidebars = {}
|
||||
|
||||
# Additional templates that should be rendered to pages, maps page names to
|
||||
# template names.
|
||||
#html_additional_pages = {}
|
||||
# html_additional_pages = {}
|
||||
|
||||
# If false, no module index is generated.
|
||||
#html_domain_indices = True
|
||||
# html_domain_indices = True
|
||||
|
||||
# If false, no index is generated.
|
||||
#html_use_index = True
|
||||
# html_use_index = True
|
||||
|
||||
# If true, the index is split into individual pages for each letter.
|
||||
#html_split_index = False
|
||||
# html_split_index = False
|
||||
|
||||
# If true, links to the reST sources are added to the pages.
|
||||
#html_show_sourcelink = True
|
||||
# html_show_sourcelink = True
|
||||
|
||||
# If true, "Created using Sphinx" is shown in the HTML footer. Default is True.
|
||||
#html_show_sphinx = True
|
||||
# html_show_sphinx = True
|
||||
|
||||
# If true, "(C) Copyright ..." is shown in the HTML footer. Default is True.
|
||||
#html_show_copyright = True
|
||||
# html_show_copyright = True
|
||||
|
||||
# If true, an OpenSearch description file will be output, and all pages will
|
||||
# contain a <link> tag referring to it. The value of this option must be the
|
||||
# base URL from which the finished HTML is served.
|
||||
#html_use_opensearch = ''
|
||||
# html_use_opensearch = ''
|
||||
|
||||
# This is the file name suffix for HTML files (e.g. ".xhtml").
|
||||
#html_file_suffix = None
|
||||
# html_file_suffix = None
|
||||
|
||||
# Output file base name for HTML help builder.
|
||||
htmlhelp_basename = 'Grampsdoc'
|
||||
htmlhelp_basename = "Grampsdoc"
|
||||
|
||||
|
||||
# -- Options for LaTeX output --------------------------------------------------
|
||||
|
||||
latex_elements = {
|
||||
# The paper size ('letterpaper' or 'a4paper').
|
||||
#'papersize': 'letterpaper',
|
||||
|
||||
# The font size ('10pt', '11pt' or '12pt').
|
||||
#'pointsize': '10pt',
|
||||
|
||||
# Additional stuff for the LaTeX preamble.
|
||||
#'preamble': '',
|
||||
# The paper size ('letterpaper' or 'a4paper').
|
||||
#'papersize': 'letterpaper',
|
||||
# The font size ('10pt', '11pt' or '12pt').
|
||||
#'pointsize': '10pt',
|
||||
# Additional stuff for the LaTeX preamble.
|
||||
#'preamble': '',
|
||||
}
|
||||
|
||||
# Grouping the document tree into LaTeX files. List of tuples
|
||||
# (source start file, target name, title, author, documentclass [howto/manual]).
|
||||
latex_documents = [
|
||||
('index', 'Gramps.tex', u'Gramps Documentation',
|
||||
u'.', 'manual'),
|
||||
("index", "Gramps.tex", "Gramps Documentation", ".", "manual"),
|
||||
]
|
||||
|
||||
# The name of an image file (relative to this directory) to place at the top of
|
||||
# the title page.
|
||||
#latex_logo = None
|
||||
# latex_logo = None
|
||||
|
||||
# For "manual" documents, if this is true, then toplevel headings are parts,
|
||||
# not chapters.
|
||||
#latex_use_parts = False
|
||||
# latex_use_parts = False
|
||||
|
||||
# If true, show page references after internal links.
|
||||
#latex_show_pagerefs = False
|
||||
# latex_show_pagerefs = False
|
||||
|
||||
# If true, show URL addresses after external links.
|
||||
#latex_show_urls = False
|
||||
# latex_show_urls = False
|
||||
|
||||
# Documents to append as an appendix to all manuals.
|
||||
#latex_appendices = []
|
||||
# latex_appendices = []
|
||||
|
||||
# If false, no module index is generated.
|
||||
#latex_domain_indices = True
|
||||
# latex_domain_indices = True
|
||||
|
||||
|
||||
# -- Options for manual page output --------------------------------------------
|
||||
|
||||
# One entry per manual page. List of tuples
|
||||
# (source start file, name, description, authors, manual section).
|
||||
man_pages = [
|
||||
('sv', 'gramps', u'Gramps Documentation',
|
||||
[u'.'], 1)
|
||||
]
|
||||
man_pages = [("sv", "gramps", "Gramps Documentation", ["."], 1)]
|
||||
|
||||
# If true, show URL addresses after external links.
|
||||
#man_show_urls = False
|
||||
# man_show_urls = False
|
||||
|
||||
|
||||
# -- Options for Texinfo output ------------------------------------------------
|
||||
@@ -228,16 +222,22 @@ man_pages = [
|
||||
# (source start file, target name, title, author,
|
||||
# dir menu entry, description, category)
|
||||
texinfo_documents = [
|
||||
('index', 'Gramps', u'Gramps Documentation',
|
||||
u'.', 'Gramps', 'One line description of project.',
|
||||
'Miscellaneous'),
|
||||
(
|
||||
"index",
|
||||
"Gramps",
|
||||
"Gramps Documentation",
|
||||
".",
|
||||
"Gramps",
|
||||
"One line description of project.",
|
||||
"Miscellaneous",
|
||||
),
|
||||
]
|
||||
|
||||
# Documents to append as an appendix to all manuals.
|
||||
#texinfo_appendices = []
|
||||
# texinfo_appendices = []
|
||||
|
||||
# If false, no module index is generated.
|
||||
#texinfo_domain_indices = True
|
||||
# texinfo_domain_indices = True
|
||||
|
||||
# How to display URL addresses: 'footnote', 'no', or 'inline'.
|
||||
#texinfo_show_urls = 'footnote'
|
||||
# texinfo_show_urls = 'footnote'
|
||||
|
||||
@@ -42,23 +42,24 @@ try:
|
||||
except:
|
||||
DOCUTILS = False
|
||||
|
||||
LANGUAGES = ['sv', 'nl', 'pl', 'cs', 'pt_BR', 'fr']
|
||||
VERSION = '5.0.0'
|
||||
DATE = ''
|
||||
LANGUAGES = ["sv", "nl", "pl", "cs", "pt_BR", "fr"]
|
||||
VERSION = "5.0.0"
|
||||
DATE = ""
|
||||
|
||||
# You can set these variables from the command line.
|
||||
SPHINXBUILD = 'sphinx-build'
|
||||
SPHINXBUILD = "sphinx-build"
|
||||
|
||||
if sys.platform == 'win32':
|
||||
pythonCmd = os.path.join(sys.prefix, 'bin', 'python.exe')
|
||||
sphinxCmd = os.path.join(sys.prefix, 'bin', 'sphinx-build.exe')
|
||||
elif sys.platform in ['linux2', 'darwin', 'cygwin']:
|
||||
pythonCmd = os.path.join(sys.prefix, 'bin', 'python')
|
||||
if sys.platform == "win32":
|
||||
pythonCmd = os.path.join(sys.prefix, "bin", "python.exe")
|
||||
sphinxCmd = os.path.join(sys.prefix, "bin", "sphinx-build.exe")
|
||||
elif sys.platform in ["linux2", "darwin", "cygwin"]:
|
||||
pythonCmd = os.path.join(sys.prefix, "bin", "python")
|
||||
sphinxCmd = SPHINXBUILD
|
||||
else:
|
||||
print ("Update Man ERROR: unknown system, don't know sphinx, ... commands")
|
||||
print("Update Man ERROR: unknown system, don't know sphinx, ... commands")
|
||||
sys.exit(0)
|
||||
|
||||
|
||||
def tests():
|
||||
"""
|
||||
Testing installed programs.
|
||||
@@ -67,18 +68,19 @@ def tests():
|
||||
"""
|
||||
try:
|
||||
print("\n=================='python'=============================\n")
|
||||
os.system('''%(program)s -V''' % {'program': pythonCmd})
|
||||
os.system("""%(program)s -V""" % {"program": pythonCmd})
|
||||
except:
|
||||
print ('Please, install python')
|
||||
print("Please, install python")
|
||||
|
||||
try:
|
||||
print("\n=================='Sphinx-build'=============================\n")
|
||||
os.system('''%(program)s''' % {'program': sphinxCmd})
|
||||
os.system("""%(program)s""" % {"program": sphinxCmd})
|
||||
except:
|
||||
print ('Please, install sphinx')
|
||||
print("Please, install sphinx")
|
||||
|
||||
if not DOCUTILS:
|
||||
print('\nNo docutils support, cannot use -m/--man and -o/--odt arguments.')
|
||||
print("\nNo docutils support, cannot use -m/--man and -o/--odt arguments.")
|
||||
|
||||
|
||||
def main():
|
||||
"""
|
||||
@@ -87,25 +89,45 @@ def main():
|
||||
"""
|
||||
|
||||
parser = ArgumentParser(
|
||||
description='This program aims to handle documentation'
|
||||
' and related translated versions.',
|
||||
)
|
||||
description="This program aims to handle documentation"
|
||||
" and related translated versions.",
|
||||
)
|
||||
|
||||
parser.add_argument("-t", "--test",
|
||||
action="store_true", dest="test", default=True,
|
||||
help="test if 'python' and 'sphinx' are properly installed")
|
||||
parser.add_argument(
|
||||
"-t",
|
||||
"--test",
|
||||
action="store_true",
|
||||
dest="test",
|
||||
default=True,
|
||||
help="test if 'python' and 'sphinx' are properly installed",
|
||||
)
|
||||
|
||||
parser.add_argument("-b", "--build",
|
||||
action="store_true", dest="build", default=False,
|
||||
help="build man documentation (via sphinx-build)")
|
||||
parser.add_argument(
|
||||
"-b",
|
||||
"--build",
|
||||
action="store_true",
|
||||
dest="build",
|
||||
default=False,
|
||||
help="build man documentation (via sphinx-build)",
|
||||
)
|
||||
|
||||
parser.add_argument("-m", "--man",
|
||||
action="store_true", dest="man", default=False,
|
||||
help="build man documentation (via docutils)")
|
||||
parser.add_argument(
|
||||
"-m",
|
||||
"--man",
|
||||
action="store_true",
|
||||
dest="man",
|
||||
default=False,
|
||||
help="build man documentation (via docutils)",
|
||||
)
|
||||
|
||||
parser.add_argument("-o", "--odt",
|
||||
action="store_true", dest="odt", default=False,
|
||||
help="build odt documentation (via docutils)")
|
||||
parser.add_argument(
|
||||
"-o",
|
||||
"--odt",
|
||||
action="store_true",
|
||||
dest="odt",
|
||||
default=False,
|
||||
help="build odt documentation (via docutils)",
|
||||
)
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
@@ -121,6 +143,7 @@ def main():
|
||||
if args.odt and DOCUTILS:
|
||||
odt()
|
||||
|
||||
|
||||
def build():
|
||||
"""
|
||||
Build documentation.
|
||||
@@ -128,28 +151,39 @@ def build():
|
||||
|
||||
# testing stage
|
||||
|
||||
os.system('''%(program)s -b html . _build/html''' % {'program': sphinxCmd})
|
||||
os.system('''%(program)s -b htmlhelp . _build/htmlhelp''' % {'program': sphinxCmd})
|
||||
os.system("""%(program)s -b html . _build/html""" % {"program": sphinxCmd})
|
||||
os.system("""%(program)s -b htmlhelp . _build/htmlhelp""" % {"program": sphinxCmd})
|
||||
if DOCUTILS:
|
||||
os.system('''%(program)s -b man . .''' % {'program': sphinxCmd})
|
||||
os.system('''%(program)s -b text . _build/text''' % {'program': sphinxCmd})
|
||||
os.system('''%(program)s -b changes . _build/changes''' % {'program': sphinxCmd})
|
||||
#os.system('''%(program)s -b linkcheck . _build/linkcheck''' % {'program': sphinxCmd})
|
||||
os.system('''%(program)s -b gettext . _build/gettext''' % {'program': sphinxCmd})
|
||||
os.system("""%(program)s -b man . .""" % {"program": sphinxCmd})
|
||||
os.system("""%(program)s -b text . _build/text""" % {"program": sphinxCmd})
|
||||
os.system("""%(program)s -b changes . _build/changes""" % {"program": sphinxCmd})
|
||||
# os.system('''%(program)s -b linkcheck . _build/linkcheck''' % {'program': sphinxCmd})
|
||||
os.system("""%(program)s -b gettext . _build/gettext""" % {"program": sphinxCmd})
|
||||
|
||||
for lang in LANGUAGES:
|
||||
os.system('''%(program)s -b html -D language="%(lang)s" master_doc="%(lang)s" %(lang)s %(lang)s'''
|
||||
% {'lang': lang, 'program': sphinxCmd})
|
||||
os.system('''%(program)s -b htmlhelp -D language="%(lang)s" master_doc="%(lang)s" %(lang)s %(lang)s'''
|
||||
% {'lang': lang, 'program': sphinxCmd})
|
||||
os.system(
|
||||
"""%(program)s -b html -D language="%(lang)s" master_doc="%(lang)s" %(lang)s %(lang)s"""
|
||||
% {"lang": lang, "program": sphinxCmd}
|
||||
)
|
||||
os.system(
|
||||
"""%(program)s -b htmlhelp -D language="%(lang)s" master_doc="%(lang)s" %(lang)s %(lang)s"""
|
||||
% {"lang": lang, "program": sphinxCmd}
|
||||
)
|
||||
if DOCUTILS:
|
||||
os.system('''%(program)s -b man %(lang)s %(lang)s'''
|
||||
% {'lang': lang, 'program': sphinxCmd})
|
||||
os.system('''%(program)s -b text -D language="%(lang)s" master_doc="%(lang)s" %(lang)s %(lang)s'''
|
||||
% {'lang': lang, 'program': sphinxCmd})
|
||||
os.system(
|
||||
"""%(program)s -b man %(lang)s %(lang)s"""
|
||||
% {"lang": lang, "program": sphinxCmd}
|
||||
)
|
||||
os.system(
|
||||
"""%(program)s -b text -D language="%(lang)s" master_doc="%(lang)s" %(lang)s %(lang)s"""
|
||||
% {"lang": lang, "program": sphinxCmd}
|
||||
)
|
||||
# for update/migration
|
||||
os.system('''%(program)s -b gettext -D language="%(lang)s" master_doc="%(lang)s" . _build/gettext/%(lang)s'''
|
||||
% {'lang': lang, 'program': sphinxCmd})
|
||||
os.system(
|
||||
"""%(program)s -b gettext -D language="%(lang)s" master_doc="%(lang)s" . _build/gettext/%(lang)s"""
|
||||
% {"lang": lang, "program": sphinxCmd}
|
||||
)
|
||||
|
||||
|
||||
def man():
|
||||
"""
|
||||
@@ -159,11 +193,14 @@ def man():
|
||||
from docutils.writers import manpage
|
||||
"""
|
||||
|
||||
os.system('''rst2man en.rst gramps.1''')
|
||||
os.system("""rst2man en.rst gramps.1""")
|
||||
|
||||
for lang in LANGUAGES:
|
||||
os.system('''rst2man %(lang)s/%(lang)s.rst -l %(lang)s %(lang)s/gramps.1'''
|
||||
% {'lang': lang})
|
||||
os.system(
|
||||
"""rst2man %(lang)s/%(lang)s.rst -l %(lang)s %(lang)s/gramps.1"""
|
||||
% {"lang": lang}
|
||||
)
|
||||
|
||||
|
||||
def odt():
|
||||
"""
|
||||
@@ -173,11 +210,14 @@ def odt():
|
||||
from docutils.writers.odf_odt import Writer, Reader
|
||||
"""
|
||||
|
||||
os.system('''rst2odt en.rst gramps.odt''')
|
||||
os.system("""rst2odt en.rst gramps.odt""")
|
||||
|
||||
for lang in LANGUAGES:
|
||||
os.system('''rst2odt %(lang)s/%(lang)s.rst -l %(lang)s %(lang)s/gramps.odt'''
|
||||
% {'lang': lang})
|
||||
os.system(
|
||||
"""rst2odt %(lang)s/%(lang)s.rst -l %(lang)s %(lang)s/gramps.odt"""
|
||||
% {"lang": lang}
|
||||
)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
||||
171
docs/conf.py
171
docs/conf.py
@@ -20,54 +20,54 @@ import shlex
|
||||
# If extensions (or modules to document with autodoc) are in another directory,
|
||||
# add these directories to sys.path here. If the directory is relative to the
|
||||
# documentation root, use os.path.abspath to make it absolute, like shown here.
|
||||
#sys.path.insert(0, os.path.abspath('.'))
|
||||
# sys.path.insert(0, os.path.abspath('.'))
|
||||
|
||||
#documentation in root/docs, allow import from root
|
||||
# documentation in root/docs, allow import from root
|
||||
sys.path.append(os.path.abspath(os.pardir))
|
||||
|
||||
# -- General configuration ------------------------------------------------
|
||||
|
||||
# If your documentation needs a minimal Sphinx version, state it here.
|
||||
#needs_sphinx = '1.0'
|
||||
# needs_sphinx = '1.0'
|
||||
|
||||
# Add any Sphinx extension module names here, as strings. They can be
|
||||
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
|
||||
# ones.
|
||||
extensions = [
|
||||
'sphinx.ext.autodoc',
|
||||
'sphinx.ext.doctest',
|
||||
'sphinx.ext.todo',
|
||||
'sphinx.ext.coverage',
|
||||
'sphinx.ext.viewcode',
|
||||
"sphinx.ext.autodoc",
|
||||
"sphinx.ext.doctest",
|
||||
"sphinx.ext.todo",
|
||||
"sphinx.ext.coverage",
|
||||
"sphinx.ext.viewcode",
|
||||
]
|
||||
|
||||
# Add any paths that contain templates here, relative to this directory.
|
||||
templates_path = ['_templates']
|
||||
templates_path = ["_templates"]
|
||||
|
||||
# The suffix(es) of source filenames.
|
||||
# You can specify multiple suffix as a list of string:
|
||||
# source_suffix = ['.rst', '.md']
|
||||
source_suffix = '.rst'
|
||||
source_suffix = ".rst"
|
||||
|
||||
# The encoding of source files.
|
||||
#source_encoding = 'utf-8-sig'
|
||||
# source_encoding = 'utf-8-sig'
|
||||
|
||||
# The master toctree document.
|
||||
master_doc = 'index'
|
||||
master_doc = "index"
|
||||
|
||||
# General information about the project.
|
||||
project = 'Gramps'
|
||||
copyright = '2001-2019, The Gramps Project'
|
||||
author = 'Donald N. Allingham'
|
||||
project = "Gramps"
|
||||
copyright = "2001-2019, The Gramps Project"
|
||||
author = "Donald N. Allingham"
|
||||
|
||||
# The version info for the project you're documenting, acts as replacement for
|
||||
# |version| and |release|, also used in various other places throughout the
|
||||
# built documents.
|
||||
#
|
||||
# The short X.Y version.
|
||||
version = '5.1.0'
|
||||
version = "5.1.0"
|
||||
# The full version, including alpha/beta/rc tags.
|
||||
release = '5.1.0'
|
||||
release = "5.1.0"
|
||||
|
||||
# The language for content autogenerated by Sphinx. Refer to documentation
|
||||
# for a list of supported languages.
|
||||
@@ -78,37 +78,37 @@ language = None
|
||||
|
||||
# There are two options for replacing |today|: either, you set today to some
|
||||
# non-false value, then it is used:
|
||||
#today = ''
|
||||
# today = ''
|
||||
# Else, today_fmt is used as the format for a strftime call.
|
||||
#today_fmt = '%B %d, %Y'
|
||||
# today_fmt = '%B %d, %Y'
|
||||
|
||||
# List of patterns, relative to source directory, that match files and
|
||||
# directories to ignore when looking for source files.
|
||||
exclude_patterns = ['_build']
|
||||
exclude_patterns = ["_build"]
|
||||
|
||||
# The reST default role (used for this markup: `text`) to use for all
|
||||
# documents.
|
||||
#default_role = None
|
||||
# default_role = None
|
||||
|
||||
# If true, '()' will be appended to :func: etc. cross-reference text.
|
||||
#add_function_parentheses = True
|
||||
# add_function_parentheses = True
|
||||
|
||||
# If true, the current module name will be prepended to all description
|
||||
# unit titles (such as .. function::).
|
||||
#add_module_names = True
|
||||
# add_module_names = True
|
||||
|
||||
# If true, sectionauthor and moduleauthor directives will be shown in the
|
||||
# output. They are ignored by default.
|
||||
#show_authors = False
|
||||
# show_authors = False
|
||||
|
||||
# The name of the Pygments (syntax highlighting) style to use.
|
||||
pygments_style = 'sphinx'
|
||||
pygments_style = "sphinx"
|
||||
|
||||
# A list of ignored prefixes for module index sorting.
|
||||
#modindex_common_prefix = []
|
||||
# modindex_common_prefix = []
|
||||
|
||||
# If true, keep warnings as "system message" paragraphs in the built documents.
|
||||
#keep_warnings = False
|
||||
# keep_warnings = False
|
||||
|
||||
# If true, `todo` and `todoList` produce output, else they produce nothing.
|
||||
todo_include_todos = True
|
||||
@@ -118,157 +118,156 @@ todo_include_todos = True
|
||||
|
||||
# The theme to use for HTML and HTML Help pages. See the documentation for
|
||||
# a list of builtin themes. default: alabaster
|
||||
html_theme = 'classic'
|
||||
html_theme = "classic"
|
||||
|
||||
# Theme options are theme-specific and customize the look and feel of a theme
|
||||
# further. For a list of options available for each theme, see the
|
||||
# documentation.
|
||||
#html_theme_options = {}
|
||||
# html_theme_options = {}
|
||||
|
||||
# Add any paths that contain custom themes here, relative to this directory.
|
||||
#html_theme_path = []
|
||||
# html_theme_path = []
|
||||
|
||||
# The name for this set of Sphinx documents. If None, it defaults to
|
||||
# "<project> v<release> documentation".
|
||||
#html_title = None
|
||||
# html_title = None
|
||||
|
||||
# A shorter title for the navigation bar. Default is the same as html_title.
|
||||
#html_short_title = None
|
||||
# html_short_title = None
|
||||
|
||||
# The name of an image file (relative to this directory) to place at the top
|
||||
# of the sidebar.
|
||||
#html_logo = None
|
||||
# html_logo = None
|
||||
|
||||
# The name of an image file (within the static path) to use as favicon of the
|
||||
# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32
|
||||
# pixels large.
|
||||
#html_favicon = None
|
||||
# html_favicon = None
|
||||
|
||||
# Add any paths that contain custom static files (such as style sheets) here,
|
||||
# relative to this directory. They are copied after the builtin static files,
|
||||
# so a file named "default.css" will overwrite the builtin "default.css".
|
||||
#html_static_path = ['_static']
|
||||
# html_static_path = ['_static']
|
||||
html_static_path = []
|
||||
|
||||
# Add any extra paths that contain custom files (such as robots.txt or
|
||||
# .htaccess) here, relative to this directory. These files are copied
|
||||
# directly to the root of the documentation.
|
||||
#html_extra_path = []
|
||||
# html_extra_path = []
|
||||
|
||||
# If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
|
||||
# using the given strftime format.
|
||||
#html_last_updated_fmt = '%b %d, %Y'
|
||||
# html_last_updated_fmt = '%b %d, %Y'
|
||||
|
||||
# If true, SmartyPants will be used to convert quotes and dashes to
|
||||
# typographically correct entities.
|
||||
#html_use_smartypants = True
|
||||
# html_use_smartypants = True
|
||||
|
||||
# Custom sidebar templates, maps document names to template names.
|
||||
#html_sidebars = {}
|
||||
# html_sidebars = {}
|
||||
|
||||
# Additional templates that should be rendered to pages, maps page names to
|
||||
# template names.
|
||||
#html_additional_pages = {}
|
||||
# html_additional_pages = {}
|
||||
|
||||
# If false, no module index is generated.
|
||||
#html_domain_indices = True
|
||||
# html_domain_indices = True
|
||||
|
||||
# If false, no index is generated.
|
||||
#html_use_index = True
|
||||
# html_use_index = True
|
||||
|
||||
# If true, the index is split into individual pages for each letter.
|
||||
#html_split_index = False
|
||||
# html_split_index = False
|
||||
|
||||
# If true, links to the reST sources are added to the pages.
|
||||
#html_show_sourcelink = True
|
||||
# html_show_sourcelink = True
|
||||
|
||||
# If true, "Created using Sphinx" is shown in the HTML footer. Default is True.
|
||||
#html_show_sphinx = True
|
||||
# html_show_sphinx = True
|
||||
|
||||
# If true, "(C) Copyright ..." is shown in the HTML footer. Default is True.
|
||||
#html_show_copyright = True
|
||||
# html_show_copyright = True
|
||||
|
||||
# If true, an OpenSearch description file will be output, and all pages will
|
||||
# contain a <link> tag referring to it. The value of this option must be the
|
||||
# base URL from which the finished HTML is served.
|
||||
#html_use_opensearch = ''
|
||||
# html_use_opensearch = ''
|
||||
|
||||
# This is the file name suffix for HTML files (e.g. ".xhtml").
|
||||
#html_file_suffix = None
|
||||
# html_file_suffix = None
|
||||
|
||||
# Language to be used for generating the HTML full-text search index.
|
||||
# Sphinx supports the following languages:
|
||||
# 'da', 'de', 'en', 'es', 'fi', 'fr', 'h', 'it', 'ja'
|
||||
# 'nl', 'no', 'pt', 'ro', 'r', 'sv', 'tr'
|
||||
#html_search_language = 'en'
|
||||
# html_search_language = 'en'
|
||||
|
||||
# A dictionary with options for the search language support, empty by default.
|
||||
# Now only 'ja' uses this config value
|
||||
#html_search_options = {'type': 'default'}
|
||||
# html_search_options = {'type': 'default'}
|
||||
|
||||
# The name of a javascript file (relative to the configuration directory) that
|
||||
# implements a search results scorer. If empty, the default will be used.
|
||||
#html_search_scorer = 'scorer.js'
|
||||
# html_search_scorer = 'scorer.js'
|
||||
|
||||
# Output file base name for HTML help builder.
|
||||
htmlhelp_basename = 'Grampsdoc'
|
||||
htmlhelp_basename = "Grampsdoc"
|
||||
|
||||
# -- Options for LaTeX output ---------------------------------------------
|
||||
|
||||
latex_elements = {
|
||||
# The paper size ('letterpaper' or 'a4paper').
|
||||
#'papersize': 'letterpaper',
|
||||
|
||||
# The font size ('10pt', '11pt' or '12pt').
|
||||
#'pointsize': '10pt',
|
||||
|
||||
# Additional stuff for the LaTeX preamble.
|
||||
#'preamble': '',
|
||||
|
||||
# Latex figure (float) alignment
|
||||
#'figure_align': 'htbp',
|
||||
# The paper size ('letterpaper' or 'a4paper').
|
||||
#'papersize': 'letterpaper',
|
||||
# The font size ('10pt', '11pt' or '12pt').
|
||||
#'pointsize': '10pt',
|
||||
# Additional stuff for the LaTeX preamble.
|
||||
#'preamble': '',
|
||||
# Latex figure (float) alignment
|
||||
#'figure_align': 'htbp',
|
||||
}
|
||||
|
||||
# Grouping the document tree into LaTeX files. List of tuples
|
||||
# (source start file, target name, title,
|
||||
# author, documentclass [howto, manual, or own class]).
|
||||
latex_documents = [
|
||||
('master_doc', 'Gramps.tex', 'Gramps Documentation',
|
||||
'The Gramps Project', 'manual'),
|
||||
(
|
||||
"master_doc",
|
||||
"Gramps.tex",
|
||||
"Gramps Documentation",
|
||||
"The Gramps Project",
|
||||
"manual",
|
||||
),
|
||||
]
|
||||
|
||||
# The name of an image file (relative to this directory) to place at the top of
|
||||
# the title page.
|
||||
#latex_logo = None
|
||||
# latex_logo = None
|
||||
|
||||
# For "manual" documents, if this is true, then toplevel headings are parts,
|
||||
# not chapters.
|
||||
#latex_use_parts = False
|
||||
# latex_use_parts = False
|
||||
|
||||
# If true, show page references after internal links.
|
||||
#latex_show_pagerefs = False
|
||||
# latex_show_pagerefs = False
|
||||
|
||||
# If true, show URL addresses after external links.
|
||||
#latex_show_urls = False
|
||||
# latex_show_urls = False
|
||||
|
||||
# Documents to append as an appendix to all manuals.
|
||||
#latex_appendices = []
|
||||
# latex_appendices = []
|
||||
|
||||
# If false, no module index is generated.
|
||||
#latex_domain_indices = True
|
||||
# latex_domain_indices = True
|
||||
|
||||
|
||||
# -- Options for manual page output ---------------------------------------
|
||||
|
||||
# One entry per manual page. List of tuples
|
||||
# (source start file, name, description, authors, manual section).
|
||||
man_pages = [
|
||||
(master_doc, 'gramps', 'Gramps Documentation',
|
||||
[author], 1)
|
||||
]
|
||||
man_pages = [(master_doc, "gramps", "Gramps Documentation", [author], 1)]
|
||||
|
||||
# If true, show URL addresses after external links.
|
||||
#man_show_urls = False
|
||||
# man_show_urls = False
|
||||
|
||||
|
||||
# -- Options for Texinfo output -------------------------------------------
|
||||
@@ -277,19 +276,25 @@ man_pages = [
|
||||
# (source start file, target name, title, author,
|
||||
# dir menu entry, description, category)
|
||||
texinfo_documents = [
|
||||
(master_doc, 'Gramps', 'Gramps Documentation',
|
||||
author, 'Gramps', 'One line description of project.',
|
||||
'Miscellaneous'),
|
||||
(
|
||||
master_doc,
|
||||
"Gramps",
|
||||
"Gramps Documentation",
|
||||
author,
|
||||
"Gramps",
|
||||
"One line description of project.",
|
||||
"Miscellaneous",
|
||||
),
|
||||
]
|
||||
|
||||
# Documents to append as an appendix to all manuals.
|
||||
#texinfo_appendices = []
|
||||
# texinfo_appendices = []
|
||||
|
||||
# If false, no module index is generated.
|
||||
#texinfo_domain_indices = True
|
||||
# texinfo_domain_indices = True
|
||||
|
||||
# How to display URL addresses: 'footnote', 'no', or 'inline'.
|
||||
#texinfo_show_urls = 'footnote'
|
||||
# texinfo_show_urls = 'footnote'
|
||||
|
||||
# If true, do not generate a @detailmenu in the "Top" node's menu.
|
||||
#texinfo_no_detailmenu = False
|
||||
# texinfo_no_detailmenu = False
|
||||
|
||||
@@ -37,18 +37,19 @@ import sys
|
||||
from argparse import ArgumentParser
|
||||
|
||||
# You can set these variables from the command line.
|
||||
SPHINXBUILD = 'sphinx-build'
|
||||
SPHINXBUILD = "sphinx-build"
|
||||
|
||||
if sys.platform == 'win32':
|
||||
pythonCmd = os.path.join(sys.prefix, 'bin', 'python.exe')
|
||||
sphinxCmd = os.path.join(sys.prefix, 'bin', 'sphinx-build.exe')
|
||||
elif sys.platform in ['linux', 'linux2', 'darwin', 'cygwin']:
|
||||
pythonCmd = os.path.join(sys.prefix, 'bin', 'python')
|
||||
if sys.platform == "win32":
|
||||
pythonCmd = os.path.join(sys.prefix, "bin", "python.exe")
|
||||
sphinxCmd = os.path.join(sys.prefix, "bin", "sphinx-build.exe")
|
||||
elif sys.platform in ["linux", "linux2", "darwin", "cygwin"]:
|
||||
pythonCmd = os.path.join(sys.prefix, "bin", "python")
|
||||
sphinxCmd = SPHINXBUILD
|
||||
else:
|
||||
print ("Update Docs ERROR: unknown system, don't know sphinx, ... commands")
|
||||
print("Update Docs ERROR: unknown system, don't know sphinx, ... commands")
|
||||
sys.exit(0)
|
||||
|
||||
|
||||
def tests():
|
||||
"""
|
||||
Testing installed programs.
|
||||
@@ -57,15 +58,16 @@ def tests():
|
||||
"""
|
||||
try:
|
||||
print("\n=================='python'=============================\n")
|
||||
os.system('''%(program)s -V''' % {'program': pythonCmd})
|
||||
os.system("""%(program)s -V""" % {"program": pythonCmd})
|
||||
except:
|
||||
print ('Please, install python')
|
||||
print("Please, install python")
|
||||
|
||||
try:
|
||||
print("\n=================='sphinx-build'=============================\n")
|
||||
os.system('''%(program)s''' % {'program': sphinxCmd})
|
||||
os.system("""%(program)s""" % {"program": sphinxCmd})
|
||||
except:
|
||||
print ('Please, install sphinx')
|
||||
print("Please, install sphinx")
|
||||
|
||||
|
||||
def main():
|
||||
"""
|
||||
@@ -74,17 +76,26 @@ def main():
|
||||
"""
|
||||
|
||||
parser = ArgumentParser(
|
||||
description='This program aims to handle manual'
|
||||
' and translated version.',
|
||||
)
|
||||
description="This program aims to handle manual" " and translated version.",
|
||||
)
|
||||
|
||||
parser.add_argument("-t", "--test",
|
||||
action="store_true", dest="test", default=True,
|
||||
help="test if 'python' and 'sphinx' are properly installed")
|
||||
parser.add_argument(
|
||||
"-t",
|
||||
"--test",
|
||||
action="store_true",
|
||||
dest="test",
|
||||
default=True,
|
||||
help="test if 'python' and 'sphinx' are properly installed",
|
||||
)
|
||||
|
||||
parser.add_argument("-b", "--build",
|
||||
action="store_true", dest="build", default=True,
|
||||
help="build documentation")
|
||||
parser.add_argument(
|
||||
"-b",
|
||||
"--build",
|
||||
action="store_true",
|
||||
dest="build",
|
||||
default=True,
|
||||
help="build documentation",
|
||||
)
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
@@ -94,6 +105,7 @@ def main():
|
||||
if args.build:
|
||||
build()
|
||||
|
||||
|
||||
def build():
|
||||
"""
|
||||
Build documentation.
|
||||
@@ -101,10 +113,11 @@ def build():
|
||||
|
||||
# testing stage
|
||||
|
||||
os.system('''%(program)s -b html . _build/html''' % {'program': sphinxCmd})
|
||||
#os.system('''%(program)s -b changes . _build/changes''' % {'program': sphinxCmd})
|
||||
#os.system('''%(program)s -b linkcheck . _build/linkcheck''' % {'program': sphinxCmd})
|
||||
#os.system('''%(program)s -b devhelp . _build/devhelp''' % {'program': sphinxCmd})
|
||||
os.system("""%(program)s -b html . _build/html""" % {"program": sphinxCmd})
|
||||
# os.system('''%(program)s -b changes . _build/changes''' % {'program': sphinxCmd})
|
||||
# os.system('''%(program)s -b linkcheck . _build/linkcheck''' % {'program': sphinxCmd})
|
||||
# os.system('''%(program)s -b devhelp . _build/devhelp''' % {'program': sphinxCmd})
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
||||
@@ -29,20 +29,20 @@
|
||||
Module responsible for handling the command line arguments for Gramps.
|
||||
"""
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
# -------------------------------------------------------------------------
|
||||
#
|
||||
# Standard python modules
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
# -------------------------------------------------------------------------
|
||||
import os
|
||||
import sys
|
||||
import re
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
# -------------------------------------------------------------------------
|
||||
#
|
||||
# gramps modules
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
# -------------------------------------------------------------------------
|
||||
from gramps.gen.recentfiles import recent_files
|
||||
from gramps.gen.utils.file import rm_tempdir, get_empty_tempdir
|
||||
from .clidbman import CLIDbManager, NAME_FILE, find_locker_name
|
||||
@@ -52,14 +52,16 @@ from gramps.gen.plug import BasePluginManager
|
||||
from gramps.gen.plug.report import CATEGORY_BOOK, CATEGORY_CODE, BookList
|
||||
from .plug import cl_report, cl_book
|
||||
from gramps.gen.const import GRAMPS_LOCALE as glocale
|
||||
|
||||
_ = glocale.translation.gettext
|
||||
from gramps.gen.config import config
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
|
||||
# -------------------------------------------------------------------------
|
||||
#
|
||||
# private functions
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
# -------------------------------------------------------------------------
|
||||
def _split_options(options_str):
|
||||
"""
|
||||
Split the options for the action.
|
||||
@@ -103,32 +105,32 @@ def _split_options(options_str):
|
||||
if not parsing_value:
|
||||
# Parsing the name of the option
|
||||
if char == "=":
|
||||
#print char, "This value ends the name"
|
||||
# print char, "This value ends the name"
|
||||
parsing_value = True
|
||||
else:
|
||||
#print char, "This value is part of the name"
|
||||
# print char, "This value is part of the name"
|
||||
name += char
|
||||
else:
|
||||
# Parsing the value of the option
|
||||
if value == "" and char == '[':
|
||||
#print char, "This character begins a list"
|
||||
if value == "" and char == "[":
|
||||
# print char, "This character begins a list"
|
||||
in_list = True
|
||||
value += char
|
||||
elif in_list == True and char == ']':
|
||||
#print char, "This character ends the list"
|
||||
elif in_list == True and char == "]":
|
||||
# print char, "This character ends the list"
|
||||
in_list = False
|
||||
value += char
|
||||
elif not in_quotes and (char == '"' or char == "'"):
|
||||
#print char, "This character starts a quoted string"
|
||||
# print char, "This character starts a quoted string"
|
||||
in_quotes = True
|
||||
quote_type = char
|
||||
value += char
|
||||
elif in_quotes and char == quote_type:
|
||||
#print char, "This character ends a quoted string"
|
||||
# print char, "This character ends a quoted string"
|
||||
in_quotes = False
|
||||
value += char
|
||||
elif not in_quotes and not in_list and char == ",":
|
||||
#print char, "This character ends the value of the option"
|
||||
# print char, "This character ends the value of the option"
|
||||
options_str_dict[name] = value
|
||||
name = ""
|
||||
value = ""
|
||||
@@ -136,7 +138,7 @@ def _split_options(options_str):
|
||||
in_quotes = False
|
||||
in_list = False
|
||||
else:
|
||||
#print char, "This character is part of the value"
|
||||
# print char, "This character is part of the value"
|
||||
value += char
|
||||
|
||||
if parsing_value and not in_quotes and not in_list:
|
||||
@@ -145,9 +147,10 @@ def _split_options(options_str):
|
||||
|
||||
return options_str_dict
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
|
||||
# -------------------------------------------------------------------------
|
||||
# ArgHandler
|
||||
#-------------------------------------------------------------------------
|
||||
# -------------------------------------------------------------------------
|
||||
class ArgHandler:
|
||||
"""
|
||||
This class is responsible for the non GUI handling of commands.
|
||||
@@ -155,8 +158,7 @@ class ArgHandler:
|
||||
actions requested working on a :class:`.DbState`.
|
||||
"""
|
||||
|
||||
def __init__(self, dbstate, parser, sessionmanager,
|
||||
errorfunc=None, gui=False):
|
||||
def __init__(self, dbstate, parser, sessionmanager, errorfunc=None, gui=False):
|
||||
self.dbstate = dbstate
|
||||
self.smgr = sessionmanager
|
||||
self.errorfunc = errorfunc
|
||||
@@ -198,16 +200,16 @@ class ArgHandler:
|
||||
if msg2 is not None:
|
||||
print(msg2, file=sys.stderr)
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
# -------------------------------------------------------------------------
|
||||
# Argument parser: sorts out given arguments
|
||||
#-------------------------------------------------------------------------
|
||||
# -------------------------------------------------------------------------
|
||||
def sanitize_args(self, importlist, exportlist):
|
||||
"""
|
||||
Check the lists with open, exports, imports, and actions options.
|
||||
"""
|
||||
for (value, family_tree_format) in importlist:
|
||||
for value, family_tree_format in importlist:
|
||||
self.__handle_import_option(value, family_tree_format)
|
||||
for (value, family_tree_format) in exportlist:
|
||||
for value, family_tree_format in exportlist:
|
||||
self.__handle_export_option(value, family_tree_format)
|
||||
|
||||
def __handle_open_option(self, value, create):
|
||||
@@ -226,22 +228,29 @@ class ArgHandler:
|
||||
if not self.check_db(db_path, self.force_unlock):
|
||||
sys.exit(1)
|
||||
if create:
|
||||
self.__error(_("Error: Family Tree '%s' already exists.\n"
|
||||
"The '-C' option cannot be used."
|
||||
) % value)
|
||||
self.__error(
|
||||
_(
|
||||
"Error: Family Tree '%s' already exists.\n"
|
||||
"The '-C' option cannot be used."
|
||||
)
|
||||
% value
|
||||
)
|
||||
sys.exit(1)
|
||||
return db_path
|
||||
elif create:
|
||||
# create the tree here, and continue
|
||||
dbid = config.get('database.backend')
|
||||
db_path, title = self.dbman.create_new_db_cli(title=value,
|
||||
dbid=dbid)
|
||||
dbid = config.get("database.backend")
|
||||
db_path, title = self.dbman.create_new_db_cli(title=value, dbid=dbid)
|
||||
return db_path
|
||||
else:
|
||||
self.__error(_('Error: Input Family Tree "%s" does not exist.\n'
|
||||
"If GEDCOM, Gramps-xml or grdb, use the -i option "
|
||||
"to import into a Family Tree instead."
|
||||
) % value)
|
||||
self.__error(
|
||||
_(
|
||||
'Error: Input Family Tree "%s" does not exist.\n'
|
||||
"If GEDCOM, Gramps-xml or grdb, use the -i option "
|
||||
"to import into a Family Tree instead."
|
||||
)
|
||||
% value
|
||||
)
|
||||
sys.exit(1)
|
||||
|
||||
def __handle_import_option(self, value, family_tree_format):
|
||||
@@ -251,8 +260,8 @@ class ArgHandler:
|
||||
"""
|
||||
fname = value
|
||||
fullpath = os.path.abspath(os.path.expanduser(fname))
|
||||
if fname != '-' and not os.path.exists(fullpath):
|
||||
self.__error(_('Error: Import file %s not found.') % fname)
|
||||
if fname != "-" and not os.path.exists(fullpath):
|
||||
self.__error(_("Error: Import file %s not found.") % fname)
|
||||
sys.exit(1)
|
||||
|
||||
if family_tree_format is None:
|
||||
@@ -270,10 +279,13 @@ class ArgHandler:
|
||||
if plugin_found:
|
||||
self.imports.append((fname, family_tree_format))
|
||||
else:
|
||||
self.__error(_('Error: Unrecognized type: "%(format)s" for '
|
||||
'import file: %(filename)s'
|
||||
) % {'format' : family_tree_format,
|
||||
'filename' : fname})
|
||||
self.__error(
|
||||
_(
|
||||
'Error: Unrecognized type: "%(format)s" for '
|
||||
"import file: %(filename)s"
|
||||
)
|
||||
% {"format": family_tree_format, "filename": fname}
|
||||
)
|
||||
sys.exit(1)
|
||||
|
||||
def __handle_export_option(self, value, family_tree_format):
|
||||
@@ -285,20 +297,27 @@ class ArgHandler:
|
||||
if self.gui:
|
||||
return
|
||||
fname = value
|
||||
if fname == '-':
|
||||
fullpath = '-'
|
||||
if fname == "-":
|
||||
fullpath = "-"
|
||||
else:
|
||||
fullpath = os.path.abspath(os.path.expanduser(fname))
|
||||
if os.path.exists(fullpath):
|
||||
message = _("WARNING: Output file already exists!\n"
|
||||
"WARNING: It will be overwritten:\n %s"
|
||||
) % fullpath
|
||||
accepted = self.user.prompt(_('OK to overwrite?'), message,
|
||||
_('yes'), _('no'),
|
||||
default_label=_('yes'))
|
||||
message = (
|
||||
_(
|
||||
"WARNING: Output file already exists!\n"
|
||||
"WARNING: It will be overwritten:\n %s"
|
||||
)
|
||||
% fullpath
|
||||
)
|
||||
accepted = self.user.prompt(
|
||||
_("OK to overwrite?"),
|
||||
message,
|
||||
_("yes"),
|
||||
_("no"),
|
||||
default_label=_("yes"),
|
||||
)
|
||||
if accepted:
|
||||
self.__error(_("Will overwrite the existing file: %s"
|
||||
) % fullpath)
|
||||
self.__error(_("Will overwrite the existing file: %s") % fullpath)
|
||||
else:
|
||||
sys.exit(1)
|
||||
|
||||
@@ -317,8 +336,7 @@ class ArgHandler:
|
||||
if plugin_found:
|
||||
self.exports.append((fullpath, family_tree_format))
|
||||
else:
|
||||
self.__error(_("ERROR: Unrecognized format for export file %s"
|
||||
) % fname)
|
||||
self.__error(_("ERROR: Unrecognized format for export file %s") % fname)
|
||||
sys.exit(1)
|
||||
|
||||
def __deduce_db_path(self, db_name_or_path):
|
||||
@@ -343,10 +361,10 @@ class ArgHandler:
|
||||
|
||||
return db_path
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
# -------------------------------------------------------------------------
|
||||
# Overall argument handler:
|
||||
# sorts out the sequence and details of operations
|
||||
#-------------------------------------------------------------------------
|
||||
# -------------------------------------------------------------------------
|
||||
def handle_args_gui(self):
|
||||
"""
|
||||
Method to handle the arguments that can be given for a GUI session.
|
||||
@@ -368,8 +386,7 @@ class ArgHandler:
|
||||
if not db_path:
|
||||
# Apparently it is not a database. See if it is a file that
|
||||
# can be imported.
|
||||
db_path, title = self.dbman.import_new_db(self.open_gui,
|
||||
self.user)
|
||||
db_path, title = self.dbman.import_new_db(self.open_gui, self.user)
|
||||
|
||||
if db_path:
|
||||
# Test if not locked or problematic
|
||||
@@ -402,17 +419,21 @@ class ArgHandler:
|
||||
"""
|
||||
# Handle the "-l" List Family Trees option.
|
||||
if self.list:
|
||||
print(_('List of known Family Trees in your database path\n'))
|
||||
print(_("List of known Family Trees in your database path\n"))
|
||||
|
||||
for name, dirname in sorted(self.dbman.family_tree_list(),
|
||||
key=lambda pair: pair[0].lower()):
|
||||
if (self.database_names is None
|
||||
or any([(re.match("^" + dbname + "$", name)
|
||||
or dbname == name)
|
||||
for dbname in self.database_names])):
|
||||
print(_('%(full_DB_path)s with name "%(f_t_name)s"'
|
||||
) % {'full_DB_path' : dirname,
|
||||
'f_t_name' : name})
|
||||
for name, dirname in sorted(
|
||||
self.dbman.family_tree_list(), key=lambda pair: pair[0].lower()
|
||||
):
|
||||
if self.database_names is None or any(
|
||||
[
|
||||
(re.match("^" + dbname + "$", name) or dbname == name)
|
||||
for dbname in self.database_names
|
||||
]
|
||||
):
|
||||
print(
|
||||
_('%(full_DB_path)s with name "%(f_t_name)s"')
|
||||
% {"full_DB_path": dirname, "f_t_name": name}
|
||||
)
|
||||
return
|
||||
|
||||
# Handle the "--remove" Family Tree
|
||||
@@ -428,7 +449,7 @@ class ArgHandler:
|
||||
|
||||
# Handle the "-t" List Family Trees, tab delimited option.
|
||||
if self.list_table:
|
||||
print(_('Gramps Family Trees:'))
|
||||
print(_("Gramps Family Trees:"))
|
||||
summary_list = self.dbman.family_tree_summary(self.database_names)
|
||||
if not summary_list:
|
||||
return
|
||||
@@ -439,9 +460,9 @@ class ArgHandler:
|
||||
if key != _("Family Tree"):
|
||||
line_list += [key]
|
||||
print("\t".join(line_list))
|
||||
for summary in sorted(summary_list,
|
||||
key=lambda
|
||||
sum: sum[_("Family Tree")].lower()):
|
||||
for summary in sorted(
|
||||
summary_list, key=lambda sum: sum[_("Family Tree")].lower()
|
||||
):
|
||||
line_list = [(_('"%s"') % summary[_("Family Tree")])]
|
||||
for item in sorted(summary):
|
||||
if item != _("Family Tree"):
|
||||
@@ -453,28 +474,25 @@ class ArgHandler:
|
||||
self.__open_action()
|
||||
self.__import_action()
|
||||
|
||||
for (action, op_string) in self.actions:
|
||||
print(_("Performing action: %s."
|
||||
) % action,
|
||||
file=sys.stderr)
|
||||
for action, op_string in self.actions:
|
||||
print(_("Performing action: %s.") % action, file=sys.stderr)
|
||||
if op_string:
|
||||
print(_("Using options string: %s"
|
||||
) % op_string,
|
||||
file=sys.stderr)
|
||||
print(_("Using options string: %s") % op_string, file=sys.stderr)
|
||||
self.cl_action(action, op_string)
|
||||
|
||||
for expt in self.exports:
|
||||
print(_("Exporting: file %(filename)s, format %(format)s."
|
||||
) % {'filename' : expt[0],
|
||||
'format' : expt[1]},
|
||||
file=sys.stderr)
|
||||
print(
|
||||
_("Exporting: file %(filename)s, format %(format)s.")
|
||||
% {"filename": expt[0], "format": expt[1]},
|
||||
file=sys.stderr,
|
||||
)
|
||||
self.cl_export(expt[0], expt[1])
|
||||
|
||||
if cleanup:
|
||||
self.cleanup()
|
||||
|
||||
def cleanup(self):
|
||||
""" clean up any remaining files """
|
||||
"""clean up any remaining files"""
|
||||
print(_("Cleaning up."), file=sys.stderr)
|
||||
# remove files in import db subdir after use
|
||||
self.dbstate.db.close()
|
||||
@@ -498,19 +516,20 @@ class ArgHandler:
|
||||
if not self.open:
|
||||
# Create empty dir for imported database(s)
|
||||
if self.gui:
|
||||
dbid = config.get('database.backend')
|
||||
self.imp_db_path, title = self.dbman.create_new_db_cli(
|
||||
dbid=dbid)
|
||||
dbid = config.get("database.backend")
|
||||
self.imp_db_path, title = self.dbman.create_new_db_cli(dbid=dbid)
|
||||
else:
|
||||
self.imp_db_path = get_empty_tempdir("import_dbdir")
|
||||
dbid = config.get('database.backend')
|
||||
dbid = config.get("database.backend")
|
||||
newdb = make_database(dbid)
|
||||
versionpath = os.path.join(self.imp_db_path, str(DBBACKEND))
|
||||
with open(versionpath, "w") as version_file:
|
||||
version_file.write(dbid)
|
||||
|
||||
try:
|
||||
self.smgr.open_activate(self.imp_db_path, self.username, self.password)
|
||||
self.smgr.open_activate(
|
||||
self.imp_db_path, self.username, self.password
|
||||
)
|
||||
msg = _("Created empty Family Tree successfully")
|
||||
print(msg, file=sys.stderr)
|
||||
except:
|
||||
@@ -519,9 +538,10 @@ class ArgHandler:
|
||||
sys.exit(1)
|
||||
|
||||
for imp in self.imports:
|
||||
msg = _("Importing: file %(filename)s, format %(format)s."
|
||||
) % {'filename' : imp[0],
|
||||
'format' : imp[1]}
|
||||
msg = _("Importing: file %(filename)s, format %(format)s.") % {
|
||||
"filename": imp[0],
|
||||
"format": imp[1],
|
||||
}
|
||||
print(msg, file=sys.stderr)
|
||||
self.cl_import(imp[0], imp[1])
|
||||
|
||||
@@ -552,8 +572,10 @@ class ArgHandler:
|
||||
if force_unlock:
|
||||
self.dbman.break_lock(dbpath)
|
||||
if self.dbman.is_locked(dbpath):
|
||||
self.__error((_("Database is locked, cannot open it!") + '\n' +
|
||||
_(" Info: %s")) % find_locker_name(dbpath))
|
||||
self.__error(
|
||||
(_("Database is locked, cannot open it!") + "\n" + _(" Info: %s"))
|
||||
% find_locker_name(dbpath)
|
||||
)
|
||||
return False
|
||||
if self.dbman.needs_recovery(dbpath):
|
||||
self.__error(_("Database needs recovery, cannot open it!"))
|
||||
@@ -563,11 +585,11 @@ class ArgHandler:
|
||||
return False
|
||||
return True
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
# -------------------------------------------------------------------------
|
||||
#
|
||||
# Import handler
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
# -------------------------------------------------------------------------
|
||||
def cl_import(self, filename, family_tree_format):
|
||||
"""
|
||||
Command-line import routine.
|
||||
@@ -579,11 +601,11 @@ class ArgHandler:
|
||||
import_function = plugin.get_import_function()
|
||||
import_function(self.dbstate.db, filename, self.user)
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
# -------------------------------------------------------------------------
|
||||
#
|
||||
# Export handler
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
# -------------------------------------------------------------------------
|
||||
def cl_export(self, filename, family_tree_format):
|
||||
"""
|
||||
Command-line export routine.
|
||||
@@ -595,11 +617,11 @@ class ArgHandler:
|
||||
export_function = plugin.get_export_function()
|
||||
export_function(self.dbstate.db, filename, self.user)
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
# -------------------------------------------------------------------------
|
||||
#
|
||||
# Action handler
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
# -------------------------------------------------------------------------
|
||||
def cl_action(self, action, options_str):
|
||||
"""
|
||||
Command-line action routine. Try to perform specified action.
|
||||
@@ -610,117 +632,130 @@ class ArgHandler:
|
||||
options_str_dict = _split_options(options_str)
|
||||
except:
|
||||
options_str_dict = {}
|
||||
print(_("Ignoring invalid options string."),
|
||||
file=sys.stderr)
|
||||
print(_("Ignoring invalid options string."), file=sys.stderr)
|
||||
|
||||
name = options_str_dict.pop('name', None)
|
||||
name = options_str_dict.pop("name", None)
|
||||
_cl_list = pmgr.get_reg_reports(gui=False)
|
||||
if name:
|
||||
for pdata in _cl_list:
|
||||
if name == pdata.id:
|
||||
mod = pmgr.load_plugin(pdata)
|
||||
if not mod:
|
||||
#import of plugin failed
|
||||
# import of plugin failed
|
||||
return
|
||||
category = pdata.category
|
||||
report_class = getattr(mod, pdata.reportclass)
|
||||
options_class = getattr(mod, pdata.optionclass)
|
||||
if category in (CATEGORY_BOOK, CATEGORY_CODE):
|
||||
options_class(self.dbstate.db, name, category,
|
||||
options_str_dict)
|
||||
options_class(
|
||||
self.dbstate.db, name, category, options_str_dict
|
||||
)
|
||||
else:
|
||||
cl_report(self.dbstate.db, name, category,
|
||||
report_class, options_class,
|
||||
options_str_dict)
|
||||
cl_report(
|
||||
self.dbstate.db,
|
||||
name,
|
||||
category,
|
||||
report_class,
|
||||
options_class,
|
||||
options_str_dict,
|
||||
)
|
||||
return
|
||||
# name exists, but is not in the list of valid report names
|
||||
msg = _("Unknown report name.")
|
||||
else:
|
||||
msg = _("Report name not given. "
|
||||
"Please use one of %(donottranslate)s=reportname"
|
||||
) % {'donottranslate' : '[-p|--options] name'}
|
||||
msg = _(
|
||||
"Report name not given. "
|
||||
"Please use one of %(donottranslate)s=reportname"
|
||||
) % {"donottranslate": "[-p|--options] name"}
|
||||
|
||||
print(_("%s\n Available names are:") % msg, file=sys.stderr)
|
||||
for pdata in sorted(_cl_list, key=lambda pdata: pdata.id.lower()):
|
||||
# Print cli report name ([item[0]), GUI report name (item[4])
|
||||
if len(pdata.id) <= 25:
|
||||
print(" %s%s- %s" % (pdata.id,
|
||||
" " * (26 - len(pdata.id)),
|
||||
pdata.name),
|
||||
file=sys.stderr)
|
||||
print(
|
||||
" %s%s- %s"
|
||||
% (pdata.id, " " * (26 - len(pdata.id)), pdata.name),
|
||||
file=sys.stderr,
|
||||
)
|
||||
else:
|
||||
print(" %s\t- %s" % (pdata.id, pdata.name),
|
||||
file=sys.stderr)
|
||||
print(" %s\t- %s" % (pdata.id, pdata.name), file=sys.stderr)
|
||||
|
||||
elif action == "tool":
|
||||
from gramps.gui.plug import tool
|
||||
|
||||
try:
|
||||
options_str_dict = dict([tuple(chunk.split('='))
|
||||
for chunk in options_str.split(',')])
|
||||
options_str_dict = dict(
|
||||
[tuple(chunk.split("=")) for chunk in options_str.split(",")]
|
||||
)
|
||||
except:
|
||||
options_str_dict = {}
|
||||
print(_("Ignoring invalid options string."),
|
||||
file=sys.stderr)
|
||||
print(_("Ignoring invalid options string."), file=sys.stderr)
|
||||
|
||||
name = options_str_dict.pop('name', None)
|
||||
name = options_str_dict.pop("name", None)
|
||||
_cli_tool_list = pmgr.get_reg_tools(gui=False)
|
||||
if name:
|
||||
for pdata in _cli_tool_list:
|
||||
if name == pdata.id:
|
||||
mod = pmgr.load_plugin(pdata)
|
||||
if not mod:
|
||||
#import of plugin failed
|
||||
# import of plugin failed
|
||||
return
|
||||
category = pdata.category
|
||||
tool_class = getattr(mod, pdata.toolclass)
|
||||
options_class = getattr(mod, pdata.optionclass)
|
||||
tool.cli_tool(dbstate=self.dbstate,
|
||||
name=name,
|
||||
category=category,
|
||||
tool_class=tool_class,
|
||||
options_class=options_class,
|
||||
options_str_dict=options_str_dict,
|
||||
user=self.user)
|
||||
tool.cli_tool(
|
||||
dbstate=self.dbstate,
|
||||
name=name,
|
||||
category=category,
|
||||
tool_class=tool_class,
|
||||
options_class=options_class,
|
||||
options_str_dict=options_str_dict,
|
||||
user=self.user,
|
||||
)
|
||||
return
|
||||
msg = _("Unknown tool name.")
|
||||
else:
|
||||
msg = _("Tool name not given. "
|
||||
"Please use one of %(donottranslate)s=toolname."
|
||||
) % {'donottranslate' : '[-p|--options] name'}
|
||||
msg = _(
|
||||
"Tool name not given. "
|
||||
"Please use one of %(donottranslate)s=toolname."
|
||||
) % {"donottranslate": "[-p|--options] name"}
|
||||
|
||||
print(_("%s\n Available names are:") % msg, file=sys.stderr)
|
||||
for pdata in sorted(_cli_tool_list,
|
||||
key=lambda pdata: pdata.id.lower()):
|
||||
for pdata in sorted(_cli_tool_list, key=lambda pdata: pdata.id.lower()):
|
||||
# Print cli report name ([item[0]), GUI report name (item[4])
|
||||
if len(pdata.id) <= 25:
|
||||
print(" %s%s- %s" % (pdata.id,
|
||||
" " * (26 - len(pdata.id)),
|
||||
pdata.name),
|
||||
file=sys.stderr)
|
||||
print(
|
||||
" %s%s- %s"
|
||||
% (pdata.id, " " * (26 - len(pdata.id)), pdata.name),
|
||||
file=sys.stderr,
|
||||
)
|
||||
else:
|
||||
print(" %s\t- %s" % (pdata.id, pdata.name),
|
||||
file=sys.stderr)
|
||||
print(" %s\t- %s" % (pdata.id, pdata.name), file=sys.stderr)
|
||||
|
||||
elif action == "book":
|
||||
try:
|
||||
options_str_dict = _split_options(options_str)
|
||||
except:
|
||||
options_str_dict = {}
|
||||
print(_("Ignoring invalid options string."),
|
||||
file=sys.stderr)
|
||||
print(_("Ignoring invalid options string."), file=sys.stderr)
|
||||
|
||||
name = options_str_dict.pop('name', None)
|
||||
book_list = BookList('books.xml', self.dbstate.db)
|
||||
name = options_str_dict.pop("name", None)
|
||||
book_list = BookList("books.xml", self.dbstate.db)
|
||||
if name:
|
||||
if name in book_list.get_book_names():
|
||||
cl_book(self.dbstate.db, name, book_list.get_book(name),
|
||||
options_str_dict)
|
||||
cl_book(
|
||||
self.dbstate.db,
|
||||
name,
|
||||
book_list.get_book(name),
|
||||
options_str_dict,
|
||||
)
|
||||
return
|
||||
msg = _("Unknown book name.")
|
||||
else:
|
||||
msg = _("Book name not given. "
|
||||
"Please use one of %(donottranslate)s=bookname."
|
||||
) % {'donottranslate' : '[-p|--options] name'}
|
||||
msg = _(
|
||||
"Book name not given. "
|
||||
"Please use one of %(donottranslate)s=bookname."
|
||||
) % {"donottranslate": "[-p|--options] name"}
|
||||
|
||||
print(_("%s\n Available names are:") % msg, file=sys.stderr)
|
||||
for name in sorted(book_list.get_book_names()):
|
||||
|
||||
@@ -30,11 +30,11 @@
|
||||
Module responsible for handling the command line arguments for Gramps.
|
||||
"""
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
# -------------------------------------------------------------------------
|
||||
#
|
||||
# Standard python modules
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
# -------------------------------------------------------------------------
|
||||
import sys
|
||||
import os
|
||||
import getopt
|
||||
@@ -42,19 +42,29 @@ import logging
|
||||
import shutil
|
||||
from glob import glob
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
# -------------------------------------------------------------------------
|
||||
#
|
||||
# gramps modules
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
from gramps.gen.const import (LONGOPTS, SHORTOPTS, USER_PLUGINS, VERSION_DIR,
|
||||
USER_CACHE, USER_CONFIG, USER_DATA, THUMB_DIR,
|
||||
USER_CSS)
|
||||
# -------------------------------------------------------------------------
|
||||
from gramps.gen.const import (
|
||||
LONGOPTS,
|
||||
SHORTOPTS,
|
||||
USER_PLUGINS,
|
||||
VERSION_DIR,
|
||||
USER_CACHE,
|
||||
USER_CONFIG,
|
||||
USER_DATA,
|
||||
THUMB_DIR,
|
||||
USER_CSS,
|
||||
)
|
||||
from gramps.gen.utils.cast import get_type_converter
|
||||
from gramps.gen.const import GRAMPS_LOCALE as glocale
|
||||
|
||||
_ = glocale.translation.gettext
|
||||
|
||||
_HELP = _("""
|
||||
_HELP = _(
|
||||
"""
|
||||
Usage: gramps [OPTION...]
|
||||
--load-modules=MODULE1,MODULE2,... Dynamic modules to load
|
||||
|
||||
@@ -91,9 +101,11 @@ Application options
|
||||
X - Books are cleared, reports and tool settings to default
|
||||
F - filters are cleared
|
||||
E - Everything is set to default or cleared
|
||||
""")
|
||||
"""
|
||||
)
|
||||
|
||||
_USAGE = _("""
|
||||
_USAGE = _(
|
||||
"""
|
||||
Example of usage of Gramps command line interface
|
||||
|
||||
1. To import four databases (whose formats can be determined from their names)
|
||||
@@ -136,11 +148,13 @@ gramps
|
||||
|
||||
Note: These examples are for bash shell.
|
||||
Syntax may be different for other shells and for Windows.
|
||||
""")
|
||||
"""
|
||||
)
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
|
||||
# -------------------------------------------------------------------------
|
||||
# ArgParser
|
||||
#-------------------------------------------------------------------------
|
||||
# -------------------------------------------------------------------------
|
||||
class ArgParser:
|
||||
"""
|
||||
This class is responsible for parsing the command line arguments (if any)
|
||||
@@ -231,9 +245,9 @@ class ArgParser:
|
||||
self.errors = []
|
||||
self.parse_args()
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
# -------------------------------------------------------------------------
|
||||
# Argument parser: sorts out given arguments
|
||||
#-------------------------------------------------------------------------
|
||||
# -------------------------------------------------------------------------
|
||||
def parse_args(self):
|
||||
"""
|
||||
Fill in lists with open, exports, imports, and actions options.
|
||||
@@ -241,14 +255,13 @@ class ArgParser:
|
||||
Any errors are added to self.errors
|
||||
"""
|
||||
try:
|
||||
options, leftargs = getopt.getopt(self.args[1:],
|
||||
SHORTOPTS, LONGOPTS)
|
||||
options, leftargs = getopt.getopt(self.args[1:], SHORTOPTS, LONGOPTS)
|
||||
except getopt.GetoptError as getopt_error:
|
||||
self.errors.append(
|
||||
self.construct_error(
|
||||
"Type gramps --help for an overview of "
|
||||
"commands, or read the manual pages.",
|
||||
error=getopt_error
|
||||
error=getopt_error,
|
||||
)
|
||||
)
|
||||
|
||||
@@ -257,7 +270,7 @@ class ArgParser:
|
||||
# Some args can work on a list of databases:
|
||||
if leftargs:
|
||||
for option, value in options:
|
||||
if option in ['-L', '-l', '-t']:
|
||||
if option in ["-L", "-l", "-t"]:
|
||||
self.database_names = leftargs
|
||||
leftargs = []
|
||||
|
||||
@@ -265,12 +278,10 @@ class ArgParser:
|
||||
# if there were an argument without option,
|
||||
# use it as a file to open and return
|
||||
self.open_gui = leftargs[0]
|
||||
print(_("Trying to open: %s ..."
|
||||
) % leftargs[0],
|
||||
file=sys.stderr)
|
||||
#see if force open is on
|
||||
print(_("Trying to open: %s ...") % leftargs[0], file=sys.stderr)
|
||||
# see if force open is on
|
||||
for option, value in options:
|
||||
if option in ('-u', '--force-unlock'):
|
||||
if option in ("-u", "--force-unlock"):
|
||||
self.force_unlock = True
|
||||
break
|
||||
return
|
||||
@@ -279,77 +290,81 @@ class ArgParser:
|
||||
cleandbg = []
|
||||
need_to_quit = False
|
||||
for opt_ix, (option, value) in enumerate(options):
|
||||
if option in ['-O', '--open']:
|
||||
if option in ["-O", "--open"]:
|
||||
self.open = value
|
||||
elif option in ['-C', '--create']:
|
||||
elif option in ["-C", "--create"]:
|
||||
self.create = value
|
||||
elif option in ['-U', '--username']:
|
||||
elif option in ["-U", "--username"]:
|
||||
self.username = value
|
||||
elif option in ['-P', '--password']:
|
||||
elif option in ["-P", "--password"]:
|
||||
self.password = value
|
||||
elif option in ['-i', '--import']:
|
||||
elif option in ["-i", "--import"]:
|
||||
family_tree_format = None
|
||||
if (opt_ix < len(options) - 1
|
||||
and options[opt_ix + 1][0] in ('-f', '--format')):
|
||||
if opt_ix < len(options) - 1 and options[opt_ix + 1][0] in (
|
||||
"-f",
|
||||
"--format",
|
||||
):
|
||||
family_tree_format = options[opt_ix + 1][1]
|
||||
self.imports.append((value, family_tree_format))
|
||||
elif option in ['-r', '--remove']:
|
||||
elif option in ["-r", "--remove"]:
|
||||
self.removes.append(value)
|
||||
elif option in ['-e', '--export']:
|
||||
elif option in ["-e", "--export"]:
|
||||
family_tree_format = None
|
||||
if (opt_ix < len(options) - 1
|
||||
and options[opt_ix + 1][0] in ('-f', '--format')):
|
||||
if opt_ix < len(options) - 1 and options[opt_ix + 1][0] in (
|
||||
"-f",
|
||||
"--format",
|
||||
):
|
||||
family_tree_format = options[opt_ix + 1][1]
|
||||
abs_name = os.path.abspath(os.path.expanduser(value))
|
||||
if not os.path.exists(abs_name):
|
||||
# The file doesn't exists, try to create it.
|
||||
try:
|
||||
open(abs_name, 'w').close()
|
||||
open(abs_name, "w").close()
|
||||
os.unlink(abs_name)
|
||||
except OSError as e:
|
||||
message = _("WARNING: %(strerr)s "
|
||||
"(errno=%(errno)s):\n"
|
||||
"WARNING: %(name)s\n") % {
|
||||
'strerr' : e.strerror,
|
||||
'errno' : e.errno,
|
||||
'name' : e.filename}
|
||||
message = _(
|
||||
"WARNING: %(strerr)s "
|
||||
"(errno=%(errno)s):\n"
|
||||
"WARNING: %(name)s\n"
|
||||
) % {"strerr": e.strerror, "errno": e.errno, "name": e.filename}
|
||||
print(message)
|
||||
sys.exit(1)
|
||||
self.exports.append((value, family_tree_format))
|
||||
elif option in ['-a', '--action']:
|
||||
elif option in ["-a", "--action"]:
|
||||
action = value
|
||||
if action not in ('report', 'tool', 'book'):
|
||||
print(_("Unknown action: %s. Ignoring."
|
||||
) % action,
|
||||
file=sys.stderr)
|
||||
if action not in ("report", "tool", "book"):
|
||||
print(_("Unknown action: %s. Ignoring.") % action, file=sys.stderr)
|
||||
continue
|
||||
options_str = ""
|
||||
if (opt_ix < len(options)-1
|
||||
and options[opt_ix+1][0] in ('-p', '--options')):
|
||||
options_str = options[opt_ix+1][1]
|
||||
if opt_ix < len(options) - 1 and options[opt_ix + 1][0] in (
|
||||
"-p",
|
||||
"--options",
|
||||
):
|
||||
options_str = options[opt_ix + 1][1]
|
||||
self.actions.append((action, options_str))
|
||||
elif option in ['-d', '--debug']:
|
||||
print(_('setup debugging'), value, file=sys.stderr)
|
||||
elif option in ["-d", "--debug"]:
|
||||
print(_("setup debugging"), value, file=sys.stderr)
|
||||
logger = logging.getLogger(value)
|
||||
logger.setLevel(logging.DEBUG)
|
||||
cleandbg += [opt_ix]
|
||||
elif option in ['-l']:
|
||||
elif option in ["-l"]:
|
||||
self.list = True
|
||||
elif option in ['-L']:
|
||||
elif option in ["-L"]:
|
||||
self.list_more = True
|
||||
elif option in ['-t']:
|
||||
elif option in ["-t"]:
|
||||
self.list_table = True
|
||||
elif option in ['-s', '--show']:
|
||||
elif option in ["-s", "--show"]:
|
||||
from gramps.gen.config import config
|
||||
print(_("Gramps config settings from %s:"
|
||||
) % config.filename)
|
||||
|
||||
print(_("Gramps config settings from %s:") % config.filename)
|
||||
for sect, settings in config.data.items():
|
||||
for settings_index, setting in settings.items():
|
||||
print("%s.%s=%s" % (sect, settings_index, repr(value)))
|
||||
print()
|
||||
sys.exit(0)
|
||||
elif option in ['-c', '--config']:
|
||||
elif option in ["-c", "--config"]:
|
||||
from gramps.gen.config import config
|
||||
|
||||
cfg_name = value
|
||||
set_value = False
|
||||
if cfg_name:
|
||||
@@ -358,11 +373,11 @@ class ArgParser:
|
||||
set_value = True
|
||||
if config.has_default(cfg_name):
|
||||
setting_value = config.get(cfg_name)
|
||||
print(_("Current Gramps config setting: "
|
||||
"%(name)s:%(value)s"
|
||||
) % {'name' : cfg_name,
|
||||
'value' : repr(setting_value)},
|
||||
file=sys.stderr)
|
||||
print(
|
||||
_("Current Gramps config setting: " "%(name)s:%(value)s")
|
||||
% {"name": cfg_name, "value": repr(setting_value)},
|
||||
file=sys.stderr,
|
||||
)
|
||||
if set_value:
|
||||
# does a user want the default config value?
|
||||
if new_value in ("DEFAULT", _("DEFAULT")):
|
||||
@@ -372,81 +387,90 @@ class ArgParser:
|
||||
new_value = converter(new_value)
|
||||
config.set(cfg_name, new_value)
|
||||
# Translators: indent "New" to match "Current"
|
||||
print(_(" New Gramps config setting: "
|
||||
print(
|
||||
_(
|
||||
" New Gramps config setting: "
|
||||
"%(name)s:%(value)s"
|
||||
) % {'name' : cfg_name,
|
||||
'value' : repr(config.get(cfg_name))},
|
||||
file=sys.stderr)
|
||||
)
|
||||
% {
|
||||
"name": cfg_name,
|
||||
"value": repr(config.get(cfg_name)),
|
||||
},
|
||||
file=sys.stderr,
|
||||
)
|
||||
else:
|
||||
need_to_quit = True
|
||||
else:
|
||||
print(_("Gramps: no such config setting: '%s'"
|
||||
) % cfg_name,
|
||||
file=sys.stderr)
|
||||
print(
|
||||
_("Gramps: no such config setting: '%s'") % cfg_name,
|
||||
file=sys.stderr,
|
||||
)
|
||||
need_to_quit = True
|
||||
cleandbg += [opt_ix]
|
||||
elif option in ['-h', '-?', '--help']:
|
||||
elif option in ["-h", "-?", "--help"]:
|
||||
self.help = True
|
||||
elif option in ['-u', '--force-unlock']:
|
||||
elif option in ["-u", "--force-unlock"]:
|
||||
self.force_unlock = True
|
||||
elif option in ['--usage']:
|
||||
elif option in ["--usage"]:
|
||||
self.usage = True
|
||||
elif option in ['-y', '--yes']:
|
||||
elif option in ["-y", "--yes"]:
|
||||
self.auto_accept = True
|
||||
elif option in ['-q', '--quiet']:
|
||||
elif option in ["-q", "--quiet"]:
|
||||
self.quiet = True
|
||||
elif option in ['-S', '--safe']:
|
||||
elif option in ["-S", "--safe"]:
|
||||
cleandbg += [opt_ix]
|
||||
elif option in ['-D', '--default']:
|
||||
elif option in ["-D", "--default"]:
|
||||
|
||||
def rmtree(path):
|
||||
if os.path.isdir(path):
|
||||
shutil.rmtree(path, ignore_errors=True)
|
||||
|
||||
if 'E' in value or 'A' in value: # clear addons
|
||||
if "E" in value or "A" in value: # clear addons
|
||||
rmtree(USER_PLUGINS)
|
||||
if 'E' in value or 'P' in value: # clear ini preferences
|
||||
if "E" in value or "P" in value: # clear ini preferences
|
||||
for fil in glob(os.path.join(VERSION_DIR, "*.*")):
|
||||
if "custom_filters.xml" in fil:
|
||||
continue
|
||||
os.remove(fil)
|
||||
# create gramps.ini so config won't load the one from an
|
||||
# older version of Gramps.
|
||||
with open(os.path.join(VERSION_DIR, 'gramps.ini'), 'w'):
|
||||
with open(os.path.join(VERSION_DIR, "gramps.ini"), "w"):
|
||||
pass
|
||||
if 'E' in value or 'F' in value: # clear filters
|
||||
if "E" in value or "F" in value: # clear filters
|
||||
fil = os.path.join(VERSION_DIR, "custom_filters.xml")
|
||||
if os.path.isfile(fil):
|
||||
os.remove(fil)
|
||||
if 'E' in value or 'X' in value: # clear xml reports/tools
|
||||
if "E" in value or "X" in value: # clear xml reports/tools
|
||||
for fil in glob(os.path.join(USER_DATA, "*.xml")):
|
||||
os.remove(fil)
|
||||
if 'E' in value or 'Z' in value: # clear upgrade zips
|
||||
if "E" in value or "Z" in value: # clear upgrade zips
|
||||
for fil in glob(os.path.join(USER_DATA, "*.zip")):
|
||||
os.remove(fil)
|
||||
if 'E' in value: # Everything else
|
||||
if "E" in value: # Everything else
|
||||
rmtree(THUMB_DIR)
|
||||
rmtree(USER_CSS)
|
||||
rmtree(os.path.join(USER_CACHE, "maps"))
|
||||
for fil in (glob(os.path.join(USER_CACHE, "*"))
|
||||
+ glob(os.path.join(USER_CONFIG, "*"))
|
||||
+ glob(os.path.join(USER_DATA, "*"))):
|
||||
for fil in (
|
||||
glob(os.path.join(USER_CACHE, "*"))
|
||||
+ glob(os.path.join(USER_CONFIG, "*"))
|
||||
+ glob(os.path.join(USER_DATA, "*"))
|
||||
):
|
||||
if os.path.isfile(fil):
|
||||
os.remove(fil)
|
||||
sys.exit(0) # Done with Default
|
||||
|
||||
#clean options list
|
||||
# clean options list
|
||||
cleandbg.reverse()
|
||||
for ind in cleandbg:
|
||||
del options[ind]
|
||||
|
||||
if (len(options) > 0
|
||||
and self.open is None
|
||||
and self.imports == []
|
||||
and self.removes == []
|
||||
and not (self.list
|
||||
or self.list_more
|
||||
or self.list_table
|
||||
or self.help)):
|
||||
if (
|
||||
len(options) > 0
|
||||
and self.open is None
|
||||
and self.imports == []
|
||||
and self.removes == []
|
||||
and not (self.list or self.list_more or self.list_table or self.help)
|
||||
):
|
||||
self.errors.append(
|
||||
self.construct_error(
|
||||
"To use in the command-line mode, supply at "
|
||||
@@ -469,20 +493,19 @@ class ArgParser:
|
||||
translated_message = _(error_message + suggestion_message) % cli_args
|
||||
|
||||
if error:
|
||||
translated_message = str(error) + '\n' + translated_message
|
||||
translated_message = str(error) + "\n" + translated_message
|
||||
|
||||
return _('Error parsing the arguments'), translated_message
|
||||
return _("Error parsing the arguments"), translated_message
|
||||
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
# -------------------------------------------------------------------------
|
||||
# Determine the need for GUI
|
||||
#-------------------------------------------------------------------------
|
||||
# -------------------------------------------------------------------------
|
||||
def need_gui(self):
|
||||
"""
|
||||
Determine whether we need a GUI session for the given tasks.
|
||||
"""
|
||||
if self.errors:
|
||||
#errors in argument parsing ==> give cli error, no gui needed
|
||||
# errors in argument parsing ==> give cli error, no gui needed
|
||||
return False
|
||||
|
||||
if len(self.removes) > 0:
|
||||
@@ -501,9 +524,9 @@ class ArgParser:
|
||||
# have both data and what to do with it => no GUI
|
||||
return False
|
||||
elif self.create:
|
||||
if self.open: # create an empty DB, open a GUI to fill it
|
||||
if self.open: # create an empty DB, open a GUI to fill it
|
||||
return True
|
||||
else: # create a DB, then do the import, with no GUI
|
||||
else: # create a DB, then do the import, with no GUI
|
||||
self.open = self.create
|
||||
return False
|
||||
else:
|
||||
|
||||
@@ -25,11 +25,11 @@ Provide the management of databases from CLI. This includes opening, renaming,
|
||||
creating, and deleting of databases.
|
||||
"""
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
# -------------------------------------------------------------------------
|
||||
#
|
||||
# Standard python modules
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
# -------------------------------------------------------------------------
|
||||
import re
|
||||
import os
|
||||
import sys
|
||||
@@ -40,61 +40,66 @@ from urllib.request import urlopen, url2pathname
|
||||
import tempfile
|
||||
import logging
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
# -------------------------------------------------------------------------
|
||||
#
|
||||
# gramps modules
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
# -------------------------------------------------------------------------
|
||||
from gramps.gen.plug import BasePluginManager
|
||||
from gramps.gen.config import config
|
||||
from gramps.gen.constfunc import win
|
||||
from gramps.gen.db.dbconst import DBLOGNAME, DBBACKEND
|
||||
from gramps.gen.db.utils import make_database, get_dbid_from_path
|
||||
from gramps.gen.const import GRAMPS_LOCALE as glocale
|
||||
|
||||
_ = glocale.translation.gettext
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
# -------------------------------------------------------------------------
|
||||
#
|
||||
# set up logging
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
# -------------------------------------------------------------------------
|
||||
LOG = logging.getLogger(".clidbman")
|
||||
_LOG = logging.getLogger(DBLOGNAME)
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
# -------------------------------------------------------------------------
|
||||
#
|
||||
# constants
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
# -------------------------------------------------------------------------
|
||||
DEFAULT_TITLE = _("Family Tree")
|
||||
NAME_FILE = "name.txt"
|
||||
META_NAME = "meta_data.db"
|
||||
UNAVAILABLE = _('Unavailable')
|
||||
UNAVAILABLE = _("Unavailable")
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
|
||||
# -------------------------------------------------------------------------
|
||||
#
|
||||
# functions
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
# -------------------------------------------------------------------------
|
||||
def _errordialog(title, errormessage):
|
||||
"""
|
||||
Show the error. A title for the error and an errormessage
|
||||
"""
|
||||
print(_('ERROR: %(title)s \n %(message)s') % {
|
||||
'title': title,
|
||||
'message': errormessage})
|
||||
print(
|
||||
_("ERROR: %(title)s \n %(message)s")
|
||||
% {"title": title, "message": errormessage}
|
||||
)
|
||||
sys.exit()
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
|
||||
# -------------------------------------------------------------------------
|
||||
#
|
||||
# CLIDbManager
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
# -------------------------------------------------------------------------
|
||||
class CLIDbManager:
|
||||
"""
|
||||
Database manager without GTK functionality, allows users to create and
|
||||
open databases
|
||||
"""
|
||||
|
||||
IND_NAME = 0
|
||||
IND_PATH = 1
|
||||
IND_PATH_NAMEFILE = 2
|
||||
@@ -109,13 +114,14 @@ class CLIDbManager:
|
||||
ICON_OPEN = 3
|
||||
|
||||
ICON_MAP = {
|
||||
ICON_NONE : None,
|
||||
ICON_RECOVERY : None,
|
||||
ICON_LOCK : None,
|
||||
ICON_OPEN : None,
|
||||
}
|
||||
ICON_NONE: None,
|
||||
ICON_RECOVERY: None,
|
||||
ICON_LOCK: None,
|
||||
ICON_OPEN: None,
|
||||
}
|
||||
|
||||
ERROR = _errordialog
|
||||
|
||||
def __init__(self, dbstate):
|
||||
self.dbstate = dbstate
|
||||
self.msg = None
|
||||
@@ -166,12 +172,15 @@ class CLIDbManager:
|
||||
retval = {_("Unavailable"): str(msg)[:74] + "..."}
|
||||
else:
|
||||
retval = {_("Unavailable"): "locked"}
|
||||
retval.update({_("Family Tree"): name,
|
||||
_("Path"): dirpath,
|
||||
_("Database"): self.get_backend_name_from_dbid(dbid),
|
||||
_("Last accessed"): time_val(dirpath)[1],
|
||||
_("Locked?"): self.is_locked(dirpath),
|
||||
})
|
||||
retval.update(
|
||||
{
|
||||
_("Family Tree"): name,
|
||||
_("Path"): dirpath,
|
||||
_("Database"): self.get_backend_name_from_dbid(dbid),
|
||||
_("Last accessed"): time_val(dirpath)[1],
|
||||
_("Locked?"): self.is_locked(dirpath),
|
||||
}
|
||||
)
|
||||
return retval
|
||||
|
||||
def get_backend_name_from_dbid(self, dbid):
|
||||
@@ -185,22 +194,34 @@ class CLIDbManager:
|
||||
"""
|
||||
Prints a detailed list of the known family trees.
|
||||
"""
|
||||
print(_('Gramps Family Trees:'))
|
||||
print(_("Gramps Family Trees:"))
|
||||
for item in self.current_names:
|
||||
(name, dirpath, path_name, last,
|
||||
tval, enable, stock_id, backend_type) = item
|
||||
if (database_names is None or
|
||||
any([(re.match("^" + dbname + "$", name) or
|
||||
dbname == name)
|
||||
for dbname in database_names])):
|
||||
(
|
||||
name,
|
||||
dirpath,
|
||||
path_name,
|
||||
last,
|
||||
tval,
|
||||
enable,
|
||||
stock_id,
|
||||
backend_type,
|
||||
) = item
|
||||
if database_names is None or any(
|
||||
[
|
||||
(re.match("^" + dbname + "$", name) or dbname == name)
|
||||
for dbname in database_names
|
||||
]
|
||||
):
|
||||
summary = self.get_dbdir_summary(dirpath, name)
|
||||
print(_('Family Tree "%s":') % summary[_("Family Tree")])
|
||||
for item in sorted(summary):
|
||||
if item != "Family Tree":
|
||||
# Translators: needed for French, ignore otherwise
|
||||
print(' ' + _("%(str1)s: %(str2)s"
|
||||
) % {'str1' : item,
|
||||
'str2' : summary[item]})
|
||||
print(
|
||||
" "
|
||||
+ _("%(str1)s: %(str2)s")
|
||||
% {"str1": item, "str2": summary[item]}
|
||||
)
|
||||
|
||||
def family_tree_summary(self, database_names=None):
|
||||
"""
|
||||
@@ -209,12 +230,22 @@ class CLIDbManager:
|
||||
# make the default directory if it does not exist
|
||||
summary_list = []
|
||||
for item in self.current_names:
|
||||
(name, dirpath, path_name, last,
|
||||
tval, enable, stock_id, backend_type) = item
|
||||
if (database_names is None or
|
||||
any([(re.match("^" + dbname + "$", name) or
|
||||
dbname == name)
|
||||
for dbname in database_names])):
|
||||
(
|
||||
name,
|
||||
dirpath,
|
||||
path_name,
|
||||
last,
|
||||
tval,
|
||||
enable,
|
||||
stock_id,
|
||||
backend_type,
|
||||
) = item
|
||||
if database_names is None or any(
|
||||
[
|
||||
(re.match("^" + dbname + "$", name) or dbname == name)
|
||||
for dbname in database_names
|
||||
]
|
||||
):
|
||||
retval = self.get_dbdir_summary(dirpath, name)
|
||||
summary_list.append(retval)
|
||||
return summary_list
|
||||
@@ -224,7 +255,7 @@ class CLIDbManager:
|
||||
Get the list of current names in the database dir
|
||||
"""
|
||||
# make the default directory if it does not exist
|
||||
dbdir = os.path.expanduser(config.get('database.path'))
|
||||
dbdir = os.path.expanduser(config.get("database.path"))
|
||||
db_ok = make_dbdir(dbdir)
|
||||
|
||||
self.current_names = []
|
||||
@@ -234,19 +265,29 @@ class CLIDbManager:
|
||||
path_name = os.path.join(dirpath, NAME_FILE)
|
||||
backend_type = get_dbid_from_path(dirpath)
|
||||
if os.path.isfile(path_name):
|
||||
with open(path_name, 'r', encoding='utf8') as file:
|
||||
with open(path_name, "r", encoding="utf8") as file:
|
||||
name = file.readline().strip()
|
||||
|
||||
(tval, last) = time_val(dirpath)
|
||||
(enable, stock_id) = self.icon_values(
|
||||
dirpath, self.active, self.dbstate.is_open())
|
||||
dirpath, self.active, self.dbstate.is_open()
|
||||
)
|
||||
|
||||
if stock_id == 'gramps-lock':
|
||||
if stock_id == "gramps-lock":
|
||||
last = find_locker_name(dirpath)
|
||||
|
||||
self.current_names.append(
|
||||
(name, os.path.join(dbdir, dpath), path_name,
|
||||
last, tval, enable, stock_id, backend_type))
|
||||
(
|
||||
name,
|
||||
os.path.join(dbdir, dpath),
|
||||
path_name,
|
||||
last,
|
||||
tval,
|
||||
enable,
|
||||
stock_id,
|
||||
backend_type,
|
||||
)
|
||||
)
|
||||
|
||||
self.current_names.sort()
|
||||
|
||||
@@ -271,13 +312,13 @@ class CLIDbManager:
|
||||
"""
|
||||
Do needed things to start import visually, eg busy cursor
|
||||
"""
|
||||
print(_('Starting Import, %s') % msg)
|
||||
print(_("Starting Import, %s") % msg)
|
||||
|
||||
def __end_cursor(self):
|
||||
"""
|
||||
Set end of a busy cursor
|
||||
"""
|
||||
print(_('Import finished...'))
|
||||
print(_("Import finished..."))
|
||||
|
||||
def create_new_db_cli(self, title=None, create_db=True, dbid=None):
|
||||
"""
|
||||
@@ -292,22 +333,23 @@ class CLIDbManager:
|
||||
name_list = [name[0] for name in self.current_names]
|
||||
title = find_next_db_name(name_list)
|
||||
|
||||
with open(path_name, "w", encoding='utf8') as name_file:
|
||||
with open(path_name, "w", encoding="utf8") as name_file:
|
||||
name_file.write(title)
|
||||
|
||||
if create_db:
|
||||
if dbid is None:
|
||||
dbid = config.get('database.backend')
|
||||
dbid = config.get("database.backend")
|
||||
newdb = make_database(dbid)
|
||||
|
||||
backend_path = os.path.join(new_path, DBBACKEND)
|
||||
with open(backend_path, "w", encoding='utf8') as backend_file:
|
||||
with open(backend_path, "w", encoding="utf8") as backend_file:
|
||||
backend_file.write(dbid)
|
||||
|
||||
(tval, last) = time_val(new_path)
|
||||
|
||||
self.current_names.append((title, new_path, path_name,
|
||||
last, tval, False, "", dbid))
|
||||
self.current_names.append(
|
||||
(title, new_path, path_name, last, tval, False, "", dbid)
|
||||
)
|
||||
return new_path, title
|
||||
|
||||
def _create_new_db(self, title=None, dbid=None, edit_entry=False):
|
||||
@@ -340,7 +382,7 @@ class CLIDbManager:
|
||||
if url.scheme == "file":
|
||||
filename = url2pathname(filename[7:])
|
||||
else:
|
||||
url_fp = urlopen(filename) # open URL
|
||||
url_fp = urlopen(filename) # open URL
|
||||
# make a temp local file:
|
||||
ext = os.path.splitext(url.path)[1]
|
||||
fd, filename = tempfile.mkstemp(suffix=ext)
|
||||
@@ -357,10 +399,8 @@ class CLIDbManager:
|
||||
|
||||
for plugin in pmgr.get_import_plugins():
|
||||
if format == plugin.get_extension():
|
||||
|
||||
dbid = config.get('database.backend')
|
||||
new_path, name = self._create_new_db(name, dbid=dbid,
|
||||
edit_entry=False)
|
||||
dbid = config.get("database.backend")
|
||||
new_path, name = self._create_new_db(name, dbid=dbid, edit_entry=False)
|
||||
|
||||
# Create a new database
|
||||
self.__start_cursor(_("Importing data..."))
|
||||
@@ -406,35 +446,37 @@ class CLIDbManager:
|
||||
Deletes a database folder given a pattenr that matches
|
||||
its proper name.
|
||||
"""
|
||||
dbdir = os.path.expanduser(config.get('database.path'))
|
||||
dbdir = os.path.expanduser(config.get("database.path"))
|
||||
match_list = []
|
||||
for dpath in os.listdir(dbdir):
|
||||
dirpath = os.path.join(dbdir, dpath)
|
||||
path_name = os.path.join(dirpath, NAME_FILE)
|
||||
if os.path.isfile(path_name):
|
||||
with open(path_name, 'r', encoding='utf8') as file:
|
||||
with open(path_name, "r", encoding="utf8") as file:
|
||||
name = file.readline().strip()
|
||||
if re.match("^" + dbname + "$", name) or dbname == name:
|
||||
match_list.append((name, dirpath))
|
||||
if len(match_list) == 0:
|
||||
CLIDbManager.ERROR("Family tree not found",
|
||||
"No matching family tree found: '%s'" % dbname)
|
||||
CLIDbManager.ERROR(
|
||||
"Family tree not found", "No matching family tree found: '%s'" % dbname
|
||||
)
|
||||
# now delete them:
|
||||
for (name, directory) in match_list:
|
||||
for name, directory in match_list:
|
||||
if user is None or user.prompt(
|
||||
_('Remove family tree warning'),
|
||||
_('Are you sure you want to remove '
|
||||
'the family tree named\n"%s"?'
|
||||
) % name,
|
||||
_('yes'), _('no'), default_label=_('no')):
|
||||
_("Remove family tree warning"),
|
||||
_("Are you sure you want to remove " 'the family tree named\n"%s"?')
|
||||
% name,
|
||||
_("yes"),
|
||||
_("no"),
|
||||
default_label=_("no"),
|
||||
):
|
||||
try:
|
||||
for (top, dirs, files) in os.walk(directory):
|
||||
for top, dirs, files in os.walk(directory):
|
||||
for filename in files:
|
||||
os.unlink(os.path.join(top, filename))
|
||||
os.rmdir(directory)
|
||||
except (IOError, OSError) as msg:
|
||||
CLIDbManager.ERROR(_("Could not delete Family Tree"),
|
||||
str(msg))
|
||||
CLIDbManager.ERROR(_("Could not delete Family Tree"), str(msg))
|
||||
|
||||
def rename_database(self, filepath, new_text):
|
||||
"""
|
||||
@@ -442,9 +484,9 @@ class CLIDbManager:
|
||||
Returns old_name, new_name if success, None, None if no success
|
||||
"""
|
||||
try:
|
||||
with open(filepath, "r", encoding='utf8') as name_file:
|
||||
with open(filepath, "r", encoding="utf8") as name_file:
|
||||
old_text = name_file.read()
|
||||
with open(filepath, "w", encoding='utf8') as name_file:
|
||||
with open(filepath, "w", encoding="utf8") as name_file:
|
||||
name_file.write(new_text)
|
||||
except (OSError, IOError) as msg:
|
||||
CLIDbManager.ERROR(_("Could not rename Family Tree"), str(msg))
|
||||
@@ -472,6 +514,7 @@ class CLIDbManager:
|
||||
else:
|
||||
return (False, self.ICON_MAP[self.ICON_NONE])
|
||||
|
||||
|
||||
def make_dbdir(dbdir):
|
||||
"""
|
||||
Create the default database directory, as defined by dbdir
|
||||
@@ -480,13 +523,18 @@ def make_dbdir(dbdir):
|
||||
if not os.path.isdir(dbdir):
|
||||
os.makedirs(dbdir)
|
||||
except (IOError, OSError) as msg:
|
||||
LOG.error(_("\nERROR: Wrong database path in Edit Menu->Preferences.\n"
|
||||
"Open preferences and set correct database path.\n\n"
|
||||
"Details: Could not make database directory:\n %s\n\n"),
|
||||
str(msg))
|
||||
LOG.error(
|
||||
_(
|
||||
"\nERROR: Wrong database path in Edit Menu->Preferences.\n"
|
||||
"Open preferences and set correct database path.\n\n"
|
||||
"Details: Could not make database directory:\n %s\n\n"
|
||||
),
|
||||
str(msg),
|
||||
)
|
||||
return False
|
||||
return True
|
||||
|
||||
|
||||
def find_next_db_name(name_list):
|
||||
"""
|
||||
Scan the name list, looking for names that do not yet exist.
|
||||
@@ -499,6 +547,7 @@ def find_next_db_name(name_list):
|
||||
return title
|
||||
i += 1
|
||||
|
||||
|
||||
def find_next_db_dir():
|
||||
"""
|
||||
Searches the default directory for the first available default
|
||||
@@ -507,12 +556,13 @@ def find_next_db_dir():
|
||||
"""
|
||||
while True:
|
||||
base = "%x" % int(time.time())
|
||||
dbdir = os.path.expanduser(config.get('database.path'))
|
||||
dbdir = os.path.expanduser(config.get("database.path"))
|
||||
new_path = os.path.join(dbdir, base)
|
||||
if not os.path.isdir(new_path):
|
||||
break
|
||||
return new_path
|
||||
|
||||
|
||||
def time_val(dirpath):
|
||||
"""
|
||||
Return the last modified time of the database. We do this by looking
|
||||
@@ -529,12 +579,13 @@ def time_val(dirpath):
|
||||
tval_mod = os.stat(meta)[8]
|
||||
if tval_mod > tval:
|
||||
tval = tval_mod
|
||||
last = time.strftime('%x %X', time.localtime(tval))
|
||||
last = time.strftime("%x %X", time.localtime(tval))
|
||||
else:
|
||||
tval = 0
|
||||
last = _("Never")
|
||||
return (tval, last)
|
||||
|
||||
|
||||
def find_locker_name(dirpath):
|
||||
"""
|
||||
Opens the lock file if it exists, reads the contexts which is "USERNAME"
|
||||
@@ -545,7 +596,7 @@ def find_locker_name(dirpath):
|
||||
"""
|
||||
try:
|
||||
fname = os.path.join(dirpath, "lock")
|
||||
with open(fname, 'r', encoding='utf8') as ifile:
|
||||
with open(fname, "r", encoding="utf8") as ifile:
|
||||
username = ifile.read().strip()
|
||||
# feature request 2356: avoid genitive form
|
||||
last = _("Locked by %s") % username
|
||||
|
||||
@@ -26,12 +26,13 @@ execution of Gramps.
|
||||
Provides also two small base classes: :class:`CLIDbLoader`, :class:`CLIManager`
|
||||
"""
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
# -------------------------------------------------------------------------
|
||||
#
|
||||
# Python modules
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
# -------------------------------------------------------------------------
|
||||
from gramps.gen.const import GRAMPS_LOCALE as glocale
|
||||
|
||||
_ = glocale.translation.gettext
|
||||
import os
|
||||
import sys
|
||||
@@ -39,11 +40,11 @@ import sys
|
||||
import logging
|
||||
|
||||
LOG = logging.getLogger(".grampscli")
|
||||
#-------------------------------------------------------------------------
|
||||
# -------------------------------------------------------------------------
|
||||
#
|
||||
# Gramps modules
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
# -------------------------------------------------------------------------
|
||||
from gramps.gen.display.name import displayer as name_displayer
|
||||
from gramps.gen.config import config
|
||||
from gramps.gen.const import PLUGINS_DIR, USER_PLUGINS
|
||||
@@ -51,26 +52,30 @@ from gramps.gen.db.dbconst import DBBACKEND
|
||||
from gramps.gen.db.utils import make_database
|
||||
from gramps.gen.errors import DbError
|
||||
from gramps.gen.dbstate import DbState
|
||||
from gramps.gen.db.exceptions import (DbUpgradeRequiredError,
|
||||
DbSupportedError,
|
||||
DbVersionError,
|
||||
DbPythonError,
|
||||
DbConnectionError)
|
||||
from gramps.gen.db.exceptions import (
|
||||
DbUpgradeRequiredError,
|
||||
DbSupportedError,
|
||||
DbVersionError,
|
||||
DbPythonError,
|
||||
DbConnectionError,
|
||||
)
|
||||
from gramps.gen.plug import BasePluginManager
|
||||
from gramps.gen.utils.config import get_researcher
|
||||
from gramps.gen.recentfiles import recent_files
|
||||
from gramps.gen.filters import reload_custom_filters
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
|
||||
# -------------------------------------------------------------------------
|
||||
#
|
||||
# CLI DbLoader class
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
# -------------------------------------------------------------------------
|
||||
class CLIDbLoader:
|
||||
"""
|
||||
Base class for Db loading action inside a :class:`.DbState`. Only the
|
||||
minimum is present needed for CLI handling
|
||||
"""
|
||||
|
||||
def __init__(self, dbstate):
|
||||
self.dbstate = dbstate
|
||||
|
||||
@@ -78,14 +83,14 @@ class CLIDbLoader:
|
||||
"""
|
||||
Issue a warning message. Inherit for GUI action
|
||||
"""
|
||||
print(_('WARNING: %s') % warnmessage, file=sys.stderr)
|
||||
print(_("WARNING: %s") % warnmessage, file=sys.stderr)
|
||||
|
||||
def _errordialog(self, title, errormessage):
|
||||
"""
|
||||
Show the error. A title for the error and an errormessage
|
||||
Inherit for GUI action
|
||||
"""
|
||||
print(_('ERROR: %s') % errormessage, file=sys.stderr)
|
||||
print(_("ERROR: %s") % errormessage, file=sys.stderr)
|
||||
sys.exit(1)
|
||||
|
||||
def _dberrordialog(self, msg):
|
||||
@@ -98,14 +103,18 @@ class CLIDbLoader:
|
||||
.. note:: Inherit for GUI action
|
||||
"""
|
||||
self._errordialog(
|
||||
'',
|
||||
"",
|
||||
_("Low level database corruption detected")
|
||||
+ '\n' +
|
||||
_("Gramps has detected a problem in the underlying "
|
||||
"database. This can sometimes be repaired from "
|
||||
"the Family Tree Manager. Select the database and "
|
||||
'click on the Repair button'
|
||||
) + '\n\n' + str(msg))
|
||||
+ "\n"
|
||||
+ _(
|
||||
"Gramps has detected a problem in the underlying "
|
||||
"database. This can sometimes be repaired from "
|
||||
"the Family Tree Manager. Select the database and "
|
||||
"click on the Repair button"
|
||||
)
|
||||
+ "\n\n"
|
||||
+ str(msg),
|
||||
)
|
||||
|
||||
def _begin_progress(self):
|
||||
"""
|
||||
@@ -146,13 +155,14 @@ class CLIDbLoader:
|
||||
if os.path.exists(filename):
|
||||
if not os.access(filename, os.W_OK):
|
||||
mode = "r"
|
||||
self._warn(_('Read only database'),
|
||||
_('You do not have write access '
|
||||
'to the selected file.'))
|
||||
self._warn(
|
||||
_("Read only database"),
|
||||
_("You do not have write access " "to the selected file."),
|
||||
)
|
||||
else:
|
||||
mode = "w"
|
||||
else:
|
||||
mode = 'w'
|
||||
mode = "w"
|
||||
|
||||
dbid_path = os.path.join(filename, DBBACKEND)
|
||||
if os.path.isfile(dbid_path):
|
||||
@@ -169,16 +179,26 @@ class CLIDbLoader:
|
||||
self._begin_progress()
|
||||
|
||||
try:
|
||||
self.dbstate.db.load(filename, self._pulse_progress, mode,
|
||||
username=username, password=password)
|
||||
except (DbConnectionError, DbSupportedError, DbUpgradeRequiredError,
|
||||
DbVersionError, DbPythonError, DbConnectionError) as msg:
|
||||
self.dbstate.db.load(
|
||||
filename,
|
||||
self._pulse_progress,
|
||||
mode,
|
||||
username=username,
|
||||
password=password,
|
||||
)
|
||||
except (
|
||||
DbConnectionError,
|
||||
DbSupportedError,
|
||||
DbUpgradeRequiredError,
|
||||
DbVersionError,
|
||||
DbPythonError,
|
||||
DbConnectionError,
|
||||
) as msg:
|
||||
self.dbstate.no_database()
|
||||
self._errordialog(_("Cannot open database"), str(msg))
|
||||
except OSError as msg:
|
||||
self.dbstate.no_database()
|
||||
self._errordialog(
|
||||
_("Could not open file: %s") % filename, str(msg))
|
||||
self._errordialog(_("Could not open file: %s") % filename, str(msg))
|
||||
except DbError as msg:
|
||||
self.dbstate.no_database()
|
||||
self._dberrordialog(msg)
|
||||
@@ -187,11 +207,13 @@ class CLIDbLoader:
|
||||
LOG.error("Failed to open database.", exc_info=True)
|
||||
return True
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
|
||||
# -------------------------------------------------------------------------
|
||||
#
|
||||
# CLIManager class
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
# -------------------------------------------------------------------------
|
||||
|
||||
|
||||
class CLIManager:
|
||||
"""
|
||||
@@ -201,6 +223,7 @@ class CLIManager:
|
||||
Aim is to manage a dbstate on which to work (load, unload), and interact
|
||||
with the plugin session
|
||||
"""
|
||||
|
||||
def __init__(self, dbstate, setloader, user):
|
||||
self.dbstate = dbstate
|
||||
if setloader:
|
||||
@@ -221,7 +244,7 @@ class CLIManager:
|
||||
"""
|
||||
Show the error. A title for the error and an errormessage
|
||||
"""
|
||||
print(_('ERROR: %s') % errormessage, file=sys.stderr)
|
||||
print(_("ERROR: %s") % errormessage, file=sys.stderr)
|
||||
sys.exit(1)
|
||||
|
||||
def _read_recent_file(self, filename, username=None, password=None):
|
||||
@@ -232,29 +255,33 @@ class CLIManager:
|
||||
# If not, do nothing, just return.
|
||||
# This can be handled better if family tree delete/rename
|
||||
# also updated the recent file menu info in displaystate.py
|
||||
if not os.path.isdir(filename):
|
||||
if not os.path.isdir(filename):
|
||||
self._errordialog(
|
||||
_("Could not load a recent Family Tree."),
|
||||
_("Family Tree does not exist, as it has been deleted."))
|
||||
_("Family Tree does not exist, as it has been deleted."),
|
||||
)
|
||||
return
|
||||
|
||||
if os.path.isfile(os.path.join(filename, "lock")):
|
||||
self._errordialog(
|
||||
_("The database is locked."),
|
||||
_("Use the --force-unlock option if you are sure "
|
||||
"that the database is not in use."))
|
||||
_(
|
||||
"Use the --force-unlock option if you are sure "
|
||||
"that the database is not in use."
|
||||
),
|
||||
)
|
||||
return
|
||||
|
||||
if self.db_loader.read_file(filename, username, password):
|
||||
# Attempt to figure out the database title
|
||||
path = os.path.join(filename, "name.txt")
|
||||
try:
|
||||
with open(path, encoding='utf8') as ifile:
|
||||
with open(path, encoding="utf8") as ifile:
|
||||
title = ifile.readline().strip()
|
||||
except:
|
||||
title = filename
|
||||
|
||||
self._post_load_newdb(filename, 'x-directory/normal', title)
|
||||
self._post_load_newdb(filename, "x-directory/normal", title)
|
||||
|
||||
def _post_load_newdb(self, filename, filetype, title=None):
|
||||
"""
|
||||
@@ -283,20 +310,18 @@ class CLIManager:
|
||||
# If the DB Owner Info is empty and
|
||||
# [default] Researcher is not empty and
|
||||
# database is empty, then copy default researcher to DB owner
|
||||
if (res.is_empty()
|
||||
and not owner.is_empty()
|
||||
and self.dbstate.db.get_total() == 0):
|
||||
if res.is_empty() and not owner.is_empty() and self.dbstate.db.get_total() == 0:
|
||||
self.dbstate.db.set_researcher(owner)
|
||||
|
||||
name_displayer.clear_custom_formats()
|
||||
name_displayer.set_name_format(self.dbstate.db.name_formats)
|
||||
fmt_default = config.get('preferences.name-format')
|
||||
fmt_default = config.get("preferences.name-format")
|
||||
name_displayer.set_default_format(fmt_default)
|
||||
|
||||
self.dbstate.db.enable_signals()
|
||||
self.dbstate.signal_change()
|
||||
|
||||
config.set('paths.recent-file', filename)
|
||||
config.set("paths.recent-file", filename)
|
||||
|
||||
recent_files(filename, name)
|
||||
self.file_loaded = True
|
||||
@@ -310,6 +335,7 @@ class CLIManager:
|
||||
if rescan: # supports updated plugin installs
|
||||
self._pmgr.reload_plugins()
|
||||
|
||||
|
||||
def startcli(errors, argparser):
|
||||
"""
|
||||
Starts a cli session of Gramps.
|
||||
@@ -318,34 +344,35 @@ def startcli(errors, argparser):
|
||||
:param argparser: :class:`.ArgParser` instance
|
||||
"""
|
||||
if errors:
|
||||
#already errors encountered. Show first one on terminal and exit
|
||||
errmsg = _('Error encountered: %s') % errors[0][0]
|
||||
# already errors encountered. Show first one on terminal and exit
|
||||
errmsg = _("Error encountered: %s") % errors[0][0]
|
||||
print(errmsg, file=sys.stderr)
|
||||
errmsg = _(' Details: %s') % errors[0][1]
|
||||
errmsg = _(" Details: %s") % errors[0][1]
|
||||
print(errmsg, file=sys.stderr)
|
||||
sys.exit(1)
|
||||
|
||||
if argparser.errors:
|
||||
errmsg = _('Error encountered in argument parsing: %s'
|
||||
) % argparser.errors[0][0]
|
||||
errmsg = _("Error encountered in argument parsing: %s") % argparser.errors[0][0]
|
||||
print(errmsg, file=sys.stderr)
|
||||
errmsg = _(' Details: %s') % argparser.errors[0][1]
|
||||
errmsg = _(" Details: %s") % argparser.errors[0][1]
|
||||
print(errmsg, file=sys.stderr)
|
||||
sys.exit(1)
|
||||
|
||||
#we need to keep track of the db state
|
||||
# we need to keep track of the db state
|
||||
dbstate = DbState()
|
||||
|
||||
#we need a manager for the CLI session
|
||||
# we need a manager for the CLI session
|
||||
from .user import User
|
||||
|
||||
user = User(auto_accept=argparser.auto_accept, quiet=argparser.quiet)
|
||||
climanager = CLIManager(dbstate, True, user)
|
||||
|
||||
#load the plugins
|
||||
# load the plugins
|
||||
climanager.do_reg_plugins(dbstate, uistate=None)
|
||||
reload_custom_filters()
|
||||
# handle the arguments
|
||||
from .arghandler import ArgHandler
|
||||
|
||||
handler = ArgHandler(dbstate, argparser, climanager)
|
||||
# create a manager to manage the database
|
||||
|
||||
|
||||
@@ -28,50 +28,75 @@
|
||||
|
||||
""" Enable report generation from the command line interface (CLI) """
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
# -------------------------------------------------------------------------
|
||||
#
|
||||
# Python modules
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
# -------------------------------------------------------------------------
|
||||
import traceback
|
||||
import os
|
||||
import sys
|
||||
|
||||
import logging
|
||||
|
||||
LOG = logging.getLogger(".")
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
# -------------------------------------------------------------------------
|
||||
#
|
||||
# Gramps modules
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
# -------------------------------------------------------------------------
|
||||
from gramps.gen.plug import BasePluginManager
|
||||
from gramps.gen.plug.docgen import (StyleSheet, StyleSheetList, PaperStyle,
|
||||
PAPER_PORTRAIT, PAPER_LANDSCAPE, graphdoc,
|
||||
treedoc)
|
||||
from gramps.gen.plug.menu import (FamilyOption, PersonOption, NoteOption,
|
||||
MediaOption, PersonListOption, NumberOption,
|
||||
BooleanOption, DestinationOption, Option,
|
||||
TextOption, EnumeratedListOption,
|
||||
StringOption)
|
||||
from gramps.gen.plug.docgen import (
|
||||
StyleSheet,
|
||||
StyleSheetList,
|
||||
PaperStyle,
|
||||
PAPER_PORTRAIT,
|
||||
PAPER_LANDSCAPE,
|
||||
graphdoc,
|
||||
treedoc,
|
||||
)
|
||||
from gramps.gen.plug.menu import (
|
||||
FamilyOption,
|
||||
PersonOption,
|
||||
NoteOption,
|
||||
MediaOption,
|
||||
PersonListOption,
|
||||
NumberOption,
|
||||
BooleanOption,
|
||||
DestinationOption,
|
||||
Option,
|
||||
TextOption,
|
||||
EnumeratedListOption,
|
||||
StringOption,
|
||||
)
|
||||
from gramps.gen.display.name import displayer as name_displayer
|
||||
from gramps.gen.errors import ReportError, FilterError
|
||||
from gramps.gen.plug.report import (CATEGORY_TEXT, CATEGORY_DRAW, CATEGORY_BOOK,
|
||||
CATEGORY_GRAPHVIZ, CATEGORY_TREE,
|
||||
CATEGORY_CODE, ReportOptions, append_styles)
|
||||
from gramps.gen.plug.report import (
|
||||
CATEGORY_TEXT,
|
||||
CATEGORY_DRAW,
|
||||
CATEGORY_BOOK,
|
||||
CATEGORY_GRAPHVIZ,
|
||||
CATEGORY_TREE,
|
||||
CATEGORY_CODE,
|
||||
ReportOptions,
|
||||
append_styles,
|
||||
)
|
||||
from gramps.gen.plug.report._paper import paper_sizes
|
||||
from gramps.gen.const import USER_HOME, DOCGEN_OPTIONS
|
||||
from gramps.gen.dbstate import DbState
|
||||
from ..grampscli import CLIManager
|
||||
from ..user import User
|
||||
from gramps.gen.const import GRAMPS_LOCALE as glocale
|
||||
|
||||
_ = glocale.translation.gettext
|
||||
|
||||
#------------------------------------------------------------------------
|
||||
|
||||
# ------------------------------------------------------------------------
|
||||
#
|
||||
# Private Functions
|
||||
#
|
||||
#------------------------------------------------------------------------
|
||||
# ------------------------------------------------------------------------
|
||||
def _convert_str_to_match_type(str_val, type_val):
|
||||
"""
|
||||
Returns a value representing str_val that is the same type as type_val.
|
||||
@@ -80,8 +105,9 @@ def _convert_str_to_match_type(str_val, type_val):
|
||||
ret_type = type(type_val)
|
||||
|
||||
if isinstance(type_val, str):
|
||||
if ((str_val.startswith("'") and str_val.endswith("'"))
|
||||
or (str_val.startswith('"') and str_val.endswith('"'))):
|
||||
if (str_val.startswith("'") and str_val.endswith("'")) or (
|
||||
str_val.startswith('"') and str_val.endswith('"')
|
||||
):
|
||||
# Remove enclosing quotes
|
||||
return str(str_val[1:-1])
|
||||
else:
|
||||
@@ -141,6 +167,7 @@ def _convert_str_to_match_type(str_val, type_val):
|
||||
|
||||
return ret_val
|
||||
|
||||
|
||||
def _validate_options(options, dbase):
|
||||
"""
|
||||
Validate all options by making sure that their values are consistent with
|
||||
@@ -168,8 +195,7 @@ def _validate_options(options, dbase):
|
||||
phandle = None
|
||||
person = dbase.get_person_from_handle(phandle)
|
||||
if not person:
|
||||
print(_("ERROR: Please specify a person"),
|
||||
file=sys.stderr)
|
||||
print(_("ERROR: Please specify a person"), file=sys.stderr)
|
||||
if person:
|
||||
option.set_value(person.get_gramps_id())
|
||||
|
||||
@@ -195,19 +221,20 @@ def _validate_options(options, dbase):
|
||||
else:
|
||||
print(_("ERROR: Please specify a family"), file=sys.stderr)
|
||||
|
||||
#------------------------------------------------------------------------
|
||||
|
||||
# ------------------------------------------------------------------------
|
||||
#
|
||||
# Command-line report
|
||||
#
|
||||
#------------------------------------------------------------------------
|
||||
# ------------------------------------------------------------------------
|
||||
class CommandLineReport:
|
||||
"""
|
||||
Provide a way to generate report from the command line.
|
||||
"""
|
||||
|
||||
def __init__(self, database, name, category, option_class, options_str_dict,
|
||||
noopt=False):
|
||||
|
||||
def __init__(
|
||||
self, database, name, category, option_class, options_str_dict, noopt=False
|
||||
):
|
||||
pmgr = BasePluginManager.get_instance()
|
||||
self.__textdoc_plugins = []
|
||||
self.__drawdoc_plugins = []
|
||||
@@ -217,15 +244,17 @@ class CommandLineReport:
|
||||
self.__textdoc_plugins.append(plugin)
|
||||
if plugin.get_draw_support() and plugin.get_extension():
|
||||
self.__drawdoc_plugins.append(plugin)
|
||||
if (plugin.get_extension()
|
||||
and plugin.get_text_support()
|
||||
and plugin.get_draw_support()):
|
||||
if (
|
||||
plugin.get_extension()
|
||||
and plugin.get_text_support()
|
||||
and plugin.get_draw_support()
|
||||
):
|
||||
self.__bookdoc_plugins.append(plugin)
|
||||
|
||||
self.database = database
|
||||
self.category = category
|
||||
|
||||
self.options_dict = None # keep pylint happy
|
||||
self.options_dict = None # keep pylint happy
|
||||
self.options_help = None
|
||||
self.paper = None
|
||||
self.orien = None
|
||||
@@ -249,8 +278,9 @@ class CommandLineReport:
|
||||
self.__gvoptions.add_menu_options(menu)
|
||||
for name in menu.get_all_option_names():
|
||||
if name not in self.option_class.options_dict:
|
||||
self.option_class.options_dict[
|
||||
name] = menu.get_option_by_name(name).get_value()
|
||||
self.option_class.options_dict[name] = menu.get_option_by_name(
|
||||
name
|
||||
).get_value()
|
||||
if category == CATEGORY_TREE:
|
||||
# Need to include Genealogy Tree options
|
||||
self.__toptions = treedoc.TreeOptions()
|
||||
@@ -258,11 +288,12 @@ class CommandLineReport:
|
||||
self.__toptions.add_menu_options(menu)
|
||||
for name in menu.get_all_option_names():
|
||||
if name not in self.option_class.options_dict:
|
||||
self.option_class.options_dict[
|
||||
name] = menu.get_option_by_name(name).get_value()
|
||||
self.option_class.options_dict[name] = menu.get_option_by_name(
|
||||
name
|
||||
).get_value()
|
||||
self.option_class.load_previous_values()
|
||||
_validate_options(self.option_class, database)
|
||||
self.show = options_str_dict.pop('show', None)
|
||||
self.show = options_str_dict.pop("show", None)
|
||||
|
||||
self.options_str_dict = options_str_dict
|
||||
self.init_standard_options(noopt)
|
||||
@@ -276,76 +307,76 @@ class CommandLineReport:
|
||||
Initialize the options that are hard-coded into the report system.
|
||||
"""
|
||||
self.options_dict = {
|
||||
'of' : self.option_class.handler.module_name,
|
||||
'off' : self.option_class.handler.get_format_name(),
|
||||
'style' :
|
||||
self.option_class.handler.get_default_stylesheet_name(),
|
||||
'papers' : self.option_class.handler.get_paper_name(),
|
||||
'papero' : self.option_class.handler.get_orientation(),
|
||||
'paperml' : self.option_class.handler.get_margins()[0],
|
||||
'papermr' : self.option_class.handler.get_margins()[1],
|
||||
'papermt' : self.option_class.handler.get_margins()[2],
|
||||
'papermb' : self.option_class.handler.get_margins()[3],
|
||||
'css' : self.option_class.handler.get_css_filename(),
|
||||
}
|
||||
"of": self.option_class.handler.module_name,
|
||||
"off": self.option_class.handler.get_format_name(),
|
||||
"style": self.option_class.handler.get_default_stylesheet_name(),
|
||||
"papers": self.option_class.handler.get_paper_name(),
|
||||
"papero": self.option_class.handler.get_orientation(),
|
||||
"paperml": self.option_class.handler.get_margins()[0],
|
||||
"papermr": self.option_class.handler.get_margins()[1],
|
||||
"papermt": self.option_class.handler.get_margins()[2],
|
||||
"papermb": self.option_class.handler.get_margins()[3],
|
||||
"css": self.option_class.handler.get_css_filename(),
|
||||
}
|
||||
|
||||
self.options_help = {
|
||||
'of' : [_("=filename"),
|
||||
_("Output file name. MANDATORY"), ""],
|
||||
'off' : [_("=format"), _("Output file format."), []],
|
||||
'style' : [_("=name"), _("Style name."), ""],
|
||||
'papers' : [_("=name"), _("Paper size name."), ""],
|
||||
'papero' : [_("=number"), _("Paper orientation number."), ""],
|
||||
'paperml' : [_("=number"),
|
||||
_("Left paper margin"), _("Size in cm")],
|
||||
'papermr' : [_("=number"),
|
||||
_("Right paper margin"), _("Size in cm")],
|
||||
'papermt' : [_("=number"),
|
||||
_("Top paper margin"), _("Size in cm")],
|
||||
'papermb' : [_("=number"),
|
||||
_("Bottom paper margin"), _("Size in cm")],
|
||||
'css' : [_("=css filename"),
|
||||
_("CSS filename to use, html format only"), ""],
|
||||
}
|
||||
"of": [_("=filename"), _("Output file name. MANDATORY"), ""],
|
||||
"off": [_("=format"), _("Output file format."), []],
|
||||
"style": [_("=name"), _("Style name."), ""],
|
||||
"papers": [_("=name"), _("Paper size name."), ""],
|
||||
"papero": [_("=number"), _("Paper orientation number."), ""],
|
||||
"paperml": [_("=number"), _("Left paper margin"), _("Size in cm")],
|
||||
"papermr": [_("=number"), _("Right paper margin"), _("Size in cm")],
|
||||
"papermt": [_("=number"), _("Top paper margin"), _("Size in cm")],
|
||||
"papermb": [_("=number"), _("Bottom paper margin"), _("Size in cm")],
|
||||
"css": [_("=css filename"), _("CSS filename to use, html format only"), ""],
|
||||
}
|
||||
|
||||
if noopt:
|
||||
return
|
||||
|
||||
self.options_help['of'][2] = os.path.join(USER_HOME,
|
||||
"whatever_name")
|
||||
self.options_help["of"][2] = os.path.join(USER_HOME, "whatever_name")
|
||||
|
||||
if self.category == CATEGORY_TEXT:
|
||||
for plugin in self.__textdoc_plugins:
|
||||
self.options_help['off'][2].append(
|
||||
plugin.get_extension() + "\t" + plugin.get_description())
|
||||
self.options_help["off"][2].append(
|
||||
plugin.get_extension() + "\t" + plugin.get_description()
|
||||
)
|
||||
elif self.category == CATEGORY_DRAW:
|
||||
for plugin in self.__drawdoc_plugins:
|
||||
self.options_help['off'][2].append(
|
||||
plugin.get_extension() + "\t" + plugin.get_description())
|
||||
self.options_help["off"][2].append(
|
||||
plugin.get_extension() + "\t" + plugin.get_description()
|
||||
)
|
||||
elif self.category == CATEGORY_BOOK:
|
||||
for plugin in self.__bookdoc_plugins:
|
||||
self.options_help['off'][2].append(
|
||||
plugin.get_extension() + "\t" + plugin.get_description())
|
||||
self.options_help["off"][2].append(
|
||||
plugin.get_extension() + "\t" + plugin.get_description()
|
||||
)
|
||||
elif self.category == CATEGORY_GRAPHVIZ:
|
||||
for graph_format in graphdoc.FORMATS:
|
||||
self.options_help['off'][2].append(
|
||||
graph_format["type"] + "\t" + graph_format["descr"])
|
||||
self.options_help["off"][2].append(
|
||||
graph_format["type"] + "\t" + graph_format["descr"]
|
||||
)
|
||||
elif self.category == CATEGORY_TREE:
|
||||
for tree_format in treedoc.FORMATS:
|
||||
self.options_help['off'][2].append(
|
||||
tree_format["type"] + "\t" + tree_format["descr"])
|
||||
self.options_help["off"][2].append(
|
||||
tree_format["type"] + "\t" + tree_format["descr"]
|
||||
)
|
||||
else:
|
||||
self.options_help['off'][2] = "NA"
|
||||
self.options_help["off"][2] = "NA"
|
||||
|
||||
self.options_help['papers'][2] = [
|
||||
paper.get_name() for paper in paper_sizes
|
||||
if paper.get_name() != 'Custom Size']
|
||||
self.options_help["papers"][2] = [
|
||||
paper.get_name()
|
||||
for paper in paper_sizes
|
||||
if paper.get_name() != "Custom Size"
|
||||
]
|
||||
|
||||
self.options_help['papero'][2] = ["%d\tPortrait" % PAPER_PORTRAIT,
|
||||
"%d\tLandscape" % PAPER_LANDSCAPE]
|
||||
self.options_help["papero"][2] = [
|
||||
"%d\tPortrait" % PAPER_PORTRAIT,
|
||||
"%d\tLandscape" % PAPER_LANDSCAPE,
|
||||
]
|
||||
|
||||
self.options_help['css'][2] = os.path.join(USER_HOME,
|
||||
"whatever_name.css")
|
||||
self.options_help["css"][2] = os.path.join(USER_HOME, "whatever_name.css")
|
||||
|
||||
if self.category in (CATEGORY_TEXT, CATEGORY_DRAW):
|
||||
default_style = StyleSheet()
|
||||
@@ -355,20 +386,19 @@ class CommandLineReport:
|
||||
style_file = self.option_class.handler.get_stylesheet_savefile()
|
||||
self.style_list = StyleSheetList(style_file, default_style)
|
||||
|
||||
self.options_help['style'][2] = self.style_list.get_style_names()
|
||||
self.options_help["style"][2] = self.style_list.get_style_names()
|
||||
|
||||
def init_report_options(self):
|
||||
"""
|
||||
Initialize the options that are defined by each report.
|
||||
"""
|
||||
|
||||
if self.category == CATEGORY_BOOK: # a Book Report has no "menu"
|
||||
if self.category == CATEGORY_BOOK: # a Book Report has no "menu"
|
||||
for key in self.option_class.options_dict:
|
||||
self.options_dict[key] = self.option_class.options_dict[key]
|
||||
self.options_help[
|
||||
key] = self.option_class.options_help[key][:3]
|
||||
self.options_help[key] = self.option_class.options_help[key][:3]
|
||||
# a Book Report can't have HTML output so "css" is meaningless
|
||||
self.options_dict.pop('css')
|
||||
self.options_dict.pop("css")
|
||||
|
||||
if not hasattr(self.option_class, "menu"):
|
||||
return
|
||||
@@ -393,9 +423,10 @@ class CommandLineReport:
|
||||
id_list = []
|
||||
for person_handle in self.database.get_person_handles(True):
|
||||
person = self.database.get_person_from_handle(person_handle)
|
||||
id_list.append("%s\t%s"
|
||||
% (person.get_gramps_id(),
|
||||
name_displayer.display(person)))
|
||||
id_list.append(
|
||||
"%s\t%s"
|
||||
% (person.get_gramps_id(), name_displayer.display(person))
|
||||
)
|
||||
self.options_help[name].append(id_list)
|
||||
elif isinstance(option, FamilyOption):
|
||||
id_list = []
|
||||
@@ -413,9 +444,11 @@ class CommandLineReport:
|
||||
if father:
|
||||
fname = name_displayer.display(father)
|
||||
# Translators: needed for French, Hebrew and Arabic
|
||||
text = _("%(id)s:\t%(father)s, %(mother)s"
|
||||
) % {'id': family.get_gramps_id(),
|
||||
'father': fname, 'mother': mname}
|
||||
text = _("%(id)s:\t%(father)s, %(mother)s") % {
|
||||
"id": family.get_gramps_id(),
|
||||
"father": fname,
|
||||
"mother": mname,
|
||||
}
|
||||
id_list.append(text)
|
||||
self.options_help[name].append(id_list)
|
||||
elif isinstance(option, NoteOption):
|
||||
@@ -443,14 +476,15 @@ class CommandLineReport:
|
||||
elif isinstance(option, TextOption):
|
||||
self.options_help[name].append(
|
||||
"A list of text values. Each entry in the list "
|
||||
"represents one line of text.")
|
||||
"represents one line of text."
|
||||
)
|
||||
elif isinstance(option, EnumeratedListOption):
|
||||
ilist = []
|
||||
for (value, description) in option.get_items():
|
||||
tabs = '\t'
|
||||
for value, description in option.get_items():
|
||||
tabs = "\t"
|
||||
try:
|
||||
tabs = '\t\t' if len(value) < 10 else '\t'
|
||||
except TypeError: #Value is a number, use just one tab.
|
||||
tabs = "\t\t" if len(value) < 10 else "\t"
|
||||
except TypeError: # Value is a number, use just one tab.
|
||||
pass
|
||||
val = "%s%s%s" % (value, tabs, description)
|
||||
ilist.append(val)
|
||||
@@ -459,13 +493,19 @@ class CommandLineReport:
|
||||
self.options_help[name].append(option.get_help())
|
||||
else:
|
||||
print(_("Unknown option: %s") % option, file=sys.stderr)
|
||||
print(_(" Valid options are:") +
|
||||
_(", ").join(list(self.options_dict.keys())), # Arabic OK
|
||||
file=sys.stderr)
|
||||
print(_(" Use '%(donottranslate)s' to see description "
|
||||
print(
|
||||
_(" Valid options are:")
|
||||
+ _(", ").join(list(self.options_dict.keys())), # Arabic OK
|
||||
file=sys.stderr,
|
||||
)
|
||||
print(
|
||||
_(
|
||||
" Use '%(donottranslate)s' to see description "
|
||||
"and acceptable values"
|
||||
) % {'donottranslate' : "show=option"},
|
||||
file=sys.stderr)
|
||||
)
|
||||
% {"donottranslate": "show=option"},
|
||||
file=sys.stderr,
|
||||
)
|
||||
|
||||
def parse_options(self):
|
||||
"""
|
||||
@@ -477,9 +517,9 @@ class CommandLineReport:
|
||||
menu = self.option_class.menu
|
||||
menu_opt_names = menu.get_all_option_names()
|
||||
|
||||
_format_str = self.options_str_dict.pop('off', None)
|
||||
_format_str = self.options_str_dict.pop("off", None)
|
||||
if _format_str:
|
||||
self.options_dict['off'] = _format_str
|
||||
self.options_dict["off"] = _format_str
|
||||
|
||||
self.css_filename = None
|
||||
_chosen_format = None
|
||||
@@ -488,13 +528,13 @@ class CommandLineReport:
|
||||
if self.category in [CATEGORY_TEXT, CATEGORY_DRAW, CATEGORY_BOOK]:
|
||||
if self.category == CATEGORY_TEXT:
|
||||
plugins = self.__textdoc_plugins
|
||||
self.css_filename = self.options_dict['css']
|
||||
self.css_filename = self.options_dict["css"]
|
||||
elif self.category == CATEGORY_DRAW:
|
||||
plugins = self.__drawdoc_plugins
|
||||
elif self.category == CATEGORY_BOOK:
|
||||
plugins = self.__bookdoc_plugins
|
||||
for plugin in plugins:
|
||||
if plugin.get_extension() == self.options_dict['off']:
|
||||
if plugin.get_extension() == self.options_dict["off"]:
|
||||
self.format = plugin.get_basedoc()
|
||||
self.doc_option_class = plugin.get_doc_option_class()
|
||||
if self.format is None:
|
||||
@@ -505,8 +545,8 @@ class CommandLineReport:
|
||||
_chosen_format = plugin.get_extension()
|
||||
elif self.category == CATEGORY_GRAPHVIZ:
|
||||
for graph_format in graphdoc.FORMATS:
|
||||
if graph_format['type'] == self.options_dict['off']:
|
||||
if not self.format: # choose the first one, not the last
|
||||
if graph_format["type"] == self.options_dict["off"]:
|
||||
if not self.format: # choose the first one, not the last
|
||||
self.format = graph_format["class"]
|
||||
if self.format is None:
|
||||
# Pick the first one as the default.
|
||||
@@ -514,8 +554,8 @@ class CommandLineReport:
|
||||
_chosen_format = graphdoc.FORMATS[0]["type"]
|
||||
elif self.category == CATEGORY_TREE:
|
||||
for tree_format in treedoc.FORMATS:
|
||||
if tree_format['type'] == self.options_dict['off']:
|
||||
if not self.format: # choose the first one, not the last
|
||||
if tree_format["type"] == self.options_dict["off"]:
|
||||
if not self.format: # choose the first one, not the last
|
||||
self.format = tree_format["class"]
|
||||
if self.format is None:
|
||||
# Pick the first one as the default.
|
||||
@@ -524,24 +564,33 @@ class CommandLineReport:
|
||||
else:
|
||||
self.format = None
|
||||
if _chosen_format and _format_str:
|
||||
print(_("Ignoring '%(notranslate1)s=%(notranslate2)s' "
|
||||
print(
|
||||
_(
|
||||
"Ignoring '%(notranslate1)s=%(notranslate2)s' "
|
||||
"and using '%(notranslate1)s=%(notranslate3)s'."
|
||||
) % {'notranslate1' : "off",
|
||||
'notranslate2' : self.options_dict['off'],
|
||||
'notranslate3' : _chosen_format},
|
||||
file=sys.stderr)
|
||||
print(_("Use '%(notranslate)s' to see valid values."
|
||||
) % {'notranslate' : "show=off"}, file=sys.stderr)
|
||||
)
|
||||
% {
|
||||
"notranslate1": "off",
|
||||
"notranslate2": self.options_dict["off"],
|
||||
"notranslate3": _chosen_format,
|
||||
},
|
||||
file=sys.stderr,
|
||||
)
|
||||
print(
|
||||
_("Use '%(notranslate)s' to see valid values.")
|
||||
% {"notranslate": "show=off"},
|
||||
file=sys.stderr,
|
||||
)
|
||||
|
||||
self.do_doc_options()
|
||||
|
||||
for opt in self.options_str_dict:
|
||||
if opt in self.options_dict:
|
||||
self.options_dict[opt] = _convert_str_to_match_type(
|
||||
self.options_str_dict[opt], self.options_dict[opt])
|
||||
self.options_str_dict[opt], self.options_dict[opt]
|
||||
)
|
||||
|
||||
self.option_class.handler.options_dict[
|
||||
opt] = self.options_dict[opt]
|
||||
self.option_class.handler.options_dict[opt] = self.options_dict[opt]
|
||||
|
||||
if menu and opt in menu_opt_names:
|
||||
option = menu.get_option_by_name(opt)
|
||||
@@ -549,28 +598,34 @@ class CommandLineReport:
|
||||
|
||||
else:
|
||||
print(_("Ignoring unknown option: %s") % opt, file=sys.stderr)
|
||||
print(_(" Valid options are:"),
|
||||
_(", ").join(list(self.options_dict.keys())), # Arabic OK
|
||||
file=sys.stderr)
|
||||
print(_(" Use '%(donottranslate)s' to see description "
|
||||
print(
|
||||
_(" Valid options are:"),
|
||||
_(", ").join(list(self.options_dict.keys())), # Arabic OK
|
||||
file=sys.stderr,
|
||||
)
|
||||
print(
|
||||
_(
|
||||
" Use '%(donottranslate)s' to see description "
|
||||
"and acceptable values"
|
||||
) % {'donottranslate' : "show=option"},
|
||||
file=sys.stderr)
|
||||
)
|
||||
% {"donottranslate": "show=option"},
|
||||
file=sys.stderr,
|
||||
)
|
||||
|
||||
self.option_class.handler.output = self.options_dict['of']
|
||||
self.option_class.handler.output = self.options_dict["of"]
|
||||
|
||||
self.paper = paper_sizes[0] # make sure one exists
|
||||
self.paper = paper_sizes[0] # make sure one exists
|
||||
for paper in paper_sizes:
|
||||
if paper.get_name() == self.options_dict['papers']:
|
||||
if paper.get_name() == self.options_dict["papers"]:
|
||||
self.paper = paper
|
||||
self.option_class.handler.set_paper(self.paper)
|
||||
|
||||
self.orien = self.options_dict['papero']
|
||||
self.orien = self.options_dict["papero"]
|
||||
|
||||
self.marginl = self.options_dict['paperml']
|
||||
self.marginr = self.options_dict['papermr']
|
||||
self.margint = self.options_dict['papermt']
|
||||
self.marginb = self.options_dict['papermb']
|
||||
self.marginl = self.options_dict["paperml"]
|
||||
self.marginr = self.options_dict["papermr"]
|
||||
self.margint = self.options_dict["papermt"]
|
||||
self.marginb = self.options_dict["papermb"]
|
||||
|
||||
if self.category in (CATEGORY_TEXT, CATEGORY_DRAW):
|
||||
default_style = StyleSheet()
|
||||
@@ -590,27 +645,27 @@ class CommandLineReport:
|
||||
"""
|
||||
self.doc_options = None
|
||||
if not self.doc_option_class:
|
||||
return # this docgen type has no options
|
||||
return # this docgen type has no options
|
||||
try:
|
||||
if issubclass(self.doc_option_class, object):
|
||||
self.doc_options = self.doc_option_class(self.raw_name,
|
||||
self.database)
|
||||
self.doc_options = self.doc_option_class(self.raw_name, self.database)
|
||||
doc_options_dict = self.doc_options.options_dict
|
||||
except TypeError:
|
||||
self.doc_options = self.doc_option_class
|
||||
self.doc_options.load_previous_values()
|
||||
docgen_menu = self.doc_options.menu
|
||||
report_menu = self.option_class.menu # "help" checks the option type
|
||||
report_menu = self.option_class.menu # "help" checks the option type
|
||||
for oname in docgen_menu.get_option_names(DOCGEN_OPTIONS):
|
||||
docgen_opt = docgen_menu.get_option(DOCGEN_OPTIONS, oname)
|
||||
if oname in self.options_str_dict and oname in doc_options_dict:
|
||||
doc_options_dict[oname] = _convert_str_to_match_type(
|
||||
self.options_str_dict[oname], doc_options_dict[oname])
|
||||
self.options_str_dict[oname], doc_options_dict[oname]
|
||||
)
|
||||
self.options_str_dict.pop(oname)
|
||||
if oname in doc_options_dict:
|
||||
docgen_opt.set_value(doc_options_dict[oname])
|
||||
report_menu.add_option(DOCGEN_OPTIONS, oname, docgen_opt)
|
||||
for oname in doc_options_dict: # enable "help"
|
||||
for oname in doc_options_dict: # enable "help"
|
||||
self.options_dict[oname] = doc_options_dict[oname]
|
||||
self.options_help[oname] = self.doc_options.options_help[oname][:3]
|
||||
|
||||
@@ -620,26 +675,29 @@ class CommandLineReport:
|
||||
"""
|
||||
if not self.show:
|
||||
return
|
||||
elif self.show == 'all':
|
||||
elif self.show == "all":
|
||||
print(_(" Available options:"))
|
||||
for key in sorted(self.options_dict.keys()):
|
||||
if key in self.options_help:
|
||||
opt = self.options_help[key]
|
||||
# Make the output nicer to read, assume a tab has 8 spaces
|
||||
tabs = '\t\t' if len(key) < 10 else '\t'
|
||||
tabs = "\t\t" if len(key) < 10 else "\t"
|
||||
optmsg = " %s%s%s (%s)" % (key, tabs, opt[1], opt[0])
|
||||
else:
|
||||
optmsg = " %s%s%s" % (key, tabs,
|
||||
_('(no help available)'))
|
||||
optmsg = " %s%s%s" % (key, tabs, _("(no help available)"))
|
||||
print(optmsg)
|
||||
print(_(" Use '%(donottranslate)s' to see description "
|
||||
print(
|
||||
_(
|
||||
" Use '%(donottranslate)s' to see description "
|
||||
"and acceptable values"
|
||||
) % {'donottranslate' : "show=option"})
|
||||
)
|
||||
% {"donottranslate": "show=option"}
|
||||
)
|
||||
elif self.show in self.options_help:
|
||||
opt = self.options_help[self.show]
|
||||
tabs = '\t\t' if len(self.show) < 10 else '\t'
|
||||
tabs = "\t\t" if len(self.show) < 10 else "\t"
|
||||
print(_(" Available values are:"))
|
||||
print(' %s%s%s (%s)' % (self.show, tabs, opt[1], opt[0]))
|
||||
print(" %s%s%s (%s)" % (self.show, tabs, opt[1], opt[0]))
|
||||
vals = opt[2]
|
||||
if isinstance(vals, (list, tuple)):
|
||||
for val in vals:
|
||||
@@ -648,27 +706,29 @@ class CommandLineReport:
|
||||
print(" %s" % opt[2])
|
||||
|
||||
else:
|
||||
#there was a show option given, but the option is invalid
|
||||
print(_("option '%(optionname)s' not valid. "
|
||||
# there was a show option given, but the option is invalid
|
||||
print(
|
||||
_(
|
||||
"option '%(optionname)s' not valid. "
|
||||
"Use '%(donottranslate)s' to see all valid options."
|
||||
) % {'optionname' : self.show,
|
||||
'donottranslate' : "show=all"},
|
||||
file=sys.stderr)
|
||||
)
|
||||
% {"optionname": self.show, "donottranslate": "show=all"},
|
||||
file=sys.stderr,
|
||||
)
|
||||
|
||||
#------------------------------------------------------------------------
|
||||
|
||||
# ------------------------------------------------------------------------
|
||||
#
|
||||
# Command-line report generic task
|
||||
#
|
||||
#------------------------------------------------------------------------
|
||||
def cl_report(database, name, category, report_class, options_class,
|
||||
options_str_dict):
|
||||
# ------------------------------------------------------------------------
|
||||
def cl_report(database, name, category, report_class, options_class, options_str_dict):
|
||||
"""
|
||||
function to actually run the selected report
|
||||
"""
|
||||
|
||||
err_msg = _("Failed to write report. ")
|
||||
clr = CommandLineReport(database, name, category, options_class,
|
||||
options_str_dict)
|
||||
clr = CommandLineReport(database, name, category, options_class, options_str_dict)
|
||||
|
||||
# Exit here if show option was given
|
||||
if clr.show:
|
||||
@@ -680,21 +740,43 @@ def cl_report(database, name, category, report_class, options_class,
|
||||
if clr.doc_options:
|
||||
clr.option_class.handler.doc = clr.format(
|
||||
clr.selected_style,
|
||||
PaperStyle(clr.paper, clr.orien, clr.marginl,
|
||||
clr.marginr, clr.margint, clr.marginb),
|
||||
clr.doc_options)
|
||||
PaperStyle(
|
||||
clr.paper,
|
||||
clr.orien,
|
||||
clr.marginl,
|
||||
clr.marginr,
|
||||
clr.margint,
|
||||
clr.marginb,
|
||||
),
|
||||
clr.doc_options,
|
||||
)
|
||||
else:
|
||||
clr.option_class.handler.doc = clr.format(
|
||||
clr.selected_style,
|
||||
PaperStyle(clr.paper, clr.orien, clr.marginl,
|
||||
clr.marginr, clr.margint, clr.marginb))
|
||||
PaperStyle(
|
||||
clr.paper,
|
||||
clr.orien,
|
||||
clr.marginl,
|
||||
clr.marginr,
|
||||
clr.margint,
|
||||
clr.marginb,
|
||||
),
|
||||
)
|
||||
elif category in [CATEGORY_GRAPHVIZ, CATEGORY_TREE]:
|
||||
clr.option_class.handler.doc = clr.format(
|
||||
clr.option_class,
|
||||
PaperStyle(clr.paper, clr.orien, clr.marginl,
|
||||
clr.marginr, clr.margint, clr.marginb))
|
||||
if (clr.css_filename is not None
|
||||
and hasattr(clr.option_class.handler.doc, 'set_css_filename')):
|
||||
PaperStyle(
|
||||
clr.paper,
|
||||
clr.orien,
|
||||
clr.marginl,
|
||||
clr.marginr,
|
||||
clr.margint,
|
||||
clr.marginb,
|
||||
),
|
||||
)
|
||||
if clr.css_filename is not None and hasattr(
|
||||
clr.option_class.handler.doc, "set_css_filename"
|
||||
):
|
||||
clr.option_class.handler.doc.set_css_filename(clr.css_filename)
|
||||
my_report = report_class(database, clr.option_class, User())
|
||||
my_report.doc.init()
|
||||
@@ -720,6 +802,7 @@ def cl_report(database, name, category, report_class, options_class,
|
||||
except:
|
||||
traceback.print_exc()
|
||||
|
||||
|
||||
def run_report(db, name, **options_str_dict):
|
||||
"""
|
||||
Given a database, run a given report.
|
||||
@@ -742,7 +825,7 @@ def run_report(db, name, **options_str_dict):
|
||||
filename in clr.option_class.get_output()
|
||||
"""
|
||||
dbstate = DbState()
|
||||
climanager = CLIManager(dbstate, False, User()) # don't load db
|
||||
climanager = CLIManager(dbstate, False, User()) # don't load db
|
||||
climanager.do_reg_plugins(dbstate, None)
|
||||
pmgr = BasePluginManager.get_instance()
|
||||
cl_list = pmgr.get_reg_reports()
|
||||
@@ -751,48 +834,51 @@ def run_report(db, name, **options_str_dict):
|
||||
if name == pdata.id:
|
||||
mod = pmgr.load_plugin(pdata)
|
||||
if not mod:
|
||||
#import of plugin failed
|
||||
# import of plugin failed
|
||||
return clr
|
||||
category = pdata.category
|
||||
report_class = getattr(mod, pdata.reportclass)
|
||||
options_class = getattr(mod, pdata.optionclass)
|
||||
if category in (CATEGORY_BOOK, CATEGORY_CODE):
|
||||
options_class(db, name, category,
|
||||
options_str_dict)
|
||||
options_class(db, name, category, options_str_dict)
|
||||
else:
|
||||
clr = cl_report(db, name, category,
|
||||
report_class, options_class,
|
||||
options_str_dict)
|
||||
clr = cl_report(
|
||||
db, name, category, report_class, options_class, options_str_dict
|
||||
)
|
||||
return clr
|
||||
return clr
|
||||
|
||||
#------------------------------------------------------------------------
|
||||
|
||||
# ------------------------------------------------------------------------
|
||||
#
|
||||
# Function to write books from command line
|
||||
#
|
||||
#------------------------------------------------------------------------
|
||||
# ------------------------------------------------------------------------
|
||||
def cl_book(database, name, book, options_str_dict):
|
||||
"""
|
||||
function to actually run the selected book,
|
||||
which in turn runs whatever reports the book has in it
|
||||
"""
|
||||
|
||||
clr = CommandLineReport(database, name, CATEGORY_BOOK,
|
||||
ReportOptions, options_str_dict)
|
||||
clr = CommandLineReport(
|
||||
database, name, CATEGORY_BOOK, ReportOptions, options_str_dict
|
||||
)
|
||||
|
||||
# Exit here if show option was given
|
||||
if clr.show:
|
||||
return
|
||||
|
||||
# write report
|
||||
doc = clr.format(None,
|
||||
PaperStyle(clr.paper, clr.orien, clr.marginl,
|
||||
clr.marginr, clr.margint, clr.marginb))
|
||||
doc = clr.format(
|
||||
None,
|
||||
PaperStyle(
|
||||
clr.paper, clr.orien, clr.marginl, clr.marginr, clr.margint, clr.marginb
|
||||
),
|
||||
)
|
||||
user = User()
|
||||
rptlist = []
|
||||
selected_style = StyleSheet()
|
||||
for item in book.get_item_list():
|
||||
|
||||
# The option values were loaded magically by the book parser.
|
||||
# But they still need to be applied to the menu options.
|
||||
opt_dict = item.option_class.options_dict
|
||||
@@ -804,9 +890,10 @@ def cl_book(database, name, book, options_str_dict):
|
||||
|
||||
item.option_class.set_document(doc)
|
||||
report_class = item.get_write_item()
|
||||
obj = (write_book_item(database,
|
||||
report_class, item.option_class, user),
|
||||
item.get_translated_name())
|
||||
obj = (
|
||||
write_book_item(database, report_class, item.option_class, user),
|
||||
item.get_translated_name(),
|
||||
)
|
||||
if obj:
|
||||
append_styles(selected_style, item)
|
||||
rptlist.append(obj)
|
||||
@@ -817,7 +904,7 @@ def cl_book(database, name, book, options_str_dict):
|
||||
newpage = 0
|
||||
err_msg = _("Failed to make '%s' report.")
|
||||
try:
|
||||
for (rpt, name) in rptlist:
|
||||
for rpt, name in rptlist:
|
||||
if newpage:
|
||||
doc.page_break()
|
||||
newpage = 1
|
||||
@@ -826,16 +913,17 @@ def cl_book(database, name, book, options_str_dict):
|
||||
doc.close()
|
||||
except ReportError as msg:
|
||||
(msg1, msg2) = msg.messages()
|
||||
print(err_msg % name, file=sys.stderr) # which report has the error?
|
||||
print(err_msg % name, file=sys.stderr) # which report has the error?
|
||||
print(msg1, file=sys.stderr)
|
||||
if msg2:
|
||||
print(msg2, file=sys.stderr)
|
||||
|
||||
#------------------------------------------------------------------------
|
||||
|
||||
# ------------------------------------------------------------------------
|
||||
#
|
||||
# Generic task function for book
|
||||
#
|
||||
#------------------------------------------------------------------------
|
||||
# ------------------------------------------------------------------------
|
||||
def write_book_item(database, report_class, options, user):
|
||||
"""Write the report using options set.
|
||||
All user dialog has already been handled and the output file opened."""
|
||||
|
||||
@@ -25,6 +25,7 @@ import unittest
|
||||
from unittest.mock import Mock
|
||||
from ..argparser import ArgParser
|
||||
|
||||
|
||||
class TestArgParser(unittest.TestCase):
|
||||
def setUp(self):
|
||||
pass
|
||||
@@ -34,47 +35,46 @@ class TestArgParser(unittest.TestCase):
|
||||
|
||||
def triggers_option_error(self, option):
|
||||
ap = self.create_parser(option)
|
||||
return (str(ap.errors).find("option "+option)>=0, ap)
|
||||
return (str(ap.errors).find("option " + option) >= 0, ap)
|
||||
|
||||
def test_wrong_argument_triggers_option_error(self):
|
||||
bad,ap = self.triggers_option_error('--I-am-a-wrong-argument')
|
||||
bad, ap = self.triggers_option_error("--I-am-a-wrong-argument")
|
||||
assert bad, ap.__dict__
|
||||
|
||||
def test_y_shortopt_sets_auto_accept(self):
|
||||
bad, ap = self.triggers_option_error('-y')
|
||||
bad, ap = self.triggers_option_error("-y")
|
||||
|
||||
self.assertFalse(bad)
|
||||
|
||||
expected_errors = [(
|
||||
'Error parsing the arguments',
|
||||
'Error parsing the arguments: [ -y ] \n' +
|
||||
'To use in the command-line mode, supply at least one input file to process.'
|
||||
)]
|
||||
self.assertEqual(
|
||||
expected_errors,
|
||||
ap.errors
|
||||
)
|
||||
expected_errors = [
|
||||
(
|
||||
"Error parsing the arguments",
|
||||
"Error parsing the arguments: [ -y ] \n"
|
||||
+ "To use in the command-line mode, supply at least one input file to process.",
|
||||
)
|
||||
]
|
||||
self.assertEqual(expected_errors, ap.errors)
|
||||
|
||||
self.assertTrue(ap.auto_accept)
|
||||
|
||||
def test_yes_longopt_sets_auto_accept(self):
|
||||
bad,ap = self.triggers_option_error('--yes')
|
||||
bad, ap = self.triggers_option_error("--yes")
|
||||
assert not bad, ap.errors
|
||||
assert ap.auto_accept
|
||||
|
||||
def test_q_shortopt_sets_quiet(self):
|
||||
bad,ap = self.triggers_option_error('-q')
|
||||
bad, ap = self.triggers_option_error("-q")
|
||||
assert not bad, ap.errors
|
||||
assert ap.quiet
|
||||
|
||||
def test_quiet_longopt_sets_quiet(self):
|
||||
bad,ap = self.triggers_option_error('--quiet')
|
||||
bad, ap = self.triggers_option_error("--quiet")
|
||||
assert not bad, ap.errors
|
||||
assert ap.quiet
|
||||
|
||||
def test_quiet_exists_by_default(self):
|
||||
ap = self.create_parser()
|
||||
assert hasattr(ap,'quiet')
|
||||
assert hasattr(ap, "quiet")
|
||||
|
||||
def test_auto_accept_unset_by_default(self):
|
||||
ap = self.create_parser()
|
||||
@@ -83,20 +83,20 @@ class TestArgParser(unittest.TestCase):
|
||||
def test_exception(self):
|
||||
argument_parser = self.create_parser("-O")
|
||||
|
||||
expected_errors = [(
|
||||
'Error parsing the arguments',
|
||||
'option -O requires argument\n'
|
||||
'Error parsing the arguments: [ -O ] \n'
|
||||
'Type gramps --help for an overview of commands, or read the manual pages.'
|
||||
)]
|
||||
self.assertEqual(
|
||||
expected_errors,
|
||||
argument_parser.errors
|
||||
)
|
||||
expected_errors = [
|
||||
(
|
||||
"Error parsing the arguments",
|
||||
"option -O requires argument\n"
|
||||
"Error parsing the arguments: [ -O ] \n"
|
||||
"Type gramps --help for an overview of commands, or read the manual pages.",
|
||||
)
|
||||
]
|
||||
self.assertEqual(expected_errors, argument_parser.errors)
|
||||
|
||||
def test_option_with_multiple_arguments(self):
|
||||
argument_parser = self.create_parser('-l', 'family_tree_name')
|
||||
self.assertEqual(argument_parser.database_names, ['family_tree_name'])
|
||||
argument_parser = self.create_parser("-l", "family_tree_name")
|
||||
self.assertEqual(argument_parser.database_names, ["family_tree_name"])
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
||||
@@ -44,8 +44,8 @@ ddir = os.path.dirname(__file__)
|
||||
min1r = os.path.join(ddir, "min1r.ged")
|
||||
out_ged = os.path.join(ddir, "test_out.ged")
|
||||
example_copy = os.path.join(ddir, "copy.gramps")
|
||||
example = os.path.join(ddir, "..", "..", "..",
|
||||
"example", "gramps", "data.gramps")
|
||||
example = os.path.join(ddir, "..", "..", "..", "example", "gramps", "data.gramps")
|
||||
|
||||
|
||||
class Test(unittest.TestCase):
|
||||
def setUp(self):
|
||||
@@ -70,8 +70,7 @@ class Test(unittest.TestCase):
|
||||
def test1_setup_works(self):
|
||||
self.assertTrue(os.path.exists(ddir), "data dir %r exists" % ddir)
|
||||
self.assertTrue(os.path.exists(min1r), "data file %r exists" % min1r)
|
||||
self.assertFalse(os.path.exists(out_ged),
|
||||
"NO out file %r yet" % out_ged)
|
||||
self.assertFalse(os.path.exists(out_ged), "NO out file %r yet" % out_ged)
|
||||
|
||||
# This tests the fix for bug #1331-1334
|
||||
# read trivial gedcom input, write gedcom output
|
||||
@@ -79,13 +78,11 @@ class Test(unittest.TestCase):
|
||||
ifile = min1r
|
||||
ofile = out_ged
|
||||
gcmd = [sys.executable, "Gramps.py", "-i", ifile, "-e", ofile]
|
||||
process = subprocess.Popen(gcmd,
|
||||
stdin=subprocess.PIPE,
|
||||
stdout=subprocess.PIPE,
|
||||
stderr=subprocess.PIPE)
|
||||
process = subprocess.Popen(
|
||||
gcmd, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE
|
||||
)
|
||||
result_str, err_str = process.communicate()
|
||||
self.assertEqual(process.returncode, 0,
|
||||
"executed CLI command %r" % gcmd)
|
||||
self.assertEqual(process.returncode, 0, "executed CLI command %r" % gcmd)
|
||||
# simple validation o output
|
||||
self.assertTrue(os.path.isfile(ofile), "output file created")
|
||||
with open(ofile) as f:
|
||||
@@ -98,13 +95,11 @@ class Test(unittest.TestCase):
|
||||
ifile = min1r
|
||||
ofile = out_ged
|
||||
gcmd = [sys.executable, "-m", "gramps", "-i", ifile, "-e", ofile]
|
||||
process = subprocess.Popen(gcmd,
|
||||
stdin=subprocess.PIPE,
|
||||
stdout=subprocess.PIPE,
|
||||
stderr=subprocess.PIPE)
|
||||
process = subprocess.Popen(
|
||||
gcmd, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE
|
||||
)
|
||||
result_str, err_str = process.communicate()
|
||||
self.assertEqual(process.returncode, 0,
|
||||
"executed CLI command %r" % gcmd)
|
||||
self.assertEqual(process.returncode, 0, "executed CLI command %r" % gcmd)
|
||||
# simple validation o output
|
||||
self.assertTrue(os.path.isfile(ofile), "output file created")
|
||||
with open(ofile) as f:
|
||||
@@ -114,39 +109,47 @@ class Test(unittest.TestCase):
|
||||
|
||||
|
||||
class UnicodeTest(unittest.TestCase):
|
||||
|
||||
def setUp(self):
|
||||
from gramps.cli.clidbman import CLIDbManager
|
||||
from gramps.gen.config import set as setconfig, get as getconfig
|
||||
from gramps.gen.dbstate import DbState
|
||||
self.newpath = os.path.join(os.path.dirname(__file__),
|
||||
'\u0393\u03c1\u03b1\u03bc\u03c3\u03c0')
|
||||
self.newtitle = 'Gr\u00e4mps T\u00e9st'
|
||||
|
||||
self.newpath = os.path.join(
|
||||
os.path.dirname(__file__), "\u0393\u03c1\u03b1\u03bc\u03c3\u03c0"
|
||||
)
|
||||
self.newtitle = "Gr\u00e4mps T\u00e9st"
|
||||
os.makedirs(self.newpath)
|
||||
self.old_path = getconfig('database.path')
|
||||
setconfig('database.path', self.newpath)
|
||||
self.old_path = getconfig("database.path")
|
||||
setconfig("database.path", self.newpath)
|
||||
self.cli = CLIDbManager(DbState())
|
||||
|
||||
def tearDown(self):
|
||||
from gramps.gen.config import set as setconfig
|
||||
for (dirpath, dirnames, filenames) in os.walk(self.newpath, False):
|
||||
|
||||
for dirpath, dirnames, filenames in os.walk(self.newpath, False):
|
||||
for afile in filenames:
|
||||
os.remove(os.path.join(dirpath, afile))
|
||||
for adir in dirnames:
|
||||
os.rmdir(os.path.join(dirpath, adir))
|
||||
os.rmdir(self.newpath)
|
||||
setconfig('database.path', self.old_path)
|
||||
setconfig("database.path", self.old_path)
|
||||
|
||||
# Test that clidbman will open files in a path containing
|
||||
# arbitrary Unicode characters.
|
||||
def test4_arbitrary_uncode_path(self):
|
||||
(dbpath, title) = self.cli.create_new_db_cli(self.newtitle)
|
||||
|
||||
self.assertEqual(self.newpath, os.path.dirname(dbpath),
|
||||
"Compare paths %s and %s" % (repr(self.newpath),
|
||||
repr(dbpath)))
|
||||
self.assertEqual(self.newtitle, title, "Compare titles %s and %s" %
|
||||
(repr(self.newtitle), repr(title)))
|
||||
self.assertEqual(
|
||||
self.newpath,
|
||||
os.path.dirname(dbpath),
|
||||
"Compare paths %s and %s" % (repr(self.newpath), repr(dbpath)),
|
||||
)
|
||||
self.assertEqual(
|
||||
self.newtitle,
|
||||
title,
|
||||
"Compare titles %s and %s" % (repr(self.newtitle), repr(title)),
|
||||
)
|
||||
|
||||
|
||||
class CLITest(unittest.TestCase):
|
||||
def tearDown(self):
|
||||
@@ -167,7 +170,8 @@ class CLITest(unittest.TestCase):
|
||||
def test1b_cli(self):
|
||||
self.call("-O", "Test: test1_cli", "--export", example_copy)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
||||
#===eof===
|
||||
# ===eof===
|
||||
|
||||
@@ -26,12 +26,14 @@ from unittest.mock import Mock, patch
|
||||
from .. import user
|
||||
import sys
|
||||
|
||||
|
||||
class TestUser:
|
||||
TITLE = "Testing prompt"
|
||||
MSG = "Choices are hard. Nevertheless, please choose!"
|
||||
ACCEPT = "To be"
|
||||
REJECT = "Not to be"
|
||||
|
||||
|
||||
class TestUser_prompt(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.real_user = user.User()
|
||||
@@ -40,38 +42,46 @@ class TestUser_prompt(unittest.TestCase):
|
||||
self.user._input = Mock(spec=input)
|
||||
|
||||
def test_default_fileout_has_write(self):
|
||||
assert hasattr(self.real_user._fileout, 'write')
|
||||
assert hasattr(self.real_user._fileout, "write")
|
||||
|
||||
def test_default_input(self):
|
||||
assert self.real_user._input.__name__.endswith('input')
|
||||
assert self.real_user._input.__name__.endswith("input")
|
||||
|
||||
def test_prompt_returns_True_if_ACCEPT_entered(self):
|
||||
self.user._input.configure_mock(return_value = TestUser.ACCEPT)
|
||||
self.user._input.configure_mock(return_value=TestUser.ACCEPT)
|
||||
assert self.user.prompt(
|
||||
TestUser.TITLE, TestUser.MSG, TestUser.ACCEPT, TestUser.REJECT
|
||||
), "True expected!"
|
||||
TestUser.TITLE, TestUser.MSG, TestUser.ACCEPT, TestUser.REJECT
|
||||
), "True expected!"
|
||||
self.user._input.assert_called_once_with()
|
||||
|
||||
def test_prompt_returns_False_if_REJECT_entered(self):
|
||||
self.user._input.configure_mock(return_value = TestUser.REJECT)
|
||||
self.user._input.configure_mock(return_value=TestUser.REJECT)
|
||||
assert not self.user.prompt(
|
||||
TestUser.TITLE, TestUser.MSG, TestUser.ACCEPT, TestUser.REJECT
|
||||
), "False expected!"
|
||||
TestUser.TITLE, TestUser.MSG, TestUser.ACCEPT, TestUser.REJECT
|
||||
), "False expected!"
|
||||
self.user._input.assert_called_once_with()
|
||||
|
||||
def assert_prompt_contains_text(self, text,
|
||||
title=TestUser.TITLE, msg=TestUser.MSG,
|
||||
accept=TestUser.ACCEPT, reject=TestUser.REJECT):
|
||||
self.user._input.configure_mock(return_value = TestUser.REJECT)
|
||||
def assert_prompt_contains_text(
|
||||
self,
|
||||
text,
|
||||
title=TestUser.TITLE,
|
||||
msg=TestUser.MSG,
|
||||
accept=TestUser.ACCEPT,
|
||||
reject=TestUser.REJECT,
|
||||
):
|
||||
self.user._input.configure_mock(return_value=TestUser.REJECT)
|
||||
self.user.prompt(title, msg, accept, reject)
|
||||
for call in self.user._fileout.method_calls:
|
||||
name, args, kwargs = call
|
||||
for a in args:
|
||||
if a.find(text) >= 0:
|
||||
return
|
||||
self.assertTrue(False,
|
||||
"'{}' never printed in prompt: {}".format(
|
||||
text, self.user._fileout.method_calls))
|
||||
self.assertTrue(
|
||||
False,
|
||||
"'{}' never printed in prompt: {}".format(
|
||||
text, self.user._fileout.method_calls
|
||||
),
|
||||
)
|
||||
|
||||
def test_prompt_contains_title_text(self):
|
||||
self.assert_prompt_contains_text(TestUser.TITLE)
|
||||
@@ -95,19 +105,20 @@ class TestUser_prompt(unittest.TestCase):
|
||||
u = user.User(auto_accept=True)
|
||||
u._fileout = Mock(spec=sys.stderr)
|
||||
assert u.prompt(
|
||||
TestUser.TITLE, TestUser.MSG, TestUser.ACCEPT, TestUser.REJECT
|
||||
), "True expected!"
|
||||
TestUser.TITLE, TestUser.MSG, TestUser.ACCEPT, TestUser.REJECT
|
||||
), "True expected!"
|
||||
assert len(u._fileout.method_calls) == 0, list(u._fileout.method_calls)
|
||||
|
||||
def test_EOFError_in_prompt_caught_as_False(self | ||||