Yield an IssueSnapshot for each time the issue size changed
502832
def iter_size_changes(self, issue):
        

        # Find the first size change, if any
        try:
            size_changes = list(filter(lambda h: h.field == 'Story Points',
                                       itertools.chain.from_iterable([c.items for c in issue.changelog.histories])))
        except AttributeError:
            return

        # If we have no size changes and the issue has a current size then a size must have ben specified at issue creation time.
        # Return the size at creation time

        try:
            current_size = issue.fields.__dict__[self.fields['StoryPoints']]
        except:
            current_size = None

        size = (size_changes[0].fromString) if len(size_changes)  else current_size

        # Issue was created
        yield IssueSizeSnapshot(
            change=None,
            key=issue.key,
            date=dateutil.parser.parse(issue.fields.created),
            size=size
        )

        for change in issue.changelog.histories:
            change_date = dateutil.parser.parse(change.created)

            #sizes = list(filter(lambda i: i.field == 'Story Points', change.items))
            #is_resolved = (sizes[-1].to is not None) if len(sizes) > 0 else is_resolved

            for item in change.items:
                if item.field == 'Story Points':
                    # StoryPoints value was changed
                    size = item.toString
                    yield IssueSizeSnapshot(
                        change=item.field,
                        key=issue.key,
                        date=change_date,
                        size=size
                    )
1131821
def format_issues(issues)
      results = [t('myissues.info')]
      results.concat(issues.map { |issue| format_issue(issue) })
    end
925425
def get_chunked_archive(self, **kwargs):
        

        chunk_size = kwargs.pop('chunk_size', 8192)
        stream = kwargs.get('stream')
        self.fill_archive(**kwargs)
        while True:
            data = stream.read(chunk_size)
            if not data:
                break
            yield data
1062123
def get_datetime_issue_in_progress(self, issue):
        
        histories = issue.changelog.histories
        for history in reversed(histories):
            history_items = history.items
            for item in history_items:
                if item.field == 'status' and item.toString == "In Progress":
                    return dateutil.parser.parse(history.created)
1159041
def rename_snapshot(self, path, oldsnapshotname, snapshotname, **kwargs):
        """"""
        response = self._put(path, 'RENAMESNAPSHOT',
                             oldsnapshotname=oldsnapshotname, snapshotname=snapshotname, **kwargs)
        assert not response.content
942069
def i_batch(items, size):
    
    for items_batch in iter(lambda: tuple(islice(items, size)),
                            tuple()):
        yield items_batch
1224750
def fetch_closed_issues_and_pr
      print "Fetching closed issues...\r" if @options[:verbose]
      issues = []
      page_i      = 0
      count_pages = calculate_pages(@client, "issues", closed_pr_options)

      iterate_pages(@client, "issues", closed_pr_options) do |new_issues|
        page_i += PER_PAGE_NUMBER
        print_in_same_line("Fetching issues... #{page_i}/#{count_pages * PER_PAGE_NUMBER}")
        issues.concat(new_issues)
        break if @options[:max_issues] && issues.length >= @options[:max_issues]
      end
      print_empty_line
      Helper.log.info "Received issues: #{issues.count}"

      # separate arrays of issues and pull requests:
      issues.map { |issue| stringify_keys_deep(issue.to_hash) }
            .partition { |issue_or_pr| issue_or_pr["pull_request"].nil? }
    end
1230678
private void repairDataSize()
   {
      try
      {
         long dataSize = quotaPersister.getWorkspaceDataSize(rName, wsName);

         ChangesItem changesItem = new ChangesItem();
         changesItem.updateWorkspaceChangedSize(dataSize);

         quotaPersister.setWorkspaceDataSize(rName, wsName, 0); // workaround

         Runnable task = new ApplyPersistedChangesTask(wqm.getContext(), changesItem);
         task.run();
      }
      catch (UnknownDataSizeException e)
      {
         if (LOG.isTraceEnabled())
         {
            LOG.trace(e.getMessage(), e);
         }
      }
   }
