class_docstr: A ZipFile subclass that ensures that implied directories
  are always included in the namelist.
  
  >>> list(CompleteDirs._implied_dirs(['foo/bar.txt', 'foo/bar/baz.txt']))
  ['foo/', 'foo/bar/']
  >>> list(CompleteDirs._implied_dirs(['foo/bar.txt', 'foo/bar/baz.txt', 'foo/bar/']))
  ['foo/']
class_docstr_tok: ["A","ZipFile","subclass","that","ensures","that","implied","directories","are","always","included","in","the","namelist",".",">",">",">","list","(","CompleteDirs._implied_dirs","(","[","'foo\/bar.txt","'",",","'foo\/bar\/baz.txt","'","]",")",")","[","'foo\/","'",",","'foo\/bar\/","'","]",">",">",">","list","(","CompleteDirs._implied_dirs","(","[","'foo\/bar.txt","'",",","'foo\/bar\/baz.txt","'",",","'foo\/bar\/","'","]",")",")","[","'foo\/","'","]"]
docstr: Given a source (filename or zipfile), return an
  appropriate CompleteDirs subclass.
docstr_tok: ["Given","a","source","(","filename","or","zipfile",")",",","return","an","appropriate","CompleteDirs","subclass","."]
code: def make(cls, source):
      """
      Given a source (filename or zipfile), return an
      appropriate CompleteDirs subclass.
      """
      if isinstance(source, CompleteDirs):
          return source
  
      if not isinstance(source, zipfile.ZipFile):
          return cls(source)
  
      # Only allow for FastLookup when supplied zipfile is read-only
      if "r" not in source.mode:
          cls = CompleteDirs
  
      source.__class__ = cls
      return source
  
imports: import io
  import posixpath
  import zipfile
  import itertools
  import contextlib
  import pathlib
  import re
  from .glob import translate
label_desc: Use image node_id 6 for calling the CompleteDirs obj's underlying member method code with example usage: obj.make(cls, source) and returns: source, source, cls