def get_packages_from_stdin(): """Return packages found from standard input""" input_lines = piped_in() if input_lines is not None: return get_pypi_packages(input_lines) else: return []
def main(): packages = [] args = sys.argv[1:] input_lines = None and piped_in() try: opts, pkgs = getopt(args, "vhr:u:", ["version", "help", "requirement", "user"]) except GetoptError as e: puts(str(e), stream=STDERR) usage(error=True) sys.exit(2) packages += pkgs packages += process_options(opts) if input_lines is not None: # Add packages found from standard input packages += get_pypi_packages(input_lines) elif not args: # Return error if no arguments given usage(error=True) sys.exit(2) for package in packages: if valid_package(package): links = get_links(package) symbol = red('\u2717') if links else green('\u2713') msg = "%s %s: %s links" % (symbol, blue(package), len(links)) print(msg) else: symbol = red('\u2717') print("%s %s: not found on PyPI" % (symbol, blue(package)), file=sys.stderr)
def main(): line = piped_in() old, new, ref = line.strip().split(' ') project_name = os.getcwd().split('/')[-1] env = os.environ pip_mirror = env['PIP_MIRROR'] if 'PIP_MIRROR' in env else DEF_MIRROR socket = env['BUILD_SOCKET'] if 'BUILD_SOCKET' in env else DEF_SOCKET build(project_name, new, socket, pip_mirror)
def main(): pipe = piped_in() commands = { 'count': _count, 'first': _first, 'last': _last, 'select': _select, 'skip': _skip, 'skipwhile': _skip_while, 'take': _take, 'takewhile': _take_while, 'where': _where, } if pipe is None: show_help("No data", commands) exit(1) if len(argv) <= 1: show_help("No command", commands) exit(1) command = argv[1].lower() lines = pipe.splitlines() if command in commands: try: commands[command](argv[2:], lines) except Exception as exception: with StdoutToStderr(): print("Something went wrong when executing '%s'" % command) print(exception) exit(1) else: show_help("Unknown command: %s" % command, commands) exit(1)
#!/usr/bin/env python # -*- coding: utf-8 -*- import sys import os from __future__ import with_statement sys.path.insert(0, os.path.abspath('..')) from clint import piped_in from clint.textui import colored, indent, puts if __name__ == '__main__': in_data = piped_in() with indent(4, quote='>>>'): if in_data: puts('Data was piped in! Here it is:') with indent(5, quote=colored.red(' |')): puts(in_data) else: puts(colored.red('Warning: ') + 'No data was piped in.')
#!/usr/bin/env python # -*- coding: utf-8 -*- from __future__ import with_statement import sys import os sys.path.insert(0, os.path.abspath('..')) from clint import piped_in from clint.textui import colored, indent, puts if __name__ == '__main__': in_data = piped_in() with indent(4, quote='>>>'): if in_data: puts('Data was piped in! Here it is:') with indent(5, quote=colored.red(' |')): puts(in_data) else: puts(colored.red('Warning: ') + 'No data was piped in.')
puts(colored.yellow('سلام')) puts(colored.magenta('안녕하세요')) puts(colored.blue('नमस्ते')) puts(colored.cyan('γειά σου')) puts('') puts('Arguments:') with indent(4): puts('%s' % colored.red(args[0])) puts('') puts('File:') with indent(4): f = args.files[0] puts(colored.yellow('%s:' % f)) with indent(2): fd = codecs.open(f, encoding='utf-8') for line in fd: line = line.strip('\n\r') puts(colored.yellow(' %s' % line)) fd.close() puts('') puts('Input:') with indent(4): in_data = json.loads(piped_in()) title = in_data['title'] text = in_data['text'] puts(colored.blue('Title: %s' % title)) puts(colored.magenta('Text: %s' % text))