Esempio n. 1
0
    def __init__(self):
        self.editor      = ok.readScriptrc().get("EDITOR")
        self.noteDir     = os.path.expanduser(ok.readScriptrc().get('NOTES_ROOT'))
        self.tocFileName = ok.readScriptrc().get('NOTES_TOC_FILE_NAME')
        self.notePattern = re.compile(r'.+\.ntx\Z')

        self.tocEntry        = 'note_toc'
        self.tocBoundary     = 78*'-'+'\n'
        self.sectionBoundary = 78*'='+'\n'
        self.tailBoundary    = 78*'_'+'\n'
        self.tailFormat      = ' vim:tw=78:ts=8:ft=help:norl:'

        self.tagPattern   = re.compile(r'^[*](?P<tag>\w+)[*]')
        self.entryPattern = re.compile(r'^[|](?P<tag>\w+)[|]')
        self.tocPattern   = re.compile(r'^(\|(?P<tag>\w+)\|)?\s*(?P<title>.+)\s*',re.UNICODE)

        self.notes = [note for note in os.listdir(self.noteDir) \
                if self.notePattern.match(note)]
Esempio n. 2
0
    def __init__(self):
        self.dbDir    = ok.readScriptrc().get('TEX_DB_ROOT')
        self.dbFile   = 'texdb.she'
        self.template = 'main.tex'

        self.texCls   = ['article']
        self.pack     = ['CJKutf8','indentfirst','hyperref','hypcap','xcolor']
        self.setting  = ['stretchLine','pagecolor','title']
        self.color    = ['LightSteelBlue2','cyan4','red2','blue2','green4']
        self.body     = ['beginDoc','beginCJK','maketitle','toc','newpage','empty','newpage','endCJK','endDoc']
Esempio n. 3
0
    def exportTex(self, part):
        texAll = []

        clsDir = ok.readScriptrc().get("TEX_CLS_ROOT")
        if clsDir == None:
            err = "variable TEX_CLS_ROOT not set in ~/.scriptrc! Exit..."
            print >> sys.stderr, err
            sys.exit(1)
        clsDir = os.path.expanduser(clsDir)
        if clsDir[-1] == '/':
            clsDir = clsDir[:-1]

        texHead = r"""\documentclass{""" + clsDir + r"""/pseudocode}
\usepackage{imakeidx}
\usepackage{hyperref}
\makeindex[program=xindy,columns=3,intoc,columnseprule]
\hypersetup{
colorlinks,
citecolor=cyan4,
filecolor=blue2,
linkcolor=red2,
urlcolor=green4
}

\begin{document}
\maketitle
\tableofcontents
\newpage

"""
        texAll.append(texHead)

        texBody = []
        part2tex(texBody, part)  # get texBody
        texAll += texBody

        texTail = r"""
\bigskip
\clearpage
\addcontentsline{toc}{section}{参考文献}
\bibliography{pseudocode}
\printindex
\end{document}"""
        texAll.append('\n' + texTail)

        filename = self.mainName + '.tex'
        f = open(filename, 'w')
        f.writelines(texAll)
        f.close()
Esempio n. 4
0
    def exportTex(self,part):
        texAll = []

        clsDir = ok.readScriptrc().get("TEX_CLS_ROOT")
        if clsDir == None:
            err = "variable TEX_CLS_ROOT not set in ~/.scriptrc! Exit..."
            print >> sys.stderr, err
            sys.exit(1)
        clsDir = os.path.expanduser(clsDir)
        if clsDir[-1] == '/':
            clsDir = clsDir[:-1]

        texHead = r"""\documentclass{"""+clsDir+r"""/pseudocode}
\usepackage{imakeidx}
\usepackage{hyperref}
\makeindex[program=xindy,columns=3,intoc,columnseprule]
\hypersetup{
colorlinks,
citecolor=cyan4,
filecolor=blue2,
linkcolor=red2,
urlcolor=green4
}

\begin{document}
\maketitle
\tableofcontents
\newpage

"""
        texAll.append(texHead)

        texBody = []
        part2tex(texBody,part) # get texBody
        texAll += texBody

        texTail = r"""
\bigskip
\clearpage
\addcontentsline{toc}{section}{参考文献}
\bibliography{pseudocode}
\printindex
\end{document}"""
        texAll.append('\n'+texTail)

        filename = self.mainName + '.tex'
        f = open(filename,'w')
        f.writelines(texAll)
        f.close()
Esempio n. 5
0
#!/usr/bin/python
"""
        File: backup.py
 Description: backup file(s) with a time suffix to the specified directory

       Usage: backup.py file1 [file2] [file3] ...

      Author: OU Yuyuan <*****@*****.**>
     Created: Tue Apr 24 12:22:01 UTC+8 2012
 Last Change: Wed Jun 13 08:39:20 UTC+8 2012#
"""

import sys,os,time
import otweak as ok

backup_dir = ok.readScriptrc().get("BACKUP_ROOT")
if backup_dir[-1] != '/':
    backup_dir += '/'
src_files  = sys.argv[1:]            # files to be backup
max_length = max(map(len,src_files)) # get max length of file names

print(" backup the following file(s) to directory: " + backup_dir)
for file_name in src_files:
    time_suffix =\
    time.strftime('%Y-%m-%d-%X',time.localtime(os.path.getmtime(file_name)))
    backup_file = file_name + '.' + time_suffix

    if file_name[0] == '.':          # change hidden file to visible
        backup_file = file_name[1:] + '.' + time_suffix

    add_space = (max_length-len(file_name))*' '