Exemple #1
0
 def __init__(self, col: _Collection, file: str) -> None:
     NoteImporter.__init__(self, col, file)
     self.opened = False
     self.workbook = None
     self.worksheet = None
     self.tagsToAdd: List[str] = []
     self.numFields = 0
Exemple #2
0
 def __init__(self, col, table, view, api_key, app_key):
     NoteImporter.__init__(self, col, "")
     self.records = None
     self.table = table
     self.view = view
     self.api_key = api_key
     self.app_key = app_key
Exemple #3
0
 def __init__(self, col, file):
     NoteImporter.__init__(self, col, file)
     self.lines = None
     self.fileobj = None
     self.delimiter = None
     self.tagsToAdd = []
     self.numFields = 0
Exemple #4
0
 def run(self):
     model = addForwardReverse(self.col)
     model['name'] = "Pauker"
     self.col.models.save(model)
     self.col.models.setCurrent(model)
     self.model = model
     self.initMapping()
     NoteImporter.run(self)
Exemple #5
0
 def run(self):
     model = addForwardReverse(self.col)
     model['name'] = "Pauker"
     self.col.models.save(model)
     self.col.models.setCurrent(model)
     self.model = model
     self.initMapping()
     NoteImporter.run(self)
Exemple #6
0
 def run(self):
     model = addForwardReverse(self.col)
     model["name"] = "Pauker"
     self.col.models.save(model, updateReqs=False)
     self.col.models.set_current(model)
     self.model = model
     self.initMapping()
     NoteImporter.run(self)
Exemple #7
0
 def __init__(self, col: Collection, file: str) -> None:
     NoteImporter.__init__(self, col, file)
     self.lines = None
     self.fileobj: Optional[TextIO] = None
     self.delimiter: Optional[str] = None
     self.tagsToAdd: List[str] = []
     self.numFields = 0
     self.dialect: Optional[Any]
     self.data: Optional[Union[str, List[str]]]
    def __init__(self, col, file):
        NoteImporter.__init__(self, col, file)
        self.model = col.models.byName(MODEL_NAME)
        self.mappingFields = [f['name'] for f in self.model['flds']]
        self.mapping = None
        self.fileDir = os.path.dirname(file)

        did = col.decks.id(DECK_NAME)
        col.decks.select(did)
        deck = col.decks.get(did)
        deck['mid'] = self.model['id']
        col.decks.save(deck)
Exemple #9
0
    def __init__(self, col, file):
        NoteImporter.__init__(self, col, file)
        self.model = col.models.byName(MODEL_NAME)
        self.mappingFields = [f['name'] for f in self.model['flds']]
        self.mapping = None
        self.fileDir = os.path.dirname(file)

        did = col.decks.id(DECK_NAME)
        col.decks.select(did)
        deck = col.decks.get(did)
        deck['mid'] = self.model['id']
        col.decks.save(deck)
Exemple #10
0
 def initMapping(self):
     self._chooseLikelyModel()
     NoteImporter.initMapping(self)
     # let the mappings turn out in the order of the spreadsheet headers
     mapping = self.mapping[0:]
     for i in xrange(0, len(self._data.header)):
         try:
             h = self._data.header[i]
             j = mapping.index(h)
             self.mapping[i] = mapping[j]
         except ValueError:
             self.log.append("Unable to find mapping for header '%s'" % h)
             self.mapping[i] = None
Exemple #11
0
 def __init__(self, *args):
     # excerpt from TextImporter (csvfile.py)
     NoteImporter.__init__(self, *args)
     self.fileobj = None
     # preamble and postamble are saved in the following variables,
     # but they are not actually processed by the current version
     # of LatexImporter:
     self.preamble = ""
     self.postamble = ""
     # noteList will contain all ForeignNotes that have been imported:
     self.noteList = []
     # the log will be built from a list of warnings and a list
     # of text passages that have been ignored
     self.log = []
     self.rubbishList = []
     self.warningList = []
Exemple #12
0
 def __init__(self, col, file):
     NoteImporter.__init__(self, col, file)
     self.model = col.models.byName(X_MODEL_NAME)
     self.sheets = None
     self.mw = aqt.mw
     self.currentSheetImport = dict()
     self.mediaDir = os.path.join(os.path.dirname(col.path),
                                  'collection.media')
     self.srcDir = tempfile.mkdtemp()
     self.xZip = zipfile.ZipFile(file, 'r')
     self.warnings = []
     self.deckId = ''
     self.notesToAdd = dict()
     self.running = True
     self.soup = BeautifulSoup(self.xZip.read('content.xml'),
                               features='html.parser')
     self.tagList = self.soup('topic')
     self.repair = False
