示例#1
0
def impXPF(url):
    xml_handle = urlopen(url)
    fname = "-".join(sys.argv[1].split("/")) + ".xpf"
    file_contents = xml_handle.read()
    save_file = open("/home/bbundy/puzzles/nyt/" + fname,"w")
    save_file.write(file_contents)
    save_file.close()
    try:
        PuzzleType.objects.get(type="Cryptic")
    except ObjectDoesNotExist:
        t = PuzzleType(type="Cryptic")
        t.save()
        t = PuzzleType(type="US")
        t.save()

    try:
        UserType.objects.get(type="Setter")
    except ObjectDoesNotExist:
        t = UserType(type="Setter")
        t.save()
        t = UserType(type="Editor")
        t.save()
        t = UserType(type="Publisher")
        t.save()
        t = UserType(type="Solver")
        t.save()

    p = xwcore.Puzzle.fromXML(file_contents)

    try:
        setter = User.objects.get(username=p.author)
    except Exception, e:
        setter = User(username=p.author, puzzle_pref=PuzzleType.objects.get(type='US'), user_type=UserType.objects.get(type='Setter'), joined=date.today())
        setter.save()
示例#2
0
def impPUZdata(file_contents, publisher):
    pz = puz.load(file_contents)
    p = xwcore.Puzzle.fromPUZ(pz)
    if publisher:
        p.publisher = publisher
    try:
        setter = User.objects.get(username=p.author)
    except Exception, e:
        setter = User(username=p.author, puzzle_pref=PuzzleType.objects.get(type='US'), user_type=UserType.objects.get(type='Setter'), joined=date.today())
        setter.save()
示例#3
0
def impPUZdata(file_contents, publisher):
    pz = puz.load(file_contents)
    p = xwcore.Puzzle.fromPUZ(pz)
    if publisher:
        p.publisher = publisher
    try:
        setter = User.objects.get(username=p.author)
    except Exception, e:
        setter = User(username=p.author, puzzle_pref=PuzzleType.objects.get(type='US'), user_type=UserType.objects.get(type='Setter'), joined=date.today())
        setter.save()

    try:
        publisher = User.objects.get(username=p.publisher)
    except Exception, e:
        publisher = User(username=p.publisher, puzzle_pref=PuzzleType.objects.get(type='US'), user_type=UserType.objects.get(type='Publisher'), joined=date.today())
        publisher.save()

    if hasattr(p, "editor"):
        try:
            editor = User.objects.get(username=p.editor)
        except Exception, e:
            editor = User(username=p.editor, puzzle_pref=PuzzleType.objects.get(type='US'), user_type=UserType.objects.get(type='Editor'), joined=date.today())
            editor.save()
    else:
        editor = setter

    if hasattr(p, "date"):
        (m, d, y) = p.date.split('/')
        pdate = date(int(y),int(m),int(d))
    else:
示例#4
0
        answers["%d-down" % num] = down_answers[num]

    num = sys.argv[1].split('/')[-1]
    title = "Guardian %s" % num
    p = xwcore.Puzzle.fromDicts(author, title, across_answers, down_answers, across_pos, down_pos, across_clues, down_clues)
    pz = p.toPUZ()
    s = pz.tostring()
    pf = open("/var/www/xw/upload/%s.puz" % num, "w")
    pf.write(s)
    pf.close()
    p.publisher = "Guardian"

    try:
        setter = User.objects.get(username=p.author)
    except Exception, e:
        setter = User(username=p.author, puzzle_pref=PuzzleType.objects.get(type='Cryptic'), user_type=UserType.objects.get(type='Setter'), joined=date.today())
        setter.save()

    try:
        publisher = User.objects.get(username=p.publisher)
    except Exception, e:
        publisher = User(username=p.publisher, puzzle_pref=PuzzleType.objects.get(type='Cryptic'), user_type=UserType.objects.get(type='Publisher'), joined=date.today())
        publisher.save()

    editor = setter

    pdate = date(int(year),int(month),int(day))
    ptype = PuzzleType.objects.get(type="Cryptic")

    try:
        grid = Grid.objects.get(format=p.dbgridstr)