# Path: comm.py
# def echo(*args):
#     sys.stdout.write(" ".join(map(str, args)) + "\n")
#     sys.stdout.flush()
# 
# def U(dat):
#     return dat


import os
import re
import sys
    from httplib import HTTPConnection
    from urllib import quote, unquote
    from urlparse import urlparse
    from http.client import HTTPConnection
    from urllib.parse import quote, unquote, urlparse
from comm import echo, U
        pre = '%sContent-Disposition: form-data; name="%s"' % (pre, name)
        pre = '%s; filename="%s"\r\n' % (pre, fn)
        pre = '%sContent-Type: text/plain\r\n\r\n' % pre
        if py3:
            self.pre = pre.encode("utf8")
        else:
            self.pre = pre
        self.end = ("\r\n--%s--" % bun).encode("ascii")
        self.tal = 0
        self.cnt = 0

    def size(self):
        self.tal = os.fstat(self.f.fileno()).st_size
        return len(self.pre) + self.tal + len(self.end)

    def read(self, bufsize):
        #FIXME, if bufsize < len(self.pre) or bufsize < len(self.end)
        if self.s == 0:
            self.s = 1
            #print '#',
            return self.pre
        if self.s == 1:
            buf = self.f.read(bufsize)
            if buf:
                #print '#',
                self.cnt += len(buf)
                sys.stdout.write("\r%s%0.1f" % (
                                  self.upd, self.cnt * 100.0 / self.tal))
                return buf
            self.s = 2

# Path: comm.py
# def echo(*args):
#     sys.stdout.write(" ".join(map(str, args)) + "\n")
#     sys.stdout.flush()
# 
# def U(dat):
#     return dat


# Path: post.py
import os
import re
import sys
    from httplib import HTTPConnection
    from urllib import quote, unquote
    from urlparse import urlparse
    from http.client import HTTPConnection
    from urllib.parse import quote, unquote, urlparse
from comm import echo, U

        pre = '%sContent-Disposition: form-data; name="%s"' % (pre, name)
        pre = '%s; filename="%s"\r\n' % (pre, fn)
        pre = '%sContent-Type: text/plain\r\n\r\n' % pre
        if py3:
            self.pre = pre.encode("utf8")
        else:
            self.pre = pre
        self.end = ("\r\n--%s--" % bun).encode("ascii")
        self.tal = 0
        self.cnt = 0

    def size(self):
        self.tal = os.fstat(self.f.fileno()).st_size
        return len(self.pre) + self.tal + len(self.end)

    def read(self, bufsize):
        #FIXME, if bufsize < len(self.pre) or bufsize < len(self.end)
        if self.s == 0:
            self.s = 1
            #print '#',
            return self.pre
        if self.s == 1:
            buf = self.f.read(bufsize)
            if buf:
                #print '#',
                self.cnt += len(buf)
                sys.stdout.write("\r%s%0.1f" % (
                                  self.upd, self.cnt * 100.0 / self.tal))
                return buf
            self.s = 2

            echo("")