Skip to content

Commit

Permalink
add python script
Browse files Browse the repository at this point in the history
  • Loading branch information
yuhei maeda committed Jun 4, 2009
1 parent 3b6c19a commit acec791
Show file tree
Hide file tree
Showing 2 changed files with 78 additions and 23 deletions.
15 changes: 12 additions & 3 deletions auto-complete-acr.el 100644 → 100755
Expand Up @@ -7,8 +7,9 @@
;; Copyright (C) 2009, myuhe , all rights reserved.
;; Created: 2009-04-13
;; Version: 0.1
;; Last-Updated: 2009-04-13 14:25:33
;; URL: http://github.com/myuhe/auto-complete-acr.el/blob/23e4295bdaa177efac5a4f9020ab5f86e7a11f2b/auto-complete-acr.el
;; Last-Updated: 2009-03-01 14:25:33
;; By: Yen-Chin,Lee
;; URL: http://www.emacswiki.org/emacs/download/auto-complete-octave.el
;; Keywords: auto-complete
;; Compatibility: GNU Emacs 23.0.91
;;
Expand Down Expand Up @@ -39,6 +40,7 @@
;;; Installation:
;;
;; Put auto-complete-acr.el to your load-path.
;; The load-path is usually ~/elisp/.
;; It's set in your ~/.emacs like this:


Expand All @@ -49,7 +51,7 @@
;;

;;; Acknowledgements:
;; I refered and hacked auto-complete-octave.el(http://www.emacswiki.org/emacs/auto-complete-octave.el)
;; I refered and hacked auto-complete-acr.el(http://www.emacswiki.org/emacs/auto-complete-octave.el)
;; thanks Yen-Chin,Lee!!
;;

Expand All @@ -66,6 +68,7 @@
;;; Code:
(defconst acr-keywords
(sort (list
;;;NAMESPACE:stats
"add.scope" "add1" "addmargins" "aggregate" "aggregate.data.frame" "testaggregate.default"
"aggregate.ts" "AIC" "alias" "anova" "anova.glm" "testanova.glmlist" "anova.lm" "anova.lmlist"
"anova.mlm" "aov" "approx" "testapproxfun" "as.formula" "as.ts" "ave"
Expand Down Expand Up @@ -120,6 +123,12 @@
"var" "testvariable.names" "vcov"
"weighted.mean" "weighted.residuals" "testweights" "window" "window<-" "write.ftable"
"xtabs" "pbirthday" "testqbirthdaytest"
;;;NAMESPACE:base
"Bessel" "Defunct" "Deprecated" "LAPACK" "New-Internal" "Scripts" "TAOCP" "all.equal" "allnames" "aperm" "append" "apply" "array" "as" "assign" "attach" "attr" "autoload" "backquote" "backsolve" "bindenv" "builtins"
"by" "callCC" "cat" "character" "chol" "colSums" "conditions" "conflicts" "connections" "constants" "contributors" "converters" "cut" "data.matrix" "dataframe" "dates" "datetime" "dcf" "debug" "delay" "det" "diag" "diff" "dput" "dump" "duplicated" "dynload" "eapply" "eigen" "environment" "eval" "eval~" "exists" "expand.grid" "factor" "files" "findInt" "formals" "format" "frametools" "funprog" "get" "getenv"
"gl" "grep" "identical" "ifelse" "interaction" "is" "jitter" "kappa" "kronecker" "labels" "lapply" "lazyload" "library" "license" "load" "locales" "lower.tri" "mapply" "match" "match.fun" "matrix" "max.col" "mean" "merge" "message" "methodsSupport" "mode" "namespace" "notyet" "options" "outer" "pairlist" "parse" "paste" "pmax"
"pretty" "print" "qr" "quit" "range" "rank" "raw" "rep" "replace" "replicate" "rev" "rle" "rm" "rowsum" "sample" "sapply" "scale" "scan" "seq" "serialize" "sets" "sink" "solve" "sort" "source" "split" "srcfile" "stop" "structure" "strwrap" "summary" "svd" "sweep" "switch" "sys" "table" "tabulate" "tapply" "taskCallback" "temp"
"time" "toString" "traceback" "unix" "unlist" "unname" "upper.tri" "userhooks" "utilities" "utils" "vector" "version" "warnings" "which" "windows" "withVisible" "write" "xor" "zapsmall" "zdatetime" "zdynvars" "zzz"
) #'(lambda (a b) (< (length a) (length b)))))

(defvar ac-source-acr
Expand Down
86 changes: 66 additions & 20 deletions ess.py
@@ -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

0 comments on commit acec791

Please sign in to comment.