Parse a SWF file for URLs.
184051
def parse_swf (url_data):
    """"""
    linkfinder = linkparse.swf_url_re.finditer
    for mo in linkfinder(url_data.get_content()):
        url = mo.group()
        url_data.add_url(url)
652486
def read(cls, f):
    """"""
    header = WETHeader.read(f)
    if header is None:
      # EOF
      return None
    content = f.read(header.length)

    # Consume empty separators
    f.readline()
    f.readline()

    return cls(header.url, content)
907420
def parse_url(self):
        """"""
        url = urlparse(self.url).path

        # handle git
        url = url.split('.git')[0]

        if ':' in url:
            url = url.split(':')[1]

        # Ony capture last two list items
        try:
            project, repo = url.split('/')[-2:]
        except ValueError:
            raise ParserError('"{}" is not a valid repository URL.'.format(self.url))

        return project, repo
826723
def handle_url(url, session, res):
    """"""
    print("Parsing", url, file=sys.stderr)
    try:
        data = getPageContent(url, session)
    except IOError as msg:
        print("ERROR:", msg, file=sys.stderr)
        return
    for match in url_matcher.finditer(data):
        url = match.group(1)
        name = unescape(match.group(2))
        name = asciify(name.replace('&', 'And').replace('@', 'At'))
        name = capfirst(name)
        if name in exclude_comics:
            continue
        if contains_case_insensitive(res, name):
            # we cannot handle two comics that only differ in case
            print("INFO: skipping possible duplicate", repr(name), file=sys.stderr)
            continue
        res[name] = url
250878
def handle_url(url, session, res):
    """"""
    print("Parsing", url, file=sys.stderr)
    try:
        data = getPageContent(url, session)
    except IOError as msg:
        print("ERROR:", msg, file=sys.stderr)
        return
    for match in url_matcher.finditer(data):
        comicurl = match.group(1)
        name = format_name(comicurl.split('.', 1)[0][7:])
        if name in exclude_comics:
            continue
        if contains_case_insensitive(res, name):
            # we cannot handle two comics that only differ in case
            print("INFO: skipping possible duplicate", repr(name), file=sys.stderr)
            continue
        # find out how many images this comic has
        end = match.end()
        mo = num_matcher.search(data[end:])
        if not mo:
            print("ERROR matching number:", repr(data[end:end+300]), file=sys.stderr)
            continue
        num = int(mo.group(1))
        # find activity
        mo = activity_matcher.search(data[end:])
        if not mo:
            print("ERROR matching activity:", repr(data[end:end+300]), file=sys.stderr)
            continue
        active = mo.group(1).lower() == "active"
        res[name] = [comicurl, num, active]
    if not res:
        print("ERROR:", "did not match any comics", file=sys.stderr)
775416
def parse_torrent_file(torrent):
    """"""
    link_re = re.compile(r'^(http?s|ftp)')
    if link_re.match(torrent):
        response = requests.get(torrent, headers=HEADERS, timeout=20)
        data = parse_torrent_buffer(response.content)
    elif os.path.isfile(torrent):
        with open(torrent, 'rb') as f:
            data = parse_torrent_buffer(f.read())
    else:
        data = None
    return data
1082893
def parse_file(self,filename):
        """"""
        try:
            return self.rProgram.ignore(cStyleComment).parseFile(filename, parseAll=True)
        except SemanticException as err:
            print(err)
            exit(3)
        except ParseException as err:
            print(err)
            exit(3)
1188080
function parse(url) {
  ['?', '#'].forEach(function(separator) {
    var index = url.indexOf(separator);
    if (index !== -1) url = url.substring(0, index);
  });
  return url;
}
504479
def parse_url(url):
    
    try:
        url = unicode(url)
    except UnicodeDecodeError:
        pass

    if py3k:
        make_utf8 = lambda x: x
    else:
        make_utf8 = lambda x: isinstance(x, unicode) and x.encode('utf-8') or x

    if '://' in url:
        scheme, url = url.split('://', 1)
    else:
        scheme = 'http'
    url = 'http://' + url
    parsed = urlparse.urlsplit(url)
    r = ObjectDict()
    r['scheme'] = make_utf8(scheme)
    r['netloc'] = make_utf8(parsed.netloc)
    r['path'] = make_utf8(parsed.path)
    r['query'] = make_utf8(parsed.query)
    r['fragment'] = make_utf8(parsed.fragment)
    r['uri'] = make_utf8(parsed.path)
    if parsed.query:
        r['uri'] += '?' + make_utf8(parsed.query)
    r['username'] = make_utf8(parsed.username)
    r['password'] = make_utf8(parsed.password)
    host = make_utf8(parsed.hostname.encode('idna').decode('utf-8'))
    r['host'] = r['hostname'] = host
    try:
        r['port'] = parsed.port
    except ValueError:
        r['port'] = None
    if r['port']:
        r['http_host'] = '%s:%d' % (r['host'], r['port'])
    else:
        r['http_host'] = r['host']

    return r
