コード例 #1
0
ファイル: res.py プロジェクト: team1201/tbbl
    def _commonProcess(self, dirList, souName, outName=None):
        print_sep('\nStart to process %s in directory [%s].'
                %(dirList, souName), True, 40)
        default, special = self._getSpecialDir(souName)
        if not default:
            return
        if not outName:
            outName = souName
        # User don't provide any files.
        if len(dirList) == 0:
            dirList = list(list_dir(default))
            # Some dir maybe in specialDir but not in defaultDir.
            # Merge them into dirList
            if special:
                specialList = list(list_dir(special))
                if specialList:
                    dirList = list(set(dirList+specialList))
            if len(dirList) == 0:
                slog.error('The directory [%s] is empty.'%default)
                return
        outputDir = self.conf.getClientPath('res', outName)
        self._rebuildDir(outputDir)

        self._mergeSpecial(dirList, outputDir, default, special)
        print_sep('Process %s in directory [%s] has done.'
                %(dirList, souName), False, 40)
コード例 #2
0
    def plst(self, plist):
        print_sep('Start to process %s in directory plst.' % plist, True, 40)
        default, special = self._getSpecialDir('plst')
        if not default:
            return
        if len(plist) == 0:
            plist = list_dir(default)
        outputDir = self.conf.getClientPath('res', 'plst')
        self._rebuildDir(outputDir)
        sourceDir = default

        tmpDir = None
        if special:
            tmpDir = self._merge2Tmp(default, special, plist)
            plist = list_dir(tmpDir)
            sourceDir = tmpDir
        print_sep('Start to convert spritesheet.')
        for dir_name in plist:
            self._convertSS(sourceDir, outputDir, dir_name,
                            self.args.disable_rotation)
        print_sep('Spritsheet converting has done.', False)
        if tmpDir:
            slog.info('Remove temporary directory [%s].' % tmpDir)
            shutil.rmtree(tmpDir)
        print_sep('Process %s in directory plst has done.' % list(plist),
                  False, 40)
コード例 #3
0
ファイル: res.py プロジェクト: team1201/tbbl
    def plst(self, plist):
        print_sep('Start to process %s in directory plst.'
                %plist, True, 40)
        default, special = self._getSpecialDir('plst')
        if not default:
            return
        if len(plist) == 0:
            plist = list_dir(default)
        outputDir = self.conf.getClientPath('res', 'plst')
        self._rebuildDir(outputDir)
        sourceDir = default

        tmpDir = None
        if special:
            tmpDir = self._merge2Tmp(default, special, plist)
            plist = list_dir(tmpDir)
            sourceDir = tmpDir
        print_sep('Start to convert spritesheet.')
        for dir_name in plist:
            self._convertSS(sourceDir, outputDir, dir_name, self.args.disable_rotation)
        print_sep('Spritsheet converting has done.', False)
        if tmpDir:
            slog.info('Remove temporary directory [%s].'%tmpDir)
            shutil.rmtree(tmpDir)
        print_sep('Process %s in directory plst has done.'
                %list(plist), False, 40)
コード例 #4
0
    def _commonProcess(self, dirList, souName, outName=None):
        print_sep(
            '\nStart to process %s in directory [%s].' % (dirList, souName),
            True, 40)
        default, special = self._getSpecialDir(souName)
        if not default:
            return
        if not outName:
            outName = souName
        # User don't provide any files.
        if len(dirList) == 0:
            dirList = list(list_dir(default))
            # Some dir maybe in specialDir but not in defaultDir.
            # Merge them into dirList
            if special:
                specialList = list(list_dir(special))
                if specialList:
                    dirList = list(set(dirList + specialList))
            if len(dirList) == 0:
                slog.error('The directory [%s] is empty.' % default)
                return
        outputDir = self.conf.getClientPath('res', outName)
        self._rebuildDir(outputDir)

        self._mergeSpecial(dirList, outputDir, default, special)
        print_sep(
            'Process %s in directory [%s] has done.' % (dirList, souName),
            False, 40)
コード例 #5
0
ファイル: res.py プロジェクト: team1201/tbbl
 def initDef(self):
     for afile in list_dir(self._aniDir, includeFile=True):
         if os.path.isdir(afile):
             self._piecedirs.append(afile)
         elif afile != 'ani_def_sample.lua' \
         and afile.startswith('ani_def_') \
         and afile.endswith('.lua') :
             self._def.append(afile)
コード例 #6
0
def _dirfolder(adir):
    global lineno
    names = list_dir(adir)

    for name in names:
        if name.endswith('.md'):
            lineno = 0
            proc(os.path.join(adir, name))
コード例 #7
0
 def getAnisInSpriteSheet(self):
     if not self._spritesheets:
         sp = []
         for f in list_dir(self._aniDir):
             if f.startswith('ani_') and f.endswith('.plist'):
                 sp.append(os.path.splitext(f)[0])
         self._spritesheets = sp
     return self._spritesheets
