#! /usr/bin/python3

#
# WARNING! Do not edit this file!
#

import os
import sys
import vim
import importlib
import subprocess


PREFIX = "__SNAKE_CASE_PLACEHOLDER__"
APP_DIR = vim.eval("s:_" + PREFIX + "_pivvy_plugin_dir") + "/.."
BUNDLE_DIR = vim.eval("s:_" + PREFIX + "_pivvy_plugin_dir") + "/../bundle"
PLUGIN_LOADED = bool(
    int(vim.eval("exists('g:_" + PREFIX + "_plugin_loaded')")))
DEVELOPER_MODE = bool(
    int(vim.eval("exists('g:_" + PREFIX + "_developer_mode')")))
USE_BUNDLE = not bool(int(vim.eval("exists('g:_" + PREFIX + "_no_bundle')")))

# Make sure this project is importable
sys.path.insert(0, APP_DIR)

if USE_BUNDLE:
    sys.path.insert(0, BUNDLE_DIR)

import pivvy

if DEVELOPER_MODE:
    # Imports are cached between bootstrap executions,
    # so make sure they are reloaded when hacking
    importlib.reload(pivvy)
    pivvy._reload()


pivvy.PREFIX = PREFIX

if not PLUGIN_LOADED or DEVELOPER_MODE:
    unresolved_dependencies = []

    with open(APP_DIR + "/requirements.txt", "r") as f:
        for requirement in f.readlines():
            dependency, version = requirement.strip().split("==")
            if importlib.find_loader(dependency) is None:
                unresolved_dependencies.append((dependency, version))

    if unresolved_dependencies:
        unresolved_dependencies_str = ", ".join(
            x[0] + " " + x[1] for x in unresolved_dependencies)
        print(
            "Plugin '__REGULAR_PLACEHOLDER__' has the following "
            "unresolved dependencies: " + unresolved_dependencies_str,
            file=sys.stderr)
        auto_resolve = pivvy.confirm(
            "I can try to resolve these dependencies myself, "
            "using pip, do you want me to do that?")
        if auto_resolve == 1:
            locally = pivvy.confirm(
                "Will now try to install " + unresolved_dependencies_str +
                " using pip. Where do you want to install the package(s)?",
                ["Plugin directory", "Globally (requires sudo)"])
            pip_command = ["pip", "install"]
            pkg_names = [x[0] for x in unresolved_dependencies]
            try:
                if locally == 1:
                    subprocess.call(
                        pip_command + ["--target=" + BUNDLE_DIR] + pkg_names)
                elif locally == 2:
                    subprocess.call(["sudo"] + pip_command + pkg_names)
            except OSError as e:
                if e.errno == os.errno.ENOENT:
                    print("Failed to locate pip!", file=sys.stderr)
                else:
                    raise e
            pivvy.command.redraw_bang()

try:
    import application

    if DEVELOPER_MODE:
        importlib.reload(application)

    if not PLUGIN_LOADED or DEVELOPER_MODE:
        application.on_load()
except ImportError as e:
    print(e, file=sys.stderr)

207e94d4186ea3b9dee9ab585921ebbceaf311ab
<mask token>

<mask token>
sys.path.insert(0, APP_DIR)
if USE_BUNDLE:
    sys.path.insert(0, BUNDLE_DIR)
<mask token>
if DEVELOPER_MODE:
    importlib.reload(pivvy)
    pivvy._reload()
<mask token>
if not PLUGIN_LOADED or DEVELOPER_MODE:
    unresolved_dependencies = []
    with open(APP_DIR + '/requirements.txt', 'r') as f:
        for requirement in f.readlines():
            dependency, version = requirement.strip().split('==')
            if importlib.find_loader(dependency) is None:
                unresolved_dependencies.append((dependency, version))
    if unresolved_dependencies:
        unresolved_dependencies_str = ', '.join(x[0] + ' ' + x[1] for x in
            unresolved_dependencies)
        print(
            "Plugin '__REGULAR_PLACEHOLDER__' has the following unresolved dependencies: "
             + unresolved_dependencies_str, file=sys.stderr)
        auto_resolve = pivvy.confirm(
            'I can try to resolve these dependencies myself, using pip, do you want me to do that?'
            )
        if auto_resolve == 1:
            locally = pivvy.confirm('Will now try to install ' +
                unresolved_dependencies_str +
                ' using pip. Where do you want to install the package(s)?',
                ['Plugin directory', 'Globally (requires sudo)'])
            pip_command = ['pip', 'install']
            pkg_names = [x[0] for x in unresolved_dependencies]
            try:
                if locally == 1:
                    subprocess.call(pip_command + ['--target=' + BUNDLE_DIR
                        ] + pkg_names)
                elif locally == 2:
                    subprocess.call(['sudo'] + pip_command + pkg_names)
            except OSError as e:
                if e.errno == os.errno.ENOENT:
                    print('Failed to locate pip!', file=sys.stderr)
                else:
                    raise e
            pivvy.command.redraw_bang()
