Преглед на файлове

Remove unused (for csv generation) code.

This repo now just generates csv files, these files are then used by the git-notebook repo to load and analyze in a Jupyter Notebook.
Dan Rapp преди 7 години
родител
ревизия
7c8a428656

+ 0
- 34
Makefile Целия файл

@@ -1,34 +0,0 @@
1
-PREFIX=/usr/local
2
-BINDIR=$(PREFIX)/bin
3
-RESOURCEDIR=$(PREFIX)/share/gitstats
4
-RESOURCES=gitstats.css sortable.js *.gif
5
-BINARIES=gitstats
6
-VERSION=$(shell git describe 2>/dev/null || git rev-parse --short HEAD 2>/dev/null || date +%Y-%m-%d)
7
-SEDVERSION=perl -pi -e 's/VERSION = 0/VERSION = "$(VERSION)"/' --
8
-
9
-all: help
10
-
11
-help:
12
-	@echo "Usage:"
13
-	@echo
14
-	@echo "make install                   # install to ${PREFIX}"
15
-	@echo "make install PREFIX=~          # install to ~"
16
-	@echo "make release [VERSION=foo]     # make a release tarball"
17
-	@echo
18
-
19
-install:
20
-	install -d $(BINDIR) $(RESOURCEDIR)
21
-	install -v $(BINARIES) $(BINDIR)
22
-	install -v -m 644 $(RESOURCES) $(RESOURCEDIR)
23
-	$(SEDVERSION) $(BINDIR)/gitstats
24
-
25
-release:
26
-	@cp gitstats gitstats.tmp
27
-	@$(SEDVERSION) gitstats.tmp
28
-	@tar --owner=0 --group=0 --transform 's!^!gitstats/!' --transform 's!gitstats.tmp!gitstats!' -zcf gitstats-$(VERSION).tar.gz gitstats.tmp $(RESOURCES) doc/ Makefile
29
-	@$(RM) gitstats.tmp
30
-
31
-man:
32
-	pod2man --center "User Commands" -r $(VERSION) doc/gitstats.pod > doc/gitstats.1
33
-
34
-.PHONY: all help install release

+ 1
- 6
README.md Целия файл

@@ -2,20 +2,15 @@
2 2
 
3 3
 A utility to pull a number of statistics from a git repo including:
4 4
 
5
-* Total LOC
5
+* Total LOC (by file type)
6 6
 * LOC (by various time periods)
7 7
 * Commits (by various time periods)
8 8
 * Commits (by various authors)
9 9
 * Files (by type)
10 10
 * Files (by various time periods)
11
-* Tags (by date, authors, volume)
12 11
 
13 12
 ## Usage
14 13
 
15 14
 `pip install gitstats`
16 15
 
17 16
 `gitstats <repo_dir>+ <output_dir>`
18
-
19
-OR
20
-
21
-`gencsvstats <repo_dir>+ <output_dir>`

+ 0
- 6
doc/AUTHOR Целия файл

@@ -1,6 +0,0 @@
1
-This work was forked from hoxu@users.sf.net and is authored by
2
-Daniel Rapp (rappdw@gmail.com)
3
-
4
-See the following command for list of authors who have contributed:
5
-  $ git shortlog HEAD
6
-

+ 0
- 339
doc/GPLv2 Целия файл

