forked from finbourne/sample-notebooks
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnbmeta.py
53 lines (45 loc) · 1.6 KB
/
nbmeta.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
import urllib.parse
class NbMeta:
"""
Metadata associated with a notebook.
Attributes
----------
path : str
Relative folder path of the location of the notebook from the root of the repository
filename : str
Notebook filename
title : str
notebook title
description : str
Notebook description, taken from the short description of the docstring
features : [str]
List of notebook features, taken from the attributes of the docstring
formatted_features : str
Comma separated formatted string based on features
"""
def __init__(self, path: str, filename: str, title: str, description: str, features: [str]):
"""
Parameters
----------
path : str
Relative folder path of the location of the notebook from the root of the repository
filename : str
Notebook filename
title : str
Notebook title
description : str
Notebook description, taken from the short description of the docstring
features : [str]
List of notebook features, taken from the attributes of the docstring
"""
self.path = path
self.filename = filename
self.url_filename = urllib.parse.quote(filename)
self.title = title
self.description = description.replace("\n", "<br>") if description else description
self.features = features
self.formatted_features = ", ".join(self.features)
def __str__(self):
return self.filename
def __repr__(self):
return self.filename