25
25
26
26
import fileinput , re , os , sys , operator , math
27
27
28
+ # The directory in which this file resides.
29
+ fdir = os .path .dirname (os .path .realpath (__file__ )) + "/"
30
+
28
31
preamble = '''// Copyright 2012-2016 The Rust Project Developers. See the COPYRIGHT
29
32
// file at the top-level directory of this distribution and at
30
33
// http://rust-lang.org/COPYRIGHT.
61
64
surrogate_codepoints = (0xd800 , 0xdfff )
62
65
63
66
def fetch (f ):
64
- if not os .path .exists (os .path .basename (f )):
67
+ path = fdir + os .path .basename (f )
68
+ if not os .path .exists (path ):
65
69
os .system ("curl -O http://www.unicode.org/Public/UNIDATA/%s"
66
70
% f )
67
71
68
- if not os .path .exists (os . path . basename ( f ) ):
72
+ if not os .path .exists (path ):
69
73
sys .stderr .write ("cannot load %s" % f )
70
74
exit (1 )
71
75
@@ -84,7 +88,7 @@ def load_unicode_data(f):
84
88
85
89
udict = {}
86
90
range_start = - 1
87
- for line in fileinput .input (f ):
91
+ for line in fileinput .input (fdir + f ):
88
92
data = line .split (';' )
89
93
if len (data ) != 15 :
90
94
continue
@@ -156,7 +160,7 @@ def load_unicode_data(f):
156
160
157
161
def load_special_casing (f , to_upper , to_lower , to_title ):
158
162
fetch (f )
159
- for line in fileinput .input (f ):
163
+ for line in fileinput .input (fdir + f ):
160
164
data = line .split ('#' )[0 ].split (';' )
161
165
if len (data ) == 5 :
162
166
code , lower , title , upper , _comment = data
@@ -243,7 +247,7 @@ def load_properties(f, interestingprops):
243
247
re1 = re .compile ("^ *([0-9A-F]+) *; *(\w+)" )
244
248
re2 = re .compile ("^ *([0-9A-F]+)\.\.([0-9A-F]+) *; *(\w+)" )
245
249
246
- for line in fileinput .input (os .path .basename (f )):
250
+ for line in fileinput .input (fdir + os .path .basename (f )):
247
251
prop = None
248
252
d_lo = 0
249
253
d_hi = 0
@@ -456,7 +460,7 @@ def emit_norm_module(f, canon, compat, combine, norm_props):
456
460
canon_comp_keys = sorted (canon_comp .keys ())
457
461
458
462
if __name__ == "__main__" :
459
- r = "tables.rs"
463
+ r = fdir + "tables.rs"
460
464
if os .path .exists (r ):
461
465
os .remove (r )
462
466
with open (r , "w" ) as rf :
@@ -465,7 +469,7 @@ def emit_norm_module(f, canon, compat, combine, norm_props):
465
469
466
470
# download and parse all the data
467
471
fetch ("ReadMe.txt" )
468
- with open ("ReadMe.txt" ) as readme :
472
+ with open (fdir + "ReadMe.txt" ) as readme :
469
473
pattern = "for Version (\d+)\.(\d+)\.(\d+) of the Unicode"
470
474
unicode_version = re .search (pattern , readme .read ()).groups ()
471
475
rf .write ("""
0 commit comments