B
    i\[                @   s  d Z ddlmZ ddlZddlZddlZddlZddlZedddddd	d
dddddddddddddddddddddd d!d"d#d$d%d&d'd(d)d*d+d,d-d.d/d0d1d2d3d4d5d6d7d8d9d:d;d<d=d>d?d@dAdBdCdDdEdFdGdHdIdJdKdLdMdNdOdPdQdRdSdTdUdVdWdXdYdZd[d\d]d^d_d`dadbdcdddedfd:dgdhdidjdkdldmdndodpdqdrdsdtdudvdwdxdydzd{d|d}d~dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd ddddddddd	d
dddddddddddddddddddddd d!d"d#d$d%d&d'd(d)d*d+d,d-d.d/d0d1d2d3d4d5d6d7d8d9d:d;d<d=d>d?d@dAdBdCdDdEdFdGdHdIdJdKdLdMdNdOdPdQdRdSdTdUdVdWdXdYdZd[d\d]d^d_d`dadbdcdddedfdgdhdidjdkdldmdndodpdqdrdsdtdudvdwdxdydzd{d|d}d~ddddddddddgZ	edd e
e	D Zdd Zdd Zedkre  dS (  z_This utility helps you migrate from PyTables 2.x APIs to 3.x APIs, which
are PEP 8 compliant.

    )absolute_importN)Zhdf5VersionZhdf5_version)Z
