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-SUCCESS: ['light green', '', '']
|
||||||
test-FAILURE: ['light red', '', '']
|
test-FAILURE: ['light red', '', '']
|
||||||
|
|
||||||
|
# Uncomment the next line if your terminal has a white background
|
||||||
|
# palette: light
|
||||||
|
|
||||||
commentlinks:
|
commentlinks:
|
||||||
- match: "^- (?P<job>.*?) (?P<url>.*?) : (?P<result>[^ ]+) ?(?P<comment>.*)$"
|
- match: "^- (?P<job>.*?) (?P<url>.*?) : (?P<result>[^ ]+) ?(?P<comment>.*)$"
|
||||||
test-result: "{job}"
|
test-result: "{job}"
|
||||||
|
@ -92,6 +92,7 @@ class ConfigSchema(object):
|
|||||||
def getSchema(self, data):
|
def getSchema(self, data):
|
||||||
schema = v.Schema({v.Required('servers'): self.servers,
|
schema = v.Schema({v.Required('servers'): self.servers,
|
||||||
'palettes': self.palettes,
|
'palettes': self.palettes,
|
||||||
|
'palette': str,
|
||||||
'commentlinks': self.commentlinks,
|
'commentlinks': self.commentlinks,
|
||||||
'dashboards': self.dashboards,
|
'dashboards': self.dashboards,
|
||||||
'reviewkeys': self.reviewkeys,
|
'reviewkeys': self.reviewkeys,
|
||||||
@ -133,12 +134,15 @@ class Config(object):
|
|||||||
log_file = server.get('log_file', '~/.gertty.log')
|
log_file = server.get('log_file', '~/.gertty.log')
|
||||||
self.log_file = os.path.expanduser(log_file)
|
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', []):
|
for p in self.config.get('palettes', []):
|
||||||
self.palettes[p['name']] = gertty.palette.Palette(p)
|
if p['name'] not in self.palettes:
|
||||||
if not self.palettes:
|
self.palettes[p['name']] = gertty.palette.Palette(p)
|
||||||
self.palettes['default'] = gertty.palette.Palette({})
|
else:
|
||||||
self.palette = self.palettes[palette]
|
self.palettes[p['name']].update(p)
|
||||||
|
self.palette = self.palettes[self.config.get('palette', palette)]
|
||||||
|
|
||||||
self.commentlinks = [gertty.commentlink.CommentLink(c)
|
self.commentlinks = [gertty.commentlink.CommentLink(c)
|
||||||
for c in self.config.get('commentlinks', [])]
|
for c in self.config.get('commentlinks', [])]
|
||||||
|
@ -75,10 +75,30 @@ DEFAULT_PALETTE={
|
|||||||
'focused-reviewed-change': ['dark gray,standout', ''],
|
'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):
|
class Palette(object):
|
||||||
def __init__(self, config):
|
def __init__(self, config):
|
||||||
self.palette = {}
|
self.palette = {}
|
||||||
self.palette.update(DEFAULT_PALETTE)
|
self.palette.update(DEFAULT_PALETTE)
|
||||||
|
self.update(config)
|
||||||
|
|
||||||
|
def update(self, config):
|
||||||
d = config.copy()
|
d = config.copy()
|
||||||
if 'name' in d:
|
if 'name' in d:
|
||||||
del d['name']
|
del d['name']
|
||||||
|
Loading…
x
Reference in New Issue
Block a user