Exemple #1
0
 def handle(self, *args, **options):
     """Iterate throw the list to create the snippets."""
     if args:
         s = Snippet(title=args[0])
         if options["header"]:
             s.header = options["header"].read()
         #            else:
         #                with open('farinha/header.txt', 'r') as f:
         #                    s.header = f.read()
         if options["body"]:
             s.body = options["body"].read()
         #            else:
         #                with open('farinha/body.txt', 'r') as f:
         #                    s.body = f.read()
         if options["footer"]:
             s.footer = options["footer"].read()
         #            else:
         #                with open('farinha/footer.txt', 'r') as f:
         #                    s.footer = f.read()
         s.save()
     else:
         self.stdout.write(
             "You need to provide at least the snippet's \
             title."
         )
Exemple #2
0
    def handle(self, *args, **options):
        """Iterate throw the list to create the snippets."""
        if args:
            s = Snippet(title=args[0])
            if options['header']:
                s.header = options['header'].read()
#            else:
#                with open('farinha/header.txt', 'r') as f:
#                    s.header = f.read()
            if options['body']:
                s.body = options['body'].read()
#            else:
#                with open('farinha/body.txt', 'r') as f:
#                    s.body = f.read()
            if options['footer']:
                s.footer = options['footer'].read()
#            else:
#                with open('farinha/footer.txt', 'r') as f:
#                    s.footer = f.read()
            s.save()
        else:
            self.stdout.write("You need to provide at least the snippet's \
                title.")
Exemple #3
0
 def test_empty_snippet(self):
     s = Snippet()
     s.save()
     self.assertEqual(str(s), "")
Exemple #4
0
 def test_footer_snippet(self):
     s = Snippet(footer="testing")
     s.save()
     self.assertEqual(str(s.footer), "testing")
Exemple #5
0
 def test_body_snippet(self):
     s = Snippet(body="testing")
     s.save()
     self.assertEqual(str(s.body), "testing")
Exemple #6
0
 def test_header_snippet(self):
     s = Snippet(header="testing")
     s.save()
     self.assertEqual(str(s.header), "testing")
Exemple #7
0
 def test_alias_snippet(self):
     s = Snippet(alias="testing")
     s.save()
     self.assertEqual(str(s.alias), "testing")
Exemple #8
0
 def test_title_snippet(self):
     s = Snippet(title="testing")
     s.save()
     self.assertEqual(str(s), "testing")
Exemple #9
0
 def test_empty_snippet(self):
     s = Snippet()
     s.save()
     self.assertEqual(str(s), "")
Exemple #10
0
 def test_footer_snippet(self):
     s = Snippet(footer="testing")
     s.save()
     self.assertEqual(str(s.footer), "testing")
Exemple #11
0
 def test_body_snippet(self):
     s = Snippet(body="testing")
     s.save()
     self.assertEqual(str(s.body), "testing")
Exemple #12
0
 def test_header_snippet(self):
     s = Snippet(header="testing")
     s.save()
     self.assertEqual(str(s.header), "testing")
Exemple #13
0
 def test_alias_snippet(self):
     s = Snippet(alias="testing")
     s.save()
     self.assertEqual(str(s.alias), "testing")
Exemple #14
0
 def test_title_snippet(self):
     s = Snippet(title="testing")
     s.save()
     self.assertEqual(str(s), "testing")