Comments (6)
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.
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.
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.
git commit 0682cde implements --json output
from cloc.
Awesome! Thanks a lot! When Can I expect this to be released?
from cloc.
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)
- CoCoA 5 support
- some labeling issue with the 1.96.1 release HOT 3
- Add support for counting directly from Github/Bitbucket etc. HOT 1
- Add support from counting directly from Github/Bitbucket etc's repos. HOT 3
- Can't create unknown regex: $RE{comment}{C++} HOT 4
- Add language support for Typst HOT 2
- Dead link in Readme HOT 1
- `--include-ext=csv` counts only first file HOT 2
- Support EditorConfig files HOT 1
- Extract comments from files (reverse of --strip-comments) HOT 2
- Ignore files auto-generated by specflow HOT 2
- Possible erroneous line termination HOT 2
- Option to display results for specific languages only HOT 1
- Report by language and by file in the same report HOT 1
- cloc counts ReasonML //-prefixed line comments as code HOT 1
- Diff counting not working as intended? HOT 4
- Add foreign key to t table to relate to the metadata table. HOT 7
- How to see the full file names as well as the language types HOT 7
- The result of diff is different from the result of git diff HOT 6
- Adding support for prisma
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cloc.