Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
SeleniumHQ
GitHub Repository: SeleniumHQ/Selenium
Path: blob/trunk/py/private/merge_cddl.py
10192 views
1
# Licensed to the Software Freedom Conservancy (SFC) under one
2
# or more contributor license agreements. See the NOTICE file
3
# distributed with this work for additional information
4
# regarding copyright ownership. The SFC licenses this file
5
# to you under the Apache License, Version 2.0 (the
6
# "License"); you may not use this file except in compliance
7
# with the License. You may obtain a copy of the License at
8
#
9
# http://www.apache.org/licenses/LICENSE-2.0
10
#
11
# Unless required by applicable law or agreed to in writing,
12
# software distributed under the License is distributed on an
13
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14
# KIND, either express or implied. See the License for the
15
# specific language governing permissions and limitations
16
# under the License.
17
18
"""Concatenate multiple CDDL files into a single output file.
19
20
Usage:
21
merge_cddl.py <output> <input1> [<input2> ...]
22
"""
23
24
import sys
25
26
27
def main() -> None:
28
if len(sys.argv) < 3:
29
usage = (__doc__ or "Usage:\n merge_cddl.py <output> <input1> [<input2> ...]\n").strip()
30
print(usage, file=sys.stderr)
31
raise SystemExit(1)
32
33
out_path = sys.argv[1]
34
input_paths = sys.argv[2:]
35
with open(out_path, "wb") as out_f:
36
for index, input_path in enumerate(input_paths):
37
if index > 0:
38
# Ensure files that lack a trailing newline don't accidentally
39
# join their last and first tokens across the boundary.
40
out_f.write(b"\n")
41
with open(input_path, "rb") as in_f:
42
out_f.write(in_f.read())
43
44
45
if __name__ == "__main__":
46
main()
47
48