##
## Copyright (c) 2006 Jason Dillon
##
## Licensed under the Apache License, Version 2.0 (the "License");
## you may not use this file except in compliance with the License.
## You may obtain a copy of the License at
##
## http://www.apache.org/licenses/LICENSE-2.0
##
## Unless required by applicable law or agreed to in writing, software
## distributed under the License is distributed on an "AS IS" BASIS,
## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
## See the License for the specific language governing permissions and
## limitations under the License.
##
##
## $Id: //guest/jason_dillon/p4spam/main/pylib/p4spam/config.py#2 $ $Date: 2006/04/12 $
##
from perforce import logging
##
## HACK: Centralized config defaults... pending getting the config file really used
##
SMTP_HOST = "localhost:25"
SPAM_ENABLED = True
SPAM_USERS = True
# Lookping
REPEAT = False
SLEEPTIME = 60
FORCE_STARTING_CHANGE = None
SAVE_LAST_CHANGE_ENABLED = False
MAX_DIFF_LINES = 1000
MAX_DIFF_LINE_LENGTH = 1000
MAX_SUBJECT_LINE_LENGTH = 200
MAX_BATCH = 10
# If set to None, then the email from the change description will be used
FROM_ADDR = None
ADMIN_BCC_ADDR = "p4admin@mycompany.com"
LAST_CHANGELIST_COUNTER = 'p4spam.lastchange'
CHANGE_LIST_URL = "http://perforce.mycompany.com/changelist.php?change=%s"
PATH_VIEW_URL = "http://perforce.mycompany.com:8666/%s"
FILE_HISTORY_URL = "http://perforce.mycompany.com/history.php?path=%s"
JIRA_BROWSE_URL = "https://issues.mycompany.com/browse/%s"
USER_HEADER = None
USER_BODY_HEADER = None
USER_BODY_FOOTER = '''
<div align="center">
<hr/>
<font size="-1">
My Company Confidential
</font>
</div>
'''
# HTML Styling
DEFAULT_STYLE = '''
#msg DL { border : 1px #006 solid; background-color : #369; padding : 6px; color : #fff; }
#msg DT { float : left; width : 6em; font-weight : bold; }
#msg DL, #msg DT, #msg UL, #msg LI { font-family : arial,helvetica,sans-serif; font-size : 10pt; }
h3 { font-family : arial,helvetica,sans-serif; font-size : 10pt; font-weight : bold; }
#msg PRE { overflow : auto; white-space : normal; background-color : #ffc; border : 1px #fc0 solid; padding : 6px; }
#msg UL, PRE, .diff { overflow : auto; }
#patch h4 { font-family : arial,helvetica,sans-serif; font-size : 10pt; }
#patch h4 { padding: 8px; background : #369; color : #fff; margin : 0; }
#patch a { font-family : arial,helvetica,sans-serif; font-size : 10pt; }
#patch a { padding: 8px; background : #369; color : #fff; margin : 0; }
#patch .propset h4, #patch .binary h4 {margin: 0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {background:#eeeeee;padding: 0 0 10px 0;}
#patch .propset .diff, #patch .binary .diff {padding: 10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch .add {background:#ddffdd;}
#patch .rem {background:#ffdddd;}
#patch .lines, .info {color:#888888;background:#ffffff;}
.diff { width : 100%; }
'''
##
## Configuration
##
class Configuration:
def __init__(this):
this.log = logging.Logger(this)
this.namespace = None
def defaults(this):
return locals()
def validate(this, namespace):
assert namespace != None
def read(this, filename):
assert filename != None
this.log.debug("Reading configuration from file: %s" % filename)
lnames = this.defaults()
gnames = globals()
# Read/parse the configuration
execfile(filename, gnames, lnames)
#if this.log.isDebugEnabled():
# this.dumpNamespace(lnames, "Locals")
# this.dumpNamespace(gnames, "Globals")
this.validate(lnames)
this.namespace = lnames
def dumpNamespace(this, namespace, title):
assert namespace != None
assert title != None
if this.log.isDebugEnabled():
this.log.debug(title)
for key in namespace.keys():
this.log.debug(" %s = %s" % (key, namespace[key]))