Exemple #13
0
    def __init__(self, *args):
        """Initialize internal varables.
        Pameters to be exposed to GUI are stored in self.META"""
        NoteImporter.__init__(self, *args)
        m = addBasicModel(self.col)
        m['name'] = "Supermemo"
        self.col.models.save(m)
        self.initMapping()

        self.lines = None
        self.numFields = int(2)

        # SmXmlParse VARIABLES
        self.xmldoc = None
        self.pieces = []
        self.cntBuf = []  # to store last parsed data
        self.cntElm = []  # to store SM Elements data
        self.cntCol = []  # to store SM Colections data

        # store some meta info related to parse algorithm
        # SmartDict works like dict / class wrapper
        self.cntMeta = SmartDict()
        self.cntMeta.popTitles = False
        self.cntMeta.title = []

        # META stores controls of import scritp, should be
        # exposed to import dialog. These are default values.
        self.META = SmartDict()
        self.META.resetLearningData = False  # implemented
        self.META.onlyMemorizedItems = False  # implemented
        self.META.loggerLevel = 2             # implemented
        # 0no,1info,2error,3debug
        self.META.tagAllTopics = True
        # path patterns to be tagged - in gui entered like 'Advanced
        # English 97|My Vocablary'
        self.META.pathsToBeTagged = ['English for begginers',  # sic
                                     'Advanced English 97',
                                     'Phrasal Verbs']
        self.META.tagMemorizedItems = True              # implemented
        self.META.logToStdOutput = False              # implemented

        self.notes = []
Exemple #14
0
    def __init__(self, col: Collection, file: str) -> None:
        """Initialize internal varables.
        Pameters to be exposed to GUI are stored in self.META"""
        NoteImporter.__init__(self, col, file)
        m = addBasicModel(self.col)
        m["name"] = "Supermemo"
        self.col.models.save(m)
        self.initMapping()

        self.lines = None
        self.numFields = int(2)

        # SmXmlParse VARIABLES
        self.xmldoc = None
        self.pieces = []
        self.cntBuf = []  # to store last parsed data
        self.cntElm = []  # to store SM Elements data
        self.cntCol = []  # to store SM Colections data

        # store some meta info related to parse algorithm
        # SmartDict works like dict / class wrapper
        self.cntMeta = SmartDict()
        self.cntMeta.popTitles = False
        self.cntMeta.title = []

        # META stores controls of import scritp, should be
        # exposed to import dialog. These are default values.
        self.META = SmartDict()
        self.META.resetLearningData = False  # implemented
        self.META.onlyMemorizedItems = False  # implemented
        self.META.loggerLevel = 2  # implemented 0no,1info,2error,3debug
        self.META.tagAllTopics = True
        self.META.pathsToBeTagged = [
            "English for begginers",
            "Advanced English 97",
            "Phrasal Verbs",
        ]  # path patterns to be tagged - in gui entered like 'Advanced English 97|My Vocablary'
        self.META.tagMemorizedItems = True  # implemented
        self.META.logToStdOutput = False  # implemented

        self.notes = []
Exemple #15
0
 def __init__(self, *args):
     NoteImporter.__init__(self, *args)
     self.fileOpen = None
 def __init__(self, col, wordlist_id):
     NoteImporter.__init__(self, col, "")
     self.records = None
     self.wordlist_id = wordlist_id
Exemple #17
0
 def __init__(self, *args):
     NoteImporter.__init__(self, *args)
     self.allowHTML = True # see NoteImporter
Exemple #18
0
 def __init__(self, *args):
     NoteImporter.__init__(self, *args)
     self._data = None
Exemple #19
0
 def __init__(self, *args):
     NoteImporter.__init__(self, *args)
     self.allowHTML = True
     self.availableIds = set()
 def __init__(self, col, file_, model_name=None, deck_name=None):
     NoteImporter.__init__(self, col, file_)
     self._setup_model(model_name, deck_name, file_)
Exemple #21
0
 def __init__(self, *args):
     NoteImporter.__init__(self, *args)
     self.lines = None
     self.fileobj = None
     self.delimiter = None
     self.tagsToAdd = []
Exemple #22
0
 def __init__(self, *args):
     NoteImporter.__init__(self, *args)
     self.lines = None
     self.fileobj = None
     self.delimiter = None
     self.tagsToAdd = []
Exemple #23
0
 def __init__(self, *args):
     NoteImporter.__init__(self, *args)
     self.allowHTML = True
     self.bDeck = None
     self.tagsToAdd = []
 def __init__(self, col, file_, model_name=None, deck_name=None):
     NoteImporter.__init__(self, col, file_)
     self._setup_model(model_name, deck_name, file_)