@@ -1,339 +0,0 @@
1
-		    GNU GENERAL PUBLIC LICENSE
2
-		       Version 2, June 1991
3
-
4
- Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
5
- 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
6
- Everyone is permitted to copy and distribute verbatim copies
7
- of this license document, but changing it is not allowed.
8
-
9
-			    Preamble
10
-
11
-  The licenses for most software are designed to take away your
12
-freedom to share and change it.  By contrast, the GNU General Public
13
-License is intended to guarantee your freedom to share and change free
14
-software--to make sure the software is free for all its users.  This
15
-General Public License applies to most of the Free Software
16
-Foundation's software and to any other program whose authors commit to
17
-using it.  (Some other Free Software Foundation software is covered by
18
-the GNU Lesser General Public License instead.)  You can apply it to
19
-your programs, too.
20
-
21
-  When we speak of free software, we are referring to freedom, not
22
-price.  Our General Public Licenses are designed to make sure that you
23
-have the freedom to distribute copies of free software (and charge for
24
-this service if you wish), that you receive source code or can get it
25
-if you want it, that you can change the software or use pieces of it
26
-in new free programs; and that you know you can do these things.
27
-
28
-  To protect your rights, we need to make restrictions that forbid
29
-anyone to deny you these rights or to ask you to surrender the rights.
30
-These restrictions translate to certain responsibilities for you if you
31
-distribute copies of the software, or if you modify it.
32
-
33
-  For example, if you distribute copies of such a program, whether
34
-gratis or for a fee, you must give the recipients all the rights that
35
-you have.  You must make sure that they, too, receive or can get the
36
-source code.  And you must show them these terms so they know their
37
-rights.
38
-
39
-  We protect your rights with two steps: (1) copyright the software, and
40
-(2) offer you this license which gives you legal permission to copy,
41
-distribute and/or modify the software.
42
-
43
-  Also, for each author's protection and ours, we want to make certain
44
-that everyone understands that there is no warranty for this free
45
-software.  If the software is modified by someone else and passed on, we
46
-want its recipients to know that what they have is not the original, so
47
-that any problems introduced by others will not reflect on the original
48
-authors' reputations.
49
-
50
-  Finally, any free program is threatened constantly by software
51
-patents.  We wish to avoid the danger that redistributors of a free
52
-program will individually obtain patent licenses, in effect making the
53
-program proprietary.  To prevent this, we have made it clear that any
54
-patent must be licensed for everyone's free use or not licensed at all.
55
-
56
-  The precise terms and conditions for copying, distribution and
57
-modification follow.
58
-
59
-		    GNU GENERAL PUBLIC LICENSE
60
-   TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
61
-
62
-  0. This License applies to any program or other work which contains
63
-a notice placed by the copyright holder saying it may be distributed
64
-under the terms of this General Public License.  The "Program", below,
65
-refers to any such program or work, and a "work based on the Program"
66
-means either the Program or any derivative work under copyright law:
67
-that is to say, a work containing the Program or a portion of it,
68
-either verbatim or with modifications and/or translated into another
69
-language.  (Hereinafter, translation is included without limitation in
70
-the term "modification".)  Each licensee is addressed as "you".
71
-
72
-Activities other than copying, distribution and modification are not
73
-covered by this License; they are outside its scope.  The act of
74
-running the Program is not restricted, and the output from the Program
75
-is covered only if its contents constitute a work based on the
76
-Program (independent of having been made by running the Program).
77
-Whether that is true depends on what the Program does.
78
-
79
-  1. You may copy and distribute verbatim copies of the Program's
80
-source code as you receive it, in any medium, provided that you
81
-conspicuously and appropriately publish on each copy an appropriate
82
-copyright notice and disclaimer of warranty; keep intact all the
83
-notices that refer to this License and to the absence of any warranty;
84
-and give any other recipients of the Program a copy of this License
85
-along with the Program.
86
-
87
-You may charge a fee for the physical act of transferring a copy, and
88
-you may at your option offer warranty protection in exchange for a fee.
89
-
90
-  2. You may modify your copy or copies of the Program or any portion
91
-of it, thus forming a work based on the Program, and copy and
92
-distribute such modifications or work under the terms of Section 1
93
-above, provided that you also meet all of these conditions:
94
-
95
-    a) You must cause the modified files to carry prominent notices
96
-    stating that you changed the files and the date of any change.
97
-
98
-    b) You must cause any work that you distribute or publish, that in
99
-    whole or in part contains or is derived from the Program or any
100
-    part thereof, to be licensed as a whole at no charge to all third
101
-    parties under the terms of this License.
102
-
103
-    c) If the modified program normally reads commands interactively
104
-    when run, you must cause it, when started running for such
105
-    interactive use in the most ordinary way, to print or display an
106
-    announcement including an appropriate copyright notice and a
107
-    notice that there is no warranty (or else, saying that you provide
108
-    a warranty) and that users may redistribute the program under
109
-    these conditions, and telling the user how to view a copy of this
110
-    License.  (Exception: if the Program itself is interactive but
111
-    does not normally print such an announcement, your work based on
112
-    the Program is not required to print an announcement.)
113
-
114
-These requirements apply to the modified work as a whole.  If
115
-identifiable sections of that work are not derived from the Program,
116
-and can be reasonably considered independent and separate works in
117
-themselves, then this License, and its terms, do not apply to those
118
-sections when you distribute them as separate works.  But when you
119
-distribute the same sections as part of a whole which is a work based
120
-on the Program, the distribution of the whole must be on the terms of
121
-this License, whose permissions for other licensees extend to the
122
-entire whole, and thus to each and every part regardless of who wrote it.
123
-
124
-Thus, it is not the intent of this section to claim rights or contest
125
-your rights to work written entirely by you; rather, the intent is to
126
-exercise the right to control the distribution of derivative or
127
-collective works based on the Program.
128
-
129
-In addition, mere aggregation of another work not based on the Program
130
-with the Program (or with a work based on the Program) on a volume of
131
-a storage or distribution medium does not bring the other work under
132
-the scope of this License.
133
-
134
-  3. You may copy and distribute the Program (or a work based on it,
135
-under Section 2) in object code or executable form under the terms of
136
-Sections 1 and 2 above provided that you also do one of the following:
137
-
138
-    a) Accompany it with the complete corresponding machine-readable
139
-    source code, which must be distributed under the terms of Sections
140
-    1 and 2 above on a medium customarily used for software interchange; or,
141
-
142
-    b) Accompany it with a written offer, valid for at least three
143
-    years, to give any third party, for a charge no more than your
144
-    cost of physically performing source distribution, a complete
145
-    machine-readable copy of the corresponding source code, to be
146
-    distributed under the terms of Sections 1 and 2 above on a medium
147
-    customarily used for software interchange; or,
148
-
149
-    c) Accompany it with the information you received as to the offer
150
-    to distribute corresponding source code.  (This alternative is
151
-    allowed only for noncommercial distribution and only if you
152
-    received the program in object code or executable form with such
153
-    an offer, in accord with Subsection b above.)
154
-
155
-The source code for a work means the preferred form of the work for
156
-making modifications to it.  For an executable work, complete source
157
-code means all the source code for all modules it contains, plus any
158
-associated interface definition files, plus the scripts used to
159
-control compilation and installation of the executable.  However, as a
160
-special exception, the source code distributed need not include
161
-anything that is normally distributed (in either source or binary
162
-form) with the major components (compiler, kernel, and so on) of the
163
-operating system on which the executable runs, unless that component
164
-itself accompanies the executable.
165
-
166
-If distribution of executable or object code is made by offering
167
-access to copy from a designated place, then offering equivalent
168
-access to copy the source code from the same place counts as
169
-distribution of the source code, even though third parties are not
170
-compelled to copy the source along with the object code.
171
-
172
-  4. You may not copy, modify, sublicense, or distribute the Program
173
-except as expressly provided under this License.  Any attempt
174
-otherwise to copy, modify, sublicense or distribute the Program is
175
-void, and will automatically terminate your rights under this License.
176
-However, parties who have received copies, or rights, from you under
177
-this License will not have their licenses terminated so long as such
178
-parties remain in full compliance.
179
-
180
-  5. You are not required to accept this License, since you have not
181
-signed it.  However, nothing else grants you permission to modify or
182
-distribute the Program or its derivative works.  These actions are
183
-prohibited by law if you do not accept this License.  Therefore, by
184
-modifying or distributing the Program (or any work based on the
185
-Program), you indicate your acceptance of this License to do so, and
186
-all its terms and conditions for copying, distributing or modifying
187
-the Program or works based on it.
188
-
189
-  6. Each time you redistribute the Program (or any work based on the
190
-Program), the recipient automatically receives a license from the
191
-original licensor to copy, distribute or modify the Program subject to
192
-these terms and conditions.  You may not impose any further
193
-restrictions on the recipients' exercise of the rights granted herein.
194
-You are not responsible for enforcing compliance by third parties to
195
-this License.
196
-
197
-  7. If, as a consequence of a court judgment or allegation of patent
198
-infringement or for any other reason (not limited to patent issues),
199
-conditions are imposed on you (whether by court order, agreement or
200
-otherwise) that contradict the conditions of this License, they do not
201
-excuse you from the conditions of this License.  If you cannot
202
-distribute so as to satisfy simultaneously your obligations under this
203
-License and any other pertinent obligations, then as a consequence you
204
-may not distribute the Program at all.  For example, if a patent
205
-license would not permit royalty-free redistribution of the Program by
206
-all those who receive copies directly or indirectly through you, then
207
-the only way you could satisfy both it and this License would be to
208
-refrain entirely from distribution of the Program.
209
-
210
-If any portion of this section is held invalid or unenforceable under
211
-any particular circumstance, the balance of the section is intended to
212
-apply and the section as a whole is intended to apply in other
213
-circumstances.
214
-
215
-It is not the purpose of this section to induce you to infringe any
216
-patents or other property right claims or to contest validity of any
217
-such claims; this section has the sole purpose of protecting the
218
-integrity of the free software distribution system, which is
219
-implemented by public license practices.  Many people have made
220
-generous contributions to the wide range of software distributed
221
-through that system in reliance on consistent application of that
222
-system; it is up to the author/donor to decide if he or she is willing
223
-to distribute software through any other system and a licensee cannot
224
-impose that choice.
225
-
226
-This section is intended to make thoroughly clear what is believed to
227
-be a consequence of the rest of this License.
228
-
229
-  8. If the distribution and/or use of the Program is restricted in
230
-certain countries either by patents or by copyrighted interfaces, the
231
-original copyright holder who places the Program under this License
232
-may add an explicit geographical distribution limitation excluding
233
-those countries, so that distribution is permitted only in or among
234
-countries not thus excluded.  In such case, this License incorporates
235
-the limitation as if written in the body of this License.
236
-
237
-  9. The Free Software Foundation may publish revised and/or new versions
238
-of the General Public License from time to time.  Such new versions will
239
-be similar in spirit to the present version, but may differ in detail to
240
-address new problems or concerns.
241
-
242
-Each version is given a distinguishing version number.  If the Program
243
-specifies a version number of this License which applies to it and "any
244
-later version", you have the option of following the terms and conditions
245
-either of that version or of any later version published by the Free
246
-Software Foundation.  If the Program does not specify a version number of
247
-this License, you may choose any version ever published by the Free Software
248
-Foundation.
249
-
250
-  10. If you wish to incorporate parts of the Program into other free
251
-programs whose distribution conditions are different, write to the author
252
-to ask for permission.  For software which is copyrighted by the Free
253
-Software Foundation, write to the Free Software Foundation; we sometimes
254
-make exceptions for this.  Our decision will be guided by the two goals
255
-of preserving the free status of all derivatives of our free software and
256
-of promoting the sharing and reuse of software generally.
257
-
258
-			    NO WARRANTY
259
-
260
-  11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
261
-FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW.  EXCEPT WHEN
262
-OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
263
-PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
264
-OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
265
-MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.  THE ENTIRE RISK AS
266
-TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU.  SHOULD THE
267
-PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
268
-REPAIR OR CORRECTION.
269
-
270
-  12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
271
-WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
272
-REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
273
-INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
274
-OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
275
-TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
276
-YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
277
-PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
278
-POSSIBILITY OF SUCH DAMAGES.
279
-
280
-		     END OF TERMS AND CONDITIONS
281
-
282
-	    How to Apply These Terms to Your New Programs
283
-
284
-  If you develop a new program, and you want it to be of the greatest
285
-possible use to the public, the best way to achieve this is to make it
286
-free software which everyone can redistribute and change under these terms.
287
-
288
-  To do so, attach the following notices to the program.  It is safest
289
-to attach them to the start of each source file to most effectively
290
-convey the exclusion of warranty; and each file should have at least
291
-the "copyright" line and a pointer to where the full notice is found.
292
-
293
-    <one line to give the program's name and a brief idea of what it does.>
294
-    Copyright (C) <year>  <name of author>
295
-
296
-    This program is free software; you can redistribute it and/or modify
297
-    it under the terms of the GNU General Public License as published by
298
-    the Free Software Foundation; either version 2 of the License, or
299
-    (at your option) any later version.
300
-
301
-    This program is distributed in the hope that it will be useful,
302
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
303
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
304
-    GNU General Public License for more details.
305
-
306
-    You should have received a copy of the GNU General Public License along
307
-    with this program; if not, write to the Free Software Foundation, Inc.,
308
-    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
309
-
310
-Also add information on how to contact you by electronic and paper mail.
311
-
312
-If the program is interactive, make it output a short notice like this
313
-when it starts in an interactive mode:
314
-
315
-    Gnomovision version 69, Copyright (C) year name of author
316
-    Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
317
-    This is free software, and you are welcome to redistribute it
318
-    under certain conditions; type `show c' for details.
319
-
320
-The hypothetical commands `show w' and `show c' should show the appropriate
321
-parts of the General Public License.  Of course, the commands you use may
322
-be called something other than `show w' and `show c'; they could even be
323
-mouse-clicks or menu items--whatever suits your program.
324
-
325
-You should also get your employer (if you work as a programmer) or your
326
-school, if any, to sign a "copyright disclaimer" for the program, if
327
-necessary.  Here is a sample; alter the names:
328
-
329
-  Yoyodyne, Inc., hereby disclaims all copyright interest in the program
330
-  `Gnomovision' (which makes passes at compilers) written by James Hacker.
331
-
332
-  <signature of Ty Coon>, 1 April 1989
333
-  Ty Coon, President of Vice
334
-
335
-This General Public License does not permit incorporating your program into
336
-proprietary programs.  If your program is a subroutine library, you may
337
-consider it more useful to permit linking proprietary applications with the
338
-library.  If this is what you want to do, use the GNU Lesser General
339
-Public License instead of this License.

+ 0
- 674
doc/GPLv3 Целия файл

@@ -1,674 +0,0 @@
1
-                    GNU GENERAL PUBLIC LICENSE
2
-                       Version 3, 29 June 2007
3
-
4
- Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
5
- Everyone is permitted to copy and distribute verbatim copies
6
- of this license document, but changing it is not allowed.
7
-
8
-                            Preamble
9
-
10
-  The GNU General Public License is a free, copyleft license for
11
-software and other kinds of works.
12
-
13
-  The licenses for most software and other practical works are designed
14
-to take away your freedom to share and change the works.  By contrast,
15
-the GNU General Public License is intended to guarantee your freedom to
16
-share and change all versions of a program--to make sure it remains free
17
-software for all its users.  We, the Free Software Foundation, use the
18
-GNU General Public License for most of our software; it applies also to
19
-any other work released this way by its authors.  You can apply it to
20
-your programs, too.
21
-
22
-  When we speak of free software, we are referring to freedom, not
23
-price.  Our General Public Licenses are designed to make sure that you
24
-have the freedom to distribute copies of free software (and charge for
25
-them if you wish), that you receive source code or can get it if you
26
-want it, that you can change the software or use pieces of it in new
27
-free programs, and that you know you can do these things.
28
-
29
-  To protect your rights, we need to prevent others from denying you
30
-these rights or asking you to surrender the rights.  Therefore, you have
31
-certain responsibilities if you distribute copies of the software, or if
32
-you modify it: responsibilities to respect the freedom of others.
33
-
34
-  For example, if you distribute copies of such a program, whether
35
-gratis or for a fee, you must pass on to the recipients the same
36
-freedoms that you received.  You must make sure that they, too, receive
37
-or can get the source code.  And you must show them these terms so they
38
-know their rights.
39
-
40
-  Developers that use the GNU GPL protect your rights with two steps:
41
-(1) assert copyright on the software, and (2) offer you this License
42
-giving you legal permission to copy, distribute and/or modify it.
43
-
44
-  For the developers' and authors' protection, the GPL clearly explains
45
-that there is no warranty for this free software.  For both users' and
46
-authors' sake, the GPL requires that modified versions be marked as
47
-changed, so that their problems will not be attributed erroneously to
48
-authors of previous versions.
49
-
50
-  Some devices are designed to deny users access to install or run
51
-modified versions of the software inside them, although the manufacturer
52
-can do so.  This is fundamentally incompatible with the aim of
53
-protecting users' freedom to change the software.  The systematic
54
-pattern of such abuse occurs in the area of products for individuals to
55
-use, which is precisely where it is most unacceptable.  Therefore, we
56
-have designed this version of the GPL to prohibit the practice for those
57
-products.  If such problems arise substantially in other domains, we
58
-stand ready to extend this provision to those domains in future versions
59
-of the GPL, as needed to protect the freedom of users.
60
-
61
-  Finally, every program is threatened constantly by software patents.
62
-States should not allow patents to restrict development and use of
63
-software on general-purpose computers, but in those that do, we wish to
64
-avoid the special danger that patents applied to a free program could
65
-make it effectively proprietary.  To prevent this, the GPL assures that
66
-patents cannot be used to render the program non-free.
67
-
68
-  The precise terms and conditions for copying, distribution and
69
-modification follow.
70
-
71
-                       TERMS AND CONDITIONS
72
-
73
-  0. Definitions.
74
-
75
-  "This License" refers to version 3 of the GNU General Public License.
76
-
77
-  "Copyright" also means copyright-like laws that apply to other kinds of
78
-works, such as semiconductor masks.
79
-
80
-  "The Program" refers to any copyrightable work licensed under this
81
-License.  Each licensee is addressed as "you".  "Licensees" and
82
-"recipients" may be individuals or organizations.
83
-
84
-  To "modify" a work means to copy from or adapt all or part of the work
85
-in a fashion requiring copyright permission, other than the making of an
86
-exact copy.  The resulting work is called a "modified version" of the
87
-earlier work or a work "based on" the earlier work.
88
-
89
-  A "covered work" means either the unmodified Program or a work based
90
-on the Program.
91
-
92
-  To "propagate" a work means to do anything with it that, without
93
-permission, would make you directly or secondarily liable for
94
-infringement under applicable copyright law, except executing it on a
95
-computer or modifying a private copy.  Propagation includes copying,
96
-distribution (with or without modification), making available to the
97
-public, and in some countries other activities as well.
98
-
99
-  To "convey" a work means any kind of propagation that enables other
100
-parties to make or receive copies.  Mere interaction with a user through
101
-a computer network, with no transfer of a copy, is not conveying.
102
-
103
-  An interactive user interface displays "Appropriate Legal Notices"
104
-to the extent that it includes a convenient and prominently visible
105
-feature that (1) displays an appropriate copyright notice, and (2)
106
-tells the user that there is no warranty for the work (except to the
107
-extent that warranties are provided), that licensees may convey the
108
-work under this License, and how to view a copy of this License.  If
109
-the interface presents a list of user commands or options, such as a
110
-menu, a prominent item in the list meets this criterion.
111
-
112
-  1. Source Code.
113
-
114
-  The "source code" for a work means the preferred form of the work
115
-for making modifications to it.  "Object code" means any non-source
116
-form of a work.
117
-
118
-  A "Standard Interface" means an interface that either is an official
119
-standard defined by a recognized standards body, or, in the case of
120
-interfaces specified for a particular programming language, one that
121
-is widely used among developers working in that language.
122
-
123
-  The "System Libraries" of an executable work include anything, other
124
-than the work as a whole, that (a) is included in the normal form of
125
-packaging a Major Component, but which is not part of that Major
126
-Component, and (b) serves only to enable use of the work with that
127
-Major Component, or to implement a Standard Interface for which an
128
-implementation is available to the public in source code form.  A
129
-"Major Component", in this context, means a major essential component
130
-(kernel, window system, and so on) of the specific operating system
131
-(if any) on which the executable work runs, or a compiler used to
132
-produce the work, or an object code interpreter used to run it.
133
-
134
-  The "Corresponding Source" for a work in object code form means all
135
-the source code needed to generate, install, and (for an executable
136
-work) run the object code and to modify the work, including scripts to
137
-control those activities.  However, it does not include the work's
138
-System Libraries, or general-purpose tools or generally available free
139
-programs which are used unmodified in performing those activities but
140
-which are not part of the work.  For example, Corresponding Source
141
-includes interface definition files associated with source files for
142
-the work, and the source code for shared libraries and dynamically
143
-linked subprograms that the work is specifically designed to require,
144
-such as by intimate data communication or control flow between those
145
-subprograms and other parts of the work.
146
-
147
-  The Corresponding Source need not include anything that users
148
-can regenerate automatically from other parts of the Corresponding
149
-Source.
150
-
151
-  The Corresponding Source for a work in source code form is that
152
-same work.
153
-
154
-  2. Basic Permissions.
155
-
156
-  All rights granted under this License are granted for the term of
157
-copyright on the Program, and are irrevocable provided the stated
158
-conditions are met.  This License explicitly affirms your unlimited
159
-permission to run the unmodified Program.  The output from running a
160
-covered work is covered by this License only if the output, given its
161
-content, constitutes a covered work.  This License acknowledges your
162
-rights of fair use or other equivalent, as provided by copyright law.
163
-
164
-  You may make, run and propagate covered works that you do not
165
-convey, without conditions so long as your license otherwise remains
166
-in force.  You may convey covered works to others for the sole purpose
167
-of having them make modifications exclusively for you, or provide you
168
-with facilities for running those works, provided that you comply with
169
-the terms of this License in conveying all material for which you do
170
-not control copyright.  Those thus making or running the covered works
171
-for you must do so exclusively on your behalf, under your direction
172
-and control, on terms that prohibit them from making any copies of
173
-your copyrighted material outside their relationship with you.
174
-
175
-  Conveying under any other circumstances is permitted solely under
176
-the conditions stated below.  Sublicensing is not allowed; section 10
177
-makes it unnecessary.
178
-
179
-  3. Protecting Users' Legal Rights From Anti-Circumvention Law.
180
-
181
-  No covered work shall be deemed part of an effective technological
182
-measure under any applicable law fulfilling obligations under article
183
-11 of the WIPO copyright treaty adopted on 20 December 1996, or
184
-similar laws prohibiting or restricting circumvention of such
185
-measures.
186
-
187
-  When you convey a covered work, you waive any legal power to forbid
188
-circumvention of technological measures to the extent such circumvention
189
-is effected by exercising rights under this License with respect to
190
-the covered work, and you disclaim any intention to limit operation or
191
-modification of the work as a means of enforcing, against the work's
192
-users, your or third parties' legal rights to forbid circumvention of
193
-technological measures.
194
-
195
-  4. Conveying Verbatim Copies.
196
-
197
-  You may convey verbatim copies of the Program's source code as you
198
-receive it, in any medium, provided that you conspicuously and
199
-appropriately publish on each copy an appropriate copyright notice;
200
-keep intact all notices stating that this License and any
201
-non-permissive terms added in accord with section 7 apply to the code;
202
-keep intact all notices of the absence of any warranty; and give all
203
-recipients a copy of this License along with the Program.
204
-
205
-  You may charge any price or no price for each copy that you convey,
206
-and you may offer support or warranty protection for a fee.
207
-
208
-  5. Conveying Modified Source Versions.
209
-
210
-  You may convey a work based on the Program, or the modifications to
211
-produce it from the Program, in the form of source code under the
212
-terms of section 4, provided that you also meet all of these conditions:
213
-
214
-    a) The work must carry prominent notices stating that you modified
215
-    it, and giving a relevant date.
216
-
217
-    b) The work must carry prominent notices stating that it is
218
-    released under this License and any conditions added under section
219
-    7.  This requirement modifies the requirement in section 4 to
220
-    "keep intact all notices".
221
-
222
-    c) You must license the entire work, as a whole, under this
223
-    License to anyone who comes into possession of a copy.  This
224
-    License will therefore apply, along with any applicable section 7
225
-    additional terms, to the whole of the work, and all its parts,
226
-    regardless of how they are packaged.  This License gives no
227
-    permission to license the work in any other way, but it does not
228
-    invalidate such permission if you have separately received it.
229
-
230
-    d) If the work has interactive user interfaces, each must display
231
-    Appropriate Legal Notices; however, if the Program has interactive
232
-    interfaces that do not display Appropriate Legal Notices, your
233
-    work need not make them do so.
234
-
235
-  A compilation of a covered work with other separate and independent
236
-works, which are not by their nature extensions of the covered work,
237
-and which are not combined with it such as to form a larger program,
238
-in or on a volume of a storage or distribution medium, is called an
239
-"aggregate" if the compilation and its resulting copyright are not
240
-used to limit the access or legal rights of the compilation's users
241
-beyond what the individual works permit.  Inclusion of a covered work
242
-in an aggregate does not cause this License to apply to the other
243
-parts of the aggregate.
244
-
245
-  6. Conveying Non-Source Forms.
246
-
247
-  You may convey a covered work in object code form under the terms
248
-of sections 4 and 5, provided that you also convey the
249
-machine-readable Corresponding Source under the terms of this License,
250
-in one of these ways:
251
-
252
-    a) Convey the object code in, or embodied in, a physical product
253
-    (including a physical distribution medium), accompanied by the
254
-    Corresponding Source fixed on a durable physical medium
255
-    customarily used for software interchange.
256
-
257
-    b) Convey the object code in, or embodied in, a physical product
258
-    (including a physical distribution medium), accompanied by a
259
-    written offer, valid for at least three years and valid for as
260
-    long as you offer spare parts or customer support for that product
261
-    model, to give anyone who possesses the object code either (1) a
262
-    copy of the Corresponding Source for all the software in the
263
-    product that is covered by this License, on a durable physical
264
-    medium customarily used for software interchange, for a price no
265
-    more than your reasonable cost of physically performing this
266
-    conveying of source, or (2) access to copy the
267
-    Corresponding Source from a network server at no charge.
268
-
269
-    c) Convey individual copies of the object code with a copy of the
270
-    written offer to provide the Corresponding Source.  This
271
-    alternative is allowed only occasionally and noncommercially, and
272
-    only if you received the object code with such an offer, in accord
273
-    with subsection 6b.
274
-
275
-    d) Convey the object code by offering access from a designated
276
-    place (gratis or for a charge), and offer equivalent access to the
277
-    Corresponding Source in the same way through the same place at no
278
-    further charge.  You need not require recipients to copy the
279
-    Corresponding Source along with the object code.  If the place to
280
-    copy the object code is a network server, the Corresponding Source
281
-    may be on a different server (operated by you or a third party)
282
-    that supports equivalent copying facilities, provided you maintain
283
-    clear directions next to the object code saying where to find the
284
-    Corresponding Source.  Regardless of what server hosts the
285
-    Corresponding Source, you remain obligated to ensure that it is
286
-    available for as long as needed to satisfy these requirements.
287
-
288
-    e) Convey the object code using peer-to-peer transmission, provided
289
-    you inform other peers where the object code and Corresponding
290
-    Source of the work are being offered to the general public at no
291
-    charge under subsection 6d.
292
-
293
-  A separable portion of the object code, whose source code is excluded
294
-from the Corresponding Source as a System Library, need not be
295
-included in conveying the object code work.
296
-
297
-  A "User Product" is either (1) a "consumer product", which means any
298
-tangible personal property which is normally used for personal, family,
299
-or household purposes, or (2) anything designed or sold for incorporation
300
-into a dwelling.  In determining whether a product is a consumer product,
301
-doubtful cases shall be resolved in favor of coverage.  For a particular
302
-product received by a particular user, "normally used" refers to a
303
-typical or common use of that class of product, regardless of the status
304
-of the particular user or of the way in which the particular user
305
-actually uses, or expects or is expected to use, the product.  A product
306
-is a consumer product regardless of whether the product has substantial
307
-commercial, industrial or non-consumer uses, unless such uses represent
308
-the only significant mode of use of the product.
309
-
310
-  "Installation Information" for a User Product means any methods,
311
-procedures, authorization keys, or other information required to install
312
-and execute modified versions of a covered work in that User Product from
313
-a modified version of its Corresponding Source.  The information must
314
-suffice to ensure that the continued functioning of the modified object
315
-code is in no case prevented or interfered with solely because
316
-modification has been made.
317
-
318
-  If you convey an object code work under this section in, or with, or
319
-specifically for use in, a User Product, and the conveying occurs as
320
-part of a transaction in which the right of possession and use of the
321
-User Product is transferred to the recipient in perpetuity or for a
322
-fixed term (regardless of how the transaction is characterized), the
323
-Corresponding Source conveyed under this section must be accompanied
324
-by the Installation Information.  But this requirement does not apply
325
-if neither you nor any third party retains the ability to install
326
-modified object code on the User Product (for example, the work has
327
-been installed in ROM).
328
-
329
-  The requirement to provide Installation Information does not include a
330
-requirement to continue to provide support service, warranty, or updates
331
-for a work that has been modified or installed by the recipient, or for
332
-the User Product in which it has been modified or installed.  Access to a
333
-network may be denied when the modification itself materially and
334
-adversely affects the operation of the network or violates the rules and
335
-protocols for communication across the network.
336
-
337
-  Corresponding Source conveyed, and Installation Information provided,
338
-in accord with this section must be in a format that is publicly
339
-documented (and with an implementation available to the public in
340
-source code form), and must require no special password or key for
341
-unpacking, reading or copying.
342
-
343
-  7. Additional Terms.
344
-
345
-  "Additional permissions" are terms that supplement the terms of this
346
-License by making exceptions from one or more of its conditions.
347
-Additional permissions that are applicable to the entire Program shall
348
-be treated as though they were included in this License, to the extent
349
-that they are valid under applicable law.  If additional permissions
350
-apply only to part of the Program, that part may be used separately
351
-under those permissions, but the entire Program remains governed by
352
-this License without regard to the additional permissions.
353
-
354
-  When you convey a copy of a covered work, you may at your option
355
-remove any additional permissions from that copy, or from any part of
356
-it.  (Additional permissions may be written to require their own
357
-removal in certain cases when you modify the work.)  You may place
358
-additional permissions on material, added by you to a covered work,
359
-for which you have or can give appropriate copyright permission.
360
-
361
-  Notwithstanding any other provision of this License, for material you
362
-add to a covered work, you may (if authorized by the copyright holders of
363
-that material) supplement the terms of this License with terms:
364
-
365
-    a) Disclaiming warranty or limiting liability differently from the
366
-    terms of sections 15 and 16 of this License; or
367
-
368
-    b) Requiring preservation of specified reasonable legal notices or
369
-    author attributions in that material or in the Appropriate Legal
370
-    Notices displayed by works containing it; or
371
-
372
-    c) Prohibiting misrepresentation of the origin of that material, or
373
-    requiring that modified versions of such material be marked in
374
-    reasonable ways as different from the original version; or
375
-
376
-    d) Limiting the use for publicity purposes of names of licensors or
377
-    authors of the material; or
378
-
379
-    e) Declining to grant rights under trademark law for use of some
380
-    trade names, trademarks, or service marks; or
381
-
382
-    f) Requiring indemnification of licensors and authors of that
383
-    material by anyone who conveys the material (or modified versions of
384
-    it) with contractual assumptions of liability to the recipient, for
385
-    any liability that these contractual assumptions directly impose on
386
-    those licensors and authors.
387
-
388
-  All other non-permissive additional terms are considered "further
389
-restrictions" within the meaning of section 10.  If the Program as you
390
-received it, or any part of it, contains a notice stating that it is
391
-governed by this License along with a term that is a further
392
-restriction, you may remove that term.  If a license document contains
393
-a further restriction but permits relicensing or conveying under this
394
-License, you may add to a covered work material governed by the terms
395
-of that license document, provided that the further restriction does
396
-not survive such relicensing or conveying.
397
-
398
-  If you add terms to a covered work in accord with this section, you
399
-must place, in the relevant source files, a statement of the
400
-additional terms that apply to those files, or a notice indicating
401
-where to find the applicable terms.
402
-
403
-  Additional terms, permissive or non-permissive, may be stated in the
404
-form of a separately written license, or stated as exceptions;
405
-the above requirements apply either way.
406
-
407
-  8. Termination.
408
-
409
-  You may not propagate or modify a covered work except as expressly
410
-provided under this License.  Any attempt otherwise to propagate or
411
-modify it is void, and will automatically terminate your rights under
412
-this License (including any patent licenses granted under the third
413
-paragraph of section 11).
414
-
415
-  However, if you cease all violation of this License, then your
416
-license from a particular copyright holder is reinstated (a)
417
-provisionally, unless and until the copyright holder explicitly and
418
-finally terminates your license, and (b) permanently, if the copyright
419
-holder fails to notify you of the violation by some reasonable means
420
-prior to 60 days after the cessation.
421
-
422
-  Moreover, your license from a particular copyright holder is
423
-reinstated permanently if the copyright holder notifies you of the
424
-violation by some reasonable means, this is the first time you have
425
-received notice of violation of this License (for any work) from that
426
-copyright holder, and you cure the violation prior to 30 days after
427
-your receipt of the notice.
428
-
429
-  Termination of your rights under this section does not terminate the
430
-licenses of parties who have received copies or rights from you under
431
-this License.  If your rights have been terminated and not permanently
432
-reinstated, you do not qualify to receive new licenses for the same
433
-material under section 10.
434
-
435
-  9. Acceptance Not Required for Having Copies.
436
-
437
-  You are not required to accept this License in order to receive or
438
-run a copy of the Program.  Ancillary propagation of a covered work
439
-occurring solely as a consequence of using peer-to-peer transmission
440
-to receive a copy likewise does not require acceptance.  However,
441
-nothing other than this License grants you permission to propagate or
442
-modify any covered work.  These actions infringe copyright if you do
443
-not accept this License.  Therefore, by modifying or propagating a
444
-covered work, you indicate your acceptance of this License to do so.
445
-
446
-  10. Automatic Licensing of Downstream Recipients.
447
-
448
-  Each time you convey a covered work, the recipient automatically
449
-receives a license from the original licensors, to run, modify and
450
-propagate that work, subject to this License.  You are not responsible
451
-for enforcing compliance by third parties with this License.
452
-
453
-  An "entity transaction" is a transaction transferring control of an
454
-organization, or substantially all assets of one, or subdividing an
455
-organization, or merging organizations.  If propagation of a covered
456
-work results from an entity transaction, each party to that
457
-transaction who receives a copy of the work also receives whatever
458
-licenses to the work the party's predecessor in interest had or could
459
-give under the previous paragraph, plus a right to possession of the
460
-Corresponding Source of the work from the predecessor in interest, if
461
-the predecessor has it or can get it with reasonable efforts.
462
-
463
-  You may not impose any further restrictions on the exercise of the
464
-rights granted or affirmed under this License.  For example, you may
465
-not impose a license fee, royalty, or other charge for exercise of
466
-rights granted under this License, and you may not initiate litigation
467
-(including a cross-claim or counterclaim in a lawsuit) alleging that
468
-any patent claim is infringed by making, using, selling, offering for
469
-sale, or importing the Program or any portion of it.
470
-
471
-  11. Patents.
472
-
473
-  A "contributor" is a copyright holder who authorizes use under this
474
-License of the Program or a work on which the Program is based.  The
475
-work thus licensed is called the contributor's "contributor version".
476
-
477
-  A contributor's "essential patent claims" are all patent claims
478
-owned or controlled by the contributor, whether already acquired or
479
-hereafter acquired, that would be infringed by some manner, permitted
480
-by this License, of making, using, or selling its contributor version,
481
-but do not include claims that would be infringed only as a
482
-consequence of further modification of the contributor version.  For
483
-purposes of this definition, "control" includes the right to grant
484
-patent sublicenses in a manner consistent with the requirements of
485
-this License.
486
-
487
-  Each contributor grants you a non-exclusive, worldwide, royalty-free
488
-patent license under the contributor's essential patent claims, to
489
-make, use, sell, offer for sale, import and otherwise run, modify and
490
-propagate the contents of its contributor version.
491
-
492
-  In the following three paragraphs, a "patent license" is any express
493
-agreement or commitment, however denominated, not to enforce a patent
494
-(such as an express permission to practice a patent or covenant not to
495
-sue for patent infringement).  To "grant" such a patent license to a
496
-party means to make such an agreement or commitment not to enforce a
497
-patent against the party.
498
-
499
-  If you convey a covered work, knowingly relying on a patent license,
500
-and the Corresponding Source of the work is not available for anyone
501
-to copy, free of charge and under the terms of this License, through a
502
-publicly available network server or other readily accessible means,
503
-then you must either (1) cause the Corresponding Source to be so
504
-available, or (2) arrange to deprive yourself of the benefit of the
505
-patent license for this particular work, or (3) arrange, in a manner
506
-consistent with the requirements of this License, to extend the patent
507
-license to downstream recipients.  "Knowingly relying" means you have
508
-actual knowledge that, but for the patent license, your conveying the
509
-covered work in a country, or your recipient's use of the covered work
510
-in a country, would infringe one or more identifiable patents in that
511
-country that you have reason to believe are valid.
512
-
513
-  If, pursuant to or in connection with a single transaction or
514
-arrangement, you convey, or propagate by procuring conveyance of, a
515
-covered work, and grant a patent license to some of the parties
516
-receiving the covered work authorizing them to use, propagate, modify
517
-or convey a specific copy of the covered work, then the patent license
518
-you grant is automatically extended to all recipients of the covered
519
-work and works based on it.
520
-
521
-  A patent license is "discriminatory" if it does not include within
522
-the scope of its coverage, prohibits the exercise of, or is
523
-conditioned on the non-exercise of one or more of the rights that are
524
-specifically granted under this License.  You may not convey a covered
525
-work if you are a party to an arrangement with a third party that is
526
-in the business of distributing software, under which you make payment
527
-to the third party based on the extent of your activity of conveying
528
-the work, and under which the third party grants, to any of the
529
-parties who would receive the covered work from you, a discriminatory
530
-patent license (a) in connection with copies of the covered work
531
-conveyed by you (or copies made from those copies), or (b) primarily
532
-for and in connection with specific products or compilations that
533
-contain the covered work, unless you entered into that arrangement,
534
-or that patent license was granted, prior to 28 March 2007.
535
-
536
-  Nothing in this License shall be construed as excluding or limiting
537
-any implied license or other defenses to infringement that may
538
-otherwise be available to you under applicable patent law.
539
-
540
-  12. No Surrender of Others' Freedom.
541
-
542
-  If conditions are imposed on you (whether by court order, agreement or
543
-otherwise) that contradict the conditions of this License, they do not
544
-excuse you from the conditions of this License.  If you cannot convey a
545
-covered work so as to satisfy simultaneously your obligations under this
546
-License and any other pertinent obligations, then as a consequence you may
547
-not convey it at all.  For example, if you agree to terms that obligate you
548
-to collect a royalty for further conveying from those to whom you convey
549
-the Program, the only way you could satisfy both those terms and this
550
-License would be to refrain entirely from conveying the Program.
551
-
552
-  13. Use with the GNU Affero General Public License.
553
-
554
-  Notwithstanding any other provision of this License, you have
555
-permission to link or combine any covered work with a work licensed
556
-under version 3 of the GNU Affero General Public License into a single
557
-combined work, and to convey the resulting work.  The terms of this
558
-License will continue to apply to the part which is the covered work,
559
-but the special requirements of the GNU Affero General Public License,
560
-section 13, concerning interaction through a network will apply to the
561
-combination as such.
562
-
563
-  14. Revised Versions of this License.
564
-
565
-  The Free Software Foundation may publish revised and/or new versions of
566
-the GNU General Public License from time to time.  Such new versions will
567
-be similar in spirit to the present version, but may differ in detail to
568
-address new problems or concerns.
569
-
570
-  Each version is given a distinguishing version number.  If the
571
-Program specifies that a certain numbered version of the GNU General
572
-Public License "or any later version" applies to it, you have the
573
-option of following the terms and conditions either of that numbered
574
-version or of any later version published by the Free Software
575
-Foundation.  If the Program does not specify a version number of the
576
-GNU General Public License, you may choose any version ever published
577
-by the Free Software Foundation.
578
-
579
-  If the Program specifies that a proxy can decide which future
580
-versions of the GNU General Public License can be used, that proxy's
581
-public statement of acceptance of a version permanently authorizes you
582
-to choose that version for the Program.
583
-
584
-  Later license versions may give you additional or different
585
-permissions.  However, no additional obligations are imposed on any
586
-author or copyright holder as a result of your choosing to follow a
587
-later version.
588
-
589
-  15. Disclaimer of Warranty.
590
-
591
-  THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
592
-APPLICABLE LAW.  EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
593
-HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
594
-OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
595
-THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
596
-PURPOSE.  THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
597
-IS WITH YOU.  SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
598
-ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
599
-
600
-  16. Limitation of Liability.
601
-
602
-  IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
603
-WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
604
-THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
605
-GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
606
-USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
607
-DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
608
-PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
609
-EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
610
-SUCH DAMAGES.
611
-
612
-  17. Interpretation of Sections 15 and 16.
613
-
614
-  If the disclaimer of warranty and limitation of liability provided
615
-above cannot be given local legal effect according to their terms,
616
-reviewing courts shall apply local law that most closely approximates
617
-an absolute waiver of all civil liability in connection with the
618
-Program, unless a warranty or assumption of liability accompanies a
619
-copy of the Program in return for a fee.
620
-
621
-                     END OF TERMS AND CONDITIONS
622
-
623
-            How to Apply These Terms to Your New Programs
624
-
625
-  If you develop a new program, and you want it to be of the greatest
626
-possible use to the public, the best way to achieve this is to make it
627
-free software which everyone can redistribute and change under these terms.
628
-
629
-  To do so, attach the following notices to the program.  It is safest
630
-to attach them to the start of each source file to most effectively
631
-state the exclusion of warranty; and each file should have at least
632
-the "copyright" line and a pointer to where the full notice is found.
633
-
634
-    <one line to give the program's name and a brief idea of what it does.>
635
-    Copyright (C) <year>  <name of author>
636
-
637
-    This program is free software: you can redistribute it and/or modify
638
-    it under the terms of the GNU General Public License as published by
639
-    the Free Software Foundation, either version 3 of the License, or
640
-    (at your option) any later version.
641
-
642
-    This program is distributed in the hope that it will be useful,
643
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
644
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
645
-    GNU General Public License for more details.
646
-
647
-    You should have received a copy of the GNU General Public License
648
-    along with this program.  If not, see <http://www.gnu.org/licenses/>.
649
-
650
-Also add information on how to contact you by electronic and paper mail.
651
-
652
-  If the program does terminal interaction, make it output a short
653
-notice like this when it starts in an interactive mode:
654
-
655
-    <program>  Copyright (C) <year>  <name of author>
656
-    This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
657
-    This is free software, and you are welcome to redistribute it
658
-    under certain conditions; type `show c' for details.
659
-
660
-The hypothetical commands `show w' and `show c' should show the appropriate
661
-parts of the General Public License.  Of course, your program's commands
662
-might be different; for a GUI interface, you would use an "about box".
663
-
664
-  You should also get your employer (if you work as a programmer) or school,
665
-if any, to sign a "copyright disclaimer" for the program, if necessary.
666
-For more information on this, and how to apply and follow the GNU GPL, see
667
-<http://www.gnu.org/licenses/>.
668
-
669
-  The GNU General Public License does not permit incorporating your program
670
-into proprietary programs.  If your program is a subroutine library, you
671
-may consider it more useful to permit linking proprietary applications with
672
-the library.  If this is what you want to do, use the GNU Lesser General
673
-Public License instead of this License.  But first, please read
674
-<http://www.gnu.org/philosophy/why-not-lgpl.html>.

