Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
INCLUDE_OPTIONS = ['tap', 'brew', 'cask', 'mas']
BREWFILE_LINE = re.compile(
r"""
^
(?P(tap|brew|cask|mas))\s* # dependency type
"(?P.*)"\s* # name between quotes
(,\s*id:\s*(?P\d\d*)\s*)? # id for mas items
$
""",
re.MULTILINE | re.VERBOSE
)
class Brew(dotbot.Plugin):
_supported_directives = [
'brewfile',
]
_tap_command = 'brew tap homebrew/bundle'
_install_command = 'brew bundle'
# Defaults
_default_filename = 'Brewfile'
_default_stdout = False
_default_stderr = False
_default_include = INCLUDE_OPTIONS
# API methods
def can_handle(self, directive):
import os, platform, subprocess, dotbot
class Brew(dotbot.Plugin):
_brewDirective = "brew"
_caskDirective = "cask"
_tapDirective = "tap"
_brewFileDirective = "brewfile"
def can_handle(self, directive):
return directive in (self._tapDirective, self._brewDirective, self._caskDirective, self._brewFileDirective)
def handle(self, directive, data):
if directive == self._tapDirective:
self._bootstrap_brew()
return self._tap(data)
if directive == self._brewDirective:
self._bootstrap_brew()
return self._process_data("brew install", data)
if directive == self._caskDirective:
import os
import glob
import shutil
import dotbot
import subprocess
class Link(dotbot.Plugin):
'''
Symbolically links dotfiles.
'''
_directive = 'link'
def can_handle(self, directive):
return directive == self._directive
def handle(self, directive, data):
if directive != self._directive:
raise ValueError('Link cannot handle directive %s' % directive)
return self._process_links(data)
def _process_links(self, links):
success = True
import os, subprocess, dotbot
class Shell(dotbot.Plugin):
'''
Run arbitrary shell commands.
'''
_directive = 'shell'
def can_handle(self, directive):
return directive == self._directive
def handle(self, directive, data):
if directive != self._directive:
raise ValueError('Shell cannot handle directive %s' %
directive)
return self._process_commands(data)
def _process_commands(self, data):
import os
import subprocess
import dotbot
class Brew(dotbot.Plugin):
_pipx_directive = 'pipx'
_pipsi_directive = 'pipsi'
_default_binary = 'pip'
# Default outputs
_default_stdout = False
_default_stderr = False
_use_user_directory = False
_supported_directives = [
'pip', # it is not the same as default binary.
_pipsi_directive,
_pipx_directive,
]
# API methods
import os, dotbot
class Clean(dotbot.Plugin):
'''
Cleans broken symbolic links.
'''
_directive = 'clean'
def can_handle(self, directive):
return directive == self._directive
def handle(self, directive, data):
if directive != self._directive:
raise ValueError('Clean cannot handle directive %s' % directive)
return self._process_clean(data)
def _process_clean(self, targets):
success = True