Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Patch minor issues for fresh installs #7

Merged
merged 11 commits into from
Feb 7, 2024

Conversation

Mamdasn
Copy link
Contributor

@Mamdasn Mamdasn commented Feb 6, 2024

  • Rename diaryfiledir to diaryFileDir to make the diary path consistent across all files
  • Use database_connection to replace the repetitive use of get_connection in dbmanager: Reduce the risk of leaving sqlite connections open unintentionally & properly communicating with sqlite
  • Fetch versioning in setup.py directly from makenote/__init__.py instead of importing the makenote package.
  • Since cur.fetchone() or metadata_encoded in migrations.py can potentially return None, they should be checked if they are not None before inferring them at index 0.
  • Abide by PEP 8:
    • remove unused variables, f-strings and packages,
    • comparison to bool should be done using is

When the package is being installed, especially for the first time, importing the __version__ from the `makenote` package can result in `PackageNotFoundError`. So it's better to not dynamically fetch versions using import.
+ Since `cur.fetchone()` or `metadata_encoded` can potentially return None, they should be checked if they are not `None` before inferring them at index 0.
+ Use 'WHERE' instead of 'LIMIT', since 'LIMIT' clause is not valid for UPDATE syntax.
+ Use `database_connection` to replace the repetitive use of `get_connection`: Reduce the risk of leaving connections open unintentionally
+ Comparison to `bool` should be done using `is`
+ Abide by PEP 8: remove unused variables, f-strings, unused packages
+ Comparison to `bool` should be done using `is`
+ Abide by PEP 8: f-strings, unused packages
-> Rename `diaryfiledir`  to `diaryFileDir` to make the diary path consistent across all files
@Mamdasn Mamdasn changed the title Patch minor issues with new installs Patch minor issues for fresh installs Feb 6, 2024
@ekm507
Copy link
Owner

ekm507 commented Feb 7, 2024

سلام.
برای درخواست ادغام سپاسگزارم.

ekm507

This comment was marked as outdated.

@Mamdasn
Copy link
Contributor Author

Mamdasn commented Feb 7, 2024

ممنون از جواب زود هنگامتان.
منظور شما از parser داخل کد پایتون چیست؟
کدام قسمت کد مد نظر شماست؟

@ekm507
Copy link
Owner

ekm507 commented Feb 7, 2024

گمان می‌کردم دیدگاه رو پاک کرده‌ام :))

منظور شما از parser داخل کد پایتون چیست؟ کدام قسمت کد مد نظر شماست؟

منظورم بخش گرفتن ورژن بود. این برای گرفتن متغیر __version__ کد پایتون رو بررسی کرده‌ای و دنبال علامت مساوی گشته‌ای.

همان‌طور که گفتم می‌خواستم این دیدگاه رو پاک کنم.

@ekm507
Copy link
Owner

ekm507 commented Feb 7, 2024

خب بررسی کردم. تغییرات عالی بودند.

فقط چند نکته:
۱. تابع sql_to_csv در فایل dbmanager هنوز ناقص است. print که در انتهایش گذاشته‌ای نباید باشه چون ربطی به کار این تابع نداره. لطفاً اون رو بردار. باید بالای اسم تابع یک کامنت TODO می‌گذاشتم.

۲. در بخش migrations چک می‌کنی که فایل دیتابیس خالی نباشه. این خیلی خوبه و مانع کرش کردن می‌شه. فقط یک نکته. در صورتی که فایل دیتابیس خالی باشه یک پیام خطا چاپ می‌کنی. این کار لازم نیست. میک‌نوت سوییچ create داره برای ایجاد یک دیتابیس خالی. دیتابیس خالی وقتی می‌تونه مهاجرت کنه نیازی به چاپ پیغام خطا نداره.

همچنین در تابع دیگری در همون فایل چک می‌کنی که آیا متادیتا داره یا نه. باز هم خیلی کار خوبیه و باز هم پیغام خطا لازم نیست. این پیام زمانی چاپ می‌شه که یک فایل دیتابیس (یا فایلی که آخر اسمش .db داره) در مسیر دیتابیس‌های میک‌نوت قرار داشته باشه که مال میک‌نوت نباشه. در این صورت اولاً که میک‌نوت مشکلی با این فایل نداره و ازش استفاده نمی‌کنه. ثانیاً که شاید یه نفر به هر دلیلی فایل‌های دیگری در اون مسیر داره. (مثلاً شاید همهٔ فایل‌های دیتابیس همهٔ نرم‌افزارهایش رو توی یک پوشه نگهداری می‌کنه) در این صورت منطقی نیست که در هر به‌روزرسانی میک‌نوت یک پیغام خطا دریافت کنه.

پس لطفاً این دو تا print رو از این فایل حذف کن.

(در کل تنها اصلاحی که لازمه حذف چند تا پرینت است. 😃)

سپاس فراوان!

- Error prints
- sql_to_csv unnecessary print
"There could be other application files in the same dir as the `makenote` db files"
@Mamdasn
Copy link
Contributor Author

Mamdasn commented Feb 7, 2024

با تشکر از نگاه تیزتان به تغییرات ایجاد شده.

همانطور که پیشنهاد دادید, تغییرات زیر روی کد ایجاد شد:

  • پرینت‌ زاید در تابع sql_to_csv در فایل dbmanager حذف شد.
  • پرینت‌های خطای زاید در migrations‍ حذف شدند.
  • در صورت وجود دیتابیسی که با sqlite سازگار نباشد (دیتاهای برنامه‌های دیگر) آن فایل مربوطه skip می‌شود.
  • اضافه کردن ‍‍۱ به نسخه وصله برنامه

Copy link
Owner

@ekm507 ekm507 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

سپاس فراوان!

@ekm507 ekm507 merged commit 5bed0a8 into ekm507:master Feb 7, 2024
@Mamdasn Mamdasn deleted the Fresh-install-patch branch February 10, 2024 22:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants