Beispiel #1
0
def status_colors(host_color):
    base = host_color

    base_rgb = colortrans.short2rgb(base)
    text_color = get_contrast_yiq(base_rgb)

    light_rgb = transform_rgb(base_rgb, LIGHTNESS_FACTOR)
    dark_rgb = transform_rgb(base_rgb, DARKNESS_FACTOR)

    bg = "colour{bg}".format(bg=base)
    cbg, cbg_hex = colortrans.rgb2short(light_rgb)
    cfg, cfg_hex = colortrans.rgb2short(dark_rgb)
    cbg = "colour{cbg}".format(cbg=cbg)
    cfg = "colour{cfg}".format(cfg=cfg)

    print u"""
source-file ~/.tmux.conf
set -g status-bg {bg}
set -g pane-active-border-fg {cbg}
set -g status-left '#[fg=colour235,bg=colour252,bold] ❐ #S #[fg=colour252,bg=colour238,nobold]#[fg=colour245,bg=colour238,bold] #(whoami) #[fg=colour238,bg={bg},nobold]'
set -g status-right '#[fg=colour238]#[fg=colour252,bg=colour238,nobold] #H #[fg=colour235,bg=colour252,bold] %c'
set -g window-status-format "#[fg={fg},bg={bg}] #I #W "
set -g window-status-current-format "#[fg={bg},bg={cbg}]#[fg={cfg},bg={cbg},noreverse,bold] #I  #W #[fg={cbg},bg={bg},nobold]"
    """.format(
            fg=text_color,
            bg=bg,
            cbg=cbg,
            cfg=cfg)
Beispiel #2
0
def getHexColor (t):
	ratio = (float(t[0]) - LOWER_BOUND) / float(t[1]) # -24 gives us better range of colors (~room temp - max)

	# Hue, Saturation, Lightness
	rgb = colorsys.hls_to_rgb(*(colorsys.ONE_THIRD - colorsys.ONE_THIRD * ratio, SATURATION, LIGHTNESS))

	# convert to hex values ''.join([str, str, str])
	hexVals = [_strip_hex(str(hex(int(i * 255)))) for i in rgb]

	return colortrans.rgb2short(''.join(hexVals))
def create_layers(dwg, layer_to_style):
    if layer_to_style is None:
        layer_to_style = {}

    if 'default' not in layer_to_style:
        layer_to_style['default'] = {'color': '#000000'}

    for name, styles in layer_to_style.items():
        layer = dwg.layers.create(name=name, dxfattribs={})
        if 'color' in styles:
            layer.set_color(colortrans.rgb2short(styles['color']))
    def parse_exp(self, exp):

        global mapperHandler
        if exp.code in self.options.codes or exp.code in ["05", "06", "11", "29", "40", "41", "42"]:
            return ""

        if exp.code in ["22", "23", "24", "25", "31"]:
            return exp.content

        if exp.code == "10":

            ## 查看是否能拿到realm map坐标
            match = pattern.match(exp.content)
            if match and (len(ws_handlers) > 0):
                # 向页面发送坐标
                print '[realm map]send location ', match.group(2)+ ","+match.group(1)
                ws_handlers[0].send(match.group(2)+ ","+match.group(1))

            if exp.argu == "spec_battle" and self.options.enable_combat_plugin:
                return "[10]" + exp.content.replace("\n", " ").strip() + "\r\n"
            elif exp.argu == "spec_prompt":
                return exp.content.strip() +"\r\n"
            elif exp.content == "NoMapSupport":
                return ""
            else:
                return exp.content.strip() +"\r\n"
               
        if exp.code == "20" or exp.code == "21":
            if not self.options.enable_color:
                return exp.content
            elif exp.argu:
                rgb = exp.argu.zfill(6) if len(exp.argu) < 6 else exp.argu
                # fix some invalid RGB color from server
                if len(rgb) > 6:
                    rgb = ''.join(c for c in rgb if c.isdigit())                
                short, _ = colortrans.rgb2short(rgb)
                return "\033[{}8;5;{}m{}\033[0m".format(3 if exp.code == "20" else 4, short, exp.content)

        if exp.code == "99":
            if exp.content.startswith("BAT_MAPPER;;REALM_MAP"):
                return "Exited to realm map.\r\n"
            elif exp.content.startswith("BAT_MAPPER;;"):
                room = exp.content.split(";;")

                ### wind 201801, add code to send socket
                if mapperHandler != None :
                    print "[mapper] send: " + ";;".join(room[1:]) + "@@\n"
                    mapperHandler.send(";;".join(room[1:]) + "@@\n")

                return ""
                ## no need to return
                #return "[-{}-]{}\r\n".format(exp.code, ";;".join(room[1:5] + [room[7]]))

        return "[-{}-]{}\r\n".format(exp.code, exp.content)
Beispiel #5
0
def make_ansi_style(pallette):
    style = {'NO_COLOR': '0'}
    for name, t in BASE_COLORS.items():
        closest = find_closest(t, pallette)
        if len(closest) == 3:
            closest = ''.join([a*2 for a in closest])
        short = rgb2short(closest)[0]
        style[name] = '38;5;' + short
        style['BOLD_'+name] = '1;38;5;' + short
        style['UNDERLINE_'+name] = '4;38;5;' + short
        style['BOLD_UNDERLINE_'+name] = '1;4;38;5;' + short
        style['BACKGROUND_'+name] = '48;5;' + short
    return style
