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

NEW: restructure using a python module/library instead of one big file #16

Open
mscheinert opened this issue Oct 13, 2020 · 2 comments
Open
Assignees
Milestone

Comments

@mscheinert
Copy link
Collaborator

mscheinert commented Oct 13, 2020

Description

Currently, the mkReadme script is a monolith. This makes it less re-usable for other developments (or our own).
A better approach would be a module/library, that can be easily imported.

Proposed Solution

Split the mkReadme script into two parts: one module and one 'executable' which imports the module.
Ultimate goal: nemo-simsar can be installed via pip & co.

Relations

  • mkReadme script
  • Dokumentation: We could add a API Reference
  • Directory structure of this project
@mscheinert mscheinert assigned mscheinert and lmicallef and unassigned mscheinert Oct 13, 2020
@mscheinert mscheinert added this to the release-2.0.0 milestone Oct 13, 2020
@mscheinert
Copy link
Collaborator Author

Simultaneously, we could also remove all the global variables and replace them with arguments and return values in the functions.

@lmicallef
Copy link
Collaborator

Scripts are uploaded in lucienneMicallef Branch | src

Major update:

  • Script has been divided into two:
    • I) storing all functions (scriptMK.py) - 'module'
    • ii) the main programme (mkReadme.py) - 'executable'
  • Script should be stored in an experiment, hence all reference being made to scripts stored in the root have been removed

Other updates to scriptMK.py

  • Lines 612 - 618: reverted to the original path configuration, I.e. currentDirectory. open("../../cfg.txt", "r") etc.. is not working correctly
  • Line 739 did not work, I have reverted to the previous code
  • Reference to input.def is changed to input.ini
  • Function to generate the markdown table from input.def has been removed
  • Library local.svn is removed
  • Subprocess.CalledProcessError is used as exception handling for SVN
  • Code commented and not being used has been removed
  • Removed unused variables

Functions removed:
main()
chooseConfigFile()
check_EXPref()

lmicallef added a commit that referenced this issue Oct 16, 2020
Updated Code:

Major update: 
- Script has been divided into two:
    - I) storing all functions (scriptMK.py)
    - ii) the main programme (mkReadme.py)
- Script should be stored in an experiment, hence all reference being made to scripts stored in the root have been removed

Other updates to scriptMK.py
- Lines 612 - 618: reverted to the original path configuration, I.e. currentDirectory. open("../../cfg.txt", "r") etc.. is not working correctly 
- Line 739 did not work, I have reverted to the previous code
- Reference to input.def is changed to input.ini
- Function to generate the markdown table from input.def has been removed
- Library local.svn is removed
- Subprocess.CalledProcessError is used as exception handling for SVN
- Code commented and not being used has been removed
- Removed unused variables
- Removed pycurl module

Functions removed:

main()
chooseConfigFile()
check_EXPref()
lmicallef added a commit that referenced this issue Nov 9, 2020
Updated Code:

Major update: 

The script which contains all the functions (scriptMK_v5.py) has been organised in two classes. One is color and the other is readmeScript. Color Class contains all the inbuild colours which are being used in the script. 

readmeScript Class contains an initialisation class (similar to a constructor) which stores attributes that will be used for several methods in this same class.  All global variables have been removed and where possible variables are being passed as arguments.

The main script (mkReadme_v5.py) imports the above classes and creates instances to be able to access the attributes and methods. 

The above changes were made (i) to avoid global variables (ii) to to have an object-oriented approach to faciliate work when we need to create a package. 

P.S. These scripts are still work in progress and script names can be changed
lmicallef added a commit that referenced this issue Dec 3, 2020
Major Updates:

ScriptMK.py is divided into two classes (this will be useful when the library will be implemented):
- Color (stores the colours used during the execution of the script)
- ReadmeScript: this class stores all the functions necessary to generate the Readme template. 
    - Global variables have been removed and replaced by arguments. 
    - The code includes reference to ‘REF’  

mkReadme.py the main update is that instances for the classes mentioned above were declared.
lmicallef added a commit that referenced this issue Mar 3, 2021
Minor updates to the previous code. 
Mainly removal of unused variables and lines of code. 

Code works with Nemo v3 and v4.
@mscheinert mscheinert mentioned this issue Mar 10, 2021
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

No branches or pull requests

2 participants