コード例 #8
0
ファイル: res.py プロジェクト: team1201/tbbl
 def getAnisInSpriteSheet(self):
     if not self._spritesheets:
         sp = []
         for f in list_dir(self._aniDir):
             if f.startswith('ani_') and f.endswith('.plist'):
                 sp.append(os.path.splitext(f)[0])
         self._spritesheets = sp
     return self._spritesheets
コード例 #9
0
 def initDef(self):
     for afile in list_dir(self._aniDir, includeFile=True):
         if os.path.isdir(afile):
             self._piecedirs.append(afile)
         elif afile != 'ani_def_sample.lua' \
         and afile.startswith('ani_def_') \
         and afile.endswith('.lua') :
             self._def.append(afile)
コード例 #10
0
ファイル: res.py プロジェクト: team1201/tbbl
 def _mergeSpecial(self, dirList, outputDir, default, special=None):
     if special:
         special_list = list(list_dir(special))
     # Copy default directory list.
     for adir in dirList:
         self._copyDir(default,  outputDir, adir)
         # Copy special directory list.
         if special and (adir in special_list):
             self._copyDir(special,  outputDir, adir)
コード例 #11
0
 def _mergeSpecial(self, dirList, outputDir, default, special=None):
     if special:
         special_list = list(list_dir(special))
     # Copy default directory list.
     for adir in dirList:
         self._copyDir(default, outputDir, adir)
         # Copy special directory list.
         if special and (adir in special_list):
             self._copyDir(special, outputDir, adir)
コード例 #12
0
 def get_new_draft(self, name=None):
     draftnames = list(list_dir(self.get_path(self.directory.draft)))
     draftfile, draftname = None, None
     if name:
         draftfile, draftname = self.get_draft(name)
         if draftname in draftnames:
             raise BlogError('The draft file "%s" is already existence!' %
                             draftname)
     else:
         name = 1
         draftfile, draftname = self.get_draft(name)
         while os.path.exists(draftfile):
             name += 1
             draftfile, draftname = self.get_draft(name)
     return draftfile, draftname
コード例 #13
0
ファイル: base.py プロジェクト: run100/blog
 def get_new_draft(self, name=None):
     draftnames = list(list_dir(self.get_path(self.directory.draft)))
     draftfile, draftname = None, None
     if name:
         draftfile, draftname = self.get_draft(name)
         if draftname in draftnames:
             raise BlogError('The draft file "%s" is already existence!'%
                     draftname)
     else:
         name = 1
         draftfile, draftname = self.get_draft(name)
         while os.path.exists(draftfile):
             name += 1
             draftfile, draftname = self.get_draft(name)
     return draftfile, draftname
コード例 #14
0
ファイル: admin.py プロジェクト: team1201/tbbl
 def toluaauto(self, bindType):
     if not self.isAdmin():
         return
     inifile = None
     cwd = self.conf.getDistPath('tolua', 'auto')
     for f in list_dir(cwd):
         if f.endswith('.ini') \
         and f.startswith('cocos2dx_') \
         and bindType in f.lower():
             inifile = f
     if inifile:
         xarg = [self.conf.getExe('python2'), 'genbindings.py', inifile]
         slog.warning('toluaauto args: %s', xarg)
         slog.warning('toluaauto target path: %s', cwd)
         py = subprocess.Popen(xarg, cwd=cwd)
         py.wait()
     else:
         slog.error('Cannot find a file named %s!'%bindType)
コード例 #15
0
ファイル: admin.py プロジェクト: team1201/tbbl
 def toluamanual(self, bindType):
     if not self.isAdmin():
         return
     toluafile = None
     cwd = self.conf.getDistPath('tolua', 'manual')
     for f in list_dir(cwd):
         if f.endswith('.tolua') \
         and bindType in f.lower():
             toluafile = f
     if toluafile:
         bindName = os.path.join(self.conf.getDistPath('tolua', 'manual'), toluafile)
         php = self.conf.getBin('quick/lib/compile_luabinding.php')
         xarg = [self.conf.getPHP(), php, '-pfx', 'cc', '-d', 
                 self.conf.getDistPath('runtime-src', 'Classes',
                     'lua-bindings', 'manual'), bindName]
         subprocess.call(xarg)
     else:
         slog.error('Cannot find a file named %s!'%bindType)
コード例 #16
0
ファイル: admin.py プロジェクト: zrong/tbbl
 def toluaauto(self, bindType):
     if not self.isAdmin():
         return
     inifile = None
     cwd = self.conf.getDistPath('tolua', 'auto')
     for f in list_dir(cwd):
         if f.endswith('.ini') \
         and f.startswith('cocos2dx_') \
         and bindType in f.lower():
             inifile = f
     if inifile:
         xarg = [self.conf.getExe('python2'), 'genbindings.py', inifile]
         slog.warning('toluaauto args: %s', xarg)
         slog.warning('toluaauto target path: %s', cwd)
         py = subprocess.Popen(xarg, cwd=cwd)
         py.wait()
     else:
         slog.error('Cannot find a file named %s!' % bindType)
