def writepy(self, pathname, basename = "<STR_LIT>"):
dir, name = os.path.split(pathname)<EOL>if os.path.isdir(pathname):<EOL><INDENT>initname = os.path.join(pathname, "<STR_LIT>")<EOL>if os.path.isfile(initname):<EOL><INDENT>if basename:<EOL><INDENT>basename = "<STR_LIT>" % (basename, name)<EOL><DEDENT>else:<EOL><INDENT>basename = name<EOL><DEDENT>if self.debug:<EOL><INDENT>print("<STR_LIT>", pathname, "<STR_LIT>", basename)<EOL><DEDENT>fname, arcname = self._get_codename(initname[<NUM_LIT:0>:-<NUM_LIT:3>], basename)<EOL>if self.debug:<EOL><INDENT>print("<STR_LIT>", arcname)<EOL><DEDENT>self.write(fname, arcname)<EOL>dirlist = os.listdir(pathname)<EOL>dirlist.remove("<STR_LIT>")<EOL>for filename in dirlist:<EOL><INDENT>path = os.path.join(pathname, filename)<EOL>root, ext = os.path.splitext(filename)<EOL>if os.path.isdir(path):<EOL><INDENT>if os.path.isfile(os.path.join(path, "<STR_LIT>")):<EOL><INDENT>self.writepy(path, basename)  <EOL><DEDENT><DEDENT>elif ext == "<STR_LIT>":<EOL><INDENT>fname, arcname = self._get_codename(path[<NUM_LIT:0>:-<NUM_LIT:3>],<EOL>basename)<EOL>if self.debug:<EOL><INDENT>print("<STR_LIT>", arcname)<EOL><DEDENT>self.write(fname, arcname)<EOL><DEDENT><DEDENT><DEDENT>else:<EOL><INDENT>if self.debug:<EOL><INDENT>print("<STR_LIT>", pathname)<EOL><DEDENT>for filename in os.listdir(pathname):<EOL><INDENT>path = os.path.join(pathname, filename)<EOL>root, ext = os.path.splitext(filename)<EOL>if ext == "<STR_LIT>":<EOL><INDENT>fname, arcname = self._get_codename(path[<NUM_LIT:0>:-<NUM_LIT:3>],<EOL>basename)<EOL>if self.debug:<EOL><INDENT>print("<STR_LIT>", arcname)<EOL><DEDENT>self.write(fname, arcname)<EOL><DEDENT><DEDENT><DEDENT><DEDENT>else:<EOL><INDENT>if pathname[-<NUM_LIT:3>:] != "<STR_LIT>":<EOL><INDENT>raise RuntimeError('<STR_LIT>')<EOL><DEDENT>fname, arcname = self._get_codename(pathname[<NUM_LIT:0>:-<NUM_LIT:3>], basename)<EOL>if self.debug:<EOL><INDENT>print("<STR_LIT>", arcname)<EOL><DEDENT>self.write(fname, arcname)<EOL><DEDENT>
Add all files from "pathname" to the ZIP archive.

        If pathname is a package directory, search the directory and
        all package subdirectories recursively for all *.py and enter
        the modules into the archive.  If pathname is a plain
        directory, listdir *.py and enter all modules.  Else, pathname
        must be a Python *.py file and the module will be put into the
        archive.  Added modules are always module.pyo or module.pyc.
        This method will compile the module.py into module.pyc if
        necessary.