Skip to content

Commit

Permalink
Carry forward opentelemetry-proto copyright notice
Browse files Browse the repository at this point in the history
  • Loading branch information
sfc-gh-jopel committed Dec 5, 2024
1 parent 3b894f9 commit 670afcb
Show file tree
Hide file tree
Showing 10 changed files with 174 additions and 0 deletions.
15 changes: 15 additions & 0 deletions scripts/plugin.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
#!/usr/bin/env python3
#
# Copyright (c) 2012-2024 Snowflake Computing Inc. All rights reserved.
#

from __future__ import annotations

import re
Expand Down Expand Up @@ -281,9 +285,19 @@ class FileTemplate:
enums: List[EnumTemplate] = field(default_factory=list)
imports: List[str] = field(default_factory=list)
name: str = ""
preamble: str = ""

@staticmethod
def from_descriptor(descriptor: FileDescriptorProto) -> "FileTemplate":
# Extract the preamble comment from the proto file
# In the case of the opentelemetry-proto files, the preamble is the license header
# Each line of the preamble is prefixed with "//"
preamble = ""
with open(f'/tmp/opentelemetry-proto/{descriptor.name}', "r") as f:
line = f.readline()
while line and line.startswith("//"):
preamble += line.replace("//", "#", 1)
line = f.readline()

# Extract the import paths for the proto file
imports = []
Expand All @@ -300,6 +314,7 @@ def from_descriptor(descriptor: FileDescriptorProto) -> "FileTemplate":
enums=[EnumTemplate.from_descriptor(enum) for enum in descriptor.enum_type],
imports=imports,
name=descriptor.name,
preamble=preamble,
)

def main():
Expand Down
7 changes: 7 additions & 0 deletions scripts/templates/template.py.jinja2
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,13 @@
#
# Copyright (c) 2012-2024 Snowflake Computing Inc. All rights reserved.
#
{{ file_template.preamble -}}
#
# This file has been generated from the original proto definition at
#
# https://github.com/open-telemetry/opentelemetry-proto
#
# using a custom protoc compiler plugin by Snowflake Computing Inc.

from __future__ import annotations

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,25 @@
#
# Copyright (c) 2012-2024 Snowflake Computing Inc. All rights reserved.
#
# Copyright 2020, OpenTelemetry Authors
#
# Licensed 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.
#
# This file has been generated from the original proto definition at
#
# https://github.com/open-telemetry/opentelemetry-proto
#
# using a custom protoc compiler plugin by Snowflake Computing Inc.

from __future__ import annotations

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,25 @@
#
# Copyright (c) 2012-2024 Snowflake Computing Inc. All rights reserved.
#
# Copyright 2019, OpenTelemetry Authors
#
# Licensed 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.
#
# This file has been generated from the original proto definition at
#
# https://github.com/open-telemetry/opentelemetry-proto
#
# using a custom protoc compiler plugin by Snowflake Computing Inc.

from __future__ import annotations

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,25 @@
#
# Copyright (c) 2012-2024 Snowflake Computing Inc. All rights reserved.
#
# Copyright 2019, OpenTelemetry Authors
#
# Licensed 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.
#
# This file has been generated from the original proto definition at
#
# https://github.com/open-telemetry/opentelemetry-proto
#
# using a custom protoc compiler plugin by Snowflake Computing Inc.

from __future__ import annotations

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,25 @@
#
# Copyright (c) 2012-2024 Snowflake Computing Inc. All rights reserved.
#
# Copyright 2019, OpenTelemetry Authors
#
# Licensed 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.
#
# This file has been generated from the original proto definition at
#
# https://github.com/open-telemetry/opentelemetry-proto
#
# using a custom protoc compiler plugin by Snowflake Computing Inc.

from __future__ import annotations

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,25 @@
#
# Copyright (c) 2012-2024 Snowflake Computing Inc. All rights reserved.
#
# Copyright 2020, OpenTelemetry Authors
#
# Licensed 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.
#
# This file has been generated from the original proto definition at
#
# https://github.com/open-telemetry/opentelemetry-proto
#
# using a custom protoc compiler plugin by Snowflake Computing Inc.

from __future__ import annotations

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,25 @@
#
# Copyright (c) 2012-2024 Snowflake Computing Inc. All rights reserved.
#
# Copyright 2019, OpenTelemetry Authors
#
# Licensed 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.
#
# This file has been generated from the original proto definition at
#
# https://github.com/open-telemetry/opentelemetry-proto
#
# using a custom protoc compiler plugin by Snowflake Computing Inc.

from __future__ import annotations

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,25 @@
#
# Copyright (c) 2012-2024 Snowflake Computing Inc. All rights reserved.
#
# Copyright 2019, OpenTelemetry Authors
#
# Licensed 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.
#
# This file has been generated from the original proto definition at
#
# https://github.com/open-telemetry/opentelemetry-proto
#
# using a custom protoc compiler plugin by Snowflake Computing Inc.

from __future__ import annotations

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,25 @@
#
# Copyright (c) 2012-2024 Snowflake Computing Inc. All rights reserved.
#
# Copyright 2019, OpenTelemetry Authors
#
# Licensed 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.
#
# This file has been generated from the original proto definition at
#
# https://github.com/open-telemetry/opentelemetry-proto
#
# using a custom protoc compiler plugin by Snowflake Computing Inc.

from __future__ import annotations

Expand Down

0 comments on commit 670afcb

Please sign in to comment.