Ned Batchelder avatar Ned Batchelder committed 7c2c439

Parameterize the behavior. Now it's presentable.

Comments (0)

Files changed (2)

 	-rm -f setuptools-*.egg
 
 kit:
-	python setup.py develop sdist --keep-temp --formats=gztar fixtar
+	python setup.py develop sdist --keep-temp --formats=gztar fixtar -oned -gfixtar --clean
 
 pypi:
 	python setup.py register

setuptools_fixtar/fixtar.py

 
     description = "Re-pack the tar file to have correct permissions."
 
-    user_options = []
+    user_options = [
+        ('owner=', 'o',
+         "Name of the owner of the files"),
+        ('group=', 'g',
+         "Name of the group of the files"),
+        ('clean', 'c',
+         "Clean up the sdist files after fixing the tar file"),
+        ]
+
+    boolean_options = ['clean']
 
     def initialize_options(self):
-        """Required by Command, even though I have nothing to add."""
-        pass
+        """Set the options to their defaults."""
+        self.owner = "owner"
+        self.group = "group"
+        self.clean = False
 
     def finalize_options(self):
-        """Required by Command, even though I have nothing to add."""
+        """Fix up any dependencies among options."""
         pass
 
     def run(self):
                 otarinfo.mode = 0755
             otarinfo.uid = 100
             otarinfo.gid = 100
-            otarinfo.uname = "ned"
-            otarinfo.gname = "coverage"
+            otarinfo.uname = self.owner
+            otarinfo.gname = self.group
             otar.addfile(otarinfo, itar.extractfile(itarinfo))
         itar.close()
         otar.close()
 
-        # To make this work, sdist has to be run with the --keep-temp option.
-        # But the clean command doesn't clean up the temp directory.
-        # Delete it here.
-        shutil.rmtree(the_dir)
+        if self.clean:
+            # To make this work, sdist has to be run with the --keep-temp option.
+            # But the clean command doesn't clean up the temp directory.
+            # Delete it here.
+            shutil.rmtree(the_dir)
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.