try:
    import application
    if DEVELOPER_MODE:
        importlib.reload(application)
    if not PLUGIN_LOADED or DEVELOPER_MODE:
        application.on_load()
except ImportError as e:
    print(e, file=sys.stderr)

<mask token>
PREFIX = '__SNAKE_CASE_PLACEHOLDER__'
APP_DIR = vim.eval('s:_' + PREFIX + '_pivvy_plugin_dir') + '/..'
BUNDLE_DIR = vim.eval('s:_' + PREFIX + '_pivvy_plugin_dir') + '/../bundle'
PLUGIN_LOADED = bool(int(vim.eval("exists('g:_" + PREFIX + "_plugin_loaded')"))
    )
DEVELOPER_MODE = bool(int(vim.eval("exists('g:_" + PREFIX +
    "_developer_mode')")))
USE_BUNDLE = not bool(int(vim.eval("exists('g:_" + PREFIX + "_no_bundle')")))
sys.path.insert(0, APP_DIR)
if USE_BUNDLE:
    sys.path.insert(0, BUNDLE_DIR)
<mask token>
if DEVELOPER_MODE:
    importlib.reload(pivvy)
    pivvy._reload()
pivvy.PREFIX = PREFIX
if not PLUGIN_LOADED or DEVELOPER_MODE:
    unresolved_dependencies = []
    with open(APP_DIR + '/requirements.txt', 'r') as f:
        for requirement in f.readlines():
            dependency, version = requirement.strip().split('==')
            if importlib.find_loader(dependency) is None:
                unresolved_dependencies.append((dependency, version))
    if unresolved_dependencies:
        unresolved_dependencies_str = ', '.join(x[0] + ' ' + x[1] for x in
            unresolved_dependencies)
        print(
            "Plugin '__REGULAR_PLACEHOLDER__' has the following unresolved dependencies: "
             + unresolved_dependencies_str, file=sys.stderr)
        auto_resolve = pivvy.confirm(
            'I can try to resolve these dependencies myself, using pip, do you want me to do that?'
            )
        if auto_resolve == 1:
            locally = pivvy.confirm('Will now try to install ' +
                unresolved_dependencies_str +
                ' using pip. Where do you want to install the package(s)?',
                ['Plugin directory', 'Globally (requires sudo)'])
            pip_command = ['pip', 'install']
            pkg_names = [x[0] for x in unresolved_dependencies]
            try:
                if locally == 1:
                    subprocess.call(pip_command + ['--target=' + BUNDLE_DIR
                        ] + pkg_names)
                elif locally == 2:
                    subprocess.call(['sudo'] + pip_command + pkg_names)
            except OSError as e:
                if e.errno == os.errno.ENOENT:
                    print('Failed to locate pip!', file=sys.stderr)
                else:
                    raise e
            pivvy.command.redraw_bang()
try:
    import application
    if DEVELOPER_MODE:
        importlib.reload(application)
    if not PLUGIN_LOADED or DEVELOPER_MODE:
        application.on_load()
except ImportError as e:
    print(e, file=sys.stderr)

import os
import sys
import vim
import importlib
import subprocess
PREFIX = '__SNAKE_CASE_PLACEHOLDER__'
APP_DIR = vim.eval('s:_' + PREFIX + '_pivvy_plugin_dir') + '/..'
BUNDLE_DIR = vim.eval('s:_' + PREFIX + '_pivvy_plugin_dir') + '/../bundle'
PLUGIN_LOADED = bool(int(vim.eval("exists('g:_" + PREFIX + "_plugin_loaded')"))
    )
DEVELOPER_MODE = bool(int(vim.eval("exists('g:_" + PREFIX +
    "_developer_mode')")))
USE_BUNDLE = not bool(int(vim.eval("exists('g:_" + PREFIX + "_no_bundle')")))
sys.path.insert(0, APP_DIR)
if USE_BUNDLE:
    sys.path.insert(0, BUNDLE_DIR)
import pivvy
if DEVELOPER_MODE:
    importlib.reload(pivvy)
    pivvy._reload()
