Esempio n. 1
0
 def as_text (self, key, filename = "", plist = [], encoding = None) :
     pipe   = sos.popen  (self.command (key, filename, plist), "r")
     body   = pipe.read  ()
     pipe.close ()
     if encoding is not None :
         body = pyk.decoded (body, encoding)
     result = body.split ("\n")
     return result
Esempio n. 2
0
 def as_text (self, key, filename = "", plist = [], encoding = None) :
     pipe   = sos.popen  (self.command (key, filename, plist), "r")
     body   = pipe.read  ()
     pipe.close ()
     if encoding is not None :
         body = pyk.decoded (body, encoding)
     result = body.split ("\n")
     return result
Esempio n. 3
0
 def content_type (self) :
     result = self.__super.content_type
     if result == "application/octet-stream" :
         pipe = sos.popen     ("file -i %s" % (self._temp_body (), ), "r")
         f_result = pipe.read ()
         pipe.close           ()
         pat = self._file_result_pattern
         if pat.match (f_result) :
             result = pat.type
             if pat.charset :
                 self._charset = pat.charset
     elif result == "application/python" :
         if self.filename.endswith (".py") :
             result = "text/x-python"
     return result
Esempio n. 4
0
 def content_type(self):
     result = self.__super.content_type
     if result == "application/octet-stream":
         pipe = sos.popen("file -i %s" % (self._temp_body(), ), "r")
         f_result = pipe.read()
         pipe.close()
         pat = self._file_result_pattern
         if pat.match(f_result):
             result = pat.type
             if pat.charset:
                 self._charset = pat.charset
     elif result == "application/python":
         if self.filename.endswith(".py"):
             result = "text/x-python"
     return result
Esempio n. 5
0
 def as_text (self, key, filename = "", plist = []) :
     pipe   = sos.popen (self.command (key, filename, plist), "r")
     result = pipe.read ().split ("\n")
     pipe.close ()
     return result