ConDict

Check-in [f7cdee11f4]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:optimize add-function
Timelines: family | ancestors | descendants | both | testing
Files: files | file ages | folders
SHA1:f7cdee11f4300f7076a21665ce95e4f8206f7e6e
User & Date: alzay 2012-10-05 09:08:36
Context
2012-10-12
12:21
default command = en-ru translate check-in: 53a4d2e45c user: alzay tags: testing
2012-10-05
09:08
optimize add-function check-in: f7cdee11f4 user: alzay tags: testing
2012-10-04
18:04
offline translate check-in: d015fb4871 user: zorro tags: testing
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to condt.py.

314
315
316
317
318
319
320









321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
            print(result_text.format(*result_param))
        except (sqlite3.DatabaseError, IncorrectDbData) as er:
            print('Sorry, error')
            return 'list'
        cur.close()
        return 'list'
    









    def command_add(self, en_words=None):
        """add new user pattern"""
        cur = self.connect.cursor()
        print('Please enter your patterns:')
        while True:
            try:
                en = input('En [' + en_words + ']:') if en_words else input('En: ')
                if not en:
                    if not en_words:
                        raise IncorrectDbData()
                    else:
                        en = en_words
                # check en translate
                if self.alreadyex(en): raise DublicationDbData
                # get translate
                try:
                    ru_words = self.command_enru(en, 'en')[0]
                except Exception as e:
                    if DEBUG: print(e)
                    ru_words = None
                ru = input('Ru [' + ru_words + ']:') if ru_words else input('Ru: ')
                if not ru:
                    if not ru_words:
                        raise IncorrectDbData()
                    else:
                        ru = ru_words
                ru = ru.lower().strip()
                en = en.lower().strip()
                with self.connect:
                    translate_id = self.command_add_kinds(cur, en, ru)
            except DublicationDbData:
                print('Words already contained in database. For search use ".list {0}"'.format(en))
                break
            except (sqlite3.DatabaseError, IncorrectDbData) as er:
                self.prer(er)







>
>
>
>
>
>
>
>
>






|
<
<
<
<
<








|
<
<
<
<
<
<
<







314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336





337
338
339
340
341
342
343
344
345







346
347
348
349
350
351
352
            print(result_text.format(*result_param))
        except (sqlite3.DatabaseError, IncorrectDbData) as er:
            print('Sorry, error')
            return 'list'
        cur.close()
        return 'list'
    
    def check_default(self, defaultVar, addStr=''):
        result = input(addStr + ' [' + defaultVar + ']:') if defaultVar else input(addStr +': ')
        if not result:
            if not defaultVar:
                raise IncorrectDbData()
            else:
                result = defaultVar
        return prepare_str(result)

    def command_add(self, en_words=None):
        """add new user pattern"""
        cur = self.connect.cursor()
        print('Please enter your patterns:')
        while True:
            try:
                en = self.check_default(en_words, 'En')





                # check en translate
                if self.alreadyex(en): raise DublicationDbData
                # get translate
                try:
                    ru_words = self.command_enru(en, 'en')[0]
                except Exception as e:
                    if DEBUG: print(e)
                    ru_words = None
                ru = self.check_default(ru_words, 'Ru')







                with self.connect:
                    translate_id = self.command_add_kinds(cur, en, ru)
            except DublicationDbData:
                print('Words already contained in database. For search use ".list {0}"'.format(en))
                break
            except (sqlite3.DatabaseError, IncorrectDbData) as er:
                self.prer(er)

Changes to db.sqlite.

cannot compute difference between binary files