Skip to content

Commit b0af470

Browse files
committed
Add timestamps to all pages
1 parent 1e2ed59 commit b0af470

File tree

2 files changed

+187
-5
lines changed

2 files changed

+187
-5
lines changed

build.py

Lines changed: 48 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import re
1010
import os
1111
import argparse
12+
import datetime
1213
import subprocess
1314
import shutil
1415
import lxml.html
@@ -170,6 +171,7 @@ def generate_files(dst_path):
170171
tags = {}
171172

172173
legacy_editors = parse_wiki_legacy_users()
174+
created, modified = parse_wiki_legacy_timestamps()
173175

174176
for fn in sorted(os.listdir('ipython')):
175177
if not fn.endswith('.ipynb'):
@@ -181,24 +183,33 @@ def generate_files(dst_path):
181183
editors = list(legacy_editors.get(basename, []))
182184

183185
# Get names from Git
184-
p = subprocess.Popen(['git', 'log', '--format=%an', 'ef45029096..', fn],
186+
created_stamp = created.get(basename, 0)
187+
modified_stamp = modified.get(basename, created_stamp)
188+
p = subprocess.Popen(['git', 'log', '--format=%at:%an', 'ef45029096..', fn],
185189
stdout=subprocess.PIPE)
186190
names, _ = p.communicate()
187191
for name in names.splitlines():
188-
name = name.strip()
192+
timestamp, name = name.strip().split(':', 1)
193+
timestamp = int(timestamp)
189194
if name and name not in editors:
190195
editors.append(name)
196+
if created_stamp is None:
197+
created_stamp = timestamp
198+
if timestamp > modified_stamp:
199+
modified_stamp = timestamp
191200

192201
# Continue
193-
title, tagset = convert_file(dst_path, fn, editors)
202+
title, tagset = convert_file(dst_path, fn, editors,
203+
created_stamp,
204+
modified_stamp)
194205
titles[basename] = title
195206
if tagset:
196207
tags[basename] = tagset
197208

198209
return titles, tags
199210

200211

201-
def convert_file(dst_path, fn, editors):
212+
def convert_file(dst_path, fn, editors, created, modified):
202213
"""
203214
Convert .ipynb to .rst, placing output under `dst_path`
204215
@@ -288,8 +299,23 @@ def convert_file(dst_path, fn, editors):
288299
if not title:
289300
title = basename
290301

302+
updateinfo = ""
303+
304+
def fmt_time(timestamp):
305+
return datetime.datetime.fromtimestamp(timestamp).strftime('%Y-%m-%d')
306+
307+
if created != 0 and modified != 0:
308+
updateinfo = ":Date: {0} (last modified), {1} (created)".format(fmt_time(modified),
309+
fmt_time(created))
310+
elif created != 0:
311+
updateinfo = ":Date: {0} (created)".format(fmt_time(created))
312+
elif modified != 0:
313+
updateinfo = ":Date: {0} (last modified)".format(fmt_time(modified))
314+
291315
authors = ", ".join(editors)
292-
text = "{0}\n{1}\n\n{2}".format(title, "="*len(title), text)
316+
text = "{0}\n{1}\n\n{2}\n\n{3}".format(title, "="*len(title),
317+
updateinfo,
318+
text)
293319

294320
with open(rst_fn, 'w') as f:
295321
f.write(text)
@@ -371,5 +397,22 @@ def parse_wiki_legacy_users():
371397
return items
372398

373399

400+
def parse_wiki_legacy_timestamps():
401+
created = {}
402+
modified = {}
403+
404+
with open('wiki-legacy-timestamps.txt', 'r') as f:
405+
for line in f:
406+
line = line.strip()
407+
if not line or line.startswith('#'):
408+
continue
409+
410+
page, c, m = line.split()
411+
created[page] = int(c)
412+
modified[page] = int(m)
413+
414+
return created, modified
415+
416+
374417
if __name__ == "__main__":
375418
main()

wiki-legacy-timestamps.txt

Lines changed: 139 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,139 @@
1+
# legacy (read-only) timestamps from the old wiki
2+
# page created last_modified
3+
AccumarrayLike 1270050836 1270051227
4+
A_Numerical_Agnostic_Pyrex_Class 1143620426 1162632919
5+
ApplyFIRFilter 1307335662 1336252641
6+
ArrayStruct_and_Pyrex 1136516287 1195412846
7+
BrownianMotion 1263769598 1264364601
8+
BuildingArrays 1139337022 1273235140
9+
ButterworthBandpass 1346686589 1346687146
10+
C_Extensions 1146215389 1165615566
11+
C_Extensions_NumPy_arrays 1165610136 1277026979
12+
CommTheory 1244319793 1244323480
13+
CompilingExtensionsOnWindowsWithMinGW 1196098330 1212193254
14+
CorrelatedRandomSamples 1274673641 1313457109
15+
CoupledSpringMassSystem 1232510671 1352300465
16+
Ctypes 1146869119 1321311389
17+
Data_Acquisition_with_NIDAQmx 1182015422 1257426482
18+
Data_Acquisition_with_PyUL 1162836440 1182015526
19+
DataFrame 1158133950 1348862786
20+
dbase 1168156158 1169186114
21+
EmbeddingInTraitsGUI 1231239133 1233218798
22+
EyeDiagram 1328387425 1328395795
23+
F2Py 1140739297 1320919020
24+
f2py_and_NumPy 1140248952 1155559543
25+
FiltFilt 1162339211 1321937693
26+
Finding_Convex_Hull 1187224567 1187224775
27+
Finding_Convex_Hull_Minimum_Point 1259541737 1259728654
28+
FIRFilter 1282871091 1307336232
29+
FittingData 1158802921 1321118212
30+
FortranIO 1207339235 1233529897
31+
FortranIO_FortranFile 1233521760 1257786619
32+
FrequencySweptDemo 1276985350 1305768883
33+
GameOfLifeStrides 1287423409 1287423952
34+
hdf5_in_Matlab 1184923310 1240920561
35+
Histograms 1364291593 136560379
36+
Histograms 1364291593 1365603797
37+
Indexing 1212289325 1212724768
38+
InputOutput 1148150817 1321562944
39+
Interpolation 1138520665 1178226727
40+
Intersection 1249066092 1249066388
41+
KalmanFiltering 1153702161 1153702376
42+
KDTree_example 1222208882 1300954367
43+
KdV 1283809834 1298395943
44+
LASReader 1303441238 1303480214
45+
Least_Squares_Circle 1300572242 1300824517
46+
LinearClassification 1306632239 1306641946
47+
LinearRegression 1139159780 1156206775
48+
LineIntegralConvolution 1227018426 1227019747
49+
LoktaVolterraTutorial 1194799996 1303675500
50+
Matplotlib_AdjustingImageSize 1137963333 1316810855
51+
Matplotlib_Animations 1137958878 1336916269
52+
Matplotlib_Arrows 1196972807 1196972822
53+
Matplotlib_BarCharts 1155134417 1199372577
54+
Matplotlib_ColormapTransformations 1159391838 1351000722
55+
Matplotlib_CompilingMatPlotLibOnSolaris10 1137963532 1231625249
56+
Matplotlib_converting_a_matrix_to_a_raster_image 1152489987 1235647824
57+
Matplotlib_CustomLogLabels 1221615498 1221615517
58+
Matplotlib_DeletingAnExistingDataSeries 1163106346 1163106346
59+
Matplotlib_Django 1167765530 1310514509
60+
Matplotlib_Drag_n_Drop_Text_Example 1202062808 1202067463
61+
Matplotlib_EmbeddingInWx 1137960889 1145507936
62+
Matplotlib_Gridding_irregularly_spaced_data 1137963607 1315401790
63+
Matplotlib_HintonDiagrams 1242338418 1269975519
64+
Matplotlib_Interactive_Plotting 1137961690 1263714652
65+
Matplotlib_LaTeX_Examples 1147341647 1313230898
66+
Matplotlib_Legend 1176303943 1320860300
67+
Matplotlib_LoadImage 1160497971 1228731148
68+
Matplotlib_Loading_a_colormap_dynamically 1137961467 1137961467
69+
Matplotlib_Maps 1137960341 1293521348
70+
Matplotlib_Matplotlib_and_Zope 1137961817 1165253482
71+
Matplotlib_mplot3D 1140184229 1269978619
72+
Matplotlib_MulticoloredLine 1137959990 1269199599
73+
Matplotlib_MultilinePlots 1137959546 1143987197
74+
Matplotlib_Multiple_Subplots_with_One_Axis_Label 1206043275 1340224415
75+
Matplotlib_Plotting_Images_with_Special_Values 1137963933 1137963969
76+
Matplotlib_Plotting_values_with_masked_arrays 1137962925 1296531834
77+
Matplotlib_PySide 1309989072 1339334707
78+
Matplotlib_Qt_with_IPython_and_Designer 1137962518 1321067775
79+
Matplotlib_ScrollingPlot 1262531491 1262531566
80+
Matplotlib_ShadedRegions 1196972673 1196972706
81+
Matplotlib_Show_colormaps 1137963050 1338984581
82+
Matplotlib_SigmoidalFunctions 1137957344 1139447913
83+
Matplotlib_ThickAxes 1228249817 1228249859
84+
Matplotlib_Transformations 1137961982 1276706894
85+
Matplotlib_TreeMap 1154198496 1198183983
86+
Matplotlib_UnfilledHistograms 1196973254 1246488470
87+
Matplotlib_Using_MatPlotLib_in_a_CGI_script 1137963744 1162615011
88+
Matplotlib_UsingTex 1137957543 1228360748
89+
Matplotlib_VTK_Integration 1137959200 1258476599
90+
MayaVi 1140431111 1303143334
91+
MayaVi_examples 1150746578 1150746629
92+
MayaVi_InstallPythonStuffFromSource 1161810617 1169405542
93+
MayaVi_mlab 1140532310 1303143461
94+
MayaVi_RunningMayavi2 1165185272 1185322546
95+
MayaVi_ScriptingMayavi2 1150752532 1218063911
96+
MayaVi_ScriptingMayavi2_BasicModules 1186749326 1186962427
97+
MayaVi_ScriptingMayavi2_Filters 1186749847 1186962506
98+
MayaVi_ScriptingMayavi2_MainModules 1186750133 1186962471
99+
MayaVi_Surf 1165221358 1171954568
100+
MayaVi_Tips 1150217569 1190106346
101+
MayaVi_tvtk 1140432532 1303143526
102+
MetaArray 1204762689 1312548740
103+
MultiDot 1174771230 1174771932
104+
Multithreading 1176916424 1206212596
105+
Obarray 1211057345 1211057423
106+
OLS 1169063267 1280950651
107+
OptimizationAndFitDemo1 1139546487 1308309455
108+
OptimizationDemo1 1139545956 1247510028
109+
ParallelProgramming 1206030381 1228421724
110+
ParticleFilter 1223464932 1321852301
111+
PerformancePython 1143135322 1308657992
112+
PIL_example 1156065609 1162387903
113+
Pyrex_and_NumPy 1136531236 1207706461
114+
RadialBasisFunctions 1170935668 1227190366
115+
RankNullspace 1315964972 1315964972
116+
RANSAC 1177314536 1241898262
117+
Reading_Custom_Text_Files_with_Pyparsing 1269368702 1270884812
118+
Reading_mat_files 1207121396 1245975608
119+
Reading_SPE_files 1239645903 1291379106
120+
Rebinning 1143463011 1180224841
121+
Recarray 1214546389 1268174841
122+
SavitzkyGolay 1173199465 1346959487
123+
SchrodingerFDTD 1185658828 1209755338
124+
SegmentAxis 1202256055 1202256223
125+
SignalSmooth 1162336633 1340544898
126+
Solving_Large_Markov_Chains 1230496843 1230500462
127+
SphericalBesselZeros 1178018504 1207509638
128+
SWIG_and_NumPy 1139394650 1169639407
129+
SWIG_Memory_Deallocation 1230655259 1335089210
130+
SWIG_NumPy_examples 1230731512 1249972395
131+
Theoretical_Ecology_Hastings_and_Powell 1179175224 1299652648
132+
TimeSeries_FAQ 1207697902 1228474476
133+
ViewsVsCopies 1201778624 1235279610
134+
vtkVolumeRendering 1234826895 1283934322
135+
Watershed 1246199486 1248184483
136+
Weave 1212015768 1312549720
137+
wxPython_dialogs 1161034186 1225701042
138+
xplt 1138840718 1138841258
139+
Zombie_Apocalypse_ODEINT 1303675792 1303675885

0 commit comments

Comments
 (0)