def __init__(self, model=None):
     self.model = model
     self.id = genID()
     if model:
         for fm in model.fieldModels:
             self.fields.append(Field(fm))
     self.new = True
예제 #2
0
 def copy(self):
     new = FieldModel()
     for p in class_mapper(FieldModel).iterate_properties:
         setattr(new, p.key, getattr(self, p.key))
     new.id = genID()
     new.model = None
     return new
예제 #3
0
파일: facts.py 프로젝트: ACEfanatic02/anki
 def __init__(self, model=None):
     self.model = model
     self.id = genID()
     if model:
         for fm in model.fieldModels:
             self.fields.append(Field(fm))
     self.new = True
def updateMediaCount(deck, file, count=1):
    mdir = deck.mediaDir()
    if deck.s.scalar(
        "select 1 from media where filename = :file", file=file):
        deck.s.statement(
            "update media set size = size + :c, created = :t where filename = :file",
            file=file, c=count, t=time.time())
    elif count > 0:
        try:
            sum = str(
                checksum(open(os.path.join(mdir, file), "rb").read()))
        except:
            sum = ""
        deck.s.statement("""
insert into media (id, filename, size, created, originalPath, description)
values (:id, :file, :c, :mod, :sum, '')""",
                         id=genID(), file=file, c=count, mod=time.time(),
                         sum=sum)
예제 #5
0
파일: media.py 프로젝트: ACEfanatic02/anki
def updateMediaCount(deck, file, count=1):
    mdir = deck.mediaDir()
    if deck.s.scalar(
        "select 1 from media where filename = :file", file=file):
        deck.s.statement(
            "update media set size = size + :c, created = :t where filename = :file",
            file=file, c=count, t=time.time())
    elif count > 0:
        try:
            sum = unicode(
                checksum(open(os.path.join(mdir, file), "rb").read()))
        except:
            sum = u""
        deck.s.statement("""
insert into media (id, filename, size, created, originalPath, description)
values (:id, :file, :c, :mod, :sum, '')""",
                         id=genID(), file=file, c=count, mod=time.time(),
                         sum=sum)
예제 #6
0
파일: cards.py 프로젝트: AgarwalPragy/anki
 def __init__(self, fact=None, cardModel=None, created=None):
     self.tags = u""
     self.id = genID()
     # new cards start as new & due
     self.type = 2
     self.relativeDelay = self.type
     self.timerStarted = False
     self.timerStopped = False
     self.modified = time.time()
     if created:
         self.created = created
         self.due = created
     else:
         self.due = self.modified
     self.combinedDue = self.due
     if fact:
         self.fact = fact
     if cardModel:
         self.cardModel = cardModel
         # for non-orm use
         self.cardModelId = cardModel.id
         self.ordinal = cardModel.ordinal
 def __init__(self, fact=None, cardModel=None, created=None):
     self.tags = ""
     self.id = genID()
     # new cards start as new & due
     self.type = 2
     self.relativeDelay = self.type
     self.timerStarted = False
     self.timerStopped = False
     self.modified = time.time()
     if created:
         self.created = created
         self.due = created
     else:
         self.due = self.modified
     self.combinedDue = self.due
     if fact:
         self.fact = fact
     if cardModel:
         self.cardModel = cardModel
         # for non-orm use
         self.cardModelId = cardModel.id
         self.ordinal = cardModel.ordinal
 def __init__(self, fieldModel=None):
     if fieldModel:
         self.fieldModel = fieldModel
         self.ordinal = fieldModel.ordinal
     self.value = ""
     self.id = genID()
예제 #9
0
파일: facts.py 프로젝트: ACEfanatic02/anki
 def __init__(self, fieldModel=None):
     if fieldModel:
         self.fieldModel = fieldModel
         self.ordinal = fieldModel.ordinal
     self.value = u""
     self.id = genID()
예제 #10
0
 def __init__(self, name=u"", required=True, unique=True):
     self.name = name
     self.required = required
     self.unique = unique
     self.id = genID()
예제 #11
0
 def __init__(self, name=u""):
     self.name = name
     self.id = genID()
예제 #12
0
 def __init__(self, name=u"", qformat=u"q", aformat=u"a", active=True):
     self.name = name
     self.qformat = qformat
     self.aformat = aformat
     self.active = active
     self.id = genID()