Parse a Chromium or Google Chrome bookmark file.
764939
def parse_chromium (url_data):
    """"""
    from ..bookmarks.chromium import parse_bookmark_data
    for url, name in parse_bookmark_data(url_data.get_content()):
        url_data.add_url(url, name=name)
642345
def parse_href(href):
    """"""
    url = urlparse(href)
    path = url.path.split('/')
    collection_name = path[1]
    id_ = path[2]
    return collection_name, id_
1201183
def read_links(self, file, encoding=None):
        '''
        '''
        return [item[0] for item in self.iter_text(file, encoding) if item[1]]
370820
def parse(filename):
    """"""
    with open(filename) as f:
        parser = ASDLParser()
        return parser.parse(f.read())
955141
def read(self, source_path):
        """"""

        self._metadata = {}
        with pelican_open(source_path) as text:
            content = creole2html(text, macros={'header': self._parse_header_macro,
                                            'code': self._parse_code_macro})
        return content, self._metadata
751605
def parse file_path
      File.new(file_path).readlines.each {|line| parse_a_bookmark line }
      @total = @bookmarks.size
    end
2865
def parse(self):
        
        try:
            if not os.path.getsize(self.ns.pathname):
                # Ignore 0-byte dummy files (Firefox creates these while downloading)
                self.job.LOG.warn("Ignoring 0-byte metafile '%s'" % (self.ns.pathname,))
                return
            self.metadata = metafile.checked_open(self.ns.pathname)
        except EnvironmentError as exc:
            self.job.LOG.error("Can't read metafile '%s' (%s)" % (
                self.ns.pathname, str(exc).replace(": '%s'" % self.ns.pathname, ""),
            ))
            return
        except ValueError as exc:
            self.job.LOG.error("Invalid metafile '%s': %s" % (self.ns.pathname, exc))
            return

        self.ns.info_hash = metafile.info_hash(self.metadata)
        self.ns.info_name = self.metadata["info"]["name"]
        self.job.LOG.info("Loaded '%s' from metafile '%s'" % (self.ns.info_name, self.ns.pathname))

        # Check whether item is already loaded
        try:
            name = self.job.proxy.d.name(self.ns.info_hash, fail_silently=True)
        except xmlrpc.HashNotFound:
            pass
        except xmlrpc.ERRORS as exc:
            if exc.faultString != "Could not find info-hash.":
                self.job.LOG.error("While checking for #%s: %s" % (self.ns.info_hash, exc))
                return
        else:
            self.job.LOG.warn("Item #%s '%s' already added to client" % (self.ns.info_hash, name))
            return

        return True
1159938
def parse_html(infile, xpath):
    """"""
    if not isinstance(infile, lh.HtmlElement):
        infile = lh.fromstring(infile)
    infile = infile.xpath(xpath)
    if not infile:
        raise ValueError('XPath {0} returned no results.'.format(xpath))
    return infile
401251
def read(self, source_path):
        
        with pelican_open(source_path) as text:
            text_lines = list(text.splitlines())

        header, content = self._separate_header_and_content(text_lines)
        metadatas = self._parse_metadatas(header)
        metadatas_processed = {
            key
            : self.process_metadata(key, value)
            for key, value in metadatas.items()
        }
        content_html = convert_html("\n".join(content),
                                    highlight=self.code_highlight)
        return content_html, metadatas_processed
983737
def Parse(self, stat, file_object, knowledge_base):
    """"""
    _ = knowledge_base
    # TODO(user): Convert this to use the far more intelligent plaso parser.
    chrome = ChromeParser(file_object)
    for timestamp, entry_type, url, data1, _, _ in chrome.Parse():
      if entry_type == "CHROME_DOWNLOAD":
        yield rdf_webhistory.BrowserHistoryItem(
            url=url,
            domain=urlparse.urlparse(url).netloc,
            access_time=timestamp,
            program_name="Chrome",
            source_path=file_object.Path(),
            download_path=data1)
      elif entry_type == "CHROME_VISIT":
        yield rdf_webhistory.BrowserHistoryItem(
            url=url,
            domain=urlparse.urlparse(url).netloc,
            access_time=timestamp,
            program_name="Chrome",
            source_path=file_object.Path(),
            title=data1)