parentNodeZ
parentnode)ZgetEnumZget_enum)Z	_initLoopZ
_init_loop)Z_fancySelectionZ_fancy_selection)Z_checkShapeZ_check_shape)Z
_readSliceZ_read_slice)Z_readCoordsZ_read_coords)Z_readSelectionZ_read_selection)Z_writeSliceZ_write_slice)Z_writeCoordsZ_write_coords)Z_writeSelectionZ_write_selection)Z_g_copyWithStatsZ_g_copy_with_stats)Z
_c_classIdZ
_c_classid)Z
_checkBaseZ
_checkbase)ZnewSetnewset)Z	copyClassZ	copyclass)Z_g_updateNodeLocationZ_g_update_node_location)Z	_g_logAddZ
_g_log_add)Z_g_delAndLogZ_g_del_and_log)Z_v__nodeFileZ_v__nodefile)Z_v__nodePathZ_v__nodepath)Z_g_setNestedNamesDescrZ_g_set_nested_names_descr)Z_g_setPathNamesZ_g_set_path_names)Z_v_colObjectsZ_v_colobjects)Z_v_nestedFormatsZ_v_nested_formats)Z_v_nestedNamesZ_v_nested_names)Z_v_nestedDescrZ_v_nested_descr)ZgetColsInOrderZget_cols_in_order)Z	joinPathsZ
join_paths)ZmetaIsDescriptionZMetaIsDescription)Z_checkShapeAppendZ_check_shape_append)Z_exprvarsCacheZ_exprvars_cache)Z_requiredExprVarsZ_required_expr_vars)ZsetInputsRangeZset_inputs_range)Z	setOutputZ
set_output)ZsetOutputRangeZset_output_range)Z	_opToCodeZ_op_to_code)Z	_codeToOpZ_code_to_op)Z_transVersionZ_trans_version)Z_transGroupParentZ_trans_group_parent)Z_transGroupNameZ_trans_group_name)Z_transGroupPathZ_trans_group_path)Z_actionLogParentZ_action_log_parent)Z_actionLogNameZ_action_log_name)Z_actionLogPathZ_action_log_path)Z_transParentZ_trans_parent)Z
_transNameZ_trans_name)Z
_transPathZ_trans_path)Z_shadowParentZ_shadow_parent)Z_shadowNameZ_shadow_name)Z_shadowPathZ_shadow_path)ZcopyFileZ	copy_file)ZopenFileZ	open_file)Z_getValueFromContainerZ_get_value_from_container)Z__getRootGroupZ__get_root_group)ZrootUEPZroot_uep)Z_getOrCreatePathZ_get_or_create_path)Z_createPathZ_create_path)ZcreateGroupZcreate_group)ZcreateTableZcreate_table)ZcreateArrayZcreate_array)ZcreateCArrayZcreate_carray)ZcreateEArrayZcreate_earray)ZcreateVLArrayZcreate_vlarray)ZcreateHardLinkZcreate_hard_link)ZcreateSoftLinkZcreate_soft_link)ZcreateExternalLinkZcreate_external_link)Z_getNodeZ	_get_node)ZgetNodeZget_node)ZisVisibleNodeZis_visible_node)Z
renameNodeZrename_node)ZmoveNodeZ	move_node)ZcopyNodeZ	copy_node)Z
removeNodeZremove_node)ZgetNodeAttrZget_node_attr)ZsetNodeAttrZset_node_attr)ZdelNodeAttrZdel_node_attr)ZcopyNodeAttrsZcopy_node_attrs)ZcopyChildrenZcopy_children)Z	listNodesZ
list_nodes)Z	iterNodesZ
iter_nodes)Z	walkNodesZ
walk_nodes)Z
walkGroupsZwalk_groups)Z
_checkOpenZ_check_open)Z_isWritableZ_iswritable)_checkWritableZ_check_writable)Z_checkGroupZ_check_group)ZisUndoEnabledZis_undo_enabled)Z_checkUndoEnabledZ_check_undo_enabled)Z_createTransactionGroupZ_create_transaction_group)Z_createTransactionZ_create_transaction)Z_createMarkZ_create_mark)Z
enableUndoZenable_undo)ZdisableUndoZdisable_undo)Z
_getMarkIDZ_get_mark_id)Z_getFinalActionZ_get_final_action)ZgetCurrentMarkZget_current_mark)Z_updateNodeLocationsZ_update_node_locations)Z_g_postInitHookZ_g_post_init_hook)Z_g_getChildGroupClassZ_g_get_child_group_class)Z_g_getChildLeafClassZ_g_get_child_leaf_class)Z_g_addChildrenNamesZ_g_add_children_names)Z_g_checkHasChildZ_g_check_has_child)Z_f_walkNodesZ_f_walknodes)Z_g_widthWarningZ_g_width_warning)Z
_g_refNodeZ
_g_refnode)Z_g_unrefNodeZ_g_unrefnode)Z_g_copyChildrenZ_g_copy_children)Z_f_getChildZ_f_get_child)Z_f_listNodesZ_f_list_nodes)Z_f_iterNodesZ_f_iter_nodes)Z_f_walkGroupsZ_f_walk_groups)Z_g_closeDescendentsZ_g_close_descendents)Z_f_copyChildrenZ_f_copy_children)Z_v_maxGroupWidthZ_v_max_group_width)Z_v_objectIDZ_v_objectid)Z_g_loadChildZ_g_load_child)Z	childNameZ	childname)Z_c_shadowNameREZ_c_shadow_name_re)Zhdf5ExtensionZhdf5extension)Z
_getFileIdZ_get_file_id)Z
_flushFileZ_flush_file)Z
_closeFileZ_close_file)Z_g_listAttrZ_g_list_attr)Z
_g_setAttrZ
_g_setattr)Z
_g_getAttrZ
_g_getattr)Z_g_listGroupZ_g_list_group)Z_g_getGChildAttrZ_g_get_gchild_attr)Z_g_getLChildAttrZ_g_get_lchild_attr)Z_g_flushGroupZ_g_flush_group)Z_g_closeGroupZ_g_close_group)Z_g_moveNodeZ_g_move_node)Z_convertTime64Z_convert_time64)Z_createArrayZ_create_array)Z_createCArrayZ_create_carray)Z
_openArrayZ_open_array)Z
_readArrayZ_read_array)Z_g_readSliceZ_g_read_slice)Z_g_readCoordsZ_g_read_coords)Z_g_readSelectionZ_g_read_selection)Z_g_writeSliceZ_g_write_slice)Z_g_writeCoordsZ_g_write_coords)Z_g_writeSelectionZ_g_write_selection)ZcalcChunksizeZcalc_chunksize)Z	infinityFZ	infinityf)ZinfinityMapZinfinitymap)ZinfTypeZinftype)ZStringNextAfterZstring_next_after)ZIntTypeNextAfterZint_type_next_after)ZBoolTypeNextAfterZbool_type_next_after)ZdefaultAutoIndexZdefault_auto_index)ZdefaultIndexFiltersZdefault_index_filters)Z_tableColumnPathnameOfIndexZ_table_column_pathname_of_index)Z_is_CSIZ_is_csi)Zis_CSIZis_csi)ZappendLastRowZappend_last_row)Zread_sliceLRZread_slice_lr)Z
readSortedZread_sorted)ZreadIndicesZread_indices)Z_processRangeZ_process_range)ZsearchLastRowZsearch_last_row)ZgetLookupRangeZget_lookup_range)Z_g_checkNameZ_g_check_name)Z
_searchBinZ_search_bin)ZindexesExtensionZindexesextension)ZinitReadZinitread)Z	readSliceZ
read_slice)Z_readIndexSliceZ_read_index_slice)Z_initSortedSliceZ_init_sorted_slice)Z_g_readSortedSliceZ_g_read_sorted_slice)Z_readSortedSliceZ_read_sorted_slice)ZgetLRUboundsZget_lru_bounds)ZgetLRUsortedZget_lru_sorted)Z_searchBinNA_bZ_search_bin_na_b)Z_searchBinNA_ubZ_search_bin_na_ub)Z_searchBinNA_sZ_search_bin_na_s)Z_searchBinNA_usZ_search_bin_na_us)Z_searchBinNA_iZ_search_bin_na_i)Z_searchBinNA_uiZ_search_bin_na_ui)Z_searchBinNA_llZ_search_bin_na_ll)Z_searchBinNA_ullZ_search_bin_na_ull)Z_searchBinNA_eZ_search_bin_na_e)Z_searchBinNA_fZ_search_bin_na_f)Z_searchBinNA_dZ_search_bin_na_d)Z_searchBinNA_gZ_search_bin_na_g)ZobjectIDZ	object_id)Z_processRangeReadZ_process_range_read)Z_pointSelectionZ_point_selection)Z	isVisibleZ	isvisible)ZgetAttrZget_attr)ZsetAttrZset_attr)ZdelAttrZdel_attr)Z_g_getLinkClassZ_g_get_link_class)ZlinkExtensionZlinkextension)Z_getLinkClassZ_get_link_class)Z_g_createHardLinkZ_g_create_hard_link)ZlrucacheExtensionZlrucacheextension)Z_checkAndSetPairZ_check_and_set_pair)Z_getContainerZ_get_container)ZcontainerRefZcontainerref)Z_g_logCreateZ_g_log_create)Z_g_preKillHookZ_g_pre_kill_hook)Z_g_checkOpenZ_g_check_open)Z_g_setLocationZ_g_set_location)Z_g_updateLocationZ_g_update_location)Z_g_delLocationZ_g_del_location)Z_g_updateDependentZ_g_update_dependent)Z_g_removeAndLogZ_g_remove_and_log)Z
_g_logMoveZ_g_log_move)ZoldPathnameZoldpathname)Z_g_copyAsChildZ_g_copy_as_child)Z_f_isVisibleZ_f_isvisible)Z_g_checkGroupZ_g_check_group)Z_g_checkNotContainsZ_g_check_not_contains)Z_g_maybeRemoveZ_g_maybe_remove)Z
_f_getAttrZ
_f_getattr)Z
_f_setAttrZ
_f_setattr)Z
_f_delAttrZ
_f_delattr)Z_v_maxTreeDepthZ_v_maxtreedepth)ZnewNodeZnew_node)ZopenNodeZ	open_node)Z_lineChunkSizeZ_line_chunksize)Z_lineSeparatorZ_line_separator)Z_notReadableErrorZ_not_readable_error)Z_appendZerosZ_append_zeros)ZgetAttrsZ
_get_attrs)ZsetAttrsZ
_set_attrs)ZdelAttrsZ
_del_attrs)Z_setAttributesZ_set_attributes)Z_checkAttributesZ_check_attributes)Z_checkNotClosedZ_check_not_closed)Z__allowedInitKwArgsZ__allowed_init_kwargs)Z
_byteShapeZ_byte_shape)Z_sizeToShapeZ_size_to_shape)Z_vTypeZ_vtype)Z_vShapeZ_vshape)Z
parentPathZ
parentpath)Z_pythonIdREZ_python_id_re)Z_reservedIdREZ_reserved_id_re)Z_hiddenNameREZ_hidden_name_re)Z_hiddenPathREZ_hidden_path_re)ZcheckNameValidityZcheck_name_validity)ZjoinPathZ	join_path)Z	splitPathZ
split_path)ZisVisibleNameZisvisiblename)ZisVisiblePathZisvisiblepath)Z	classNameZ	classname)ZclassNameDictZclass_name_dict)ZclassIdDictZclass_id_dict)ZgetClassByNameZget_class_by_name)ZdumpLeafZ	dump_leaf)Z	dumpGroupZ
dump_group)ZnewdstGroupZnewdst_group)ZrecreateIndexesZrecreate_indexes)ZcopyLeafZ	copy_leaf)Z_nxTypeFromNPTypeZ_nxtype_from_nptype)Z_npSizeTypeZ_npsizetype)Z_indexNameOfZ_index_name_of)Z_indexPathnameOfZ_index_pathname_of)Z_indexPathnameOfColumnZ_index_pathname_of_column)Z_indexNameOf_Z_index_name_of_)Z_indexPathnameOf_Z_index_pathname_of_)Z_indexPathnameOfColumn_Z_index_pathname_of_column_)Z_table__setautoIndexZ_table__setautoindex)Z_table__getautoIndexZ_table__getautoindex)Z_table__autoIndexZ_table__autoindex)Z_table__whereIndexedZ_table__where_indexed)ZcreateIndexesTableZcreate_indexes_table)ZcreateIndexesDescrZcreate_indexes_descr)Z_column__createIndexZ_column__create_index)Z
_autoIndexZ
_autoindex)Z	autoIndexZ	autoindex)Z	_useIndexZ
_use_index)Z_whereConditionZ_where_condition)Z_conditionCacheZ_condition_cache)Z_enabledIndexingInQueriesZ_enabled_indexing_in_queries)Z_emptyArrayCacheZ_empty_array_cache)Z_getTypeColNamesZ_get_type_col_names)Z_getEnumMapZ_get_enum_map)Z_cacheDescriptionDataZ_cache_description_data)Z_getColumnInstanceZ_get_column_instance)Z_checkColumnZ_check_column)Z_disableIndexingInQueriesZ_disable_indexing_in_queries)Z_enableIndexingInQueriesZ_enable_indexing_in_queries)Z_getConditionKeyZ_get_condition_key)Z_compileConditionZ_compile_condition)ZwillQueryUseIndexingZwill_query_use_indexing)Z	readWhereZ
read_where)ZwhereAppendZappend_where)ZgetWhereListZget_where_list)Z_check_sortby_CSIZ_check_sortby_csi)Z_readCoordinatesZ_read_coordinates)ZreadCoordinatesZread_coordinates)Z_saveBufferedRowsZ_save_buffered_rows)ZmodifyCoordinatesZmodify_coordinates)Z
modifyRowsZmodify_rows)ZmodifyColumnZmodify_column)ZmodifyColumnsZmodify_columns)ZflushRowsToIndexZflush_rows_to_index)Z_addRowsToIndexZ_add_rows_to_index)Z
removeRowsZremove_rows)Z_setColumnIndexingZ_set_column_indexing)Z_markColumnsAsDirtyZ_mark_columns_as_dirty)Z_reIndexZ_reindex)Z
_doReIndexZ_do_reindex)ZreIndexZreindex)ZreIndexDirtyZreindex_dirty)Z_g_copyRowsZ_g_copy_rows)Z_g_copyRows_optimZ_g_copy_rows_optim)Z_g_propIndexesZ_g_prop_indexes)Z_g_updateTableLocationZ_g_update_table_location)Z
_tableFileZ_table_file)Z
_tablePathZ_table_path)ZcreateIndexZcreate_index)ZcreateCSIndexZcreate_csindex)ZremoveIndexZremove_index)ZtableExtensionZtableextension)ZgetNestedFieldCacheZget_nested_field_cache)ZgetNestedTypeZget_nested_type)Z_createTableZ_create_table)Z_getInfoZ	_get_info)Z
indexChunkZ
indexchunk)Z
indexValidZ
indexvalid)ZindexValuesZindexvalues)ZbufcoordsDataZbufcoords_data)ZindexValuesDataZindex_values_data)ZchunkmapDataZchunkmap_data)ZindexValidDataZindex_valid_data)Z	whereCondZ	wherecond)ZiterseqMaxElementsZiterseq_max_elements)ZIObufZiobuf)ZIObufcpyZiobufcpy)Z_convertTime64_Z_convert_time64_)Z_convertTypesZ_convert_types)Z
_newBufferZ_new_buffer)Z__next__inKernelZ__next__inkernel)Z_fillColZ	_fill_col)Z_flushBufferedRowsZ_flush_buffered_rows)Z_getUnsavedNrowsZ_get_unsaved_nrows)Z_flushModRowsZ_flush_mod_rows)ZmoveToShadowZmove_to_shadow)ZmoveFromShadowZmove_from_shadow)Z
undoCreateZundo_create)Z
redoCreateZredo_create)Z
undoRemoveZundo_remove)Z
redoRemoveZredo_remove)ZundoMoveZ	undo_move)ZredoMoveZ	redo_move)ZattrToShadowZattr_to_shadow)ZattrFromShadowZattr_from_shadow)ZundoAddAttrZundo_add_attr)ZredoAddAttrZredo_add_attr)ZundoDelAttrZundo_del_attr)ZredoDelAttrZredo_del_attr)ZconvertToNPAtomZconvert_to_np_atom)ZconvertToNPAtom2Zconvert_to_np_atom2)ZcheckFileAccessZcheck_file_access)ZlogInstanceCreationZlog_instance_creation)ZfetchLoggedInstancesZfetch_logged_instances)ZcountLoggedInstancesZcount_logged_instances)ZlistLoggedInstancesZlist_logged_instances)ZdumpLoggedInstancesZdump_logged_instances)ZdetectNumberOfCoresZdetect_number_of_cores)ZutilsExtensionZutilsextension)ZPTTypeToHDF5Zpttype_to_hdf5)ZPTSpecialKindsZpt_special_kinds)ZNPExtPrefixesToPTKindsZnpext_prefixes_to_ptkinds)ZHDF5ClassToStringZhdf5_class_to_string)ZsetBloscMaxThreadsZset_blosc_max_threads)ZsilenceHDF5MessagesZsilence_hdf5_messages)Z
isHDF5FileZis_hdf5_file)ZisPyTablesFileZis_pytables_file)ZgetHDF5VersionZget_hdf5_version)ZgetPyTablesVersionZget_pytables_version)ZwhichLibVersionZwhich_lib_version)Z
whichClassZwhich_class)ZgetNestedFieldZget_nested_field)Z
getFiltersZget_filters)ZgetTypeEnumZget_type_enum)ZenumFromHDF5Zenum_from_hdf5)Z
enumToHDF5Zenum_to_hdf5)ZAtomToHDF5TypeZatom_to_hdf5_type)ZloadEnumZ	load_enum)ZHDF5ToNPNestedTypeZhdf5_to_np_nested_type)ZHDF5ToNPExtTypeZhdf5_to_np_ext_type)ZAtomFromHDF5TypeZatom_from_hdf5_type)ZcreateNestedTypeZcreate_nested_type)Z_openUnImplementedZ_open_unimplementedc             C   s   g | ]\}}||fqS  r   ).0kvr   r   4lib/python3.7/site-packages/tables/scripts/pt2to3.py
<listcomp>  s    r
   c                sp   | j r
