1
- # Last Updated | 2020-08-21
1
+ # Last Updated | 2020-08-24
2
2
# Python Modules
3
3
import os
4
4
import sys
5
5
import re
6
6
from typing import List
7
7
8
- sys .path .insert (1 , './manuscript-object/' )
9
-
10
8
# Third Party Modules
11
9
import pandas as pd
12
10
from datetime import datetime
25
23
'profession' : 'pro' , 'sensory' : 'sn' , 'tool' : 'tl' , 'time' : 'tmp' , 'weapon' : 'wp' ,
26
24
'german' : 'de' , 'greek' : 'el' , 'italian' : 'it' , 'latin' : 'la' , 'occitan' : 'oc' , 'poitevin' : 'po' ,}
27
25
28
- m_path = f'{ os .getcwd ()} '
26
+ manuscript_data_path = os .path .dirname (os .getcwd ()) + "/m-k-manuscript-data"
27
+ assert (os .path .exists (manuscript_data_path )), ("Could not find manuscript data directory: " + manuscript_data_path )
28
+ print ("Using manuscript data directory:" , manuscript_data_path )
29
29
30
30
def update_metadata (manuscript : BnF ) -> None :
31
31
"""
@@ -54,7 +54,7 @@ def update_metadata(manuscript: BnF) -> None:
54
54
# remove entry column, since it only displays memory address
55
55
df .drop (columns = ['entry' ], inplace = True )
56
56
57
- df .to_csv (f'{ m_path } /metadata/entry_metadata.csv' , index = False )
57
+ df .to_csv (f'{ manuscript_data_path } /metadata/entry_metadata.csv' , index = False )
58
58
59
59
def update_entries (manuscript : BnF ) -> None :
60
60
"""
@@ -67,13 +67,13 @@ def update_entries(manuscript: BnF) -> None:
67
67
None
68
68
"""
69
69
70
- for path in [f'{ m_path } /entries' , f'{ m_path } /entries/txt' , f'{ m_path } /entries/xml' ]:
70
+ for path in [f'{ manuscript_data_path } /entries' , f'{ manuscript_data_path } /entries/txt' , f'{ manuscript_data_path } /entries/xml' ]:
71
71
if not os .path .exists (path ):
72
72
os .mkdir (path )
73
73
74
74
for version in versions :
75
- txt_path = f'{ m_path } /entries/txt/{ version } '
76
- xml_path = f'{ m_path } /entries/xml/{ version } '
75
+ txt_path = f'{ manuscript_data_path } /entries/txt/{ version } '
76
+ xml_path = f'{ manuscript_data_path } /entries/xml/{ version } '
77
77
78
78
# If the entries/txt or xml directory does not exist, create it. Otherwise, clear the directory.
79
79
for path in [txt_path , xml_path ]:
@@ -121,7 +121,7 @@ def update_all_folios(manuscript: BnF) -> None:
121
121
text = f'{ text } \n \n { new_text } ' if text else new_text
122
122
123
123
# write file
124
- f = open (f'{ m_path } /allFolios/{ folder } /all_{ version } .{ folder } ' , 'w' )
124
+ f = open (f'{ manuscript_data_path } /allFolios/{ folder } /all_{ version } .{ folder } ' , 'w' )
125
125
f .write (text )
126
126
f .close ()
127
127
@@ -136,11 +136,11 @@ def update_ms(manuscript: BnF) -> None:
136
136
None
137
137
"""
138
138
for version in versions :
139
- for r , d , f in os .walk (f'{ m_path } /ms-xml/{ version } ' ):
139
+ for r , d , f in os .walk (f'{ manuscript_data_path } /ms-xml/{ version } ' ):
140
140
for filename in f : # iterate through /ms-xml/{version} folder
141
141
# read xml file
142
142
text = ''
143
- filepath = f'{ m_path } /ms-xml/{ version } /{ filename } '
143
+ filepath = f'{ manuscript_data_path } /ms-xml/{ version } /{ filename } '
144
144
with open (filepath , encoding = "utf-8" , errors = "surrogateescape" ) as f :
145
145
text = f .read ()
146
146
@@ -188,7 +188,7 @@ def update():
188
188
print ('Updating allFolios' )
189
189
update_all_folios (manuscript )
190
190
191
- update_time ()
191
+ # update_time()
192
192
193
193
if __name__ == "__main__" :
194
194
update ()
0 commit comments