659006
def _process_bulk_chunk(
    client,
    bulk_actions,
    bulk_data,
    raise_on_exception=True,
    raise_on_error=True,
    *args,
    **kwargs
):
    
    # if raise on error is set, we need to collect errors per chunk before raising them
    errors = []

    try:
        # send the actual request
        resp = client.bulk("\n".join(bulk_actions) + "\n", *args, **kwargs)
    except TransportError as e:
        # default behavior - just propagate exception
        if raise_on_exception:
            raise e

        # if we are not propagating, mark all actions in current chunk as failed
        err_message = str(e)
        exc_errors = []

        for data in bulk_data:
            # collect all the information about failed actions
            op_type, action = data[0].copy().popitem()
            info = {"error": err_message, "status": e.status_code, "exception": e}
            if op_type != "delete":
                info["data"] = data[1]
            info.update(action)
            exc_errors.append({op_type: info})

        # emulate standard behavior for failed actions
        if raise_on_error:
            raise BulkIndexError(
                "%i document(s) failed to index." % len(exc_errors), exc_errors
            )
        else:
            for err in exc_errors:
                yield False, err
            return

    # go through request-response pairs and detect failures
    for data, (op_type, item) in zip(
        bulk_data, map(methodcaller("popitem"), resp["items"])
    ):
        ok = 200 <= item.get("status", 500) < 300
        if not ok and raise_on_error:
            # include original document source
            if len(data) > 1:
                item["data"] = data[1]
            errors.append({op_type: item})

        if ok or not errors:
            # if we are not just recording all errors to be able to raise
            # them all at once, yield items individually
            yield ok, {op_type: item}

    if errors:
        raise BulkIndexError("%i document(s) failed to index." % len(errors), errors)
407598
def _chunk_offsets(self):
        """"""
        index = 0
        blob_size = self.blob_properties.get('content-length')
        while index < blob_size:
            yield index
            index = index + self._chunk_size
1306110
private List<DocumentChange> computeSnapshot(Timestamp readTime) {
    List<DocumentChange> appliedChanges = new ArrayList<>();

    ChangeSet changeSet = extractChanges(readTime);

    // Process the sorted changes in the order that is expected by our clients (removals, additions,
    // and then modifications). We also need to sort the individual changes to assure that
    // oldIndex/newIndex keep incrementing.
    Collections.sort(changeSet.deletes, comparator);
    for (QueryDocumentSnapshot delete : changeSet.deletes) {
      appliedChanges.add(deleteDoc(delete));
    }

    Collections.sort(changeSet.adds, comparator);
    for (QueryDocumentSnapshot add : changeSet.adds) {
      appliedChanges.add(addDoc(add));
    }

    Collections.sort(changeSet.updates, comparator);
    for (QueryDocumentSnapshot update : changeSet.updates) {
      DocumentChange change = modifyDoc(update);
      if (change != null) {
        appliedChanges.add(change);
      }
    }

    return appliedChanges;
  }
912276
def save_file_revisions(self,snapshot,file_revisions):
        

        annotations = defaultdict(list)

        for file_revision in file_revisions:
            issues_results = {}

            for analyzer_name,results in file_revision.results.items():

                if 'issues' in results:
                    issues_results[analyzer_name] = results['issues']
                    del results['issues']
                    if len(issues_results) > 1000:
                        issues_results[analyzer_name] = [{
                                'code' : 'TooManyIssues',
                                'analyzer' : analyzer_name,
                            }]

            with self.project.backend.transaction():
                self.project.backend.save(file_revision)

            def location_sorter(issue):
                if issue['location'] and issue['location'][0] and issue['location'][0][0]:
                    return issue['location'][0][0][0]
                return 0

            with self.project.backend.transaction():
                for analyzer_name,issues in issues_results.items():
                    grouped_issues = group_issues_by_fingerprint(issues)
                    for issue_dict in grouped_issues:

                        hasher = Hasher()
                        hasher.add(analyzer_name)
                        hasher.add(issue_dict['code'])
                        hasher.add(issue_dict['fingerprint'])
                        issue_dict['hash'] = hasher.digest.hexdigest()

                        try:
                            #we check if the issue already exists
                            issue = self.project.backend.get(Issue,{'hash' : issue_dict['hash'],
                                                                    'project' : self.project
                                                                   })
                        except Issue.DoesNotExist:
                            #if not, we create it
                            d = issue_dict.copy()
                            d['analyzer'] = analyzer_name
                            if 'location' in d:
                                del d['location']
                            if 'occurrences' in d:
                                del d['occurrences']
                            issue = Issue(d)
                            issue.project = self.project
                            self.project.backend.save(issue)

                        for occurrence in issue_dict['occurrences']:
                            hasher = Hasher()
                            hasher.add(file_revision.hash)
                            hasher.add(issue.hash)
                            hasher.add(occurrence.get('from_row'))
                            hasher.add(occurrence.get('from_column'))
                            hasher.add(occurrence.get('to_row'))
                            hasher.add(occurrence.get('to_column'))
                            hasher.add(occurrence.get('sequence'))
                            occurrence['hash'] = hasher.digest.hexdigest()

                            try:
                                #we check if the occurrence already exists
                                occurrence = self.project.backend.get(IssueOccurrence,{'hash' : occurrence['hash'],
                                                                                       'issue' : issue
                                                                                      })
                            except IssueOccurrence.DoesNotExist:
                                #if not, we create it
                                occurrence = IssueOccurrence(occurrence)
                                occurrence.issue = issue
                                occurrence.file_revision = file_revision
                                self.project.backend.save(occurrence)
                            annotations['occurrences'].append(occurrence)
                        annotations['issues'].append(issue)

        return annotations