pivvy.PREFIX = PREFIX
if not PLUGIN_LOADED or DEVELOPER_MODE:
    unresolved_dependencies = []
    with open(APP_DIR + '/requirements.txt', 'r') as f:
        for requirement in f.readlines():
            dependency, version = requirement.strip().split('==')
            if importlib.find_loader(dependency) is None:
                unresolved_dependencies.append((dependency, version))
    if unresolved_dependencies:
        unresolved_dependencies_str = ', '.join(x[0] + ' ' + x[1] for x in
            unresolved_dependencies)
        print(
            "Plugin '__REGULAR_PLACEHOLDER__' has the following unresolved dependencies: "
             + unresolved_dependencies_str, file=sys.stderr)
        auto_resolve = pivvy.confirm(
            'I can try to resolve these dependencies myself, using pip, do you want me to do that?'
            )
        if auto_resolve == 1:
            locally = pivvy.confirm('Will now try to install ' +
                unresolved_dependencies_str +
                ' using pip. Where do you want to install the package(s)?',
                ['Plugin directory', 'Globally (requires sudo)'])
            pip_command = ['pip', 'install']
            pkg_names = [x[0] for x in unresolved_dependencies]
            try:
                if locally == 1:
                    subprocess.call(pip_command + ['--target=' + BUNDLE_DIR
                        ] + pkg_names)
                elif locally == 2:
                    subprocess.call(['sudo'] + pip_command + pkg_names)
            except OSError as e:
                if e.errno == os.errno.ENOENT:
                    print('Failed to locate pip!', file=sys.stderr)
                else:
                    raise e
            pivvy.command.redraw_bang()
try:
    import application
    if DEVELOPER_MODE:
        importlib.reload(application)
    if not PLUGIN_LOADED or DEVELOPER_MODE:
        application.on_load()
except ImportError as e:
    print(e, file=sys.stderr)

#! /usr/bin/python3

#
# WARNING! Do not edit this file!
#

import os
import sys
import vim
import importlib
import subprocess


PREFIX = "__SNAKE_CASE_PLACEHOLDER__"
APP_DIR = vim.eval("s:_" + PREFIX + "_pivvy_plugin_dir") + "/.."
BUNDLE_DIR = vim.eval("s:_" + PREFIX + "_pivvy_plugin_dir") + "/../bundle"
PLUGIN_LOADED = bool(
    int(vim.eval("exists('g:_" + PREFIX + "_plugin_loaded')")))
DEVELOPER_MODE = bool(
    int(vim.eval("exists('g:_" + PREFIX + "_developer_mode')")))
USE_BUNDLE = not bool(int(vim.eval("exists('g:_" + PREFIX + "_no_bundle')")))

# Make sure this project is importable
sys.path.insert(0, APP_DIR)

if USE_BUNDLE:
    sys.path.insert(0, BUNDLE_DIR)

import pivvy

if DEVELOPER_MODE:
    # Imports are cached between bootstrap executions,
    # so make sure they are reloaded when hacking
    importlib.reload(pivvy)
    pivvy._reload()


pivvy.PREFIX = PREFIX

if not PLUGIN_LOADED or DEVELOPER_MODE:
    unresolved_dependencies = []

    with open(APP_DIR + "/requirements.txt", "r") as f:
        for requirement in f.readlines():
            dependency, version = requirement.strip().split("==")
            if importlib.find_loader(dependency) is None:
                unresolved_dependencies.append((dependency, version))

    if unresolved_dependencies:
        unresolved_dependencies_str = ", ".join(
            x[0] + " " + x[1] for x in unresolved_dependencies)
        print(
            "Plugin '__REGULAR_PLACEHOLDER__' has the following "
            "unresolved dependencies: " + unresolved_dependencies_str,
            file=sys.stderr)
        auto_resolve = pivvy.confirm(
            "I can try to resolve these dependencies myself, "
            "using pip, do you want me to do that?")
        if auto_resolve == 1:
            locally = pivvy.confirm(
                "Will now try to install " + unresolved_dependencies_str +
                " using pip. Where do you want to install the package(s)?",
                ["Plugin directory", "Globally (requires sudo)"])
            pip_command = ["pip", "install"]
            pkg_names = [x[0] for x in unresolved_dependencies]
            try:
                if locally == 1:
                    subprocess.call(
                        pip_command + ["--target=" + BUNDLE_DIR] + pkg_names)
                elif locally == 2:
                    subprocess.call(["sudo"] + pip_command + pkg_names)
            except OSError as e:
                if e.errno == os.errno.ENOENT:
                    print("Failed to locate pip!", file=sys.stderr)
                else:
                    raise e
            pivvy.command.redraw_bang()

try:
    import application

    if DEVELOPER_MODE:
        importlib.reload(application)

    if not PLUGIN_LOADED or DEVELOPER_MODE:
        application.on_load()
except ImportError as e:
    print(e, file=sys.stderr)
