GithubHelp home page GithubHelp logo

Comments (6)

AlDanial avatar AlDanial commented on June 16, 2024

Help me out here... what is it you're after? You want cloc to count json files (it already does)? You want cloc to write results in json? You want to load json into Python?

from cloc.

stardust85 avatar stardust85 commented on June 16, 2024

Sorry for my brevity, I'd like to be able to get the results in json format, because it is the most convenient format for parsing in python and I need to post-process the results in python. Or more concretely, I need to prepare them for drawing them in zabbix for different revisions.

from cloc.

AlDanial avatar AlDanial commented on June 16, 2024

Sure, I can add a json output option. May be a few weeks before I get to it though. In the meantime, please give the YAML serialization a try; works great with Python.

First create YAML output with cloc:

cloc --yaml --out x.yaml code_project

Next, load the YAML file x.yaml into a Python variable. Here's a sample ipython session:

In [1]: import yaml

In [2]: x = yaml.load(file('x.yaml'))

In [3]: x

Out[3]: {'Bourne Shell': {'blank': 53, 'code': 448, 'comment': 94, 'nFiles': 30},
'C': {'blank': 4, 'code': 50, 'comment': 19, 'nFiles': 1},
'HTML': {'blank': 151, 'code': 8866, 'comment': 207, 'nFiles': 30},
'MATLAB': {'blank': 0, 'code': 22, 'comment': 1, 'nFiles': 1},
'Perl': {'blank': 2004, 'code': 22682, 'comment': 4221, 'nFiles': 164},
'Python': {'blank': 101, 'code': 553, 'comment': 284, 'nFiles': 3},
'SUM': {'blank': 2313, 'code': 32621, 'comment': 4826, 'nFiles': 229},
'header': {'cloc_url': 'https://github.com/AlDanial/cloc',
'cloc_version': 1.65,
'elapsed_seconds': 0.519536018371582,
'files_per_second': 440.777909331042,
'lines_per_second': 76529.8239083068,
'n_files': 229,
'n_lines': 39760,
'report_file': 'x.yaml'}}

from cloc.

AlDanial avatar AlDanial commented on June 16, 2024

git commit 0682cde implements --json output

from cloc.

stardust85 avatar stardust85 commented on June 16, 2024

Awesome! Thanks a lot! When Can I expect this to be released?

from cloc.

AlDanial avatar AlDanial commented on June 16, 2024

You can pull the source from the master branch now. The next release will be in a week or two.

from cloc.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.