コード例 #1
0
def fwGlobPath(fw, Path):
    Groups = []
    Projects = []
    Subjects = []
    Sesions = []

    Segments = Path.split('/')
    Containers = {}

    if (len(Segments) >= 0):
        Groups = [
            Group for Group in fw.groups()
            if (globre.match(Segments[0], Group.id))
        ]
        for Group in Groups:
            Containers[Group.id] = Group

    CurrentPath = []
    if (len(Segments) > 1):
        Projects = {}
        for GroupPath, Group in Containers.items():
            for Project in Group.projects():
                if (globre.match(Segments[1], Project.label)):
                    Projects['/'.join([GroupPath, Project.label])] = Project

        Containers = Projects

    if (len(Segments) > 2):
        Subjects = {}
        for ProjectPath, Project in Containers.items():
            for Subject in Project.subjects():
                if (globre.match(Segments[2], Subject.label)):
                    Subjects['/'.join([ProjectPath, Subject.label])] = Subject

        Containers = Subjects

    if (len(Segments) > 3):
        Sessions = {}
        for SubjectPath, Subject in Containers.items():
            for Session in Subject.sessions():
                if (globre.match(Segments[3], Session.label)):
                    Sessions['/'.join([SubjectPath, Session.label])] = Session

        Containers = Sessions

    if (len(Segments) > 4):
        Acquisitions = {}
        for SessionPath, Session in Containers.items():
            for Acquisition in Session.acquisitions():
                if (globre.match(Segments[3], Session.label)):
                    Acquisitions['/'.join([SessionPath,
                                           Acquisition.label])] = Acquisition

        Containers = Acquisitions

    return (Containers)
コード例 #2
0
 def match_pattern(self,collection , context):
     for pattern in collection:
         if globre.match(pattern, context):
             log.debug(
                 "Matched pattern {pattern} in path {path}".format(
                     pattern=pattern, path=context)
             )
             return True
     return False
コード例 #3
0
ファイル: test.py プロジェクト: dsuch/globre-lgpl
 def test_match(self):
   self.assertIsNotNone(globre.match('/foo/bar/**.ini', '/foo/bar/conf.ini'))
   self.assertIsNotNone(globre.match('/foo/bar/**.ini', '/foo/bar/a/b/c/conf.ini'))
   self.assertIsNone(globre.match('/foo/bar/**.ini', '/a/foo/bar/conf.ini'))
   self.assertIsNone(globre.match('/foo/bar/**.ini', '/foo/bar/conf.ini.txt'))
   self.assertIsNone(globre.match('/foo/bar/**.ini', '/foo/bar/conf.ini/zig.txt'))
   self.assertIsNone(globre.match('/foo/bar/**.ini', '/FOO/BAR/ZIP/CONF.INI'))
   self.assertIsNotNone(globre.match('/foo/bar/**.ini', '/FOO/BAR/ZIP/CONF.INI', flags=re.IGNORECASE))
コード例 #4
0
def get_project_by_pattern(project_name):
    """Find YouTrack project name by GitLab project name."""
    if _projects is None:
        read_projects()

    for pattern in _projects:
        if globre.match(pattern, project_name):
            return _projects[pattern]

    raise ValueError('Project name does not match any pattern!')
コード例 #5
0
 def is_excluded(self, node):
     '''
     returns True if the node should be excluded 
     '''
     if self.excludes is not None:
         for exclude in self.excludes:
             if globre.match(exclude, node.root_path):
                 log.debug("Matched exclude path [%s] to node [%s]",
                           exclude, node.root_path)
                 return True
     return False
コード例 #6
0
 def is_included(self, node):
     '''
     returns True if the node should be included
     '''
     if self.includes is not None:
         for include in self.includes:
             if globre.match(include, node.root_path):
                 log.debug("Matched include path [%s] to node [%s]",
                           include, node.root_path)
                 return True
     else:
         return True
コード例 #7
0
ファイル: test.py プロジェクト: metagriffin/globre
 def test_sep_alternate(self):
   self.assertIsNotNone(globre.match('/foo/**.ini', '/foo/bar/conf.ini', sep='/'))
   self.assertIsNotNone(globre.match('\\\\foo\\\\**.ini', '\\foo\\bar\\conf.ini', sep='\\'))
   self.assertIsNotNone(globre.match(':foo:**.ini', ':foo:bar:conf.ini', sep=':'))
   self.assertIsNone(globre.match('/foo/*.ini', '/foo/bar/conf.ini', sep='/'))
   self.assertIsNone(globre.match('\\\\foo\\\\*.ini', '\\foo\\bar\\conf.ini', sep='\\'))
   self.assertIsNone(globre.match(':foo:*.ini', ':foo:bar:conf.ini', sep=':'))
