You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
34 lines
761 B
Python
34 lines
761 B
Python
# coding=utf-8
|
|
import os
|
|
import stat
|
|
|
|
TEMPLATE = """\
|
|
Qutebrowser userscript {name!r} was installed at:
|
|
|
|
{path}
|
|
|
|
You can try it out by running the command:
|
|
|
|
:spawn --userscript {path}
|
|
"""
|
|
|
|
|
|
def setup_permissions(path):
|
|
file_stat = os.stat(path)
|
|
os.chmod(path, file_stat.st_mode | stat.S_IXUSR | stat.S_IXGRP | stat.S_IXOTH)
|
|
|
|
|
|
def format_commands(path, name):
|
|
return TEMPLATE.format(path=path, name=name)
|
|
|
|
|
|
def install(path, name=None):
|
|
"""
|
|
Sets permissions for qutescript at path and returns
|
|
instructons and commands to integrate with qutebrowser.
|
|
"""
|
|
path = os.path.abspath(os.path.expanduser(path))
|
|
name = name or os.path.basename(path)
|
|
setup_permissions(path)
|
|
return format_commands(path=path, name=name)
|