Geocode an arbitrary number of strings from Command Line.
512462
def cli(location, **kwargs):
    """"""

    locations = []

    # Read Standard Input
    # $ cat foo.txt | geocode
    try:
        for line in fileinput.input():
            locations.append(line.strip())
    except:
        pass

    # Read multiple files & user input location
    for item in location:
        if os.path.exists(item):
            with open(item, 'rb') as f:
                locations += f.read().splitlines()
        else:
            locations.append(item)

    # Distance calculation
    if kwargs['distance']:
        d = geocoder.distance(locations, **kwargs)
        click.echo(d)
        return

    # Geocode results from user input
    for location in locations:
        g = geocoder.get(location.strip(), **kwargs)
        try:
            click.echo(json.dumps(getattr(g, kwargs['output'])))
        except IOError:
            # When invalid command is entered a broken pipe error occurs
            return
436410
def copy(string, **kwargs):
    """"""
    try:
        subprocess.Popen(['pbcopy'], stdin=subprocess.PIPE).communicate(
                string.encode("utf-8"))
    except OSError as why:
        raise XcodeNotFound

    return
393490
function concatString(lines) {
  var output = ''
  for (var i = 0; i < lines.length; i ++) {
    output += lines[i] + '\n'
  }
  return output
}
224889
def main(args):
    """"""
    filename = args[0]
    marker = args[1]
    for line in fileinput.input(filename, inplace=1):
        print(line.rstrip())
        if line.startswith(marker):
            break
438780
public static void main(final String[] args)
    {
        for (int i = 0; i < 10; i++)
        {
            perfTestEncode(i);
            perfTestDecode(i);
        }
    }
1291095
def copy(string, xsel=False):
    """"""
    try:
        _cmd = ["xclip", "-selection", "clipboard"]
        subprocess.Popen(_cmd, stdin=subprocess.PIPE).communicate(
                string.encode('utf-8'))
        if xsel:
            _cmd = ["xclip", "-selection", "primary"]
            subprocess.Popen(_cmd, stdin=subprocess.PIPE).communicate(
                    string.encode('utf-8'))
    except OSError as why:
        raise XclipNotFound
240892
function stringToRegexp(str, keys, options = {}) {
  let tokens = parse(str, options);
  let end = options.end !== false;
  let strict = options.strict;
  let delimiter = options.delimiter ? escapeString(options.delimiter) : '\\/';
  let delimiters = options.delimiters || './';
  let endsWith = [].concat(options.endsWith || []).map(escapeString).concat('$').join('|');
  let isEndDelimited = false;
  let route = '';

  // Iterate over the tokens and create our regexp string.
  for (let i = 0; i < tokens.length; i++) {
    let token = tokens[i];

    if (typeof token === 'string') {
      route += escapeString(token);
      isEndDelimited = i === tokens.length - 1 && delimiters.includes(token[token.length - 1]);
      continue;
    }

    let prefix = escapeString(token.prefix);
    let capture = token.repeat
      ? `(?:${token.pattern})(?:${prefix}(?:${token.pattern}))*`
      : token.pattern;

    if (keys) keys.push(token);

    if (token.optional) {
      if (token.partial) {
        route += prefix + `(${capture})?`;
      } else {
        route += `(?:${prefix}(${capture}))?`;
      }
    } else {
      route += `${prefix}(${capture})`;
    }
  }

  if (end) {
    if (!strict) route += `(?:${delimiter})?`;

    route += endsWith === '$' ? '$' : `(?=${endsWith})`;
  } else {
    if (!strict) route += `(?:${delimiter}(?=${endsWith}))?`;
    if (!isEndDelimited) route += `(?=${delimiter}|${endsWith})`;
  }

  return `^${route}`;
}
420812
def generate_string(out_dir, limits):
    """"""
    max_limit = max((int(v) for v in limits))

    with open(filename(out_dir, 'string'), 'wb') as out_f:
        with IncludeGuard(out_f):
            out_f.write(
                '\n'
                '#include <boost/metaparse/v{0}/cpp11/impl/concat.hpp>\n'
                '#include <boost/preprocessor/cat.hpp>\n'
                .format(VERSION)
            )

            generate_make_string(out_f, 512)

            out_f.write(
                '\n'
                '#ifndef BOOST_METAPARSE_LIMIT_STRING_SIZE\n'
                '#  error BOOST_METAPARSE_LIMIT_STRING_SIZE not defined\n'
                '#endif\n'
                '\n'
                '#if BOOST_METAPARSE_LIMIT_STRING_SIZE > {0}\n'
                '#  error BOOST_METAPARSE_LIMIT_STRING_SIZE is greater than'
                ' {0}. To increase the limit run tools/string_headers.py of'
                ' Boost.Metaparse against your Boost headers.\n'
                '#endif\n'
                '\n'
                .format(max_limit)
            )

            define_macro(out_f, (
                'STRING',
                ['s'],
                '{0}::make_string< '
                '{0}::take(sizeof(s)-1), sizeof(s)-1-{0}::take(sizeof(s)-1),'
                'BOOST_PP_CAT({1}, BOOST_METAPARSE_LIMIT_STRING_SIZE)(s)'
                '>::type'
                .format(
                    '::boost::metaparse::v{0}::impl'.format(VERSION),
                    macro_name('I')
                )
            ))

            out_f.write('\n')
            for limit in xrange(0, max_limit + 1):
                out_f.write(
                    '#define {0} {1}\n'
                    .format(
                        macro_name('I{0}'.format(limit)),
                        macro_name('INDEX_STR{0}'.format(
                            min(int(l) for l in limits if int(l) >= limit)
                        ))
                    )
                )
            out_f.write('\n')

            prev_macro = None
            prev_limit = 0
            for length_limit in (int(l) for l in limits):
                this_macro = macro_name('INDEX_STR{0}'.format(length_limit))
                out_f.write(
                    '#define {0}(s) {1}{2}\n'
                    .format(
                        this_macro,
                        '{0}(s),'.format(prev_macro) if prev_macro else '',
                        ','.join(
                            '{0}((s), {1})'
                            .format(macro_name('STRING_AT'), i)
                            for i in xrange(prev_limit, length_limit)
                        )
                    )
                )
                prev_macro = this_macro
                prev_limit = length_limit
