# Path: gitcms/redirect/models.py
# class Redirect(models.Model):
#     source = models.CharField(u'source', max_length=255)
#     target = models.CharField(u'target', max_length=255)
#     def __unicode__(self):
#         return 'Redirect[ %s ==> %s ]' % (self.source, self.target)


import yaml
import os
from .models import Redirect

def loaddir(directory, clear=False):
    if clear:
       Redirect.objects.all().delete()
    for redfile in os.listdir(directory):
        if redfile[0] == '.': continue
        for redirect in yaml.load_all(file(directory + '/' + redfile)):

# Path: gitcms/redirect/models.py
# class Redirect(models.Model):
#     source = models.CharField(u'source', max_length=255)
#     target = models.CharField(u'target', max_length=255)
#     def __unicode__(self):
#         return 'Redirect[ %s ==> %s ]' % (self.source, self.target)


# Path: gitcms/redirect/load.py
import yaml
import os
from .models import Redirect


def loaddir(directory, clear=False):
    if clear:
       Redirect.objects.all().delete()
    for redfile in os.listdir(directory):
        if redfile[0] == '.': continue
        for redirect in yaml.load_all(file(directory + '/' + redfile)):

            R = Redirect(**redirect)