<s> """<STR_LIT>""" <EOL> from __future__ import absolute_import <EOL> import re <EOL> import warnings <EOL> import keyword <EOL> from . exceptions import NaturalNameWarning <EOL> import six <EOL> __docformat__ = '<STR_LIT>' <EOL> """<STR_LIT>""" <EOL> _python_id_re = re . compile ( '<STR_LIT>' ) <EOL> """<STR_LIT>""" <EOL> _reserved_id_re = re . compile ( '<STR_LIT>' ) <EOL> """<STR_LIT>""" <EOL> _hidden_name_re = re . compile ( '<STR_LIT>' ) <EOL> """<STR_LIT>""" <EOL> _hidden_path_re = re . compile ( '<STR_LIT>' ) <EOL> """<STR_LIT>""" <EOL> _warnInfo = ( <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" ) <EOL> """<STR_LIT>""" <EOL> def check_attribute_name ( name ) : <EOL> """<STR_LIT>""" <EOL> if not isinstance ( name , six . string_types ) : <EOL> raise TypeError ( "<STR_LIT>" % ( name , ) ) <EOL> if name == '<STR_LIT>' : <EOL> raise ValueError ( "<STR_LIT>" ) <EOL> if not _python_id_re . match ( name ) : <EOL> warnings . warn ( "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> % ( name , _python_id_re . pattern , _warnInfo ) , <EOL> NaturalNameWarning ) <EOL> return <EOL> if keyword . iskeyword ( name ) : <EOL> warnings . warn ( "<STR_LIT>" <EOL> % ( name , _warnInfo ) , NaturalNameWarning ) <EOL> return <EOL> if _reserved_id_re . match ( name ) : <EOL> raise ValueError ( "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> % ( name , _reserved_id_re . pattern ) ) <EOL> if name == '<STR_LIT>' : <EOL> raise ValueError ( "<STR_LIT>" ) <EOL> def check_name_validity ( name ) : <EOL> """<STR_LIT>""" <EOL> check_attribute_name ( name ) <EOL> if name == '<STR_LIT:.>' : <EOL> raise ValueError ( "<STR_LIT>" ) <EOL> elif '<STR_LIT:/>' in name : <EOL> raise ValueError ( "<STR_LIT>" <EOL> "<STR_LIT>" % name ) <EOL> def join_path ( parentpath , name ) : <EOL> """<STR_LIT>""" <EOL> if name . startswith ( '<STR_LIT>' ) : <EOL> name = name [ <NUM_LIT:2> : ] <EOL> if parentpath == '<STR_LIT:/>' and name . startswith ( '<STR_LIT:/>' ) : <EOL> pstr = '<STR_LIT:%s>' % name <EOL> elif parentpath == '<STR_LIT:/>' or name . startswith ( '<STR_LIT:/>' ) : <EOL> pstr = '<STR_LIT>' % ( parentpath , name ) <EOL> else : <EOL> pstr = '<STR_LIT>' % ( parentpath , name ) <EOL> if pstr . endswith ( '<STR_LIT:/>' ) : <EOL> pstr = pstr [ : - <NUM_LIT:1> ] <EOL> return pstr <EOL> def split_path ( path ) : <EOL> """<STR_LIT>""" <EOL> lastslash = path . rfind ( '<STR_LIT:/>' ) <EOL> ppath = path [ : lastslash ] <EOL> name = path [ lastslash + <NUM_LIT:1> : ] <EOL> if ppath == '<STR_LIT>' : <EOL> ppath = '<STR_LIT:/>' <EOL> return ( ppath , name ) <EOL> def isvisiblename ( name ) : <EOL> """<STR_LIT>""" <EOL> return _hidden_name_re . match ( name ) is None <EOL> def isvisiblepath ( path ) : <EOL> """<STR_LIT>""" <EOL> return _hidden_path_re . search ( path ) is None <EOL> def _test ( ) : <EOL> """<STR_LIT>""" <EOL> import doctest <EOL> doctest . testmod ( ) <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> _test ( ) </s>
