FreeCAD

Форк
0
/
LicenseChecker.py 
98 строк · 2.8 Кб
1
#! python
2
# -*- coding: utf-8 -*-
3
# (c) 2013 Werner Mayer LGPL
4
#
5
# Utility to search for source, header and Python files with a missing license text
6

7
import codecs, os
8

9
ext = [".cpp", ".cxx", ".cc", ".c", ".hpp", ".hxx", ".hh", ".h", ".inl", ".inc", ".py"]
10
flt = [
11
    "__init__.py",
12
    "_rc.py",
13
    "coin_header_includes.h",
14
    "CxxDebug.hxx",
15
    "IndirectPythonInterface.hxx",
16
    ("thumbs%sIExtractImage.h") % (os.path.sep),
17
    # ('src%sTools')%(os.path.sep),
18
    ("src%sTools%sembedded") % (os.path.sep, os.path.sep),
19
    ("App%skdl_cp") % (os.path.sep),
20
    ("3rdParty%satlas") % (os.path.sep),
21
    ("Mod%sGDML") % (os.path.sep),
22
    ("boost%snumeric%sbindings") % (os.path.sep, os.path.sep),
23
    ("salomesmesh%sinc") % (os.path.sep),
24
    ("App%sCore%stritritest.h") % (os.path.sep, os.path.sep),
25
]
26
# A note to tritritest.h
27
# tritritest.h has no licensing information, but Tomas Moller replied
28
# the following, when asked about it:
29
#
30
# The code is free to use for anyone and any projects, but I give no
31
# warranties.
32
#
33
# See: http://anonscm.debian.org/gitweb/?p=debian-science/packages/freecad.git;a=blob;f=debian/copyright
34
lic = [
35
    "LGPL",
36
    "GNU Library",
37
    "GNU Lesser",
38
    "Permission to copy, use, modify",
39
    "Permission to use, copy, modify",
40
    "Distributed under the Boost Software License",
41
    "Redistribution  and  use  in  source  and  binary  forms",
42
    "Redistribution and use in source and binary forms",
43
    "it under the same terms as Python itself",
44
    "As a special exception, you may create a larger work that contains",
45
    "Permission is hereby granted, free of charge, to any person obtaining",
46
    "Permission is granted to anyone to use this software",
47
    "This file was automatically generated by SWIG",
48
]
49

50

51
def startProcessing():
52
    fn = os.path.realpath(__file__)
53
    # get path of parent directory
54
    fn = os.path.dirname(fn)
55
    fn = os.path.dirname(fn)
56
    global ext
57
    global flt
58
    traverse(fn, ext, flt)
59

60

61
def traverse(path, ext, flt):
62
    for r, d, f in os.walk(path):
63
        for i in f:
64
            fn = os.path.join(r, i)
65
            # filter out some file names
66
            stop = False
67
            for j in flt:
68
                if fn.find(j) >= 0:
69
                    stop = True
70
                    break
71
            if stop:
72
                continue
73
            bn = os.path.basename(fn).lower()
74
            for j in ext:
75
                if bn.endswith(j):
76
                    parsefile(fn)
77
                    break
78

79

80
def parsefile(fn):
81
    data = codecs.open(fn, "r", "utf-8")
82
    try:
83
        lines = data.readlines()
84
        data.close()
85

86
        global lic
87
        for i in lines:
88
            for j in lic:
89
                if i.find(j) >= 0:
90
                    return
91

92
        print("Missing license text in file %s") % (fn)
93
    except Exception:
94
        pass
95

96

97
if __name__ == "__main__":
98
    startProcessing()
99

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.