Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
p = cls.globjoin(cls.tempdir, p)
else:
p = cls.tempdir
res = glob.glob(p, **kwargs)
print("RESULTS: ", res)
if res:
cls.assert_equal({type(r) for r in res}, {str})
cls.assert_count_equal(glob.iglob(p, **kwargs), res)
if 'root_dir' in kwargs and kwargs['root_dir'] is not None:
kwargs['root_dir'] = os.fsencode(kwargs['root_dir'])
bres = [os.fsencode(x) for x in res]
cls.assert_count_equal(glob.glob(os.fsencode(p), **kwargs), bres)
cls.assert_count_equal(glob.iglob(os.fsencode(p), **kwargs), bres)
if bres:
cls.assert_equal({type(r) for r in bres}, {bytes})
return res
self.assertEqual([filepath], glob.glob(filepath.replace('\\', '\\\\'), flags=glob.C))
self.assertEqual(
[self.RE_DRIVE.sub(lambda m: m.group(0).upper(), filepath)],
glob.glob(self.RE_DRIVE.sub(lambda m: m.group(0).upper(), filepath).replace('\\', '\\\\'), flags=glob.C)
)
self.assertEqual(
[self.RE_DRIVE.sub(lambda m: m.group(0).lower(), filepath)],
glob.glob(self.RE_DRIVE.sub(lambda m: m.group(0).lower(), filepath).replace('\\', '\\\\'), flags=glob.C)
)
@skip_unless_symlink
class TestSymlinkLoopGlob(unittest.TestCase):
"""Symlink loop test case."""
DEFAULT_FLAGS = glob.BRACE | glob.EXTGLOB | glob.GLOBSTAR | glob.FOLLOW
def globjoin(self, *parts):
"""Joins glob path."""
sep = os.fsencode(self.globsep) if isinstance(parts[0], bytes) else self.globsep
return sep.join(list(parts))
def setUp(self):
"""Setup."""
if os.sep == '/':
self.globsep = os.sep
else:
self.globsep = r'\\'
def test_selflink(self):
def setUp(self):
"""Setup."""
self.tempdir = TESTFN + "_dir"
self.default_flags = glob.G | glob.P
def setup_class(cls):
"""Setup default flag options."""
# The tests we scraped were written with this assumed.
cls.flags = glob.NEGATE | glob.GLOBSTAR | glob.EXTGLOB | glob.BRACE
Options(default_negate='sym3/EF'),
[
('**', 'EF'),
[
] if not can_symlink() else [
],
glob.N | glob.L
],
[
('**', 'EF'),
[
] if not can_symlink() else [
],
glob.N
],
Options(default_negate='**'),
# Disable symlinks
[
('a*', '**'),
[
('EF',), ('ZZZ',), ('',)
] if not can_symlink() else [
('EF',), ('ZZZ',), ('',), ('sym1',), ('sym2',)
],
glob.N | glob.L
],
Options(cwd_temp=True, absolute=True),
['!(.)', ['abc'], glob.M],
[r'!(\.)', ['abc'], glob.M],
[r'!(\x2e)', ['abc'], glob.M | glob.R],
['@(!(.))', ['abc'], glob.M],
['!(@(.))', ['abc'], glob.M],
['+(!(.))', ['abc'], glob.M],
['!(+(.))', ['abc'], glob.M],
['!(?)', ['abc'], glob.M],
['!(*)', [], glob.M],
['!([.])', ['abc'], glob.M],
['!(.)', ['..', '.abc', 'abc'], glob.M | glob.D],
[r'!(\.)', ['..', '.abc', 'abc'], glob.M | glob.D],
[r'!(\x2e)', ['..', '.abc', 'abc'], glob.M | glob.R | glob.D],
['@(!(.))', ['..', '.abc', 'abc'], glob.M | glob.D],
['!(@(.))', ['..', '.abc', 'abc'], glob.M | glob.D],
['+(!(.))', ['..', '.abc', 'abc'], glob.M | glob.D],
['+(!(.))', ['.abc', 'abc'], glob.M | glob.D | glob.Z],
['!(+(.))', ['.abc', 'abc'], glob.M | glob.D],
['!(?)', ['.abc', 'abc'], glob.M | glob.D],
['!(*)', [], glob.M | glob.D],
['!([.])', ['.abc', 'abc'], glob.M | glob.D],
['@(..|.)', ['.', '..']],
['@(..|.)', ['.', '..'], glob.Z],
# More extended pattern dot related tests
['*(.)', ['.', '..']],
[r'*(\.)', ['.', '..']],
['*([.])', []],
['*(?)', ['abc']],
['@(.?)', ['..']],
['@(?.)', []],
['*(.)', ['.', '..'], glob.D],
def setUp(self):
"""Setup."""
self.tempdir = TESTFN + "_dir"
self.mktemp('.hidden', 'a.txt')
self.mktemp('.hidden', 'b.file')
self.mktemp('.hidden_file')
self.mktemp('a.txt')
self.mktemp('b.file')
self.mktemp('c.txt.bak')
self.can_symlink = can_symlink()
if self.can_symlink:
self.mksymlink('.hidden', self.norm('sym1'))
self.mksymlink(os.path.join('.hidden', 'a.txt'), self.norm('sym2'))
self.default_flags = glob.G | glob.P | glob.B
try:
import mkdocs # noqa
import pymdownx # noqa
except ImportError:
print(
'========================================================================================\n'
'gen_docs requires mkdocs and pymdown-extensions to be installed properly.\n'
'You can install requirements with the command `pip install -r requirements/docs.txt`.\n'
'Please reslove the issues and try again.\n'
'========================================================================================\n'
)
raise
__version__ = '2.0.0'
FLAGS = glob.G | glob.N | glob.B | glob.S
FILES_PATTERNS = [
'mkdocs-internal.yml',
'docs/src/markdown/**/*.{md,txt,png,gif,html}',
'docs/internal_theme/**/*.{html,css,js}'
]
MKDOCS_CFG = "mkdocs-internal.yml"
MKDOCS_BUILD = "rummage/lib/gui/data/docs"
def console(cmd, input_file=None):
"""Call with arguments."""
returncode = None
output = None
I = IGNORECASE = glob.IGNORECASE
R = RAWCHARS = glob.RAWCHARS
D = DOTGLOB = DOTMATCH = glob.DOTMATCH
E = EXTGLOB = EXTMATCH = glob.EXTMATCH
G = GLOBSTAR = _wcparse.GLOBSTAR
N = NEGATE = glob.NEGATE
B = BRACE = glob.BRACE
M = MINUSNEGATE = glob.MINUSNEGATE
P = REALPATH = glob.REALPATH
L = FOLLOW = glob.FOLLOW
S = SPLIT = glob.SPLIT
X = MATCHBASE = glob.MATCHBASE
O = NODIR = glob.NODIR
A = NEGATEALL = glob.NEGATEALL
Q = NOUNIQUE = glob.NOUNIQUE
Z = NODOTDIR = glob.NODOTDIR
SD = SCANDOTDIR = glob.SCANDOTDIR
# Internal flags
_EXTMATCHBASE = _wcparse._EXTMATCHBASE
_RTL = _wcparse._RTL
_NOABSOLUTE = _wcparse._NOABSOLUTE
_PATHNAME = _wcparse.PATHNAME
_FORCEWIN = _wcparse.FORCEWIN
_FORCEUNIX = _wcparse.FORCEUNIX
_PATHLIB = glob._PATHLIB
FLAG_MASK = (
CASE |
IGNORECASE |