Add a standard 'light' palette
For use in a terminal with a white background. Also add a config file option that selects the default palette. Change-Id: I1b4a61efa3d9011bfe089471fa80ad4563d9ba01
This commit is contained in:
parent
f4896ed222
commit
9e38b52b63
@ -15,6 +15,9 @@ palettes:
|
||||
test-SUCCESS: ['light green', '', '']
|
||||
test-FAILURE: ['light red', '', '']
|
||||
|
||||
# Uncomment the next line if your terminal has a white background
|
||||
# palette: light
|
||||
|
||||
commentlinks:
|
||||
- match: "^- (?P<job>.*?) (?P<url>.*?) : (?P<result>[^ ]+) ?(?P<comment>.*)$"
|
||||
test-result: "{job}"
|
||||
|
@ -92,6 +92,7 @@ class ConfigSchema(object):
|
||||
def getSchema(self, data):
|
||||
schema = v.Schema({v.Required('servers'): self.servers,
|
||||
'palettes': self.palettes,
|
||||
'palette': str,
|
||||
'commentlinks': self.commentlinks,
|
||||
'dashboards': self.dashboards,
|
||||
'reviewkeys': self.reviewkeys,
|
||||
@ -133,12 +134,15 @@ class Config(object):
|
||||
log_file = server.get('log_file', '~/.gertty.log')
|
||||
self.log_file = os.path.expanduser(log_file)
|
||||
|
||||
self.palettes = {}
|
||||
self.palettes = {'default': gertty.palette.Palette({}),
|
||||
'light': gertty.palette.Palette(gertty.palette.LIGHT_PALETTE),
|
||||
}
|
||||
for p in self.config.get('palettes', []):
|
||||
self.palettes[p['name']] = gertty.palette.Palette(p)
|
||||
if not self.palettes:
|
||||
self.palettes['default'] = gertty.palette.Palette({})
|
||||
self.palette = self.palettes[palette]
|
||||
if p['name'] not in self.palettes:
|
||||
self.palettes[p['name']] = gertty.palette.Palette(p)
|
||||
else:
|
||||
self.palettes[p['name']].update(p)
|
||||
self.palette = self.palettes[self.config.get('palette', palette)]
|
||||
|
||||
self.commentlinks = [gertty.commentlink.CommentLink(c)
|
||||
for c in self.config.get('commentlinks', [])]
|
||||
|
@ -75,10 +75,30 @@ DEFAULT_PALETTE={
|
||||
'focused-reviewed-change': ['dark gray,standout', ''],
|
||||
}
|
||||
|
||||
# A delta from the default palette
|
||||
LIGHT_PALETTE = {
|
||||
'table-header': ['black,bold', ''],
|
||||
'unreviewed-project': ['black', ''],
|
||||
'subscribed-project': ['dark gray', ''],
|
||||
'unsubscribed-project': ['dark gray', ''],
|
||||
'focused-unreviewed-project': ['black,standout', ''],
|
||||
'focused-subscribed-project': ['dark gray,standout', ''],
|
||||
'focused-unsubscribed-project': ['dark gray,standout', ''],
|
||||
'change-data': ['dark blue,bold', ''],
|
||||
'reviewer-name': ['brown', ''],
|
||||
'change-message-name': ['brown', ''],
|
||||
'change-message-header': ['black', ''],
|
||||
'focused-link': ['dark blue,bold', ''],
|
||||
'filename': ['dark cyan', ''],
|
||||
}
|
||||
|
||||
class Palette(object):
|
||||
def __init__(self, config):
|
||||
self.palette = {}
|
||||
self.palette.update(DEFAULT_PALETTE)
|
||||
self.update(config)
|
||||
|
||||
def update(self, config):
|
||||
d = config.copy()
|
||||
if 'name' in d:
|
||||
del d['name']
|
||||
|
Loading…
x
Reference in New Issue
Block a user