Example #1
0
        def test_samefile(self):
            f = open(support.TESTFN + "1", "wb")
            try:
                f.write(b"foo")
                f.close()
                self.assertIs(
                    genericpath.samefile(support.TESTFN + "1",
                                         support.TESTFN + "1"), True)
                # If we don't have links, assume that os.stat doesn't return resonable
                # inode information and thus, that samefile() doesn't work
                if hasattr(os, "symlink"):
                    os.symlink(support.TESTFN + "1", support.TESTFN + "2")
                    self.assertIs(
                        genericpath.samefile(support.TESTFN + "1",
                                             support.TESTFN + "2"), True)
                    os.remove(support.TESTFN + "2")
                    f = open(support.TESTFN + "2", "wb")
                    f.write(b"bar")
                    f.close()
                    self.assertIs(
                        genericpath.samefile(support.TESTFN + "1",
                                             support.TESTFN + "2"), False)
            finally:
                if not f.close():
                    f.close()
                try:
                    os.remove(support.TESTFN + "1")
                except os.error:
                    pass
                try:
                    os.remove(support.TESTFN + "2")
                except os.error:
                    pass

            self.assertRaises(TypeError, genericpath.samefile)
        def test_samefile(self):
            f = open(support.TESTFN + "1", "wb")
            try:
                f.write(b"foo")
                f.close()
                self.assertIs(
                    genericpath.samefile(
                        support.TESTFN + "1",
                        support.TESTFN + "1"
                    ),
                    True
                )
                # If we don't have links, assume that os.stat doesn't return resonable
                # inode information and thus, that samefile() doesn't work
                if hasattr(os, "symlink"):
                    os.symlink(
                        support.TESTFN + "1",
                        support.TESTFN + "2"
                    )
                    self.assertIs(
                        genericpath.samefile(
                            support.TESTFN + "1",
                            support.TESTFN + "2"
                        ),
                        True
                    )
                    os.remove(support.TESTFN + "2")
                    f = open(support.TESTFN + "2", "wb")
                    f.write(b"bar")
                    f.close()
                    self.assertIs(
                        genericpath.samefile(
                            support.TESTFN + "1",
                            support.TESTFN + "2"
                        ),
                        False
                    )
            finally:
                if not f.close():
                    f.close()
                try:
                    os.remove(support.TESTFN + "1")
                except os.error:
                    pass
                try:
                    os.remove(support.TESTFN + "2")
                except os.error:
                    pass

            self.assertRaises(TypeError, genericpath.samefile)
Example #3
0
    def __init__(self, args):
        msm = MycroftSkillsManager()
        skill_matches = [
            skill for skill in msm.list()
            if skill.is_local and samefile(skill.path, args.skill_folder)
        ]
        if not skill_matches:
            raise NotUploaded(
                'Skill at folder not uploaded to store: {}'.format(
                    args.skill_folder))

        self.skill = SkillData(skill_matches[0])
Example #4
0
 def update_event(self, inp=-1):
     self.set_output_val(0,
                         genericpath.samefile(self.input(0), self.input(1)))