コード例 #17
0
ファイル: res.py プロジェクト: team1201/tbbl
 def generateADef(self, ani):
     if not self._gendef:
         return
     pieceNum = len(list(list_dir(os.path.join(self._aniDir, ani))))
     sub = {
         'spritesheets':[ani],
         'animations'  :[{ 
             'name':ani,
             'delay_per_unit':0.042,
             'loops':1,
             'restore_original_frame':'false', 
             'range':{'start':1,'end':pieceNum},
             }],
     }
     # animation file is started by "ani_", main name starts from index 4.
     defName = 'ani_def_%s.lua'%ani[4:]
     defFile = self._conf.getClientPath('res', 'ani', defName)
     write_by_jinja(self._conf.getJinjaTempl('ani_def.lua'), defFile, sub)
     slog.info('Generate a ani_def file: %s.'%defFile)
コード例 #18
0
ファイル: admin.py プロジェクト: zrong/tbbl
 def toluamanual(self, bindType):
     if not self.isAdmin():
         return
     toluafile = None
     cwd = self.conf.getDistPath('tolua', 'manual')
     for f in list_dir(cwd):
         if f.endswith('.tolua') \
         and bindType in f.lower():
             toluafile = f
     if toluafile:
         bindName = os.path.join(self.conf.getDistPath('tolua', 'manual'),
                                 toluafile)
         php = self.conf.getBin('quick/lib/compile_luabinding.php')
         xarg = [
             self.conf.getPHP(), php, '-pfx', 'cc', '-d',
             self.conf.getDistPath('runtime-src', 'Classes', 'lua-bindings',
                                   'manual'), bindName
         ]
         subprocess.call(xarg)
     else:
         slog.error('Cannot find a file named %s!' % bindType)
コード例 #19
0
 def generateADef(self, ani):
     if not self._gendef:
         return
     pieceNum = len(list(list_dir(os.path.join(self._aniDir, ani))))
     sub = {
         'spritesheets': [ani],
         'animations': [{
             'name': ani,
             'delay_per_unit': 0.042,
             'loops': 1,
             'restore_original_frame': 'false',
             'range': {
                 'start': 1,
                 'end': pieceNum
             },
         }],
     }
     # animation file is started by "ani_", main name starts from index 4.
     defName = 'ani_def_%s.lua' % ani[4:]
     defFile = self._conf.getClientPath('res', 'ani', defName)
     write_by_jinja(self._conf.getJinjaTempl('ani_def.lua'), defFile, sub)
     slog.info('Generate a ani_def file: %s.' % defFile)
コード例 #20
0
 def _write_analytic(self):
     if args.name:
         match = re.match(r'^(\d*)-(\d*)$', args.name)
         a, b = None, None
         if match:
             if match.group(1):
                 a = int(match.group(1))
             if match.group(2):
                 b = int(match.group(2))
             dirlist = []
             for f in list_dir(conf.get_path(args.dirname)):
                 if not f.endswith('.md'):
                     continue
                 fname = int(f.split('.')[0])
                 if a != None:
                     if fname < a:
                         continue
                 if b != None:
                     if fname > b:
                         continue
                 dirlist.append(fname)
             abc = sorted(dirlist)
             slog.info('\n'.join([str(item) for item in sorted(dirlist)]))
コード例 #21
0
ファイル: write.py プロジェクト: run100/blog
 def _write_analytic(self):
     if args.name:
         match = re.match(r'^(\d*)-(\d*)$', args.name)
         a,b = None,None
         if match:
             if match.group(1):
                 a = int(match.group(1))
             if match.group(2):
                 b = int(match.group(2))
             dirlist = []
             for f in list_dir(conf.get_path(args.dirname)):
                 if not f.endswith('.md'):
                     continue
                 fname = int(f.split('.')[0])
                 if a != None:
                     if fname < a:
                         continue
                 if b != None:
                     if fname > b:
                         continue
                 dirlist.append(fname)
             abc = sorted(dirlist)
             slog.info('\n'.join([str(item) for item in sorted(dirlist)]))
コード例 #22
0
ファイル: res.py プロジェクト: team1201/tbbl
 def getAniDefs(self):
     anidef = []
     for f in list_dir(self._aniDir):
         if f.startswith('ani_def_') and f.endswith('.lua'):
             anidef.append(f)
     return anidef
コード例 #23
0
ファイル: testbase.py プロジェクト: Tiger6688/python
def test_list_dir():
    assert len(list(base.list_dir(workDir))) > 0
コード例 #24
0
ファイル: res.py プロジェクト: team1201/tbbl
 def getPieceDirs(self):
     if not self._piecedirs:
         self._piecedirs = list(list_dir(self._aniDir, include_file=False))
     return self._piecedirs
コード例 #25
0
ファイル: testbase.py プロジェクト: Tiger6688/python
def test_list_dir():
    assert len(list(base.list_dir(workDir))) > 0
コード例 #26
0
 def getAniDefs(self):
     anidef = []
     for f in list_dir(self._aniDir):
         if f.startswith('ani_def_') and f.endswith('.lua'):
             anidef.append(f)
     return anidef
コード例 #27
0
 def getPieceDirs(self):
     if not self._piecedirs:
         self._piecedirs = list(list_dir(self._aniDir, include_file=False))
     return self._piecedirs