(self, pat: AnyStr, *, period_special: bool = True)
Arguments
		---------
		pat
			The glob pattern to use for matching
		period_special
			Whether a leading period in file/directory names should be matchable by
			``*``, ``?`` and ``[…]`` – traditionally they are not, but many modern
			shells allow one to disable this behaviour
Arguments
		---------
		pat
			The glob pattern to use for matching
		period_special
			Whether a leading period in file/directory names should be matchable by
			``*``, ``?`` and ``[…]`` – traditionally they are not, but many modern
			shells allow one to disable this behaviour
Arguments --------- pat The glob pattern to use for matching period_special Whether a leading period in file / directory names should be matchable by * ? and [ … ] – traditionally they are not but many modern shells allow one to disable this behaviour
def __init__(self, pat: AnyStr, *, period_special: bool = True):
		"""
		Arguments
		---------
		pat
			The glob pattern to use for matching
		period_special
			Whether a leading period in file/directory names should be matchable by
			``*``, ``?`` and ``[…]`` – traditionally they are not, but many modern
			shells allow one to disable this behaviour
		"""
		super().__init__(isinstance(pat, bytes))

		self.period_special = period_special

		self._sep = utils.maybe_fsencode(os.path.sep, pat)
		dblstar = utils.maybe_fsencode("**", pat)
		dot = utils.maybe_fsencode(".", pat)
		pat_ndot = utils.maybe_fsencode(r"(?![.])", pat)

		# Normalize path separator
		if os.path.altsep:
			pat = pat.replace(utils.maybe_fsencode(os.path.altsep, pat), self._sep)
		
		# Sanity checks for stuff that will definitely NOT EVER match
		# (there is another one in the loop below)
		assert not os.path.isabs(pat), "Absolute matching patterns will never match"
		
		# Note the extra final slash for its effect of only matching directories
		#
		# (TBH, I find it hard to see how that is useful, but everybody does it
		#  and it keeps things consistent overall – something to only match files
		#  would be nice however.)
		self._dir_only = pat.endswith(self._sep)

		self._pat = []
		for label in pat.split(self._sep):
			# Skip over useless path components
			if len(label) < 1 or label == dot:
				continue
			
			assert label != dot + dot, 'Matching patterns containing ".." will never match'
			
			if label == dblstar:
				self._pat.append(None)
			elif dblstar in label:
				raise NotImplementedError(
					"Using double-star (**) and other characters in the same glob "
					"path label ({0}) is not currently supported – please do file "
					"an issue if you need this!".format(os.fsdecode(label))
				)
			else:
				if not isinstance(label, bytes):
					re_expr = fnmatch.translate(label)
				else:
					re_expr = fnmatch.translate(label.decode("latin-1")).encode("latin-1")
				
				if period_special and not label.startswith(dot):
					re_expr = pat_ndot + re_expr
				self._pat.append(re.compile(re_expr))
def __init__ ( self , pat : AnyStr , * , period_special : bool = True ) : super ( ) . __init__ ( isinstance ( pat , bytes ) ) self . period_special = period_special self . _sep = utils . maybe_fsencode ( os . path . sep , pat ) dblstar = utils . maybe_fsencode ( "**" , pat ) dot = utils . maybe_fsencode ( "." , pat ) pat_ndot = utils . maybe_fsencode ( r"(?![.])" , pat ) # Normalize path separator if os . path . altsep : pat = pat . replace ( utils . maybe_fsencode ( os . path . altsep , pat ) , self . _sep ) # Sanity checks for stuff that will definitely NOT EVER match # (there is another one in the loop below) assert not os . path . isabs ( pat ) , "Absolute matching patterns will never match" # Note the extra final slash for its effect of only matching directories # # (TBH, I find it hard to see how that is useful, but everybody does it #  and it keeps things consistent overall – something to only match files #  would be nice however.) self . _dir_only = pat . endswith ( self . _sep ) self . _pat = [ ] for label in pat . split ( self . _sep ) : # Skip over useless path components if len ( label ) < 1 or label == dot : continue assert label != dot + dot , 'Matching patterns containing ".." will never match' if label == dblstar : self . _pat . append ( None ) elif dblstar in label : raise NotImplementedError ( "Using double-star (**) and other characters in the same glob " "path label ({0}) is not currently supported – please do file " "an issue if you need this!" . format ( os . fsdecode ( label ) ) ) else : if not isinstance ( label , bytes ) : re_expr = fnmatch . translate ( label ) else : re_expr = fnmatch . translate ( label . decode ( "latin-1" ) ) . encode ( "latin-1" ) if period_special and not label . startswith ( dot ) : re_expr = pat_ndot + re_expr self . _pat . append ( re . compile ( re_expr ) )