Пример #1
0
 def lint(self):
     ""  # suppress inherited doc
     # Ensure that the interface layer used is valid.
     impl = self.interface.directory / self.role + '.py'
     if not impl.exists():
         log.error('Missing implementation for interface role: %s.py',
                   self.role)
         return False
     valid = True
     ignorer = utils.ignore_matcher(self.config.ignores +
                                    self.interface.config.ignores +
                                    self.config.excludes +
                                    self.interface.config.excludes)
     for entry, _ in utils.walk(self.interface.directory,
                                lambda x: True,
                                matcher=ignorer,
                                kind="files"):
         if entry.splitext()[1] != ".py":
             continue
         relpath = entry.relpath(self._target.directory)
         target = self._target.directory / relpath
         if not target.exists():
             continue
         unchanged = utils.delta_python_dump(entry,
                                             target,
                                             from_name=relpath)
         if not unchanged:
             valid = False
     return valid
Пример #2
0
 def lint(self):
     ""  # suppress inherited doc
     # Ensure that the interface layer used is valid.
     impl = self.interface.directory / self.role + '.py'
     if not impl.exists():
         log.error('Missing implementation for interface role: %s.py',
                   self.role)
         return False
     valid = True
     ignorer = utils.ignore_matcher(self.config.ignores +
                                    self.interface.config.ignores)
     for entry, _ in utils.walk(self.interface.directory,
                                lambda x: True,
                                matcher=ignorer,
                                kind="files"):
         if entry.splitext()[1] != ".py":
             continue
         relpath = entry.relpath(self._target.directory)
         target = self._target.directory / relpath
         if not target.exists():
             continue
         unchanged = utils.delta_python_dump(entry, target,
                                             from_name=relpath)
         if not unchanged:
             valid = False
     return valid
Пример #3
0
 def lint(self):
     for entry in self.interface.directory.walkfiles():
         if entry.splitext()[1] != ".py":
             continue
         relpath = entry.relpath(self._target.directory)
         target = self._target.directory / relpath
         if not target.exists():
             continue
         return utils.delta_python_dump(entry, target, from_name=relpath)
Пример #4
0
 def lint(self):
     for entry in self.interface.directory.walkfiles():
         if entry.splitext()[1] != ".py":
             continue
         relpath = entry.relpath(self._target.directory)
         target = self._target.directory / relpath
         if not target.exists():
             continue
         return utils.delta_python_dump(entry, target, from_name=relpath)
Пример #5
0
 def lint(self):
     impl = self.interface.directory / self.role + '.py'
     if not impl.exists():
         log.error('Missing implementation for interface role: %s.py', self.role)
         return False
     valid = True
     for entry in self.interface.directory.walkfiles():
         if entry.splitext()[1] != ".py":
             continue
         relpath = entry.relpath(self._target.directory)
         target = self._target.directory / relpath
         if not target.exists():
             continue
         unchanged = utils.delta_python_dump(entry, target,
                                             from_name=relpath)
         if not unchanged:
             valid = False
     return valid
Пример #6
0
 def lint(self):
     impl = self.interface.directory / self.role + '.py'
     if not impl.exists():
         log.error('Missing implementation for interface role: %s.py',
                   self.role)
         return False
     valid = True
     for entry in self.interface.directory.walkfiles():
         if entry.splitext()[1] != ".py":
             continue
         relpath = entry.relpath(self._target.directory)
         target = self._target.directory / relpath
         if not target.exists():
             continue
         unchanged = utils.delta_python_dump(entry, target,
                                             from_name=relpath)
         if not unchanged:
             valid = False
     return valid
Пример #7
0
    def test_delta_python(self):
        a = StringIO("""
        def foo(n):
            return n * 2


        @when('db.ready')
        def react(db):
            print(db)
        """)

        b = StringIO("""
        def foo(n):
            return n * 2


        @when('db.ready', 'bar')
        def react(db):
            print(db)
        """)

        result = StringIO()
        t = utils.TermWriter(fp=result)
        rc = utils.delta_python_dump(a,
                                     b,
                                     utils.REACTIVE_PATTERNS,
                                     context=3,
                                     term=t,
                                     from_name="Alpha",
                                     to_name="Beta")
        # return code here indicates that there was a diff
        self.assertFalse(rc)
        result.seek(0)
        output = result.read()
        self.assertIn("Alpha", output)
        self.assertIn("Beta", output)
        self.assertIn("@when('db.ready'", output)
        self.assertIn("bar", output)
Пример #8
0
    def test_delta_python(self):
        a = StringIO("""
        def foo(n):
            return n * 2


        @when('db.ready')
        def react(db):
            print(db)
        """)

        b = StringIO("""
        def foo(n):
            return n * 2


        @when('db.ready', 'bar')
        def react(db):
            print(db)
        """)

        result = StringIO()
        t = utils.TermWriter(fp=result)
        rc = utils.delta_python_dump(a, b, utils.REACTIVE_PATTERNS,
                                     context=3,
                                     term=t,
                                     from_name="Alpha",
                                     to_name="Beta")
        # return code here indicates that there was a diff
        self.assertFalse(rc)
        result.seek(0)
        output = result.read()
        self.assertIn("Alpha", output)
        self.assertIn("Beta", output)
        self.assertIn("@when('db.ready'", output)
        self.assertIn("bar", output)