コード例 #8
0
ファイル: test.py プロジェクト: metagriffin/globre
 def test_sep_default(self):
   self.assertIsNotNone(globre.match('/foo/**.ini', '/foo/bar/conf.ini'))
   self.assertIsNone(globre.match('/foo/**.ini', '\\foo\\bar\\conf.ini'))
   self.assertIsNotNone(globre.match(':foo:**.ini', ':foo:bar:conf.ini'))
   self.assertIsNone(globre.match('/foo/*.ini', '/foo/bar/conf.ini'))
   self.assertIsNone(globre.match('/foo/*.ini', '\\foo\\bar\\conf.ini'))
   self.assertIsNotNone(globre.match(':foo:*.ini', ':foo:bar:conf.ini'))
コード例 #9
0
ファイル: test.py プロジェクト: pauln23/osint9
 def test_sep_default(self):
     self.assertIsNotNone(globre.match('/foo/**.ini', '/foo/bar/conf.ini'))
     self.assertIsNone(globre.match('/foo/**.ini', '\\foo\\bar\\conf.ini'))
     self.assertIsNotNone(globre.match(':foo:**.ini', ':foo:bar:conf.ini'))
     self.assertIsNone(globre.match('/foo/*.ini', '/foo/bar/conf.ini'))
     self.assertIsNone(globre.match('/foo/*.ini', '\\foo\\bar\\conf.ini'))
     self.assertIsNotNone(globre.match(':foo:*.ini', ':foo:bar:conf.ini'))
コード例 #10
0
 def is_excluded(self, node):
     '''
     returns True if the node should be excluded 
     if the are no exclude patterns then nothing is excluded
     any exclude pattern matching the root path will result in exclusion
     '''
     if self.excludes is not None:
         for exclude in self.excludes:
             if globre.match(exclude, node.root_path):
                 log.debug("Matched exclude path [%s] to node [%s]",
                           exclude, node.root_path)
                 return True
     return False
コード例 #11
0
 def is_included(self, node):
     '''
     returns True if the node should be included.
     if there are no include patterns then everything is included
     any include patterns matching the root path will result in inclusion
     '''
     if self.includes is not None:
         for include in self.includes:
             if globre.match(include, node.root_path):
                 log.debug("Matched include path [%s] to node [%s]",
                           include, node.root_path)
                 return True
     else:
         return True
コード例 #12
0
ファイル: test.py プロジェクト: jayvdb/globre
 def test_match(self):
     self.assertIsNotNone(
         globre.match('/foo/bar/**.ini', '/foo/bar/conf.ini'))
     self.assertIsNotNone(
         globre.match('/foo/bar/**.ini', '/foo/bar/a/b/c/conf.ini'))
     self.assertIsNone(
         globre.match('/foo/bar/**.ini', '/a/foo/bar/conf.ini'))
     self.assertIsNone(
         globre.match('/foo/bar/**.ini', '/foo/bar/conf.ini.txt'))
     self.assertIsNone(
         globre.match('/foo/bar/**.ini', '/foo/bar/conf.ini/zig.txt'))
     self.assertIsNone(
         globre.match('/foo/bar/**.ini', '/FOO/BAR/ZIP/CONF.INI'))
     self.assertIsNotNone(
         globre.match('/foo/bar/**.ini',
                      '/FOO/BAR/ZIP/CONF.INI',
                      flags=re.IGNORECASE))
コード例 #13
0
ファイル: test.py プロジェクト: pauln23/osint9
 def test_sep_alternate(self):
     self.assertIsNotNone(
         globre.match('/foo/**.ini', '/foo/bar/conf.ini', sep='/'))
     self.assertIsNotNone(
         globre.match('\\\\foo\\\\**.ini', '\\foo\\bar\\conf.ini',
                      sep='\\'))
     self.assertIsNotNone(
         globre.match(':foo:**.ini', ':foo:bar:conf.ini', sep=':'))
     self.assertIsNone(
         globre.match('/foo/*.ini', '/foo/bar/conf.ini', sep='/'))
     self.assertIsNone(
         globre.match('\\\\foo\\\\*.ini', '\\foo\\bar\\conf.ini', sep='\\'))
     self.assertIsNone(
         globre.match(':foo:*.ini', ':foo:bar:conf.ini', sep=':'))
