1# Copyright 2020 The TensorFlow Authors. All Rights Reserved.
2#
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7#     http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14# ==============================================================================
15# Lint as: python3
16"""Creates a zip package of the files passed in."""
17from __future__ import absolute_import
18from __future__ import division
19from __future__ import print_function
20
21import os
22import zipfile
23
24from absl import app
25from absl import flags
26
27FLAGS = flags.FLAGS
28flags.DEFINE_string("export_zip_path", None, "Path to zip file.")
29flags.DEFINE_string("file_directory", None, "Path to the files to be zipped.")
30
31
32def main(_):
33  with zipfile.ZipFile(FLAGS.export_zip_path, mode="w") as zf:
34    for root, _, files in os.walk(FLAGS.file_directory):
35      for f in files:
36        if f.endswith(".java"):
37          zf.write(os.path.join(root, f))
38
39
40if __name__ == "__main__":
41  app.run(main)
42