Beispiel #6
0
def view_list_issues(username: str, repos: str):
    try:
        g = c.get('GITHUB')
        issues = g.get_user(username).get_repo(repos).get_issues()
        for issue in issues:
            state_icon = u':shit:'
            if issue.state == 'open':
                state = color_field('state_open', state_icon)
            elif issue.state == 'closed':
                state = color_field('state_closed', state_icon)
            else:
                state = default(state_icon)

            title = color_field('title', issue.title)
            if int(issue.comments) > 0:
                comments = ':speech_balloon: {}'.format(issue.comments)
                comments = color_field('comments', comments)
            else:
                comments = ''
            number = color_field('number', '#{}'.format(issue.number))
            created = color_field('created', issue.created_at)
            user = color_field('user', issue.user.login)
            if issue.assignee:
                assignee = ':bow: {}'.format(issue.assignee.login)
                assignee = color_field('assignee', assignee)
            else:
                assignee = ''

            list_labels = []
            for l in issue.labels:
                term_color = rgb2short(l.color)[0]
                text_color = get_contrast(l.color)
                label = color_256(term_color, bg=True)(text_color(l.name))
                list_labels.append(label)
            labels = ' '.join(list_labels)

            template = ('{state} {title} {labels}  {assignee}  {comments}\n'
                        '  {number} opened {created} by {user}')
            info = template.format(state=state, title=title, labels=labels,
                                   comments=comments, number=number,
                                   created=created, user=user,
                                   assignee=assignee)
            print(emoji.emojize(info), '\n')
    except KeyError as err:
        print(err)
    except UnknownObjectException:
        print('Can\'t get issues for {}/{}'.format(username, repos))
Beispiel #7
0
def my_issues(*args, **kwagrs):
    g = c.get('GITHUB')
    for issue in g.get_user().get_issues():
        state_icon = u':shit:'
        if issue.state == 'open':
            state = color_field('state_open', state_icon)
        elif issue.state == 'closed':
            state = color_field('state_closed', state_icon)
        else:
            state = default(state_icon)

        repos = color_field('repos', issue.repository.full_name)
        title = color_field('title', issue.title)
        if int(issue.comments) > 0:
            comments = ':speech_balloon: {}'.format(issue.comments)
            comments = color_field('comments', comments)
        else:
            comments = ''
        number = color_field('number', '#{}'.format(issue.number))
        created = color_field('created', issue.created_at)
        user = color_field('user', issue.user.login)

        list_labels = []
        for l in issue.labels:
            term_color = rgb2short(l.color)[0]
            text_color = get_contrast(l.color)
            label = color_256(term_color, bg=True)(text_color(l.name))
            list_labels.append(label)
        labels = ' '.join(list_labels)

        template = ('{state} {repos} {title} {labels}  {comments}\n'
                    '  {number} opened {created} by {user}')
        info = template.format(state=state, repos=repos, title=title,
                               comments=comments, number=number,
                               created=created, user=user, labels=labels)
        print(emoji.emojize(info), '\n')
import sys
import os
import subprocess
import colortrans

f = open('list.txt', 'r+')
r = open('mylight_copy.vim', 'r+').read()
# target = open('output.txt', 'w')
# target = open('output.txt', 'w')

for line in f:
    # r = open('mylight_copy.vim', 'r+').read()
    s = colortrans.rgb2short(line)
    # r = r.replace(str('#' + s[1]).upper(), str(s[0]))
    # r = r.replace(str('#' + s[1]).lower(), str(s[0]))
    print s
    # target.write(r)
    # target.close()

# target.write(r)
    
    # print s[1].upper()
    
# out_file = open(outp, "w")
# sub = subprocess.call(['sed', 's/\"//g', inp], stdout=out_file )
#
# import sys
# import os
# import subprocess
#
# files = os.listdir(sys.argv[1])
Beispiel #9
0
 def hex2bash(self, hex_color):
     return colortrans.rgb2short(hex_color)
Beispiel #10
0
 def hex2bash(self, hex_color):
     return colortrans.rgb2short(hex_color)
Beispiel #11
0
import json
import os

home = os.environ['HOME']
 
# open the current config.json and potentially overwrite the right values
colorjsonfile = '{}/.config/powerline/colors.json'.format(home)
with open(colorjsonfile) as pywaljsonfile:	
	pywaljson = json.load(pywaljsonfile)

# read the pywal cache file
pywalcolors = open('{}/.cache/wal/colors'.format(home), "r")
i = 0
for row in pywalcolors:
	# clean up the color
	colorstring = row.strip()
	# remove the hashtag
	colorstring = colorstring.lstrip('#')
	# convert it to short
	colorshort = colortrans.rgb2short(colorstring)[0]
	# print the color
	print(colorshort)
	# overwrite the setting in the json file
	colorname = 'pywal'+str(i)
	pywaljson['colors'][colorname] = int(colorshort)
	i = i+1

# write the json object back to the file
with open(colorjsonfile, 'w') as outfile:
	json.dump(pywaljson, outfile)