コード例 #1
0
def _sections_with_changes(fwd, rev):

    # Make the "lefts" (the sections in the files)

    before_lines = fwd.to_reference_lines()
    after_lines = rev.to_reference_lines()

    from kiss_rdb.storage_adapters.eno import \
        sections_parsed_coarsely_via_lines as func

    before_sects = func(before_lines)
    after_sects = func(after_lines)

    def sects_with_line_offsets(sects):
        offset = 0
        for sect in sects:
            next_offset = offset + sect.line_count
            yield offset, next_offset, sect
            offset = next_offset

    cbefore_sects = sects_with_line_offsets(before_sects)
    cafter_sects = sects_with_line_offsets(after_sects)

    # Make the "rights" (change runs in the diff)

    def change_runs_of(exte):
        return (run for typ, run in exte.to_classified_runs()
                if 'no_change' != typ)  # noqa: E501

    before_change_runs = change_runs_of(fwd)
    after_change_runs = change_runs_of(rev)

    # Pair the sections with their overlapping changes

    before_inters = _find_span_intersections(cbefore_sects, before_change_runs)
    after_inters = _find_span_intersections(cafter_sects, after_change_runs)

    # Filter out so you only have the ones with changes

    def only_these(pairs):
        for sect, inters in pairs:
            if inters is None:
                continue
            yield sect, inters

    before_pairs = tuple(only_these(before_inters))
    after_pairs = tuple(only_these(after_inters))
    return before_pairs, after_pairs
コード例 #2
0
    def _private_index(self):
        eid = self._NCID
        if eid is None:
            return ('my_state_4_node_was_not_specified',)

        # Build the big index under the node
        bcoll = self._read_only_collection
        itr = big_index_for_one(eid, bcoll, self._listener)
        if itr is None:
            raise self._stop()
        func = higher_level_functions().tree_index_via
        tree_index = func(eid, itr)

        ddmm = tree_index.document_depth_minmax
        if ddmm is None:
            # This node is not a document, no documents within the tree.
            # We try this older "look up" way second because if it fails
            # it emits and doing it second allows us not to hack a listener
            return self._look_upwards()

        shallowest_depth, deepest_depth = ddmm
        if 0 == shallowest_depth:
            return 'my_state_2_node_is_part_of_document', 'by_way_of_tree_index', tree_index  # noqa: E501

        assert 0 < shallowest_depth
        return 'my_state_1_node_is_dewey_node', tree_index
コード例 #3
0
def _resolve_business_collection(coll_path, listener):
    from pho import read_only_business_collection_via_path_ as func
    # (read-only is especially important for #here4)

    bcoll = func(coll_path, listener)
    if bcoll:
        return bcoll
    raise _Stop()
コード例 #4
0
def _read_only_business_collection_via(directory):

    if not isinstance(directory, str):
        directory.build_big_index_  # [#022]
        return directory

    from pho import read_only_business_collection_via_path_ as func
    return func(directory)
コード例 #5
0
    def _look_upwards(self):
        from .abstract_document_via_notecards import \
            document_notecards_in_order_via_any_arbitrary_start_node_ as func

        itr = func(self._NCID, self._read_only_collection, self._listener)
        if itr is None:
            # was gonna be 'my_state_3_node_has_no_documents_above_or_below'
            raise self._stop()

        return 'my_state_2_node_is_part_of_document', 'by_way_of_look_up', itr
コード例 #6
0
def _main(coll_path, listener, do_rigged_only):

    db = _database_via_collection_path(coll_path, listener)

    def these():
        from modality_agnostic import ModalityAgnosticErrorMonitor as cls
        mon = cls(listener)
        bcoll = _resolve_business_collection(coll_path, listener)
        return bcoll, mon

    if do_rigged_only:
        bcoll, _mon = these()
        from ._update_rigged_documents import func
        func(db, bcoll, _Stop, listener)
        return

    # First pass: load changed file queue from any new commits from HEAD
    num = _populate_temporary_table(db, coll_path, listener)
    _say_number_of_new_commits(listener, num)

    if num:
        # If there were some, add files to the files queue
        num = _transfer_from_temp_table_to_changed_file_queue(db, listener)
        _say_number_of_new_changed_files(listener, num)

    # Second pass: touch and stale notecard records from changed file queue
    bcoll, mon = these()
    nnn, nn, n = _index_each_file_that_changed(db, bcoll, mon)
    _say_number_of_entities_to_audit(listener, nnn, nn, n)

    # Third pass: run the audit trail on each stale notecard
    nn, n = _run_the_audit_trail_on_each_stale_notecard(db, bcoll, mon)
    _say_num_entity_edits(listener, nn, n)

    # Fourth pass: populate document & document ci tables via unseen commits
    nnn, nn, n = _update_document_commit_table(bcoll, db, listener)
    _say_document_commits(listener, nnn, nn, n)

    # Pass four-point-five lol:
    from ._update_rigged_documents import func
    func(db, bcoll, _Stop, listener)
コード例 #7
0
    def resolve_one_or_more_patch_lines():
        from kiss_rdb.vcs_adapters.git import git_diff as func
        rc, patch_lines = func(path, listener, opn=opn)
        if rc:
            raise stop()  # assume something emitted
        if not patch_lines:

            def these_lines():
                yield "file is noent, is not in the repo or has no changes:"
                yield path

            listener('notice', 'expression', 'no_diff', these_lines)
            raise stop()
        return patch_lines
コード例 #8
0
 def lines():
     yield "Multiple node trees, choose one:"
     for line in func(tree_idens, 24):
         yield line
コード例 #9
0
 def _read_only_collection(self):
     from pho import read_only_business_collection_via_path_ as func
     return func(self._collection_path, listener=self._listener)
コード例 #10
0
def _scanner_via_iterator(itr):
    assert hasattr(itr, '__next__')
    from text_lib.magnetics.scanner_via import scanner_via_iterator as func
    return func(itr)
コード例 #11
0
def _database_via_collection_path(coll_path, listener):
    from ._model import database_after_updating_schema_ as func
    db = func(coll_path, listener)
    if db is None:
        raise _Stop()
    return db
コード例 #12
0
def _commits_not_in_the_commits_table(HEAD_SHA, coll_path):
    from ._common import GIT_LOG_NUMSTAT_ as func
    return func(coll_path, HEAD_SHA,
                ('git', 'log', '--numstat', '--', 'entities'))
コード例 #13
0
 def bcoll_via(coll_path):
     # failure seems somewhat unlikely
     from pho import read_only_business_collection_via_path_ as func
     return func(coll_path, listener)
コード例 #14
0
def _scanner_via_iterator(itr):
    from text_lib.magnetics.scanner_via import scanner_via_iterator as func
    return func(itr)
コード例 #15
0
 def resolve_extended_patches(patch_lines):
     from text_lib.diff_and_patch.classified_lines_via_patch import func
     with open(path) as lines:
         fwd, rev = func(patch_lines, lines)
         return fwd, rev
コード例 #16
0
def _mutable_business_collection_via(collection_path):
    def rng(pool_size):
        return 11584  # DC6 with two behind it?
    from pho import _mutable_business_collection_via as func
    return func(collection_path, rng)