19849
def ensure_str(text):
    """
    if isinstance(text, unicode):
        try:
            return text.encode(pyreadline_codepage, u"replace")
        except (LookupError, TypeError):
            return text.encode(u"ascii", u"replace")
    return text
107043
def ensure_str(s):
    
    """
    try:
        return s.decode()
    except AttributeError:
        if isinstance(s, str):
            return s
    return repr(s)
570536
def rem_encoding(code):
    """"""
    old_lines = code.splitlines()
    new_lines = []
    for i in range(min(2, len(old_lines))):
        line = old_lines[i]
        if not (line.lstrip().startswith("#") and "coding" in line):
            new_lines.append(line)
    new_lines += old_lines[2:]
    return "\n".join(new_lines)
298410
def keys_values(self):
        """"""
        keys_values = []
        for value in self.keys.values():
            if isinstance(value, list):
                keys_values += value
            elif isinstance(value, basestring) and not value.startswith('-'):
                # Avoid -99. Should be fixed in geozones
                keys_values.append(value)
            elif isinstance(value, int) and value >= 0:
                # Avoid -99. Should be fixed in geozones
                keys_values.append(str(value))
        return keys_values
1003401
def encode(cls, line):
        """"""
        if not line.encoded:
            encoding = getattr(line, 'encoding_param', None)
            if encoding and encoding.upper() == cls.base64string:
                line.value = b64encode(line.value).decode('utf-8')
            else:
                line.value = backslashEscape(str_(line.value))
            line.encoded = True
941126
def _encode_string(string):
    """"""
    if not isinstance(string, bytes):
        string = string.encode('utf8')
    return ffi.new('char[]', string)
428446
def from_command_line(command_line):
    """"""
    assert is_iterable_typed(command_line, basestring)
    targets = []
    properties = []

    for e in command_line:
        if e[:1] != "-":
            # Build request spec either has "=" in it, or completely
            # consists of implicit feature values.
            if e.find("=") != -1 or looks_like_implicit_value(e.split("/")[0]):
                properties.append(e)
            elif e:
                targets.append(e)

    return [targets, properties]
366373
function stringToRegexp (path, keys, options) {
	  var tokens = parse(path)
	  var re = tokensToRegExp(tokens, options)
	
	  // Attach keys back to the regexp.
	  for (var i = 0; i < tokens.length; i++) {
	    if (typeof tokens[i] !== 'string') {
	      keys.push(tokens[i])
	    }
	  }
	
	  return attachKeys(re, keys)
	}
121087
def from_string(cls, s):
        """"""
        stream = cStringIO(s)
        stream.seek(0)
        return cls(**yaml.safe_load(stream))