


'''simple docstring'''


import os
from collections.abc import Iterator






def  __lowerCAmelCase (__lowerCAmelCase = "."   ):
		for dir_path, dir_names, filenames in os.walk(__lowerCAmelCase   ):
				_UpperCAmelCase		:       List[Any]								=      [d for d in dir_names if d != "scripts" and d[0] not in "._"]
				for filename in filenames:
						if filename == "__init__.py":
								continue
						if os.path.splitext(__lowerCAmelCase   )[1] in (".py", ".ipynb"):
								yield os.path.join(__lowerCAmelCase      , __lowerCAmelCase   ).lstrip("./"   )






def  __lowerCAmelCase (__lowerCAmelCase   ):
		return F"""{i * '  '}*""" if i else "\n##"






def  __lowerCAmelCase (__lowerCAmelCase      , __lowerCAmelCase   ):
		_UpperCAmelCase		:       List[str]								=      old_path.split(os.sep   )
		for i, new_part in enumerate(new_path.split(os.sep   )   ):
				if (i + 1 > len(__lowerCAmelCase   ) or old_parts[i] != new_part) and new_part:
						print(F"""{md_prefix(__lowerCAmelCase   )} {new_part.replace('_'      , ' '   ).title()}"""   )
		return new_path






def  __lowerCAmelCase (__lowerCAmelCase = "."   ):
		_UpperCAmelCase		:       Tuple								=      ""
		for filepath in sorted(good_file_paths(__lowerCAmelCase   )   ):
				_UpperCAmelCase		:       List[Any]								=      os.path.split(__lowerCAmelCase   )
				if filepath != old_path:
						_UpperCAmelCase		:       Union[str, Any]								=      print_path(__lowerCAmelCase      , __lowerCAmelCase   )
				_UpperCAmelCase		:       Optional[Any]								=      (filepath.count(os.sep   ) + 1) if filepath else 0
				_UpperCAmelCase		:       Tuple								=      F"""{filepath}/{filename}""".replace(" "      , "%20"   )
				_UpperCAmelCase		:       Any								=      os.path.splitext(filename.replace("_"      , " "   ).title()   )[0]
				print(F"""{md_prefix(__lowerCAmelCase   )} [{filename}]({url})"""   )


if __name__ == "__main__":
			print_directory_md('.')







'''simple docstring'''


from typing import Optional
from urllib.parse import quote

import huggingface_hub as hfh
from packaging import version






def  __lowerCAmelCase (__lowerCAmelCase      , __lowerCAmelCase      , __lowerCAmelCase = None   ):
		if version.parse(hfh.__version__   ).release < version.parse("0.11.0"   ).release:
				# old versions of hfh don't url-encode the file path
				_UpperCAmelCase		:       str								=      quote(__lowerCAmelCase   )
		return hfh.hf_hub_url(__lowerCAmelCase      , __lowerCAmelCase      , repo_type="dataset"      , revision=__lowerCAmelCase   )



