Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

remove unused imports, some code style #333

Merged
merged 2 commits into from

2 participants

@hellysmile

No description provided.

lib/fpm/package/pyfpm/get_metadata.py
((8 lines not shown))
import simplejson as json
+except ImportError:
+ import json
@jordansissel Owner

why flip the order of simplejson and json?

that was a mistake

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
lib/fpm/package/pyfpm/get_metadata.py
((18 lines not shown))
class get_metadata(Command):
- description = "get package metadata"
- user_options = []
-
- def initialize_options(self):
- pass
- # def initialize_options
+ description = "get package metadata"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@jordansissel

I don't follow PEP8 myself (it has lots of silly suggestions)

I also don't have the energy to read and further decipher the unclear parts of PEP8, so I'm just going to eyeball this and give it a thumbs up

2013-01-10-141458

@jordansissel jordansissel merged commit e5b8c59 into from
@jordansissel

Thanks for helping improve fpm! :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jan 8, 2013
  1. @hellysmile
  2. @hellysmile

    fix json imports

    hellysmile authored
This page is out of date. Refresh to see the latest.
Showing with 50 additions and 64 deletions.
  1. +50 −64 lib/fpm/package/pyfpm/get_metadata.py
View
114 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
+
# 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))
Something went wrong with that request. Please try again.