From 3d3adc18b0113206b9f2a1b26574711d720aab13 Mon Sep 17 00:00:00 2001 From: Bryce Vonilten Date: Thu, 7 Nov 2019 15:05:53 -0800 Subject: [PATCH] small fixes to LOCCounter. Added files needed to make this a package on pypi --- LICENSE.txt | 17 +++++++++++++ README.md | 23 ++++++++++++++++++ .../LOCCounter.py | 8 +++--- python_loc_counter/__init__.py | 1 + .../__pycache__/LOCCounter.cpython-37.pyc | Bin 0 -> 5238 bytes .../__pycache__/__init__.cpython-37.pyc | Bin 0 -> 239 bytes setup.cfg | 2 ++ setup.py | 21 ++++++++++++++++ tests/__init__.py | 0 tests/__pycache__/__init__.cpython-37.pyc | Bin 0 -> 162 bytes tests/__pycache__/test.cpython-37.pyc | Bin 0 -> 636 bytes tests/test.py | 16 ++++++++++++ 12 files changed, 84 insertions(+), 4 deletions(-) create mode 100644 LICENSE.txt create mode 100644 README.md rename LOCCounter.py => python_loc_counter/LOCCounter.py (95%) create mode 100644 python_loc_counter/__init__.py create mode 100644 python_loc_counter/__pycache__/LOCCounter.cpython-37.pyc create mode 100644 python_loc_counter/__pycache__/__init__.cpython-37.pyc create mode 100644 setup.cfg create mode 100644 setup.py create mode 100644 tests/__init__.py create mode 100644 tests/__pycache__/__init__.cpython-37.pyc create mode 100644 tests/__pycache__/test.cpython-37.pyc create mode 100644 tests/test.py diff --git a/LICENSE.txt b/LICENSE.txt new file mode 100644 index 0000000..e208043 --- /dev/null +++ b/LICENSE.txt @@ -0,0 +1,17 @@ +MIT License +Copyright (c) 2018 YOUR NAME +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..933e69c --- /dev/null +++ b/README.md @@ -0,0 +1,23 @@ +# python-loc-counter + +This python-loc-counter module was built to count various LOC metrics: +- source_loc +- single_comment_loc +- single_docstring_loc +- double_docstring_loc +- total_comments_loc +- blank_loc +- total_line_count + +### Installation +This package only uses the standard libaries. Pip install instuctions coming... + +```sh +$ cd test +``` + +### Development +See a feature or found a bug? Feel free to make suggestions or (better yet) contributions for future iterations! + +### Example Projects +- Originally this module was built for: https://github.com/bcdasilv/code-style-mining/tree/python_analysis. diff --git a/LOCCounter.py b/python_loc_counter/LOCCounter.py similarity index 95% rename from LOCCounter.py rename to python_loc_counter/LOCCounter.py index 336804c..48e2234 100644 --- a/LOCCounter.py +++ b/python_loc_counter/LOCCounter.py @@ -23,7 +23,7 @@ class LOCCounter: def __init__(self, file): self.file = file - __calcLOC() + self.__calcLOC() __source_loc = 0 __single_comment_loc = 0 @@ -51,8 +51,8 @@ def getLOC(self): } """ - return {"source_loc": self.__source_loc, "single_comments_loc": self.__single_comments_loc, - "single_docstring_loc": single_docstring_loc, "double_docstring_loc": self.__double_docstring_loc, + return {"source_loc": self.__source_loc, "single_comments_loc": self.__single_comment_loc, + "single_docstring_loc": self.__single_docstring_loc, "double_docstring_loc": self.__double_docstring_loc, "total_comments_loc": self.__total_comments_loc, "blank_loc": self.__blank_loc, "total_line_count": self.__total_line_count} @@ -80,7 +80,7 @@ def __calcLOC(self): continue #Remove quotes for some comment analysis - l = re.sub(r"(\"\"\")|(''')|((\"|').*?\4)", __choseRegexGroups, line) + l = re.sub(r"(\"\"\")|(''')|((\"|').*?\4)", self.__choseRegexGroups, line) #print(repr(l)) inDoubleDoc = inDoubleDoc if (l.count('"""')%2 == 0) else not inDoubleDoc diff --git a/python_loc_counter/__init__.py b/python_loc_counter/__init__.py new file mode 100644 index 0000000..0fd19e6 --- /dev/null +++ b/python_loc_counter/__init__.py @@ -0,0 +1 @@ +from python_loc_counter.LOCCounter import LOCCounter diff --git a/python_loc_counter/__pycache__/LOCCounter.cpython-37.pyc b/python_loc_counter/__pycache__/LOCCounter.cpython-37.pyc new file mode 100644 index 0000000000000000000000000000000000000000..ffe90304ca2a81ce3e1b3e97142b5c7471db2e86 GIT binary patch literal 5238 zcmb_g&2Jn@74NV4=<(Q@*p8F130pXUctWst(MljMOLpV1VWr@OIIw7B)U>C{@x(pd zld7I%J=;Dd;)KLrxB+swAZ}c_aN@*YfcgrTTsiKE->dHF`S3VvBxYPy-Ba&Xz4z*U z{K|Lc=W7N&>%af|FWd`;@h^HAer!CvkET}9af6$I(aJ`%W!^Km#qAdcx1U=ri<{d< z(|H9tW2;U5@MGcOeKhp~oiJJ^H;B4rXWT7^JFOC08Lfg=MRU<=Xmh;8%P)*pomY4j z<2-kH4dViz<8_SZ_&i_0*x=`Q1LJvqo-bltN~i~JJC3;Z&q{7PE8 z|MBK#)DL4J{Us<_bMJMYijetiuM>#S?}}S2-tQ>Z4t%B9vrZ7OUBUd_K(IJsk3`I{ z0_%!ccG`;V98 z*wK$idxd^*I1s#6bAKe_{fJ{J*Bvgu!5)aXFGIz!FBrvyJRpQTZ7s+K+r(o(@M8hu zkn5)6NaA%&2V&Welz1Q>iBIpzsNYj-T|aK`L)v{2^n_%4{jeQ(qL5^UGO!(!M9nmv zP?>n!QD3%2zO~GSRQg8-3klXHyEC7JVVy9}xnR3MY)0L#2xB$PttY{#XK8`mQx>=z zwP9e8&tBn4KZ*t8L!#ND+{N;NIBg}aXW5xndKkriaEeZJWUA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__init__.cpython-37.pyc b/python_loc_counter/__pycache__/__init__.cpython-37.pyc new file mode 100644 index 0000000000000000000000000000000000000000..59e42dafb031f840f895f34868eaf63bbaac938d GIT binary patch literal 239 zcmZ?b<>g`kf{#;<#F_%>#~=<2Faa43KwK;UBvKes7;_kM8KW2(8B&;n88n$+0!0}# z8Eg`kf~T{O#DeI@AOZ#$feZ&AE@lA|DGb33nv8xc8Hzx{2;!HwvsFxJacWU< zj8jo%a%zlAYH@Z+enE_LeoAIudQ3o3epYI7NpVa;Wl2VUUVKh|a(r@rXTZlX-=vg$db=M%m4sm`zzxB literal 0 HcmV?d00001 diff --git a/tests/__pycache__/test.cpython-37.pyc b/tests/__pycache__/test.cpython-37.pyc new file mode 100644 index 0000000000000000000000000000000000000000..f9e522d48f63a0a84f42915b7f64236c74a51aa9 GIT binary patch literal 636 zcmZWnO-sW-5S`toAC?xxucP-|>Rm*nDGDMgR4*YSHM`bmvKw}{U`0>*J4BBj{1^U; zTs`?0JUP2nS#iR=ym`#NOeX1fyKTVOeSAB4B>?ZX_z8++3sbKmFkmEyg2aRXqpbD- zG3E3gunL9{)<3WZLQ=K&4x&g-gyAZ+k_~HA!;CO>iNMGm7`TOdaz_lgB~SDjIRVFO z9uGWT_jtqOO^>%cJ~!hGa6Gzyv(j5LTpPWnMuN#=JIi^`T$`}1?08kZRGBbwW6TY{ zLEORnP)=0JZM9^pOpJ3L$)e!GXsa&&ssov7gXhOT@<2|`a{fnN#O@<$M!9b>k77R` ziL1R#aA#^C<=U*`7KxrAt%7qLIBur1)xLnLxV|#7Od`o} zn&eQ)OP(5?lv8sd#c3|n({G2wEyH22oK`_G%7pz!dI