Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
yuhei maeda
committed
Jun 4, 2009
1 parent
3b6c19a
commit acec791
Showing
2 changed files
with
78 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,66 @@ | ||
#!/usr/bin/env python | ||
# -*- coding: utf-8 -*- | ||
# NAMESPACEにある関数名をlispで使えるように変換させます。 | ||
# NAMESPACEのexpoort()の括弧内にある関数名をコピーしてファイルを指定してから使ってください。 | ||
|
||
import re | ||
|
||
mer = [] | ||
f = open("D:\Rscript\ess\NAMESPACE") | ||
for line in f: | ||
line = line.strip() | ||
mer.append(line) | ||
f.close() | ||
|
||
out = "".join(mer) | ||
out = re.sub(" ","",out) | ||
out = re.sub('\"',"",out) | ||
out = re.sub(",","\" \"",out) | ||
out = re.sub("^""",'\"',out) | ||
out = re.sub("$""",'\"',out) | ||
import os | ||
import re | ||
|
||
filenamelist=[] | ||
|
||
for dpath,dname,filename in os.walk("/usr/lib/R/library"): | ||
###### | ||
for filename in filename: | ||
if filename == ("NAMESPACE"): | ||
fpath = os.path.join(dpath,filename) | ||
filenamelist.append(fpath) | ||
|
||
## for dpath,dname,filename in os.walk("/usr/lib/R/library"): | ||
## for filename in filename: | ||
## r =open(os.path.join(dpath,filename)) | ||
## for line in r: | ||
## print line | ||
|
||
mer=[] | ||
|
||
for file__ in filenamelist: | ||
f = open(file__) | ||
|
||
p1 = re.compile('export\(') | ||
frag = 0 | ||
strfrag = 0 | ||
|
||
for line in f: | ||
if line[0:6] == 'export' and ")" not in line : | ||
frag = 1 | ||
line = line.strip() | ||
line = p1.sub("",line) | ||
mer.append(line) | ||
elif line[0:6] == 'export' and ")" in line: | ||
frag= 0 | ||
line = line.strip() | ||
line = re.sub("\)",",",line) | ||
line = p1.sub("",line) | ||
mer.append(line) | ||
elif frag == 1 and ")" not in line and "#" not in line: | ||
line = line.strip() | ||
mer.append(line) | ||
|
||
elif frag == 1 and ")" in line and "#" not in line: | ||
frag = 0 | ||
line = line.strip() | ||
line = re.sub("\)",",",line) | ||
mer.append(line) | ||
|
||
elif frag == 1 and ")" not in line and "#" in line: | ||
frag = 1 | ||
|
||
elif frag == 1 and ")" in line and "#" in line: | ||
frag = 1 | ||
|
||
else: | ||
frag = 0 | ||
|
||
out = "".join(mer) | ||
out = re.sub(" ","",out) | ||
out = re.sub('\"',"",out) | ||
out = re.sub(",","\" \"",out) | ||
out = re.sub("^""",'\"',out) | ||
out = re.sub("$""",'\"',out) | ||
|
||
print out |