# Path: lektor/packages.py
# def get_package_info(path):
#     """Returns the name of a package at a path."""
#     rv = portable_popen([
#         sys.executable,
#         'setup.py', '--quiet', '--name', '--author', '--author-email',
#         '--license', '--url',
#     ], cwd=path, stdout=PIPE).communicate()[0].splitlines()
#     def _process(value):
#         value = value.strip()
#         if value == 'UNKNOWN':
#             return None
#         return value.decode('utf-8', 'replace')
#     return {
#         'name': _process(rv[0]),
#         'author': _process(rv[1]),
#         'author_email': _process(rv[2]),
#         'license': _process(rv[3]),
#         'url': _process(rv[4]),
#         'path': path,
#     }
# 
# def register_package(path):
#     """Registers the plugin at the given path."""
#     portable_popen([
#         sys.executable,
#         'setup.py', 'register'
#     ], cwd=path).wait()
# 
# def publish_package(path):
#     """Registers the plugin at the given path."""
#     portable_popen([
#         sys.executable,
#         'setup.py', 'sdist', 'bdist_wheel', 'upload'
#     ], cwd=path).wait()
# 
# Path: lektor/cli.py
# def echo_json(data):
# def buildflag(cli):
#     def __init__(self):
#     def _get_ui_lang(self):
#     def _set_ui_lang(self, value):
#     def set_project_path(self, value):
#     def get_project(self, silent=False):
#     def get_default_output_path(self):
#     def get_env(self):
#     def load_plugins(self, reinstall=False):
# def validate_language(ctx, param, value):
# def cli(ctx, project=None, language=None):
# def build_cmd(ctx, output_path, watch, prune, verbosity,
#               source_info_only, profile, build_flags):
#     def _build():
# def clean_cmd(ctx, output_path, verbosity):
# def deploy_cmd(ctx, server, output_path, **credentials):
# def server_cmd(ctx, host, port, output_path, verbosity, build_flags, browse):
# def project_info_cmd(ctx, as_json, ops):
# def content_file_info_cmd(ctx, files, as_json):
#     def fail(msg):
# def plugins_cmd():
# def plugins_add_cmd(ctx, name):
# def plugins_remove_cmd(ctx, name):
# def plugins_list_cmd(ctx, as_json, verbosity):
# def plugins_flush_cache_cmd(ctx):
# def plugins_reinstall_cmd(ctx):
# def quickstart_cmd(ctx, **options):
# class Context(object):


import os
import sys
import click
    import code
from .packages import get_package_info, register_package, publish_package
from .cli import pass_context
    from lektor.db import F, Tree
    from lektor.builder import Builder
    from .quickstart import plugin_quickstart
        env=ctx.get_env(),
        pad=pad,
        tree=Tree(pad),
        config=ctx.get_env().load_config(),
        make_builder=lambda: Builder(ctx.get_env().new_pad(),
                                     ctx.get_default_output_path()),
        F=F
    )
    code.interact(banner=banner, local=ns)


@cli.command('publish-plugin', short_help='Publish a plugin to PyPI.')
def publish_plugin_cmd():
    """Publishes the current version of the plugin in the current folder.

    This generally requires that your setup.py has at least the bare minimum
    configuration for valid publishing to PyPI.
    """
    info = ensure_plugin()
    for key in 'author', 'author_email', 'license', 'url':
        if not info[key]:
            raise click.UsageError('Cannot publish plugin without setting '
                                   '"%s" in setup.py.' % key)
    register_package(info['path'])
    publish_package(info['path'])


@cli.command('new-plugin', short_help='Creates a new plugin')
@click.option('--path', type=click.Path(), help='The destination path')
@click.argument('plugin_name', required=False)

# Path: lektor/packages.py
# def get_package_info(path):
#     """Returns the name of a package at a path."""
#     rv = portable_popen([
#         sys.executable,
#         'setup.py', '--quiet', '--name', '--author', '--author-email',
#         '--license', '--url',
#     ], cwd=path, stdout=PIPE).communicate()[0].splitlines()
#     def _process(value):
#         value = value.strip()
#         if value == 'UNKNOWN':
#             return None
#         return value.decode('utf-8', 'replace')
#     return {
#         'name': _process(rv[0]),
#         'author': _process(rv[1]),
#         'author_email': _process(rv[2]),
#         'license': _process(rv[3]),
#         'url': _process(rv[4]),
#         'path': path,
#     }
# 
# def register_package(path):
#     """Registers the plugin at the given path."""
#     portable_popen([
#         sys.executable,
#         'setup.py', 'register'
#     ], cwd=path).wait()
# 
# def publish_package(path):
#     """Registers the plugin at the given path."""
#     portable_popen([
#         sys.executable,
#         'setup.py', 'sdist', 'bdist_wheel', 'upload'
#     ], cwd=path).wait()
# 
# Path: lektor/cli.py
# def echo_json(data):
# def buildflag(cli):
#     def __init__(self):
#     def _get_ui_lang(self):
#     def _set_ui_lang(self, value):
#     def set_project_path(self, value):
#     def get_project(self, silent=False):
#     def get_default_output_path(self):
#     def get_env(self):
#     def load_plugins(self, reinstall=False):
# def validate_language(ctx, param, value):
# def cli(ctx, project=None, language=None):
# def build_cmd(ctx, output_path, watch, prune, verbosity,
#               source_info_only, profile, build_flags):
#     def _build():
# def clean_cmd(ctx, output_path, verbosity):
# def deploy_cmd(ctx, server, output_path, **credentials):
# def server_cmd(ctx, host, port, output_path, verbosity, build_flags, browse):
# def project_info_cmd(ctx, as_json, ops):
# def content_file_info_cmd(ctx, files, as_json):
#     def fail(msg):
# def plugins_cmd():
# def plugins_add_cmd(ctx, name):
# def plugins_remove_cmd(ctx, name):
# def plugins_list_cmd(ctx, as_json, verbosity):
# def plugins_flush_cache_cmd(ctx):
# def plugins_reinstall_cmd(ctx):
# def quickstart_cmd(ctx, **options):
# class Context(object):


# Path: lektor/devcli.py
import os
import sys
import click
    import code
from .packages import get_package_info, register_package, publish_package
from .cli import pass_context
    from lektor.db import F, Tree
    from lektor.builder import Builder
    from .quickstart import plugin_quickstart

        env=ctx.get_env(),
        pad=pad,
        tree=Tree(pad),
        config=ctx.get_env().load_config(),
        make_builder=lambda: Builder(ctx.get_env().new_pad(),
                                     ctx.get_default_output_path()),
        F=F
    )
    code.interact(banner=banner, local=ns)


@cli.command('publish-plugin', short_help='Publish a plugin to PyPI.')
def publish_plugin_cmd():
    """Publishes the current version of the plugin in the current folder.

    This generally requires that your setup.py has at least the bare minimum
    configuration for valid publishing to PyPI.
    """
    info = ensure_plugin()
    for key in 'author', 'author_email', 'license', 'url':
        if not info[key]:
            raise click.UsageError('Cannot publish plugin without setting '
                                   '"%s" in setup.py.' % key)
    register_package(info['path'])
    publish_package(info['path'])


@cli.command('new-plugin', short_help='Creates a new plugin')
@click.option('--path', type=click.Path(), help='The destination path')
@click.argument('plugin_name', required=False)

@pass_context