当前位置: 首页>>代码示例>>Python>>正文


Python migutil.opj函数代码示例

本文整理汇总了Python中MoinMoin.script.migration.migutil.opj函数的典型用法代码示例。如果您正苦于以下问题:Python opj函数的具体用法?Python opj怎么用?Python opj使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了opj函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: gather_pagedirs

def gather_pagedirs(dir_from):
    """ this gathers edit-log information from the pagedirs, just to make sure
    """
    pagedir = opj(dir_from, 'pages')
    pagelist = listdir(pagedir)
    for pagename in pagelist:
        editlog_from = opj(pagedir, pagename, 'edit-log')
        gather_editlog(editlog_from, pagename)
开发者ID:Kartstig,项目名称:engineering-inventions-wiki,代码行数:8,代码来源:12_to_13_mig08.py

示例2: remove_trash

def remove_trash(dir_from):
    for pagename in info:
        # omit dead pages and MoinEditorBackup
        if pagename in pagelist and (
           os.path.exists(opj(dir_from, pagename, 'text')) or
           os.path.exists(opj(dir_from, pagename, 'backup'))
           ) and not pagename.endswith('MoinEditorBackup'):
            info2[pagename] = info[pagename]
开发者ID:imosts,项目名称:flume,代码行数:8,代码来源:12_to_13_mig05.py

示例3: convert_pagedir

def convert_pagedir(dir_from, dir_to):
    os.mkdir(dir_to)
    for dname_from in listdir(dir_from):
        print "%s" % (dname_from, )
        dname_to = dname_from
        shutil.copytree(opj(dir_from, dname_from), opj(dir_to, dname_to), 1)
        try:
            os.remove(opj(dir_to, dname_to, 'last-edited'))
        except: pass
开发者ID:Glottotopia,项目名称:aagd,代码行数:9,代码来源:12_to_13_mig03.py

示例4: __init__

 def __init__(self, request, src_data_dir, dest_data_dir):
     self.request = request
     self.sdata = src_data_dir
     self.ddata = dest_data_dir
     self.pages = {}
     self.users = {}
     self.complete = {}
     self.renames = {}
     self.complete_fname = opj(self.sdata, 'complete.txt')
     self.rename_fname1 = opj(self.sdata, 'rename1.txt')
     self.rename_fname2 = opj(self.sdata, 'rename2.txt')
开发者ID:Opngate,项目名称:moinmoin,代码行数:11,代码来源:_conv160a.py

示例5: convert_userdir

def convert_userdir(dir_from, dir_to):
    os.mkdir(dir_to)
    for fname in listdir(dir_from):
        if fname.endswith('.bookmark'):
            bm = open(opj(dir_from, fname)).read().strip()
            bm = str(wikiutil.timestamp2version(float(bm)))
            f = open(opj(dir_to, fname), 'w')
            f.write(bm)
            f.close()
        else:
            copy_file(opj(dir_from, fname), opj(dir_to, fname))
开发者ID:Glottotopia,项目名称:aagd,代码行数:11,代码来源:12_to_13_mig04.py

示例6: convert_pagedir

def convert_pagedir(dir_from, dir_to, enc_from, enc_to):
    os.mkdir(dir_to)
    for dname_from in listdir(dir_from):
        dname_to = qf_convert_string(dname_from, enc_from, enc_to)
        print "%s -> %s" % (dname_from, dname_to)
        shutil.copytree(opj(dir_from, dname_from), opj(dir_to, dname_to), 1)
        try:
            convert_editlog(opj(dir_from, dname_from, 'last-edited'),
                            opj(dir_to, dname_to, 'last-edited'),
                            enc_from, enc_to)
        except IOError:
            pass # we ignore if it doesnt exist
开发者ID:Kartstig,项目名称:engineering-inventions-wiki,代码行数:12,代码来源:12_to_13_mig02.py

