Bearsampp / sandbox

R&D Repo for Bearsampp
GNU General Public License v3.0
0 stars 1 forks source link

python #87

Closed N6REJ closed 2 months ago

N6REJ commented 2 months ago

User description

Removes python control panel


PR Type

enhancement, bug_fix


Description


Changes walkthrough πŸ“

Relevant files
Enhancement
10 files
class.lang.php
Remove Python CP constant from language class                       

core/classes/class.lang.php
  • Removed PYTHON_CP constant.
  • Updated getKeys method to exclude PYTHON_CP.
  • +0/-2     
    class.tool.python.php
    Remove Python CP executable references and methods             

    core/classes/tools/class.tool.python.php
  • Removed LOCAL_CFG_CP_EXE constant and related variable.
  • Removed getCpExe method.
  • Updated error handling to exclude CP executable.
  • +6/-20   
    class.tpl.app.python.php
    Remove Python CP menu item                                                             

    core/classes/tpls/app/class.tpl.app.python.php - Removed menu item for Python command prompt.
    +6/-12   
    class.tpl.aestan.php
    Remove Python CP glyph constant                                                   

    core/classes/tpls/class.tpl.aestan.php - Removed `GLYPH_PYTHON_CP` constant.
    +0/-1     
    english.lang
    Remove Python CP language entry                                                   

    core/langs/english.lang - Removed `pythonCp` entry.
    +0/-1     
    french.lang
    Remove French Python CP language entry                                     

    core/langs/french.lang - Removed `pythonCp` entry.
    +0/-1     
    german.lang
    Remove German Python CP language entry                                     

    core/langs/german.lang - Removed `pythonCp` entry.
    +0/-1     
    hungarian.lang
    Remove Hungarian Python CP language entry                               

    core/langs/hungarian.lang - Removed `pythonCp` entry.
    +0/-1     
    spanish.lang
    Remove Spanish Python CP language entry                                   

    core/langs/spanish.lang - Removed `pythonCp` entry.
    +0/-1     
    swedish.lang
    Remove Swedish Python CP language entry                                   

    core/langs/swedish.lang - Removed `pythonCp` entry.
    +0/-1     

    πŸ’‘ PR-Agent usage: Comment /help "your question" on any pull request to receive relevant information

    codiumai-pr-agent-pro[bot] commented 2 months ago

    PR Reviewer Guide πŸ”

    ⏱️ Estimated effort to review: 2 πŸ”΅πŸ”΅βšͺβšͺβšͺ
    πŸ§ͺ No relevant tests
    πŸ”’ No security concerns identified
    ⚑ Key issues to review

    Potential Bug
    The removal of Python CP might cause issues if other parts of the system still rely on it. Ensure all references to Python CP are removed throughout the codebase. User Experience
    Removal of Python CP menu item might affect user experience. Consider adding a notice or updating documentation to inform users about this change.
    codiumai-pr-agent-pro[bot] commented 2 months ago

    PR Code Suggestions ✨

    CategorySuggestion                                                                                                                                    Score
    Best practice
    Use specific exception types for better error handling ___ **Consider using a more specific exception type instead of the generic Exception when
    throwing errors. This can help with error handling and debugging.** [core/classes/tools/class.tool.python.php [69-77]](https://github.com/Bearsampp/sandbox/pull/87/files#diff-1413001690c9eebd9d6d210081327b0d845509e9fa01b3611d76653bcbecce6bR69-R77) ```diff if (!is_file($this->bearsamppConf)) { - Util::logError(sprintf($bearsamppLang->getValue(Lang::ERROR_CONF_NOT_FOUND), $this->name . ' ' . $this->version, $this->bearsamppConf)); + throw new FileNotFoundException(sprintf($bearsamppLang->getValue(Lang::ERROR_CONF_NOT_FOUND), $this->name . ' ' . $this->version, $this->bearsamppConf)); } if (!is_file($this->exe)) { - Util::logError(sprintf($bearsamppLang->getValue(Lang::ERROR_EXE_NOT_FOUND), $this->name . ' ' . $this->version, $this->exe)); + throw new FileNotFoundException(sprintf($bearsamppLang->getValue(Lang::ERROR_EXE_NOT_FOUND), $this->name . ' ' . $this->version, $this->exe)); } if (!is_file($this->idleExe)) { - Util::logError(sprintf($bearsamppLang->getValue(Lang::ERROR_EXE_NOT_FOUND), $this->name . ' ' . $this->version, $this->idleExe)); + throw new FileNotFoundException(sprintf($bearsamppLang->getValue(Lang::ERROR_EXE_NOT_FOUND), $this->name . ' ' . $this->version, $this->idleExe)); } ``` - [ ] **Apply this suggestion**
    Suggestion importance[1-10]: 8 Why: Using specific exception types enhances error handling and debugging, making the code more robust and easier to maintain. This is a significant improvement over using generic exceptions.
    8
    Use a constant for the 'IDLE' string to improve code maintainability ___ **Consider using a constant for the 'IDLE' string to improve maintainability and
    reduce the risk of typos.** [core/classes/tpls/app/class.tpl.app.python.php [57-61]](https://github.com/Bearsampp/sandbox/pull/87/files#diff-eba53033bb4f754078cbb62b047d295c301d40e3d7ee6f4e2a5ed479445ceb1dR57-R61) ```diff +const PYTHON_IDLE = 'IDLE'; + $resultItems .= TplAestan::getItemExe( - $bearsamppLang->getValue(Lang::PYTHON) . ' IDLE', + $bearsamppLang->getValue(Lang::PYTHON) . ' ' . self::PYTHON_IDLE, $bearsamppTools->getPython()->getIdleExe(), TplAestan::GLYPH_PYTHON ) . PHP_EOL; ``` - [ ] **Apply this suggestion**
    Suggestion importance[1-10]: 6 Why: Defining a constant for the 'IDLE' string improves maintainability and reduces the risk of typos, but it is a minor enhancement with limited impact on overall functionality.
    6
    Enhancement
    Use a constant array for language keys to improve maintainability ___ **Consider updating the getKeys method to use an array constant for language keys
    instead of listing them individually. This would make maintenance easier and reduce
    the chance of errors when adding or removing keys.** [core/classes/class.lang.php [422-432]](https://github.com/Bearsampp/sandbox/pull/87/files#diff-a118643b1351745f98e04a23f3304557badf843a75110c60679c95f023025c38R422-R432) ```diff +private const LANGUAGE_KEYS = [ + self::LOGS, + self::LOGS_VERBOSE, + self::MODULES, + self::NAME, + self::PAYPAL, + self::PYTHON_CONSOLE, + self::PWGEN, + self::QUIT, + self::READ_CHANGELOG, + self::RELOAD, +]; + public static function getKeys() { - return array( - self::LOGS, - self::LOGS_VERBOSE, - self::MODULES, - self::NAME, - self::PAYPAL, - self::PYTHON_CONSOLE, - self::PWGEN, - self::QUIT, - self::READ_CHANGELOG, - self::RELOAD, + return self::LANGUAGE_KEYS; +} ``` - [ ] **Apply this suggestion**
    Suggestion importance[1-10]: 7 Why: This suggestion improves maintainability by centralizing the language keys in a constant array, reducing the risk of errors when adding or removing keys. However, it is not crucial for functionality.
    7

    πŸ’‘ Need additional feedback ? start a PR chat