/usr/share/bibus/LyX/constants.py is in bibus 1.5.2-3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 | # constants.py -*- coding: iso-8859-1 -*-
# Copyright (c) 2005 Günter Milde
# Released under the terms of the GNU General Public License (ver. 2 or later)
"""
Customizable constants for the LyX package modules
This module is loaded by all LyX-package modules that need customizable
constants for values that might differ in different settings.
- LyX settings and properties
- pyLyX settings and properties
CUSTOMIZATION:
* per user:
create ~/.lyx/scripts/python/config.py with your defaults
* per module:
import LyX.constants first,
set the new value, and
import the needed module
EXAMPLE:
# myclient.py
'''a client that connects to a different serverpipe'''
from LyX import constants
constants.SERVERPIPE = "~/.lyx/alternative-serverpipe"
import LyX.lyxserver
...
"""
import sys, os, logging
import re
# LyX settings and properties
# ---------------------------
# the lyx binary
LYXCMD = 'lyx'
# system wide LyX directory for layouts, bind-files, ...
SYSTEM_DIR = "/usr/share/lyx" # this works for Debian
# per-user LyX directory
USER_DIR = "~/.lyx" # what is the correct value for Windows?
# per-user LyX config file (Edit>Preferences)
LYXRC_FILE = os.path.join(USER_DIR, "preferences")
# the server pipe path (without ".in" and ".out") (Edit>Preferences>Paths)
SERVERPIPE = os.environ.get("LYXPIPE", "~/.lyx/lyxpipe" )
# command-line options (from `man lyx`)
LYX_OPTIONS = {'-help': 0,
'-version': 0,
'-sysdir': 1,
'-userdir': 1,
'-dbg': 1,
'-x': 1, '--execute': 1,
'-e': 1, '--export': 1,
'-i': 2, '--import': 2,
# xfroms fronted options
'-geometry': 1,
'-display': 1,
'-bw': 1,
'-visual': 1,
'-depth': 1,
'-debug': 1,
'-sync': 0,
'-private': 0,
'-shared': 0,
'-stdcmap': 0,
'-name': 1
}
# pyLyX settings and properties
# -----------------------------
VERSION = "pyLyX 0.3"
# per-user pyLyX configuration file
RC_FILE = os.path.join(USER_DIR, "scripts", "python", "config.py")
# Verbosity: show all messages of severity >= LOG_LEVEL
# 0: ALL, 10: DEBUG, 20: INFO, 30: WARN, 40: ERROR, 50: CRITICAL
# (see `logging` standard module)
LOG_LEVEL = logging.INFO
# default timeout for reading the outpipe (in ms)
LYXSERVER_POLL_TIMEOUT = 1000 # 1 s
# after starting, lyx, needs some time to setup the serverpipes
LYXSERVER_SETUP_DELAY = 2 # wait n seconds
LYXSERVER_SETUP_RETRIES = 10 # try n times to connect
# Setup
# -----
def setup():
"""Set up constants
* Set up the logger instance
* Read user configuration
* Normalize paths and convert '~' to home directory
"""
global SERVERPIPE, RC_FILE, USER_DIR, SYSTEM_DIR, LYXRC_FILE
# Set up the logger instance
logging.basicConfig()
logger = logging.getLogger("constants")
#set verbosity to show all messages of severity >= LOG_LEVEL
logger.setLevel(LOG_LEVEL)
# Read user configuration, log IOErrors (no file, ...) as warning
RC_FILE = os.path.abspath(os.path.expanduser(RC_FILE))
namespace = sys.modules[__name__].__dict__
try:
execfile(RC_FILE, namespace)
except IOError:
logger.debug(" Could not load config file '%s'"%RC_FILE)
logger.debug(" Error message was", exc_info=True)
# Normalize paths and convert '~' to home directory
SERVERPIPE = os.path.abspath(os.path.expanduser(SERVERPIPE))
USER_DIR = os.path.abspath(os.path.expanduser(USER_DIR))
SYSTEM_DIR = os.path.abspath(os.path.expanduser(SYSTEM_DIR))
LYXRC_FILE = os.path.abspath(os.path.expanduser(LYXRC_FILE))
return
# run setup when imported
setup()
|