示例7: write

    def write(self, pages_dir):
        """ write a page, including revisions, log, attachments to disk """
        if ('PAGE', self.name) in self.renames:
            name_new = self.renames[('PAGE', self.name)]
            if name_new != self.name:
                print "Renaming page %r -> %r" % (self.name, name_new)
                self.name_old = self.name
                self.name = name_new
        qpagename = wikiutil.quoteWikinameFS(self.name)
        page_dir = opj(pages_dir, qpagename)
        os.makedirs(page_dir)
        # write current file
        current = self.current
        if current is not None:
            if create_rev and not self.is_deleted:
                current += 1
            current_fname = opj(page_dir, 'current')
            current_file = file(current_fname, "w")
            current_str = '%08d\n' % current
            current_file.write(current_str)
            current_file.close()
        # copy edit-log
        if self.editlog is not None:
            editlog_fname = opj(page_dir, 'edit-log')
            self.editlog.copy(editlog_fname, self.renames, deleted=self.is_deleted)
        # copy page revisions
        if self.revisions is not None:
            rev_dir = opj(page_dir, 'revisions')
            os.makedirs(rev_dir)
            for rev in self.revlist:
                if create_rev:
                    self.revisions[rev].copy(rev_dir, self.renames)
                else:
                    if int(rev) == self.current:
                        self.revisions[rev].copy(rev_dir, self.renames, convert=True)
                    else:
                        self.revisions[rev].copy(rev_dir, self.renames)
            if create_rev and not self.is_deleted:
                self.revisions[rev].copy(rev_dir, self.renames, convert=True, new_rev=rev+1)

        # copy attachments
        if self.attachments is not None:
            attach_dir = opj(page_dir, 'attachments')
            os.makedirs(attach_dir)
            for fn, att in self.attachments.items():
                # we have to check for renames here because we need the (old) pagename, too:
                if ('FILE', self.name_old, fn) in self.renames:
                    fn_new = self.renames[('FILE', self.name_old, fn)]
                    if fn_new != fn:
                        print "Renaming file %r %r -> %r" % (self.name_old, fn, fn_new)
                        att.name = fn_new
                att.copy(attach_dir)
开发者ID:Opngate,项目名称:moinmoin,代码行数:52,代码来源:_conv160a.py

示例8: convert_textdir

def convert_textdir(dir_from, dir_to, enc_from, enc_to, is_backupdir=0):
    os.mkdir(dir_to)
    for fname_from in listdir(dir_from):
        if is_backupdir:
            fname, timestamp = fname_from.split('.')
        else:
            fname = fname_from
        fname = qf_convert_string(fname, enc_from, enc_to)
        if is_backupdir:
            fname_to = '.'.join([fname, timestamp])
        else:
            fname_to = fname
        convert_file(opj(dir_from, fname_from), opj(dir_to, fname_to),
                     enc_from, enc_to)
开发者ID:Kartstig,项目名称:engineering-inventions-wiki,代码行数:14,代码来源:12_to_13_mig02.py

示例9: write

 def write(self, users_dir):
     """ write profile and bookmarks data to disk """
     fname = opj(users_dir, self.uid)
     f = codecs.open(fname, "w", config.charset)
     for key, value in self.profile.items():
         if key in (u"subscribed_pages", u"quicklinks"):
             pages = value.split(u"\t")
             for i in range(len(pages)):
                 pagename = pages[i]
                 try:
                     interwiki, pagename = pagename.split(u":", 1)
                 except:
                     interwiki, pagename = u"Self", pagename
                 if interwiki == u"Self" or interwiki == self.request.cfg.interwikiname:
                     if ("PAGE", pagename) in self.renames:
                         pagename = self.renames[("PAGE", pagename)]
                         pages[i] = u"%s:%s" % (interwiki, pagename)
             key += "[]"  # we have lists here
             value = u"\t".join(pages)
             f.write(u"%s=%s\n" % (key, value))
         else:
             f.write(u"%s=%s\n" % (key, value))
     bookmark_entries = [u"%s:%s" % item for item in self.bookmarks.items()]
     key = u"bookmarks{}"
     value = u"\t".join(bookmark_entries)
     f.write(u"%s=%s\n" % (key, value))
     f.close()
开发者ID:Opngate,项目名称:moinmoin,代码行数:27,代码来源:_conv160.py