139337
def read(cls, file):
        """"""
        parser = WebVTTParser().read(file)
        return cls(file=file, captions=parser.captions, styles=parser.styles)
507209
def load_bookmark(self, slot_num):
        """"""
        bookmarks = CONF.get('editor', 'bookmarks')
        if slot_num in bookmarks:
            filename, line_num, column = bookmarks[slot_num]
        else:
            return
        if not osp.isfile(filename):
            self.last_edit_cursor_pos = None
            return
        self.load(filename)
        editor = self.get_current_editor()
        if line_num < editor.document().lineCount():
            linelength = len(editor.document()
                             .findBlockByNumber(line_num).text())
            if column <= linelength:
                editor.go_to_line(line_num + 1, column)
            else:
                # Last column
                editor.go_to_line(line_num + 1, linelength)
87916
def Parse(self, stat, file_object, knowledge_base):
    """"""
    _, _ = stat, knowledge_base
    # TODO(user): Convert this to use the far more intelligent plaso parser.
    ie = IEParser(file_object)
    for dat in ie.Parse():
      yield rdf_webhistory.BrowserHistoryItem(
          url=dat["url"],
          domain=urlparse.urlparse(dat["url"]).netloc,
          access_time=dat.get("mtime"),
          program_name="Internet Explorer",
          source_urn=file_object.urn)
736413
def parse_from_file(file_object):
    

    logger.info('Parsing %s file.', file_object.file_name)

    # Read the files
    doc_content = file_object.read_file('document.xml')

    # Parse the document
    document = parse_document(doc_content)

    try:
        style_content = file_object.read_file('styles.xml')
        parse_style(document, style_content)
    except KeyError:
        logger.warning('Could not read styles.')

    try:
        doc_rel_content = file_object.read_file('_rels/document.xml.rels')
        parse_relationship(document, doc_rel_content, 'document')
    except KeyError:
        logger.warning('Could not read document relationships.')

    try:
        doc_rel_content = file_object.read_file('_rels/endnotes.xml.rels')
        parse_relationship(document, doc_rel_content, 'endnotes')
    except KeyError:
        logger.warning('Could not read endnotes relationships.')

    try:
        doc_rel_content = file_object.read_file('_rels/footnotes.xml.rels')
        parse_relationship(document, doc_rel_content, 'footnotes')
    except KeyError:
        logger.warning('Could not read footnotes relationships.')

    try:
        comments_content = file_object.read_file('comments.xml')
        parse_comments(document, comments_content)
    except KeyError:
        logger.warning('Could not read comments.')

    try:
        footnotes_content = file_object.read_file('footnotes.xml')
        parse_footnotes(document, footnotes_content)
    except KeyError:
        logger.warning('Could not read footnotes.')

    try:
        endnotes_content = file_object.read_file('endnotes.xml')
        parse_endnotes(document, endnotes_content)
    except KeyError:
        logger.warning('Could not read endnotes.')

    try:
        numbering_content = file_object.read_file('numbering.xml')
        parse_numbering(document, numbering_content)
    except KeyError:
        logger.warning('Could not read numbering.')

    return document
819402
def parse_magnet(magnet_uri):
    """"""
    data = defaultdict(list)
    if not magnet_uri.startswith('magnet:'):
        return data
    else:
        magnet_uri = magnet_uri.strip('magnet:?')
        for segment in magnet_uri.split('&'):
            key, value = segment.split('=')
            if key == 'dn':
                data['name'] = requests.utils.unquote(value).replace('+', '.')
            elif key == 'xt':
                data['infoHash'] = value.strip('urn:btih:')
            elif key == 'tr':
                data['trackers'].append(requests.utils.unquote(value))
            else:
                data[key] = value
    return data
1155467
def findBookmark(self, bookmark):
        """"""
        if self.isClosed or self.isEncrypted:
            raise ValueError("operation illegal for closed / encrypted doc")

        return _fitz.Document_findBookmark(self, bookmark)
656274
def find_bookmark_file (profile="Default"):
    
    try:
        dirname = os.path.join(get_profile_dir(), profile)
        if os.path.isdir(dirname):
            fname = os.path.join(dirname, "Bookmarks")
            if os.path.isfile(fname):
                return fname
    except Exception:
        pass
    return u""