|
11 | 11 | "```bash\n",
|
12 | 12 | "sudo apt install jupyter\n",
|
13 | 13 | "sudo apt install python3-pip\n",
|
14 |
| - "pip install getorg --upgrade\n", |
| 14 | + "pip install python-frontmatter getorg --upgrade\n", |
15 | 15 | "```\n",
|
16 | 16 | "\n",
|
17 | 17 | "After which you can run this from the `_talks/` directory, via:\n",
|
|
29 | 29 | "metadata": {
|
30 | 30 | "collapsed": false,
|
31 | 31 | "execution": {
|
32 |
| - "iopub.execute_input": "2025-02-22T01:30:05.703774Z", |
33 |
| - "iopub.status.busy": "2025-02-22T01:30:05.703517Z", |
34 |
| - "iopub.status.idle": "2025-02-22T01:30:06.843336Z", |
35 |
| - "shell.execute_reply": "2025-02-22T01:30:06.842591Z" |
| 32 | + "iopub.execute_input": "2025-02-25T02:57:21.388444Z", |
| 33 | + "iopub.status.busy": "2025-02-25T02:57:21.387866Z", |
| 34 | + "iopub.status.idle": "2025-02-25T02:57:22.511527Z", |
| 35 | + "shell.execute_reply": "2025-02-25T02:57:22.510903Z" |
36 | 36 | }
|
37 | 37 | },
|
38 | 38 | "outputs": [
|
39 | 39 | {
|
40 | 40 | "name": "stdout",
|
41 | 41 | "output_type": "stream",
|
42 | 42 | "text": [
|
43 |
| - "Requirement already satisfied: getorg in /opt/hostedtoolcache/Python/3.9.21/x64/lib/python3.9/site-packages (0.3.1)\r\n" |
| 43 | + "Collecting python-frontmatter\r\n", |
| 44 | + " Downloading python_frontmatter-1.1.0-py3-none-any.whl.metadata (4.1 kB)\r\n" |
44 | 45 | ]
|
45 | 46 | },
|
46 | 47 | {
|
47 | 48 | "name": "stdout",
|
48 | 49 | "output_type": "stream",
|
49 | 50 | "text": [
|
| 51 | + "Requirement already satisfied: getorg in /opt/hostedtoolcache/Python/3.9.21/x64/lib/python3.9/site-packages (0.3.1)\r\n", |
| 52 | + "Requirement already satisfied: PyYAML in /opt/hostedtoolcache/Python/3.9.21/x64/lib/python3.9/site-packages (from python-frontmatter) (6.0.2)\r\n", |
50 | 53 | "Requirement already satisfied: geopy in /opt/hostedtoolcache/Python/3.9.21/x64/lib/python3.9/site-packages (from getorg) (2.4.1)\r\n",
|
51 | 54 | "Requirement already satisfied: pygithub in /opt/hostedtoolcache/Python/3.9.21/x64/lib/python3.9/site-packages (from getorg) (2.6.1)\r\n",
|
52 | 55 | "Requirement already satisfied: retrying in /opt/hostedtoolcache/Python/3.9.21/x64/lib/python3.9/site-packages (from getorg) (1.3.4)\r\n",
|
|
57 | 60 | "Requirement already satisfied: typing-extensions>=4.0.0 in /opt/hostedtoolcache/Python/3.9.21/x64/lib/python3.9/site-packages (from pygithub->getorg) (4.12.2)\r\n",
|
58 | 61 | "Requirement already satisfied: urllib3>=1.26.0 in /opt/hostedtoolcache/Python/3.9.21/x64/lib/python3.9/site-packages (from pygithub->getorg) (2.3.0)\r\n",
|
59 | 62 | "Requirement already satisfied: Deprecated in /opt/hostedtoolcache/Python/3.9.21/x64/lib/python3.9/site-packages (from pygithub->getorg) (1.2.18)\r\n",
|
60 |
| - "Requirement already satisfied: six>=1.7.0 in /opt/hostedtoolcache/Python/3.9.21/x64/lib/python3.9/site-packages (from retrying->getorg) (1.17.0)\r\n" |
| 63 | + "Requirement already satisfied: six>=1.7.0 in /opt/hostedtoolcache/Python/3.9.21/x64/lib/python3.9/site-packages (from retrying->getorg) (1.17.0)\r\n", |
| 64 | + "Requirement already satisfied: cryptography>=3.4.0 in /opt/hostedtoolcache/Python/3.9.21/x64/lib/python3.9/site-packages (from pyjwt[crypto]>=2.4.0->pygithub->getorg) (44.0.1)\r\n", |
| 65 | + "Requirement already satisfied: cffi>=1.4.1 in /opt/hostedtoolcache/Python/3.9.21/x64/lib/python3.9/site-packages (from pynacl>=1.4.0->pygithub->getorg) (1.17.1)\r\n", |
| 66 | + "Requirement already satisfied: charset-normalizer<4,>=2 in /opt/hostedtoolcache/Python/3.9.21/x64/lib/python3.9/site-packages (from requests>=2.14.0->pygithub->getorg) (3.4.1)\r\n", |
| 67 | + "Requirement already satisfied: idna<4,>=2.5 in /opt/hostedtoolcache/Python/3.9.21/x64/lib/python3.9/site-packages (from requests>=2.14.0->pygithub->getorg) (3.10)\r\n", |
| 68 | + "Requirement already satisfied: certifi>=2017.4.17 in /opt/hostedtoolcache/Python/3.9.21/x64/lib/python3.9/site-packages (from requests>=2.14.0->pygithub->getorg) (2025.1.31)\r\n" |
61 | 69 | ]
|
62 | 70 | },
|
63 | 71 | {
|
64 | 72 | "name": "stdout",
|
65 | 73 | "output_type": "stream",
|
66 | 74 | "text": [
|
67 |
| - "Requirement already satisfied: cryptography>=3.4.0 in /opt/hostedtoolcache/Python/3.9.21/x64/lib/python3.9/site-packages (from pyjwt[crypto]>=2.4.0->pygithub->getorg) (44.0.1)\r\n", |
68 |
| - "Requirement already satisfied: cffi>=1.4.1 in /opt/hostedtoolcache/Python/3.9.21/x64/lib/python3.9/site-packages (from pynacl>=1.4.0->pygithub->getorg) (1.17.1)\r\n", |
69 |
| - "Requirement already satisfied: charset-normalizer<4,>=2 in /opt/hostedtoolcache/Python/3.9.21/x64/lib/python3.9/site-packages (from requests>=2.14.0->pygithub->getorg) (3.4.1)\r\n", |
70 |
| - "Requirement already satisfied: idna<4,>=2.5 in /opt/hostedtoolcache/Python/3.9.21/x64/lib/python3.9/site-packages (from requests>=2.14.0->pygithub->getorg) (3.10)\r\n", |
71 |
| - "Requirement already satisfied: certifi>=2017.4.17 in /opt/hostedtoolcache/Python/3.9.21/x64/lib/python3.9/site-packages (from requests>=2.14.0->pygithub->getorg) (2025.1.31)\r\n", |
72 | 75 | "Requirement already satisfied: wrapt<2,>=1.10 in /opt/hostedtoolcache/Python/3.9.21/x64/lib/python3.9/site-packages (from Deprecated->pygithub->getorg) (1.17.2)\r\n",
|
73 |
| - "Requirement already satisfied: pycparser in /opt/hostedtoolcache/Python/3.9.21/x64/lib/python3.9/site-packages (from cffi>=1.4.1->pynacl>=1.4.0->pygithub->getorg) (2.22)\r\n" |
| 76 | + "Requirement already satisfied: pycparser in /opt/hostedtoolcache/Python/3.9.21/x64/lib/python3.9/site-packages (from cffi>=1.4.1->pynacl>=1.4.0->pygithub->getorg) (2.22)\r\n", |
| 77 | + "Downloading python_frontmatter-1.1.0-py3-none-any.whl (9.8 kB)\r\n" |
| 78 | + ] |
| 79 | + }, |
| 80 | + { |
| 81 | + "name": "stdout", |
| 82 | + "output_type": "stream", |
| 83 | + "text": [ |
| 84 | + "Installing collected packages: python-frontmatter\r\n" |
| 85 | + ] |
| 86 | + }, |
| 87 | + { |
| 88 | + "name": "stdout", |
| 89 | + "output_type": "stream", |
| 90 | + "text": [ |
| 91 | + "Successfully installed python-frontmatter-1.1.0\r\n" |
74 | 92 | ]
|
75 | 93 | },
|
76 | 94 | {
|
|
87 | 105 | ],
|
88 | 106 | "source": [
|
89 | 107 | "# Start by installing the dependencies\n",
|
90 |
| - "!pip install getorg --upgrade\n", |
| 108 | + "!pip install python-frontmatter getorg --upgrade\n", |
| 109 | + "import frontmatter\n", |
91 | 110 | "import glob\n",
|
92 | 111 | "import getorg\n",
|
93 | 112 | "from geopy import Nominatim"
|
|
99 | 118 | "metadata": {
|
100 | 119 | "collapsed": false,
|
101 | 120 | "execution": {
|
102 |
| - "iopub.execute_input": "2025-02-22T01:30:06.845946Z", |
103 |
| - "iopub.status.busy": "2025-02-22T01:30:06.845467Z", |
104 |
| - "iopub.status.idle": "2025-02-22T01:30:06.849121Z", |
105 |
| - "shell.execute_reply": "2025-02-22T01:30:06.848477Z" |
| 121 | + "iopub.execute_input": "2025-02-25T02:57:22.513776Z", |
| 122 | + "iopub.status.busy": "2025-02-25T02:57:22.513344Z", |
| 123 | + "iopub.status.idle": "2025-02-25T02:57:22.516648Z", |
| 124 | + "shell.execute_reply": "2025-02-25T02:57:22.516090Z" |
106 | 125 | }
|
107 | 126 | },
|
108 | 127 | "outputs": [],
|
|
117 | 136 | "metadata": {
|
118 | 137 | "collapsed": true,
|
119 | 138 | "execution": {
|
120 |
| - "iopub.execute_input": "2025-02-22T01:30:06.851364Z", |
121 |
| - "iopub.status.busy": "2025-02-22T01:30:06.850962Z", |
122 |
| - "iopub.status.idle": "2025-02-22T01:30:06.876444Z", |
123 |
| - "shell.execute_reply": "2025-02-22T01:30:06.875850Z" |
| 139 | + "iopub.execute_input": "2025-02-25T02:57:22.518622Z", |
| 140 | + "iopub.status.busy": "2025-02-25T02:57:22.518252Z", |
| 141 | + "iopub.status.idle": "2025-02-25T02:57:22.543417Z", |
| 142 | + "shell.execute_reply": "2025-02-25T02:57:22.542908Z" |
124 | 143 | }
|
125 | 144 | },
|
126 | 145 | "outputs": [],
|
|
139 | 158 | "metadata": {
|
140 | 159 | "collapsed": false,
|
141 | 160 | "execution": {
|
142 |
| - "iopub.execute_input": "2025-02-22T01:30:06.878925Z", |
143 |
| - "iopub.status.busy": "2025-02-22T01:30:06.878494Z", |
144 |
| - "iopub.status.idle": "2025-02-22T01:30:09.224074Z", |
145 |
| - "shell.execute_reply": "2025-02-22T01:30:09.223402Z" |
| 161 | + "iopub.execute_input": "2025-02-25T02:57:22.545540Z", |
| 162 | + "iopub.status.busy": "2025-02-25T02:57:22.545175Z", |
| 163 | + "iopub.status.idle": "2025-02-25T02:57:22.549637Z", |
| 164 | + "shell.execute_reply": "2025-02-25T02:57:22.549147Z" |
146 | 165 | }
|
147 | 166 | },
|
148 |
| - "outputs": [ |
149 |
| - { |
150 |
| - "name": "stdout", |
151 |
| - "output_type": "stream", |
152 |
| - "text": [ |
153 |
| - " \n", |
154 |
| - " None\n" |
155 |
| - ] |
156 |
| - }, |
157 |
| - { |
158 |
| - "name": "stdout", |
159 |
| - "output_type": "stream", |
160 |
| - "text": [ |
161 |
| - " \n", |
162 |
| - " None\n" |
163 |
| - ] |
164 |
| - } |
165 |
| - ], |
| 167 | + "outputs": [], |
166 | 168 | "source": [
|
167 | 169 | "# Perform geolocation\n",
|
168 | 170 | "for file in g:\n",
|
169 |
| - " with open(file, 'r') as f:\n", |
170 |
| - " lines = f.read()\n", |
171 |
| - " if lines.find('location: \"') > 1:\n", |
172 |
| - " loc_start = lines.find('location: \"') + 11\n", |
173 |
| - " lines_trim = lines[loc_start:]\n", |
174 |
| - " loc_end = lines_trim.find('\"')\n", |
175 |
| - " location = lines_trim[:loc_end]\n", |
176 |
| - " \n", |
177 |
| - " \n", |
178 |
| - " location_dict[location] = geocoder.geocode(location)\n", |
179 |
| - " print(location, \"\\n\", location_dict[location])\n" |
| 171 | + " # Read the file\n", |
| 172 | + " data = frontmatter.load(file)\n", |
| 173 | + " data = data.to_dict()\n", |
| 174 | + "\n", |
| 175 | + " # Press on if the location is not present\n", |
| 176 | + " if 'location' not in data:\n", |
| 177 | + " continue\n", |
| 178 | + "\n", |
| 179 | + " # Prepare the description\n", |
| 180 | + " title = data['title'].strip()\n", |
| 181 | + " venue = data['venue'].strip()\n", |
| 182 | + " location = data['location'].strip()\n", |
| 183 | + " description = f\"{title}\\n{venue}; {location}\"\n", |
| 184 | + " print(description)\n", |
| 185 | + "\n", |
| 186 | + " # Geocode the location and report the status\n", |
| 187 | + " location_dict[description] = geocoder.geocode(location)\n", |
| 188 | + " print(description, location_dict[description])" |
180 | 189 | ]
|
181 | 190 | },
|
182 | 191 | {
|
|
185 | 194 | "metadata": {
|
186 | 195 | "collapsed": false,
|
187 | 196 | "execution": {
|
188 |
| - "iopub.execute_input": "2025-02-22T01:30:09.226429Z", |
189 |
| - "iopub.status.busy": "2025-02-22T01:30:09.225951Z", |
190 |
| - "iopub.status.idle": "2025-02-22T01:30:09.233806Z", |
191 |
| - "shell.execute_reply": "2025-02-22T01:30:09.233240Z" |
| 197 | + "iopub.execute_input": "2025-02-25T02:57:22.551418Z", |
| 198 | + "iopub.status.busy": "2025-02-25T02:57:22.551243Z", |
| 199 | + "iopub.status.idle": "2025-02-25T02:57:22.558593Z", |
| 200 | + "shell.execute_reply": "2025-02-25T02:57:22.557942Z" |
192 | 201 | }
|
193 | 202 | },
|
194 | 203 | "outputs": [
|
|
0 commit comments