示例10: read

 def read(self):
     fname = opj(self.rev_dir, '%08d' % self.rev)
     f = file(fname, "rb")
     data = f.read()
     f.close()
     data = data.decode(config.charset)
     return data
开发者ID:Opngate,项目名称:moinmoin,代码行数:7,代码来源:_conv160a.py

示例11: execute

def execute(script, data_dir, rev):
    plugindir = opj(data_dir, 'plugin')
    for d in ['filter', ]:
        thisdir = opj(plugindir, d)
        makedir(thisdir)
        fname = opj(thisdir, '__init__.py')
        f = open(fname, 'w')
        f.write("""\
# -*- coding: iso-8859-1 -*-

from MoinMoin.util import pysupport

modules = pysupport.getPackageModules(__file__)
""")
        f.close()
    return rev + 1
开发者ID:Kartstig,项目名称:engineering-inventions-wiki,代码行数:16,代码来源:1050300.py

示例12: write_dest

    def write_dest(self):
        self.init_dest()
        # copy pages
        pages_dir = opj(self.ddata, 'pages')
        for pn, page in self.pages.items():
            if pn.endswith('/MoinEditorBackup'):
                continue # we don't care for old editor backups
            page.copy(pages_dir, self.renames)

        # copy users
        users_dir = opj(self.ddata, 'user')
        for user in self.users.values():
            user.copy(users_dir, self.renames)

        # copy logs
        self.editlog.copy(opj(self.ddata, 'edit-log'), self.renames)
        self.eventlog.copy(opj(self.ddata, 'event-log'), self.renames)
开发者ID:Opngate,项目名称:moinmoin,代码行数:17,代码来源:_conv160a.py

示例13: read_src

    def read_src(self):
        # create Page objects in memory
        pages_dir = opj(self.sdata, 'pages')
        pagelist = listdir(pages_dir)
        for qpagename in pagelist:
            p = Page(self.request, pages_dir, qpagename)
            self.pages[p.name] = p

        # create User objects in memory
        users_dir = opj(self.sdata, 'user')
        user_re = re.compile(r'^\d+\.\d+(\.\d+)?$')
        userlist = listdir(users_dir)
        userlist = [f for f in userlist if user_re.match(f)]
        for userid in userlist:
            u = User(self.request, users_dir, userid)
            self.users[u.uid] = u

        # create log objects in memory
        self.editlog = EditLog(self.request, opj(self.sdata, 'edit-log'))
        self.eventlog = EventLog(self.request, opj(self.sdata, 'event-log'))
开发者ID:Opngate,项目名称:moinmoin,代码行数:20,代码来源:_conv160a.py

示例14: migrate

def migrate(dir_to):
    """ this removes edit-lock files from the pagedirs and
        converts attachment filenames
    """
    pagesdir = opj(dir_to, 'pages')
    pagelist = listdir(pagesdir)
    for pagename in pagelist:
        pagedir = opj(pagesdir, pagename)
        editlock = opj(pagedir, 'edit-lock')
        try:
            os.remove(editlock)
        except:
            pass

        attachdir = os.path.join(pagedir, 'attachments')
        for root, dirs, files in os.walk(attachdir):
            for f in  files:
                try:
                    f.decode(to_encoding)
                except UnicodeDecodeError:
                    fnew = f.decode(from_encoding).encode(to_encoding)
                    os.rename(os.path.join(root, f), os.path.join(root, fnew))
                    print 'renamed', f, '\n ->', fnew, ' in dir:', root
开发者ID:steveyen,项目名称:moingo,代码行数:23,代码来源:12_to_13_mig10.py

示例15: init_dest

 def init_dest(self):
     try:
         os.makedirs(self.ddata)
     except:
         pass
     os.makedirs(opj(self.ddata, "pages"))
     os.makedirs(opj(self.ddata, "user"))
     copy_dir(opj(self.sdata, "plugin"), opj(self.ddata, "plugin"))
     copy_file(opj(self.sdata, "intermap.txt"), opj(self.ddata, "intermap.txt"))
开发者ID:Opngate,项目名称:moinmoin,代码行数:9,代码来源:_conv160.py


注:本文中的MoinMoin.script.migration.migutil.opj函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。