1 # Copyright 2015 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 16 """Import router for file_io.""" 17 from __future__ import absolute_import 18 from __future__ import division 19 from __future__ import print_function 20 21 # pylint: disable=unused-import 22 from tensorflow.python.lib.io.file_io import copy as Copy 23 from tensorflow.python.lib.io.file_io import create_dir as MkDir 24 from tensorflow.python.lib.io.file_io import delete_file as Remove 25 from tensorflow.python.lib.io.file_io import delete_recursively as DeleteRecursively 26 from tensorflow.python.lib.io.file_io import file_exists as Exists 27 from tensorflow.python.lib.io.file_io import FileIO as _FileIO 28 from tensorflow.python.lib.io.file_io import get_matching_files as Glob 29 from tensorflow.python.lib.io.file_io import is_directory as IsDirectory 30 from tensorflow.python.lib.io.file_io import list_directory as ListDirectory 31 from tensorflow.python.lib.io.file_io import recursive_create_dir as MakeDirs 32 from tensorflow.python.lib.io.file_io import rename as Rename 33 from tensorflow.python.lib.io.file_io import stat as Stat 34 from tensorflow.python.lib.io.file_io import walk as Walk 35 # pylint: enable=unused-import 36 from tensorflow.python.util.all_util import remove_undocumented 37 from tensorflow.python.util.tf_export import tf_export 38 39 40 @tf_export('gfile.GFile', 'gfile.Open') 41 class GFile(_FileIO): 42 """File I/O wrappers without thread locking.""" 43 44 def __init__(self, name, mode='r'): 45 super(GFile, self).__init__(name=name, mode=mode) 46 47 48 @tf_export('gfile.FastGFile') 49 class FastGFile(_FileIO): 50 """File I/O wrappers without thread locking.""" 51 52 def __init__(self, name, mode='r'): 53 super(FastGFile, self).__init__(name=name, mode=mode) 54 55 56 # Does not alias to Open so that we use our version of GFile to strip 57 # 'b' mode. 58 Open = GFile 59 60 # TODO(drpng): Find the right place to document these. 61 _allowed_symbols = [ 62 'Copy', 63 'DeleteRecursively', 64 'Exists', 65 'FastGFile', 66 'GFile', 67 'Glob', 68 'IsDirectory', 69 'ListDirectory', 70 'Open', 71 'MakeDirs', 72 'MkDir', 73 'Remove', 74 'Rename', 75 'Stat', 76 'Walk', 77 ] 78 79 remove_undocumented(__name__, _allowed_symbols) 80