tnt ddt  }| jrL|d7 }|d7 }|d7 }|d7 }tj	|tj
d} fdd	}||fS )
Nz(?<=\W)({0})(?=\W)|z'(?!\s*?=\s*?previous_api(_property)?\()z(?!\* to \*\w+\*)z0(?!\* parameter has been renamed into \*\w+\*\.)z1(?! is pending deprecation, import \w+ instead\.))flagsc                s     | d| dS )N   r   )getgroup)m)namesr   r	   repl  s    zmake_subs.<locals>.repl)reversenew2oldnamesold2newnamesformatjoinlistkeysignore_previousrecompile	MULTILINE)nsssubsr   r   )r   r	   	make_subs  s    r!   c           	   C   s$  d} t j| d}|jddddddd	 |jd
dddddd	 |jdd ddd |jddddddd	 |jddd | }tj|jst	d
|j t|jd}| }W d Q R X t|\}}|||}|jr|jn|j|_|jd krtj| n"t|jd}|| W d Q R X d S )NzPyTables 2.x -> 3.x API transition tool

This tool displays to standard out, so it is 
common to pipe this to another file:

$ pt2to3 oldfile.py > newfile.py)Zdescriptionz-rz	--reverse
store_trueFr   z'reverts changes, going from 3.x -> 2.x.)actiondefaultdesthelpz-pz--no-ignore-previousZstore_falseTr   zignores previous_api() calls.z-ooutputzoutput file to write to.)r$   r%   r&   z-iz	--inplaceinplacezoverwrites the file in-place.filenamezpath to input file.)r&   zfile {0!r} not foundrw)argparseArgumentParseradd_argument
parse_argsospathisfiler)   sysexitr   openreadr!   subr(   r'   stdoutwrite)Zdescparserr   fsrcr    r   Ztargr   r   r	   main  s2    



r=   __main__)__doc__Z
__future__r   r0   r   r3   r,   Zsixdictr   Z	iteritemsr   r!   r=   __name__r   r   r   r	   <module>   s$  "