388879
def url_read_text(url, verbose=True):
    
    """
    data = url_read(url, verbose)
    text = data.decode('utf8')
    return text
1301528
def parse_safari (url_data):
    """"""
    from ..bookmarks.safari import parse_bookmark_data
    for url, name in parse_bookmark_data(url_data.get_content()):
        url_data.add_url(url, name=name)
644726
private void parseRenameFile(List<String> lines, URL url) {
        // format allows multiple [types] and [enums] so file can be merged
        boolean types = false;
        boolean enums = false;
        for (String line : lines) {
            try {
                if (line.equals("[types]")) {
                    types = true;
                    enums = false;
                } else if (line.equals("[enums]")) {
                    types = false;
                    enums = true;
                } else if (types) {
                    int equalsPos = line.indexOf('=');
                    if (equalsPos < 0) {
                        throw new IllegalArgumentException(
                                "Renamed.ini type line must be formatted as 'oldClassName = newClassName'");
                    }
                    String oldName = line.substring(0, equalsPos).trim();
                    String newName = line.substring(equalsPos + 1).trim();
                    Class<?> newClass = null;
                    try {
                        newClass = StringConvert.loadType(newName);
                    } catch (Throwable ex) {
                        if (LOG) {
                            ex.printStackTrace(System.err);
                        }
                        throw new IllegalArgumentException(
                                "Class.forName(" + newName + ") failed: " + ex.getMessage());
                    }
                    renamedType(oldName, newClass);
                } else if (enums) {
                    int equalsPos = line.indexOf('=');
                    int lastDotPos = line.lastIndexOf('.');
                    if (equalsPos < 0 || lastDotPos < 0 || lastDotPos < equalsPos) {
                        throw new IllegalArgumentException(
                                "Renamed.ini enum line must be formatted as 'oldEnumConstantName = enumClassName.newEnumConstantName'");
                    }
                    String oldName = line.substring(0, equalsPos).trim();
                    String enumClassName = line.substring(equalsPos + 1, lastDotPos).trim();
                    String enumConstantName = line.substring(lastDotPos + 1).trim();
                    @SuppressWarnings("rawtypes")
                    Class<? extends Enum> enumClass = Class.forName(enumClassName).asSubclass(Enum.class);
                    @SuppressWarnings("unchecked")
                    Enum<?> newEnum = Enum.valueOf(enumClass, enumConstantName);
                    renamedEnum(oldName, newEnum);
                } else {
                    throw new IllegalArgumentException("Renamed.ini must start with [types] or [enums]");
                }
            } catch (Exception ex) {
                // always print message, and then continue
                System.err.println("ERROR: Invalid Renamed.ini: " + url + ": " + ex.getMessage());
            }
        }
    }
79451
def filename_from_url(url):
    """"""
    fname = os.path.basename(urlparse.urlparse(url).path)
    if len(fname.strip(" \n\t.")) == 0:
        return None
    return fname
449610
def parse_file(self, filename, encoding=None, debug=False):
        """"""
        stream = codecs.open(filename, "r", encoding)
        try:
            return self.parse_stream(stream, debug)
        finally:
            stream.close()
708210
def urlparse(uri):
    """"""
    scheme, netloc, path, params, query, fragment = parse.urlparse(uri)
    return (
        parse.unquote(scheme),
        parse.unquote(netloc),
        parse.unquote(path),
        parse.unquote(params),
        parse.unquote(query),
        parse.unquote(fragment)
    )
809790
def parse_url(url):
    
    if url.startswith(('http', 'https', '//')):
        if url.startswith('//'):
            return urlparse.urlparse(url, scheme='http')
        else:
            return urlparse.urlparse(url)
    else:
        return urlparse.urlparse(urlparse.urljoin('http://', url))
443872
def url_or_file_open(uri):
    """"""
    if (not re.match(r'''\w+:''', uri)):
        uri = 'file:' + uri
    return(urlopen(uri))