Server IP : 103.119.228.120 / Your IP : 13.58.207.196 Web Server : Apache System : Linux v8.techscape8.com 3.10.0-1160.119.1.el7.tuxcare.els2.x86_64 #1 SMP Mon Jul 15 12:09:18 UTC 2024 x86_64 User : nobody ( 99) PHP Version : 5.6.40 Disable Function : shell_exec,symlink,system,exec,proc_get_status,proc_nice,proc_terminate,define_syslog_variables,syslog,openlog,closelog,escapeshellcmd,passthru,ocinum cols,ini_alter,leak,listen,chgrp,apache_note,apache_setenv,debugger_on,debugger_off,ftp_exec,dl,dll,myshellexec,proc_open,socket_bind,proc_close,escapeshellarg,parse_ini_filepopen,fpassthru,exec,passthru,escapeshellarg,escapeshellcmd,proc_close,proc_open,ini_alter,popen,show_source,proc_nice,proc_terminate,proc_get_status,proc_close,pfsockopen,leak,apache_child_terminate,posix_kill,posix_mkfifo,posix_setpgid,posix_setsid,posix_setuid,dl,symlink,shell_exec,system,dl,passthru,escapeshellarg,escapeshellcmd,myshellexec,c99_buff_prepare,c99_sess_put,fpassthru,getdisfunc,fx29exec,fx29exec2,is_windows,disp_freespace,fx29sh_getupdate,fx29_buff_prepare,fx29_sess_put,fx29shexit,fx29fsearch,fx29ftpbrutecheck,fx29sh_tools,fx29sh_about,milw0rm,imagez,sh_name,myshellexec,checkproxyhost,dosyayicek,c99_buff_prepare,c99_sess_put,c99getsource,c99sh_getupdate,c99fsearch,c99shexit,view_perms,posix_getpwuid,posix_getgrgid,posix_kill,parse_perms,parsesort,view_perms_color,set_encoder_input,ls_setcheckboxall,ls_reverse_all,rsg_read,rsg_glob,selfURL,dispsecinfo,unix2DosTime,addFile,system,get_users,view_size,DirFiles,DirFilesWide,DirPrintHTMLHeaders,GetFilesTotal,GetTitles,GetTimeTotal,GetMatchesCount,GetFileMatchesCount,GetResultFiles,fs_copy_dir,fs_copy_obj,fs_move_dir,fs_move_obj,fs_rmdir,SearchText,getmicrotime MySQL : ON | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /usr/local/ssl/local/ssl/local/ssl/lib64/python2.7/ |
Upload File : |
"""A readline()-style interface to the parts of a multipart message. The MultiFile class makes each part of a multipart message "feel" like an ordinary file, as long as you use fp.readline(). Allows recursive use, for nested multipart messages. Probably best used together with module mimetools. Suggested use: real_fp = open(...) fp = MultiFile(real_fp) "read some lines from fp" fp.push(separator) while 1: "read lines from fp until it returns an empty string" (A) if not fp.next(): break fp.pop() "read remaining lines from fp until it returns an empty string" The latter sequence may be used recursively at (A). It is also allowed to use multiple push()...pop() sequences. If seekable is given as 0, the class code will not do the bookkeeping it normally attempts in order to make seeks relative to the beginning of the current file part. This may be useful when using MultiFile with a non- seekable stream object. """ from warnings import warn warn("the multifile module has been deprecated since Python 2.5", DeprecationWarning, stacklevel=2) del warn __all__ = ["MultiFile","Error"] class Error(Exception): pass class MultiFile: seekable = 0 def __init__(self, fp, seekable=1): self.fp = fp self.stack = [] self.level = 0 self.last = 0 if seekable: self.seekable = 1 self.start = self.fp.tell() self.posstack = [] def tell(self): if self.level > 0: return self.lastpos return self.fp.tell() - self.start def seek(self, pos, whence=0): here = self.tell() if whence: if whence == 1: pos = pos + here elif whence == 2: if self.level > 0: pos = pos + self.lastpos else: raise Error, "can't use whence=2 yet" if not 0 <= pos <= here or \ self.level > 0 and pos > self.lastpos: raise Error, 'bad MultiFile.seek() call' self.fp.seek(pos + self.start) self.level = 0 self.last = 0 def readline(self): if self.level > 0: return '' line = self.fp.readline() # Real EOF? if not line: self.level = len(self.stack) self.last = (self.level > 0) if self.last: raise Error, 'sudden EOF in MultiFile.readline()' return '' assert self.level == 0 # Fast check to see if this is just data if self.is_data(line): return line else: # Ignore trailing whitespace on marker lines marker = line.rstrip() # No? OK, try to match a boundary. # Return the line (unstripped) if we don't. for i, sep in enumerate(reversed(self.stack)): if marker == self.section_divider(sep): self.last = 0 break elif marker == self.end_marker(sep): self.last = 1 break else: return line # We only get here if we see a section divider or EOM line if self.seekable: self.lastpos = self.tell() - len(line) self.level = i+1 if self.level > 1: raise Error,'Missing endmarker in MultiFile.readline()' return '' def readlines(self): list = [] while 1: line = self.readline() if not line: break list.append(line) return list def read(self): # Note: no size argument -- read until EOF only! return ''.join(self.readlines()) def next(self): while self.readline(): pass if self.level > 1 or self.last: return 0 self.level = 0 self.last = 0 if self.seekable: self.start = self.fp.tell() return 1 def push(self, sep): if self.level > 0: raise Error, 'bad MultiFile.push() call' self.stack.append(sep) if self.seekable: self.posstack.append(self.start) self.start = self.fp.tell() def pop(self): if self.stack == []: raise Error, 'bad MultiFile.pop() call' if self.level <= 1: self.last = 0 else: abslastpos = self.lastpos + self.start self.level = max(0, self.level - 1) self.stack.pop() if self.seekable: self.start = self.posstack.pop() if self.level > 0: self.lastpos = abslastpos - self.start def is_data(self, line): return line[:2] != '--' def section_divider(self, str): return "--" + str def end_marker(self, str): return "--" + str + "--"