mercurial/utils/resourceutil.py
changeset 44029 bba9149adc14
parent 44028 42a897bf678c
child 44152 a90039b07343
equal deleted inserted replaced
44028:42a897bf678c 44029:bba9149adc14
    53     def is_resource(package, name):
    53     def is_resource(package, name):
    54         return resources.is_resource(
    54         return resources.is_resource(
    55             pycompat.sysstr(package), encoding.strfromlocal(name)
    55             pycompat.sysstr(package), encoding.strfromlocal(name)
    56         )
    56         )
    57 
    57 
       
    58     def contents(package):
       
    59         for r in resources.contents(pycompat.sysstr(package)):
       
    60             yield encoding.strtolocal(r)
       
    61 
    58 
    62 
    59 except (ImportError, AttributeError):
    63 except (ImportError, AttributeError):
    60 
    64 
    61     def _package_path(package):
    65     def _package_path(package):
    62         return os.path.join(_rootpath, *package.split(b'.'))
    66         return os.path.join(_rootpath, *package.split(b'.'))
    70 
    74 
    71         try:
    75         try:
    72             return os.path.isfile(pycompat.fsdecode(path))
    76             return os.path.isfile(pycompat.fsdecode(path))
    73         except (IOError, OSError):
    77         except (IOError, OSError):
    74             return False
    78             return False
       
    79 
       
    80     def contents(package):
       
    81         path = pycompat.fsdecode(_package_path(package))
       
    82 
       
    83         for p in os.listdir(path):
       
    84             yield pycompat.fsencode(p)