805289
def fetch_data_async(blob, start_index, end_index, **options):
  """"""
  if isinstance(blob, BlobInfo):
    blob = blob.key()
  rpc = blobstore.create_rpc(**options)
  rpc = blobstore.fetch_data_async(blob, start_index, end_index, rpc=rpc)
  result = yield rpc
  raise tasklets.Return(result)
7229
def iter_changes(self, issue, include_resolution_changes=True):
        

        is_resolved = False

        # Find the first status change, if any
        try:
            status_changes = list(filter(
                lambda h: h.field == 'status',
                itertools.chain.from_iterable([c.items for c in issue.changelog.histories])))
        except AttributeError:
            return
        last_status = status_changes[0].fromString if len(status_changes) > 0 else issue.fields.status.name
        last_resolution = None

        # Issue was created
        yield IssueSnapshot(
            change=None,
            key=issue.key,
            date=dateutil.parser.parse(issue.fields.created),
            status=last_status,
            resolution=None,
            is_resolved=is_resolved
        )

        for change in issue.changelog.histories:
            change_date = dateutil.parser.parse(change.created)

            resolutions = list(filter(lambda i: i.field == 'resolution', change.items))
            is_resolved = (resolutions[-1].to is not None) if len(resolutions) > 0 else is_resolved

            for item in change.items:
                if item.field == 'status':
                    # Status was changed
                    last_status = item.toString
                    yield IssueSnapshot(
                        change=item.field,
                        key=issue.key,
                        date=change_date,
                        status=last_status,
                        resolution=last_resolution,
                        is_resolved=is_resolved
                    )
                elif item.field == 'resolution':
                    last_resolution = item.toString
                    if include_resolution_changes:
                        yield IssueSnapshot(
                            change=item.field,
                            key=issue.key,
                            date=change_date,
                            status=last_status,
                            resolution=last_resolution,
                            is_resolved=is_resolved
                        )
761169
public void loadSnapshot(String vm, String snapshotUuid) {
        if (!EnumSet.of(POWEROFF, SAVED).contains(vmState(vm))) {
            powerOff(vm);
        }
        execute("snapshot", vm, "restore", snapshotUuid);
        start(vm);
    }
186089
def _populate_issue(self, graph: TraceGraph, instance_id: int) -> None:
        
        instance = graph._issue_instances[instance_id]
        issue = graph._issues[instance.issue_id.local_id]
        self._populate_shared_text(graph, instance.message_id)
        self._populate_shared_text(graph, instance.filename_id)
        self._populate_shared_text(graph, instance.callable_id)

        self.add_issue_instance(instance)
        self.add_issue(issue)

        if instance_id in graph._issue_instance_fix_info:
            issue_fix_info = graph._issue_instance_fix_info[instance_id]
            self.add_issue_instance_fix_info(instance, issue_fix_info)

        for shared_text_id in graph._issue_instance_shared_text_assoc[instance_id]:
            shared_text = graph._shared_texts[shared_text_id]
            if shared_text_id not in self._shared_texts:
                self.add_shared_text(shared_text)
            self.add_issue_instance_shared_text_assoc(instance, shared_text)
948932
public static QuerySnapshot withDocuments(
      final Query query, Timestamp readTime, final List<QueryDocumentSnapshot> documents) {
    return new QuerySnapshot(query, readTime) {
      volatile List<DocumentChange> documentChanges;

      @Nonnull
      @Override
      public List<QueryDocumentSnapshot> getDocuments() {
        return Collections.unmodifiableList(documents);
      }

      @Nonnull
      @Override
      public List<DocumentChange> getDocumentChanges() {
        if (documentChanges == null) {
          synchronized (documents) {
            if (documentChanges == null) {
              documentChanges = new ArrayList<>();
              for (int i = 0; i < documents.size(); ++i) {
                documentChanges.add(new DocumentChange(documents.get(i), Type.ADDED, -1, i));
              }
            }
          }
        }
        return Collections.unmodifiableList(documentChanges);
      }

      @Override
      public int size() {
        return documents.size();
      }

      @Override
      public boolean equals(Object o) {
        if (this == o) {
          return true;
        }
        if (o == null || getClass() != o.getClass()) {
          return false;
        }
        QuerySnapshot that = (QuerySnapshot) o;
        return Objects.equals(query, that.query)
            && Objects.equals(this.size(), that.size())
            && Objects.equals(this.getDocuments(), that.getDocuments());
      }

      @Override
      public int hashCode() {
        return Objects.hash(query, this.getDocuments());
      }
    };
  }