pylabnotebook 0.1.10__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Binary file
pylabnotebook/LICENSE ADDED
@@ -0,0 +1,9 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2023 Matteo Miotto
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6
+
7
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
8
+
9
+ THE SOFTWARE IS PROVIDED "AS IS," WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES, OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT, OR OTHERWISE, ARISING FROM, OUT OF, OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,2 @@
1
+ from .version import __version__
2
+ __version__ = __version__
@@ -0,0 +1,84 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <meta http-equiv="X-UA-Compatible" content="IE=edge">
6
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
7
+ <title>Example Lab notebook</title>
8
+ <style>
9
+
10
+ h1 {
11
+ color: red;
12
+ text-align: center;
13
+ font-size: 2.5em;
14
+ }
15
+
16
+ h2 {
17
+ text-align: center;
18
+ border: 1px solid red;
19
+ font-size: 1.875em;
20
+ }
21
+
22
+ h3 {
23
+ font-weight: bold;
24
+ margin: 1em 0em 0.2em 0em;
25
+ font-size: 1.2em;
26
+ }
27
+
28
+ details {
29
+ font-size: 1em;
30
+ cursor: pointer;
31
+ display: inline
32
+ }
33
+
34
+ details > li {
35
+ padding-left: 2em;
36
+ font-size: 1em;
37
+ }
38
+
39
+ p {
40
+ margin: 0.2em 0em;
41
+ font-size: 1em;
42
+ }
43
+
44
+ </style>
45
+ </head>
46
+ <body>
47
+ <h1>Example lab notebook</h1>
48
+ <p>Created on: 2022-03-16</p>
49
+ <p>Author: mmiots9</p>
50
+
51
+ <h2>2022-03-16</h2>
52
+
53
+ <h3>add README</h3>
54
+ <p></p>
55
+ <p>sha: 20143ed</p>
56
+ <p>Analysis file: <code>none</code></p>
57
+
58
+ <details>
59
+ <summary>Affected files</summary>
60
+ <li> A README.md </li>
61
+ </details>
62
+
63
+ <h3>First analysis</h3>
64
+ <p>Create a fake output file</p>
65
+ <p>sha: 977558e</p>
66
+ <p>Analysis file: <code>analyses/first.Rmd</code></p>
67
+
68
+ <details>
69
+ <summary>Affected files</summary>
70
+ <li> A analyses/first.Rmd </li>
71
+ <li> A output/out1.pdf </li>
72
+ </details>
73
+
74
+ <h3>new info file</h3>
75
+ <p></p>
76
+ <p>sha: 9ffcab5</p>
77
+ <p>Analysis file: <code>none</code></p>
78
+
79
+ <details>
80
+ <summary>Affected files</summary>
81
+ <li> A info.txt </li>
82
+ </details>
83
+ </body>
84
+ </html>
pylabnotebook/main.py ADDED
@@ -0,0 +1,419 @@
1
+ import argparse
2
+ import os
3
+ from datetime import datetime
4
+ import subprocess
5
+ import json
6
+ import shutil
7
+ import sys
8
+ import re
9
+ from .version import __version__
10
+
11
+ def create_labnotebook(name):
12
+ """
13
+ This function creates a new labnotebook. Thes structure is stored in the newly created .labnotebook folder.
14
+ """
15
+
16
+ # 1. Check if .git folder is present
17
+ if not os.path.exists(".git"):
18
+ print("Error: There is no .git folder in the current working directory.")
19
+ print("Please go to the folder where .git is to create a new notebook in the same folder or run 'git init'.")
20
+ return
21
+ pass
22
+
23
+ # 2. Create .labnotebook directory if it doesn't exist, otherwise return an error
24
+ try:
25
+ os.makedirs(".labnotebook")
26
+ except OSError:
27
+ print(".labnotebook folder is already present. If you want to create a new .labnotebook directory, you have to firstly delete it.")
28
+ return
29
+
30
+ # 3. Get useful variables
31
+ today = datetime.now().strftime('%Y-%m-%d')
32
+ aut = subprocess.check_output(["git", "config", "--get", "user.name"], universal_newlines = True).strip()
33
+ red = '\033[0;31m'
34
+ green = '\033[0;32m'
35
+ ncol = '\033[0m'
36
+
37
+ # 4. Create config file
38
+ create_config_json(name=name, aut=aut)
39
+
40
+ # 5. Create HEAD, BODY and FOOTER
41
+ create_head_html(name = name)
42
+ create_body_html(name, today, aut)
43
+ script_dir = os.path.dirname(os.path.abspath(__file__))
44
+ footer_template_path = os.path.join(script_dir, "templates", "footer.html")
45
+ new_footer_path = os.path.join(".labnotebook", "footer.html")
46
+ shutil.copy(footer_template_path, new_footer_path)
47
+
48
+ # 6. Copy style.css file
49
+ css_template_path = os.path.join(script_dir, "templates", "style.css")
50
+ new_css_path = os.path.join(".labnotebook", "labstyles.css")
51
+ shutil.copy(css_template_path, new_css_path)
52
+
53
+ # 7. Return messages
54
+ print(f"\n{green}.labnotebook folder successfully created")
55
+ print(f"{red}Mandatory: when updating the notebook, make sure you are in {os.getcwd()}")
56
+ print("Never change the .labnotebook folder name or content")
57
+ print(ncol)
58
+
59
+
60
+ def create_config_json(name, aut):
61
+ """
62
+ This function creates the config.json file in the .labnotebook folder
63
+ """
64
+ config = {"NOTEBOOK_NAME": f"{name}",
65
+ "LAB_AUTHOR": f"{aut}",
66
+ "LAST_COMMIT": None,
67
+ "LAST_DAY": None,
68
+ "SHOW_ANALYSIS_FILES": True,
69
+ "LAB_CSS": ".labnotebook/labstyles.css",
70
+ "ANALYSIS_EXT": ['.html']}
71
+
72
+ filename = '.labnotebook/config.json'
73
+ with open(filename, 'w') as file:
74
+ json.dump(config, file, indent = 4)
75
+
76
+
77
+ def create_head_html(name):
78
+ """
79
+ This function creates the head.html file based on the head template, by changing the title meta.
80
+ """
81
+ # 1. Get the directory where the current script is located
82
+ script_dir = os.path.dirname(os.path.abspath(__file__))
83
+
84
+ # 2. Define the path to the 'templates' folder relative to the script's directory
85
+ head_template_path = os.path.join(script_dir, "templates", "head.html")
86
+
87
+ # 3. Perform the substitution
88
+ try:
89
+ # 3.1 Read the content of the template file
90
+ with open(head_template_path, "r") as template_file:
91
+ template_content = template_file.read()
92
+
93
+ # 3.2 Perform the substitution
94
+ head_content = template_content.replace("{name_placeholder}", name)
95
+
96
+ # 3.3 Define the path for the new .labnotebook/head.html file
97
+ new_head_path = os.path.join(".labnotebook", "head.html")
98
+
99
+ # 3.4 Write the modified content to the new file
100
+ with open(new_head_path, "w") as new_head_file:
101
+ new_head_file.write(head_content)
102
+
103
+ except FileNotFoundError:
104
+ print("Template file not found.")
105
+ except Exception as e:
106
+ print(f"An error occurred: {str(e)}")
107
+
108
+
109
+ def create_body_html(name, today, aut):
110
+ """
111
+ This function creates the body.html file based on the body template, by changing the title, the author and the date.
112
+ """
113
+ # 1. Get the directory where the current script is located
114
+ script_dir = os.path.dirname(os.path.abspath(__file__))
115
+
116
+ # 2. Define the path to the 'templates' folder relative to the script's directory
117
+ body_template_path = os.path.join(script_dir, "templates", "body.html")
118
+
119
+ # 3. Perform the substitution
120
+ try:
121
+ # 3.1 Read the content of the template file
122
+ with open(body_template_path, "r") as template_file:
123
+ template_content = template_file.read()
124
+
125
+ # 3.2 Perform the substitution
126
+ body_content = (template_content.replace("{name_placeholder}", name).
127
+ replace("{today_placeholder}", today).
128
+ replace("{aut_placeholder}", aut))
129
+
130
+ # 3.3 Define the path for the new .labnotebook/head.html file
131
+ new_body_path = os.path.join(".labnotebook", "body.html")
132
+
133
+ # 3.4 Write the modified content to the new file
134
+ with open(new_body_path, "w") as new_body_file:
135
+ new_body_file.write(body_content)
136
+
137
+ except FileNotFoundError:
138
+ print("Template file not found.")
139
+ except Exception as e:
140
+ print(f"An error occurred: {str(e)}")
141
+
142
+
143
+ def update_labnotebook(force_update):
144
+ """
145
+ This function updates body.html and config.json files in .labonotebook folder by looping through all commits not already inclded.
146
+ """
147
+ # 1. Get useful variables
148
+ red = '\033[0;31m'
149
+
150
+ # 2. Check for .labnotebook folder and config.json files
151
+ if not os.path.exists(".labnotebook"):
152
+ print(f"{red}Error: There is no .labnotebook folder in the current working directory. "
153
+ "Please go to the folder where .labnotebook is.")
154
+ sys.exit(2)
155
+
156
+ config_file = os.path.join(".labnotebook", "config.json")
157
+ try:
158
+ with open(config_file, "r") as config_file:
159
+ config = json.load(config_file)
160
+ except FileNotFoundError:
161
+ print(f"{red}Error: There is no config file in .labnotebook folder. Please provide the config file.")
162
+ sys.exit(2)
163
+
164
+ # 3. Check for staged files
165
+ git_status = subprocess.run("git status", shell=True, stdout=subprocess.PIPE, text=True)
166
+ if "Changes to be committed:" in git_status.stdout:
167
+ print(f"{red}Error: You have staged files to be committed. This is incompatible with updatenotebook. "
168
+ "Please commit those changes, restore the files, or stage them prior to running this function.")
169
+ sys.exit(1)
170
+
171
+ # 4. Reset config and head if force_update
172
+ if force_update:
173
+ create_config_json(name = config.get('NOTEBOOK_NAME'),
174
+ aut = config.get('LAB_AUTHOR'))
175
+ with open(config_file, "r") as config_file:
176
+ config = json.load(config_file)
177
+ create_body_html(name = config.get('NOTEBOOK_NAME'),
178
+ today = datetime.now().strftime('%Y-%m-%d'),
179
+ aut = config.get('LAB_AUTHOR'))
180
+
181
+ # 5. Get list of commits sha
182
+ last_commit = config.get('LAST_COMMIT')
183
+ sha_list = get_sha_list(last_commit)
184
+
185
+ # 6. Remove main and body closing tags from body.html
186
+ with open(".labnotebook/body.html", "r") as body_file:
187
+ body_content = body_file.read()
188
+ body_content = (body_content.replace("</main>", "").
189
+ replace("</body>", ""))
190
+
191
+ # 7. Get info about each commit
192
+ analysis_ext = config.get('ANALYSIS_EXT')
193
+ excluded_patterns = get_excluded_patterns()
194
+ commits_info = {sha: get_commit_info(sha, analysis_ext, excluded_patterns) for sha in sha_list}
195
+
196
+ # 8. Write info into body.html and update config
197
+ write_update_files(commits_info, body_content, config)
198
+
199
+
200
+ def get_sha_list(last_commit):
201
+ """
202
+ This functions returns a list of commits sha (from oldest to newest) that have not been already included in the notebook.
203
+ """
204
+
205
+ red = '\033[0;31m'
206
+ yellow = '\033[1;33m'
207
+
208
+ # 1. Get list of all commits
209
+ git_sha = subprocess.run("git log --pretty=format:%h --reverse", shell=True, stdout=subprocess.PIPE, text=True).stdout.split('\n')
210
+
211
+ # 2. Subset for new commits
212
+ # 2.1 If git history is empty, return error
213
+ if git_sha == ['']:
214
+ print(f"{red}Error: Git history is empty")
215
+ sys.exit(5)
216
+
217
+ # 2.2 Return all if last commit is None
218
+ if last_commit is None:
219
+ return git_sha
220
+
221
+ # 2.3 Raise error if last commit is not in git_sha list
222
+ if last_commit not in git_sha:
223
+ print(f"{red}Error: Last commit used for the lab notebook ({last_commit}) is not in the current git log history."
224
+ f"\nIt is possible that you have changed commit history. Please check your git log and insert the commit SHA to use in the config file or force the update to start again from the beginning of the git history using labnotebook update -f/--force.")
225
+ sys.exit(5)
226
+
227
+ # 2.4 Perform the subset
228
+ index = git_sha.index(last_commit)
229
+ git_sha = git_sha[index + 1:]
230
+
231
+ # 2.5 Interrupt if last_commit is actually the last commit in history
232
+ if len(git_sha) == 0:
233
+ print(f"{yellow}Warning: LAST_COMMIT is already the last commit in history. Nothing to update.")
234
+ sys.exit(5)
235
+
236
+ # 3. Return git_sha
237
+ return git_sha
238
+
239
+
240
+ def get_excluded_patterns():
241
+ """
242
+ This functions returns a list of the patterns to exclude in analysis files.
243
+ """
244
+ try:
245
+ with open('.labignore', 'r') as f:
246
+ excluded_patterns = f.read().splitlines()
247
+ excluded_patterns = [pattern.replace('*', '.*') for pattern in excluded_patterns]
248
+ except FileNotFoundError:
249
+ excluded_patterns = []
250
+ finally:
251
+ return excluded_patterns
252
+
253
+
254
+
255
+ def get_commit_info(commit_sha, analysis_ext, excluded_patterns):
256
+ """
257
+ This function returns a dictionary of the information about the commit specified in commit_sha. These info are: date, author, title, message and changed files.
258
+ """
259
+ date, author, title = subprocess.check_output(['git', 'log', '-n', '1', '--pretty=format:%cs%n%an%n%s', commit_sha], text=True).strip().split('\n')
260
+ message = subprocess.check_output(['git', 'log', '-n', '1', '--pretty=format:%b', commit_sha], text=True).strip().replace("\n", "<br>\n")
261
+ changed_files = subprocess.check_output(['git', 'show', '--pretty=%n', '--name-status', commit_sha], text=True).strip().split('\n')
262
+ changed_files = {file.split('\t')[1] : file.split('\t')[0] for file in changed_files}
263
+ analysis_files = [key for key,_ in changed_files.items() if any(ext in key for ext in analysis_ext) and not any([re.search(pattern, key) for pattern in excluded_patterns])]
264
+ commit_info = {'date': date,
265
+ 'author': author,
266
+ 'title': title,
267
+ 'message': message,
268
+ 'changed_files': changed_files,
269
+ 'analysis_files': analysis_files}
270
+ return commit_info
271
+
272
+
273
+ def write_update_files(commits_info, body_content, config):
274
+ """
275
+ This function writes the commit elements into body.html and updates the config.json file.
276
+ """
277
+ # 1. Loop through commits
278
+ for sha, commit in commits_info.items():
279
+ # 1.1 Check last day
280
+ if config.get('LAST_DAY') != commit.get('date'):
281
+ body_content += f"<h2 class='day-el'>{commit.get('date')}</h2>\n\n"
282
+ config['LAST_DAY'] = commit.get('date')
283
+
284
+ # 1.2 Write commit div
285
+ body_content += f"<div class='commit-el' id='{sha}'>\n"
286
+ body_content += f"<h3 class='title-el'>{commit.get('title')}</h3>\n"
287
+ if commit.get('message') == '':
288
+ pass
289
+ else:
290
+ body_content += f"<p class='mess-el'>{commit.get('message')}</p>\n"
291
+ body_content += f"<p class='author-el'>Author: {commit.get('author')}</p>\n"
292
+ body_content += f"<p class='sha-el'>sha: {sha}</p>\n"
293
+ if len(commit.get('analysis_files')) == 0:
294
+ body_content += "<div class='analyses-el'>Analysis file/s: <code>none</code></div>\n"
295
+ else:
296
+ body_content += f"<div class='analyses-el'>Analysis file/s:\n<ul class='analysis_list'>\n"
297
+ for a_file in commit.get('analysis_files'):
298
+ body_content += f"<li><code><a href='{a_file}' target='_blank'>{a_file}</a></code></li>\n"
299
+ body_content += "</ul>\n</div>\n"
300
+ body_content += "<details>\n<summary>Changed files</summary>\n<ul class='changed_list'>\n"
301
+ for c_file in commit.get('changed_files'):
302
+ body_content += f"<li>{c_file}</li>\n"
303
+ body_content += "</ul>\n</details>\n</div>\n"
304
+
305
+ # 1.3 Update last commit
306
+ config['LAST_COMMIT'] = f"{sha}"
307
+
308
+ # 2. Insert closing tags
309
+ body_content += "</main>\n</body>"
310
+
311
+ # 3. Write body.html
312
+ with open('.labnotebook/body.html', "w") as new_body_file:
313
+ new_body_file.write(body_content)
314
+
315
+ # 4. Write config.json
316
+ with open(".labnotebook/config.json", 'w') as file:
317
+ json.dump(config, file, indent = 4)
318
+
319
+
320
+ def export_labnotebook(output_file, force, link):
321
+ """
322
+ This function exports the labnotebook into a single (or multiple) html file ready to read.
323
+ """
324
+ # 1. Get useful variables
325
+ red = '\033[0;31m'
326
+
327
+ # 2. Check for .labnotebook folder, config.json and .html files
328
+ if not os.path.exists(".labnotebook"):
329
+ print(f"{red}Error: There is no .labnotebook folder in the current working directory. "
330
+ "Please go to the folder where .labnotebook is.")
331
+ sys.exit(2)
332
+
333
+ config_file = os.path.join(".labnotebook", "config.json")
334
+ try:
335
+ with open(config_file, "r") as config_file:
336
+ config = json.load(config_file)
337
+ except FileNotFoundError:
338
+ print(f"{red}Error: There is no config file in .labnotebook folder. Please provide the config file.")
339
+ sys.exit(2)
340
+
341
+ required_files = [
342
+ '.labnotebook/head.html',
343
+ '.labnotebook/body.html',
344
+ '.labnotebook/footer.html',
345
+ config.get('LAB_CSS')
346
+ ]
347
+
348
+ for file in required_files:
349
+ if not os.path.exists(file):
350
+ print(f"Error: There is no {file} file.")
351
+ sys.exit(2)
352
+
353
+ # 3. Check if file already exists and force is False
354
+ if os.path.exists(output_file) and not force:
355
+ print(f"{red}Error: {output_file} already exists. Use -f/--force to overwrite it.")
356
+ sys.exit(1)
357
+
358
+ # 4. Read head.html and edit it
359
+ with open('.labnotebook/head.html', 'r') as head_file:
360
+ output_content = head_file.read()
361
+ output_content = output_content.replace("</head>", "")
362
+ if link:
363
+ output_content += f"<link rel='stylesheet' href='{config.get('LAB_CSS')}'>\n"
364
+ else:
365
+ with open(config.get('LAB_CSS'), 'r') as style_file:
366
+ output_content += f"<style>\n{style_file.read()}\n</style>\n"
367
+
368
+ if not config.get('SHOW_ANALYSIS_FILES'):
369
+ output_content += "<style>\n.analyses-el {display: none;}\n</style>\n"
370
+
371
+ output_content += "</head>\n"
372
+
373
+ # 5. Read body.html and insert into output content
374
+ with open('.labnotebook/body.html', 'r') as body_file:
375
+ output_content += f"{body_file.read()}\n"
376
+
377
+ # 5. Read footer.html and insert into output content
378
+ with open('.labnotebook/footer.html', 'r') as footer_file:
379
+ output_content += f"{footer_file.read()}\n"
380
+
381
+ # 6. Write output file
382
+ with open(output_file, 'w') as output_file:
383
+ output_file.write(output_content)
384
+
385
+
386
+ def main():
387
+ parser = argparse.ArgumentParser(description="Lab Notebook Tool")
388
+ parser.add_argument('--version', action='version', version='%(prog)s ' + __version__, help="Show package version")
389
+
390
+ subparsers = parser.add_subparsers(dest="command")
391
+
392
+ create_parser = subparsers.add_parser("create", help="Create a new lab notebook")
393
+ create_parser.add_argument("-n", "--name", required=True, help="Name of the lab notebook. If the name should contain more words, wrap them into quotes")
394
+
395
+ update_parser = subparsers.add_parser("update", help="Update lab notebook")
396
+ update_parser.add_argument("-f", "--force", help="Force the update", default=False, action="store_true")
397
+
398
+ export_parser = subparsers.add_parser("export", help="Export lab notebook to an html file")
399
+ export_parser.add_argument("-o", "--output", required=True, help="Path/name of the output HTML file")
400
+ export_parser.add_argument("-f", "--force", help="Force the overwriting of the output file if already present", default=False, action="store_true")
401
+ export_parser.add_argument("-l", "--link", help="Link style file in head. By default style file is copied in <style></style> tags in head", default=False, action="store_true")
402
+
403
+ args = parser.parse_args()
404
+
405
+ if args.command == "create":
406
+ if not args.name:
407
+ create_parser.error("-n/--name is required for the 'create' command. Please provide the name of the notebook.")
408
+ create_labnotebook(args.name)
409
+ elif args.command == "update":
410
+ update_labnotebook(args.force)
411
+ elif args.command == "export":
412
+ if not args.output:
413
+ export_parser.error("-o/--output is required for the 'export' command. Please provide the name of the output file.")
414
+ export_labnotebook(args.output, args.force, args.link)
415
+ else:
416
+ parser.print_help()
417
+
418
+ if __name__ == "__main__":
419
+ main()
@@ -0,0 +1,10 @@
1
+ <body>
2
+ <header>
3
+ <h1 id='labtitle'>{name_placeholder} lab notebook</h1>
4
+ <p id='creationdate'>Created on: {today_placeholder}</p>
5
+ <p id='labauthor'>Author: {aut_placeholder}</p>
6
+ </header>
7
+ <main>
8
+
9
+ </main>
10
+ </body>
@@ -0,0 +1,4 @@
1
+ <footer>
2
+ <p>Labnotebook &copy; mmiots9</p>
3
+ </footer>
4
+ </html>
@@ -0,0 +1,11 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+
4
+ <head>
5
+ <meta charset="UTF-8">
6
+ <meta http-equiv="X-UA-Compatible" content="IE=edge">
7
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
8
+ <title>
9
+ {name_placeholder} lab notebook
10
+ </title>
11
+ </head>
@@ -0,0 +1,62 @@
1
+ * {
2
+ margin: 0;
3
+ padding: 0;
4
+ box-sizing: border-box;
5
+ }
6
+
7
+ header {
8
+ padding: 1rem;
9
+ }
10
+
11
+ h1 {
12
+ color: red;
13
+ text-align: center;
14
+ font-size: 2.5em;
15
+ }
16
+
17
+ h2 {
18
+ text-align: center;
19
+ border: 1px solid red;
20
+ font-size: 1.875em;
21
+ }
22
+
23
+ h3 {
24
+ font-weight: bold;
25
+ margin: 1em 0em 0.2em 0em;
26
+ font-size: 1.2em;
27
+ }
28
+
29
+ details {
30
+ font-size: 1em;
31
+ cursor: pointer;
32
+ display: inline;
33
+ }
34
+
35
+ details li {
36
+ cursor: text;
37
+ padding-left: 0.5em;
38
+ font-size: 1em;
39
+ margin-left: 3em;
40
+ }
41
+
42
+ p {
43
+ margin: 0.2em 0em;
44
+ font-size: 1em;
45
+ }
46
+
47
+ .analyses-el {
48
+ display: block;
49
+ }
50
+
51
+ .analyses-el li {
52
+ margin-left: 3em;
53
+ padding-left: 0.5em;
54
+ }
55
+
56
+ .commit-el {
57
+ padding: 1rem;
58
+ }
59
+
60
+ .sha-el {
61
+ margin-top: 1em;
62
+ }
@@ -0,0 +1 @@
1
+ __version__ = "0.1.10"
@@ -0,0 +1,77 @@
1
+ Metadata-Version: 2.1
2
+ Name: pylabnotebook
3
+ Version: 0.1.10
4
+ Summary: This package provides functions to write an automated labnotebook using git.
5
+ Keywords: git,notebook,track,history,log
6
+ Author-Email: Matteo Miotto <miotsdata@gmail.com>
7
+ License: MIT
8
+ Classifier: Programming Language :: Python :: 3
9
+ Classifier: License :: OSI Approved :: MIT License
10
+ Classifier: Operating System :: OS Independent
11
+ Project-URL: Homepage, https://github.com/mmiots9/pylabnotebook
12
+ Project-URL: Issues, https://github.com/mmiots9/pylabnotebook/issues
13
+ Requires-Python: >=3.7
14
+ Requires-Dist: setuptools>=72.1.0
15
+ Requires-Dist: argparse>=1.4.0
16
+ Description-Content-Type: text/markdown
17
+
18
+ <h1 align="center">Labnotebook 📔🖥</h1>
19
+
20
+ This project aims to help bioinformaticians in creating the so called "Laboratory notebook" automatically, thanks to git workflow manager.
21
+
22
+ **IMPORTANT**: this tool is based on git and its application, in particular, through git history it will create an html notebook divided by date and commit.
23
+
24
+ <h3 style="margin-bottom:3px;">Features</h3>
25
+ <ul>
26
+ <li>Automatically create a laboratory notebook</li>
27
+ <li>Customizable CSS file</li>
28
+ <li>Direct link to analysis files (expecially for user who creates .html reports. e.g. markdown or jupyter notebook html)</li>
29
+ <li>Export to html</li>
30
+ </ul>
31
+
32
+ <h3>Installation</h3>
33
+ To install the package, run:
34
+
35
+ ```
36
+ pip install pylabnotebook
37
+ ```
38
+
39
+ This will install the pylabnotebook package; you can then run <code>labnotebook</code> function from within the terminal (detailed explanation below).
40
+
41
+ <h3>Notebook structure</h3>
42
+ The structure of the notebook is very simple. You can see an example <a href='https://miotsdata.netlify.app/it/bash/mie_funzioni/example.html' target='_blank'>here</a>.
43
+
44
+ <p style="margin-bottom:0px;">On top, you have the notebook name, the author and the notebook creation date. Then, for each day, you have a list of all the commits done, organized as follow:</p>
45
+ <ul>
46
+ <li>Commit message (first line)</li>
47
+ <li>Commit body</li>
48
+ <li>Commit author</li>
49
+ <li>Commit sha</li>
50
+ <li>Analysis file (which can be hidden if you don't have this type of features)</li>
51
+ <li>List of changed files</li>
52
+ </ul>
53
+
54
+ <h3>Create a notebook</h3>
55
+ To create a notebook, go to the folder in which is present the .git folder and type <code>labnotebook create -n &#60;name_of_the_notebook&#62;</code>. If you want to have spaces in your name, just wrap it into quotes.
56
+
57
+ A .labnotebook folder is created, containing config.json file, a basic .css file and three file containing head, body and footer html file.
58
+
59
+ **IMPORTANT**: never change the name of the created folder and its files!
60
+
61
+ <h3>Update a notebook</h3>
62
+ When you want to update the notebook, go to the folder in which is present the .git folder, type <code>labnotebook update</code>. It will check for new commits and upate the files in .labnotebook folder.
63
+ <br>
64
+ If the git history have changed and the last commit present in the labnotebook is no longer in git history, it will raise an error; you can skip this by forcing the update (<code>-f/--force</code>).
65
+
66
+ **IMPORTANT**: After each notebook update a commit is made with labnotebook as author. This will ensure that these commits are not considered during the update, as only commits without labnotebook as author are used.
67
+
68
+ <h4>Link to analysis files</h4>
69
+ When updating the notebook, it automatically create a list of analysis files for each commit with direct links to them. By default, it takes all the .html files changed/added in that commit.<br>
70
+ If you want to add different extensions, you can update the .labnotebook config.json file by adding/removing extensions in the ANALYSIS_EXT variable. Each extension should be separated by a comma, as it is considered an array (eg. "ANALYSIS_EXT": ['.html', '.txt'])Just type the extension, not wildcards or other special characters.<br>
71
+ Moreover, by creating a ".labignore" file, you can exclude some files/folders to be recognized as analysis files (as for a standard .gitignore file it will use wildcards).
72
+
73
+ <h3>Export html file</h3>
74
+ When you want to export the full html file containing the notebook, go to the folder in which is present the .git folder, type <code>labnotebook export -o &#60;name_of_the_output_file&#62;</code>.
75
+
76
+ <h3>Issue reporting and suggestions</h3>
77
+ If you find any issue or you want to suggest some edit, please feel free to open an issue or a pull request.
@@ -0,0 +1,14 @@
1
+ pylabnotebook-0.1.10.dist-info/METADATA,sha256=ipG-9sftchxlM59mzdKNq_2UidFiQFdQHd0ESH2XDjQ,4399
2
+ pylabnotebook-0.1.10.dist-info/WHEEL,sha256=rSwsxJWe3vzyR5HCwjWXQruDgschpei4h_giTm0dJVE,90
3
+ pylabnotebook-0.1.10.dist-info/entry_points.txt,sha256=qWrcIU-3KCOY-_ahKQ7HvtW_q99Q0T46FSxaUDQUi-A,57
4
+ pylabnotebook/.DS_Store,sha256=O5MejKsw-hyXNu3bQynTAp5g-NBfGdrVNUJd_ovnFTU,6148
5
+ pylabnotebook/LICENSE,sha256=Sx-dX1QyPDd3yHNnh20Ot7ZGSGI9Yo4y905zj42g5EM,1074
6
+ pylabnotebook/__init__.py,sha256=wB4hrgk3qggoao6XtynolWbLwEcEomt6eLADJkkPLEI,58
7
+ pylabnotebook/example.html,sha256=C1fb1vUYtAxei00TOk-PsTUxmoDV1RhPVt42JkE_kv8,1401
8
+ pylabnotebook/main.py,sha256=0PrDQEwAC6Zg7Dwwjmg6-a73F-YrwK2h6eqQUWeEJJQ,17344
9
+ pylabnotebook/templates/body.html,sha256=yz1Ls5UBsWo3KWPsly9rg9vsT7F-jLglr7XSxareoTM,249
10
+ pylabnotebook/templates/footer.html,sha256=r9oMMFWh2nybAWjGAYgwmyomfmH5D52cFqOl8Ho9Qy0,64
11
+ pylabnotebook/templates/head.html,sha256=o657x8D6ulqDFXog2WZTw2jU1ar5O_Sly91VO-HiRqM,273
12
+ pylabnotebook/templates/style.css,sha256=fKK6YdYYWurzp2LG6nMppuYloZDLn4kwJEKK2I5T4hU,733
13
+ pylabnotebook/version.py,sha256=z0zCHFTcKSR0tJ6h5qrpNmRVP21QIPP8N0p7quCnnm0,23
14
+ pylabnotebook-0.1.10.dist-info/RECORD,,
@@ -0,0 +1,4 @@
1
+ Wheel-Version: 1.0
2
+ Generator: pdm-backend (2.3.3)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
@@ -0,0 +1,3 @@
1
+ [console_scripts]
2
+ labnotebook = pylabnotebook.main:main
3
+