コード例 #14
0
ファイル: test.py プロジェクト: metagriffin/globre
 def test_sep_multi(self):
   self.assertIsNotNone(globre.match('/foo/**.ini', '/foo/bar/conf.ini', sep='/\\'))
   self.assertIsNotNone(globre.match('/foo/**.ini', '\\foo\\bar\\conf.ini', sep='/\\'))
   self.assertIsNotNone(globre.match('/foo/**.ini', '/foo\\bar/conf.ini', sep='/\\'))
   self.assertIsNotNone(globre.match('\\\\foo\\\\**.ini', '\\foo\\bar\\conf.ini', sep='/\\'))
   self.assertIsNotNone(globre.match('\\\\foo\\\\**.ini', '/foo/bar/conf.ini', sep='/\\'))
   self.assertIsNotNone(globre.match('\\\\foo/**.ini', '\\foo\\bar\\conf.ini', sep='/\\'))
   self.assertIsNotNone(globre.match('\\\\foo/**.ini', '/foo\\bar/conf.ini', sep='/\\'))
   self.assertIsNone(globre.match('/foo/*.ini', '/foo/bar/conf.ini', sep='/\\'))
   self.assertIsNone(globre.match('/foo/*.ini', '\\foo\\bar\\conf.ini', sep='/\\'))
   self.assertIsNone(globre.match('/foo/*.ini', '/foo\\bar/conf.ini', sep='/\\'))
   self.assertIsNone(globre.match('\\\\foo\\\\*.ini', '\\foo\\bar\\conf.ini', sep='/\\'))
   self.assertIsNone(globre.match('\\\\foo\\\\*.ini', '/foo/bar/conf.ini', sep='/\\'))
   self.assertIsNone(globre.match('\\\\foo/*.ini', '\\foo\\bar\\conf.ini', sep='/\\'))
   self.assertIsNone(globre.match('\\\\foo/*.ini', '/foo\\bar/conf.ini', sep='/\\'))
コード例 #15
0
ファイル: test.py プロジェクト: pauln23/osint9
 def test_sep_multi(self):
     self.assertIsNotNone(
         globre.match('/foo/**.ini', '/foo/bar/conf.ini', sep='/\\'))
     self.assertIsNotNone(
         globre.match('/foo/**.ini', '\\foo\\bar\\conf.ini', sep='/\\'))
     self.assertIsNotNone(
         globre.match('/foo/**.ini', '/foo\\bar/conf.ini', sep='/\\'))
     self.assertIsNotNone(
         globre.match('\\\\foo\\\\**.ini',
                      '\\foo\\bar\\conf.ini',
                      sep='/\\'))
     self.assertIsNotNone(
         globre.match('\\\\foo\\\\**.ini', '/foo/bar/conf.ini', sep='/\\'))
     self.assertIsNotNone(
         globre.match('\\\\foo/**.ini', '\\foo\\bar\\conf.ini', sep='/\\'))
     self.assertIsNotNone(
         globre.match('\\\\foo/**.ini', '/foo\\bar/conf.ini', sep='/\\'))
     self.assertIsNone(
         globre.match('/foo/*.ini', '/foo/bar/conf.ini', sep='/\\'))
     self.assertIsNone(
         globre.match('/foo/*.ini', '\\foo\\bar\\conf.ini', sep='/\\'))
     self.assertIsNone(
         globre.match('/foo/*.ini', '/foo\\bar/conf.ini', sep='/\\'))
     self.assertIsNone(
         globre.match('\\\\foo\\\\*.ini', '\\foo\\bar\\conf.ini',
                      sep='/\\'))
     self.assertIsNone(
         globre.match('\\\\foo\\\\*.ini', '/foo/bar/conf.ini', sep='/\\'))
     self.assertIsNone(
         globre.match('\\\\foo/*.ini', '\\foo\\bar\\conf.ini', sep='/\\'))
     self.assertIsNone(
         globre.match('\\\\foo/*.ini', '/foo\\bar/conf.ini', sep='/\\'))