__author__ = 'maxwu'

import json

from me.maxwu.cistat import config
from me.maxwu.cistat.reqs.circleci_request import CircleCiReq
from me.maxwu.cistat.model.xunit_report import Xunitrpt

"""Main script file to provide configuration loading, cli_app and version.
"""

VERSION = "1.0"


def cli_app():
    vcs, project, username = config.get_circleci_vcs(), config.get_circleci_project(), config.get_circleci_username()

    urls = CircleCiReq.get_recent_artifacts(
            token=config.get_circleci_token(),
            vcs=vcs,
            project=project,
            username=username
    )

    report = Xunitrpt()

    for artifact in urls:
        print("fetching {}".format(artifact))
        report += Xunitrpt(xunit=CircleCiReq.get_artifact_report(url=artifact))

    print("Top 10 failure cases: {}".format(report.get_cases_in_rate()[:10]))

    print("Plot Barchart of Pass Rate")
    report.plot_barchart_rate(project, "Pass Rate per case")


if __name__ == '__main__':
    cli_app()

__author__ = 'maxwu'

import pprint
from me.maxwu.cistat import config
from me.maxwu.cistat.reqs.circleci_request import CircleCiReq
from me.maxwu.cistat.model.xunit_report import Xunitrpt

"""Main script file to provide configuration loading, cli_app and version.
"""

VERSION = "1.0"


def cli_app():
    vcs, project, username = config.get_circleci_vcs(), config.get_circleci_project(), config.get_circleci_username()

    urls = CircleCiReq.get_recent_artifacts(
            token=config.get_circleci_token(),
            vcs=vcs,
            project=project,
            username=username
    )

    report = Xunitrpt()

    for artifact in urls:
        print("fetching {}".format(artifact))
        report += Xunitrpt(xunit=CircleCiReq.get_artifact_report(url=artifact))

    print("Top 10 failure cases:")
    pprint.pprint(report.get_cases_in_rate()[:10])

    print("Plot Barchart of Pass Rate")
    report.plot_barchart_rate(project, "Pass Rate per case")


if __name__ == '__main__':
    cli_app()

Update sample task with pprint
Update sample task with pprint

  __author__ = 'maxwu'
  
+ import pprint
- import json
- 
  from me.maxwu.cistat import config
  from me.maxwu.cistat.reqs.circleci_request import CircleCiReq
  from me.maxwu.cistat.model.xunit_report import Xunitrpt
  
  """Main script file to provide configuration loading, cli_app and version.
  """
  
  VERSION = "1.0"
  
  
  def cli_app():
      vcs, project, username = config.get_circleci_vcs(), config.get_circleci_project(), config.get_circleci_username()
  
      urls = CircleCiReq.get_recent_artifacts(
              token=config.get_circleci_token(),
              vcs=vcs,
              project=project,
              username=username
      )
  
      report = Xunitrpt()
  
      for artifact in urls:
          print("fetching {}".format(artifact))
          report += Xunitrpt(xunit=CircleCiReq.get_artifact_report(url=artifact))
  
-     print("Top 10 failure cases: {}".format(report.get_cases_in_rate()[:10]))
+     print("Top 10 failure cases:")
+     pprint.pprint(report.get_cases_in_rate()[:10])
  
      print("Plot Barchart of Pass Rate")
      report.plot_barchart_rate(project, "Pass Rate per case")
  
  
  if __name__ == '__main__':
      cli_app()
  
Update sample task with pprint
## Code Before:
__author__ = 'maxwu'

import json

from me.maxwu.cistat import config
from me.maxwu.cistat.reqs.circleci_request import CircleCiReq
from me.maxwu.cistat.model.xunit_report import Xunitrpt

"""Main script file to provide configuration loading, cli_app and version.
"""

VERSION = "1.0"


def cli_app():
    vcs, project, username = config.get_circleci_vcs(), config.get_circleci_project(), config.get_circleci_username()

    urls = CircleCiReq.get_recent_artifacts(
            token=config.get_circleci_token(),
            vcs=vcs,
            project=project,
            username=username
    )

    report = Xunitrpt()

    for artifact in urls:
        print("fetching {}".format(artifact))
        report += Xunitrpt(xunit=CircleCiReq.get_artifact_report(url=artifact))

    print("Top 10 failure cases: {}".format(report.get_cases_in_rate()[:10]))

    print("Plot Barchart of Pass Rate")
    report.plot_barchart_rate(project, "Pass Rate per case")


if __name__ == '__main__':
    cli_app()

## Instruction:
Update sample task with pprint
## Code After:
__author__ = 'maxwu'

import pprint
from me.maxwu.cistat import config
from me.maxwu.cistat.reqs.circleci_request import CircleCiReq
from me.maxwu.cistat.model.xunit_report import Xunitrpt

"""Main script file to provide configuration loading, cli_app and version.
"""

VERSION = "1.0"


def cli_app():
    vcs, project, username = config.get_circleci_vcs(), config.get_circleci_project(), config.get_circleci_username()

    urls = CircleCiReq.get_recent_artifacts(
            token=config.get_circleci_token(),
            vcs=vcs,
            project=project,
            username=username
    )

    report = Xunitrpt()

    for artifact in urls:
        print("fetching {}".format(artifact))
        report += Xunitrpt(xunit=CircleCiReq.get_artifact_report(url=artifact))

    print("Top 10 failure cases:")
    pprint.pprint(report.get_cases_in_rate()[:10])

    print("Plot Barchart of Pass Rate")
    report.plot_barchart_rate(project, "Pass Rate per case")


if __name__ == '__main__':
    cli_app()
