Permalink
Browse files

remove unused imports, some code style

  • Loading branch information...
1 parent 06b1e9e commit 9388afd3189edee1e3b66d10578e2d71f90c1a8e @hellysmile hellysmile committed Jan 8, 2013
Showing with 52 additions and 66 deletions.
  1. +52 −66 lib/fpm/package/pyfpm/get_metadata.py
@@ -1,76 +1,62 @@
from distutils.core import Command
-import re
-import time
import pkg_resources
try:
- import json
-except ImportError:
import simplejson as json
+except ImportError:
+ import json
+
# Note, the last time I coded python daily was at Google, so it's entirely
# possible some of my techniques below are outdated or bad.
# If you have fixes, let me know.
-
class get_metadata(Command):
- description = "get package metadata"
- user_options = []
-
- def initialize_options(self):
- pass
- # def initialize_options
-
- def finalize_options(self):
- pass
- # def finalize_options
-
- def run(self):
- #print type(self.distribution)
- #for i in sorted(dir(self.distribution)):
- #if i.startswith("_"):
- #continue
- ###print "%s: %r" % (i, self.__getattr__(i))
- #print "%s" % i
-
- data = {
- "name": self.distribution.get_name(),
- "version": self.distribution.get_version(),
- "author": "%s <%s>" % (self.distribution.get_author(),
- self.distribution.get_author_email()),
- "description": self.distribution.get_description(),
- "license": self.distribution.get_license(),
- "url": self.distribution.get_url(),
- }
-
- # If there are python C/extension modules, we'll want to build a native
- # arch package.
- if self.distribution.has_ext_modules():
- data["architecture"] = "native"
- else:
- data["architecture"] = "all"
- # end if
-
- final_deps = []
- if getattr(self.distribution, 'install_requires', None):
- for dep in pkg_resources.parse_requirements(self.distribution.install_requires):
- # add all defined specs to the dependecy list separately.
- if dep.specs:
- for operator, version in dep.specs:
- final_deps.append("%s %s %s" % (
- dep.project_name,
- "=" if operator == "==" else operator,
- version
- ))
- else:
- final_deps.append(dep.project_name)
-
- data["dependencies"] = final_deps
-
- #print json.dumps(data, indent=2)
- if hasattr(json, 'dumps'):
- print(json.dumps(data, indent=2))
- else:
- # For Python 2.5 and Debian's python-json
- print(json.write(data))
- # def run
-# class list_dependencies
+ description = "get package metadata"
+ user_options = []
+
+ def initialize_options(self):
+ pass
+
+ def finalize_options(self):
+ pass
+
+ def run(self):
+ data = {
+ "name": self.distribution.get_name(),
+ "version": self.distribution.get_version(),
+ "author": "%s <%s>" % (
+ self.distribution.get_author(),
+ self.distribution.get_author_email()
+ ),
+ "description": self.distribution.get_description(),
+ "license": self.distribution.get_license(),
+ "url": self.distribution.get_url(),
+ }
+
+ if self.distribution.has_ext_modules():
+ data["architecture"] = "native"
+ else:
+ data["architecture"] = "all"
+
+ final_deps = []
+ if getattr(self.distribution, 'install_requires', None):
+ for dep in pkg_resources.parse_requirements(
+ self.distribution.install_requires):
+ # add all defined specs to the dependecy list separately.
+ if dep.specs:
+ for operator, version in dep.specs:
+ final_deps.append("%s %s %s" % (
+ dep.project_name,
+ (lambda x: "=" if x == "==" else x)(operator),
+ version
+ ))
+ else:
+ final_deps.append(dep.project_name)
+
+ data["dependencies"] = final_deps
+
+ if hasattr(json, 'dumps'):
+ print(json.dumps(data, indent=2))
+ else:
+ # For Python 2.5 and Debian's python-json
+ print(json.write(data))

0 comments on commit 9388afd

Please sign in to comment.