You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@skywalking.apache.org by ke...@apache.org on 2020/05/05 12:42:26 UTC
[skywalking-python] 03/19: Add script to check license headers
This is an automated email from the ASF dual-hosted git repository.
kezhenxu94 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/skywalking-python.git
commit 18b5bfa7921369eab15c247735bc653664858ff2
Author: kezhenxu94 <ke...@163.com>
AuthorDate: Sun May 3 11:42:28 2020 +0800
Add script to check license headers
---
.gitignore | 1 +
Makefile | 36 +++++++++++++++++++++
skywalking/client/http/__init__.py | 16 ++++++++++
skywalking/utils/__init__.py | 16 ++++++++++
tests/__init__.py | 16 ++++++++++
tools/check-license-header.py | 65 ++++++++++++++++++++++++++++++++++++++
6 files changed, 150 insertions(+)
diff --git a/.gitignore b/.gitignore
index 750824d..1cfc0a1 100644
--- a/.gitignore
+++ b/.gitignore
@@ -2,3 +2,4 @@
*.iml
.DS_Store
*~
+**/*_pb2*
\ No newline at end of file
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..8fe8308
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,36 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+.PHONY: license
+
+setup:
+ python3 -m pip install --upgrade pip
+ python3 -m pip install grpcio --ignore-installed
+ python3 -m pip install grpcio-tools
+
+gen:
+ python3 -m grpc_tools.protoc -I protocol --python_out=. --grpc_python_out=. protocol/**/*.proto
+
+license:
+ python3 tools/check-license-header.py skywalking tests tools
+
+clean:
+ rm -rf browser
+ rm -rf common
+ rm -rf language_agent
+ rm -rf management
+ rm -rf profile
+ rm -rf service_mesh_probe
diff --git a/skywalking/client/http/__init__.py b/skywalking/client/http/__init__.py
index e69de29..b1312a0 100644
--- a/skywalking/client/http/__init__.py
+++ b/skywalking/client/http/__init__.py
@@ -0,0 +1,16 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
diff --git a/skywalking/utils/__init__.py b/skywalking/utils/__init__.py
index e69de29..b1312a0 100644
--- a/skywalking/utils/__init__.py
+++ b/skywalking/utils/__init__.py
@@ -0,0 +1,16 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
diff --git a/tests/__init__.py b/tests/__init__.py
index e69de29..b1312a0 100644
--- a/tests/__init__.py
+++ b/tests/__init__.py
@@ -0,0 +1,16 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
diff --git a/tools/check-license-header.py b/tools/check-license-header.py
new file mode 100644
index 0000000..a94aea2
--- /dev/null
+++ b/tools/check-license-header.py
@@ -0,0 +1,65 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+import os
+import sys
+
+ignored_chars = '#\n \t'
+
+license_header = ' '.join(
+ [
+ line.strip(ignored_chars) for line in """
+ #
+ # Licensed to the Apache Software Foundation (ASF) under one or more
+ # contributor license agreements. See the NOTICE file distributed with
+ # this work for additional information regarding copyright ownership.
+ # The ASF licenses this file to You under the Apache License, Version 2.0
+ # (the "License"); you may not use this file except in compliance with
+ # the License. You may obtain a copy of the License at
+ #
+ # http://www.apache.org/licenses/LICENSE-2.0
+ #
+ # Unless required by applicable law or agreed to in writing, software
+ # distributed under the License is distributed on an "AS IS" BASIS,
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ # See the License for the specific language governing permissions and
+ # limitations under the License.
+ #
+ """.splitlines()
+ ]
+).strip(ignored_chars)
+
+
+def walk_through_dir(d) -> bool:
+ checked = True
+ for root, sub_dirs, files in os.walk(d):
+ for filename in files:
+ file_path = os.path.join(root, filename)
+
+ with open(file_path, 'r') as f:
+ header = ' '.join([line.strip(ignored_chars) for line in f.readlines() if line.startswith('#')]).strip()
+ print('%s license header in file: %s' % ('✅' if header == license_header else '❌', file_path))
+ checked &= header == license_header
+ return checked
+
+
+if __name__ == "__main__":
+ checked = True
+ for _, directory in enumerate(sys.argv):
+ checked &= walk_through_dir(directory)
+ if not checked:
+ sys.exit(1)