parameters: (paths: List[Path], verbose: bool = False, source_encoding: str = None)
return_statement: return count
docstring: Rename filepaths to their punyencoded names
docstring_summary: Rename filepaths to their punyencoded names
docstring_tokens: Rename filepaths to their punyencoded names
function: def punyencode_paths(paths: List[Path], verbose: bool = False, source_encoding: str = None) -> int:
      """Rename filepaths to their punyencoded names"""
      count = 0
      for path in paths:
          if source_encoding is not None:
              new_name = punyencode(demojibake_hfs_bytestring(bytes(path.name, "utf8"), source_encoding))
          else:
              new_name = punyencode(path.name)
          if path.stem != new_name:
              count += 1
              new_path = path.parent / new_name
              if verbose:
                  print(f"Renamed {path} to {new_path}")
              path.rename(new_path)
      return count
function_tokens: def punyencode_paths ( paths : List [ Path ] , verbose : bool = False , source_encoding : str = None ) -> int : count = 0 for path in paths : if source_encoding is not None : new_name = punyencode ( demojibake_hfs_bytestring ( bytes ( path . name , "utf8" ) , source_encoding ) ) else : new_name = punyencode ( path . name ) if path . stem != new_name : count += 1 new_path = path . parent / new_name if verbose : print ( f"Renamed {path} to {new_path}" ) path . rename ( new_path ) return count