public void DotsShouldBeLiterals() { Glob glob = new Glob("*.cs"); Assert.IsTrue(glob.IsMatch("someFile.cs")); Assert.IsFalse(glob.IsMatch("notmatchedcs")); }
public void DollarSignsAndCaretsAreLiterals() { Glob glob = new Glob("abc$def^*"); Assert.IsTrue(glob.IsMatch("abc$def^")); Assert.IsTrue(glob.IsMatch("abc$def^Stuff")); Assert.IsFalse(glob.IsMatch("abc$")); }
public void ShouldMatchWithTrailingWildcard() { Glob glob = new Glob("MyClass*"); Assert.IsTrue(glob.IsMatch("MyClass")); Assert.IsTrue(glob.IsMatch("MyClassAndMore2")); Assert.IsFalse(glob.IsMatch("ReallyMyClass")); }
public void CanMatchSingleFileWithAnyNameOrExtension() { var glob = new Glob("folder/*.*"); Assert.True(glob.IsMatch("folder/bigfile.txt")); Assert.True(glob.IsMatch("folder/smallfile.txt")); Assert.True(glob.IsMatch("folder/smallfile.txt.min")); }
public void ShouldMatchExactlyWhenNoWildcards() { Glob glob = new Glob("MyClass"); Assert.IsTrue(glob.IsMatch("MyClass")); Assert.IsFalse(glob.IsMatch("MyClass2")); Assert.IsFalse(glob.IsMatch("ReallyMyClass")); }
public void ShouldMatchWithLeadingWildcard() { Glob glob = new Glob("*Class"); Assert.IsTrue(glob.IsMatch("MyClass")); Assert.IsTrue(glob.IsMatch("My.other.Class")); Assert.IsFalse(glob.IsMatch("MyClassAndMore2")); }
public void CanMatchSingleFileOnExtension() { var glob = new Glob("folder/*.txt"); Assert.True(glob.IsMatch("folder/bigfile.txt")); Assert.True(glob.IsMatch("folder/smallfile.txt")); Assert.False(glob.IsMatch("folder/smallfile.txt.min")); }
public void BracketsShouldMatchSingleCharacters() { Glob glob = new Glob("Test[0-9][0-9]"); Assert.IsTrue(glob.IsMatch("Test01")); Assert.IsTrue(glob.IsMatch("Test54")); Assert.IsFalse(glob.IsMatch("Test200")); }
public void CanMatchSingleFileUsingNumberRange() { var glob = new Glob("*file[1-9].txt"); Assert.True(glob.IsMatch("bigfile1.txt")); Assert.True(glob.IsMatch("smallfile8.txt")); Assert.False(glob.IsMatch("smallfile0.txt")); Assert.False(glob.IsMatch("smallfilea.txt")); }
public void CanMatchSingleFileUsingCharRange() { var glob = new Glob("*fil[e-z].txt"); Assert.True(glob.IsMatch("bigfile.txt")); Assert.True(glob.IsMatch("smallfilf.txt")); Assert.False(glob.IsMatch("smallfila.txt")); Assert.False(glob.IsMatch("smallfilez.txt")); }
public void CanMatchSingleFileUsingCharList() { var glob = new Glob("*file[abc].txt"); Assert.True(glob.IsMatch("bigfilea.txt")); Assert.True(glob.IsMatch("smallfileb.txt")); Assert.False(glob.IsMatch("smallfiled.txt")); Assert.False(glob.IsMatch("smallfileaa.txt")); }
public void QuestionMarksShouldMatchSingleCharacters() { Glob glob = new Glob("one??two"); Assert.IsTrue(glob.IsMatch("one00two")); Assert.IsTrue(glob.IsMatch("oneWEtwo")); Assert.IsFalse(glob.IsMatch("oneTooManytwo")); Assert.IsTrue(glob.IsMatch("one??two")); }
public Inputs(IEnumerable<string> filesOrStandardInput) { var fileNames = new Glob(Environment.CurrentDirectory); filesOrStandardInput.Except(Input.IsStandardInput).Each(fileNames.Include); inputs = fileNames.Select(f => new Input(f)).ToList(); if (filesOrStandardInput.Any(Input.IsStandardInput) || inputs.Count == 0) inputs.Insert(0, Input.FromStandardInput()); }
public void CanCompareInstances() { var glob = new Glob(FileSystem) { Pattern = "abc" }; Assert.False(glob.Equals(4711)); Assert.True(glob.Equals(new Glob() { Pattern = "abc" })); }
public void CanLog() { var log = ""; var glob = new Glob(new GlobOptions { IgnoreCase = true, ErrorLog = s => log += s }, new TestFileSystem()) { Pattern = @"test" }; var fs = glob.ExpandNames().ToList(); Assert.False(string.IsNullOrEmpty(log)); }
public void Can_Generate_Matches(string pattern, int volume) { // var generatedStrings = new List<string>(testStrings); var glob = Glob.Parse(pattern); var sut = new GlobMatchStringGenerator(glob.Tokens); for (int i = 0; i < volume; i++) { var generatedString = sut.GenerateRandomMatch(); var result = glob.IsMatch(generatedString); Assert.True(result, string.Format("{0} did not match pattern {1}", generatedString, pattern)); } }
/// <summary> /// Finds the files matching the specified globs. /// </summary> /// <param name="directory">The starting directory.</param> /// <param name="globs">The globs to match.</param> /// <returns>The paths of the matching files.</returns> public static IReadOnlyList <string> FindFilesFrom(string directory, params string[] globs) { if (directory == null) { throw new ArgumentNullException(nameof(directory)); } if (globs == null) { throw new ArgumentNullException(nameof(globs)); } return(globs.SelectMany(glob => Glob.Files(directory, glob, GlobOptions.CaseInsensitive)).Distinct().Select(path => Path.Combine(directory, path)).ToList()); }
public void MatchingRangeIgnoreCase(string pattern, char[] matchingChars) { for (int i = 0; i < 255; i++) { var c = (char)i; bool shouldMatch = Array.IndexOf(matchingChars, c) >= 0; Assert.True(shouldMatch == Glob.IsMatch(pattern, c.ToString(), ignoreCase: true, matchWildCardWithDirectorySeparator: false), $"character: '{(i != 0 ? c.ToString() : "\\0")}' (0x{i:X2})"); Assert.True(shouldMatch == Glob.IsMatch(pattern, c.ToString(), ignoreCase: true, matchWildCardWithDirectorySeparator: true), $"character: '{(i != 0 ? c.ToString() : "\\0")}' (0x{i:X2})"); } }
public void Main(string args) { Argument Arg = getArgument(args); if (Arg != null) { Glob Filter = new Glob(Arg.glob); Echo(Arg.glob + " => " + Filter.Rgx.ToString()); List <IMyTerminalBlock> Group = getBlockGroup(Arg); List <IMyTerminalBlock> Blocks = findBlocksByGlob(Group, Filter); replaceNamesInBlocklist(Blocks, Filter, Arg); } }
public IEnumerable <string> EnumerateFileSystemEntries(string directoryName, string pattern, SearchOption searchOption) { Glob g = Glob.Parse(searchOption != SearchOption.AllDirectories ? "**/" + pattern : pattern); foreach (string entry in _files.Keys.Union(_directories).Where(x => x.StartsWith(directoryName, StringComparison.Ordinal) || x.StartsWith(directoryName, StringComparison.Ordinal) && (x[directoryName.Length] == Path.DirectorySeparatorChar || x[directoryName.Length] == Path.AltDirectorySeparatorChar))) { string p = entry.Replace('\\', '/').TrimStart('/'); if (g.IsMatch(p)) { yield return(entry); } } }
public FileWatcherConfiguration(string watchPath, string destinationPath, string[] excludedPathsGlob) { this.watchPath = watchPath.Trim(); this.destinationPath = destinationPath.Trim(); this.excludedPathsGlob = new Glob[excludedPathsGlob.Length]; for (int i = 0; i < excludedPathsGlob.Length; ++i) { GlobOptions options = new GlobOptions(); options.Evaluation.CaseInsensitive = true; this.excludedPathsGlob[i] = Glob.Parse(excludedPathsGlob[i], options); } }
private IDependencyRule CreateIndependentOfProjectRule(Pattern dependingNamePattern, Glob dependencyNamePattern, string dependencyType) { var ruleDescription = IndependentRuleMetadata.FormatIndependentRule(dependingNamePattern, dependencyType, dependencyNamePattern); return(new IndependentRule( new JoinedDescribedCondition(new IsFollowingAssemblyCondition(), new HasAssemblyNameMatchingPatternCondition( dependencyNamePattern), ruleDescription), dependingNamePattern, _ruleViolationFactory)); }
public static bool ShouldMutateProject(Project project, Config config) { if (config.ProjectFilters == null || !config.ProjectFilters.Any()) { return(true); } var relativePath = RelativeFilePath(project.FilePath, config); return(config.ProjectFilters .Any(f => Glob.Parse(f).IsMatch(project.Name) || Glob.Parse(f).IsMatch(relativePath))); }
static void Main(string[] args) { bool show_help = false; bool watch = false; bool force = false; bool commit = false; var options = new OptionSet() { { "o|output=", "specify output Directory", v => output = v }, { "c|commit", "commit ocr-version", v => commit = true }, { "w|watch", "watch directory", v => watch = true }, { "f|force", "force generation of ocr file", v => force = true }, { "h|help", "orccore file1 [file2 ...file-n]", v => show_help = v != null } }; var pathes = options.Parse(args); if (show_help) { options.WriteOptionDescriptions(Console.Out); System.Environment.Exit(0); } if (watch) { Watcher watcher = new Watcher(pathes[0], output); watcher.Start(); Console.ReadLine(); watcher.Stop(); } else { foreach (var p in pathes) { var globber = new Glob(); var files = globber.ExpandNames(p); OcrService scanner = new OcrService(output); foreach (var f in files) { if (commit) { scanner.Commit(f); } else { scanner.Scan(f, force); } } } } }
private static IEnumerable <string> ExpandGlobPatterns(IEnumerable <string> globPatterns) { var glob = new Glob(); var fileNames = new List <string>(); foreach (var pattern in globPatterns) { var paths = glob.Expand(pattern); fileNames.AddRange(paths.Select(path => path.FullName)); } return(fileNames); }
private void updateListView() { List <AssortedProductModelModel> assortedProductModelList = Glob.GetAssortedProductModelList(); lvwProductFacture.Items.Clear(); assortedProductModelList.ForEach(it => { var productCode = it.ProductCode; var productName = it.ProductName; var facturerCode = it.FacturerCode; var facturerName = it.FacturerName; ListViewItem lvi = new ListViewItem(new string[] { productName, facturerName, productCode, facturerCode }); lvwProductFacture.Items.Add(lvi); }); }
public static Type GetDrawable(ImportNamespaceInfo import, string localName) { lock (_lock) { if (!_loadedTypes.TryGetValue(import.AssemblyName, out var typeDict)) { typeDict = _loadedTypes[import.AssemblyName] = Assembly .Load(import.AssemblyName) .GetExportedTypes() .Where(t => t.IsClass && t.IsSubclassOf(typeof(Drawable))) .ToArray(); } var pattern = Glob.Parse(import.ImportPattern); var matchingTypes = typeDict .Where(t => pattern.IsMatch(t.FullName) && localName.Equals(t.Name)) .ToArray(); if (matchingTypes.Length == 1) { var matchingType = matchingTypes[0]; // Ensure type is not abstract if (matchingType.IsAbstract) { throw new MarkupException($"Drawable '{matchingType}' is abstract and cannot be used."); } // Ensure type can be created if (!matchingType.GetConstructors().Any(c => c.GetParameters().All(p => p.IsOptional))) { throw new MarkupException($"Drawable '{matchingType}' does not have a suitable constructor."); } return(matchingType); } if (matchingTypes.Length == 0) { throw new KeyNotFoundException($"Type '{localName}' could not be found in assembly '{import.AssemblyName}'."); } throw new AmbiguousMatchException( $"Drawable '{localName}' is ambiguous between the following types: " + string.Join(", ", matchingTypes.Select(t => t.FullName)) ); } }
public void SetupData() { _testMatchingStringsList = new List <string>(NumberOfMatches); //_testNonMatchingStringsList = new List<string>(NumberOfMatches); _glob = Glob.Parse(GlobPattern); var generator = new GlobMatchStringGenerator(_glob.Tokens); for (int i = 0; i < 1000; i++) { var matchString = generator.GenerateRandomMatch(); _testMatchingStringsList.Add(matchString); //_testNonMatchingStringsList.Add(generator.GenerateRandomNonMatch()); } }
/// <summary> /// Checks whether subject matches a list of glob patterns. /// </summary> /// <param name="items"></param> /// <param name="subject"></param> /// <returns></returns> public static bool MatchesAny(this IEnumerable <string> items, string subject) { foreach (var pattern in items) { var glob = Glob.Parse(pattern); if (glob.IsMatch(subject)) { return(true); } } return(false); }
public static IEnumerable <ScenarioItem> Default() { yield return(new ScenarioItem { Glob = Glob.Parse("*.cs"), Input = new[] { @"program.cs", @"program.txt" }, Output = new[] { @"program.cs" } }); yield return(new ScenarioItem { Glob = Glob.Parse("**.cs"), Input = new[] { @"program.cs", @"program.txt", @"properties\assembly.cs", @"properties\assembly.info" }, Output = new[] { @"program.cs", @"properties\assembly.cs" } }); yield return(new ScenarioItem { Glob = Glob.Parse("program.*"), Input = new[] { @"program.cs", @"program.txt", @"properties\assembly.cs", @"properties\assembly.info" }, Output = new[] { @"program.cs", @"program.txt" } }); }
public void FilterDirectory_enumerate_root_directory_child_by_name() { var e = Fixture1Enumerator(); string[] results = Glob.FilterDirectory(Glob.Parse("a/*.txt"), "/", e.FileExists, e).ToArray(); Assert.Equal(new [] { "/a/b.txt", "/a/d.txt", }, results, FileNameComparison); }
public void FilterDirectory_enumerate_files_by_extension() { var e = Fixture1Enumerator(); string[] results = Glob.FilterDirectory(Glob.Parse("**/*.csv"), "/", e.FileExists, e).ToArray(); Assert.Equal(new [] { "/a/c.csv", "/a/e/l.csv", }, results, FileNameComparison); }
public void FilterDirectory_enumerate_by_wildcard_recursive_similar_names() { var e = Fixture2Enumerator(); // Should exclude the ~a dire string[] results = Glob.FilterDirectory(Glob.Parse("src/**/a/*.txt"), "/", e.FileExists, e).ToArray(); Assert.Equal(new [] { "/src/a/bon.txt", "/src/a/bot.txt", }, results, FileNameComparison); }
public IEnumerable <ContentItem> GetContentItems(string version, string type, string pattern) { var glob = Glob.Parse(pattern); if (_contentItems.TryGetValue(version, out var versionCollection)) { if (versionCollection.TryGetValue(type, out var typeCollection)) { return(typeCollection.Where(t => glob.IsMatch(t.File.Path))); } } return(Enumerable.Empty <ContentItem>()); }
private int OnExecute() { // var project = new Project(); // project.groups = new List<ProjectGroup>(); // project.groups.Add(new ProjectGroup() { name = "Render", }) if (!File.Exists(manifest)) { Console.WriteLine($"Could not find manifest file [{manifest}]."); return(-1); } using (var fs = File.OpenRead(manifest)) { var dir = Path.GetDirectoryName(manifest); var m = Utf8Json.JsonSerializer.Deserialize <Manifest>(fs); foreach (var g in m.groups) { if (Path.IsPathRooted(g.path) || g.path.Contains("..")) { Console.WriteLine("Path must be relative and a subdirectory."); return(-1); } Console.WriteLine(g.name); var workingDir = Path.Combine(dir, g.path); foreach (var file in Glob.Files(workingDir, "*.json", GlobOptions.CaseInsensitive)) { if (ProcessFile(m, g, Path.Combine(workingDir, file)) != 0) { return(-1); } Console.WriteLine(" " + file); } } } // foreach (var file in Glob.Files(workingDir, search, GlobOptions.CaseInsensitive)) // { // if (ProcessFile(file) != 0) // return -1; // //WriteLine(file); // } return(0); }
public void replaceNamesInBlocklist(List <IMyTerminalBlock> Blocks, Glob Filter, Argument Arg) { Dictionary <string, int> BlockCounter = new Dictionary <string, int>(); for (int i = 0; i < Blocks.Count; i++) { string typeIdString = Blocks[i].BlockDefinition.TypeIdString; if (!BlockCounter.ContainsKey(typeIdString)) { BlockCounter.Add(typeIdString, 0); } BlockCounter[typeIdString] = BlockCounter[typeIdString] + 1; replaceBlockname(Blocks[i], Filter, Arg, BlockCounter[typeIdString]); } }
public override void DoAction() { //TODO: Mine for a relic //Change to a different number for more chance. int outcome = UnityEngine.Random.Range(0, 100); if (outcome < Glob.ChanceToMineRelic) { Material[] relicMaterials = Glob.GetRelicsMaterials(); _particleSystemRenderer.material = relicMaterials[UnityEngine.Random.Range(0, relicMaterials.Length - 1)]; _particle.Play(); this.GetCity().AddRelic(); } }
public void FilterDirectory_enumerate_literal_directory() { var e = Fixture1Enumerator(); var glob = Glob.Parse("a/e/**/*.txt"); string[] results = Glob.FilterDirectory(Glob.Parse("a/e/**/*.txt"), "/", e.FileExists, e).ToArray(); Assert.Equal(new [] { "/a/e/f/g/h.txt", "/a/e/f/g/i.txt", }, results, FileNameComparison); }
private void launchMissile(CustomTile pTarget) { Missile missile = Instantiate(Glob.GetMissile()); missile.WaitWithAnimation(4); missile.SetMissileTile(pTarget); City targetCity = pTarget.GetCity(); Destroy(pTarget.GetBuildingOnTile().gameObject); Debug.Log("Destroyed the building"); pTarget.SetBuilding(null); SetCurrentMode(CurrentMode.SELECTINGTILE); _isFocusedOnOwnCity = true; }
private static void RunIsMatchTest(string pattern, string samplePath, bool shouldBe = true) { var result = Glob.IsMatch(samplePath, pattern); var failureMsg = $"'{pattern}' {(shouldBe ? "SHOULD OF MATCHED" : "SHOULD NOT OF MATCHED")} '{samplePath}'"; if (shouldBe == true) { result.ShouldBeTrue(failureMsg); } else { result.ShouldBeFalse(failureMsg); } System.Diagnostics.Debug.WriteLine($"\n{string.Concat(Enumerable.Repeat('-', 50))}\n"); }
public IEnumerable <string> FindFiles(string pattern) { //pattern = pattern.TrimStart('/'); //var files = Enumerable.Empty<string>(); Glob glob = Glob.Parse(pattern, new GlobOptions { Evaluation = new EvaluationOptions { CaseInsensitive = true } }); var matches = Files.Keys.Where(x => glob.IsMatch(x)); return(matches); }
public bool IsMarkedToExport(string objective, ITimetableInput timetableInput) { var whitelist = GetWhitelist(timetableInput); foreach (var pattern in whitelist) { var glob = Glob.Parse(pattern); if (glob.IsMatch(objective)) { return(true); } } return(false); }
private static bool ShouldMutateAccordingToFilters(Document document, Config config) { if (config.SourceFileFilters == null || !config.SourceFileFilters.Any()) { return(true); } var relativePath = RelativeFilePath(document.FilePath, config); var matchesAnyFilter = config.SourceFileFilters .Any(f => Glob.Parse(f).IsMatch(relativePath)); return(matchesAnyFilter); }
private IEnumerable<string> GetRegexForGlobPattern(string pattern) { var glob = new Glob(pattern, GlobOptions.Compiled); return filenames.Where(filename => glob.IsMatch(filename)); }
public void CanParseSimpleFilename() { var glob = new Glob("*.txt"); Assert.True(glob.IsMatch("file.txt")); Assert.False(glob.IsMatch("file.zip")); Assert.True(glob.IsMatch(@"c:\windows\file.txt")); }
public void CanParseDots() { var glob = new Glob("/some/dir/folder/foo.*"); Assert.True(glob.IsMatch("/some/dir/folder/foo.txt")); Assert.True(glob.IsMatch("/some/dir/folder/foo.csv")); }
public void ShouldMatchWithCaseInsensitiveFlag() { Glob glob = new Glob("MyClass", false); Assert.IsTrue(glob.IsMatch("myclass")); }
public SimpleAgent(Point clp, Glob _g) : this(clp) { g = _g; }
public void Glob(Glob _g) { g = _g; }
public SimpleAgent(Point clp, Point p, Glob _g, Color c) : this(clp, p, _g) { Col(c); }
public FoodTickerAgent(Point clp, Glob _g) : this(clp) { g = _g; }
public void ShouldBeCaseSensitiveByDefault() { Glob glob = new Glob("MyClass"); Assert.IsFalse(glob.IsMatch("myclass")); }
public FoodTickerAgent(Point clp, Point p, Glob _g, Color c) : this(clp, p, _g) { Col(c); }
public void ShouldMatchNothingWithEmptyPattern() { Glob glob = new Glob(string.Empty); Assert.IsFalse(glob.IsMatch("a")); }
public SimpleAgent(Point clp, Point p, Glob _g) : this(clp, _g) { Pos(p); }
public void CanMatchSingleFile() { var glob = new Glob("*file.txt"); Assert.True(glob.IsMatch("bigfile.txt")); Assert.True(glob.IsMatch("smallfile.txt")); }
public FoodTickerAgent(Point clp, Point p, Glob _g) : this(clp, _g) { Pos(p); }
public Benchmarks() { this._compiled = new Glob(Pattern, GlobOptions.Compiled); this._uncompiled = new Glob(Pattern); }