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


Python Sys.getFileExt方法代码示例

本文整理汇总了Python中psr.sys.Sys.getFileExt方法的典型用法代码示例。如果您正苦于以下问题:Python Sys.getFileExt方法的具体用法?Python Sys.getFileExt怎么用?Python Sys.getFileExt使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在psr.sys.Sys的用法示例。


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

示例1: buildFile

# 需要导入模块: from psr.sys import Sys [as 别名]
# 或者: from psr.sys.Sys import getFileExt [as 别名]
    def buildFile(self, fromPath, label="", catg=""):
        count = self.getCountParts(fromPath)
        Sys.pwlog([(" Get Hash... ", Const.CLZ_7, True)])
        sha256 = hash_sha256_file(fromPath)
        Sys.pwlog([(" hash : ", Const.CLZ_0), (sha256, Const.CLZ_2, True), (" Build File...", Const.CLZ_0, True)])

        kg = KeyGen(128)
        size = Sys.getsize(fromPath)
        row = self.idxu.index.get(sha256)
        if row is None:
            if label == "":
                label, ext = Sys.getFileExt(Sys.basename(fromPath))
            else:
                label, ext = Sys.getFileExt(label)
            if catg == "":
                catg = self.idxu.index.getAutoCatg(ext)
            size = Sys.getsize(fromPath)

            Sys.pwlog(
                [
                    (" Splitting ", Const.CLZ_1),
                    (label, Const.CLZ_7),
                    (ext, Const.CLZ_7),
                    (" (", Const.CLZ_0),
                    (Sys.readableBytes(size), Const.CLZ_3),
                    (")", Const.CLZ_0, True),
                ]
            )
            Sys.cli_emit_progress(0)
            Sys.sleep(0.2)
            km = Kirmah(kg.key)
            km.DIR_OUTBOX = self.outbox
            # hlst genetate with sha256
            hlst = km.ck.getHashList(sha256, int(count), True)
            usr = self.idxu.conf.get("name", "infos")
            ownerHash = self.idxu.mb.getHashName(usr)
            km.split(fromPath, hlst)
            Sys.pwlog([(" done ", Const.CLZ_2, True)])
            row = [kg.key, label, ext, count, catg, hlst, usr, ownerHash, sha256, size]
            self.backupAddMap(row)

        else:

            Sys.pwlog(
                [
                    (" File Already exist ! ", Const.CLZ_1, True),
                    (" id : ".rjust(10, " "), Const.CLZ_0),
                    (str(row[ImpraIndex.UID]), Const.CLZ_1, True),
                    (" label : ".rjust(10, " "), Const.CLZ_0),
                    (row[ImpraIndex.LABEL], Const.CLZ_3, True),
                ]
            )

            row = None
        return row
开发者ID:pluie-org,项目名称:imprastorage,代码行数:57,代码来源:core.py

示例2: setDestFile

# 需要导入模块: from psr.sys import Sys [as 别名]
# 或者: from psr.sys.Sys import getFileExt [as 别名]
 def setDestFile(self, path):
     """"""
     if path is not None :
         self.dst = ''.join([path, Sys.sep, '' if self.src is None else Sys.basename(self.src)])
         if self.encmode:
             self.dst = ''.join([self.dst, Kirmah.EXT if not self.splitmode else Kirmah.EXT_TARK])
         else :
             self.dst, ext = Sys.getFileExt(self.dst)
             if not ext == (Kirmah.EXT if not self.splitmode else Kirmah.EXT_TARK):
                 self.dst += ext
         #~ if Io.file_exists(self.dst):
             #~ raise FileNeedOverwriteException(self.dst)
     else : self.dst = None
开发者ID:pluie-org,项目名称:imprastorage,代码行数:15,代码来源:app.py

示例3: edit

# 需要导入模块: from psr.sys import Sys [as 别名]
# 或者: from psr.sys.Sys import getFileExt [as 别名]
 def edit(self, key, label=None, category=None):
     """Get the corresponding key in the index
     :Returns: `tuple` row
     """
     done = False
     row  = self.dic[key]
     r    = list(row)
     if label != None :
         try :
             name, ext = Sys.getFileExt(label)
             r[self.LABEL] = name
             if ext is not '' :
                 r[self.EXT] = ext
         except Exception as e :
             r[self.LABEL] = label
     if category != None :
         r[self.CATG] = category
     self.dic[key] = tuple(r)
     done = row != self.dic[key]
     return done
开发者ID:pluie-org,项目名称:imprastorage,代码行数:22,代码来源:index.py

示例4: onCommandAdd

# 需要导入模块: from psr.sys import Sys [as 别名]
# 或者: from psr.sys.Sys import getFileExt [as 别名]
 def onCommandAdd(self):
     """"""
     if not len(self.a) > 1:
         self.parser.error_cmd((self.a[0] + " command need one argument",), True)
     else:
         vfile = self.a[1]
         if not Io.file_exists(vfile):
             if Sys.isdir(vfile):
                 for f in Sys.listdir(vfile):
                     if not Sys.isdir(f):
                         label, ext = Sys.getFileExt(Sys.basename(f))
                         if self.o.category is None:
                             self.o.category = ""
                         done = self.impst.addFile(vfile + Sys.sep + f, label, self.o.category)
                         if done:
                             self.Cli.printLineSep(Const.LINE_SEP_CHAR, Const.LINE_SEP_LEN)
                             Sys.dprint(" ", end="")
                             Sys.echo(" == OK == ", Sys.Clz.bg2 + Sys.Clz.fgb7)
                             Sys.dprint()
             else:
                 self.parser.error_cmd((self.a[0] + " is not a file or a directory",), True)
         else:
             if not len(self.a) > 2:
                 label = Sys.basename(vfile)
             else:
                 label = self.a[2]
             if self.o.category is None:
                 self.o.category = ""
             Sys.clear()
             self.pheader()
             done = self.impst.addFile(vfile, label, self.o.category)
             if done:
                 self.Cli.printLineSep(Const.LINE_SEP_CHAR, Const.LINE_SEP_LEN)
                 Sys.dprint(" ", end="")
                 Sys.echo(" == OK == ", Sys.Clz.bg2 + Sys.Clz.fgb7)
                 Sys.dprint()
             else:
                 self.Cli.printLineSep(Const.LINE_SEP_CHAR, Const.LINE_SEP_LEN)
                 Sys.dprint(" ", end="")
                 Sys.echo(" == KO == ", Sys.Clz.bg1 + Sys.Clz.fgb7)
                 Sys.dprint()
开发者ID:pluie-org,项目名称:imprastorage,代码行数:43,代码来源:cliapp.py

示例5: on_add_file_set

# 需要导入模块: from psr.sys import Sys [as 别名]
# 或者: from psr.sys.Sys import getFileExt [as 别名]
 def on_add_file_set(self, fc, data=None):
     """"""
     fname, ext = Sys.getFileExt( fc.get_filename())
     catg = self.index.getAutoCatg(ext)
     if (self.get('entry2').get_text() == '' or self.get('checkbutton2').get_active()) and catg!='none' :
         self.get('entry2').set_text(catg)
开发者ID:pluie-org,项目名称:imprastorage,代码行数:8,代码来源:gui.py


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