+ 0
- 10
doc/INSTALL Целия файл

@@ -1,10 +0,0 @@
1
-gitstats does not currently need to be installed; it's used right from the
2
-directory (it also assumes some files like the stylesheet are in .)
3
-
4
-Suppose you have a git project at /mnt/src/git/project
5
-and you want to save the statistics to ~/public_html/project
6
-
7
-You would run:
8
-$ ./gitstats /mnt/src/git/project ~/public_html/project
9
-(go grab a cup of coffee if it's a large project :)
10
-$ sensible-browser ~/public_html/project/index.html

+ 0
- 4
doc/LICENSE Целия файл

@@ -1,4 +0,0 @@
1
-gitstats license is GPLv2/GPLv3, see doc/GPLv2 and doc/GPLv3 respectively.
2
-
3
-sortable.js, contained in gitstats, is licensed under the MIT license. See the
4
-file itself for details.

+ 0
- 22
doc/README Целия файл

@@ -1,22 +0,0 @@
1
-gitstats is a statistics generator for git repositories.  It is mostly intended
2
-for developers, as a way to check some development statistics for a project.
3
-
4
-Currently it produces only HTML output with tables and graphs.
5
-
6
-Requirements
7
-============
8
-- Python (>= 2.6.0)
9
-- Git (>= 1.5.2.4)
10
-- Gnuplot (>= 4.0.0)
11
-- a git repository (bare clone will work as well)
12
-
13
-The above versions are not absolute requirements; older versions may work also.
14
-
15
-Recommended
16
-===========
17
-- Lots of memory and fast disk for large projects
18
-
19
-Contributions
20
-=============
21
-Patches should be sent under "GPLv2 or later" license - this will allow
22
-upgrading to newer GPL versions if they are sensible.

+ 0
- 77
doc/TODO.txt Целия файл

@@ -1,77 +0,0 @@
1
-[]
2
-- cleanup: use defaultdict(int) for counting dicts instead of foo[x] = foo.get(x, 0) + 1
3
-	- not supported in python 2.4 - do any users use python 2.4?
4
-	- debian lenny (oldstable) has python 2.5
5
-- bug: multirepo tags
6
-	- self.tags contains tags from all repos - WRONG
7
-
8
-- general: analysis, ohloh-like?
9
-	- age: active days / days - high % means active project usually
10
-	- number of contributors (& their active days)
11
-
12
-- https://sourceforge.net/tracker/index.php?func=detail&aid=2865754&group_id=203965&atid=987714
13
-	- gitstats is a great tool, but the one thing that I miss is the number of
14
-	SLOC or comments on the "lines of code" image. Could this somehow be
15
-	added?
16
-
17
-[Unsorted]
18
-- clean up after running gnuplot (option to keep .dat files around?)
19
-- show raw data in some way (the tables used currently aren't very nice)
20
-- allow multiple stylesheets
21
-	- parameter --style
22
-	- styles/{default,...}.css
23
-- could show some statistics from last year, month, etc... pisg-like?
24
-- Commandline options
25
-	--debug / --verbose
26
-- save command line settings and use them next run if not overridden?
27
-
28
-[Stats]
29
-- General
30
-	- Total repository size (slooooow)?
31
-
32
-- Activity by Time?
33
-	- (G?) Last 30 days
34
-	- (G?) Last 12 months
35
-	- (T) Hour of Week: percentages / coloring?
36
-	- (G) Pace of Changes - number of line/other changes happening over time
37
-
38
-- Authors
39
-	- (T) List of authors
40
-		- Lines
41
-	- (T) Author of Month
42
-		- Lines
43
-	- (T) Author of Year
44
-		- Lines
45
-
46
-- Files
47
-	- Average revisions per file
48
-	- (G) Average file size: x = date, y = lines/file
49
-	- (T) Largest Files?
50
-	- (T) Files With Most Revisions?
51
-
52
-- Lines
53
-	- Average lines/file
54
-	- (G) Lines of Code: show tags as vertical lines?
55
-
56
-- Tags
57
-	- Lines
58
-
59
-- Author page for each author
60
-	- Name, mail
61
-	- Total commits (%)
62
-	- LOC (%)
63
-	- Last commit: date
64
-	- First commit: date
65
-	- Activity by Clock Time
66
-		- (G) Hour of Day
67
-		- (G) Day of Week
68
-	- (T) Activity in Directories: Directory, Changes, LOC, LOC/change
69
-	- (Most Recent Commits?)
70
-	- Author of Month(s):
71
-	- Author of Year(s):
72
-
73
-- Pages for years?
74
-	- Commits (% of all)
75
-	- Author top ten
76
-	- Month statistics
77
-

+ 0
- 115
doc/gitstats.pod Целия файл

@@ -1,115 +0,0 @@
1
-=encoding utf8
2
-
3
-=head1 NAME
4
-
5
-gitstats - git history statistics generator
6
-
7
-=head1 SYNOPSIS
8
-
9
-B<gitstats> [options] <repository dir> <output dir>
10
-
11
-=head1 DESCRIPTION
12
-
13
-B<gitstats> is a statistics generator for L<git(1)> repositories. It examines the repository and produces some interesting statistics from the history of it. Currently HTML is the only output format.
14
-
15
-=head1 OPTIONS
16
-
17
--c option=value
18
-
19
-Override a default configuration value. Defaults can be seen by running B<gitstats> without parameters.
20
-
21
-=head2 Values:
22
-
23
-=over
24
-
25
-=item authors_top
26
-
27
-How many top authors to show.
28
-
29
-=item commit_begin, commit_end
30
-
31
-Specify a commit range to generate statistics from. You can specify only commit_end limit statistics to a certain commit or another branch.
32
-
33
-=item linear_linestats
34
-
35
-When enabled, the lines of code statistics are collected from linear history.
36
-The downside is that commits of long feature branches appear only at the point
37
-where a merge commit is made.
38
-
39
-If disabled (old behaviour), the problem is that if two branches contain the
40
-same changes (for example, removal of same lines), the statistics get skewed.
41
-
42
-Defaults to on.
43
-
44
-=item max_authors
45
-
46
-How many authors to show in the list of authors.
47
-
48
-=item max_domains
49
-
50
-How many domains to show in domains by commits.
51
-
52
-=item max_ext_length
53
-
54
-Maximum file extension length.
55
-
56
-=item processes
57
-
58
-Number of concurrent processes to use when extracting git repository data.
59
-
60
-=item project_name
61
-
62
-Project name to show on the generated pages. Default is to use basename of the repository directory.
63
-
64
-=item start_date
65
-
66
-Specify a starting date to pass with --since to git.
67
-
68
-=item style
69
-
70
-CSS stylesheet to use.
71
-
72
-=back
73
-
74
-=head1 FAQ
75
-
76
-Q: How do I generate statistics of a non-master branch?
77
-
78
-A: Use C<-c commit_end=web> parameter.
79
-
80
-Q: I have files in my git repository that I would like to exclude from the statistics, how do I do that?
81
-
82
-A: At the moment the only way is to use L<git-filter-branch(1)> to create a temporary repository and generate the statistics from that.
83
-
84
-Q: How do I merge author information when the same author has made commits using different names or emails ?
85
-
86
-A: Use git .mailmap feature described in B<MAPPING AUTHORS> of L<git-shortlog(1)>.
87
-
88
-=head1 EXAMPLES
89
-
90
-=over
91
-
92
-=item Generates statistics from a git repository in C<foo> and outputs the result in a directory C<foo_stats>:
93
-
94
-  gitstats foo foo_stats
95
-
96
-=item As above, but only analyzes the last 10 commits:
97
-
98
-  gitstats -c commit_begin='HEAD~10' foo foo_stats
99
-
100
-=back
101
-
102
-=head1 AUTHORS
103
-
104
-B<gitstats> was written by Heikki Hokkanen and others.
105
-
106
-See the git repository at https://github.com/rappdw/gitstats for an up-to-date full list of contributors.
107
-
108
-=head1 WWW
109
-
110
-http://gitstats.sourceforge.net/
111
-
112
-=head1 SEE ALSO
113
-
114
-L<git(1)>
115
-

+ 2
- 2
gitstats/__init__.py Целия файл

@@ -1,7 +1,7 @@
1
-from gitstats.process import run
1
+from gitstats.git_csv_generator import gen_csv
2 2
 from gitstats._version import get_versions
3 3
 __version__ = get_versions()['version']
4 4
 del get_versions
5 5
 
6 6
 if __name__ == "__main__":
7
-    run()
7
+    gen_csv()

+ 0
- 6
gitstats/data/__init__.py Целия файл

@@ -1,10 +1,4 @@
1
-from .author import Author
2
-from .author_row import AuthorRow
3
-from .author_totals import AuthorTotals
4
-from .tag import Tag
5 1
 from .revision import Revision
6
-from .file import File
7
-from .loc_by_date import LocByDate
8 2
 from .pr import PullRequest
9 3
 from .file_info import FileInfo
10 4
 from .revision_graph import RevisionGraph

+ 0
- 25
gitstats/data/author.py Целия файл

@@ -1,25 +0,0 @@
1
-from collections import defaultdict
2
-from dataclasses import dataclass, field
3
-from datetime import timedelta
4
-from typing import Dict, Set
5
-
6
-
7
-@dataclass
8
-class Author:
9
-    lines_added: int = 0
10
-    lines_removed: int = 0
11
-    commits: int = 0
12
-    first_commit_stamp: int = 0
13
-    last_commit_stamp: int = 0
14
-    last_active_day: str = ''
15
-    active_days: Set[str] = field(default_factory=set)
16
-    place_by_commits: int = 0
17
-    commits_frac: float = 0.0
18
-    date_first: str = ''
19
-    date_last: str = ''
20
-    timedelta: timedelta = None
21
-    activity_by_day_and_hour: Dict[int, Dict[int, int]] = field(default_factory=lambda: defaultdict(lambda: defaultdict(int)))
22
-    extra_effort: int = 0
23
-    extra_frac: float = 0.0
24
-
25
-

+ 0
- 10
gitstats/data/author_row.py Целия файл

@@ -1,10 +0,0 @@
1
-from dataclasses import dataclass
2
-
3
-@dataclass
4
-class AuthorRow:
5
-    hash: str
6
-    stamp: int
7
-    author: str
8
-    files_modified: int
9
-    lines_inserted: int
10
-    lines_deleted: int

+ 0
- 6
gitstats/data/author_totals.py Целия файл

@@ -1,6 +0,0 @@
1
-from dataclasses import dataclass
2
-
3
-@dataclass
4
-class AuthorTotals:
5
-    author: str
6
-    total_commits: int

+ 0
- 10
gitstats/data/file.py Целия файл

@@ -1,10 +0,0 @@
1
-from dataclasses import dataclass
2
-
3
-@dataclass
4
-class File:
5
-    full_path: str
6
-    ext: str
7
-    size: int
8
-    lines: int = 0
9
-
10
-

+ 0
- 13
gitstats/data/loc_by_date.py Целия файл

@@ -1,13 +0,0 @@
1
-from dataclasses import dataclass
2
-
3
-
4
-@dataclass
5
-class LocByDate:
6
-    hash: str = ''
7
-    stamp: int = 0
8
-    file_count: int = 0
9
-    lines_inserted: int = 0
10
-    lines_deleted: int = 0
11
-    total_lines: int = 0
12
-
13
-

+ 0
- 13
gitstats/data/tag.py Целия файл

@@ -1,13 +0,0 @@
1
-from collections import defaultdict
2
-from dataclasses import dataclass, field
3
-from typing import Dict
4
-
5
-@dataclass
6
-class Tag:
7
-    tag: str
8
-    stamp: int
9
-    hash: str
10
-    commits: int = 0
11
-    authors: Dict[str, int] = field(default_factory=defaultdict(int))
12
-
13
-

+ 0
- 6
gitstats/data_generators/__init__.py Целия файл

@@ -1,9 +1,3 @@
1
-from .gen_author_data import gen_author_data
2
-from .gen_author_totals import gen_author_totals_data
3
-from .gen_tag_data import gen_tag_data
4
-from .gen_revision_data import gen_revision_data
5
-from .gen_file_data import gen_file_data
6
-from .gen_loc_data import gen_loc_data
7 1
 from .gen_pr_data import gen_pr_data
8 2
 from .gen_revision_graph import gen_revision_graph
9 3
 from .gen_complete_file_info import gen_complete_file_info

+ 0
- 87
gitstats/data_generators/gen_author_data.py Целия файл

@@ -1,87 +0,0 @@
1
-import csv
2
-import logging
3
-import os
4
-import re
5
-
6
-from gitstats import cli, cd
7
-from gitstats.miscfuncs import getlogrange, getpipeoutput, getstatsummarycounts
8
-from gitstats.data import AuthorRow
9
-
10
-
11
-def gen_author_data(conf, row_processor, ignore_files=''):
12
-    '''
13
-    Given a configuration, pull authorship information. For
14
-    each author, callback to the row_processor passing an AuthorRow
15
-
16
-    :param conf: configuration (mostly used for date limits)
17
-    :param row_processor: function to receive the callback
18
-    :return: None
19
-    '''
20
-
21
-    # DBG: git log --shortstat --date-order --pretty=format:"%H %at %aN" --since="2017-10-01" "HEAD"
22
-    # Results are in the form of
23
-    #
24
-    # 3c16756701d264619db0b309f42ebdc713b29827 1522513256 Dan Rapp
25
-    # 524ee0d32ffbbb8bb82966b769bbf7dbc1d87a68 1522480979 Michael Wright
26
-    # 1 file changed, 6 insertions(+)
27
-    #
28
-    # If there are two (or more) lines,
29
-    # The first line(s) is the merge to master or other branch
30
-    # The last line is the commit on the branch
31
-    lines = getpipeoutput(
32
-        ['git log --shortstat --date-order --pretty=format:"%%H %%at %%aN" %s %s' % (
33
-            getlogrange(conf, 'HEAD'), ignore_files)]).split('\n')
34
-    lines.reverse()
35
-
36
-    files = 0
37
-    inserted = 0
38
-    deleted = 0
39
-    stamp = 0
40
-    for line in lines:
41
-        if len(line) == 0:
42
-            continue
43
-
44
-        # <stamp> <author>
45
-        if re.search('files? changed', line) is None:
46
-            if files + inserted + deleted > 0:  # this case indicates we've already processed the line
47
-                pos = line.find(' ')
48
-                if pos != -1:
49
-                    try:
50
-                        oldstamp = stamp
51
-                        tokens = line.split()
52
-                        sha = tokens[0]
53
-                        stamp = int(tokens[1])
54
-                        author = ' '.join(tokens[2:])
55
-                        if oldstamp > stamp:
56
-                            # clock skew, keep old timestamp to avoid having ugly graph
57
-                            stamp = oldstamp
58
-                        row_processor(AuthorRow(sha, stamp, author, files, inserted, deleted))
59
-                        # Since subsequent lines are (generally) reflections of merging into a branch
60
-                        # don't provide "credit" to the author did the merge
61
-                        (files, inserted, deleted) = 0, 0, 0
62
-                    except ValueError:
63
-                        logging.warning(f'unexpected line "{line}')
64
-                else:
65
-                    logging.warning(f'unexpected line "{line}')
66
-        else:
67
-            numbers = getstatsummarycounts(line)
68
-
69
-            if len(numbers) == 3:
70
-                (files, inserted, deleted) = map(lambda el: int(el), numbers)
71
-            else:
72
-                logging.warning(f'Failed to handle line "{line}"')
73
-                (files, inserted, deleted) = (0, 0, 0)
74
-
75
-if __name__ == "__main__":
76
-    conf, paths, outputpath = cli.get_cli()
77
-    with open(outputpath, 'w', encoding='utf8') as f:
78
-        writer = csv.writer(f)
79
-        writer.writerow(['repo', 'sha', 'stamp', 'author', 'files changed', 'lines inserted', 'lines deleted'])
80
-
81
-        for path in paths:
82
-            repo_name = os.path.split(path)[1]
83
-            with (cd.cd(path)):
84
-                def row_processor(row: AuthorRow):
85
-                    writer.writerow([repo_name, row.hash, row.stamp, row.author, row.files_modified,
86
-                                     row.lines_inserted, row.lines_deleted])
87
-                gen_author_data(conf, row_processor)

+ 0
- 47
gitstats/data_generators/gen_author_totals.py Целия файл

@@ -1,47 +0,0 @@
1
-import csv
2
-import os
3
-
4
-from gitstats import cli, cd
5
-from gitstats.miscfuncs import getlogrange, getpipeoutput
6
-from gitstats.data import AuthorTotals
7
-
8
-
9
-def gen_author_totals_data(conf, row_processor=None, revision_range=None):
10
-    '''
11
-    Given configuration, pull total commit per author. For
12
-    each "row" callback to the row_processor passing an AuthorTotals
13
-
14
-    :param conf: configuration (mostly used for date limits)
15
-    :param row_processor: function to receive the callback
16
-    :return: count of the number of authors
17
-    '''
18
-
19
-    # DBG: git shortlog -s --since="2017-10-01" "HEAD"
20
-    if not revision_range:
21
-        revision_range = getlogrange(conf)
22
-    lines = getpipeoutput(['git shortlog -s %s' % revision_range]).split('\n')
23
-    count = 0
24
-    for line in lines:
25
-        line = line.strip()
26
-        if not line:
27
-            continue
28
-        count += 1
29
-        if row_processor:
30
-            tokens = line.split()
31
-            commit_count = int(tokens[0])
32
-            author = ' '.join(tokens[1:])
33
-            row_processor(AuthorTotals(author, commit_count))
34
-    return count
35
-
36
-if __name__ == "__main__":
37
-    conf, paths, outputpath = cli.get_cli()
38
-    with open(outputpath, 'w', encoding='utf8') as f:
39
-        writer = csv.writer(f)
40
-        writer.writerow(['repo', 'author', 'commits'])
41
-
42
-        for path in paths:
43
-            repo_name = os.path.split(path)[1]
44
-            with (cd.cd(path)):
45
-                def row_processor(row: AuthorTotals):
46
-                    writer.writerow([repo_name, row.author, row.total_commits])
47
-                gen_author_totals_data(conf, row_processor)

+ 0
- 64
gitstats/data_generators/gen_file_data.py Целия файл

@@ -1,64 +0,0 @@
1
-import csv
2
-import os
3
-import re
4
-
5
-from multiprocessing import Pool
6
-
7
-from gitstats import cli, cd
8
-from gitstats.miscfuncs import getcommitrange, getpipeoutput, getnumoflinesinblob
9
-from gitstats.data import File
10
-
11
-
12
-def gen_file_data(conf, row_processor):
13
-    '''
14
-    Given a configuration, pull authorship information. For
15
-    each author, callback to the row_processor passing an AuthorRow
16
-
17
-    :param conf: configuration (mostly used for date limits)
18
-    :param row_processor: function to receive the callback
19
-    :return: None
20
-    '''
21
-
22
-    # extensions and size of files
23
-
24
-    # DBG: git ls-tree -r -l -z HEAD
25
-    lines = getpipeoutput(['git ls-tree -r -l -z %s' % getcommitrange(conf, 'HEAD', end_only=True)]).split(
26
-        '\000')
27
-    blobs_to_read = {} # blob_id -> File
28
-    for line in lines:
29
-        if len(line) == 0:
30
-            continue
31
-        parts = re.split('\s+', line, 4)
32
-        if parts[0] == '160000' and parts[3] == '-':
33
-            # skip submodules
34
-            continue
35
-        blob_id = parts[2]
36
-        size = int(parts[3])
37
-        fullpath = parts[4]
38
-        _, ext = os.path.splitext(fullpath)
39
-        blobs_to_read[blob_id] = File(fullpath, ext, size)
40
-
41
-    # DBG: git cat-file blob e4f17a621893811250be96c8ef9c37b5e97a1df7', 'wc -l'
42
-    pool = Pool(processes=conf['processes'])
43
-    blob_linecount = pool.map(getnumoflinesinblob, blobs_to_read.keys())
44
-    pool.terminate()
45
-    pool.join()
46
-    # Update cache and write down info about number of number of lines
47
-    for (blob_id, linecount) in blob_linecount:
48
-        file_data = blobs_to_read[blob_id]
49
-        file_data.lines = linecount
50
-        row_processor(file_data)
51
-
52
-
53
-if __name__ == "__main__":
54
-    conf, paths, outputpath = cli.get_cli()
55
-    with open(outputpath, 'w', encoding='utf8') as f:
56
-        writer = csv.writer(f)
57
-        writer.writerow(['repo', 'file', 'ext', 'size', 'line_count'])
58
-
59
-        for path in paths:
60
-            repo_name = os.path.split(path)[1]
61
-            with (cd.cd(path)):
62
-                def row_processor(row: File):
63
-                    writer.writerow([repo_name, row.full_path, row.ext, row.size, row.lines])
64
-                gen_file_data(conf, row_processor)

+ 0
- 95
gitstats/data_generators/gen_loc_data.py Целия файл

@@ -1,95 +0,0 @@
1
-import csv
2
-import logging
3
-import os
4
-import re
5
-
6
-from gitstats import cli, cd
7
-from gitstats.miscfuncs import getlogrange, getpipeoutput, getstatsummarycounts
8
-from gitstats.data import LocByDate
9
-
10
-# TODO: the author isn't working here because it's the commit that merges to master, so we
11
-# TODO: probably need to back up a commit. Each commit here represents a merged PR
12
-
13
-def gen_loc_data(conf, row_processor, ignore_files=''):
14
-    '''
15
-    Given a configuration, pull authorship information. For
16
-    each author, callback to the row_processor passing an AuthorRow
17
-
18
-    :param conf: configuration (mostly used for date limits)
19
-    :param row_processor: function to receive the callback
20
-    :return: (total_files, total_lines) in repo
21
-    '''
22
-
23
-    # line statistics
24
-    # outputs:
25
-    #  N files changed, N insertions (+), N deletions(-)
26
-
27
-    # computation of lines of code by date is better done
28
-    # on a linear history.
29
-    extra = ''
30
-    if conf['linear_linestats']:
31
-        extra = '--first-parent -m'
32
-
33
-    # DBG: git log --shortstat --first-parent -m --pretty=format:"%at %aN" --since="2017-10-01" "HEAD"'
34
-    lines = getpipeoutput(
35
-        ['git log --shortstat %s --pretty=format:"%%H %%at %%aN" %s %s' % (extra, getlogrange(conf, 'HEAD'), ignore_files)]).split('\n')
36
-    lines.reverse()
37
-    files = 0
38
-    inserted = 0
39
-    deleted = 0
40
-    total_lines = 0
41
-    for line in lines:
42
-        if len(line) == 0:
43
-            continue
44
-
45
-        if re.search('files? changed', line) is None:
46
-            line = line.strip()
47
-            if line:
48
-                try:
49
-                    parts = line.split(' ', 2)
50
-                    (hash, stamp, author) = (parts[0], int(parts[1]), parts[2])
51
-                    row_processor(LocByDate(hash, stamp, files, inserted, deleted, total_lines))
52
-                    files, inserted, deleted = 0, 0, 0
53
-                except ValueError:
54
-                    logging.warning(f'unexpected line "{line}')
55
-            else:
56
-                logging.warning(f'unexpected line "{line}')
57
-        else:
58
-            numbers = getstatsummarycounts(line)
59
-
60
-            if len(numbers) == 3:
61
-                (files, inserted, deleted) = map(lambda el: int(el), numbers)
62
-                total_lines += inserted
63
-                total_lines -= deleted
64
-            else:
65
-                logging.warning(f'Failed to handle line "{line}"')
66
-                (files, inserted, deleted) = (0, 0, 0)
67
-
68
-    totals = getpipeoutput(
69
-        ['git diff --shortstat `git hash-object -t tree /dev/null` %s' % (ignore_files)]
70
-    )
71
-    total_files, remainder = totals.strip().split(' file')
72
-    total_lines = remainder.split('hanged, ')[1].split(' insert')[0]
73
-    try:
74
-        total_files = int(total_files)
75
-        total_lines = int(total_lines)
76
-    except ValueError:
77
-        total_lines = 0
78
-        total_files = 0
79
-        logging.warning(f"Unable to parse results: {totals}")
80
-    return total_files, total_lines
81
-
82
-
83
-if __name__ == "__main__":
84
-    conf, paths, outputpath = cli.get_cli()
85
-    with open(outputpath, 'w', encoding='utf8') as f:
86
-        writer = csv.writer(f)
87
-        writer.writerow(['repo', 'sha', 'stamp', 'file count', 'lines inserted', 'lines deleted', 'total lines'])
88
-
89
-        for path in paths:
90
-            repo_name = os.path.split(path)[1]
91
-            with (cd.cd(path)):
92
-                def row_processor(row: LocByDate):
93
-                    writer.writerow([repo_name, row.hash, row.stamp, row.file_count, row.lines_inserted,
94
-                                     row.lines_deleted, row.total_lines])
95
-                gen_loc_data(conf, row_processor)

+ 0
- 49
gitstats/data_generators/gen_revision_data.py Целия файл

@@ -1,49 +0,0 @@
1
-import csv
2
-import os
3
-
4
-from multiprocessing import Pool
5
-
6
-from gitstats import cli, cd
7
-from gitstats.miscfuncs import getnumoffilesfromrev
8
-from gitstats.data import Revision, RevisionGraph
9
-from gitstats.data_generators.gen_revision_graph import gen_revision_graph
10
-
11
-
12
-def gen_revision_data(conf, row_processor, graph: RevisionGraph):
13
-    '''
14
-    Given a configuration, pull revision information. For
15
-    each author, callback to the row_processor passing an Revision
16
-
17
-    :param conf: configuration (mostly used for date limits)
18
-    :param row_processor: function to receive the callback
19
-    :return: None
20
-    '''
21
-
22
-    # todo: consider putting in a cache for this. There was one in the original code
23
-    # DBG: git ls-tree -r --name-only "ceb3165b51ae0680724fd71e16a5ff836a0de41e"', 'wc -l'
24
-    pool = Pool(processes=conf['processes'])
25
-    rev_count = pool.map(getnumoffilesfromrev, graph.revisions.keys())
26
-    pool.terminate()
27
-    pool.join()
28
-    # Update cache with new revisions and append then to general list
29
-    for (rev, count) in rev_count:
30
-        revision = graph.revisions[rev]
31
-        revision.file_count = count
32
-        row_processor(revision)
33
-
34
-
35
-if __name__ == "__main__":
36
-    conf, paths, outputpath = cli.get_cli()
37
-    begin, end = cli.get_begin_end_timestamps(conf)
38
-    with open(outputpath, 'w', encoding='utf8') as f:
39
-        writer = csv.writer(f)
40
-        writer.writerow(['repo', 'sha', 'stamp', 'timezone', 'author', 'email', 'domain', 'files_changed'])
41
-
42
-        for path in paths:
43
-            rev_by_tree_hash, _, _, _ = gen_revision_graph(begin, end)
44
-            repo_name = os.path.split(path)[1]
45
-            with (cd.cd(path)):
46
-                def row_processor(row: Revision):
47
-                    writer.writerow([repo_name, row.hash, row.stamp, row.timezone, row.author, row.email,
48
-                                     row.domain, row.file_count])
49
-                gen_revision_data(conf, row_processor, rev_by_tree_hash)

+ 0
- 72
gitstats/data_generators/gen_tag_data.py Целия файл

@@ -1,72 +0,0 @@
1
-import csv
2
-import os
3
-
4
-from collections import defaultdict
5
-from typing import Dict
6
-
7
-from gitstats import cli, cd
8
-from gitstats.miscfuncs import getpipeoutput
9
-from gitstats.data import AuthorTotals, Tag
10
-from gitstats.data_generators import gen_author_totals_data
11
-
12
-
13
-def gen_tag_data(conf, row_processor):
14
-    '''
15
-    Given a configuration, pull tag information. For
16
-    each tag, callback to the row_processor passing a Tag
17
-
18
-    :param conf: configuration (mostly used for date limits)
19
-    :param row_processor: function to receive the callback
20
-    :return: None
21
-    '''
22
-
23
-    # tags
24
-    tags = {} # stamp -> tags
25
-    lines = getpipeoutput(['git show-ref --tags']).split('\n')
26
-    for line in lines:
27
-        if len(line) == 0:
28
-            continue
29
-        (line_hash, tag) = line.split(' ')
30
-
31
-        tag = tag.replace('refs/tags/', '')
32
-        output = getpipeoutput(['git log "%s" --pretty=format:"%%at" -n 1' % line_hash])
33
-
34
-        stamp = 0
35
-        if len(output) > 0:
36
-            try:
37
-                stamp = int(output.strip())
38
-            except ValueError:
39
-                stamp = 0
40
-
41
-        tags[stamp] = Tag(tag, stamp, line_hash, 0, {})
42
-
43
-    stamps = sorted(tags.keys())
44
-    prev = None
45
-    for stamp in stamps:
46
-        def process_row(row: AuthorTotals):
47
-            tags[stamp].authors[row.author] = row.total_commits
48
-            tags[stamp].commits += row.total_commits
49
-
50
-        revision_tags = tags[stamp].tag
51
-        if prev != None:
52
-            revision_tags += ' "^%s"' % prev
53
-
54
-        gen_author_totals_data(conf, process_row, revision_tags)
55
-        row_processor(tags[stamp])
56
-
57
-        prev = tags[stamp].tag
58
-
59
-
60
-if __name__ == "__main__":
61
-    conf, paths, outputpath = cli.get_cli()
62
-    with open(outputpath, 'w', encoding='utf8') as f:
63
-        writer = csv.writer(f)
64
-        writer.writerow(['repo', 'sha', 'stamp', 'commits for tag', 'author', 'commits by author'])
65
-
66
-        for path in paths:
67
-            repo_name = os.path.split(path)[1]
68
-            with (cd.cd(path)):
69
-                def row_processor(row: Tag):
70
-                    for author, commits in row.authors.items():
71
-                        writer.writerow([repo_name, row.hash, row.stamp, row.commits, author, commits])
72
-                gen_tag_data(conf, row_processor)

+ 0
- 162
gitstats/datacollector.py Целия файл

@@ -1,162 +0,0 @@
1
-import datetime
2
-import logging
3
-import os
4
-import pickle
5
-import time
6
-import zlib
7
-
8
-from collections import defaultdict
9
-from typing import Dict
10
-from gitstats.data.author import Author
11
-
12
-
13
-class DataCollector:
14
-    """Manages data collection from a revision control repository."""
15
-
16
-    def __init__(self, conf):
17
-        self.conf = conf
18
-        self.stamp_created = time.time()
19
-        self.cache = {}
20
-        self.total_authors = 0
21
-        self.activity_by_hour_of_day = {}  # hour -> commits
22
-        self.activity_by_day_of_week = {}  # day -> commits
23
-        self.activity_by_month_of_year = {}  # month [1-12] -> commits
24
-        self.activity_by_hour_of_week = {}  # weekday -> hour -> commits
25
-        self.activity_by_hour_of_day_busiest = 0
26
-        self.activity_by_hour_of_week_busiest = 0
27
-        self.activity_by_year_week = {}  # yy_wNN -> commits
28
-        self.activity_by_year_week_peak = 0
29
-
30
-        self.authors: Dict[Author] = defaultdict(lambda: Author())
31
-
32
-        self.total_commits = 0
33
-        self.total_files = 0
34
-        self.authors_by_commits = 0
35
-
36
-        # domains
37
-        self.domains = {}  # domain -> commits
38
-
39
-        # author of the month
40
-        self.author_of_month = {}  # month -> author -> commits
41
-        self.author_of_year = {}  # year -> author -> commits
42
-        self.commits_by_month = {}  # month -> commits
43
-        self.commits_by_year = {}  # year -> commits
44
-        self.lines_added_by_month = {}  # month -> lines added
45
-        self.lines_added_by_year = {}  # year -> lines added
46
-        self.lines_removed_by_month = {}  # month -> lines removed
47
-        self.lines_removed_by_year = {}  # year -> lines removed
48
-        self.first_commit_stamp = 0
49
-        self.last_commit_stamp = 0
50
-        self.last_active_day = None
51
-        self.active_days = set()
52
-
53
-        # lines
54
-        self.total_lines = 0
55
-        self.total_lines_added = 0
56
-        self.total_lines_removed = 0
57
-
58
-        # size
59
-        self.total_size = 0
60
-
61
-        # timezone
62
-        self.commits_by_timezone = {}  # timezone -> commits
63
-
64
-        # tags
65
-        self.tags = {}
66
-
67
-        self.files_by_stamp = {}  # stamp -> files
68
-
69
-        # extensions
70
-        self.extensions = {}  # extension -> files, lines
71
-
72
-        # line statistics
73
-        self.changes_by_date = {}  # stamp -> { files, ins, del }
74
-
75
-    ##
76
-    # This should be the main function to extract data from the repository.
77
-    def collect(self, dir):
78
-        self.dir = dir
79
-        if len(self.conf['project_name']) == 0:
80
-            self.projectname = os.path.basename(os.path.abspath(dir))
81
-        else:
82
-            self.projectname = self.conf['project_name']
83
-
84
-    ##
85
-    # Load cacheable data
86
-    def loadCache(self, cachefile):
87
-        if not os.path.exists(cachefile):
88
-            return
89
-        logging.info('Loading cache...')
90
-        f = open(cachefile, 'rb')
91
-        try:
92
-            self.cache = pickle.loads(zlib.decompress(f.read()))
93
-        except:
94
-            # temporary hack to upgrade non-compressed caches
95
-            f.seek(0)
96
-            self.cache = pickle.load(f)
97
-        f.close()
98
-
99
-    ##
100
-    # Produce any additional statistics from the extracted data.
101
-    def refine(self):
102
-        pass
103
-
104
-    ##
105
-    # : get a dictionary of author
106
-    def getAuthorInfo(self, author):
107
-        return None
108
-
109
-    def getActivityByDayOfWeek(self):
110
-        return {}
111
-
112
-    def getActivityByHourOfDay(self):
113
-        return {}
114
-
115
-    # : get a dictionary of domains
116
-    def getDomainInfo(self, domain):
117
-        return None
118
-
119
-    ##
120
-    # Get a list of authors
121
-    def getAuthors(self):
122
-        return []
123
-
124
-    def getFirstCommitDate(self):
125
-        return datetime.datetime.now()
126
-
127
-    def getLastCommitDate(self):
128
-        return datetime.datetime.now()
129
-
130
-    def getStampCreated(self):
131
-        return self.stamp_created
132
-
133
-    def getTags(self):
134
-        return []
135
-
136
-    def getTotalAuthors(self):
137
-        return -1
138
-
139
-    def getTotalCommits(self):
140
-        return -1
141
-
142
-    def getTotalFiles(self):
143
-        return -1
144
-
145
-    def getTotalLOC(self):
146
-        return -1
147
-
148
-    ##
149
-    # Save cacheable data
150
-    def saveCache(self, cachefile):
151
-        logging.info('Saving cache...')
152
-        tempfile = cachefile + '.tmp'
153
-        f = open(tempfile, 'wb')
154
-        # pickle.dump(self.cache, f)
155
-        data = zlib.compress(pickle.dumps(self.cache))
156
-        f.write(data)
157
-        f.close()
158
-        try:
159
-            os.remove(cachefile)
160
-        except OSError:
161
-            pass
162
-        os.rename(tempfile, cachefile)

+ 0
- 276
gitstats/gitdatacollector.py Целия файл

@@ -1,276 +0,0 @@
1
-import datetime
2
-
3
-from collections import defaultdict
4
-
5
-from gitstats.datacollector import DataCollector
6
-from gitstats.data import Author, AuthorRow, File, LocByDate, Revision, Tag
7
-from gitstats.data_generators import gen_author_data, gen_author_totals_data, gen_tag_data, gen_revision_data, \
8
-    gen_file_data, gen_loc_data
9
-from gitstats.miscfuncs import getpipeoutput
10
-
11
-
12
-class GitDataCollector(DataCollector):
13
-    def __init__(self, conf):
14
-        super(GitDataCollector, self).__init__(conf)
15
-        
16
-    def collect(self, directory):
17
-        super(GitDataCollector, self).collect(directory)
18
-        self.total_authors += self.get_total_authors()
19
-        self.get_tags()
20
-        self.get_revision_info()
21
-        self.get_file_info()
22
-        self.get_loc_info()
23
-        self.get_author_info()
24
-
25
-    def get_total_authors(self):
26
-        return gen_author_totals_data(self.conf)
27
-
28
-    def get_author_info(self):
29
-        # Per-author statistics
30
-        # defined for stamp, author only if author commited at this timestamp.
31
-
32
-        self.changes_by_date_by_author = defaultdict(lambda: defaultdict(lambda: Author())) # stamp -> author -> lines_added
33
-
34
-        def row_processor(row: AuthorRow):
35
-            self.authors[row.author].commits += 1
36
-            self.authors[row.author].lines_added += row.lines_inserted
37
-            self.authors[row.author].lines_removed += row.lines_deleted
38
-            self.changes_by_date_by_author[row.stamp][row.author].lines_added = self.authors[row.author].lines_added
39
-            self.changes_by_date_by_author[row.stamp][row.author].commits = self.authors[row.author].commits
40
-
41
-        gen_author_data(self.conf, row_processor)
42
-
43
-    def get_loc_info(self):
44
-
45
-        self.changes_by_date = {}  # stamp -> { files, ins, del }
46
-        def row_processor(row: LocByDate):
47
-            self.changes_by_date[row.stamp] = {
48
-                'files': row.file_count,
49
-                'ins': row.lines_inserted,
50
-                'del': row.lines_deleted,
51
-                'lines': row.total_lines
52
-            }
53
-            date = datetime.datetime.fromtimestamp(row.stamp)
54
-            yymm = date.strftime('%Y-%m')
55
-            self.lines_added_by_month[yymm] = self.lines_added_by_month.get(yymm, 0) + row.lines_inserted
56
-            self.lines_removed_by_month[yymm] = self.lines_removed_by_month.get(yymm, 0) + row.lines_deleted
57
-
58
-            yy = date.year
59
-            self.lines_added_by_year[yy] = self.lines_added_by_year.get(yy, 0) + row.lines_inserted
60
-            self.lines_removed_by_year[yy] = self.lines_removed_by_year.get(yy, 0) + row.lines_deleted
61
-
62
-            self.total_lines_added += row.lines_inserted
63
-            self.total_lines_removed += row.lines_deleted
64
-
65
-        self.total_lines += gen_loc_data(self.conf, row_processor)[1]
66
-
67
-    def get_file_info(self):
68
-        # extensions and size of files
69
-        def row_processor(row: File):
70
-            self.total_size += row.size
71
-            self.total_files += 1
72
-            if row.ext not in self.extensions:
73
-                self.extensions[row.ext] = {'files': 0, 'lines': 0}
74
-            self.extensions[row.ext]['files'] += 1
75
-            self.extensions[row.ext]['lines'] += row.lines
76
-
77
-        gen_file_data(self.conf, row_processor)
78
-
79
-    def get_revision_info(self):
80
-        # Collect revision statistics
81
-        # Outputs "<stamp> <date> <time> <timezone> <author> '<' <mail> '>'"
82
-
83
-        def row_processor(row: Revision):
84
-            stamp = row.stamp
85
-            domain = row.domain
86
-            author = row.author
87
-            timezone = row.timezone
88
-
89
-            date = datetime.datetime.fromtimestamp(float(stamp))
90
-
91
-            # First and last commit stamp (may be in any order because of cherry-picking and patches)
92
-            if stamp > self.last_commit_stamp:
93
-                self.last_commit_stamp = stamp
94
-            if self.first_commit_stamp == 0 or stamp < self.first_commit_stamp:
95
-                self.first_commit_stamp = stamp
96
-
97
-            # activity
98
-            # hour
99
-            hour = date.hour
100
-            self.activity_by_hour_of_day[hour] = self.activity_by_hour_of_day.get(hour, 0) + 1
101
-            # most active hour?
102
-            if self.activity_by_hour_of_day[hour] > self.activity_by_hour_of_day_busiest:
103
-                self.activity_by_hour_of_day_busiest = self.activity_by_hour_of_day[hour]
104
-
105
-            # day of week
106
-            day = date.weekday()
107
-            self.activity_by_day_of_week[day] = self.activity_by_day_of_week.get(day, 0) + 1
108
-
109
-            # domain stats
110
-            if domain not in self.domains:
111
-                self.domains[domain] = {}
112
-            # commits
113
-            self.domains[domain]['commits'] = self.domains[domain].get('commits', 0) + 1
114
-
115
-            # hour of week
116
-            if day not in self.activity_by_hour_of_week:
117
-                self.activity_by_hour_of_week[day] = {}
118
-            self.activity_by_hour_of_week[day][hour] = self.activity_by_hour_of_week[day].get(hour, 0) + 1
119
-            # most active hour?
120
-            if self.activity_by_hour_of_week[day][hour] > self.activity_by_hour_of_week_busiest:
121
-                self.activity_by_hour_of_week_busiest = self.activity_by_hour_of_week[day][hour]
122
-
123
-            # month of year
124
-            month = date.month
125
-            self.activity_by_month_of_year[month] = self.activity_by_month_of_year.get(month, 0) + 1
126
-
127
-            # yearly/weekly activity
128
-            yyw = date.strftime('%Y-%W')
129
-            self.activity_by_year_week[yyw] = self.activity_by_year_week.get(yyw, 0) + 1
130
-            if self.activity_by_year_week_peak < self.activity_by_year_week[yyw]:
131
-                self.activity_by_year_week_peak = self.activity_by_year_week[yyw]
132
-
133
-            # author stats
134
-            self.authors[author].activity_by_day_and_hour[day][hour] += 1
135
-            # commits, note again that commits may be in any date order because of cherry-picking and patches
136
-            if not self.authors[author].last_commit_stamp:
137
-                self.authors[author].last_commit_stamp = stamp
138
-            if stamp > self.authors[author].last_commit_stamp:
139
-                self.authors[author].last_commit_stamp = stamp
140
-            if not self.authors[author].first_commit_stamp:
141
-                self.authors[author].first_commit_stamp = stamp
142
-            if stamp < self.authors[author].first_commit_stamp:
143
-                self.authors[author].first_commit_stamp = stamp
144
-
145
-            # author of the month/year
146
-            yymm = date.strftime('%Y-%m')
147
-            if yymm in self.author_of_month:
148
-                self.author_of_month[yymm][author] = self.author_of_month[yymm].get(author, 0) + 1
149
-            else:
150
-                self.author_of_month[yymm] = {}
151
-                self.author_of_month[yymm][author] = 1
152
-            self.commits_by_month[yymm] = self.commits_by_month.get(yymm, 0) + 1
153
-
154
-            yy = date.year
155
-            if yy in self.author_of_year:
156
-                self.author_of_year[yy][author] = self.author_of_year[yy].get(author, 0) + 1
157
-            else:
158
-                self.author_of_year[yy] = {}
159
-                self.author_of_year[yy][author] = 1
160
-            self.commits_by_year[yy] = self.commits_by_year.get(yy, 0) + 1
161
-
162
-            # authors: active days
163
-            yymmdd = date.strftime('%Y-%m-%d')
164
-            if not self.authors[author].last_active_day:
165
-                self.authors[author].last_active_day = yymmdd
166
-            elif yymmdd != self.authors[author].last_active_day:
167
-                self.authors[author].last_active_day = yymmdd
168
-            self.authors[author].active_days.add(yymmdd)
169
-
170
-            # project: active days
171
-            if yymmdd != self.last_active_day:
172
-                self.last_active_day = yymmdd
173
-                self.active_days.add(yymmdd)
174
-
175
-            # timezone
176
-            self.commits_by_timezone[timezone] = self.commits_by_timezone.get(timezone, 0) + 1
177
-
178
-            # file counts
179
-            self.files_by_stamp[stamp] = row.file_count
180
-
181
-        self.total_commits += gen_revision_data(self.conf, row_processor)
182
-
183
-    def get_tags(self):
184
-        def row_processor(row: Tag):
185
-            self.tags[row.tag] = {
186
-                'stamp': row.stamp,
187
-                'hash': row.hash,
188
-                'date': datetime.datetime.fromtimestamp(row.stamp).strftime('%Y-%m-%d'),
189
-                'commits': row.commits,
190
-                'authors': row.authors
191
-            }
192
-
193
-        gen_tag_data(self.conf, row_processor)
194
-
195
-    def refine(self):
196
-        # authors
197
-        # name -> {place_by_commits, commits_frac, date_first, date_last, timedelta}
198
-        self.authors_by_commits = self.getAuthors()
199
-        total_commits_without_merge = 0
200
-        for i, name in enumerate(self.authors_by_commits):
201
-            self.authors[name].place_by_commits = i + 1
202
-            total_commits_without_merge += self.authors[name].commits
203
-
204
-        for name in self.authors.keys():
205
-            a = self.authors[name]
206
-            a.commits_frac = (100 * float(a.commits)) / total_commits_without_merge
207
-            date_first = datetime.datetime.fromtimestamp(a.first_commit_stamp)
208
-            date_last = datetime.datetime.fromtimestamp(a.last_commit_stamp)
209
-            delta = date_last - date_first
210
-            a.date_first = date_first.strftime('%Y-%m-%d')
211
-            a.date_last = date_last.strftime('%Y-%m-%d')
212
-            a.timedelta = delta
213
-            for day in range(6):
214
-                for hour in range(24):
215
-                    if day > 4 or hour < 8 or hour > 17:
216
-                        a.extra_effort += a.activity_by_day_and_hour[day][hour]
217
-            a.extra_frac = (100 * float(a.extra_effort)) / a.commits
218
-
219
-    def getActiveDays(self):
220
-        return self.active_days
221
-
222
-    def getActivityByDayOfWeek(self):
223
-        return self.activity_by_day_of_week
224
-
225
-    def getActivityByHourOfDay(self):
226
-        return self.activity_by_hour_of_day
227
-
228
-    def getAuthorInfo(self, author):
229
-        return self.authors[author]
230
-
231
-    def getAuthors(self, limit=None):
232
-        res = [el[0] for el in sorted(self.authors.items(), key=lambda x: x[1].commits, reverse=True)]
233
-        return res[:limit]
234
-
235
-    def getCommitDeltaDays(self):
236
-        return (self.last_commit_stamp / 86400 - self.first_commit_stamp / 86400) + 1
237
-
238
-    def getDomainInfo(self, domain):
239
-        return self.domains[domain]
240
-
241
-    def getDomains(self):
242
-        return self.domains.keys()
243
-
244
-    def getFirstCommitDate(self):
245
-        return datetime.datetime.fromtimestamp(self.first_commit_stamp)
246
-
247
-    def getLastCommitDate(self):
248
-        return datetime.datetime.fromtimestamp(self.last_commit_stamp)
249
-
250
-    def getTags(self):
251
-        lines = getpipeoutput(['git show-ref --tags', 'cut -d/ -f3'])
252
-        return lines.split('\n')
253
-
254
-    def getTagDate(self, tag):
255
-        return self.revToDate('tags/' + tag)
256
-
257
-    def getTotalAuthors(self):
258
-        # because we are equating names (see name_xlate), the total authors will be the number of
259
-        # elements in the authors dictionary rather than the count from the git log
260
-        return len(self.authors)
261
-
262
-    def getTotalCommits(self):
263
-        return self.total_commits
264
-
265
-    def getTotalFiles(self):
266
-        return self.total_files
267
-
268
-    def getTotalLOC(self):
269
-        return self.total_lines
270
-
271
-    def getTotalSize(self):
272
-        return self.total_size
273
-
274
-    def revToDate(self, rev):
275
-        stamp = int(getpipeoutput(['git log --pretty=format:%%at "%s" -n 1' % rev]))
276
-        return datetime.datetime.fromtimestamp(stamp).strftime('%Y-%m-%d')

+ 0
- 734
gitstats/htmlreportcreator.py Целия файл

@@ -1,734 +0,0 @@
1
-import datetime
2
-import glob
3
-import logging
4
-import pkg_resources
5
-import os
6
-import shutil
7
-import time
8
-
9
-from .reportcreator import ReportCreator
10
-from .miscfuncs import getgitversion, getgnuplotversion, getkeyssortedbyvaluekey, getkeyssortedbyvalues, getpipeoutput, \
11
-    getversion, gnuplot_cmd
12
-
13
-GNUPLOT_COMMON = 'set terminal png transparent size 640,240\nset size 1.0,1.0\n'
14
-WEEKDAYS = ('Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun')
15
-
16
-def html_linkify(text):
17
-    return text.lower().replace(' ', '_')
18
-
19
-
20
-def html_header(level, text):
21
-    name = html_linkify(text)
22
-    return '\n<h%d id="%s"><a href="#%s">%s</a></h%d>\n\n' % (level, name, name, text, level)
23
-
24
-
25
-class HTMLReportCreator(ReportCreator):
26
-    def __init(self, conf):
27
-        super(HTMLReportCreator, self).__init__(conf)
28
-
29
-    def create(self, data, path):
30
-        super(HTMLReportCreator, self).create(data, path)
31
-        self.title = data.projectname
32
-
33
-        # copy static files. Looks in the binary directory, ../share/gitstats and /usr/share/gitstats
34
-        resources = (self.conf['style'], 'sortable.js', 'arrow-up.gif', 'arrow-down.gif', 'arrow-none.gif')
35
-        for resource in (self.conf['style'], 'sortable.js', 'arrow-up.gif', 'arrow-down.gif', 'arrow-none.gif'):
36
-            resource_file = pkg_resources.resource_filename('gitstats', os.path.join('resources', resource))
37
-            if os.path.exists(resource_file):
38
-                shutil.copyfile(resource_file, os.path.join(path, resource))
39
-            else:
40
-                logging.warning(f'"{resource}" not found, so not copied')
41
-
42
-        f = open(path + "/index.html", 'w')
43
-        format = '%Y-%m-%d %H:%M:%S'
44
-        self.printHeader(f)
45
-
46
-        f.write('<h1>GitStats - %s</h1>' % data.projectname)
47
-
48
-        self.printNav(f)
49
-
50
-        f.write('<dl>')
51
-        f.write('<dt>Project name</dt><dd>%s</dd>' % (data.projectname))
52
-        f.write('<dt>Generated</dt><dd>%s (in %d seconds)</dd>' % (
53
-            datetime.datetime.now().strftime(format), time.time() - data.getStampCreated()))
54
-        f.write(
55
-            '<dt>Generator</dt><dd><a href="https://github.com/rappdw/gitstats">GitStats</a> (version %s), %s, %s</dd>' % (
56
-                getversion(), getgitversion(), getgnuplotversion()))
57
-        f.write('<dt>Report Period</dt><dd>%s to %s</dd>' % (
58
-            data.getFirstCommitDate().strftime(format), data.getLastCommitDate().strftime(format)))
59
-        f.write('<dt>Age</dt><dd>%d days, %d active days (%3.2f%%)</dd>' % (
60
-            data.getCommitDeltaDays(), len(data.getActiveDays()),
61
-            (100.0 * len(data.getActiveDays()) / data.getCommitDeltaDays())))
62
-        f.write('<dt>Total Files</dt><dd>%s</dd>' % data.getTotalFiles())
63
-        f.write('<dt>Total Lines of Code</dt><dd>%s (%d added, %d removed)</dd>' % (
64
-            data.getTotalLOC(), data.total_lines_added, data.total_lines_removed))
65
-        f.write('<dt>Total Commits</dt><dd>%s (average %.1f commits per active day, %.1f per all days)</dd>' % (
66
-            data.getTotalCommits(), float(data.getTotalCommits()) / len(data.getActiveDays()),
67
-            float(data.getTotalCommits()) / data.getCommitDeltaDays()))
68
-        f.write('<dt>Authors</dt><dd>%s (average %.1f commits per author)</dd>' % (
69
-            data.getTotalAuthors(), (1.0 * data.getTotalCommits()) / data.getTotalAuthors()))
70
-        f.write('</dl>')
71
-
72
-        f.write('</body>\n</html>')
73
-        f.close()
74
-
75
-        ###
76
-        # Activity
77
-        f = open(path + '/activity.html', 'w')
78
-        self.printHeader(f)
79
-        f.write('<h1>Activity</h1>')
80
-        self.printNav(f)
81
-
82
-        # f.write('<h2>Last 30 days</h2>')
83
-
84
-        # f.write('<h2>Last 12 months</h2>')
85
-
86
-        # Weekly activity
87
-        WEEKS = 32
88
-        f.write(html_header(2, 'Weekly activity'))
89
-        f.write('<p>Last %d weeks</p>' % WEEKS)
90
-
91
-        # generate weeks to show (previous N weeks from now)
92
-        now = datetime.datetime.now()
93
-        deltaweek = datetime.timedelta(7)
94
-        weeks = []
95
-        stampcur = now
96
-        for i in range(0, WEEKS):
97
-            weeks.insert(0, stampcur.strftime('%Y-%W'))
98
-            stampcur -= deltaweek
99
-
100
-        # top row: commits & bar
101
-        f.write('<table class="noborders"><tr>')
102
-        for i in range(0, WEEKS):
103
-            commits = 0
104
-            if weeks[i] in data.activity_by_year_week:
105
-                commits = data.activity_by_year_week[weeks[i]]
106
-
107
-            percentage = 0
108
-            if weeks[i] in data.activity_by_year_week:
109
-                percentage = float(data.activity_by_year_week[weeks[i]]) / data.activity_by_year_week_peak
110
-            height = max(1, int(200 * percentage))
111
-            f.write(
112
-                '<td style="text-align: center; vertical-align: bottom">%d<div style="display: block; background-color: red; width: 20px; height: %dpx"></div></td>' % (
113
-                    commits, height))
114
-
115
-        # bottom row: year/week
116
-        f.write('</tr><tr>')
117
-        for i in range(0, WEEKS):
118
-            f.write('<td>%s</td>' % (WEEKS - i))
119
-        f.write('</tr></table>')
120
-
121
-        # Hour of Day
122
-        f.write(html_header(2, 'Hour of Day'))
123
-        hour_of_day = data.getActivityByHourOfDay()
124
-        f.write('<table><tr><th>Hour</th>')
125
-        for i in range(0, 24):
126
-            f.write('<th>%d</th>' % i)
127
-        f.write('</tr>\n<tr><th>Commits</th>')
128
-        fp = open(path + '/hour_of_day.dat', 'w')
129
-        for i in range(0, 24):
130
-            if i in hour_of_day:
131
-                r = 127 + int((float(hour_of_day[i]) / data.activity_by_hour_of_day_busiest) * 128)
132
-                f.write('<td style="background-color: rgb(%d, 0, 0)">%d</td>' % (r, hour_of_day[i]))
133
-                fp.write('%d %d\n' % (i, hour_of_day[i]))
134
-            else:
135
-                f.write('<td>0</td>')
136
-                fp.write('%d 0\n' % i)
137
-        fp.close()
138
-        f.write('</tr>\n<tr><th>%</th>')
139
-        totalcommits = data.getTotalCommits()
140
-        for i in range(0, 24):
141
-            if i in hour_of_day:
142
-                r = 127 + int((float(hour_of_day[i]) / data.activity_by_hour_of_day_busiest) * 128)
143
-                f.write('<td style="background-color: rgb(%d, 0, 0)">%.2f</td>' % (
144
-                    r, (100.0 * hour_of_day[i]) / totalcommits))
145
-            else:
146
-                f.write('<td>0.00</td>')
147
-        f.write('</tr></table>')
148
-        f.write('<img src="hour_of_day.png" alt="Hour of Day">')
149
-        fg = open(path + '/hour_of_day.dat', 'w')
150
-        for i in range(0, 24):
151
-            if i in hour_of_day:
152
-                fg.write('%d %d\n' % (i + 1, hour_of_day[i]))
153
-            else:
154
-                fg.write('%d 0\n' % (i + 1))
155
-        fg.close()
156
-
157
-        # Day of Week
158
-        f.write(html_header(2, 'Day of Week'))
159
-        day_of_week = data.getActivityByDayOfWeek()
160
-        f.write('<div class="vtable"><table>')
161
-        f.write('<tr><th>Day</th><th>Total (%)</th></tr>')
162
-        fp = open(path + '/day_of_week.dat', 'w')
163
-        for d in range(0, 7):
164
-            commits = 0
165
-            if d in day_of_week:
166
-                commits = day_of_week[d]
167
-            fp.write('%d %s %d\n' % (d + 1, WEEKDAYS[d], commits))
168
-            f.write('<tr>')
169
-            f.write('<th>%s</th>' % (WEEKDAYS[d]))
170
-            if d in day_of_week:
171
-                f.write('<td>%d (%.2f%%)</td>' % (day_of_week[d], (100.0 * day_of_week[d]) / totalcommits))
172
-            else:
173
-                f.write('<td>0</td>')
174
-            f.write('</tr>')
175
-        f.write('</table></div>')
176
-        f.write('<img src="day_of_week.png" alt="Day of Week">')
177
-        fp.close()
178
-
179
-        # Hour of Week
180
-        f.write(html_header(2, 'Hour of Week'))
181
-        f.write('<table>')
182
-
183
-        f.write('<tr><th>Weekday</th>')
184
-        for hour in range(0, 24):
185
-            f.write('<th>%d</th>' % (hour))
186
-        f.write('</tr>')
187
-
188
-        for weekday in range(0, 7):
189
-            f.write('<tr><th>%s</th>' % (WEEKDAYS[weekday]))
190
-            for hour in range(0, 24):
191
-                try:
192
-                    commits = data.activity_by_hour_of_week[weekday][hour]
193
-                except KeyError:
194
-                    commits = 0
195
-                if commits != 0:
196
-                    f.write('<td')
197
-                    r = 127 + int((float(commits) / data.activity_by_hour_of_week_busiest) * 128)
198
-                    f.write(' style="background-color: rgb(%d, 0, 0)"' % r)
199
-                    f.write('>%d</td>' % commits)
200
-                else:
201
-                    f.write('<td></td>')
202
-            f.write('</tr>')
203
-
204
-        f.write('</table>')
205
-
206
-        # Month of Year
207
-        f.write(html_header(2, 'Month of Year'))
208
-        f.write('<div class="vtable"><table>')
209
-        f.write('<tr><th>Month</th><th>Commits (%)</th></tr>')
210
-        fp = open(path + '/month_of_year.dat', 'w')
211
-        for mm in range(1, 13):
212
-            commits = 0
213
-            if mm in data.activity_by_month_of_year:
214
-                commits = data.activity_by_month_of_year[mm]
215
-            f.write(
216
-                '<tr><td>%d</td><td>%d (%.2f %%)</td></tr>' % (mm, commits, (100.0 * commits) / data.getTotalCommits()))
217
-            fp.write('%d %d\n' % (mm, commits))
218
-        fp.close()
219
-        f.write('</table></div>')
220
-        f.write('<img src="month_of_year.png" alt="Month of Year">')
221
-
222
-        # Commits by year/month
223
-        f.write(html_header(2, 'Commits by year/month'))
224
-        f.write(
225
-            '<div class="vtable"><table><tr><th>Month</th><th>Commits</th><th>Lines added</th><th>Lines removed</th></tr>')
226
-        for yymm in reversed(sorted(data.commits_by_month.keys())):
227
-            f.write('<tr><td>%s</td><td>%d</td><td>%d</td><td>%d</td></tr>' % (
228
-                yymm, data.commits_by_month.get(yymm, 0), data.lines_added_by_month.get(yymm, 0),
229
-                data.lines_removed_by_month.get(yymm, 0)))
230
-        f.write('</table></div>')
231
-        f.write('<img src="commits_by_year_month.png" alt="Commits by year/month">')
232
-        fg = open(path + '/commits_by_year_month.dat', 'w')
233
-        for yymm in sorted(data.commits_by_month.keys()):
234
-            fg.write('%s %s\n' % (yymm, data.commits_by_month[yymm]))
235
-        fg.close()
236
-
237
-        # Commits by year
238
-        f.write(html_header(2, 'Commits by Year'))
239
-        f.write(
240
-            '<div class="vtable"><table><tr><th>Year</th><th>Commits (% of all)</th><th>Lines added</th><th>Lines removed</th></tr>')
241
-        for yy in reversed(sorted(data.commits_by_year.keys())):
242
-            f.write('<tr><td>%s</td><td>%d (%.2f%%)</td><td>%d</td><td>%d</td></tr>' % (
243
-                yy, data.commits_by_year.get(yy, 0), (100.0 * data.commits_by_year.get(yy, 0)) / data.getTotalCommits(),
244
-                data.lines_added_by_year.get(yy, 0), data.lines_removed_by_year.get(yy, 0)))
245
-        f.write('</table></div>')
246
-        f.write('<img src="commits_by_year.png" alt="Commits by Year">')
247
-        fg = open(path + '/commits_by_year.dat', 'w')
248
-        for yy in sorted(data.commits_by_year.keys()):
249
-            fg.write('%d %d\n' % (yy, data.commits_by_year[yy]))
250
-        fg.close()
251
-
252
-        # Commits by timezone
253
-        f.write(html_header(2, 'Commits by Timezone'))
254
-        f.write('<table><tr>')
255
-        f.write('<th>Timezone</th><th>Commits</th>')
256
-        f.write('</tr>')
257
-        max_commits_on_tz = max(data.commits_by_timezone.values())
258
-        for i in sorted(data.commits_by_timezone.keys(), key=lambda n: int(n)):
259
-            commits = data.commits_by_timezone[i]
260
-            r = 127 + int((float(commits) / max_commits_on_tz) * 128)
261
-            f.write('<tr><th>%s</th><td style="background-color: rgb(%d, 0, 0)">%d</td></tr>' % (i, r, commits))
262
-        f.write('</table>')
263
-
264
-        f.write('</body></html>')
265
-        f.close()
266
-
267
-        ###
268
-        # Authors
269
-        f = open(path + '/authors.html', 'w')
270
-        self.printHeader(f)
271
-
272
-        f.write('<h1>Authors</h1>')
273
-        self.printNav(f)
274
-
275
-        # Authors :: List of authors
276
-        f.write(html_header(2, 'List of Authors'))
277
-
278
-        f.write('<table class="authors sortable" id="authors">')
279
-        f.write(
280
-            '<tr><th>Author</th><th>Commits (%)</th><th>+ lines</th><th>- lines</th><th>First commit</th><th>Last commit</th><th class="unsortable">Age</th><th>Active days</th><th># by commits</th></tr>')
281
-        for author in data.getAuthors(self.conf['max_authors']):
282
-            info = data.getAuthorInfo(author)
283
-            f.write(
284
-                '<tr><td>%s</td><td>%d (%.2f%%)</td><td>%d</td><td>%d</td><td>%s</td><td>%s</td><td>%s</td><td>%d</td><td>%d</td></tr>' % (
285
-                    author, info.commits, info.commits_frac, info.lines_added, info.lines_removed,
286
-                    info.date_first, info.date_last, info.timedelta, len(info.active_days),
287
-                    info.place_by_commits))
288
-        f.write('</table>')
289
-
290
-        allauthors = data.getAuthors()
291
-        if len(allauthors) > self.conf['max_authors']:
292
-            rest = allauthors[self.conf['max_authors']:]
293
-            f.write('<p class="moreauthors">These didn\'t make it to the top: %s</p>' % ', '.join(rest))
294
-
295
-        f.write(html_header(2, 'Cumulated Added Lines of Code per Author'))
296
-        f.write('<img src="lines_of_code_by_author.png" alt="Lines of code per Author">')
297
-        if len(allauthors) > self.conf['max_authors']:
298
-            f.write('<p class="moreauthors">Only top %d authors shown</p>' % self.conf['max_authors'])
299
-
300
-        f.write(html_header(2, 'Commits per Author'))
301
-        f.write('<img src="commits_by_author.png" alt="Commits per Author">')
302
-        if len(allauthors) > self.conf['max_authors']:
303
-            f.write('<p class="moreauthors">Only top %d authors shown</p>' % self.conf['max_authors'])
304
-
305
-        fgl = open(path + '/lines_of_code_by_author.dat', 'w')
306
-        fgc = open(path + '/commits_by_author.dat', 'w')
307
-
308
-        lines_by_authors = {}  # cumulated added lines by
309
-        # author. to save memory,
310
-        # changes_by_date_by_author[stamp][author] is defined
311
-        # only at points where author commits.
312
-        # lines_by_authors allows us to generate all the
313
-        # points in the .dat file.
314
-
315
-        # Don't rely on getAuthors to give the same order each
316
-        # time. Be robust and keep the list in a variable.
317
-        commits_by_authors = {}  # cumulated added lines by
318
-
319
-        self.authors_to_plot = data.getAuthors(self.conf['max_authors'])
320
-        for author in self.authors_to_plot:
321
-            lines_by_authors[author] = 0
322
-            commits_by_authors[author] = 0
323
-        for stamp in sorted(data.changes_by_date_by_author.keys()):
324
-            fgl.write('%d' % stamp)
325
-            fgc.write('%d' % stamp)
326
-            for author in self.authors_to_plot:
327
-                if author in data.changes_by_date_by_author[stamp].keys():
328
-                    lines_by_authors[author] = data.changes_by_date_by_author[stamp][author].lines_added
329
-                    commits_by_authors[author] = data.changes_by_date_by_author[stamp][author].commits
330
-                fgl.write(' %d' % lines_by_authors[author])
331
-                fgc.write(' %d' % commits_by_authors[author])
332
-            fgl.write('\n')
333
-            fgc.write('\n')
334
-        fgl.close()
335
-        fgc.close()
336
-
337
-        # Authors :: Author of Month
338
-        f.write(html_header(2, 'Author of Month'))
339
-        f.write('<table class="sortable" id="aom">')
340
-        f.write(
341
-            '<tr><th>Month</th><th>Author</th><th>Commits (%%)</th><th class="unsortable">Next top %d</th><th>Number of authors</th></tr>' %
342
-            self.conf['authors_top'])
343
-        for yymm in reversed(sorted(data.author_of_month.keys())):
344
-            authordict = data.author_of_month[yymm]
345
-            authors = getkeyssortedbyvalues(authordict)
346
-            authors.reverse()
347
-            commits = data.author_of_month[yymm][authors[0]]
348
-            next = ', '.join(authors[1:self.conf['authors_top'] + 1])
349
-            f.write('<tr><td>%s</td><td>%s</td><td>%d (%.2f%% of %d)</td><td>%s</td><td>%d</td></tr>' % (
350
-                yymm, authors[0], commits, (100.0 * commits) / data.commits_by_month[yymm], data.commits_by_month[yymm],
351
-                next, len(authors)))
352
-
353
-        f.write('</table>')
354
-
355
-        f.write(html_header(2, 'Author of Year'))
356
-        f.write(
357
-            '<table class="sortable" id="aoy"><tr><th>Year</th><th>Author</th><th>Commits (%%)</th><th class="unsortable">Next top %d</th><th>Number of authors</th></tr>' %
358
-            self.conf['authors_top'])
359
-        for yy in reversed(sorted(data.author_of_year.keys())):
360
-            authordict = data.author_of_year[yy]
361
-            authors = getkeyssortedbyvalues(authordict)
362
-            authors.reverse()
363
-            commits = data.author_of_year[yy][authors[0]]
364
-            next = ', '.join(authors[1:self.conf['authors_top'] + 1])
365
-            f.write('<tr><td>%s</td><td>%s</td><td>%d (%.2f%% of %d)</td><td>%s</td><td>%d</td></tr>' % (
366
-                yy, authors[0], commits, (100.0 * commits) / data.commits_by_year[yy], data.commits_by_year[yy], next,
367
-                len(authors)))
368
-        f.write('</table>')
369
-
370
-        # Domains
371
-        f.write(html_header(2, 'Commits by Domains'))
372
-        domains_by_commits = getkeyssortedbyvaluekey(data.domains, 'commits')
373
-        domains_by_commits.reverse()  # most first
374
-        f.write('<div class="vtable"><table>')
375
-        f.write('<tr><th>Domains</th><th>Total (%)</th></tr>')
376
-        fp = open(path + '/domains.dat', 'w')
377
-        n = 0
378
-        for domain in domains_by_commits:
379
-            if n == self.conf['max_domains']:
380
-                break
381
-            commits = 0
382
-            n += 1
383
-            info = data.getDomainInfo(domain)
384
-            fp.write('%s %d %d\n' % (domain, n, info['commits']))
385
-            f.write('<tr><th>%s</th><td>%d (%.2f%%)</td></tr>' % (
386
-                domain, info['commits'], (100.0 * info['commits'] / totalcommits)))
387
-        f.write('</table></div>')
388
-        f.write('<img src="domains.png" alt="Commits by Domains">')
389
-        fp.close()
390
-
391
-        f.write('</body></html>')
392
-        f.close()
393
-
394
-        ###
395
-        # Files
396
-        f = open(path + '/files.html', 'w')
397
-        self.printHeader(f)
398
-        f.write('<h1>Files</h1>')
399
-        self.printNav(f)
400
-
401
-        f.write('<dl>\n')
402
-        f.write('<dt>Total files</dt><dd>%d</dd>' % data.getTotalFiles())
403
-        f.write('<dt>Total lines</dt><dd>%d</dd>' % data.getTotalLOC())
404
-        try:
405
-            f.write(
406
-                '<dt>Average file size</dt><dd>%.2f bytes</dd>' % (float(data.getTotalSize()) / data.getTotalFiles()))
407
-        except ZeroDivisionError:
408
-            pass
409
-        f.write('</dl>\n')
410
-
411
-        # Files :: File count by date
412
-        f.write(html_header(2, 'File count by date'))
413
-
414
-        # use set to get rid of duplicate/unnecessary entries
415
-        files_by_date = set()
416
-        for stamp in sorted(data.files_by_stamp.keys()):
417
-            files_by_date.add(
418
-                '%s %d' % (datetime.datetime.fromtimestamp(stamp).strftime('%Y-%m-%d'), data.files_by_stamp[stamp]))
419
-
420
-        fg = open(path + '/files_by_date.dat', 'w')
421
-        for line in sorted(list(files_by_date)):
422
-            fg.write('%s\n' % line)
423
-        # for stamp in sorted(data.files_by_stamp.keys()):
424
-        #	fg.write('%s %d\n' % (datetime.datetime.fromtimestamp(stamp).strftime('%Y-%m-%d'), data.files_by_stamp[stamp]))
425
-        fg.close()
426
-
427
-        f.write('<img src="files_by_date.png" alt="Files by Date">')
428
-
429
-        # f.write('<h2>Average file size by date</h2>')
430
-
431
-        # Files :: Extensions
432
-        f.write(html_header(2, 'Extensions'))
433
-        f.write(
434
-            '<table class="sortable" id="ext"><tr><th>Extension</th><th>Files (%)</th><th>Lines (%)</th><th>Lines/file</th></tr>')
435
-        for ext in sorted(data.extensions.keys()):
436
-            files = data.extensions[ext]['files']
437
-            lines = data.extensions[ext]['lines']
438
-            try:
439
-                loc_percentage = (100.0 * lines) / data.getTotalLOC()
440
-            except ZeroDivisionError:
441
-                loc_percentage = 0
442
-            f.write('<tr><td>%s</td><td>%d (%.2f%%)</td><td>%d (%.2f%%)</td><td>%d</td></tr>' % (
443
-                ext, files, (100.0 * files) / data.getTotalFiles(), lines, loc_percentage, lines / files))
444
-        f.write('</table>')
445
-
446
-        f.write('</body></html>')
447
-        f.close()
448
-
449
-        ###
450
-        # Lines
451
-        f = open(path + '/lines.html', 'w')
452
-        self.printHeader(f)
453
-        f.write('<h1>Lines</h1>')
454
-        self.printNav(f)
455
-
456
-        f.write('<dl>\n')
457
-        f.write('<dt>Total lines</dt><dd>%d</dd>' % data.getTotalLOC())
458
-        f.write('</dl>\n')
459
-
460
-        f.write(html_header(2, 'Lines of Code'))
461
-        f.write('<img src="lines_of_code.png" alt="Lines of Code">')
462
-
463
-        fg = open(path + '/lines_of_code.dat', 'w')
464
-        for stamp in sorted(data.changes_by_date.keys()):
465
-            fg.write('%d %d\n' % (stamp, data.changes_by_date[stamp]['lines']))
466
-        fg.close()
467
-
468
-        f.write('</body></html>')
469
-        f.close()
470
-
471
-        ###
472
-        # tags.html
473
-        f = open(path + '/tags.html', 'w')
474
-        self.printHeader(f)
475
-        f.write('<h1>Tags</h1>')
476
-        self.printNav(f)
477
-
478
-        f.write('<dl>')
479
-        f.write('<dt>Total tags</dt><dd>%d</dd>' % len(data.tags))
480
-        if len(data.tags) > 0:
481
-            f.write('<dt>Average commits per tag</dt><dd>%.2f</dd>' % (1.0 * data.getTotalCommits() / len(data.tags)))
482
-        f.write('</dl>')
483
-
484
-        f.write('<table class="tags">')
485
-        f.write('<tr><th>Name</th><th>Date</th><th>Commits</th><th>Authors</th></tr>')
486
-        # sort the tags by date desc
487
-        tags_sorted_by_date_desc = map(lambda el: el[1],
488
-                                       reversed(sorted(map(lambda el: (el[1]['date'], el[0]), data.tags.items()))))
489
-        for tag in tags_sorted_by_date_desc:
490
-            authorinfo = []
491
-            self.authors_by_commits = getkeyssortedbyvalues(data.tags[tag]['authors'])
492
-            for i in reversed(self.authors_by_commits):
493
-                authorinfo.append('%s (%d)' % (i, data.tags[tag]['authors'][i]))
494
-            f.write('<tr><td>%s</td><td>%s</td><td>%d</td><td>%s</td></tr>' % (
495
-                tag, data.tags[tag]['date'], data.tags[tag]['commits'], ', '.join(authorinfo)))
496
-        f.write('</table>')
497
-
498
-        f.write('</body></html>')
499
-        f.close()
500
-
501
-        self.createGraphs(path)
502
-
503
-    def createGraphs(self, path):
504
-        logging.info('Generating graphs...')
505
-
506
-        # hour of day
507
-        f = open(path + '/hour_of_day.plot', 'w')
508
-        f.write(GNUPLOT_COMMON)
509
-        f.write(
510
-            """
511
-            set output 'hour_of_day.png'
512
-            unset key
513
-            set xrange [0.5:24.5]
514
-            set yrange [0:]
515
-            set xtics 4
516
-            set grid y
517
-            set ylabel "Commits"
518
-            plot 'hour_of_day.dat' using 1:2:(0.5) w boxes fs solid
519
-            """)
520
-        f.close()
521
-
522
-        # day of week
523
-        f = open(path + '/day_of_week.plot', 'w')
524
-        f.write(GNUPLOT_COMMON)
525
-        f.write(
526
-            """
527
-            set output 'day_of_week.png'
528
-            unset key
529
-            set xrange [0.5:7.5]
530
-            set yrange [0:]
531
-            set xtics 1
532
-            set grid y
533
-            set ylabel "Commits"
534
-            plot 'day_of_week.dat' using 1:3:(0.5):xtic(2) w boxes fs solid
535
-            """)
536
-        f.close()
537
-
538
-        # Domains
539
-        f = open(path + '/domains.plot', 'w')
540
-        f.write(GNUPLOT_COMMON)
541
-        f.write(
542
-            """
543
-            set output 'domains.png'
544
-            unset key
545
-            unset xtics
546
-            set yrange [0:]
547
-            set grid y
548
-            set ylabel "Commits"
549
-            plot 'domains.dat' using 2:3:(0.5) with boxes fs solid, '' using 2:3:1 with labels rotate by 45 offset 0,1
550
-            """)
551
-        f.close()
552
-
553
-        # Month of Year
554
-        f = open(path + '/month_of_year.plot', 'w')
555
-        f.write(GNUPLOT_COMMON)
556
-        f.write(
557
-            """
558
-            set output 'month_of_year.png'
559
-            unset key
560
-            set xrange [0.5:12.5]
561
-            set yrange [0:]
562
-            set xtics 1
563
-            set grid y
564
-            set ylabel "Commits"
565
-            plot 'month_of_year.dat' using 1:2:(0.5) w boxes fs solid
566
-            """)
567
-        f.close()
568
-
569
-        # commits_by_year_month
570
-        f = open(path + '/commits_by_year_month.plot', 'w')
571
-        f.write(GNUPLOT_COMMON)
572
-        f.write(
573
-            """
574
-            set output 'commits_by_year_month.png'
575
-            unset key
576
-            set yrange [0:]
577
-            set xdata time
578
-            set timefmt "%Y-%m"
579
-            set format x "%Y-%m"
580
-            set xtics rotate
581
-            set bmargin 5
582
-            set grid y
583
-            set ylabel "Commits"
584
-            plot 'commits_by_year_month.dat' using 1:2:(0.5) w boxes fs solid
585
-            """)
586
-        f.close()
587
-
588
-        # commits_by_year
589
-        f = open(path + '/commits_by_year.plot', 'w')
590
-        f.write(GNUPLOT_COMMON)
591
-        f.write(
592
-            """
593
-            set output 'commits_by_year.png'
594
-            unset key
595
-            set yrange [0:]
596
-            set xtics 1 rotate
597
-            set grid y
598
-            set ylabel "Commits"
599
-            set yrange [0:]
600
-            plot 'commits_by_year.dat' using 1:2:(0.5) w boxes fs solid
601
-            """)
602
-        f.close()
603
-
604
-        # Files by date
605
-        f = open(path + '/files_by_date.plot', 'w')
606
-        f.write(GNUPLOT_COMMON)
607
-        f.write(
608
-            """
609
-            set output 'files_by_date.png'
610
-            unset key
611
-            set yrange [0:]
612
-            set xdata time
613
-            set timefmt "%Y-%m-%d"
614
-            set format x "%Y-%m-%d"
615
-            set grid y
616
-            set ylabel "Files"
617
-            set xtics rotate
618
-            set ytics autofreq
619
-            set bmargin 6
620
-            plot 'files_by_date.dat' using 1:2 w steps
621
-            """)
622
-        f.close()
623
-
624
-        # Lines of Code
625
-        f = open(path + '/lines_of_code.plot', 'w')
626
-        f.write(GNUPLOT_COMMON)
627
-        f.write(
628
-            """
629
-            set output 'lines_of_code.png'
630
-            unset key
631
-            set yrange [0:]
632
-            set xdata time
633
-            set timefmt "%s"
634
-            set format x "%Y-%m-%d"
635
-            set grid y
636
-            set ylabel "Lines"
637
-            set xtics rotate
638
-            set bmargin 6
639
-            plot 'lines_of_code.dat' using 1:2 w lines
640
-            """)
641
-        f.close()
642
-
643
-        # Lines of Code Added per author
644
-        f = open(path + '/lines_of_code_by_author.plot', 'w')
645
-        f.write(GNUPLOT_COMMON)
646
-        f.write(
647
-            """
648
-            set terminal png transparent size 640,480
649
-            set output 'lines_of_code_by_author.png'
650
-            set key left top
651
-            set yrange [0:]
652
-            set xdata time
653
-            set timefmt "%s"
654
-            set format x "%Y-%m-%d"
655
-            set grid y
656
-            set ylabel "Lines"
657
-            set xtics rotate
658
-            set bmargin 6
659
-            plot """
660
-        )
661
-        i = 1
662
-        plots = []
663
-        for a in self.authors_to_plot:
664
-            i = i + 1
665
-            author = a.replace("\"", "\\\"").replace("`", "")
666
-            plots.append("""'lines_of_code_by_author.dat' using 1:%d title "%s" w lines""" % (i, author))
667
-        f.write(", ".join(plots))
668
-        f.write('\n')
669
-
670
-        f.close()
671
-
672
-        # Commits per author
673
-        f = open(path + '/commits_by_author.plot', 'w')
674
-        f.write(GNUPLOT_COMMON)
675
-        f.write(
676
-            """
677
-            set terminal png transparent size 640,480
678
-            set output 'commits_by_author.png'
679
-            set key left top
680
-            set yrange [0:]
681
-            set xdata time
682
-            set timefmt "%s"
683
-            set format x "%Y-%m-%d"
684
-            set grid y
685
-            set ylabel "Commits"
686
-            set xtics rotate
687
-            set bmargin 6
688
-            plot """
689
-        )
690
-        i = 1
691
-        plots = []
692
-        for a in self.authors_to_plot:
693
-            i = i + 1
694
-            author = a.replace("\"", "\\\"").replace("`", "")
695
-            plots.append("""'commits_by_author.dat' using 1:%d title "%s" w lines""" % (i, author))
696
-        f.write(", ".join(plots))
697
-        f.write('\n')
698
-
699
-        f.close()
700
-
701
-        os.chdir(path)
702
-        files = glob.glob(path + '/*.plot')
703
-        for f in files:
704
-            out = getpipeoutput([gnuplot_cmd + ' "%s"' % f])
705
-            if len(out) > 0:
706
-                print(out)
707
-
708
-    def printHeader(self, f, title=''):
709
-        f.write(
710
-            """<!DOCTYPE html>
711
-            <html>
712
-            <head>
713
-                <meta charset="UTF-8">
714
-                <title>GitStats - %s</title>
715
-                <link rel="stylesheet" href="%s" type="text/css">
716
-                <meta name="generator" content="GitStats %s">
717
-                <script type="text/javascript" src="sortable.js"></script>
718
-            </head>
719
-            <body>
720
-            """ % (self.title, self.conf['style'], getversion()))
721
-
722
-    def printNav(self, f):
723
-        f.write("""
724
-<div class="nav">
725
-<ul>
726
-<li><a href="index.html">General</a></li>
727
-<li><a href="activity.html">Activity</a></li>
728
-<li><a href="authors.html">Authors</a></li>
729
-<li><a href="files.html">Files</a></li>
730
-<li><a href="lines.html">Lines</a></li>
731
-<li><a href="tags.html">Tags</a></li>
732
-</ul>
733
-</div>
734
-""")

+ 0
- 94
gitstats/miscfuncs.py Целия файл

@@ -1,19 +1,7 @@
1
-import datetime
2 1
 import logging
3
-import os
4
-import re
5 2
 import subprocess
6 3
 import time
7 4
 
8
-os.environ['LC_ALL'] = 'C'
9
-
10
-# By default, gnuplot is searched from path, but can be overridden with the
11
-# environment variable "GNUPLOT"
12
-gnuplot_cmd = 'gnuplot'
13
-if 'GNUPLOT' in os.environ:
14
-    gnuplot_cmd = os.environ['GNUPLOT']
15
-
16
-
17 5
 def getpipeoutput(cmds):
18 6
     start = time.time()
19 7
     p = subprocess.Popen(cmds[0], stdout=subprocess.PIPE, shell=True)
@@ -27,85 +15,3 @@ def getpipeoutput(cmds):
27 15
     end = time.time()
28 16
     logging.info(f'\r[{end - start:.4f}] >> {" | ".join(cmds)}')
29 17
     return output.rstrip('\n')
30
-
31
-
32
-def getlogrange(conf, defaultrange='HEAD', end_only=True):
33
-    commit_range = getcommitrange(conf, defaultrange, end_only)
34
-    if len(conf['start_date']) > 0:
35
-        return '--since="%s" "%s"' % (conf['start_date'], commit_range)
36
-    return commit_range
37
-
38
-
39
-def getcommitrange(conf, defaultrange='HEAD', end_only=False):
40
-    if len(conf['commit_end']) > 0:
41
-        if end_only or len(conf['commit_begin']) == 0:
42
-            return conf['commit_end']
43
-        return '%s..%s' % (conf['commit_begin'], conf['commit_end'])
44
-    return defaultrange
45
-
46
-
47
-def getkeyssortedbyvalues(dictionary):
48
-    return [elem[1] for elem in sorted([(el[1], el[0]) for el in dictionary.items()])]
49
-
50
-
51
-# dict['author'] = { 'commits': 512 } - ...key(dict, 'commits')
52
-def getkeyssortedbyvaluekey(d, key):
53
-    return [elem[1] for elem in sorted([(d[el][key], el) for el in d.keys()])]
54
-
55
-
56
-def getstatsummarycounts(line):
57
-    numbers = re.findall('\d+', line)
58
-    if len(numbers) == 1:
59
-        # neither insertions nor deletions: may probably only happen for "0 files changed"
60
-        numbers.append(0)
61
-        numbers.append(0)
62
-    elif len(numbers) == 2 and line.find('(+)') != -1:
63
-        numbers.append(0)  # only insertions were printed on line
64
-    elif len(numbers) == 2 and line.find('(-)') != -1:
65
-        numbers.insert(1, 0)  # only deletions were printed on line
66
-    return numbers
67
-
68
-
69
-def getversion():
70
-    from ._version import get_versions
71
-    __version__ = get_versions()['version']
72
-    del get_versions
73
-    return __version__
74
-
75
-
76
-def getgitversion():
77
-    return getpipeoutput(['git --version']).split('\n')[0]
78
-
79
-
80
-def getgnuplotversion():
81
-    return getpipeoutput(['%s --version' % gnuplot_cmd]).split('\n')[0]
82
-
83
-
84
-def getnumoffilesfromrev(tree_hash):
85
-    """
86
-    Get number of files changed in commit
87
-    """
88
-    # DBG: git ls-tree -r --name-only "ceb3165b51ae0680724fd71e16a5ff836a0de41e"' | 'wc -l'
89
-    return (tree_hash, int(getpipeoutput(['git ls-tree -r --name-only "%s"' % tree_hash, 'wc -l']).split('\n')[0]))
90
-
91
-
92
-def getnumoflinesinblob(blob_id):
93
-    """
94
-    Get number of lines in blob
95
-    """
96
-
97
-    # DBG: git cat-file blob e4f17a621893811250be96c8ef9c37b5e97a1df7', 'wc -l'
98
-    return blob_id, int(getpipeoutput(['git cat-file blob %s' % blob_id, 'wc -l']).split()[0])
99
-
100
-def gettimedelta(sha_tuple):
101
-    """
102
-    Get the time delta between the time stamp passed in the tuple ([1]) and the sha of the second rev in the tuple ([2])
103
-    return the result, keyed by the sha of the first rev in the tuple ([0])
104
-    """
105
-    # DBG:  git log -n 1 --format=%at "ceb3165b51ae0680724fd71e16a5ff836a0de41e"'
106
-    timestamp_branch = int(getpipeoutput([' git log -n 1 --format=%%at "%s"' % sha_tuple[2]]).split('\n')[0])
107
-    delta = datetime.datetime.utcfromtimestamp(sha_tuple[1]) - datetime.datetime.utcfromtimestamp(timestamp_branch)
108
-
109
-    return (sha_tuple[0], delta)
110
-
111
-

+ 0
- 81
gitstats/process.py Целия файл

@@ -1,81 +0,0 @@
1
-#!/usr/bin/python
2
-# Copyright (c) 2007-2014 Heikki Hokkanen <hoxu@users.sf.net> & others (see doc/AUTHOR)
3
-# GPLv2 / GPLv3
4
-import logging
5
-import os
6
-import sys
7
-import time
8
-
9
-import multiprocessing_logging
10
-
11
-from gitstats.gitdatacollector import GitDataCollector
12
-from gitstats.htmlreportcreator import HTMLReportCreator
13
-from gitstats.miscfuncs import getgnuplotversion
14
-from gitstats import cli
15
-
16
-exectime_internal = 0.0
17
-exectime_external = 0.0
18
-
19
-def run():
20
-
21
-    conf, paths, outputpath = cli.get_cli()
22
-
23
-    logging.basicConfig(level=conf['logging'], format='%(message)s')
24
-    multiprocessing_logging.install_mp_handler()
25
-    time_start = time.time()
26
-
27
-
28
-    rundir = os.getcwd()
29
-
30
-    try:
31
-        os.makedirs(outputpath)
32
-    except OSError:
33
-        pass
34
-    if not os.path.isdir(outputpath):
35
-        logging.fatal('Output path is not a directory or does not exist')
36
-        sys.exit(1)
37
-
38
-    if not getgnuplotversion():
39
-        logging.error('gnuplot not found')
40
-        sys.exit(1)
41
-
42
-    logging.info(f'Output path: {outputpath}')
43
-    cachefile = os.path.join(outputpath, 'gitstats.cache')
44
-
45
-    data = GitDataCollector(conf)
46
-    data.loadCache(cachefile)
47
-
48
-    for gitpath in paths:
49
-        logging.info(f'Git path: {gitpath}')
50
-
51
-        prevdir = os.getcwd()
52
-        os.chdir(gitpath)
53
-
54
-        logging.info('Collecting data...')
55
-        data.collect(gitpath)
56
-
57
-        os.chdir(prevdir)
58
-
59
-    data.saveCache(cachefile)
60
-
61
-    logging.info('Refining data...')
62
-    data.refine()
63
-
64
-    os.chdir(rundir)
65
-
66
-    logging.info('Generating report...')
67
-    report = HTMLReportCreator(conf)
68
-    report.create(data, outputpath)
69
-
70
-    time_end = time.time()
71
-    calculated_exectime_internal = time_end - time_start
72
-    logging.info(f'Execution time {calculated_exectime_internal} secs, {exectime_external} secs ({(100.0 * exectime_external) / calculated_exectime_internal}%) in external commands)')
73
-
74
-    print('You may now run:')
75
-    print()
76
-    print('   sensible-browser \'%s\'' % os.path.join(outputpath, 'index.html').replace("'", "'\\''"))
77
-    print()
78
-
79
-
80
-if __name__ == '__main__':
81
-    run()

+ 0
- 11
gitstats/reportcreator.py Целия файл

@@ -1,11 +0,0 @@
1
-class ReportCreator:
2
-    """Creates the actual report based on given data."""
3
-
4
-    def __init__(self, conf):
5
-        self.conf = conf
6
-        self.data = None
7
-        self.path = None
8
-
9
-    def create(self, data, path):
10
-        self.data = data
11
-        self.path = path

BIN
gitstats/resources/arrow-down.gif Целия файл


BIN
gitstats/resources/arrow-none.gif Целия файл


BIN
gitstats/resources/arrow-up.gif Целия файл


+ 0
- 145
gitstats/resources/gitstats.css Целия файл

@@ -1,145 +0,0 @@
1
-/**
2
- * GitStats - default style
3
- */
4
-body {
5
-	color: black;
6
-	background-color: #dfd;
7
-}
8
-
9
-dt {
10
-	font-weight: bold;
11
-	float: left;
12
-	margin-right: 1em;
13
-}
14
-
15
-dt:after {
16
-	content: ': ';
17
-}
18
-
19
-dd {
20
-	display: block;
21
-	clear: left;
22
-}
23
-
24
-table {
25
-	border: 1px solid black;
26
-	border-collapse: collapse;
27
-	font-size: 80%;
28
-	margin-bottom: 1em;
29
-}
30
-
31
-table.noborders {
32
-	border: none;
33
-}
34
-
35
-table.noborders td {
36
-	border: none;
37
-}
38
-
39
-.vtable {
40
-	float: right;
41
-	clear: both;
42
-}
43
-
44
-table.tags td {
45
-	vertical-align: top;
46
-}
47
-
48
-td {
49
-	background-color: white;
50
-}
51
-
52
-th {
53
-	background-color: #ddf;
54
-}
55
-
56
-th a {
57
-	text-decoration: none;
58
-}
59
-
60
-tr:hover {
61
-	background-color: #ddf;
62
-}
63
-
64
-td {
65
-	border: 1px solid black;
66
-	padding: 0.2em;
67
-	padding-left: 0.3em;
68
-	padding-right: 0.2em;
69
-}
70
-
71
-/* Navigation bar; tabbed style */
72
-.nav {
73
-	border-bottom: 1px solid black;
74
-	padding: 0.3em;
75
-}
76
-
77
-.nav ul {
78
-	list-style-type: none;
79
-	display: inline;
80
-	margin: 0;
81
-	padding: 0;
82
-}
83
-
84
-.nav li {
85
-	display: inline;
86
-}
87
-
88
-.nav li a {
89
-	padding: 0.3em;
90
-	text-decoration: none;
91
-	color: black;
92
-	border: 1px solid black;
93
-	margin: 0.5em;
94
-	background-color: #ddf;
95
-}
96
-
97
-.nav li a:hover {
98
-	background-color: #ddd;
99
-	border-bottom: 1px solid #ddf;
100
-}
101
-
102
-img {
103
-	border: 1px solid black;
104
-	padding: 0.5em;
105
-	background-color: white;
106
-}
107
-
108
-th img {
109
-	border: 0px;
110
-	padding: 0px;
111
-	background-color: #ddf;
112
-}
113
-
114
-h1 a, h2 a {
115
-	color: black;
116
-	text-decoration: none;
117
-}
118
-
119
-h1:hover a:after,
120
-h2:hover a:after {
121
-	content: '¶';
122
-	color: #555;
123
-}
124
-
125
-h1 {
126
-	font-size: x-large;
127
-}
128
-
129
-h2 {
130
-	background-color: #564;
131
-	border: 1px solid black;
132
-	padding-left: 0.5em;
133
-	padding-right: 0.5em;
134
-	color: white;
135
-	font-size: large;
136
-	clear: both;
137
-}
138
-
139
-h2 a {
140
-	color: white;
141
-}
142
-
143
-.moreauthors {
144
-	font-size: 80%;
145
-}

+ 0
- 324
gitstats/resources/sortable.js Целия файл

@@ -1,324 +0,0 @@
1
-/*
2
-Table sorting script  by Joost de Valk, check it out at http://www.joostdevalk.nl/code/sortable-table/.
3
-Based on a script from http://www.kryogenix.org/code/browser/sorttable/.
4
-Distributed under the MIT license: http://www.kryogenix.org/code/browser/licence.html .
5
-
6
-Copyright (c) 1997-2007 Stuart Langridge, Joost de Valk.
7
-
8
-Version 1.5.7
9
-*/
10
-
11
-/* You can change these values */
12
-var image_path = "";
13
-var image_up = "arrow-up.gif";
14
-var image_down = "arrow-down.gif";
15
-var image_none = "arrow-none.gif";
16
-var europeandate = true;
17
-var alternate_row_colors = true;
18
-
19
-/* Don't change anything below this unless you know what you're doing */
20
-addEvent(window, "load", sortables_init);
21
-
22
-var SORT_COLUMN_INDEX;
23
-var thead = false;
24
-
25
-function sortables_init() {
26
-	// Find all tables with class sortable and make them sortable
27
-	if (!document.getElementsByTagName) return;
28
-	tbls = document.getElementsByTagName("table");
29
-	for (ti=0;ti<tbls.length;ti++) {
30
-		thisTbl = tbls[ti];
31
-		if (((' '+thisTbl.className+' ').indexOf("sortable") != -1) && (thisTbl.id)) {
32
-			ts_makeSortable(thisTbl);
33
-		}
34
-	}
35
-}
36
-
37
-function ts_makeSortable(t) {
38
-	if (t.rows && t.rows.length > 0) {
39
-		if (t.tHead && t.tHead.rows.length > 0) {
40
-			var firstRow = t.tHead.rows[t.tHead.rows.length-1];
41
-			thead = true;
42
-		} else {
43
-			var firstRow = t.rows[0];
44
-		}
45
-	}
46
-	if (!firstRow) return;
47
-	
48
-	// We have a first row: assume it's the header, and make its contents clickable links
49
-	for (var i=0;i<firstRow.cells.length;i++) {
50
-		var cell = firstRow.cells[i];
51
-		var txt = ts_getInnerText(cell);
52
-		if (cell.className != "unsortable" && cell.className.indexOf("unsortable") == -1) {
53
-			cell.innerHTML = '<a href="#" class="sortheader" onclick="ts_resortTable(this, '+i+');return false;">'+txt+'<span class="sortarrow">&nbsp;&nbsp;<img src="'+ image_path + image_none + '" alt="&darr;"/></span></a>';
54
-		}
55
-	}
56
-	if (alternate_row_colors) {
57
-		alternate(t);
58
-	}
59
-}
60
-
61
-function ts_getInnerText(el) {
62
-	if (typeof el == "string") return el;
63
-	if (typeof el == "undefined") { return el };
64
-	if (el.innerText) return el.innerText;	//Not needed but it is faster
65
-	var str = "";
66
-	
67
-	var cs = el.childNodes;
68
-	var l = cs.length;
69
-	for (var i = 0; i < l; i++) {
70
-		switch (cs[i].nodeType) {
71
-			case 1: //ELEMENT_NODE
72
-				str += ts_getInnerText(cs[i]);
73
-				break;
74
-			case 3:	//TEXT_NODE
75
-				str += cs[i].nodeValue;
76
-				break;
77
-		}
78
-	}
79
-	return str;
80
-}
81
-
82
-function ts_resortTable(lnk, clid) {
83
-	var span;
84
-	for (var ci=0;ci<lnk.childNodes.length;ci++) {
85
-		if (lnk.childNodes[ci].tagName && lnk.childNodes[ci].tagName.toLowerCase() == 'span') span = lnk.childNodes[ci];
86
-	}
87
-	var spantext = ts_getInnerText(span);
88
-	var td = lnk.parentNode;
89
-	var column = clid || td.cellIndex;
90
-	var t = getParent(td,'TABLE');
91
-	// Work out a type for the column
92
-	if (t.rows.length <= 1) return;
93
-	var itm = "";
94
-	var i = 1;
95
-	while (itm == "" && i < t.tBodies[0].rows.length) {
96
-		var itm = ts_getInnerText(t.tBodies[0].rows[i].cells[column]);
97
-		itm = trim(itm);
98
-		if (itm.substr(0,4) == "<!--" || itm.length == 0) {
99
-			itm = "";
100
-		}
101
-		i++;
102
-	}
103
-	if (itm == "") return; 
104
-	sortfn = ts_sort_caseinsensitive;
105
-	if (itm.match(/^\d\d[\/\.-][a-zA-z][a-zA-Z][a-zA-Z][\/\.-]\d\d\d\d$/)) sortfn = ts_sort_date;
106
-	if (itm.match(/^\d\d[\/\.-]\d\d[\/\.-]\d\d\d{2}?$/)) sortfn = ts_sort_date;
107
-	if (itm.match(/^-?[£$€Û¢´]\d/)) sortfn = ts_sort_numeric;
108
-	// ignore stuff in () after the numbers.
109
-	if (itm.match(/^-?(\d+[,\.]?)+(E[-+][\d]+)?%?( \(.*\))?$/)) sortfn = ts_sort_numeric;
110
-	SORT_COLUMN_INDEX = column;
111
-	var firstRow = new Array();
112
-	var newRows = new Array();
113
-	for (k=0;k<t.tBodies.length;k++) {
114
-		for (i=0;i<t.tBodies[k].rows[0].length;i++) { 
115
-			firstRow[i] = t.tBodies[k].rows[0][i]; 
116
-		}
117
-	}
118
-	for (k=0;k<t.tBodies.length;k++) {
119
-		if (!thead) {
120
-			// Skip the first row
121
-			for (j=1;j<t.tBodies[k].rows.length;j++) { 
122
-				newRows[j-1] = t.tBodies[k].rows[j];
123
-			}
124
-		} else {
125
-			// Do NOT skip the first row
126
-			for (j=0;j<t.tBodies[k].rows.length;j++) { 
127
-				newRows[j] = t.tBodies[k].rows[j];
128
-			}
129
-		}
130
-	}
131
-	newRows.sort(sortfn);
132
-	if (span.getAttribute("sortdir") == 'down') {
133
-			ARROW = '&nbsp;&nbsp;<img src="'+ image_path + image_down + '" alt="&darr;"/>';
134
-			newRows.reverse();
135
-			span.setAttribute('sortdir','up');
136
-	} else {
137
-			ARROW = '&nbsp;&nbsp;<img src="'+ image_path + image_up + '" alt="&uarr;"/>';
138
-			span.setAttribute('sortdir','down');
139
-	} 
140
-    // We appendChild rows that already exist to the tbody, so it moves them rather than creating new ones
141
-    // don't do sortbottom rows
142
-    for (i=0; i<newRows.length; i++) { 
143
-		if (!newRows[i].className || (newRows[i].className && (newRows[i].className.indexOf('sortbottom') == -1))) {
144
-			t.tBodies[0].appendChild(newRows[i]);
145
-		}
146
-	}
147
-    // do sortbottom rows only
148
-    for (i=0; i<newRows.length; i++) {
149
-		if (newRows[i].className && (newRows[i].className.indexOf('sortbottom') != -1)) 
150
-			t.tBodies[0].appendChild(newRows[i]);
151
-	}
152
-	// Delete any other arrows there may be showing
153
-	var allspans = document.getElementsByTagName("span");
154
-	for (var ci=0;ci<allspans.length;ci++) {
155
-		if (allspans[ci].className == 'sortarrow') {
156
-			if (getParent(allspans[ci],"table") == getParent(lnk,"table")) { // in the same table as us?
157
-				allspans[ci].innerHTML = '&nbsp;&nbsp;<img src="'+ image_path + image_none + '" alt="&darr;"/>';
158
-			}
159
-		}
160
-	}		
161
-	span.innerHTML = ARROW;
162
-	alternate(t);
163
-}
164
-
165
-function getParent(el, pTagName) {
166
-	if (el == null) {
167
-		return null;
168
-	} else if (el.nodeType == 1 && el.tagName.toLowerCase() == pTagName.toLowerCase()) {
169
-		return el;
170
-	} else {
171
-		return getParent(el.parentNode, pTagName);
172
-	}
173
-}
174
-
175
-function sort_date(date) {	
176
-	// y2k notes: two digit years less than 50 are treated as 20XX, greater than 50 are treated as 19XX
177
-	dt = "00000000";
178
-	if (date.length == 11) {
179
-		mtstr = date.substr(3,3);
180
-		mtstr = mtstr.toLowerCase();
181
-		switch(mtstr) {
182
-			case "jan": var mt = "01"; break;
183
-			case "feb": var mt = "02"; break;
184
-			case "mar": var mt = "03"; break;
185
-			case "apr": var mt = "04"; break;
186
-			case "may": var mt = "05"; break;
187
-			case "jun": var mt = "06"; break;
188
-			case "jul": var mt = "07"; break;
189
-			case "aug": var mt = "08"; break;
190
-			case "sep": var mt = "09"; break;
191
-			case "oct": var mt = "10"; break;
192
-			case "nov": var mt = "11"; break;
193
-			case "dec": var mt = "12"; break;
194
-			// default: var mt = "00";
195
-		}
196
-		dt = date.substr(7,4)+mt+date.substr(0,2);
197
-		return dt;
198
-	} else if (date.length == 10) {
199
-		if (europeandate == false) {
200
-			dt = date.substr(6,4)+date.substr(0,2)+date.substr(3,2);
201
-			return dt;
202
-		} else {
203
-			dt = date.substr(6,4)+date.substr(3,2)+date.substr(0,2);
204
-			return dt;
205
-		}
206
-	} else if (date.length == 8) {
207
-		yr = date.substr(6,2);
208
-		if (parseInt(yr) < 50) { 
209
-			yr = '20'+yr; 
210
-		} else { 
211
-			yr = '19'+yr; 
212
-		}
213
-		if (europeandate == true) {
214
-			dt = yr+date.substr(3,2)+date.substr(0,2);
215
-			return dt;
216
-		} else {
217
-			dt = yr+date.substr(0,2)+date.substr(3,2);
218
-			return dt;
219
-		}
220
-	}
221
-	return dt;
222
-}
223
-
224
-function ts_sort_date(a,b) {
225
-	dt1 = sort_date(ts_getInnerText(a.cells[SORT_COLUMN_INDEX]));
226
-	dt2 = sort_date(ts_getInnerText(b.cells[SORT_COLUMN_INDEX]));
227
-	
228
-	if (dt1==dt2) {
229
-		return 0;
230
-	}
231
-	if (dt1<dt2) { 
232
-		return -1;
233
-	}
234
-	return 1;
235
-}
236
-function ts_sort_numeric(a,b) {
237
-	var aa = ts_getInnerText(a.cells[SORT_COLUMN_INDEX]);
238
-	aa = clean_num(aa);
239
-	var bb = ts_getInnerText(b.cells[SORT_COLUMN_INDEX]);
240
-	bb = clean_num(bb);
241
-	return compare_numeric(aa,bb);
242
-}
243
-function compare_numeric(a,b) {
244
-	var a = parseFloat(a);
245
-	a = (isNaN(a) ? 0 : a);
246
-	var b = parseFloat(b);
247
-	b = (isNaN(b) ? 0 : b);
248
-	return a - b;
249
-}
250
-function ts_sort_caseinsensitive(a,b) {
251
-	aa = ts_getInnerText(a.cells[SORT_COLUMN_INDEX]).toLowerCase();
252
-	bb = ts_getInnerText(b.cells[SORT_COLUMN_INDEX]).toLowerCase();
253
-	if (aa==bb) {
254
-		return 0;
255
-	}
256
-	if (aa<bb) {
257
-		return -1;
258
-	}
259
-	return 1;
260
-}
261
-function ts_sort_default(a,b) {
262
-	aa = ts_getInnerText(a.cells[SORT_COLUMN_INDEX]);
263
-	bb = ts_getInnerText(b.cells[SORT_COLUMN_INDEX]);
264
-	if (aa==bb) {
265
-		return 0;
266
-	}
267
-	if (aa<bb) {
268
-		return -1;
269
-	}
270
-	return 1;
271
-}
272
-function addEvent(elm, evType, fn, useCapture)
273
-// addEvent and removeEvent
274
-// cross-browser event handling for IE5+,	NS6 and Mozilla
275
-// By Scott Andrew
276
-{
277
-	if (elm.addEventListener){
278
-		elm.addEventListener(evType, fn, useCapture);
279
-		return true;
280
-	} else if (elm.attachEvent){
281
-		var r = elm.attachEvent("on"+evType, fn);
282
-		return r;
283
-	} else {
284
-		alert("Handler could not be removed");
285
-	}
286
-}
287
-function clean_num(str) {
288
-	str = str.replace(new RegExp(/[^-?0-9.]/g),"");
289
-	return str;
290
-}
291
-function trim(s) {
292
-	return s.replace(/^\s+|\s+$/g, "");
293
-}
294
-function alternate(table) {
295
-	// Take object table and get all it's tbodies.
296
-	var tableBodies = table.getElementsByTagName("tbody");
297
-	// Loop through these tbodies
298
-	for (var i = 0; i < tableBodies.length; i++) {
299
-		// Take the tbody, and get all it's rows
300
-		var tableRows = tableBodies[i].getElementsByTagName("tr");
301
-		// Loop through these rows
302
-		// Start at 1 because we want to leave the heading row untouched
303
-		for (var j = 0; j < tableRows.length; j++) {
304
-			// Check if j is even, and apply classes for both possible results
305
-			if ( (j % 2) == 0  ) {
306
-				if ( !(tableRows[j].className.indexOf('odd') == -1) ) {
307
-					tableRows[j].className = tableRows[j].className.replace('odd', 'even');
308
-				} else {
309
-					if ( tableRows[j].className.indexOf('even') == -1 ) {
310
-						tableRows[j].className += " even";
311
-					}
312
-				}
313
-			} else {
314
-				if ( !(tableRows[j].className.indexOf('even') == -1) ) {
315
-					tableRows[j].className = tableRows[j].className.replace('even', 'odd');
316
-				} else {
317
-					if ( tableRows[j].className.indexOf('odd') == -1 ) {
318
-						tableRows[j].className += " odd";
319
-					}
320
-				}
321
-			} 
322
-		}
323
-	}
324
-}

+ 0
- 1
setup.py Целия файл

@@ -56,7 +56,6 @@ setup(
56 56
     entry_points={
57 57
         'console_scripts': [
58 58
             'gitstats = gitstats:main',
59
-            'gencsvstats = gitstats.git_csv_generator:gen_csv'
60 59
         ],
61 60
     },
62 61
     # entry_points={